Skip to content

feat: relax flag validation for test/monitor commands#6482

Merged
paulrosca-snyk merged 1 commit intomainfrom
OSF-220-cli-jumps-back-to-the-old-cli-for-unknown-cli-arguments
Mar 19, 2026
Merged

feat: relax flag validation for test/monitor commands#6482
paulrosca-snyk merged 1 commit intomainfrom
OSF-220-cli-jumps-back-to-the-old-cli-for-unknown-cli-arguments

Conversation

@paulrosca-snyk
Copy link
Copy Markdown
Contributor

Pull Request Submission Checklist

  • Follows CONTRIBUTING guidelines
  • Commit messages
    are release-note ready, emphasizing
    what was changed, not how.
  • Includes detailed description of changes
  • Contains risk assessment (Low | Medium | High)
  • Highlights breaking API changes (if applicable)
  • Links to automated tests covering new functionality
  • Includes manual testing instructions (if necessary)
  • Updates relevant GitBook documentation (PR link: ___)
  • Includes product update to be announced in the next stable release notes

What does this PR do?

Relaxes the flag validation for snyk test and snyk monitor so that the command can be routed to the new flow (e.g reachability) even when an unknown flag is being passed.

Where should the reviewer start?

How should this be manually tested?

Running snyk test --reachability --foo-bar should return the vulnerability information enriched with reachability signals.

What's the product update that needs to be communicated to CLI users?

N/A

Risk assessment (Low | Medium | High)?

Low. This only impacts customers which use the new testing flow, and the impact should be positive.

@paulrosca-snyk paulrosca-snyk force-pushed the OSF-220-cli-jumps-back-to-the-old-cli-for-unknown-cli-arguments branch 2 times, most recently from 7de7edb to 3d4f0ae Compare February 2, 2026 08:45
@paulrosca-snyk paulrosca-snyk force-pushed the OSF-220-cli-jumps-back-to-the-old-cli-for-unknown-cli-arguments branch 2 times, most recently from fc5dc1e to 523addc Compare February 9, 2026 15:14
@paulrosca-snyk paulrosca-snyk force-pushed the OSF-220-cli-jumps-back-to-the-old-cli-for-unknown-cli-arguments branch from 523addc to 59495ca Compare March 6, 2026 09:27
@snyk-io
Copy link
Copy Markdown

snyk-io Bot commented Mar 6, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@paulrosca-snyk paulrosca-snyk force-pushed the OSF-220-cli-jumps-back-to-the-old-cli-for-unknown-cli-arguments branch 7 times, most recently from 37e6d91 to a27d8cb Compare March 17, 2026 15:11
@paulrosca-snyk paulrosca-snyk marked this pull request as ready for review March 17, 2026 15:23
@paulrosca-snyk paulrosca-snyk requested review from a team as code owners March 17, 2026 15:23
@snyk-pr-review-bot

This comment has been minimized.

});

test('emits a valid json output when unknown flags are passed', async () => {
const { stdout, stderr } = await runSnykCLI(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: check the exit code it shouldn't be 2

@paulrosca-snyk paulrosca-snyk force-pushed the OSF-220-cli-jumps-back-to-the-old-cli-for-unknown-cli-arguments branch from a27d8cb to c81e721 Compare March 18, 2026 07:25
@snyk-pr-review-bot

This comment has been minimized.

@paulrosca-snyk paulrosca-snyk force-pushed the OSF-220-cli-jumps-back-to-the-old-cli-for-unknown-cli-arguments branch from c81e721 to 1826e7a Compare March 18, 2026 09:41
@snyk-pr-review-bot

This comment has been minimized.

@paulrosca-snyk paulrosca-snyk force-pushed the OSF-220-cli-jumps-back-to-the-old-cli-for-unknown-cli-arguments branch from 1826e7a to d4a68c1 Compare March 18, 2026 13:42
@snyk-pr-review-bot

This comment has been minimized.

@paulrosca-snyk paulrosca-snyk force-pushed the OSF-220-cli-jumps-back-to-the-old-cli-for-unknown-cli-arguments branch from d4a68c1 to 822a1ac Compare March 19, 2026 10:02
@snyk-pr-review-bot

This comment has been minimized.

@paulrosca-snyk paulrosca-snyk force-pushed the OSF-220-cli-jumps-back-to-the-old-cli-for-unknown-cli-arguments branch from 822a1ac to 1a6b564 Compare March 19, 2026 14:33
@snyk-pr-review-bot
Copy link
Copy Markdown

PR Reviewer Guide 🔍

🧪 PR contains tests
 External call assumptions: None.
🔒 No security concerns identified
⚡ Recommended focus areas for review

Behavioral Change (2 occurrences) 🟡 [minor]
  1. cliv2/cmd/cliv2/behavior/legacy/validation.go
    The addition of --json and --sarif to incompatibleFlagRules (lines 48-49) prevents users from specifying both flags simultaneously. While this is likely intended for clarity, it represents a breaking change for users who may have included both in automated scripts where one flag was previously ignored or took precedence.

  2. cliv2/cmd/cliv2/behavior/legacy/validation.go
    Enabling cmd.FParseErrWhitelist.UnknownFlags = true in SetupTestMonitorCommand means that typos in standard flags (e.g., --jsson instead of --json) will no longer be caught by the Cobra parser for the test and monitor commands. These will instead be passed to the legacy CLI or ignored, potentially causing unexpected behavior if the user assumes a flag is active when it is not.

📚 Repository Context Analyzed

This review considered 9 relevant code sections from 8 files (average relevance: 0.79)

@paulrosca-snyk paulrosca-snyk merged commit fd77fd3 into main Mar 19, 2026
9 checks passed
@paulrosca-snyk paulrosca-snyk deleted the OSF-220-cli-jumps-back-to-the-old-cli-for-unknown-cli-arguments branch March 19, 2026 15:17
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.

2 participants