@@ -197,12 +197,13 @@ impl SecretPatternManager {
197197 ToolPattern {
198198 tool_name: "AWS" . to_string( ) ,
199199 pattern_type: "access_key" . to_string( ) ,
200- pattern: Regex :: new( r#"AKIA[0-9A-Z]{16}"# ) ?,
200+ // More specific - must be in assignment context
201+ pattern: Regex :: new( r#"(?i)(?:aws[_-]?access[_-]?key|access[_-]?key[_-]?id)\s*[:=]\s*["']?(AKIA[0-9A-Z]{16})["']?"# ) ?,
201202 severity: SecuritySeverity :: Critical ,
202- description: "AWS access key ID (CRITICAL)" . to_string( ) ,
203+ description: "AWS access key ID in assignment (CRITICAL)" . to_string( ) ,
203204 public_safe: false ,
204205 context_keywords: vec![ "aws" . to_string( ) , "access" . to_string( ) , "key" . to_string( ) ] ,
205- false_positive_keywords: vec![ ] ,
206+ false_positive_keywords: vec![ "example" . to_string ( ) , "AKIAEXAMPLE" . to_string ( ) ] ,
206207 } ,
207208 ToolPattern {
208209 tool_name: "AWS" . to_string( ) ,
@@ -212,7 +213,7 @@ impl SecretPatternManager {
212213 description: "AWS secret access key (CRITICAL)" . to_string( ) ,
213214 public_safe: false ,
214215 context_keywords: vec![ "aws" . to_string( ) , "secret" . to_string( ) ] ,
215- false_positive_keywords: vec![ ] ,
216+ false_positive_keywords: vec![ "example" . to_string ( ) , "your_secret" . to_string ( ) , "placeholder" . to_string ( ) ] ,
216217 } ,
217218 ] ) ;
218219
@@ -267,18 +268,20 @@ impl SecretPatternManager {
267268 GenericPattern {
268269 id: "bearer-token" . to_string( ) ,
269270 name: "Bearer Token" . to_string( ) ,
270- pattern: Regex :: new( r#"(?i)(?:authorization|bearer)\s*[:=]\s*["'](?:bearer\s+)?([A-Za-z0-9_-]{20,})["']"# ) ?,
271+ // More specific - exclude template literals and ensure it's a real assignment
272+ pattern: Regex :: new( r#"(?i)(?:authorization|bearer)\s*[:=]\s*["'](?:bearer\s+)?([A-Za-z0-9_-]{32,})["'](?!\s*\$\{)"# ) ?,
271273 severity: SecuritySeverity :: Critical ,
272274 category: SecurityCategory :: SecretsExposure ,
273- description: "Bearer token in authorization header" . to_string( ) ,
275+ description: "Bearer token in authorization header (excluding templates) " . to_string( ) ,
274276 } ,
275277 GenericPattern {
276278 id: "jwt-token" . to_string( ) ,
277279 name: "JWT Token" . to_string( ) ,
278- pattern: Regex :: new( r#"eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+"# ) ?,
280+ // More specific JWT pattern - must be properly formatted and in assignment context
281+ pattern: Regex :: new( r#"(?i)(?:token|jwt|authorization|bearer)\s*[:=]\s*["']?eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}["']?"# ) ?,
279282 severity: SecuritySeverity :: Medium ,
280283 category: SecurityCategory :: SecretsExposure ,
281- description: "JSON Web Token detected" . to_string( ) ,
284+ description: "JSON Web Token detected in assignment " . to_string( ) ,
282285 } ,
283286 GenericPattern {
284287 id: "database-url" . to_string( ) ,
@@ -299,10 +302,11 @@ impl SecretPatternManager {
299302 GenericPattern {
300303 id: "generic-api-key" . to_string( ) ,
301304 name: "Generic API Key" . to_string( ) ,
302- pattern: Regex :: new( r#"(?i)(?:api[_-]?key|apikey)\s*[:=]\s*["']([A-Za-z0-9_-]{20,})["']"# ) ?,
305+ // More specific - require longer keys and exclude common false positives
306+ pattern: Regex :: new( r#"(?i)(?:api[_-]?key|apikey)\s*[:=]\s*["']([A-Za-z0-9_-]{32,})["']"# ) ?,
303307 severity: SecuritySeverity :: High ,
304308 category: SecurityCategory :: SecretsExposure ,
305- description: "Generic API key pattern" . to_string( ) ,
309+ description: "Generic API key pattern (32+ characters) " . to_string( ) ,
306310 } ,
307311 ] ;
308312
0 commit comments