Skip to content

Start container scans from the CLI (0.5.16) - #54

Open
harshit905 wants to merge 2 commits into
mainfrom
harshit/container-scan-start
Open

harshit905 wants to merge 2 commits into
mainfrom
harshit/container-scan-start

Conversation

@harshit905

@harshit905 harshit905 commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

User description

What

Adds codeant findings cloud start --kind container to start an AWS ECR, Azure ACR, or GCP Artifact Registry container scan without the UI, and to gate a CI pipeline on the result.

  • --provider aws|azure|gcp, --region (required for AWS), --config-id (AWS), --repositories a,b:tag (default: every repository)
  • --wait checks /cloud/<provider>/container-scanning/results/paginated every 15 s, up to --timeout seconds (default 1800)
  • --fail-on <severity> checks the finished scan's severity_rollup for that severity and every higher one
Exit Meaning
0 started (no --wait), or finished below --fail-on
1 request error: auth, missing registry connection, denied access, invalid options
2 findings at or above --fail-on
3 an image failed to scan (completed_with_errors)
4 still running at --timeout

Why

Container results were already readable through findings cloud history/list/get, but starting a scan needed the UI. codeant api request can reach the start routes but does not send username, which they read. This builds on request() in src/findings/cloud.js, which already sends it.

No backend change: results/paginated returns the running scan's meta, and each call finalizes the scan once every image has a result.

Docs

findings.md (examples, target format per provider, exit codes, GitHub Actions step), changelog 0.5.16. Public docs: CodeAnt-AI/docs#121.

Testing

  • npm test: 205 passed
  • Invalid --kind, --fail-on, --provider, --timeout 0, --fail-on without --wait, and AWS without --region exit 1 before any network call; without a login the command exits 1 with Missing API key
  • Not yet run against a live registry (start, wait, threshold, unknown repository, timeout). Do not merge until that is done: merging publishes the release to npm.

CodeAnt-AI Description

Start and gate cloud container scans from the CLI

What Changed

  • Start container scans for AWS ECR, Azure ACR, or GCP Artifact Registry without using the CodeAnt app, optionally selecting repositories.
  • Wait for scans to finish, set a timeout, and return a scan summary; optionally exit with a failure when findings meet a chosen severity threshold.
  • Report distinct exit codes for threshold breaches, image scan failures, and timeouts.

Impact

✅ Container scans start without opening the CodeAnt app
✅ CI can block on a selected finding severity
✅ Failed and timed-out scans have distinct outcomes

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@harshit905

Copy link
Copy Markdown
Collaborator Author

@CodeAnt-AI: review

@codeant-ai

codeant-ai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

CodeAnt  CodeAnt Review Status

✅  Review completed

Status Commit Started (UTC) Finished (UTC)
✅  #d1300 Reviewed your PR d257529 Nov 03, 2026 · 04:30 04:31
✅  #733cf Reviewed your PR d257529 Nov 02, 2026 · 05:30 05:34
✅  #c5526 Reviewed your PR 8c1fb14 Nov 02, 2026 · 05:06 05:09

@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Nov 2, 2026
Comment thread src/findings/cloud.js Resolved
Comment thread src/findings/cloud.js
const timeout = options.timeout ?? 1800;
const deadline = Date.now() + timeout * 1000;
for (;;) {
const scan = await request(provider, 'container', 'results/paginated', options, { scan_id: started.scan_id, limit: 25 }, tenant);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: The deadline is checked only after this request returns, so a slow poll can finish after --timeout and prevent the CLI from exiting 4 on time.

Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Logic error

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** src/findings/cloud.js
**Line:** 158:158
**Comment:**
	*Logic Error: The deadline is checked only after this request returns, so a slow poll can finish after `--timeout` and prevent the CLI from exiting 4 on time.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@CodeAnt-AI: While a scan is running, this poll only reads the scan meta.json and lists its repos/ prefix, and the API in front of it cuts requests off at about 60 s, so the overrun should be at most one short request. Is there a path where a single running-status poll could take much longer than that, enough to justify passing an AbortSignal through request() and fetchAppApi()?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The normal running-scan path—reading scan metadata and listing repositories—shouldn’t take much longer than the API’s roughly 60-second cutoff, so there’s no known backend operation that would routinely cause a large overrun.

However, that cutoff isn’t a client-side deadline: a stalled connection could leave fetch waiting, and even a 60-second response exceeds a valid --timeout 1. A late response could also report completion after the deadline and be returned as success. Since --timeout is documented as a maximum wait, I’d bound each poll by the remaining time with an AbortSignal and report exit 4 when that deadline expires. If the timeout is intended to be approximate, the signal plumbing isn’t necessary—but the docs should say an in-flight poll may overrun it.

@codeant-ai

codeant-ai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

CodeAnt  CodeAnt PR Risk

🟡  Medium Risk

  • The PR needs attention before merging.
  • With --wait, a results request can exceed --timeout because the deadline is checked only after it returns, delaying exit 4 or returning late success.

Assessed commit: d2575295d307

@harshit905

Copy link
Copy Markdown
Collaborator Author

@CodeAnt-AI: review

@codeant-ai

codeant-ai Bot commented Nov 2, 2026

Copy link
Copy Markdown

CodeAnt  CodeAnt Nitpicks

1 code suggestion

1. When stderr is piped in CI, process.exit() can end the process before console.error() flushes, hiding the scan ID in timeout errors.

Possible bug · src/commands/findings/index.js:226-227

@harshit905
harshit905 marked this pull request as ready for review November 3, 2026 04:30
@codeant-ai

codeant-ai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant