Skip to content

CM-63882 - Added scanType validation#452

Open
aaron-butler-cy-int wants to merge 3 commits into
cycodehq:mainfrom
aaron-butler-cy-int:CM-63882-cli-fix-scan-type-validation
Open

CM-63882 - Added scanType validation#452
aaron-butler-cy-int wants to merge 3 commits into
cycodehq:mainfrom
aaron-butler-cy-int:CM-63882-cli-fix-scan-type-validation

Conversation

@aaron-butler-cy-int
Copy link
Copy Markdown

the scan command use to accept multiple -t flags but would only run the last scan listed in the command. Added validation that only one -t flag was in the command.

Comment on lines +129 to +137
if len(scan_type) > 1:
raise typer.BadParameter(
f'Only one scan type can be specified per command. '
f'Got: {", ".join(str(t) for t in scan_type)}. '
f'Run a separate command for each scan type.',
param_hint='-t/--scan-type',
)

resolved_scan_type = scan_type[0]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Try using a parameter callback to perform the validation, we can then reuse it later:
https://typer.tiangolo.com/tutorial/options/callback-and-context/

Comment thread tests/cli/commands/scan/test_scan_command.py Outdated
Co-authored-by: omerr-cycode <omer.roth@cycode.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.

2 participants