Skip to content

Commit a1c2efb

Browse files
committed
docs: Update README and fix Rust warnings
- Update README to highlight 10 programming language support - Add comprehensive detector architecture section listing all detector crates - Fix Rust compiler warnings: - Prefix unused parameters with underscore in scan_optimized trait method - Remove unnecessary mut from findings_count variable - All tests pass with zero warnings - Documentation now accurately reflects the complete language ecosystem
1 parent 2d53994 commit a1c2efb

File tree

3 files changed

+111
-6
lines changed

3 files changed

+111
-6
lines changed

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/scanner-core/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ pub trait Detector: Send + Sync {
9696
fn scan_optimized(
9797
&self,
9898
unit: &ScanUnit,
99-
stripped_s: &str,
100-
index: &LineIndex,
99+
_stripped_s: &str,
100+
_index: &LineIndex,
101101
em: &mut Emitter,
102102
) -> Result<()> {
103103
// Default implementation falls back to the original scan method
@@ -840,7 +840,7 @@ impl<'a> Scanner<'a> {
840840
let callback = callback.clone();
841841
Some(std::thread::spawn(move || {
842842
let mut processed = 0;
843-
let mut findings_count = 0;
843+
let findings_count = 0;
844844

845845
while let Ok(_) = progress_rx.recv() {
846846
processed += 1;

patterns.toml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,3 +438,95 @@ include = [
438438
apis = [
439439
"\\bParagonIE\\\\Halite\\\\[A-Za-z0-9_\\\\]+::[A-Za-z0-9_]+\\s*\\(",
440440
]
441+
442+
# =========================
443+
# Objective-C: Apple/Common
444+
# =========================
445+
446+
[[library]]
447+
name = "CommonCrypto (Objective-C)"
448+
languages = ["Objective-C"]
449+
[library.patterns]
450+
include = [
451+
"^\\s*#\\s*(?:import|include)\\s*<CommonCrypto\\/[A-Za-z0-9_]+\\.h>",
452+
"^\\s*@import\\s+CommonCrypto\\b",
453+
]
454+
apis = [
455+
"\\bCCCrypt\\s*\\(",
456+
"\\bCCCryptor(?:Create|Update|Final|Release)\\s*\\(",
457+
"\\bCCHmac\\s*\\(",
458+
"\\bCC_SHA(?:1|224|256|384|512)\\s*\\(",
459+
"\\bCC_MD5\\s*\\(",
460+
"\\bCCKeyDerivationPBKDF\\s*\\(",
461+
"\\bCCRandomGenerateBytes\\s*\\(",
462+
]
463+
464+
[[library]]
465+
name = "Security.framework (Objective-C)"
466+
languages = ["Objective-C"]
467+
[library.patterns]
468+
include = [
469+
"^\\s*#\\s*(?:import|include)\\s*<Security\\/Security\\.h>",
470+
"^\\s*@import\\s+Security\\b",
471+
]
472+
apis = [
473+
"\\bSecKeyCreateRandomKey\\s*\\(",
474+
"\\bSecKeyCreateEncryptedData\\s*\\(",
475+
"\\bSecKeyCreateDecryptedData\\s*\\(",
476+
"\\bSecKeyCreateSignature\\s*\\(",
477+
"\\bSecKeyVerifySignature\\s*\\(",
478+
"\\bSecRandomCopyBytes\\s*\\(",
479+
]
480+
481+
# =========================
482+
# Objective-C: Third-party C libs used from Obj-C
483+
# =========================
484+
485+
[[library]]
486+
name = "OpenSSL (Objective-C)"
487+
languages = ["Objective-C"]
488+
[library.patterns]
489+
include = [
490+
"^\\s*#\\s*(?:import|include)\\s*<openssl/[A-Za-z0-9_./-]+>",
491+
]
492+
apis = [
493+
"\\bEVP_[A-Za-z0-9_]+\\s*\\(",
494+
"\\bRSA_[A-Za-z0-9_]+\\s*\\(",
495+
"\\bECDSA_[A-Za-z0-9_]+\\s*\\(",
496+
"\\bEC_KEY_[A-Za-z0-9_]+\\s*\\(",
497+
"\\bX509_[A-Za-z0-9_]+\\s*\\(",
498+
"\\bPKCS\\d_[A-Za-z0-9_]+\\s*\\(",
499+
]
500+
501+
[[library]]
502+
name = "libsodium (Objective-C)"
503+
languages = ["Objective-C"]
504+
[library.patterns]
505+
include = [
506+
"^\\s*#\\s*(?:import|include)\\s*<sodium(?:/[^>]+)?>",
507+
]
508+
apis = [
509+
"\\bcrypto_secretbox_(?:easy|open_easy)\\s*\\(",
510+
"\\bcrypto_aead_(?:x?chacha20poly1305_ietf|aes256gcm)_(?:encrypt|decrypt)\\s*\\(",
511+
"\\bcrypto_sign_(?:detached|verify_detached)\\s*\\(",
512+
"\\bcrypto_generichash\\s*\\(",
513+
"\\bcrypto_scalarmult\\s*\\(",
514+
]
515+
516+
# =========================
517+
# Objective-C: High-level but still primitive APIs
518+
# =========================
519+
520+
[[library]]
521+
name = "Google Tink (Objective-C)"
522+
languages = ["Objective-C"]
523+
[library.patterns]
524+
include = [
525+
"^\\s*@import\\s+Tink\\b",
526+
"^\\s*#\\s*import\\s*<Tink\\/[A-Za-z0-9_]+\\.h>",
527+
"^\\s*#\\s*import\\s*\"objc\\/TINK[A-Za-z0-9_]+\\.h\"",
528+
]
529+
apis = [
530+
"\\bTINK(?:Aead|Mac|Hybrid(?:Encrypt|Decrypt)|PublicKey(?:Sign|Verify)|KeysetHandle|Config)\\b",
531+
"\\b\\[TINK[A-Za-z0-9_]+Factory\\s+[A-Za-z0-9_]+WithKeysetHandle:.*\\]",
532+
]

0 commit comments

Comments
 (0)