Skip to content

Commit dd1a148

Browse files
authored
Merge pull request #1 from script3r/cursor/rust-crypto-library-scanner-984e
Rust crypto library scanner
2 parents 4a3ac72 + ca2ba79 commit dd1a148

File tree

35 files changed

+3835
-0
lines changed

35 files changed

+3835
-0
lines changed

.github/workflows/ci.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
test:
14+
name: Test
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Install Rust
22+
uses: actions-rs/toolchain@v1
23+
with:
24+
toolchain: stable
25+
components: rustfmt, clippy
26+
override: true
27+
28+
- name: Cache cargo registry
29+
uses: actions/cache@v4
30+
with:
31+
path: |
32+
~/.cargo/registry
33+
~/.cargo/git
34+
target
35+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
36+
restore-keys: |
37+
${{ runner.os }}-cargo-
38+
39+
- name: Check formatting
40+
run: cargo fmt --all -- --check
41+
42+
- name: Run clippy
43+
run: cargo clippy --all-targets --all-features
44+
45+
- name: Build project
46+
run: cargo build --verbose
47+
48+
- name: Run tests
49+
run: cargo test --verbose
50+
51+
- name: Build release
52+
run: cargo build --release --verbose
53+
54+
- name: Test CLI help
55+
run: ./target/release/cryptofind --help
56+
57+
test-windows:
58+
name: Test (Windows)
59+
runs-on: windows-latest
60+
61+
steps:
62+
- name: Checkout code
63+
uses: actions/checkout@v4
64+
65+
- name: Install Rust
66+
uses: actions-rs/toolchain@v1
67+
with:
68+
toolchain: stable
69+
override: true
70+
71+
- name: Cache cargo registry
72+
uses: actions/cache@v4
73+
with:
74+
path: |
75+
~/.cargo/registry
76+
~/.cargo/git
77+
target
78+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
79+
restore-keys: |
80+
${{ runner.os }}-cargo-
81+
82+
- name: Build project
83+
run: cargo build --verbose
84+
85+
- name: Run tests
86+
run: cargo test --verbose
87+
88+
- name: Build release
89+
run: cargo build --release --verbose
90+
91+
test-macos:
92+
name: Test (macOS)
93+
runs-on: macos-latest
94+
95+
steps:
96+
- name: Checkout code
97+
uses: actions/checkout@v4
98+
99+
- name: Install Rust
100+
uses: actions-rs/toolchain@v1
101+
with:
102+
toolchain: stable
103+
override: true
104+
105+
- name: Cache cargo registry
106+
uses: actions/cache@v4
107+
with:
108+
path: |
109+
~/.cargo/registry
110+
~/.cargo/git
111+
target
112+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
113+
restore-keys: |
114+
${{ runner.os }}-cargo-
115+
116+
- name: Build project
117+
run: cargo build --verbose
118+
119+
- name: Run tests
120+
run: cargo test --verbose
121+
122+
- name: Build release
123+
run: cargo build --release --verbose
124+
125+
benchmark:
126+
name: Benchmark
127+
runs-on: ubuntu-latest
128+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
129+
130+
steps:
131+
- name: Checkout code
132+
uses: actions/checkout@v4
133+
134+
- name: Install Rust
135+
uses: actions-rs/toolchain@v1
136+
with:
137+
toolchain: stable
138+
override: true
139+
140+
- name: Cache cargo registry
141+
uses: actions/cache@v4
142+
with:
143+
path: |
144+
~/.cargo/registry
145+
~/.cargo/git
146+
target
147+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
148+
restore-keys: |
149+
${{ runner.os }}-cargo-
150+
151+
- name: Run benchmarks
152+
run: cargo bench --verbose

CONTRIBUTING.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## Contributing to cryptofind
2+
3+
Thank you for improving cryptofind! This project aims for speed, precision, and extensibility.
4+
5+
### Adding a New Library via patterns
6+
7+
1. Edit `patterns.toml` and add a new `[[library]]` entry.
8+
2. Use anchored regexes for `include`/`import`/`namespace`/`apis`.
9+
3. Prefer import/include anchors; use API patterns only as secondary evidence.
10+
4. Run `cargo test` to validate regex and stripper behavior.
11+
12+
### Adding a New Language or Custom Detector
13+
14+
1. Create a new crate under `crates/detector-<lang>/`.
15+
2. Implement the `Detector` trait from `scanner-core`.
16+
3. Provide `prefilter()` substrings and extensions for fast filtering.
17+
4. Use comment stripping utilities to avoid matches in comments/strings.
18+
19+
### Performance Guidelines
20+
21+
- Stream files and avoid unnecessary allocations.
22+
- Use `rayon` for parallelism; keep per-file work independent.
23+
- Prefer `aho-corasick` for prefilter substring matching.
24+
- Short-circuit after sufficient evidence unless `--exhaustive` (future work).
25+
26+
### Testing
27+
28+
- Add unit tests for any new stripper rules.
29+
- Provide fixtures under `fixtures/<lang>/positive` and `fixtures/<lang>/negative`.
30+
- Add integration tests in `tests/` to cover the new patterns.
31+

0 commit comments

Comments
 (0)