Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ members = [
"crates/detector-rust",
"crates/detector-python",
"crates/detector-php",
"crates/detector-swift",
"crates/detector-objc",
"crates/detector-kotlin",
"crates/cli",
]
resolver = "2"
Expand Down
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## cryptofind

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.
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.

### Install & Run

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

### Extending Detectors
### Detector Architecture

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.
The scanner uses a modular detector architecture with dedicated crates for each language:

- **detector-c**: C language support
- **detector-cpp**: C++ language support
- **detector-go**: Go language support
- **detector-java**: Java language support
- **detector-rust**: Rust language support
- **detector-python**: Python language support
- **detector-php**: PHP language support
- **detector-swift**: Swift language support
- **detector-objc**: Objective-C language support
- **detector-kotlin**: Kotlin language support

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.

### Tests & Benchmarks

Expand Down
3 changes: 3 additions & 0 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ aho-corasick = { workspace = true }
crossbeam-channel = { workspace = true }
indicatif = "0.17"
scanner-core = { path = "../scanner-core" }
detector-swift = { path = "../detector-swift" }
detector-objc = { path = "../detector-objc" }
detector-kotlin = { path = "../detector-kotlin" }

[[bin]]
name = "cryptofind"
Expand Down
15 changes: 15 additions & 0 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,21 @@ fn main() -> Result<()> {
&[Language::Php],
reg.clone(),
)),
Box::new(PatternDetector::new(
"detector-swift",
&[Language::Swift],
reg.clone(),
)),
Box::new(PatternDetector::new(
"detector-objc",
&[Language::ObjC],
reg.clone(),
)),
Box::new(PatternDetector::new(
"detector-kotlin",
&[Language::Kotlin],
reg.clone(),
)),
];

let mut cfg = Config::default();
Expand Down
13 changes: 13 additions & 0 deletions crates/detector-kotlin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "detector-kotlin"
version = "0.1.0"
edition = "2021"
license = "Apache-2.0"

[dependencies]
scanner-core = { path = "../scanner-core" }
anyhow = { workspace = true }

[lib]
name = "detector_kotlin"
path = "src/lib.rs"
10 changes: 10 additions & 0 deletions crates/detector-kotlin/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use scanner_core::{Detector, Language, PatternDetector, PatternRegistry};
use std::sync::Arc;

pub fn make(registry: Arc<PatternRegistry>) -> Box<dyn Detector> {
Box::new(PatternDetector::new(
"detector-kotlin",
&[Language::Kotlin],
registry,
))
}
13 changes: 13 additions & 0 deletions crates/detector-objc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "detector-objc"
version = "0.1.0"
edition = "2021"
license = "Apache-2.0"

[dependencies]
scanner-core = { path = "../scanner-core" }
anyhow = { workspace = true }

[lib]
name = "detector_objc"
path = "src/lib.rs"
10 changes: 10 additions & 0 deletions crates/detector-objc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use scanner_core::{Detector, Language, PatternDetector, PatternRegistry};
use std::sync::Arc;

pub fn make(registry: Arc<PatternRegistry>) -> Box<dyn Detector> {
Box::new(PatternDetector::new(
"detector-objc",
&[Language::ObjC],
registry,
))
}
13 changes: 13 additions & 0 deletions crates/detector-swift/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "detector-swift"
version = "0.1.0"
edition = "2021"
license = "Apache-2.0"

[dependencies]
scanner-core = { path = "../scanner-core" }
anyhow = { workspace = true }

[lib]
name = "detector_swift"
path = "src/lib.rs"
10 changes: 10 additions & 0 deletions crates/detector-swift/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use scanner_core::{Detector, Language, PatternDetector, PatternRegistry};
use std::sync::Arc;

pub fn make(registry: Arc<PatternRegistry>) -> Box<dyn Detector> {
Box::new(PatternDetector::new(
"detector-swift",
&[Language::Swift],
registry,
))
}
6 changes: 3 additions & 3 deletions crates/scanner-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ pub trait Detector: Send + Sync {
fn scan_optimized(
&self,
unit: &ScanUnit,
stripped_s: &str,
index: &LineIndex,
_stripped_s: &str,
_index: &LineIndex,
em: &mut Emitter,
) -> Result<()> {
// Default implementation falls back to the original scan method
Expand Down Expand Up @@ -840,7 +840,7 @@ impl<'a> Scanner<'a> {
let callback = callback.clone();
Some(std::thread::spawn(move || {
let mut processed = 0;
let mut findings_count = 0;
let findings_count = 0;

while let Ok(_) = progress_rx.recv() {
processed += 1;
Expand Down
Loading
Loading