Skip to content

Commit

Permalink
chore: rename typo-file-path and orgs-file-path
Browse files Browse the repository at this point in the history
  • Loading branch information
j-lanson authored and patrickjcasey committed Nov 14, 2024
1 parent 7883031 commit de22001
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions config/Hipcheck.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ analyze {

category "attacks" {
analysis "mitre/typo" {
typo-file-path "./config/Typos.toml"
typo-file "./config/Typos.toml"
count-threshold 0
}

category "commit" {
analysis "mitre/affiliation" {
orgs-file-path "./plugins/affiliation/test/example_orgs.kdl"
orgs-file "./plugins/affiliation/test/example_orgs.kdl"
count-threshold 0
}

Expand Down
8 changes: 4 additions & 4 deletions plugins/affiliation/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct Config {

#[derive(Debug, Deserialize)]
struct RawConfig {
#[serde(rename = "orgs-file-path")]
#[serde(rename = "orgs-file")]
orgs_file_path: Option<String>,
#[serde(rename = "count-threshold")]
count_threshold: Option<u64>,
Expand All @@ -51,14 +51,14 @@ impl TryFrom<RawConfig> for Config {
// Get the Orgs file path and confirm it exists
let orgs_file = PathBuf::from(&ofv);
file::exists(&orgs_file).map_err(|_e| ConfigError::InvalidConfigValue {
field_name: "orgs_file_path".to_owned(),
field_name: "orgs-file".to_owned(),
value: ofv.clone(),
reason: "could not find an orgs file with that name".to_owned(),
})?;
// Parse the Orgs file and construct an OrgSpec.
let orgs_spec =
OrgSpec::load_from(&orgs_file).map_err(|e| ConfigError::InvalidConfigValue {
field_name: "orgs_file_path".to_owned(),
field_name: "orgs-file".to_owned(),
value: ofv.clone(),
reason: format!("Failed to load org spec: {}", e),
})?;
Expand All @@ -68,7 +68,7 @@ impl TryFrom<RawConfig> for Config {
})
} else {
Err(ConfigError::MissingRequiredConfig {
field_name: "orgs_file_path".to_owned(),
field_name: "orgs-file".to_owned(),
field_type: "string".to_owned(),
possible_values: vec![],
})
Expand Down
6 changes: 3 additions & 3 deletions plugins/typo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub static TYPOFILE: OnceLock<TypoFile> = OnceLock::new();

#[derive(Deserialize)]
struct RawConfig {
#[serde(rename = "typo-file-path")]
#[serde(rename = "typo-file")]
typo_file_path: Option<String>,
#[serde(rename = "count-threshold")]
count_threshold: Option<u64>,
Expand All @@ -38,7 +38,7 @@ impl TryFrom<RawConfig> for Config {
// Get path to typo TOML file
let Some(raw_typo_path) = value.typo_file_path else {
return Err(ConfigError::MissingRequiredConfig {
field_name: "typo_file_path".to_owned(),
field_name: "typo-file".to_owned(),
field_type: "string".to_owned(),
possible_values: vec![],
});
Expand All @@ -48,7 +48,7 @@ impl TryFrom<RawConfig> for Config {
let typo_file = TypoFile::load_from(&typo_path).map_err(|e| {
log::error!("failed to load typo file: {}", e);
ConfigError::InvalidConfigValue {
field_name: "typo_file_path".to_owned(),
field_name: "typo-file".to_owned(),
value: "string".to_owned(),
reason: format!("failed to load typo file: {}", e),
}
Expand Down

0 comments on commit de22001

Please sign in to comment.