Skip to content

Commit 2b3f6c6

Browse files
cursoragentscript3r
andcommitted
Remove PHP support and update Rust AES pattern
Co-authored-by: script3r <[email protected]>
1 parent 8524d74 commit 2b3f6c6

File tree

4 files changed

+11
-47
lines changed

4 files changed

+11
-47
lines changed

Cargo.lock

Lines changed: 0 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/cli/src/main.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@ fn main() -> Result<()> {
9292
&[Language::Go],
9393
patterns.clone(),
9494
).with_context(|| "Failed to create Go AST detector")?),
95-
Box::new(AstBasedDetector::with_patterns(
96-
"ast-detector-php",
97-
&[Language::Php],
98-
patterns.clone(),
99-
).with_context(|| "Failed to create PHP AST detector")?),
10095
];
10196

10297
let mut cfg = Config {

crates/scanner-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ tree-sitter-python = { workspace = true }
2424
tree-sitter-javascript = { workspace = true }
2525
tree-sitter-java = { workspace = true }
2626
tree-sitter-go = { workspace = true }
27-
tree-sitter-php = { workspace = true }
27+
# tree-sitter-php = { workspace = true }
2828
# tree-sitter-swift = { workspace = true }
2929
# tree-sitter-kotlin = { workspace = true }
3030

crates/scanner-core/src/ast.rs

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,7 @@ impl AstDetector {
5656
parsers.insert(ScanLanguage::Java, Self::create_parser(tree_sitter_java::language())?);
5757
parsers.insert(ScanLanguage::Go, Self::create_parser(tree_sitter_go::language())?);
5858

59-
// Try to add PHP parser - check if it has the language() function
60-
if let Ok(php_parser) = Self::try_create_php_parser() {
61-
parsers.insert(ScanLanguage::Php, php_parser);
62-
}
63-
64-
// Note: Swift, Kotlin, Objective-C and Erlang disabled due to inconsistent tree-sitter APIs
59+
// Note: PHP, Swift, Kotlin, Objective-C and Erlang disabled due to inconsistent tree-sitter APIs
6560

6661
Ok(Self {
6762
parsers,
@@ -76,14 +71,6 @@ impl AstDetector {
7671
Ok(parser)
7772
}
7873

79-
fn try_create_php_parser() -> Result<Parser> {
80-
let mut parser = Parser::new();
81-
// Try the standard language() function first
82-
let language = tree_sitter_php::language();
83-
parser.set_language(&language)
84-
.map_err(|e| anyhow!("Failed to set PHP parser language: {}", e))?;
85-
Ok(parser)
86-
}
8774

8875
/// Load AST patterns from patterns.toml or use defaults
8976
pub fn load_patterns_from_file(patterns_file: &str) -> Result<Vec<AstPattern>> {
@@ -227,11 +214,16 @@ impl AstDetector {
227214
metadata: HashMap::new(),
228215
},
229216

230-
// Rust AES constants
217+
// Rust AES constants (more specific)
231218
AstPattern {
232219
query: r#"
233-
(identifier) @id
234-
(#match? @id "AES_.*_GCM")
220+
(use_declaration
221+
argument: (scoped_use_list
222+
path: (scoped_identifier
223+
path: (identifier) @crate
224+
name: (identifier) @item
225+
(#eq? @crate "ring")
226+
(#match? @item "AES_.*_GCM"))))
235227
"#.to_string(),
236228
language: ScanLanguage::Rust,
237229
match_type: AstMatchType::Algorithm {
@@ -313,17 +305,6 @@ impl AstDetector {
313305
metadata: HashMap::new(),
314306
},
315307

316-
// PHP OpenSSL function calls
317-
AstPattern {
318-
query: r#"
319-
(function_call_expression
320-
function: (name) @func
321-
(#match? @func "openssl_.*"))
322-
"#.to_string(),
323-
language: ScanLanguage::Php,
324-
match_type: AstMatchType::Library { name: "OpenSSL".to_string() },
325-
metadata: HashMap::new(),
326-
},
327308

328309
]
329310
}
@@ -349,8 +330,7 @@ impl AstDetector {
349330
ScanLanguage::Python => tree_sitter_python::language(),
350331
ScanLanguage::Java => tree_sitter_java::language(),
351332
ScanLanguage::Go => tree_sitter_go::language(),
352-
ScanLanguage::Php => tree_sitter_php::language(),
353-
_ => return Ok(matches), // Skip unsupported languages (Swift, Kotlin, ObjC, Erlang)
333+
_ => return Ok(matches), // Skip unsupported languages (PHP, Swift, Kotlin, ObjC, Erlang)
354334
};
355335

356336
// Execute each pattern that matches this language

0 commit comments

Comments
 (0)