Skip to content

Commit

Permalink
chore: remove churn, entropy, typo from hipcheck core
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarr-mitre committed Nov 22, 2024
1 parent 1297d11 commit eded124
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 1,420 deletions.
56 changes: 1 addition & 55 deletions hipcheck/src/analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use crate::{
F64,
};
use std::{
collections::HashSet,
default::Default,
};

Expand All @@ -20,47 +19,15 @@ use std::{
pub trait AnalysisProvider:
AttacksConfigQuery + CommitConfigQuery + GitProvider + MetricProvider + PracticesConfigQuery
{
/// Returns result of churn analysis
fn churn_analysis(&self) -> Result<QueryResult>;

/// Returns result of entropy analysis
fn entropy_analysis(&self) -> Result<QueryResult>;

/// Returns result of identity analysis
fn identity_analysis(&self) -> Result<QueryResult>;

/// Returns result of fuzz analysis
fn fuzz_analysis(&self) -> Result<QueryResult>;

/// Returns result of typo analysis
fn typo_analysis(&self) -> Result<QueryResult>;
}




pub fn churn_analysis(db: &dyn AnalysisProvider) -> Result<QueryResult> {
let results = db.churn_metric()?;
let value: Vec<F64> = results.commit_churn_freqs.iter().map(|o| o.churn).collect();
// @Todo - in RFD4 transition we lost the ability to flag commits, because
// the need to flag them as concerns is dependent on policy expr
Ok(QueryResult {
value: serde_json::to_value(value)?,
concerns: vec![],
})
}

pub fn entropy_analysis(db: &dyn AnalysisProvider) -> Result<QueryResult> {
let results = db.entropy_metric()?;
let value: Vec<F64> = results.commit_entropies.iter().map(|o| o.entropy).collect();
// @Todo - in RFD4 transition we lost the ability to flag commits, because
// the need to flag them as concerns is dependent on policy expr
Ok(QueryResult {
value: serde_json::to_value(value)?,
concerns: vec![],
})
}

pub fn identity_analysis(db: &dyn AnalysisProvider) -> Result<QueryResult> {
let results = db.identity_metric()?;
let num_flagged = results
Expand All @@ -83,25 +50,4 @@ pub fn fuzz_analysis(db: &dyn AnalysisProvider) -> Result<QueryResult> {
value: serde_json::to_value(value)?,
concerns: vec![],
})
}


pub fn typo_analysis(db: &dyn AnalysisProvider) -> Result<QueryResult> {
let results = db.typo_metric()?;

// @Note - policy expr json injection does not support string/obj as array elts
let value = results.typos.iter().map(|_| true).collect::<Vec<bool>>();

let concerns: Vec<String> = results
.typos
.iter()
.map(|typodep| typodep.dependency.to_string())
.collect::<HashSet<_>>()
.into_iter()
.collect();

Ok(QueryResult {
value: serde_json::to_value(value)?,
concerns,
})
}
}
1 change: 0 additions & 1 deletion hipcheck/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ use crate::{
session::Session,
setup::{resolve_and_transform_source, SourceType},
shell::Shell,
util::iter::{TryAny, TryFilter},
};
use cli::{
CacheArgs, CacheOp, CheckArgs, CliConfig, FullCommands, PluginArgs, SchemaArgs, SchemaCommand,
Expand Down
158 changes: 0 additions & 158 deletions hipcheck/src/metric/churn.rs

This file was deleted.

Loading

0 comments on commit eded124

Please sign in to comment.