Skip to content

fix(anta.tests): Detect SNMPv3 remote users and align SA178 with revision 1.3 - #1856

Open
carl-baillargeon wants to merge 6 commits into
aristanetworks:mainfrom
carl-baillargeon:fix/sa178-snmp-remote-users
Open

carl-baillargeon wants to merge 6 commits into
aristanetworks:mainfrom
carl-baillargeon:fix/sa178-snmp-remote-users

Conversation

@carl-baillargeon

@carl-baillargeon carl-baillargeon commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

SA178 read SNMPv3 users from show snmp user, which never lists remote users. Devices with only remote users that have an authentication key were reported as not affected.

  • Remote users: the authentication state now comes from the same show running-config | include ^snmp-server user output as the credential-syntax check. The parser handles the optional remote <host> [udp-port <port>] prefix. An unexpected line layout now returns an error instead of being skipped.
  • Revision 1.3:
    • 4.36.2F, 4.35.6M, 4.34.8M and 4.33.10M are now affected.
    • Fixed releases are now 4.36.3M, 4.35.7M, 4.34.9M and 4.33.11M.
  • Hotfix: new SA178HotfixFact. The SWIX only counts on those four releases, and only when it is installed and set to load at boot. Legacy keys still need configure convert new-syntax.
  • The docs overview row is updated.

Verified on vEOS-lab from 4.31.0F to 4.36.3M with local, remote, remote udp-port, IPv6 remote and no-auth users. With remote-only users, main reports not affected and this branch reports affected, with the correct remediation per release.

Fixes #1761

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have run pre-commit for code linting and typing (pre-commit run)
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (tox -e testenv)

Summary by CodeRabbit

  • New Features
    • SA178 assessments now recognize applicable persistent hotfixes and identify conditions mitigated by them.
    • Assessment results show mitigated conditions alongside remaining exposure and remediation guidance.
  • Updates
    • SA178 assessments reflect revised affected and fixed software releases, hotfix applicability, and remediation guidance.
    • SNMPv3 checks now support remote users and configurations with optional ports or IPv6 addresses, and report malformed configuration as unavailable.
    • Updated the SA178 advisory date and ANTA version information.

…sion 1.3

SA178 read SNMPv3 users from 'show snmp user', which never lists remote users, so devices with only remote users were reported not affected. Read the authentication state from the running-config 'snmp-server user' lines instead, and parse the optional 'remote <host> [udp-port <port>]' prefix.

Align SA178 with revision 1.3: new affected range and fixed releases, and the SWIX hotfix for 4.36.2F, 4.35.6M, 4.34.8M and 4.33.10M.

Fixes aristanetworks#1761
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c2f05a47-861e-47aa-a1cc-c0b5968e6ce5
Commits

Reviewing files that changed from the base of the PR and between f7f836b and 5c7bfd7.

Files selected for processing: 3
  • anta/_advisory/findings/models.py
  • anta/tests/advisories/sa_178.py
  • tests/units/anta_tests/advisories/test_sa_178.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The change detects SNMPv3 authentication from running configuration and updates Security Advisory 0178 to account for remote users, persistent hotfixes, and revised release boundaries. Affected results can also report mitigated conditions. Tests cover parsing, advisory assessment, and result rendering.

Changes: SA178 detection and remediation

Layer / File(s) Summary
Parse SNMPv3 authentication from configuration
anta/_advisory/facts/management.py, tests/units/_advisory/facts/test_management.py
SnmpV3AuthenticationFact now reads running-configuration text and derives authentication state from credential syntax. Parsing handles optional remote hosts and UDP ports. Tests cover local, remote, malformed, and no-auth configurations.
Integrate hotfix state and mitigated conditions
anta/_advisory/facts/software.py, anta/tests/advisories/sa_178.py, anta/_advisory/findings/models.py, anta/_advisory/findings/projection.py, docs/security-advisory/tests-overview.md, tests/units/_advisory/facts/test_software.py
SA178 adds a persistent-hotfix fact and uses its state for listed hotfix releases. The advisory’s affected and fixed release boundaries advance by one patch. AffectedResult now stores mitigated conditions, which the projection renders in affected results. Advisory metadata is updated.
Validate detection and assessment outcomes
tests/units/anta_tests/advisories/test_sa_178.py, tests/units/_advisory/findings/test_projection.py
Tests cover revised release boundaries, remote and unauthenticated users, effective and ineffective hotfix states, unavailable facts, remediation, and mitigated-condition rendering.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant SA178
  participant SnmpV3AuthenticationFact
  participant SA178HotfixFact
  participant EOS
  participant _assess_sa178
  SA178->>SnmpV3AuthenticationFact: collect authentication state
  SnmpV3AuthenticationFact->>EOS: read running configuration
  EOS-->>SnmpV3AuthenticationFact: return configuration text
  SA178->>SA178HotfixFact: collect persistent hotfix state
  SA178HotfixFact->>EOS: read hotfix command output
  EOS-->>SA178HotfixFact: return hotfix state
  SA178->>_assess_sa178: pass collected facts
Loading

Possibly related PRs

  • aristanetworks/anta#1857: Changes SA178 expected-result documentation for encrypted syntax and adds advisory docstring layout checks.

Suggested reviewers: clausholbecharista, gmuloc

Merge Risk: Minimal · up to 5c7bf

Remote-user detection and hotfix assessment have no identified merge-blocking issue. Merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the primary changes: remote SNMPv3 user detection and SA178 revision 1.3 alignment.
Description check Passed The description follows the required template, explains the remote-user parsing and SA178 updates, references issue #1761, documents verification, and marks all checklist items complete.
Linked Issues check Passed Issue #1761 requires SA178 to detect authenticated remote SNMPv3 users. SnmpV3AuthenticationFact now parses show running-config | include ^snmp-server user, including the optional `remote […
Out of Scope Changes check Passed The changes remain within SA178. The release matrix, fixed releases, SA178HotfixFact, remediation logic, finding rendering, documentation, and tests implement the current PR intent for SA178 revisio…
Full details: Linked Issues check

Explanation

Issue #1761 requires SA178 to detect authenticated remote SNMPv3 users. SnmpV3AuthenticationFact now parses show running-config | include ^snmp-server user, including the optional remote &lt;host&gt; [udp-port &lt;port&gt;] fields. The parser detects the issue reproduction layout and returns an unavailable fact for malformed layouts. The changed tests cover remote, UDP-port, IPv6, mixed, no-auth, and malformed configurations. No coding requirement from #1761 remains unmet.

Full details: Out of Scope Changes check

Explanation

The changes remain within SA178. The release matrix, fixed releases, SA178HotfixFact, remediation logic, finding rendering, documentation, and tests implement the current PR intent for SA178 revision 1.3 and its hotfix behavior. The finding-model changes support the SA178 mitigation output. No unrelated subsystem or feature change is demonstrated.

Full details: Docstring Coverage

Explanation

Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 15 functions across 9 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
⚔️ Resolve merge conflicts: 💡
  • Resolve merge conflict in branch fix/sa178-snmp-remote-users
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.50%. Comparing base (f8531ec) to head (f7f836b).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1856      +/-   ##
==========================================
+ Coverage   95.39%   95.50%   +0.11%     
==========================================
  Files         172      172              
  Lines       17261    17263       +2     
  Branches     2644     2638       -6     
==========================================
+ Hits        16466    16487      +21     
+ Misses        480      472       -8     
+ Partials      315      304      -11     
Components Coverage Δ
CLI 93.81% <ø> (ø)
asynceapi 84.86% <ø> (ø)
ANTA Core 92.53% <100.00%> (+0.24%) ⬆️
ANTA Tests 98.69% <100.00%> (+0.01%) ⬆️
Files with missing lines Coverage Δ
anta/_advisory/facts/management.py 88.62% <100.00%> (+1.66%) ⬆️
anta/_advisory/facts/software.py 88.70% <100.00%> (+0.57%) ⬆️
anta/_advisory/findings/models.py 81.69% <100.00%> (+0.12%) ⬆️
anta/_advisory/findings/projection.py 92.68% <100.00%> (+0.47%) ⬆️
anta/tests/advisories/sa_178.py 100.00% <100.00%> (+1.78%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed

codspeed Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 34 untouched benchmarks


Comparing carl-baillargeon:fix/sa178-snmp-remote-users (aefe467) with main (f8531ec)

Open in CodSpeed

Comment thread anta/tests/advisories/sa_178.py Resolved
Comment thread anta/tests/advisories/sa_178.py Outdated
return AffectedResult(
vulnerability_id=VULNERABILITY_ID,
context=(software_context,),
context=(EosReleaseAssessment(software_context.fact, VersionRelation.FIXED),),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for an affected version like 4.35.6 we are statng Version FIXED here (because the hotfix was applied).
Would it not make more sense to state VersionRelartion.AFFECTED and claum the mitigation is enabled?

"eos_data": eos_data(LEGACY_USER, PERSISTENT_HOTFIX),
"expected": expected_result(
AntaTestStatus.FAILURE,
"The device is affected because EOS version '4.35.6M' is fixed, the SNMPv3 authentication key is enabled, and the SNMPv3 credential syntax is legacy",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong 4.35.6M is not FIXED it is AFFECTED but hotfix is present

@ankudinov ankudinov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. SA178 lab test passed

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions

Copy link
Copy Markdown
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔇 Additional comments: 1
tests/units/anta_tests/advisories/test_sa_178.py: 1

299-299: Trivial · Maintainability & Code Quality · Low value

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Put the actual value first in this assertion.

The assertion puts the expected set on the left and HOTFIX_RELEASES on the right. Every other assertion in this file puts the actual value first. SonarCloud flags the inconsistency. Swap the operands to match the file convention.

♻️ Proposed fix
-        assert {"4.36.2F", "4.35.6M", "4.34.8M", "4.33.10M"} == HOTFIX_RELEASES
+        assert HOTFIX_RELEASES == {"4.36.2F", "4.35.6M", "4.34.8M", "4.33.10M"}

Source: Linters/SAST tools


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1ebe0cc0-9de0-46e8-beb6-2925772ddbcb
Commits

Reviewing files that changed from the base of the PR and between 63045c0 and f7f836b.

Files selected for processing: 7
  • anta/_advisory/facts/management.py
  • anta/_advisory/findings/models.py
  • anta/_advisory/findings/projection.py
  • anta/tests/advisories/sa_178.py
  • tests/units/_advisory/facts/test_software.py
  • tests/units/_advisory/findings/test_projection.py
  • tests/units/anta_tests/advisories/test_sa_178.py
Files skipped from review as they are similar to previous changes: 1
  • tests/units/_advisory/facts/test_software.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: SA178, SNMP remote user false negative

3 participants