@@ -31,12 +31,13 @@ def remove_alerts(comments: dict, new_alerts: list) -> list:
3131 if ignore_all :
3232 break
3333 else :
34- purl = f"{ alert .pkg_name } , { alert .pkg_version } "
35- purl_star = f"{ alert .pkg_name } , *"
34+ full_name = f"{ alert .pkg_type } /{ alert .pkg_name } "
35+ purl = (full_name , alert .pkg_version )
36+ purl_star = (full_name , "*" )
3637 if purl in ignore_commands or purl_star in ignore_commands :
37- print (f"Alerts for { alert .pkg_name } @{ alert .pkg_version } ignored" )
38+ log . info (f"Alerts for { alert .pkg_name } @{ alert .pkg_version } ignored" )
3839 else :
39- print (f"Adding alert { alert .type } for { alert .pkg_name } @{ alert .pkg_version } " )
40+ log . info (f"Adding alert { alert .type } for { alert .pkg_name } @{ alert .pkg_version } " )
4041 alerts .append (alert )
4142 return alerts
4243
@@ -49,16 +50,20 @@ def get_ignore_options(comments: dict) -> [bool, list]:
4950 comment : Comment
5051 first_line = comment .body_list [0 ]
5152 if not ignore_all and "SocketSecurity ignore" in first_line :
52- first_line = first_line .lstrip ("@" )
53- _ , command = first_line .split ("SocketSecurity " )
54- command = command .strip ()
55- if command == "ignore-all" :
56- ignore_all = True
57- else :
58- command = command .lstrip ("ignore" ).strip ()
59- name , version = command .split ("@" )
60- data = f"{ name } , { version } "
61- ignore_commands .append (data )
53+ try :
54+ first_line = first_line .lstrip ("@" )
55+ _ , command = first_line .split ("SocketSecurity " )
56+ command = command .strip ()
57+ if command == "ignore-all" :
58+ ignore_all = True
59+ else :
60+ command = command .lstrip ("ignore" ).strip ()
61+ name , version = command .split ("@" )
62+ data = (name , version )
63+ ignore_commands .append (data )
64+ except Exception as error :
65+ log .error (f"Unable to process ignore command for { comment } " )
66+ log .error (error )
6267 return ignore_all , ignore_commands
6368
6469 @staticmethod
@@ -71,7 +76,7 @@ def is_ignore(pkg_name: str, pkg_version: str, name: str, version: str) -> bool:
7176 @staticmethod
7277 def is_heading_line (line ) -> bool :
7378 is_heading_line = True
74- if line != "|Alert|Package|Introduced by|Manifest File|" and ":---" not in line :
79+ if line != "|Alert|Package|Introduced by|Manifest File|CI| " and ":---" not in line :
7580 is_heading_line = False
7681 return is_heading_line
7782
@@ -86,10 +91,12 @@ def process_security_comment(comment: Comment, comments) -> str:
8691 start = True
8792 lines .append (line )
8893 elif start and "end-socket-alerts-table" not in line and not Comments .is_heading_line (line ) and line != '' :
89- title , package , introduced_by , manifest = line .lstrip ("|" ).rstrip ("|" ).split ("|" )
94+ title , package , introduced_by , manifest , ci = line .lstrip ("|" ).rstrip ("|" ).split ("|" )
9095 details , _ = package .split ("](" )
9196 ecosystem , details = details .split ("/" , 1 )
97+ ecosystem = ecosystem .lstrip ("[" )
9298 pkg_name , pkg_version = details .split ("@" )
99+ pkg_name = f"{ ecosystem } /{ pkg_name } "
93100 ignore = False
94101 for name , version in ignore_commands :
95102 if ignore_all or Comments .is_ignore (pkg_name , pkg_version , name , version ):
@@ -114,7 +121,7 @@ def check_for_socket_comments(comments: dict):
114121 socket_comments ["security" ] = comment
115122 elif "socket-overview-comment-actions" in comment .body :
116123 socket_comments ["overview" ] = comment
117- elif "SocketSecurity ignore" in comment .body :
124+ elif "SocketSecurity ignore" . lower () in comment .body_list [ 0 ]. lower () :
118125 if "ignore" not in socket_comments :
119126 socket_comments ["ignore" ] = []
120127 socket_comments ["ignore" ].append (comment )
0 commit comments