163
163
164
164
165
165
def output_console_comments (diff_report : Diff , sbom_file_name : str = None ) -> None :
166
- console_security_comment = Messages .create_console_security_alert_table (diff_report )
167
- save_sbom_file (diff_report , sbom_file_name )
168
- log .info (f"Socket Full Scan ID: { diff_report .id } " )
169
- if not report_pass (diff_report ):
170
- log .info ("Security issues detected by Socket Security" )
171
- msg = f"\n { console_security_comment } "
172
- log .info (msg )
173
- if not blocking_disabled :
174
- sys .exit (1 )
175
- else :
176
- log .info ("No New Security issues detected by Socket Security" )
166
+ if diff_report .id != "NO_DIFF_RAN" :
167
+ console_security_comment = Messages .create_console_security_alert_table (diff_report )
168
+ save_sbom_file (diff_report , sbom_file_name )
169
+ log .info (f"Socket Full Scan ID: { diff_report .id } " )
170
+ if len (diff_report .new_alerts ) > 0 :
171
+ log .info ("Security issues detected by Socket Security" )
172
+ msg = f"\n { console_security_comment } "
173
+ log .info (msg )
174
+ if not report_pass (diff_report ) and not blocking_disabled :
175
+ sys .exit (1 )
176
+ else :
177
+ # Means only warning alerts with no blocked
178
+ if not blocking_disabled :
179
+ sys .exit (5 )
180
+ else :
181
+ log .info ("No New Security issues detected by Socket Security" )
177
182
178
183
179
184
def output_console_json (diff_report : Diff , sbom_file_name : str = None ) -> None :
180
- console_security_comment = Messages .create_security_comment_json (diff_report )
181
- save_sbom_file (diff_report , sbom_file_name )
182
- print (json .dumps (console_security_comment ))
183
- if not report_pass (diff_report ) and not blocking_disabled :
184
- sys .exit (1 )
185
+ if diff_report .id != "NO_DIFF_RAN" :
186
+ console_security_comment = Messages .create_security_comment_json (diff_report )
187
+ save_sbom_file (diff_report , sbom_file_name )
188
+ print (json .dumps (console_security_comment ))
189
+ if not report_pass (diff_report ) and not blocking_disabled :
190
+ sys .exit (1 )
191
+ elif len (diff_report .new_alerts ) > 0 and not blocking_disabled :
192
+ # Means only warning alerts with no blocked
193
+ sys .exit (5 )
185
194
186
195
187
196
def report_pass (diff_report : Diff ) -> bool :
@@ -299,11 +308,12 @@ def main_code():
299
308
default_branch = scm .is_default_branch
300
309
301
310
base_api_url = os .getenv ("BASE_API_URL" ) or None
302
- core = Core (token = api_token , request_timeout = 1200 , base_api_url = base_api_url )
311
+ core = Core (token = api_token , request_timeout = 1200 , base_api_url = base_api_url , allow_unverified = allow_unverified )
303
312
no_change = True
304
313
if ignore_commit_files :
305
314
no_change = False
306
315
elif is_repo and files is not None and len (files ) > 0 :
316
+ log .info (files )
307
317
no_change = core .match_supported_files (files )
308
318
309
319
set_as_pending_head = False
@@ -319,7 +329,8 @@ def main_code():
319
329
make_default_branch = default_branch ,
320
330
set_as_pending_head = set_as_pending_head
321
331
)
322
- diff = None
332
+ diff = Diff ()
333
+ diff .id = "NO_DIFF_RAN"
323
334
if scm is not None and scm .check_event_type () == "comment" :
324
335
log .info ("Comment initiated flow" )
325
336
log .debug (f"Getting comments for Repo { scm .repository } for PR { scm .pr_number } " )
@@ -329,10 +340,11 @@ def main_code():
329
340
elif scm is not None and scm .check_event_type () != "comment" :
330
341
log .info ("Push initiated flow" )
331
342
diff : Diff
332
- diff = core .create_new_diff (target_path , params , workspace = target_path , no_change = no_change )
333
343
if no_change :
334
- log .info ("No dependency changes" )
344
+ log .info ("No manifest files changes, skipping scan" )
345
+ # log.info("No dependency changes")
335
346
elif scm .check_event_type () == "diff" :
347
+ diff = core .create_new_diff (target_path , params , workspace = target_path , no_change = no_change )
336
348
log .info ("Starting comment logic for PR/MR event" )
337
349
log .debug (f"Getting comments for Repo { scm .repository } for PR { scm .pr_number } " )
338
350
comments = scm .get_comments_for_pr (repo , str (pr_number ))
0 commit comments