Skip to main content

cc_audit/
lib.rs

1//! cc-audit - Security scanner for Claude Code configurations.
2//!
3//! This crate is organized into the following 7-layer architecture:
4//!
5//! - **L1 (input/)**: Input handling (CLI, stdin)
6//! - **L2 (config/)**: Configuration loading and validation
7//! - **L3 (discovery/)**: Target file discovery and filtering
8//! - **L4 (parser/)**: Content parsing for various file formats
9//! - **L5 (engine/)**: Detection engine and rule matching
10//! - **L6 (aggregator/)**: Result aggregation and scoring
11//! - **L7 (output/)**: Output formatting and reporting
12//!
13//! Cross-cutting modules:
14//! - **rules/**: Rule definitions and custom rules
15//! - **external/**: External integrations (hooks, MCP, watch)
16//! - **runtime/**: Execution control and pipeline (v1.x skeleton)
17//! - **types/**: Common type definitions
18
19// ============================================
20// 7-Layer Architecture Modules
21// ============================================
22
23// L1: Input Layer
24pub mod cli;
25pub mod client;
26pub mod input;
27
28// L2: Configuration Layer
29pub mod config;
30pub mod profile;
31
32// L3: Discovery Layer
33pub mod discovery;
34pub mod ignore;
35
36// L4: Parser Layer
37pub mod parser;
38
39// L5: Detection Engine Layer
40pub mod context;
41pub mod cve_db;
42pub mod deobfuscation;
43pub mod engine;
44pub mod line_join;
45pub mod malware_db;
46pub mod rules;
47pub mod suppression;
48
49// L6: Aggregation Layer
50pub mod aggregator;
51pub mod baseline;
52pub mod scoring;
53
54// L7: Output Layer
55pub mod output;
56pub mod reporter;
57
58// ============================================
59// Cross-Cutting Modules
60// ============================================
61
62pub mod error;
63pub mod external;
64pub mod runtime;
65pub mod types;
66
67// External integrations
68pub mod feedback;
69pub mod fix;
70pub mod hooks;
71pub mod mcp_server;
72pub mod pinning;
73pub mod proxy;
74pub mod remote;
75pub mod sbom;
76pub mod trusted_domains;
77pub mod watch;
78
79// Legacy modules (for backward compatibility)
80pub mod handlers;
81pub mod hook_mode;
82pub mod run;
83
84#[deprecated(
85    since = "3.2.0",
86    note = "Use `crate::engine` instead. This module will be removed in v4.0.0. \
87            See migration guide in `src/scanner/mod.rs`."
88)]
89pub mod scanner;
90
91#[cfg(test)]
92pub mod test_utils;
93
94// ============================================
95// Re-exports for Public API
96// ============================================
97
98// L1: Input
99pub use cli::{
100    BadgeFormat, CheckArgs, Cli, Commands, HookAction, OutputFormat, ProxyArgs, ScanType,
101};
102pub use client::{
103    ClientType, DetectedClient, detect_client, detect_installed_clients, list_installed_clients,
104};
105
106// L2: Configuration
107pub use config::{Config, ConfigError, ConfigLoadResult, TextFilesConfig, WatchConfig};
108pub use profile::{Profile, profile_from_check_args};
109
110// L3: Discovery
111pub use discovery::{DirectoryWalker, WalkConfig};
112pub use ignore::IgnoreFilter;
113
114// L4: Parser
115pub use parser::{
116    ContentParser, ContentType, DockerfileParser, FrontmatterParser, JsonParser, MarkdownParser,
117    ParsedContent, ParserRegistry, TomlParser, YamlParser,
118};
119
120// L5: Detection Engine
121pub use context::{ContentContext, ContextDetector};
122pub use cve_db::{CveDatabase, CveDbError, CveEntry};
123pub use deobfuscation::{DecodedContent, Deobfuscator};
124pub use engine::traits::{AnalysisMetadata, AnalysisResult, DetectionEngine, EngineConfig};
125pub use engine::{
126    CommandScanner, ContentScanner, DependencyScanner, DockerScanner, HookScanner, McpScanner,
127    PluginScanner, RulesDirScanner, ScanError, Scanner, ScannerConfig, SkillScanner,
128    SubagentScanner,
129};
130pub use malware_db::{MalwareDatabase, MalwareDbError};
131pub use rules::{
132    Confidence, CustomRuleError, CustomRuleLoader, DynamicRule, Finding, RuleEngine, RuleSeverity,
133    ScanResult, Severity, Summary,
134};
135
136// L6: Aggregation
137pub use aggregator::{FindingCollector, SummaryBuilder};
138pub use baseline::{Baseline, DriftEntry, DriftReport};
139pub use scoring::{CategoryScore, RiskLevel, RiskScore, SeverityBreakdown};
140
141// L7: Output
142pub use output::OutputFormatter;
143pub use reporter::{
144    Reporter, html::HtmlReporter, json::JsonReporter, markdown::MarkdownReporter,
145    sarif::SarifReporter, terminal::TerminalReporter,
146};
147
148// Runtime & Orchestration
149pub use run::{
150    ScanMode, WatchModeResult, format_result_check_args, format_result_with_config, is_text_file,
151    is_text_file_with_config, run_scan_with_check_args, run_scan_with_check_args_config,
152    scan_path_with_cve_db, scan_path_with_malware_db, setup_watch_mode, watch_iteration,
153};
154pub use runtime::{HookRunner, Pipeline, PipelineStage, ScanContext, ScanExecutor};
155
156// External Integrations
157pub use error::{AuditError, Result};
158pub use feedback::{FalsePositiveReport, ReportSubmitter, SubmitResult, SubmitTarget};
159pub use fix::{AutoFixer, Fix, FixResult};
160pub use hooks::{HookError, HookInstaller};
161pub use mcp_server::McpServer;
162pub use pinning::{PinMismatch, PinVerifyResult, PinnedTool, ToolPins};
163pub use proxy::{InterceptAction, MessageInterceptor, ProxyConfig, ProxyLogger, ProxyServer};
164pub use remote::{ClonedRepo, GitCloner, RemoteError, parse_github_url};
165pub use sbom::{
166    Component, ComponentType, CycloneDxBom, DependencyExtractor, SbomBuilder, SbomFormat,
167};
168pub use trusted_domains::{TrustedDomain, TrustedDomainMatcher};
169pub use types::{AuthToken, FileHash, GitRef, PathValidationError, RuleId, ScanTarget};
170pub use watch::FileWatcher;