cc-audit 0.4.1

Security auditor for Claude Code skills, hooks, and MCP servers
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
# cc-audit development tasks

# Default recipe: show available commands
default:
    @just --list

# ============================================================================
# Setup
# ============================================================================

# Setup development environment
setup:
    @echo "Installing required tools..."
    rustup component add clippy rustfmt llvm-tools-preview
    cargo install cargo-llvm-cov cargo-audit cargo-deny cargo-vet cargo-outdated \
        cargo-semver-checks cargo-msrv cargo-mutants
    @echo "Setup complete!"

# Setup all tools including nightly-only tools (fuzz)
setup-all: setup
    @echo "Installing nightly tools..."
    rustup install nightly
    cargo +nightly install cargo-fuzz
    @echo "All tools installed!"

# ============================================================================
# Build
# ============================================================================

# Build the project
build:
    cargo build

# Build release version
build-release:
    cargo build --release

# Build with all features
build-all-features:
    cargo build --all-features

# ============================================================================
# Test
# ============================================================================

# Run all tests
test:
    cargo test

# Run all tests with all features (CI equivalent)
test-all:
    cargo test --all-features

# Run tests with verbose output
test-verbose:
    cargo test -- --nocapture

# ============================================================================
# Coverage (CI: coverage job)
# ============================================================================

# Run coverage and show summary
coverage:
    cargo llvm-cov --summary-only

# Run coverage with all features (CI equivalent)
coverage-all:
    cargo llvm-cov --all-features --summary-only

# Generate coverage report in lcov format (CI equivalent)
coverage-lcov:
    cargo llvm-cov --all-features --lcov --output-path lcov.info

# Run coverage and generate HTML report
coverage-html:
    cargo llvm-cov --all-features --html
    @echo "Coverage report: target/llvm-cov/html/index.html"

# ============================================================================
# Lint & Format (CI: fmt, clippy jobs)
# ============================================================================

# Run clippy linter
lint:
    cargo clippy -- -D warnings

# Run clippy with all targets and features (CI equivalent)
lint-all:
    cargo clippy --all-targets --all-features -- -D warnings

# Format code
fmt:
    cargo fmt --all

# Check formatting without modifying (CI equivalent)
fmt-check:
    cargo fmt --all --check

# ============================================================================
# Documentation (CI: doc job)
# ============================================================================

# Build documentation (CI equivalent)
doc:
    RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features

# Build and open documentation
doc-open:
    RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --open

# ============================================================================
# CI Main Checks (ci.yml equivalent)
# ============================================================================

# Run all CI main checks (fmt + clippy + test + doc)
ci-main: fmt-check lint-all test-all doc
    @echo "All CI main checks passed!"

# Quick CI check (fmt + lint only, fastest)
ci-quick: fmt-check lint-all
    @echo "Quick CI checks passed!"

# ============================================================================
# Security Checks (security.yml equivalent)
# ============================================================================

# Run cargo-audit for security vulnerabilities
security-audit:
    cargo audit

# Run cargo-deny for dependency checks (CI equivalent)
security-deny:
    cargo deny check all

# Run cargo-vet for supply chain security
security-vet:
    cargo vet --locked || echo "Supply chain audit incomplete - run 'cargo vet' to complete"

# Check for outdated dependencies
security-outdated:
    cargo outdated --root-deps-only

# Run all security checks (security.yml equivalent)
ci-security: security-audit security-deny security-vet
    @echo "All security checks passed!"

# ============================================================================
# Performance Checks (performance.yml equivalent)
# ============================================================================

# Run benchmarks (CI equivalent)
bench:
    cargo bench --bench scan_benchmark -- --noplot

# Run benchmarks and save baseline
bench-baseline name="local":
    cargo bench --bench scan_benchmark -- --noplot --save-baseline {{name}}

# Compare benchmarks against baseline
bench-compare baseline="main":
    cargo bench --bench scan_benchmark -- --noplot --baseline {{baseline}}

# Measure binary size
binary-size: build-release
    #!/usr/bin/env bash
    set -e
    if [[ "$OSTYPE" == "darwin"* ]]; then
        SIZE=$(stat -f%z target/release/cc-audit)
    else
        SIZE=$(stat -c%s target/release/cc-audit)
    fi
    SIZE_MB=$(echo "scale=2; $SIZE / 1048576" | bc)
    echo "Binary size: ${SIZE_MB}MB ($SIZE bytes)"
    # Threshold: 20MB
    if [ "$SIZE" -gt 20971520 ]; then
        echo "Warning: Binary size exceeds 20MB threshold"
    fi

# Measure build time (debug)
build-time-debug:
    #!/usr/bin/env bash
    cargo clean
    START=$(date +%s)
    cargo build 2>&1
    END=$(date +%s)
    echo "Debug build time: $((END - START))s"

# Measure build time (release)
build-time-release:
    #!/usr/bin/env bash
    cargo clean
    START=$(date +%s)
    cargo build --release 2>&1
    END=$(date +%s)
    echo "Release build time: $((END - START))s"

# Run all performance checks
ci-performance: bench binary-size
    @echo "Performance checks completed!"

# ============================================================================
# Self Audit (self-audit.yml equivalent)
# ============================================================================

# Run self audit on all types
self-audit: build-release
    @echo "=== Skill Scan ===" && ./target/release/cc-audit --type skill . || true
    @echo ""
    @echo "=== Hook Scan ===" && ./target/release/cc-audit --type hook . || true
    @echo ""
    @echo "=== MCP Scan ===" && ./target/release/cc-audit --type mcp . || true
    @echo ""
    @echo "=== Command Scan ===" && ./target/release/cc-audit --type command . || true
    @echo ""
    @echo "=== Docker Scan ===" && ./target/release/cc-audit --type docker . || true
    @echo ""
    @echo "=== Dependency Scan ===" && ./target/release/cc-audit --type dependency . || true

# Run self audit in strict/CI mode
self-audit-strict: build-release
    ./target/release/cc-audit --type skill --ci .

# ============================================================================
# MSRV Check (msrv.yml equivalent)
# ============================================================================

# Find minimum supported Rust version
msrv-find:
    cargo msrv find --min 1.75.0

# Verify build with MSRV (1.85.0)
msrv-verify:
    rustup run 1.85.0 cargo check --all-features
    rustup run 1.85.0 cargo build --all-features
    rustup run 1.85.0 cargo test --all-features

# Verify build with stable
msrv-stable:
    rustup run stable cargo check --all-features
    rustup run stable cargo build --all-features
    rustup run stable cargo test --all-features

# Verify build with beta
msrv-beta:
    rustup run beta cargo check --all-features
    rustup run beta cargo build --all-features
    rustup run beta cargo test --all-features

# ============================================================================
# Semver Check (semver.yml equivalent)
# ============================================================================

# Check semver compatibility against latest tag
semver-check:
    #!/usr/bin/env bash
    LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
    if [ -z "$LATEST_TAG" ]; then
        echo "No previous tags found, skipping semver check"
        exit 0
    fi
    echo "Checking API compatibility against $LATEST_TAG"
    cargo semver-checks check-release --baseline-rev "$LATEST_TAG"

# ============================================================================
# Mutation Testing (mutation.yml equivalent)
# ============================================================================

# Run mutation testing
mutation:
    cargo mutants --timeout 60 --jobs 2

# Run quick mutation testing (limited)
mutation-quick:
    cargo mutants --timeout 30 --jobs 2 --in-place

# ============================================================================
# Fuzz Testing (fuzz.yml equivalent) - Requires nightly
# ============================================================================

# List fuzz targets
fuzz-list:
    cargo +nightly fuzz list 2>/dev/null || echo "No fuzz targets found. Run 'cargo fuzz init' to setup."

# Run fuzz testing (default 60 seconds)
fuzz target duration="60":
    cargo +nightly fuzz run {{target}} -- -max_total_time={{duration}}

# ============================================================================
# Combined CI Commands
# ============================================================================

# Run ALL CI checks locally (equivalent to all GitHub Actions)
ci-all: ci-main ci-security self-audit
    @echo ""
    @echo "============================================"
    @echo "All CI checks passed!"
    @echo "============================================"

# Run full CI with performance (slower)
ci-full: ci-all ci-performance
    @echo ""
    @echo "============================================"
    @echo "Full CI checks (including performance) passed!"
    @echo "============================================"

# Run extended CI (includes mutation testing, slower)
ci-extended: ci-full mutation
    @echo ""
    @echo "============================================"
    @echo "Extended CI checks passed!"
    @echo "============================================"

# ============================================================================
# Development Utilities
# ============================================================================

# Run the tool on examples
run-examples:
    @echo "=== clean ===" && cargo run --quiet -- ./examples/clean/ || true
    @echo ""
    @echo "=== exfiltration ===" && cargo run --quiet -- ./examples/exfiltration/ || true
    @echo ""
    @echo "=== privilege-escalation ===" && cargo run --quiet -- ./examples/privilege-escalation/ || true
    @echo ""
    @echo "=== persistence ===" && cargo run --quiet -- ./examples/persistence/ || true
    @echo ""
    @echo "=== prompt-injection ===" && cargo run --quiet -- ./examples/prompt-injection/ || true
    @echo ""
    @echo "=== overpermission ===" && cargo run --quiet -- ./examples/overpermission/ || true

# Run the tool on a specific path
run path:
    cargo run -- {{path}}

# Run with JSON output
run-json path:
    cargo run -- --format json {{path}}

# Run with verbose output
run-verbose path:
    cargo run -- --verbose {{path}}

# Clean build artifacts
clean:
    cargo clean

# Watch for changes and run tests
watch:
    cargo watch -x test

# Install the tool locally
install:
    cargo install --path .

# Uninstall the tool
uninstall:
    cargo uninstall cc-audit

# ============================================================================
# CI Local Testing with act
# ============================================================================

# List available CI jobs
act-list:
    act -l --workflows .github/workflows/ci.yml

# Run CI locally (dry run)
act-dry:
    act push -n --workflows .github/workflows/ci.yml

# Run all CI jobs locally via act (ubuntu only, skips macOS/Windows)
act-ci:
    act push --workflows .github/workflows/ci.yml

# Run specific CI job (e.g., just act-job fmt)
act-job job:
    act -j {{job}} --workflows .github/workflows/ci.yml

# Run security workflow via act
act-security:
    act push --workflows .github/workflows/security.yml

# Run performance workflow via act
act-performance:
    act push --workflows .github/workflows/performance.yml

# Run self-audit workflow via act
act-self-audit:
    act push --workflows .github/workflows/self-audit.yml

# ============================================================================
# Snapshot Testing
# ============================================================================

# Run snapshot tests
test-snapshot:
    cargo test snapshot_ -- --nocapture

# Review pending snapshot changes
snapshot-review:
    cargo insta review

# Accept all pending snapshots
snapshot-accept:
    cargo insta accept

# ============================================================================
# Code Generation (xtask)
# ============================================================================

# Create a new security rule
# Usage: just new-rule <category> <id> <name>
# Example: just new-rule privilege PE-006 "Setuid bit manipulation"
new-rule category id name:
    cargo xtask new-rule --category {{category}} --id {{id}} --name "{{name}}"