Skip to content

Commit 858625b

Browse files
adding a change to duroc hog output
1 parent a974e81 commit 858625b

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

crates/rusty-hog-scanner/src/default_rules.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"Slack Token": "(xox[p|b|o|a]-[0-9]{12}-[0-9]{12}-[0-9]{12}-[a-z0-9]{32})",
2+
"Slack Token": "(xox[p|b|o|a]-[0-9]{10,13}-[0-9]{10,13}[a-zA-Z0-9\\-]*)",
33
"RSA private key": "-----BEGIN RSA PRIVATE KEY-----",
44
"SSH (DSA) private key": "-----BEGIN DSA PRIVATE KEY-----",
55
"SSH (EC) private key": "-----BEGIN EC PRIVATE KEY-----",

src/bin/duroc_hog.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub struct FileFinding {
5858
pub path: String,
5959
pub reason: String,
6060
pub linenum: usize,
61-
pub diff: String,
61+
pub lineindextuples: Vec<(usize, usize)>
6262
}
6363

6464
const ZIPEXTENSIONS: &[&str] = &["zip"];
@@ -379,22 +379,21 @@ fn scan_bytes(input: Vec<u8>, ss: &SecretScanner, path: String) -> HashSet<FileF
379379
let results = ss.matches_entropy(new_line);
380380
for (r, matches) in results {
381381
let mut strings_found: Vec<String> = Vec::new();
382+
let mut lineindextuples: Vec<(usize, usize)> = Vec::new();
382383
for m in matches {
383384
let result = ASCII
384385
.decode(&new_line[m.start()..m.end()], DecoderTrap::Ignore)
385386
.unwrap_or_else(|_| "<STRING DECODE ERROR>".parse().unwrap());
386387
strings_found.push(result);
388+
lineindextuples.push((m.start(),m.end()));
387389
}
388390
if !strings_found.is_empty() {
389-
let new_line_string = ASCII
390-
.decode(&new_line, DecoderTrap::Ignore)
391-
.unwrap_or_else(|_| "<STRING DECODE ERROR>".parse().unwrap());
392391
findings.insert(FileFinding {
393-
diff: new_line_string,
394392
strings_found,
395393
reason: r.clone(),
396394
path: path.clone(),
397395
linenum: index + 1,
396+
lineindextuples
398397
});
399398
}
400399
}

0 commit comments

Comments
 (0)