Skip to content

Commit

Permalink
Merge pull request #72 from newrelic/scutler_20240822
Browse files Browse the repository at this point in the history
adding a change to duroc hog output
  • Loading branch information
cutler-scott-newrelic authored Aug 22, 2024
2 parents a974e81 + 858625b commit c607cf9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
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

0 comments on commit c607cf9

Please sign in to comment.