@@ -18,7 +18,7 @@ class Messages:
1818 def map_severity_to_sarif (severity : str ) -> str :
1919 """
2020 Map Socket severity levels to SARIF levels (GitHub code scanning).
21-
21+
2222 'low' -> 'note'
2323 'medium' or 'middle' -> 'warning'
2424 'high' or 'critical' -> 'error'
@@ -45,6 +45,7 @@ def find_line_in_file(packagename: str, packageversion: str, manifest_file: str)
4545 2) Text-based (requirements.txt, package.json, yarn.lock, etc.)
4646 - Uses compiled regex patterns to detect a match line by line
4747 """
48+ # Extract just the file name to detect manifest type
4849 file_type = Path (manifest_file ).name
4950 logging .debug ("Processing file: %s" , manifest_file )
5051
@@ -206,8 +207,8 @@ def create_security_comment_sarif(diff) -> dict:
206207 severity = alert .severity
207208
208209 # --- Extract manifest files from alert data ---
209- manifest_files = []
210210 logging .debug ("Alert %s - introduced_by: %s, manifests: %s" , rule_id , alert .introduced_by , getattr (alert , 'manifests' , None ))
211+ manifest_files = []
211212 if alert .introduced_by and isinstance (alert .introduced_by , list ):
212213 for entry in alert .introduced_by :
213214 if isinstance (entry , list ) and len (entry ) >= 2 :
@@ -218,9 +219,8 @@ def create_security_comment_sarif(diff) -> dict:
218219 manifest_files = [mf .strip () for mf in alert .manifests .split (";" ) if mf .strip ()]
219220
220221 if not manifest_files :
221- # Do not fall back to requirements.txt; log an error instead.
222222 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
224224
225225 logging .debug ("Alert %s using manifest_files: %s" , rule_id , manifest_files )
226226 # Use the first manifest for URL generation.
@@ -246,7 +246,7 @@ def create_security_comment_sarif(diff) -> dict:
246246 for mf in manifest_files :
247247 line_number , line_content = Messages .find_line_in_file (pkg_name , pkg_version , mf )
248248 if line_number < 1 :
249- line_number = 1 # Ensure SARIF compliance.
249+ line_number = 1
250250 logging .debug ("Alert %s: Manifest %s, line %d: %s" , rule_id , mf , line_number , line_content )
251251 locations .append ({
252252 "physicalLocation" : {
0 commit comments