@@ -18,7 +18,7 @@ class Messages:
18
18
def map_severity_to_sarif (severity : str ) -> str :
19
19
"""
20
20
Map Socket severity levels to SARIF levels (GitHub code scanning).
21
-
21
+
22
22
'low' -> 'note'
23
23
'medium' or 'middle' -> 'warning'
24
24
'high' or 'critical' -> 'error'
@@ -45,6 +45,7 @@ def find_line_in_file(packagename: str, packageversion: str, manifest_file: str)
45
45
2) Text-based (requirements.txt, package.json, yarn.lock, etc.)
46
46
- Uses compiled regex patterns to detect a match line by line
47
47
"""
48
+ # Extract just the file name to detect manifest type
48
49
file_type = Path (manifest_file ).name
49
50
logging .debug ("Processing file: %s" , manifest_file )
50
51
@@ -206,8 +207,8 @@ def create_security_comment_sarif(diff) -> dict:
206
207
severity = alert .severity
207
208
208
209
# --- Extract manifest files from alert data ---
209
- manifest_files = []
210
210
logging .debug ("Alert %s - introduced_by: %s, manifests: %s" , rule_id , alert .introduced_by , getattr (alert , 'manifests' , None ))
211
+ manifest_files = []
211
212
if alert .introduced_by and isinstance (alert .introduced_by , list ):
212
213
for entry in alert .introduced_by :
213
214
if isinstance (entry , list ) and len (entry ) >= 2 :
@@ -218,9 +219,8 @@ def create_security_comment_sarif(diff) -> dict:
218
219
manifest_files = [mf .strip () for mf in alert .manifests .split (";" ) if mf .strip ()]
219
220
220
221
if not manifest_files :
221
- # Do not fall back to requirements.txt; log an error instead.
222
222
logging .error ("Alert %s: No manifest file found; cannot determine file location." , rule_id )
223
- continue # Skip this alert
223
+ continue # Skip this alert if no manifest is provided
224
224
225
225
logging .debug ("Alert %s using manifest_files: %s" , rule_id , manifest_files )
226
226
# Use the first manifest for URL generation.
@@ -246,7 +246,7 @@ def create_security_comment_sarif(diff) -> dict:
246
246
for mf in manifest_files :
247
247
line_number , line_content = Messages .find_line_in_file (pkg_name , pkg_version , mf )
248
248
if line_number < 1 :
249
- line_number = 1 # Ensure SARIF compliance.
249
+ line_number = 1
250
250
logging .debug ("Alert %s: Manifest %s, line %d: %s" , rule_id , mf , line_number , line_content )
251
251
locations .append ({
252
252
"physicalLocation" : {
0 commit comments