Skip to content

Add Trivy security-audit workflow and report sorter; validate cgroup paths against embedded NUL - #26

Closed
andypost wants to merge 1 commit into
roadmapfrom
codex/create-security-audit-with-sorted-results
Closed

andypost wants to merge 1 commit into
roadmapfrom
codex/create-security-audit-with-sorted-results

Conversation

@andypost

Copy link
Copy Markdown
Owner

Motivation

  • Add an automated Trivy filesystem vulnerability audit that produces a human-readable, severity-sorted Markdown report and can fail the run on configurable severity.
  • Harden cgroup path validation to reject empty values and embedded NUL bytes that could lead to truncated C-string usage.
  • Capture findings and follow-up items for the new audit flow in documentation and exercise the new validation with a unit test.

Description

  • Add .github/scripts/sort-trivy-results.py which parses Trivy JSON output, sorts vulnerabilities by severity and CVSS v3 score, renders a Markdown report, and can exit non-zero when a configured severity threshold is met.
  • Add .github/workflows/security-audit.yml GitHub Action to run Trivy (JSON and SARIF), upload SARIF, generate the sorted Markdown report, append it to the step summary, and upload the security-audit/ artifact.
  • Add docs/security-audit-findings.md documenting candidate findings from a manual review of the new audit/workflow and adjacent code paths.
  • Harden C validation in src/nxt_conf_validation.c for cgroup paths by rejecting empty strings and embedded NUL bytes, replacing a sprintf with snprintf to avoid unsafe formatting, and preserving the existing ".." path check.
  • Extend test/test_python_isolation.py to include a test case that asserts a cgroup path containing an embedded NUL ('scope\0python') is treated as invalid.

Testing

  • Updated isolation unit test test/test_python_isolation.py::test_python_isolation_cgroup_invalid was run and the new case for embedded NULs passed.
  • The repository unit test suite was executed after the change via the project test runner and completed successfully.
  • The new GitHub Actions workflow was added and its configuration validated via static review; the workflow will run in CI on pushes, PRs, and a weekly schedule.

Codex Task

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request adds a Python script to generate severity-sorted Markdown reports from Trivy JSON output and includes a new document tracking potential security vulnerabilities. Additionally, it hardens cgroup path validation in src/nxt_conf_validation.c by rejecting embedded NUL bytes and using snprintf, with a corresponding test case added. Review feedback suggests enhancing the Markdown escaping logic to handle backslashes and removing redundant severity normalization in the sorting process.

Comment thread .github/scripts/sort-trivy-results.py
Comment thread .github/scripts/sort-trivy-results.py
@andypost

andypost commented Jul 7, 2026

Copy link
Copy Markdown
Owner Author

Reworked. The C-hardening half of this draft (cgroup/rootfs embedded-NUL + sprintf(%*s)snprintf(%.*s)) has been rebased onto current pre-1.35.6, extended with a rootfs config-time validator, verified against a live unitd, and opened as freeunitorg/freeunit#95.

Deliberately not carried over:

  • Trivy workflow + sort-trivy-results.py → moved to a separate ci: PR (freeunitorg/freeunit#99).
  • docs/security-audit-findings.md → a public list of suspected-unfixed vulns; kept out of the repo for disclosure hygiene. Its one live item (rootfs NUL / SA-001) is fixed by freeunitorg/freeunit#95; the rest folded into the private wave-2 tracker.

This draft can be closed once both land.

@andypost

andypost commented Jul 7, 2026

Copy link
Copy Markdown
Owner Author

The Trivy half is now reworked as freeunitorg/freeunit#99 (report-only by default, security-events:write scoped to the job, docs/security-audit-findings.md dropped for disclosure hygiene).

With the C validation fix in freeunitorg/freeunit#95 and the workflow in freeunitorg/freeunit#99, this draft is fully superseded and can be closed once both land.

@andypost andypost closed this Jul 7, 2026
@andypost
andypost deleted the codex/create-security-audit-with-sorted-results branch July 7, 2026 18:57
andypost added a commit to freeunitorg/freeunit that referenced this pull request Jul 7, 2026
Scan the tree (Cargo.lock, go.mod/sum, package-lock, requirements,
Dockerfiles) with Trivy on a weekly schedule, on pushes/PRs touching
dependency manifests, and on demand. Findings are uploaded as SARIF to
the Security tab and rendered into a severity-sorted Markdown report
(sort-trivy-results.py) appended to the job summary and artifact.

Automatic runs are report-only and never fail the build; a blocking
severity gate is opt-in via workflow_dispatch. security-events:write is
scoped to the audit job, not the whole workflow.

The report parser guards Trivy edge outputs: a CVSS source whose value
is explicitly null, a null "Results" field, and a non-dict top-level
report, all of which would otherwise raise.

Reworked from the CI portion of andypost#26; the cgroup/rootfs
config-validation fix from that draft ships separately in
#95.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant