Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding a change to duroc hog output #72

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/rusty-hog-scanner/src/default_rules.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Slack Token": "(xox[p|b|o|a]-[0-9]{12}-[0-9]{12}-[0-9]{12}-[a-z0-9]{32})",
"Slack Token": "(xox[p|b|o|a]-[0-9]{10,13}-[0-9]{10,13}[a-zA-Z0-9\\-]*)",
"RSA private key": "-----BEGIN RSA PRIVATE KEY-----",
"SSH (DSA) private key": "-----BEGIN DSA PRIVATE KEY-----",
"SSH (EC) private key": "-----BEGIN EC PRIVATE KEY-----",
Expand Down
9 changes: 4 additions & 5 deletions src/bin/duroc_hog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub struct FileFinding {
pub path: String,
pub reason: String,
pub linenum: usize,
pub diff: String,
pub lineindextuples: Vec<(usize, usize)>
}

const ZIPEXTENSIONS: &[&str] = &["zip"];
Expand Down Expand Up @@ -379,22 +379,21 @@ fn scan_bytes(input: Vec<u8>, ss: &SecretScanner, path: String) -> HashSet<FileF
let results = ss.matches_entropy(new_line);
for (r, matches) in results {
let mut strings_found: Vec<String> = Vec::new();
let mut lineindextuples: Vec<(usize, usize)> = Vec::new();
for m in matches {
let result = ASCII
.decode(&new_line[m.start()..m.end()], DecoderTrap::Ignore)
.unwrap_or_else(|_| "<STRING DECODE ERROR>".parse().unwrap());
strings_found.push(result);
lineindextuples.push((m.start(),m.end()));
}
if !strings_found.is_empty() {
let new_line_string = ASCII
.decode(&new_line, DecoderTrap::Ignore)
.unwrap_or_else(|_| "<STRING DECODE ERROR>".parse().unwrap());
findings.insert(FileFinding {
diff: new_line_string,
strings_found,
reason: r.clone(),
path: path.clone(),
linenum: index + 1,
lineindextuples
});
}
}
Expand Down
Loading