Skip to content

hostcfgd: Validate RADIUS server fields before creating PAM files - #430

Open
ashutosh-agrawal wants to merge 1 commit into
sonic-net:masterfrom
ashutosh-agrawal:validate-radius-server-entry
Open

hostcfgd: Validate RADIUS server fields before creating PAM files#430
ashutosh-agrawal wants to merge 1 commit into
sonic-net:masterfrom
ashutosh-agrawal:validate-radius-server-entry

Conversation

@ashutosh-agrawal

Copy link
Copy Markdown
Member

What I did

Added validation for the RADIUS server address and authentication port before using the entry to generate RADIUS configuration.

hostcfgd uses 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

  • Validate the server address with ipaddress.ip_address().
  • Require the authentication port to be between 1 and 65535.
  • Skip invalid server entries and log the address and port without logging the configured passkey.
  • Leave valid IPv4 and IPv6 server entries unchanged.

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 -q

Result: 8 passed.

Signed-off-by: Ashutosh Agrawal <ashu@cisco.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants