Skip to content

Commit

Permalink
Simplify result.
Browse files Browse the repository at this point in the history
  • Loading branch information
bartossh committed Aug 25, 2024
1 parent 342fdd3 commit 47244cb
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 12 deletions.
2 changes: 0 additions & 2 deletions src/detectors/regex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ where
file: self.file.to_string(),
line: self.line_ends.get_line(start.unwrap_or_default()).unwrap_or_default(),
author: None,
verified: false,
};

start = Some(position.start);
Expand Down Expand Up @@ -233,7 +232,6 @@ where
file: self.file.to_string(),
line: self.line_ends.get_line(start.unwrap_or_default()).unwrap_or_default(),
author: None,
verified: false,
};
let _ = self.sx.send(Some(Input::Finding(secret)));
}
Expand Down
9 changes: 2 additions & 7 deletions src/result/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,13 @@ pub struct Secret {
pub file: String,
pub line: usize,
pub author: Option<String>,
pub verified: bool,
}

impl Display for Secret {
#[inline(always)]
fn fmt(&self, f: &mut Formatter) -> Result {
let verified: &str = match self.verified {
true => "Found verified result !",
_ => "Found unverified result ?",
};
write!(f, "{}\nDetector Type [ {} ]\nDecoderType [ {} ]\nRawResult [ {} ]\nBranch [ {} ]\nFile [ {} ]\nLine [ {} ]\nAuthor [ {} ]\n",
verified, self.detector_type, self.decoder_type, self.raw_result,
write!(f, "😱 Found secret:\nDetector Type [ {} ]\nDecoderType [ {} ]\nRawResult [ {} ]\nBranch [ {} ]\nFile [ {} ]\nLine [ {} ]\nAuthor [ {} ]\n",
self.detector_type, self.decoder_type, self.raw_result,
self.branch, self.file, self.line, self.author.clone().unwrap_or("unknown".to_string()),
)
}
Expand Down
3 changes: 1 addition & 2 deletions src/result/mod_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ mod tests {
file: "some/file/with/secert/key.priv".to_string(),
line: 21,
author: None,
verified: false,
};

let mut given = String::new();
Expand All @@ -24,7 +23,7 @@ mod tests {
};

assert_eq!(given,
r#"Found unverified result ?
r#"😱 Found secret:
Detector Type [ AWS ]
DecoderType [ Plane ]
RawResult [ -----BEGIN PRIVATE KEY-----MIIBWwIBADCCATQGByqGSM44BAEwggEnAoGBAKUM1CBGwXTGv6j5PWTfcAkD5zp2fOQnT/bl9Be3y+c9yppoa9Z/WKv3Dc2rIg75hbjJcbgwFlLqpnJa7/a+g88UWzhZGHCRCtFMon3OFlw9xUzA3bh8VyzuMybG71eIt0TnJteFbc9bzHy742YQJkBUOmqkUkOcSUwd5AnXH8sxAh0Az+gTc64gel0LHg4k0a5Mi4xQomnMuC+Dy+pqBQKBgQCJc5Zsr2+CMUIF36EJI80+o7y76s+G4LUYu6+qnu5X/p5lK2mg2CqEHDQjkRMbBuAyVmIl/7uj14AUD4P4NJxptN4smzMLLu+dDyt1SzwZDPgDs6rTCKHkA18IDwazvpfr6RT1n8zZM8dbmWdXqDP5HNn4CQX6c/aFJe8dlwV3MAQeAhwPlZQFNUSYcSyX7jrv/WYvV1DyUMkYTmpVgmXA-----END PRIVATE KEY----- ]
Expand Down
1 change: 0 additions & 1 deletion src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub trait RepositoryProvider {
fn get_local_branches(&self) -> Result<Vec<String>, SourceError>;
fn get_remote_branches(&self) -> Result<Vec<String>, SourceError>;
fn switch_branch(&self, branch: &str) -> Result<(), SourceError>;
fn
}

/// Source wrapps around the concreate source provider.
Expand Down

0 comments on commit 47244cb

Please sign in to comment.