Skip to content

feat: add --siem flag to security-audit report for NDJSON export#1905

Open
jlima8900 wants to merge 4 commits intoKeeper-Security:masterfrom
jlima8900:feat/siem-output-format-pr1876
Open

feat: add --siem flag to security-audit report for NDJSON export#1905
jlima8900 wants to merge 4 commits intoKeeper-Security:masterfrom
jlima8900:feat/siem-output-format-pr1876

Conversation

@jlima8900
Copy link
Copy Markdown

Summary

Adds SIEM-ready output to security-audit report using NDJSON format (one JSON event per line). The existing audit-log command has SIEM export (Splunk, syslog, Sumo, Azure) for event streams, but the security-audit report had no machine-readable output.

Test plan

  • Verified NDJSON output format
  • Tested with jq parsing
  • Backward compatible — existing report output unchanged without --siem flag

Adds NDJSON output for SIEM ingestion (Splunk, Elastic, Datadog).

- --siem flag produces one JSON object per line
- Rejects --siem + --record-details combination
- Warns when --siem overrides explicit --format
- Empty reports produce empty output
- security_score field only emitted in non-BreachWatch mode
- Output file written with 0o600 permissions
Address PR Keeper-Security#1876 review from @aaunario-keeper:

- --siem + --format now raises CommandError instead of silently ignoring
  the format flag, making the override explicit in the CLI contract
- Add clarifying parentheses on empty-report ternary to make precedence
  obvious (behavior unchanged — empty list already produced '')
Address review feedback:
- Reject --siem + --record-details combination with clear error
- Reject --siem + --format combination (SIEM is NDJSON-only)
- Fix empty report producing blank line instead of empty output
- Mask sensitive fields in SIEM NDJSON output (CodeQL finding)
- Add os.fchmod(fd, 0o600) to ensure existing files get restrictive
  permissions (os.open mode only applies on creation)
- Add 25 tests covering NDJSON format, PII masking, risk factors,
  empty report handling, file permissions, flag validation, and
  BreachWatch mode
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.

1 participant