fix(compose): surface per-service scan failures in user-facing summary - #160
Conversation
f76a1d8 to
04f8171
Compare
|
Hello @myukitty - can you please update your branch and PR and resubmit this PR again? |
OWASP#161 records failed services in the compose results dict, but nothing reads them back out. A run where some services could not be scanned still prints a summary and a score as if every service had been covered, which is the visibility gap OWASP#131 describes. Add the missing user-facing half: - carry total_services next to failed_services so the summary has a denominator, and - print "N of M services could not be scanned: <names>" in the Quick take block, and include failed_services/total_services in --json. run_full_scan records a service twice when both its Dockerfile and its image scan fail, so the names are de-duplicated before counting. Fixes OWASP#131. Builds on OWASP#161.
04f8171 to
e596d9b
Compare
|
Thanks @advaitpatel — updated and rebased onto current Since #161 merged in the meantime, I rewrote the PR rather than just resolving the conflict. #161 already tracks What is left is 4 files, +141/-3:
No change to exit codes, scoring, or scan behaviour. Full details and before/after output are in the updated description. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #160 +/- ##
==========================================
+ Coverage 78.95% 80.51% +1.56%
==========================================
Files 26 32 +6
Lines 4158 5169 +1011
==========================================
+ Hits 3283 4162 +879
- Misses 875 1007 +132
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Pull Request
Description
Rebased onto current
mainand rewritten now that #161 has merged.#161 added
failed_servicestracking insideComposeOrchestrator.run_full_scan, which covers the first two acceptance criteria of #131. Nothing reads that field back out, so the third one is still open: a compose run where some services could not be scanned still prints a Quick take and a security score as if every service had been covered. That is the misleading behaviour #131 was filed about.This PR adds only the missing user-facing half, on top of #161:
compose_scanner.pycarriestotal_servicesalongsidefailed_services, so the summary has a denominator.cli.pyprints one Quick take line —N of M services could not be scanned: <names>— and includesfailed_services/total_servicesin--jsonoutput.run_full_scan, so names are de-duplicated before counting.No change to exit codes, scoring, or scan behaviour — this is purely the visibility fix #131 asked for.
Before (current
main, 2 of 3 services unscannable):After:
The per-service
reasonstrings are available in--jsonunderscan_info.failed_services; I kept them out of the one-line Quick take because they vary per service. Happy to inline the reason if you would rather match the issue's example wording exactly.Closes #131
Type of Change
How Has This Been Tested?
Added 7 tests: 4 in
tests/test_cli.pycovering the summary line, the de-duplication, the no-total fallback, and silence when nothing failed; 3 intests/test_compose_scanner.pycoveringtotal_services, populatedfailed_services, and the unparseable-compose path.pytest tests/— 254 passed, 2 skipped. The 2 failures intests/test_utils.pyon my machine are the optionaldocksec[ai]extras not being installed, and reproduce unchanged onmain.ruff check .— all checks passed.Test Configuration:
main@ 77c0cd1Checklist
Related Issues / PRs
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.