Skip to content

Commit

Permalink
Fix invalidation text showing for secrets that aren't invalidated
Browse files Browse the repository at this point in the history
Signed-off-by: Lilly Rose Berner <[email protected]>
  • Loading branch information
LostLuma committed Dec 1, 2024
1 parent 56563a7 commit 7e32708
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion echo/src/database/pastes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ impl Annotation {
for scan in scans {
let mut content = format!("Mystb.in found a secret for {}.", scan.service);

if invalidate_secrets {
if scan.invalidated {
content += " This secret has been invalidated.";
}

Expand Down
6 changes: 5 additions & 1 deletion echo/src/scanners/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub struct ScanResult<'r> {
pub tail: Position,

pub content: &'r str,
pub invalidated: bool,
pub service: Arc<String>,
}

Expand All @@ -35,16 +36,19 @@ pub async fn scan_file<'r>(content: &'r str, invalidate_secrets: bool) -> Vec<Sc

for scanner in SCANNERS.get().unwrap() {
for finding in scanner.execute(content) {
let do_invalidate = scanner.nullify() && invalidate_secrets;

let result = ScanResult {
service: scanner.service(),
content: finding.as_str(),
invalidated: do_invalidate,
head: find_position(content, finding.start()),
tail: find_position(content, finding.end()),
};

results.push(result);

if scanner.nullify() && invalidate_secrets {
if do_invalidate {
REPORTER.get().unwrap().add(finding.as_str()).await;
}
}
Expand Down

0 comments on commit 7e32708

Please sign in to comment.