fix: redact secrets from HTML report command output - #906
Open
oboehmer wants to merge 1 commit into
Open
Conversation
Add sanitize module that redacts credentials, SNMP communities, pre-shared
keys, and similar sensitive data before command/API output is persisted to
JSONL and rendered into HTML reports.
CLI and JSON rules are kept separate and selected via a content heuristic
(output starting with '{' or '[' → JSON rules, otherwise CLI rules).
Closes #881
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.
Description
Redact credentials, SNMP community strings, pre-shared keys, and similar sensitive data from command/API output before it is persisted to JSONL and rendered into HTML reports.
add_command_api_executionincollector.pyis the single chokepoint where all output (SSH commands and API responses) passes before hitting disk. A newsanitizemodule applies regex-based redaction rules, with CLI and JSON rulesets kept separate and selected via a content heuristic (output starting with{or[→ JSON rules, otherwise CLI rules).Closes
Related Issue(s)
show running-config | sectiontracking)Type of Change
Test Framework Affected
Network as Code (NaC) Architecture Affected
Platform Tested
Key Changes
nac_test/pyats_core/reporting/sanitize.pywith separate_CLI_RULES(6 patterns) and_JSON_RULES(1 pattern)_looks_like_json()selects the appropriate ruleset, preventing cross-contamination (e.g. CLIdescription "community center"is not falsely redacted)collector.py:add_command_api_execution— sanitization runs after 50KB truncation, before JSONL writeCLI patterns redacted
password/secret/key/key-string/server-key/pac key <type> <value>domain-password <value>snmp-server community <value>snmp-server host ... priv <value>set-key ascii/hex <value>(WLAN PSK)attribute type password <value>(AAA/RADIUS)JSON patterns redacted
password,secret,community,presharedKey,sharedSecret,psk,authKey,enableSecret,enablePassword,snmpAuthPassword,snmpPrivPassword, etc.Testing Done
pytest/pre-commit run -a)Test Commands Used
Checklist
pre-commit run -apasses)