-
Notifications
You must be signed in to change notification settings - Fork 2
Support scanning a specific branch #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -343,6 +343,14 @@ def generate_sbom_csv( | |
| rich_help_panel="Scanning Options", | ||
| ), | ||
| ] = None, | ||
| branch: Annotated[ | ||
| str | None, | ||
| typer.Option( | ||
| "--branch", | ||
| help="The branch to analyze. If not provided, the default branch of the repository will be used.", | ||
| rich_help_panel="Scanning Options", | ||
| ), | ||
| ] = None, | ||
| ) -> None: | ||
| """ | ||
| Generate a CSV report (SBOM) of third party dependencies for a given | ||
|
|
@@ -437,12 +445,15 @@ def generate_sbom_csv( | |
|
|
||
| try: | ||
| source_code_manager = SourceCodeManager( | ||
| cache_dir, github_client, cache_ttl, mirrors | ||
| cache_dir, github_client, cache_ttl, mirrors, branch_override=branch | ||
| ) | ||
| except ValueError as e: | ||
| logger.error(str(e)) | ||
| sys.exit(1) | ||
|
|
||
| if branch: | ||
| source_code_manager.set_branch_override_target(package) | ||
|
Comment on lines
+454
to
+455
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
|
|
||
| if enabled_strategies["GitHubSbomMetadataCollectionStrategy"]: | ||
| strategies.append( | ||
| GitHubSbomMetadataCollectionStrategy( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assignment accepts raw
--branchinput and later feeds it intogit clone ... --branch={effective_branch}executed throughrun_command(os.system), so shell metacharacters in the branch value can execute arbitrary commands. The new CLI option introduces a direct user-controlled path into a shell command; validate the ref format and avoid shell-string execution for clone arguments.Useful? React with 👍 / 👎.