Skip to content

Commit 83ee737

Browse files
committed
Embed default patterns for cargo install
1 parent cc8840b commit 83ee737

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ repository = "https://github.com/script3r/cipherscope"
88
readme = "README.md"
99
keywords = ["crypto", "static-analysis", "security", "inventory", "tree-sitter"]
1010
categories = ["development-tools", "command-line-utilities"]
11+
include = ["src/**", "patterns.toml", "Cargo.toml", "README.md", "LICENSE"]
1112

1213
[dependencies]
1314
anyhow = "1.0"

src/main.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ use serde::Serialize;
1919
mod patterns;
2020
mod scan;
2121

22+
const DEFAULT_PATTERNS: &str = include_str!("../patterns.toml");
23+
2224
#[derive(Parser, Debug)]
2325
#[command(
2426
name = "cipherscope",
@@ -34,9 +36,9 @@ struct Cli {
3436
#[arg(short, long)]
3537
exclude: Vec<String>,
3638

37-
/// Path to patterns.toml
38-
#[arg(short = 'p', long, default_value = "patterns.toml")]
39-
patterns: PathBuf,
39+
/// Path to patterns.toml (defaults to the embedded patterns)
40+
#[arg(short = 'p', long)]
41+
patterns: Option<PathBuf>,
4042

4143
/// Output JSONL file path (defaults to stdout, use a filename to write to file)
4244
#[arg(short, long, default_value = "-")]
@@ -98,8 +100,12 @@ fn main() -> Result<()> {
98100
.build_global()
99101
.ok();
100102

101-
let patterns_text = std::fs::read_to_string(&cli.patterns)
102-
.with_context(|| format!("reading patterns file: {}", cli.patterns.display()))?;
103+
let patterns_text = if let Some(path) = cli.patterns.as_ref() {
104+
std::fs::read_to_string(path)
105+
.with_context(|| format!("reading patterns file: {}", path.display()))?
106+
} else {
107+
DEFAULT_PATTERNS.to_string()
108+
};
103109
let patterns = Arc::new(patterns::PatternSet::from_toml(&patterns_text)?);
104110

105111
// Setup progress reporting

0 commit comments

Comments
 (0)