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

[STAL-3020] Support validation #553

Merged
merged 12 commits into from
Nov 13, 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/bins/src/bin/datadog-static-analyzer-git-hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ fn main() -> Result<()> {
.filter(|f| !should_ignore_file_for_secret(f))
.collect();

let sds_scanner = build_sds_scanner(&secrets_rules);
let sds_scanner = build_sds_scanner(&secrets_rules, use_debug);

secrets_results = secrets_files
.par_iter()
Expand Down
4 changes: 2 additions & 2 deletions crates/bins/src/bin/datadog-static-analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ fn main() -> Result<()> {
None
};

let sds_scanner = build_sds_scanner(&secrets_rules);
let sds_scanner = build_sds_scanner(&secrets_rules, use_debug);

let nb_secrets_rules: usize = secrets_rules.len();
let nb_secrets_files = secrets_files.len();
Expand Down Expand Up @@ -695,7 +695,7 @@ fn main() -> Result<()> {
let secrets_execution_time_secs = secrets_start.elapsed().as_secs();

println!(
"Found {} secret(s) ({} validated) in {} file(s) using {} rule(s) within {} sec(s)",
"Found {} secret(s) (including {} valid) in {} file(s) using {} rule(s) within {} sec(s)",
nb_secrets_found,
nb_secrets_validated,
nb_secrets_files,
Expand Down
14 changes: 2 additions & 12 deletions crates/cli/src/datadog_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,8 @@ pub fn get_secrets_rules(use_staging: bool) -> Result<Vec<SecretRule>> {
match api_response {
Ok(d) => Ok(d
.data
.iter()
.map(|v| SecretRule {
id: v.id.clone(),
name: v.attributes.name.clone(),
description: v.attributes.description.clone(),
pattern: v.attributes.pattern.clone(),
default_included_keywords: v
.attributes
.default_included_keywords
.clone()
.unwrap_or_default(),
})
.into_iter()
.map(|v| v.try_into().expect("cannot convert rule"))
.collect()),
Err(e) => {
eprintln!("Error when parsing the secret rules {e:?}");
Expand Down
4 changes: 4 additions & 0 deletions crates/cli/src/model/cli_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ mod tests {
description: "description1".to_string(),
pattern: "pattern1".to_string(),
default_included_keywords: vec![],
validators: Some(vec![]),
match_validation: None,
};

let secret_rule2 = SecretRule {
Expand All @@ -199,6 +201,8 @@ mod tests {
description: "description2".to_string(),
pattern: "pattern2".to_string(),
default_included_keywords: vec![],
validators: Some(vec![]),
match_validation: None,
};

let cli_configuration_base = CliConfiguration {
Expand Down
Loading
Loading