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

chore: rename typo-file-path and orgs-file-path #627

Merged
merged 1 commit into from
Nov 14, 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
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