Repository navigation
fix: keep scan reports private and accessible to the runner - #87
ANAMASGARD wants to merge 2 commits into
Conversation
Run the container as the invoking UID/GID with a writable temporary home. Finalize SARIF even after scanner failure, preserve the scanner exit status, and use private temporary files with explicit finalization errors. Add report and container-boundary regressions and exercise the local action in scan workflows. Signed-off-by: Gaurav Chaudhary <chaudharygaurav2004@gmail.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 44 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Run the unprivileged autofix scan against the checked-out action so its JSON reports use the runner identity. Resolve the container test runtime before shadowing Docker on PATH to avoid recursive shim execution. Add workflow-selection and bounded default-Docker dispatch regressions. Signed-off-by: Gaurav Chaudhary <chaudharygaurav2004@gmail.com>
matthyx
left a comment
There was a problem hiding this comment.
Request changes: the ownership/finalization fix is needed, but one introduced format-compatibility regression remains.
P2 — Match the JSON format as a complete token (entrypoint.sh:183). contains "${output_formats}" "json" also matches supported image formats cyclonedx-json and spdx-json. With image: nginx, either format and the default outputFile: results, a successful scanner writes results.cdx.json or results.spdx.json. This new guard instead requires results or results.json and returns failure (JSON file results not found.). The CLI v4.0.16 format/output contract confirms those formats and extensions. A credential-free, network-isolated boundary reproduction with successful scanner fixtures returned baseline=0, PR=1 for both formats. Use exact comma-delimited membership for the standalone json format and add both regressions. The existing substring-based autofix behavior predates this PR; this finding concerns the newly unconditional report check.
Reviewed head 83e2342c8ba2d5985875de989a534bd887259e0d against main at 6a527186fc87c668469fe8b9333b251ffc4eaed8. Immediately before submission the PR remained open, non-draft and mergeable, with both commits unchanged and no human reviews or inline threads to duplicate.
Necessity: #85 documents root-owned 0600 reports; the target still runs Docker without --user. Matching the runner identity fixes the producer/consumer boundary without weakening confidentiality. Capturing scanner status, private temporary files, cleanup, and preserving failed scan status are sound. No other material blocker found across the nine changed files; independent architecture review identifies the format guard as a blocker.
History: merged #84 fixes SARIF paths and is preserved; open #88 updates the uploader and is complementary. Merged #3 explicitly approved non-root execution. #61, #71 and #50 concern missing/empty reports or Helm attribution, not this ownership fix. Closed #7 was explicitly replaced by #9; #44 has no recorded rejection of this approach. #20 reverted an executable-bit regression, not non-root execution. No duplicate/superseding ownership fix found. Search covered all 65 PRs and 23 issues plus repository search for SARIF, permissions and entrypoint symbols; this does not cover private/unindexed discussions or all forks.
Validation: inspected scripts before executing in Bubblewrap with cleared environment, network isolation, read-only source and ephemeral writable storage. bash tests/entrypoint_test.sh: 19/19; bash tests/action_test.sh: 27/27; bash tests/report_test.sh: 33/33. The report suite against main's entrypoint fails 10/33 assertions. Shell syntax and git diff --check pass. ShellCheck unavailable; real CLI/container tests not rerun locally. Latest test CI confirms all six container cases pass. Hosted configuration and image logs confirm completed SARIF uploads after threshold failures. Autofix CI successfully uploads both results.sarif and results.json, closing the description's stated hosted JSON-upload gap. Those checks do not cover SBOM-only formats.
Summary
Fixes #85.
Ensure downstream GitHub Actions steps can read generated scan reports while preserving the Kubescape CLI’s intentional owner-only permissions.
Problem
The action runs its scan container as root, while subsequent upload steps run as the non-root GitHub Actions runner. With CLI v4.0.16, reports written with mode
0600can therefore fail to upload withEACCES.Additionally, scanner threshold failures exit the entrypoint before SARIF normalization. Successful normalization can instead replace a private report with a temporary file whose permissions depend on the umask.
Changes
@main.No recursive workspace permission changes or world-readable report workaround is introduced.
Validation
Hosted workflows executing this branch’s action both passed, including SARIF uploads:
Threshold-triggered scanner failures remain failures; the workflows’ existing
continue-on-errorpermits subsequent upload steps.Scope and remaining validation
This PR addresses report ownership and finalization only. The CodeQL uploader-version update remains separate, and the SARIF path correction from #84 is preserved.
Hosted JSON artifact-upload validation remains outstanding.
Summary by CodeRabbit