@@ -224,6 +224,7 @@ def create_full_scan(self, files: List[str], params: FullScanParams, store_resul
224
224
225
225
# Time the post API call
226
226
post_start = time .time ()
227
+
227
228
res = self .sdk .fullscans .post (files , params )
228
229
post_end = time .time ()
229
230
log .debug (f"API fullscans.post took { post_end - post_start :.2f} seconds" )
@@ -235,13 +236,32 @@ def create_full_scan(self, files: List[str], params: FullScanParams, store_resul
235
236
full_scan = FullScan (** asdict (res .data ))
236
237
237
238
if not store_results :
239
+ log .debug ("Skipping results storage as requested" )
238
240
full_scan .sbom_artifacts = []
239
241
full_scan .packages = {}
240
242
return full_scan
241
243
244
+ # Add extensive debug logging
245
+ log .debug (f"Full scan created with ID: { full_scan .id } " )
246
+ log .debug (f"Organization slug: { self .config .org_slug } " )
247
+ log .debug (f"store_results is { store_results } " )
248
+ log .debug (f"Params used for scan: { params } " )
249
+
242
250
# Time the stream API call
243
251
stream_start = time .time ()
244
- artifacts_response = self .sdk .fullscans .stream (self .config .org_slug , full_scan .id )
252
+ log .debug (f"Initiating stream request for full scan { full_scan .id } " )
253
+ try :
254
+ artifacts_response = self .sdk .fullscans .stream (self .config .org_slug , full_scan .id )
255
+ log .debug (f"Stream response received: success={ artifacts_response .success } " )
256
+ if hasattr (artifacts_response , 'status' ):
257
+ log .debug (f"Stream response status: { artifacts_response .status } " )
258
+ if hasattr (artifacts_response , 'message' ):
259
+ log .debug (f"Stream response message: { artifacts_response .message } " )
260
+ except Exception as e :
261
+ log .error (f"Exception during stream request: { str (e )} " )
262
+ log .error (f"Exception type: { type (e )} " )
263
+ raise
264
+
245
265
stream_end = time .time ()
246
266
log .debug (f"API fullscans.stream took { stream_end - stream_start :.2f} seconds" )
247
267
@@ -254,11 +274,13 @@ def create_full_scan(self, files: List[str], params: FullScanParams, store_resul
254
274
255
275
# Store the original SocketArtifact objects
256
276
full_scan .sbom_artifacts = list (artifacts_response .artifacts .values ())
277
+ log .debug (f"Retrieved { len (full_scan .sbom_artifacts )} artifacts" )
257
278
258
279
# Create packages dictionary directly from the artifacts
259
280
packages = {}
260
281
top_level_count = {}
261
282
283
+ log .debug ("Starting package processing from artifacts" )
262
284
for artifact in artifacts_response .artifacts .values ():
263
285
package = Package .from_socket_artifact (artifact )
264
286
if package .id not in packages :
@@ -275,6 +297,7 @@ def create_full_scan(self, files: List[str], params: FullScanParams, store_resul
275
297
package .transitives = top_level_count .get (package .id , 0 )
276
298
277
299
full_scan .packages = packages
300
+ log .debug (f"Processed { len (packages )} packages" )
278
301
279
302
create_full_end = time .time ()
280
303
total_time = create_full_end - create_full_start
@@ -412,7 +435,7 @@ def get_added_and_removed_packages(self, head_full_scan_id: Optional[str], new_f
412
435
# Process added and updated artifacts
413
436
for artifact in chain (diff_report .artifacts .added , diff_report .artifacts .updated ):
414
437
try :
415
- pkg = Package .from_socket_artifact (artifact )
438
+ pkg = Package .from_diff_artifact (artifact )
416
439
added_packages [artifact .id ] = pkg
417
440
except KeyError as e :
418
441
log .error (f"KeyError creating package from added artifact { artifact .id } : { e } " )
@@ -457,6 +480,8 @@ def create_new_diff(
457
480
pass
458
481
459
482
# Create new scan - only store results if we don't have a head scan to diff against
483
+ if head_full_scan_id is None :
484
+ log .debug ("No head scan found to diff against" )
460
485
new_full_scan = self .create_full_scan (files_for_sending , params , store_results = head_full_scan_id is None )
461
486
462
487
added_packages , removed_packages = self .get_added_and_removed_packages (head_full_scan_id , new_full_scan )
@@ -595,26 +620,31 @@ def get_source_data(package: Package, packages: dict) -> list:
595
620
introduced_by = []
596
621
if package .direct :
597
622
manifests = ""
598
- for manifest_data in package .manifestFiles :
599
- manifest_file = manifest_data .get ("file" )
600
- manifests += f"{ manifest_file } ;"
601
- manifests = manifests .rstrip (";" )
623
+ if package .manifestFiles :
624
+ for manifest_data in package .manifestFiles :
625
+ manifest_file = manifest_data ["file" ]
626
+ if manifest_file :
627
+ manifests += f"{ manifest_file } ;"
628
+ manifests = manifests .rstrip (";" )
602
629
source = ("direct" , manifests )
603
630
introduced_by .append (source )
604
631
else :
605
- for top_id in package .topLevelAncestors :
632
+ for top_id in package .topLevelAncestors or [] :
606
633
top_package = packages .get (top_id )
607
634
if top_package :
608
635
manifests = ""
609
636
top_purl = f"{ top_package .type } /{ top_package .name } @{ top_package .version } "
610
- for manifest_data in top_package .manifestFiles :
611
- manifest_file = manifest_data .get ("file" )
612
- manifests += f"{ manifest_file } ;"
613
- manifests = manifests .rstrip (";" )
637
+ if top_package .manifestFiles :
638
+ for manifest_data in top_package .manifestFiles :
639
+ manifest_file = manifest_data ["file" ]
640
+ if manifest_file :
641
+ manifests += f"{ manifest_file } ;"
642
+ manifests = manifests .rstrip (";" )
614
643
source = (top_purl , manifests )
615
644
introduced_by .append (source )
616
645
else :
617
646
log .debug (f"Unable to get top level package info for { top_id } " )
647
+
618
648
return introduced_by
619
649
620
650
@staticmethod
0 commit comments