Repository navigation
feat(findings): container scanning scan type and image filters - #66
Conversation
There was no way to list only container image scanning findings. The API's value for that scan type is ContainerSCA; ContainerScanning and Container (the product's wording) are accepted as aliases. The normalized list is de-duplicated since several aliases map to one value. Refs OD-1049 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Complexity | 1 medium |
🟢 Metrics 70 complexity · 14 duplication
Metric Results Complexity 70 Duplication 14
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull Request Overview
✅ No blocking issues noticed
No blocking implementation issues were identified.
Codacy also found:
- Four expected test-fixture code clones in
src/commands/findings.test.ts. - No static-analysis issues; coverage data was unavailable.
Test suggestions
- ContainerSCA and its aliases normalize to ContainerSCA.
- Spaces, hyphens, underscores, and case variations are accepted during normalization.
- Repeated aliases are de-duplicated in the request body.
- ContainerImageFilter is not exposed as a CLI option.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. ContainerImageFilter is not exposed as a CLI option.
TIP How was this review? Give us feedback
Adds -i, --image <name> and -t, --image-tag <tag>, mapped to the search body's containerImage (ContainerImageFilter). The API requires a name for a tag, so --image-tag alone is refused before any request. Cards show the scanned image as name:tag and JSON gains imageName/imageTag. Also lists the Container alias in --scan-types help (Codacy review). Refs OD-1049 Co-Authored-By: Claude Opus 5.5 <[email protected]>
A container scanning finding is about an image, not a repository, so its card header shows name:tag where org-wide listings show the repository, and no longer repeats it at the end of the status line. The image also shows in the single-repository view, where the repository is hidden as redundant. Refs OD-1049 Co-Authored-By: Claude Opus 5.5 <[email protected]>
| if (opts.image) { | ||
| body.containerImage = opts.imageTag | ||
| ? { name: opts.image, tag: opts.imageTag } | ||
| : { name: opts.image }; | ||
| } |
There was a problem hiding this comment.
SHOULD fix before merge: an empty or padded --image silently drops or mangles the filter
if (opts.image) is a truthiness check, and Commander passes --image "" through as "". So codacy findings gh org --image "$IMG" with IMG unset sends no containerImage at all, and returns every finding in the organization instead of failing. That is the opposite of what a script narrowing to one image wants. The value is also never trimmed, so --image " nginx" sends " nginx" and matches nothing. The comma-list options trim via parseCommaList, so this one is inconsistent with them.
Verified locally: parsing --image "" gives {"image":""}. Refusing an empty or whitespace-only --image/--image-tag before the request, and trimming both, would close it.
🤖 Generated by /review-pr command
There was a problem hiding this comment.
Fixing. --image/--image-tag now go through parseImageFilter, which trims both values and refuses an empty or whitespace-only one before git auto-detection or any request, so an unset $IMG errors instead of widening to the whole org.
🤖 Generated by /pr-fixup command
| body.containerImage = opts.imageTag | ||
| ? { name: opts.image, tag: opts.imageTag } | ||
| : { name: opts.image }; |
There was a problem hiding this comment.
SHOULD fix before merge: --image nginx:1.25.3 is sent as the image name
Container cards now print the image as name:tag, so copying that value into --image is the natural next step. That whole string goes to the API as containerImage.name, which matches nothing, and the command quietly reports no findings. Nothing tells the user the tag belongs in --image-tag.
Either split a name:tag reference (the tag is what follows the last : after the last /, so a registry port like host:5000/app is not mistaken for a tag), or refuse it with a hint to use --image-tag. Both are local and run before the request.
🤖 Generated by /review-pr command
There was a problem hiding this comment.
Fixing. --image nginx:1.25.3 is now split into name and tag. Only a colon after the last / starts a tag, so registry:5000/app stays a name. Two different tags (--image nginx:1.25.3 --image-tag 1.26.0) and digest references (@sha256:) are refused rather than sent.
🤖 Generated by /pr-fixup command
|
codacy-cloud-cli/src/commands/finding.ts Line 66 in 4bac273 SHOULD fix before merge: This PR makes Matching 🤖 Generated by /review-pr command |
|
Re #66 (comment) ( 🤖 Generated by /pr-fixup command |
Addresses the /review-pr round on #66: - --image/--image-tag go through parseImageFilter: values are trimmed, and empty values, a tag without a name, digest references and two different tags are refused before any request. An empty --image was dropped by a truthiness check, widening the result to the whole org. - --image name:tag is split into name and tag (a registry port stays in the name), since the cards print the image in that form. - finding <id> shows image:tag in place of the repository, through the shared formatImageReference, and its JSON gains imageName/imageTag. Refs OD-1049 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
codacy findingscan now narrow to container scanning results (OD-1049).--scan-typesacceptsContainerSCA. That is the API value (asSearchSRMItems.scanTypeslists it inapi-v3/api-swagger.yaml), notContainerScanningas the ticket names it.ContainerScanningandContainerare accepted as aliases, normalized like the other scan types (case-insensitive, spaces/hyphens/underscores ignored). The normalized list is now de-duplicated, since several aliases resolve to the same value.-i, --image <name>and-t, --image-tag <tag>map to the search body'scontainerImage(ContainerImageFilter) throughparseImageFilter. Values are trimmed, and--image name:tagis split into name and tag; only a colon after the last/starts a tag, soregistry:5000/appstays a name. Input the API would mishandle silently is refused before any request or git auto-detection: empty values (a truthiness check would drop--image ""and widen to the whole org), a tag without a name, a digest reference, or two different tags.name:tag(justnamewhen there is no tag) in the slot the repository uses in org-wide listings, since these findings are about an image, not a repository. It is shown in the single-repository view too, where the repository is hidden.finding <id>does the same on its header line, through the sharedformatImageReference. Non-container findings are unchanged. Both commands'--output jsongainsimageNameandimageTag.-T ContainerSCA/container-scanning/ContainerscanTypes: ["ContainerSCA"]-T ContainerSCA,containerscanTypes: ["ContainerSCA"](de-duplicated)--image nginxcontainerImage: { name: "nginx" }--image nginx --image-tag 1.25.3containerImage: { name: "nginx", tag: "1.25.3" }--image nginx:1.25.3containerImage: { name: "nginx", tag: "1.25.3" }--image registry:5000/appcontainerImage: { name: "registry:5000/app" }--image-tag 1.25.3Error: --image-tag requires --image <name>.--image ""Error: --image needs an image name, but the value is empty.--image nginx:1.25.3 --image-tag 1.26.0--image nginx@sha256:…--imagedoes not addContainerSCAto the scan types by itself; the API applies the image filter on its own.Test plan
npx vitest run src/commands/findings.test.ts src/commands/finding.test.ts src/utils/formatting.test.ts: 25 new tests across the three files (scan-type aliases, image filter request bodies and refusals,parseImageFilterunit tests, image-in-place-of-repository rendering on both commands, JSON fields,formatImageReference)npm test: 823 passingnpx tsc --noEmit -p .codacy findings gh <org> --scan-types ContainerSCA --image <name> --image-tag <tag>against an org with container findings🤖 Generated with Claude Code