Skip to content

Commit 52b1e7d

Browse files
authored
Merge pull request #58 from auths-dev/dev-crateIoComparison
feat: add compare commands with standalone scanner
2 parents 6ca254e + ada9b1e commit 52b1e7d

8 files changed

Lines changed: 762 additions & 87 deletions

File tree

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,19 @@ jobs:
6868
- name: Build and verify proofs
6969
run: cd proofs && lake build
7070

71+
deep-driver:
72+
name: Deep Analysis Driver (nightly)
73+
runs-on: ubuntu-latest
74+
# Only run when capsec-deep changes
75+
if: contains(github.event.pull_request.title, 'deep') || contains(join(github.event.commits.*.modified, ','), 'capsec-deep')
76+
steps:
77+
- uses: actions/checkout@v4
78+
- uses: dtolnay/rust-toolchain@nightly
79+
with:
80+
components: rustc-dev, llvm-tools
81+
- run: cd crates/capsec-deep && cargo build
82+
- run: cd crates/capsec-deep && CAPSEC_DEEP_DEBUG=1 cargo run -- --edition 2024 tests/fixtures/simple_fs.rs 2>&1 | grep "Found 1 findings"
83+
7184
capsec-audit:
7285
name: Capability Audit
7386
runs-on: ubuntu-latest

README.md

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,28 @@ The audit tool finds the problems. The type system prevents them at compile time
3131

3232
## cargo-capsec — Static Capability Audit
3333

34-
Scans Rust source for ambient authority (filesystem, network, env, process) and reports what your code — and your dependencies — can do to the outside world. Zero config, zero code changes.
34+
Scans Rust source for ambient authority (filesystem, network, env, process, FFI) and reports what your code — and your dependencies — can do to the outside world. Zero config, zero code changes.
3535

3636
### Install
3737

3838
```bash
3939
cargo install cargo-capsec
40-
41-
# Or from source:
42-
cargo install --path crates/cargo-capsec
4340
```
4441

45-
### Run
42+
### Adopt in 30 seconds
4643

4744
```bash
48-
# Scan workspace crates only (fast, default)
49-
cargo capsec audit
45+
cargo capsec init
46+
```
5047

51-
# Scan workspace + dependencies — cross-crate propagation shows
52-
# which of YOUR functions inherit authority from dependencies
53-
cargo capsec audit --include-deps
48+
Runs a full audit, generates a `.capsec.toml` that suppresses all existing findings, saves a baseline, and optionally sets up CI. You immediately start catching *new* ambient authority without drowning in legacy noise.
5449

55-
# Control dependency depth (default: 1 = direct deps only)
56-
cargo capsec audit --include-deps --dep-depth 3 # up to 3 hops
57-
cargo capsec audit --include-deps --dep-depth 0 # unlimited
50+
### Audit
5851

59-
# Supply-chain view — only dependency findings
60-
cargo capsec audit --deps-only
52+
```bash
53+
cargo capsec audit # workspace only
54+
cargo capsec audit --include-deps # + cross-crate dependency propagation
55+
cargo capsec audit --deep --include-deps # + MIR analysis (nightly, sees through macros)
6156
```
6257

6358
```
@@ -66,35 +61,54 @@ my-app v0.1.0
6661
FS src/config.rs:8:5 fs::read_to_string load_config()
6762
NET src/api.rs:15:9 reqwest::get fetch_data()
6863
↳ Cross-crate: reqwest::get() → TcpStream::connect [NET]
64+
FFI src/db.rs:31:9 rusqlite::execute query()
65+
↳ Cross-crate: rusqlite::execute() → sqlite3_exec [FFI]
6966
PROC src/deploy.rs:42:17 Command::new run_migration()
67+
```
68+
69+
### Diff dependency versions
70+
71+
```bash
72+
cargo capsec diff serde_json@1.0.130 serde_json@1.0.133
73+
```
74+
75+
```
76+
serde_json 1.0.130 → 1.0.133
77+
─────────────────────────────
78+
+ NET src/de.rs:142:9 TcpStream::connect fetch_schema()
79+
- FS src/io.rs:88:5 fs::read old_loader()
7080
71-
Summary
72-
───────
73-
Crates with findings: 1
74-
Total findings: 3
75-
Categories: FS: 1 NET: 1 ENV: 0 PROC: 1
76-
1 critical-risk findings
81+
Summary: 1 added, 1 removed, 1 unchanged
82+
```
83+
84+
When Dependabot bumps a dependency, know exactly what new authority it introduced.
85+
86+
### Compare crates
87+
88+
```bash
89+
cargo capsec compare ureq@2.12.1 reqwest@0.12.12
90+
```
91+
92+
Side-by-side authority profiles to make informed dependency choices.
93+
94+
### CI
95+
96+
```bash
97+
cargo capsec init --ci github # generates .github/workflows/capsec.yml
7798
```
7899

79-
### Add to CI
100+
Or manually:
80101

81102
```yaml
82-
# .github/workflows/capsec.yml
83-
name: Capability Audit
84-
on: [pull_request]
85-
jobs:
86-
audit:
87-
runs-on: ubuntu-latest
88-
steps:
89-
- uses: actions/checkout@v4
90-
- uses: dtolnay/rust-toolchain@stable
91-
- run: cargo install cargo-capsec
92-
- run: cargo capsec audit --fail-on high --quiet
103+
- run: cargo capsec audit --fail-on high --format sarif > capsec.sarif
104+
- uses: github/codeql-action/upload-sarif@v3
105+
with:
106+
sarif_file: capsec.sarif
93107
```
94108
95-
New high-risk I/O in a PR? CI fails. No new I/O? CI passes. Teams can adopt incrementally with `--baseline` and `--diff` to only flag *new* findings.
109+
See the [full CLI reference](crates/cargo-capsec/README.md) for all commands and flags.
96110
97-
To see it in action, you can reference these:
111+
To see it in action:
98112
* [CI/CD](https://github.com/auths-dev/capsec/blob/main/.github/workflows/ci.yml#L57)
99113
* [Pre-Commit Hook](https://github.com/auths-dev/capsec/blob/main/.pre-commit-config.yaml#L32)
100114

0 commit comments

Comments
 (0)