@@ -46,20 +46,22 @@ def __init__(
46
46
check_exploits : bool = False ,
47
47
exploits_list : List [str ] = [],
48
48
disabled_sources : List [str ] = [],
49
+ no_scan : bool = False ,
49
50
):
50
- self .logger = logger or LOGGER .getChild (self .__class__ .__name__ )
51
- self .error_mode = error_mode
52
51
self .score = score
53
52
self .check_metrics = check_metrics
54
53
self .epss_percentile = epss_percentile
55
54
self .epss_probability = epss_probability
56
- self .products_with_cve = 0
57
- self .products_without_cve = 0
58
- self .all_cve_data = defaultdict (CVEData )
59
- self .all_cve_version_info = dict ()
55
+ self .logger = logger or LOGGER .getChild (self .__class__ .__name__ )
56
+ self .error_mode = error_mode
60
57
self .check_exploits = check_exploits
61
58
self .exploits_list = exploits_list
62
59
self .disabled_sources = disabled_sources
60
+ self .no_scan = no_scan
61
+ self .products_with_cve = 0
62
+ self .products_without_cve = 0
63
+ self .all_cve_data = defaultdict (lambda : {"cves" : [], "paths" : set ()})
64
+ self .all_cve_version_info = dict ()
63
65
self .all_product_data = dict ()
64
66
65
67
def get_cves (self , product_info : ProductInfo , triage_data : TriageData ):
@@ -74,6 +76,21 @@ def get_cves(self, product_info: ProductInfo, triage_data: TriageData):
74
76
if self .score > 10 or self .epss_probability > 1.0 or self .epss_percentile > 1.0 :
75
77
return
76
78
79
+ # Handle no-scan mode
80
+ if self .no_scan :
81
+ # In no-scan mode, just populate the product data without CVE scanning
82
+ if product_info not in self .all_product_data :
83
+ self .logger .debug (f"Add product { product_info } (no-scan mode)" )
84
+ self .all_product_data [product_info ] = 0
85
+
86
+ # Also populate all_cve_data with empty CVE list and paths
87
+ if product_info not in self .all_cve_data :
88
+ self .all_cve_data [product_info ] = {"cves" : [], "paths" : set ()}
89
+
90
+ # Update paths
91
+ self .all_cve_data [product_info ]["paths" ] |= set (triage_data ["paths" ])
92
+ return
93
+
77
94
if product_info .vendor == "UNKNOWN" :
78
95
# Add product
79
96
if product_info not in self .all_product_data :
@@ -298,7 +315,7 @@ def get_cves(self, product_info: ProductInfo, triage_data: TriageData):
298
315
self .epss_percentile ,
299
316
self .epss_probability ,
300
317
)
301
- # row_dict doesnt have metric as key. As it based on result from query on
318
+ # row_dict doesn't have metric as key. As it based on result from query on
302
319
# cve_severity table declaring row_dict[metric]
303
320
row_dict ["metric" ] = {}
304
321
# looping for result of query for metrics.
@@ -481,9 +498,10 @@ def __enter__(self):
481
498
Returns:
482
499
CVEScanner: The instance of the CVEScanner with an active database connection.
483
500
"""
484
- self .connection = sqlite3 .connect (self .dbname )
485
- self .connection .row_factory = sqlite3 .Row
486
- self .cursor = self .connection .cursor ()
501
+ if not self .no_scan :
502
+ self .connection = sqlite3 .connect (self .dbname )
503
+ self .connection .row_factory = sqlite3 .Row
504
+ self .cursor = self .connection .cursor ()
487
505
return self
488
506
489
507
def __exit__ (self , exc_type , exc_val , exc_tb ):
@@ -498,5 +516,6 @@ def __exit__(self, exc_type, exc_val, exc_tb):
498
516
Returns:
499
517
None
500
518
"""
501
- self .cursor .close ()
502
- self .connection .close ()
519
+ if not self .no_scan and hasattr (self , "cursor" ) and hasattr (self , "connection" ):
520
+ self .cursor .close ()
521
+ self .connection .close ()
0 commit comments