From 73336d4a842b019f36ba26ad67a6cb270ff55687 Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Tue, 6 Aug 2024 10:31:13 +0000 Subject: [PATCH] add code, iac, sbom, code and log4shell functions --- .github/workflows/example.yml | 2 +- plugin/Cargo.lock | 2 +- plugin/Cargo.toml | 2 +- plugin/src/lib.rs | 90 +++++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+), 3 deletions(-) diff --git a/.github/workflows/example.yml b/.github/workflows/example.yml index 3757ce7..e74a2ec 100644 --- a/.github/workflows/example.yml +++ b/.github/workflows/example.yml @@ -17,7 +17,7 @@ jobs: pipeline: . args: | setup - iac_test --severity-threshold=medium + iac test --severity-threshold=medium working-directory: example env: SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} diff --git a/plugin/Cargo.lock b/plugin/Cargo.lock index 2b39291..14f0d49 100644 --- a/plugin/Cargo.lock +++ b/plugin/Cargo.lock @@ -345,7 +345,7 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "snyk" -version = "0.6.0" +version = "0.6.1" dependencies = [ "extism-pdk", "fluentci-pdk", diff --git a/plugin/Cargo.toml b/plugin/Cargo.toml index b3518ca..7a0e0c0 100644 --- a/plugin/Cargo.toml +++ b/plugin/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2021" name = "snyk" -version = "0.6.0" +version = "0.6.1" [lib] crate-type = ["cdylib"] diff --git a/plugin/src/lib.rs b/plugin/src/lib.rs index 16e5e4c..65e5587 100644 --- a/plugin/src/lib.rs +++ b/plugin/src/lib.rs @@ -35,6 +35,96 @@ pub fn test(args: String) -> FnResult { Ok(stdout) } +#[plugin_fn] +pub fn iac(args: String) -> FnResult { + let stdout = dag() + .pipeline("iac test")? + .pkgx()? + .with_exec(vec![ + "pkgx", + "+nodejs.org", + "+bun.sh", + "bunx", + "snyk", + "iac", + &args, + ])? + .stdout()?; + Ok(stdout) +} + +#[plugin_fn] +pub fn code(args: String) -> FnResult { + let stdout = dag() + .pipeline("iac test")? + .pkgx()? + .with_exec(vec![ + "pkgx", + "+nodejs.org", + "+bun.sh", + "bunx", + "snyk", + "code", + &args, + ])? + .stdout()?; + Ok(stdout) +} + +#[plugin_fn] +pub fn sbom(args: String) -> FnResult { + let stdout = dag() + .pipeline("iac test")? + .pkgx()? + .with_exec(vec![ + "pkgx", + "+nodejs.org", + "+bun.sh", + "bunx", + "snyk", + "sbom", + &args, + ])? + .stdout()?; + Ok(stdout) +} + +#[plugin_fn] +pub fn log4shell(args: String) -> FnResult { + let stdout = dag() + .pipeline("iac test")? + .pkgx()? + .with_exec(vec![ + "pkgx", + "+nodejs.org", + "+bun.sh", + "bunx", + "snyk", + "log4shell", + &args, + ])? + .stdout()?; + Ok(stdout) +} + +#[plugin_fn] +pub fn container(args: String) -> FnResult { + let stdout = dag() + .pipeline("iac test")? + .pkgx()? + .with_exec(vec![ + "pkgx", + "+nodejs.org", + "+bun.sh", + "bunx", + "snyk", + "container", + &args, + ])? + .stdout()?; + Ok(stdout) +} + #[plugin_fn] pub fn iac_test(args: String) -> FnResult { let stdout = dag()