Skip to content

Validate --report-format values before scan create(AST-182795) - #1636

Open
cx-sumit-morchhale wants to merge 2 commits into
stagingfrom
bug/AST-182795-reportFormatFlagVal
Open

cx-sumit-morchhale wants to merge 2 commits into
stagingfrom
bug/AST-182795-reportFormatFlagVal

Conversation

@cx-sumit-morchhale

Copy link
Copy Markdown
Contributor

Summary

  • Adds printer.ValidateReportFormats, which checks comma-separated --report-format values using the same split and case-insensitive matching as CreateScanReport.
  • cx results show: validates after the scan-ID check and before GetByID, so a bad value makes no API call.
  • cx scan create: validates in validateCreateScanFlags. Known gap: this runs after validateScanTypes, which still calls the token and feature-flag APIs before the format is rejected.

Known issues

  • Error text changed. The message is now Invalid report format <x>. Supported formats are: .... Previously it was bad report format <x>. TestRunGetResultsByScanIdWrongFormat was changed to check the bad report format prefix, so it fails against this text. Needs a decision before merge.
  • Commit message is inaccurate. It says the scan create check is at the start of the run function. It is in validateCreateScanFlags (see the Summary).
  • No unit tests for the validator or the scan create check in this PR.
  • Full ./internal/commands/... run did not pass. It hit the 25-minute timeout, and several environment-dependent tests failed: ScaResolver not found, no container engine for KICS realtime, Windows permission tests, ASCA installer, and SCA realtime. Not yet checked against the base branch.

Test plan

  • Decide the error-text wording and make TestRunGetResultsByScanIdWrongFormat pass.
  • results show --report-format abc fails before any API request.
  • scan create --report-format abc fails, and check whether API requests happen first.
  • Valid single and comma-separated values still work, including scan create --async.

🤖 Generated with Claude Code

Reject unsupported --report-format values early in `results show` and
`scan create`, before any API call or scan submission.

- Add printer.ValidateReportFormats, which uses the same comma split and
  case-insensitive matching as CreateScanReport.
- Call it at the top of runGetResultCommand, after the scan-ID check.
- Call it at the start of the scan create run function.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@cx-sumit-morchhale
cx-sumit-morchhale requested a review from a team as a code owner November 30, 2026 13:45
@cx-sumit-morchhale cx-sumit-morchhale changed the title AST-182795: Validate --report-format values before API calls Validate --report-format values before scan create(AST-182795) Nov 30, 2026
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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