Skip to content

Commit

Permalink
refactor/simplify concretization
Browse files Browse the repository at this point in the history
  • Loading branch information
woodruffw committed Jan 23, 2025
1 parent b98190b commit ec31dd6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 57 deletions.
2 changes: 1 addition & 1 deletion src/audit/overprovisioned_secrets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl Audit for OverprovisionedSecrets {
continue;
};

todo!()
// todo!()
}

Ok(vec![])
Expand Down
51 changes: 0 additions & 51 deletions src/finding/locate.rs

This file was deleted.

34 changes: 29 additions & 5 deletions src/finding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::{borrow::Cow, sync::LazyLock};

use anyhow::{anyhow, Result};
use clap::ValueEnum;
use locate::Locator;
use regex::Regex;
use serde::Serialize;
use terminal_link::Link;
Expand All @@ -14,8 +13,6 @@ use crate::{
registry::InputKey,
};

pub(crate) mod locate;

/// Represents the expected "persona" that would be interested in a given
/// finding. This is used to model the sensitivity of different use-cases
/// to false positives.
Expand Down Expand Up @@ -192,11 +189,38 @@ impl<'w> SymbolicLocation<'w> {
self,
document: &'w impl AsRef<yamlpath::Document>,
) -> Result<Location<'w>> {
let feature = Locator::new().concretize(document, &self)?;
let document = document.as_ref();

// If we don't have a path into the workflow, all
// we have is the workflow itself.
let feature = if self.route.components.is_empty() {
document.root()
} else {
let mut builder = yamlpath::QueryBuilder::new();

for component in &self.route.components {
builder = match component {
RouteComponent::Key(key) => builder.key(key.clone()),
RouteComponent::Index(idx) => builder.index(*idx),
}
}

let query = builder.build();

document.query(&query)?
};

Ok(Location {
symbolic: self,
concrete: feature,
concrete: Feature {
location: ConcreteLocation::from(&feature.location),
feature: document.extract_with_leading_whitespace(&feature),
comments: document
.feature_comments(&feature)
.into_iter()
.map(Comment)
.collect(),
},
})
}
}
Expand Down

0 comments on commit ec31dd6

Please sign in to comment.