hostcfgd: Validate RADIUS server fields before creating PAM files - #430
Merged
qiluo-msft merged 3 commits intoSep 25, 2026
Merged
Conversation
Signed-off-by: Ashutosh Agrawal <ashu@cisco.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
qiluo-msft
reviewed
Sep 19, 2026
Signed-off-by: Ashutosh Agrawal <ashu@cisco.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
qiluo-msft
approved these changes
Sep 23, 2026
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Numeric legacy IPv4 forms can bypass validation through the hostname fallback.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
What changed in this PR
Adds RADIUS server address and authentication-port validation before generating PAM configuration.
Changes:
- Validates host and port values, skipping invalid entries.
- Normalizes valid ports and logs rejected entries.
- Adds unit and integration coverage for valid and invalid inputs.
| File | Description |
|---|---|
scripts/hostcfgd |
Adds RADIUS validation and filtering. |
tests/hostcfgd/hostcfgd_radius_test.py |
Tests validation and rendering. |
tests/hostcfgd/test_radius_vectors.py |
Adds invalid server fixtures. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Signed-off-by: Ashutosh Agrawal <ashu@cisco.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What I did
Added validation for the RADIUS server address and authentication port before using the entry to generate RADIUS configuration.
hostcfgduses these fields in the filename for each server’s PAM configuration. It previously assumed that both values were valid. A bad address or port could result in an unexpected filename or an invalid RADIUS configuration.How I did it
ipaddress.ip_address().How I verified it
Added coverage for valid IPv4 and IPv6 addresses, malformed addresses, non-numeric ports, and ports outside the valid range.
python3 -m pytest tests/hostcfgd/hostcfgd_radius_test.py -qResult: 8 passed.