From dabfefa9ec326bb32b0ca296555791cb6d639ff5 Mon Sep 17 00:00:00 2001 From: GeekMasher Date: Fri, 12 Sep 2025 13:19:40 +0100 Subject: [PATCH 1/2] fix: enhance CodeQL directories and logging for working --- src/action.rs | 21 +++++++++++++++------ src/main.rs | 2 ++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/action.rs b/src/action.rs index d6761ff..b84a180 100644 --- a/src/action.rs +++ b/src/action.rs @@ -202,29 +202,35 @@ impl Action { /// # Errors /// - If `working_directory()` fails /// - If path canonicalization fails - fn get_codeql_directories(&self) -> Result> { + fn get_codeql_directories(&self) -> Vec { let mut paths = Vec::new(); // GITHUB_WORKSPACE if let Ok(github_workspace) = std::env::var("GITHUB_WORKSPACE") { + log::debug!("GITHUB_WORKSPACE found: {}", github_workspace); paths.push(PathBuf::from(github_workspace).join(".codeql")); } // Local CodeQL directory in the working directory - if let Ok(local_codeql) = self.working_directory()?.join(".codeql").canonicalize() { - paths.push(local_codeql); + if let Ok(working_dir) = self.working_directory() { + if let Ok(local_codeql) = working_dir.join(".codeql").canonicalize() { + log::debug!("Local working directory found: {}", local_codeql.display()); + paths.push(local_codeql); + } } // Runner temp directory if let Ok(runner_temp) = std::env::var("RUNNER_TEMP") { - paths.push(PathBuf::from(runner_temp).join(".codeql").canonicalize()?); + log::debug!("RUNNER_TEMP found: {}", runner_temp); + paths.push(PathBuf::from(runner_temp).join(".codeql")); } // temp_dir if let Ok(temp_dir) = std::env::temp_dir().canonicalize() { + log::debug!("System temp directory found: {}", temp_dir.display()); paths.push(temp_dir.join(".codeql")); } - Ok(paths) + paths } /// Returns the directory to use for CodeQL operations. @@ -237,7 +243,10 @@ impl Action { /// It uses the parent of the working directory to to stop issues where the /// database/sarif files gets indexed by CodeQL. pub fn get_codeql_dir(&self) -> Result { - let paths = self.get_codeql_directories()?; + let paths = self.get_codeql_directories(); + if paths.is_empty() { + return Err(anyhow::anyhow!("No valid CodeQL directories were found")); + } log::debug!("Possible CodeQL directories: {:?}", paths); for path in paths { diff --git a/src/main.rs b/src/main.rs index 4743e19..04d2bba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,9 +40,11 @@ async fn main() -> Result<()> { let cwd = action .working_directory() .context("Failed to get working directory")?; + log::info!("Working Directory :: {cwd:?}"); let codeql_dir = action .get_codeql_dir() .context("Failed to get CodeQL directory")?; + log::info!("CodeQL Directory :: {codeql_dir:?}"); let databases = codeql_dir.join("databases"); let sarif_output = codeql_dir.join("results"); From 17e47608f5990662885d9698cf14c52caf0cbc33 Mon Sep 17 00:00:00 2001 From: GeekMasher Date: Fri, 12 Sep 2025 13:20:40 +0100 Subject: [PATCH 2/2] feat(version): v0.1.3 --- .release.yml | 2 +- Cargo.lock | 33 +++++++++++++++++++++------------ Cargo.toml | 2 +- README.md | 2 +- action.Dockerfile | 2 +- 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/.release.yml b/.release.yml index 3e26315..f7cdd27 100644 --- a/.release.yml +++ b/.release.yml @@ -1,6 +1,6 @@ name: "codeql-extractor-action" repository: "advanced-security/codeql-extractor-action" -version: 0.1.2 +version: 0.1.3 ecosystems: - Docs diff --git a/Cargo.lock b/Cargo.lock index efe76a7..48656d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -199,9 +199,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.36" +version = "1.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5252b3d2648e5eedbc1a6f501e3c795e07025c1e93bbf8bbdd6eef7f447a6d54" +checksum = "65193589c6404eb80b450d618eaf9a2cafaaafd57ecce47370519ef674a7bd44" dependencies = [ "find-msvc-tools", "jobserver", @@ -241,7 +241,7 @@ dependencies = [ [[package]] name = "codeql-extractor-action" -version = "0.1.2" +version = "0.1.3" dependencies = [ "anyhow", "dotenvy", @@ -633,7 +633,7 @@ dependencies = [ "cfg-if", "libc", "r-efi", - "wasi 0.14.4+wasi-0.2.4", + "wasi 0.14.5+wasi-0.2.4", ] [[package]] @@ -1849,9 +1849,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.4" +version = "0.103.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a17884ae0c1b773f1ccd2bd4a8c72f16da897310a98b0e84bf349ad5ead92fc" +checksum = "b5a37813727b78798e53c2bec3f5e8fe12a6d6f8389bf9ca7802add4c9905ad8" dependencies = [ "ring", "rustls-pki-types", @@ -2439,9 +2439,9 @@ checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" [[package]] name = "unicode-ident" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" [[package]] name = "unsafe-libyaml" @@ -2518,9 +2518,18 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasi" -version = "0.14.4+wasi-0.2.4" +version = "0.14.5+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4494f6290a82f5fe584817a676a34b9d6763e8d9d18204009fb31dceca98fd4" +dependencies = [ + "wasip2", +] + +[[package]] +name = "wasip2" +version = "1.0.0+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88a5f4a424faf49c3c2c344f166f0662341d470ea185e939657aaff130f0ec4a" +checksum = "03fa2761397e5bd52002cd7e73110c71af2109aca4e521a9f40473fe685b0a24" dependencies = [ "wit-bindgen", ] @@ -2990,9 +2999,9 @@ dependencies = [ [[package]] name = "zip" -version = "5.0.0" +version = "5.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9fdfa5f34b5980f2c21b3a2c68c09ade4debddc7be52c51056695effc73a08c" +checksum = "2f852905151ac8d4d06fdca66520a661c09730a74c6d4e2b0f27b436b382e532" dependencies = [ "aes", "arbitrary", diff --git a/Cargo.toml b/Cargo.toml index ad9827e..6573d8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "codeql-extractor-action" description = "GitHub Action for CodeQL Extractors" -version = "0.1.2" +version = "0.1.3" authors = ["GeekMasher"] license = "MIT" diff --git a/README.md b/README.md index b8cb3f2..d1ebe42 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ This action is designed to be used in conjunction with the [CodeQL][CodeQL] anal ```yml - name: "CodeQL Extractor Action" - uses: advanced-security/codeql-extractor-action@v0.1.2 + uses: advanced-security/codeql-extractor-action@v0.1.3 with: # Repository reference (e.g. "owner/repo", "owner/repo@ref") extractor: "advanced-security/codeql-extractor-iac" diff --git a/action.Dockerfile b/action.Dockerfile index b95123f..69d0735 100644 --- a/action.Dockerfile +++ b/action.Dockerfile @@ -1,3 +1,3 @@ -FROM ghcr.io/advanced-security/codeql-extractor-action:v0.1.2 +FROM ghcr.io/advanced-security/codeql-extractor-action:v0.1.3 ENTRYPOINT [ "codeql-extractor-action" ]