Skip to content

Commit 89fb976

Browse files
authored
Merge pull request #2 from script3r/cursor/rust-crypto-library-scanner-984e
Cursor/rust crypto library scanner 984e
2 parents dd1a148 + a1c2efb commit 89fb976

File tree

13 files changed

+493
-244
lines changed

13 files changed

+493
-244
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ members = [
88
"crates/detector-rust",
99
"crates/detector-python",
1010
"crates/detector-php",
11+
"crates/detector-swift",
12+
"crates/detector-objc",
13+
"crates/detector-kotlin",
1114
"crates/cli",
1215
]
1316
resolver = "2"

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## cryptofind
22

3-
Fast, low-false-positive static scanner that finds third-party cryptographic libraries and call sites across Go, Java, C, C++, Rust, Python, PHP, Swift, Objective-C, and Kotlin codebases.
3+
Fast, low-false-positive static scanner that finds third-party cryptographic libraries and call sites across 10 programming languages: Go, Java, C, C++, Rust, Python, PHP, Swift, Objective-C, and Kotlin.
44

55
### Install & Run
66

@@ -78,9 +78,22 @@ The scanner automatically detects and processes files with these extensions:
7878
- **Aho-Corasick Prefiltering**: Fast substring matching before expensive regex operations
7979
- **Parallel Processing**: Multi-threaded file scanning using Rayon
8080

81-
### Extending Detectors
81+
### Detector Architecture
8282

83-
Detectors are plugin-like. Add a new crate under `crates/` implementing the `Detector` trait, or extend the `patterns.toml` to cover additional libraries. See `crates/scanner-core/src/lib.rs` for the trait and pattern-driven detector.
83+
The scanner uses a modular detector architecture with dedicated crates for each language:
84+
85+
- **detector-c**: C language support
86+
- **detector-cpp**: C++ language support
87+
- **detector-go**: Go language support
88+
- **detector-java**: Java language support
89+
- **detector-rust**: Rust language support
90+
- **detector-python**: Python language support
91+
- **detector-php**: PHP language support
92+
- **detector-swift**: Swift language support
93+
- **detector-objc**: Objective-C language support
94+
- **detector-kotlin**: Kotlin language support
95+
96+
Each detector implements the `Detector` trait and can be extended independently. To add support for a new language, create a new detector crate under `crates/` or extend the `patterns.toml` to cover additional libraries. See `crates/scanner-core/src/lib.rs` for the trait definition and pattern-driven detector implementation.
8497

8598
### Tests & Benchmarks
8699

crates/cli/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ aho-corasick = { workspace = true }
1818
crossbeam-channel = { workspace = true }
1919
indicatif = "0.17"
2020
scanner-core = { path = "../scanner-core" }
21+
detector-swift = { path = "../detector-swift" }
22+
detector-objc = { path = "../detector-objc" }
23+
detector-kotlin = { path = "../detector-kotlin" }
2124

2225
[[bin]]
2326
name = "cryptofind"

crates/cli/src/main.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,21 @@ fn main() -> Result<()> {
132132
&[Language::Php],
133133
reg.clone(),
134134
)),
135+
Box::new(PatternDetector::new(
136+
"detector-swift",
137+
&[Language::Swift],
138+
reg.clone(),
139+
)),
140+
Box::new(PatternDetector::new(
141+
"detector-objc",
142+
&[Language::ObjC],
143+
reg.clone(),
144+
)),
145+
Box::new(PatternDetector::new(
146+
"detector-kotlin",
147+
&[Language::Kotlin],
148+
reg.clone(),
149+
)),
135150
];
136151

137152
let mut cfg = Config::default();

crates/detector-kotlin/Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "detector-kotlin"
3+
version = "0.1.0"
4+
edition = "2021"
5+
license = "Apache-2.0"
6+
7+
[dependencies]
8+
scanner-core = { path = "../scanner-core" }
9+
anyhow = { workspace = true }
10+
11+
[lib]
12+
name = "detector_kotlin"
13+
path = "src/lib.rs"

crates/detector-kotlin/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use scanner_core::{Detector, Language, PatternDetector, PatternRegistry};
2+
use std::sync::Arc;
3+
4+
pub fn make(registry: Arc<PatternRegistry>) -> Box<dyn Detector> {
5+
Box::new(PatternDetector::new(
6+
"detector-kotlin",
7+
&[Language::Kotlin],
8+
registry,
9+
))
10+
}

crates/detector-objc/Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "detector-objc"
3+
version = "0.1.0"
4+
edition = "2021"
5+
license = "Apache-2.0"
6+
7+
[dependencies]
8+
scanner-core = { path = "../scanner-core" }
9+
anyhow = { workspace = true }
10+
11+
[lib]
12+
name = "detector_objc"
13+
path = "src/lib.rs"

crates/detector-objc/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use scanner_core::{Detector, Language, PatternDetector, PatternRegistry};
2+
use std::sync::Arc;
3+
4+
pub fn make(registry: Arc<PatternRegistry>) -> Box<dyn Detector> {
5+
Box::new(PatternDetector::new(
6+
"detector-objc",
7+
&[Language::ObjC],
8+
registry,
9+
))
10+
}

crates/detector-swift/Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "detector-swift"
3+
version = "0.1.0"
4+
edition = "2021"
5+
license = "Apache-2.0"
6+
7+
[dependencies]
8+
scanner-core = { path = "../scanner-core" }
9+
anyhow = { workspace = true }
10+
11+
[lib]
12+
name = "detector_swift"
13+
path = "src/lib.rs"

0 commit comments

Comments
 (0)