Skip to content

Commit e446850

Browse files
committed
fix: include branch information in scan parameters for repository scans
- Store branch name in context when provided via --branch flag - Include branch in scan_parameters dict sent to backend API - Fixes issue where branch_name and branch_id were null in JSON export This ensures that when scanning a specific branch with 'cycode scan repository --branch <branch>', the branch information is properly sent to the backend API so it can populate branch_name and branch_id fields in the detection details.
1 parent 63d06ff commit e446850

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

cycode/cli/apps/scan/repository/repository_command.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ def repository_command(
6767

6868
add_sca_dependencies_tree_documents_if_needed(ctx, scan_type, documents_to_scan)
6969

70+
# Store branch in context so it can be included in scan parameters
71+
if branch:
72+
ctx.obj['branch'] = branch
73+
7074
logger.debug('Found all relevant files for scanning %s', {'path': path, 'branch': branch})
7175
scan_documents(ctx, documents_to_scan, get_scan_parameters(ctx, (str(path),)))
7276
except Exception as e:

cycode/cli/apps/scan/scan_parameters.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,9 @@ def get_scan_parameters(ctx: typer.Context, paths: Optional[tuple[str, ...]] = N
3333
ctx.obj['remote_url'] = remote_url
3434
scan_parameters['remote_url'] = remote_url
3535

36+
# Include branch information if available (for repository scans)
37+
branch = ctx.obj.get('branch')
38+
if branch:
39+
scan_parameters['branch'] = branch
40+
3641
return scan_parameters

0 commit comments

Comments
 (0)