File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ def __init__(self) -> None:
9999 "Research Concepts" : "1000.csv" ,
100100 }
101101 self .directory = USER_CACHE_DIR / "cwe"
102+ self .NOCWE = CWE (id = - 1 , name = " Missing or invalid CWE" , description = "None" )
102103
103104 try :
104105 self .cwes = self .load ()
@@ -162,7 +163,7 @@ def from_string(self, cwe_string: str) -> CWE:
162163 if match := re .search (r"[CWE|cwe]-(\d+)" , cwe_string ):
163164 return self .from_id (int (match .group (1 )))
164165 else :
165- return CWE ( id = - 1 , name = "Invalid CWE" , description = "None" )
166+ return self . NOCWE
166167
167168 def from_id (self , cwe_id : int ) -> CWE :
168169 """Get a CWE by its identifier.
@@ -177,7 +178,7 @@ def from_id(self, cwe_id: int) -> CWE:
177178 try :
178179 return self .cwes [self .cwes .index (cwe_id )]
179180 except ValueError :
180- return CWE ( id = - 1 , name = "Invalid CWE" , description = "None" )
181+ return self . NOCWE
181182
182183
183184CWEs = CWEsCollection ()
You can’t perform that action at this time.
0 commit comments