@@ -136,13 +136,35 @@ def main_code():
136
136
raise Exception (f"Unable to find path { config .target_path } " )
137
137
138
138
if not config .repo :
139
- config .repo = "socket-default-repo"
139
+ base_repo_name = "socket-default-repo"
140
+ if config .workspace_name :
141
+ config .repo = f"{ base_repo_name } -{ config .workspace_name } "
142
+ else :
143
+ config .repo = base_repo_name
140
144
log .debug (f"Using default repository name: { config .repo } " )
141
145
142
146
if not config .branch :
143
147
config .branch = "socket-default-branch"
144
148
log .debug (f"Using default branch name: { config .branch } " )
145
149
150
+ # Calculate the scan path - combine target_path with sub_path if provided
151
+ scan_path = config .target_path
152
+ if config .sub_path :
153
+ import os
154
+ scan_path = os .path .join (config .target_path , config .sub_path )
155
+ log .debug (f"Using sub-path for scanning: { scan_path } " )
156
+ # Verify the scan path exists
157
+ if not os .path .exists (scan_path ):
158
+ raise Exception (f"Sub-path does not exist: { scan_path } " )
159
+
160
+ # Modify repository name if workspace_name is provided
161
+ if config .workspace_name and config .repo :
162
+ config .repo = f"{ config .repo } -{ config .workspace_name } "
163
+ log .debug (f"Modified repository name with workspace suffix: { config .repo } " )
164
+ elif config .workspace_name and not config .repo :
165
+ # If no repo name was set but workspace_name is provided, we'll use it later
166
+ log .debug (f"Workspace name provided: { config .workspace_name } " )
167
+
146
168
scm = None
147
169
if config .scm == "github" :
148
170
from socketsecurity .core .scm .github import Github , GithubConfig
@@ -179,6 +201,21 @@ def main_code():
179
201
# Check if we have supported manifest files
180
202
has_supported_files = files_to_check and core .has_manifest_files (files_to_check )
181
203
204
+ # If using sub_path, we need to check if manifest files exist in the scan path
205
+ if config .sub_path and not files_explicitly_specified :
206
+ # Override file checking to look in the scan path instead
207
+ import os
208
+ from pathlib import Path
209
+
210
+ # Get manifest files from the scan path
211
+ try :
212
+ scan_files = core .find_files (scan_path )
213
+ has_supported_files = len (scan_files ) > 0
214
+ log .debug (f"Found { len (scan_files )} manifest files in scan path: { scan_path } " )
215
+ except Exception as e :
216
+ log .debug (f"Error finding files in scan path { scan_path } : { e } " )
217
+ has_supported_files = False
218
+
182
219
# Case 3: If no supported files or files are empty, force API mode (no PR comments)
183
220
if not has_supported_files :
184
221
force_api_mode = True
@@ -264,7 +301,7 @@ def main_code():
264
301
log .info ("Push initiated flow" )
265
302
if scm .check_event_type () == "diff" :
266
303
log .info ("Starting comment logic for PR/MR event" )
267
- diff = core .create_new_diff (config . target_path , params , no_change = should_skip_scan , save_files_list_path = config .save_submitted_files_list , save_manifest_tar_path = config .save_manifest_tar )
304
+ diff = core .create_new_diff (scan_path , params , no_change = should_skip_scan , save_files_list_path = config .save_submitted_files_list , save_manifest_tar_path = config .save_manifest_tar )
268
305
comments = scm .get_comments_for_pr ()
269
306
log .debug ("Removing comment alerts" )
270
307
@@ -317,14 +354,14 @@ def main_code():
317
354
)
318
355
else :
319
356
log .info ("Starting non-PR/MR flow" )
320
- diff = core .create_new_diff (config . target_path , params , no_change = should_skip_scan , save_files_list_path = config .save_submitted_files_list , save_manifest_tar_path = config .save_manifest_tar )
357
+ diff = core .create_new_diff (scan_path , params , no_change = should_skip_scan , save_files_list_path = config .save_submitted_files_list , save_manifest_tar_path = config .save_manifest_tar )
321
358
322
359
output_handler .handle_output (diff )
323
360
324
361
elif config .enable_diff and not force_api_mode :
325
362
# New logic: --enable-diff forces diff mode even with --integration api (no SCM)
326
363
log .info ("Diff mode enabled without SCM integration" )
327
- diff = core .create_new_diff (config . target_path , params , no_change = should_skip_scan , save_files_list_path = config .save_submitted_files_list , save_manifest_tar_path = config .save_manifest_tar )
364
+ diff = core .create_new_diff (scan_path , params , no_change = should_skip_scan , save_files_list_path = config .save_submitted_files_list , save_manifest_tar_path = config .save_manifest_tar )
328
365
output_handler .handle_output (diff )
329
366
330
367
elif config .enable_diff and force_api_mode :
@@ -337,7 +374,7 @@ def main_code():
337
374
}
338
375
log .debug (f"params={ serializable_params } " )
339
376
diff = core .create_full_scan_with_report_url (
340
- config . target_path ,
377
+ scan_path ,
341
378
params ,
342
379
no_change = should_skip_scan ,
343
380
save_files_list_path = config .save_submitted_files_list ,
@@ -356,7 +393,7 @@ def main_code():
356
393
}
357
394
log .debug (f"params={ serializable_params } " )
358
395
diff = core .create_full_scan_with_report_url (
359
- config . target_path ,
396
+ scan_path ,
360
397
params ,
361
398
no_change = should_skip_scan ,
362
399
save_files_list_path = config .save_submitted_files_list ,
@@ -367,7 +404,7 @@ def main_code():
367
404
else :
368
405
log .info ("API Mode" )
369
406
diff = core .create_new_diff (
370
- config . target_path , params ,
407
+ scan_path , params ,
371
408
no_change = should_skip_scan ,
372
409
save_files_list_path = config .save_submitted_files_list ,
373
410
save_manifest_tar_path = config .save_manifest_tar
0 commit comments