Skip to content

Fix aws_ecr_image_scanning for enhanced scanning, with correct counts - #324

Open
21tmccauley wants to merge 1 commit into
mainfrom
ecr-scan-enhanced-counts
Open

21tmccauley wants to merge 1 commit into
mainfrom
ecr-scan-enhanced-counts

Conversation

@21tmccauley

Copy link
Copy Markdown
Collaborator

The third piece of #300 (contributed by Lucid, co-authored by Rocky Olsen). The other two fetchers merged in #323. This carries Rocky's aws_ecr_image_scanning 0.3.0 changes plus a fix for a severity-count bug found in live testing.

From #300

  • Reads newest-image scan results regardless of scan_on_push, including enhanced continuous and completed manual scans. Before this, enhanced registries reported latest_image_scan: null.
  • Resolves the effective scan frequency through AWS, reports all six severities, and uses null instead of a false 0 when counts are unknown.
  • Needs ecr:BatchGetRepositoryScanningConfiguration (upgrade step in the CHANGELOG).

The fix

With enhanced (Inspector) scanning, ECR's findingSeverityCounts covers only the findings on the returned page, not the whole image. #300 requested one finding per page (--max-results 1 --no-paginate), so the counts covered a single finding. On a live image with 10,357 findings it reported:

critical high medium low info untriaged
#300 0 0 1 0 0 0
This PR 456 3,589 3,956 94 244 2,018
Inspector (truth) 456 3,589 3,956 94 244 2,018

The fetcher now reads every page and counts enhancedFindings itself. BASIC scans keep AWS's total. The raw response goes to a temp file and is reduced to the summary straight away.

  • Permissions: with enhanced scanning, AWS also checks inspector2:ListCoverage and inspector2:ListFindings on DescribeImageScanFindings. I verified this with a role holding exactly the documented permissions (denied without them, correct counts with them). Both are now in the README and CHANGELOG.
  • Timeout: reading every finding takes about 90s for 10k findings, so the runtime timeout goes from 600s (the default) to 3600s.

Tests

  • New: page-scoped summary ignored, every finding counted; an enhanced scan with no findings reports zeros, not unknown.
  • Rocky's 13 ECR tests restored.
  • Full suite: 8,769 passed, 102 skipped. ruff and mypy pass on framework/.
  • Live: main vs this branch on an enhanced registry with scan_on_push=false (main reports null, this branch reports the scan), plus the count comparison above.

Closes #300 together with #323.

🤖 Generated with Claude Code

Brings in Lucid's aws_ecr_image_scanning 0.3.0 changes from #300 (reads
scan results regardless of scan_on_push, resolves effective scan
frequency, all six severities, null instead of a false zero), plus a fix
for its severity counts.

With enhanced (Inspector) scanning, ECR's findingSeverityCounts covers
only the findings on the returned page. #300 requested one finding per
page, so an image with 456 critical and 3,589 high reported 0 critical,
0 high, 1 medium. The fetcher now reads every page and counts
enhancedFindings itself; BASIC scans keep AWS's total. Verified live
against Inspector (all six severities match on a 10,357-finding image).

Also documents that enhanced scanning needs inspector2:ListCoverage and
inspector2:ListFindings (verified with a role holding exactly the listed
permissions), and raises the runtime timeout to 3600s since a 10k-finding
image takes about 90s to read.

Co-authored-by: Rocky Olsen <rolsen@lucidchart.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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