Skip to content

Commit

Permalink
fix: remove double-printing of policy exprs
Browse files Browse the repository at this point in the history
  • Loading branch information
j-lanson authored and alilleybrinker committed Nov 8, 2024
1 parent f98d557 commit c82797e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
11 changes: 5 additions & 6 deletions hipcheck/src/report/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,14 @@ pub struct Analysis {
/// We use this when printing the result to help explain to the user
/// *why* an analysis failed.
policy_expr: String,

/// The default query explanation pulled from RPC with the plugin.
message: String,
}

impl Analysis {
pub fn plugin(name: String, passed: bool, policy_expr: String, message: String) -> Self {
pub fn plugin(name: String, passed: bool, policy_expr: String) -> Self {
Analysis {
name,
passed,
policy_expr,
message,
}
}

Expand All @@ -309,8 +305,11 @@ impl Analysis {
}
}

#[allow(unused)]
pub fn explanation(&self) -> String {
self.message.clone()
// @Todo - create subsystem that takes an Expr and explains in
// English why the policy did or did not fail
"".to_owned()
}
}

Expand Down
8 changes: 1 addition & 7 deletions hipcheck/src/report/report_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub use crate::report::*;
use crate::{
analysis::score::*,
config::{ConfigSource, RiskConfigQuery},
engine::HcEngine,
error::{Error, Result},
hc_error,
plugin::{PluginName, PluginPublisher},
Expand Down Expand Up @@ -35,13 +34,8 @@ pub fn build_report(session: &Session, scoring: &ScoringResults) -> Result<Repor

match &stored.response {
Ok(res) => {
// This is the "explanation" pulled from the new gRPC call.
let message = session
.default_query_explanation(analysis.publisher.clone(), analysis.plugin.clone())?
.unwrap_or("no query explanation provided".to_owned());

builder.add_analysis(
Analysis::plugin(name, stored.passed, stored.policy.clone(), message),
Analysis::plugin(name, stored.passed, stored.policy.clone()),
res.concerns.clone(),
)?;
}
Expand Down
2 changes: 0 additions & 2 deletions hipcheck/src/shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ fn print_human(report: Report) -> Result<()> {
Title::Passed,
analysis.statement()
);
macros::println!("{EMPTY:LEFT_COL_WIDTH$} {}", analysis.explanation());
// Empty line at end to space out analyses.
macros::println!();
}
Expand All @@ -381,7 +380,6 @@ fn print_human(report: Report) -> Result<()> {
Title::Failed,
analysis.statement()
);
macros::println!("{EMPTY:LEFT_COL_WIDTH$} {}", analysis.explanation());

for concern in failing_analysis.concerns() {
macros::println!("{EMPTY:LEFT_COL_WIDTH$} {}", concern);
Expand Down

0 comments on commit c82797e

Please sign in to comment.