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

feat: Adds typo plugin #544

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 17 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ members = [
"plugins/npm_dependencies",
"plugins/activity",
"plugins/affiliation",
"plugins/fuzz",
"plugins/binary",
"plugins/churn",
"plugins/entropy",
"plugins/fuzz",
"plugins/identity",
"plugins/linguist",
"plugins/review",
"plugins/binary",
"plugins/identity",
"plugins/churn"
]
"plugins/typo"]

# Make sure Hipcheck is run with `cargo run`.
#
Expand Down
11 changes: 6 additions & 5 deletions config/Hipcheck.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ plugins {
plugin "mitre/activity" version="0.1.0"
plugin "mitre/binary" version="0.1.0"
plugin "mitre/fuzz" version="0.1.0" manifest="./plugins/fuzz/plugin.kdl"
plugin "mitre/review" version="0.1.0"
plugin "mitre/typo" version="0.1.0"
plugin "mitre/review" version="0.1.0" manifest="./plugins/review/plugin.kdl"
plugin "mitre/typo" version="0.1.0" manifest="./plugins/typo/plugin.kdl"
plugin "mitre/affiliation" version="0.1.0"
plugin "mitre/entropy" version="0.1.0"
plugin "mitre/churn" version="0.1.0"
Expand All @@ -21,15 +21,16 @@ analyze {
analysis "mitre/activity" policy="(lte $ 52)" weight=3
analysis "mitre/binary" {
binary-file "./config/Binary.toml"
binary-file-threshold "0"
binary-file-threshold 0
}
analysis "mitre/fuzz" policy="(eq #t $)"
analysis "mitre/review" policy="(lte $ 0.05)"
}

category "attacks" {
analysis "mitre/typo" policy="(eq 0 (count $))" {
typo-file "./config/Typos.toml"
analysis "mitre/typo" {
typo-file-path "./config/Typos.toml"
count-threshold 0
}

category "commit" {
Expand Down
2 changes: 1 addition & 1 deletion hipcheck/src/plugin/retrieval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use xz2::read::XzDecoder;
use super::get_current_arch;

/// The plugins currently are not delegated via the `plugin` system and are still part of `hipcheck` core
pub const MITRE_LEGACY_PLUGINS: [&str; 4] = ["activity", "entropy", "affiliation", "typo"];
pub const MITRE_LEGACY_PLUGINS: [&str; 3] = ["activity", "entropy", "affiliation"];

/// determine all of the plugins that need to be run and locate download them, if they do not exist
pub fn retrieve_plugins(
Expand Down
3 changes: 1 addition & 2 deletions plugins/affiliation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ strum = { version = "0.26.3", features = ["derive"] }
tokio = { version = "1.40.0", features = ["rt"] }

[dev-dependencies]
hipcheck-sdk = { path = "../../sdk/rust", features = ["macros", "mock_engine"]}
test-log = "0.2.16"
hipcheck-sdk = { path = "../../sdk/rust", features = ["macros", "mock_engine"]}
4 changes: 1 addition & 3 deletions plugins/affiliation/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,6 @@ mod test {

use pathbuf::pathbuf;
use std::{env, result::Result as StdResult};
use test_log::test;

fn repo() -> LocalGitRepo {
LocalGitRepo {
path: "/home/users/me/.cache/hipcheck/clones/github/foo/bar/".to_string(),
Expand Down Expand Up @@ -547,7 +545,7 @@ mod test {
Ok(mock_responses)
}

#[test(tokio::test)]
#[tokio::test]
async fn test_affiliation() {
let orgs_file = pathbuf![&env::current_dir().unwrap(), "test", "example_orgs.kdl"];
let orgs_spec = OrgSpec::load_from(&orgs_file).unwrap();
Expand Down
10 changes: 10 additions & 0 deletions plugins/npm_dependencies/plugin.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
publisher "mitre"
name "npm_dependencies"
version "0.1.0"
license "Apache-2.0"
entrypoint {
on arch="aarch64-apple-darwin" "./target/debug/npm_dependencies_sdk"
on arch="x86_64-apple-darwin" "./target/debug/npm_dependencies_sdk"
on arch="x86_64-unknown-linux-gnu" "./target/debug/npm_dependencies_sdk"
on arch="x86_64-pc-windows-msvc" "./target/debug/npm_dependencies_sdk"
}
22 changes: 22 additions & 0 deletions plugins/typo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "typo_sdk"
version = "0.1.0"
license = "Apache-2.0"
edition = "2021"
publish = false

[dependencies]
anyhow = "1.0.91"
clap = { version = "4.5.18", features = ["derive"] }
hipcheck-sdk = { path = "../../sdk/rust", features = ["macros"] }
log = "0.4.22"
maplit = "1.0.2"
pathbuf = "1.0.0"
serde = { version = "1.0.210", features = ["derive", "rc"] }
serde_json = "1.0.128"
tokio = { version = "1.40.0", features = ["rt"] }
toml = "0.8.19"
url = "2.5.2"

[dev-dependencies]
hipcheck-sdk = { path = "../../sdk/rust", features = ["mock_engine"] }
13 changes: 13 additions & 0 deletions plugins/typo/plugin.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
publisher "mitre"
name "typo"
version "0.1.0"
license "Apache-2.0"
entrypoint {
on arch="aarch64-apple-darwin" "./target/debug/typo_sdk"
on arch="x86_64-apple-darwin" "./target/debug/typo_sdk"
on arch="x86_64-unknown-linux-gnu" "./target/debug/typo_sdk"
on arch="x86_64-pc-windows-msvc" "./target/debug/typo_sdk"
}
dependencies {
plugin "mitre/npm_dependencies" version="0.1.0" manifest="./plugins/npm_dependencies/plugin.kdl"
}
Loading