Skip to content

Commit 47d503e

Browse files
authored
Merge pull request #25 from advanced-security/patch-codeql-dirs
Patch: Fix CodeQL directories bug and release v0.1.3
2 parents 9f40f1f + 17e4760 commit 47d503e

File tree

7 files changed

+42
-22
lines changed

7 files changed

+42
-22
lines changed

.release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: "codeql-extractor-action"
22
repository: "advanced-security/codeql-extractor-action"
3-
version: 0.1.2
3+
version: 0.1.3
44

55
ecosystems:
66
- Docs

Cargo.lock

Lines changed: 21 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "codeql-extractor-action"
33
description = "GitHub Action for CodeQL Extractors"
4-
version = "0.1.2"
4+
version = "0.1.3"
55
authors = ["GeekMasher"]
66

77
license = "MIT"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ This action is designed to be used in conjunction with the [CodeQL][CodeQL] anal
2929

3030
```yml
3131
- name: "CodeQL Extractor Action"
32-
uses: advanced-security/[email protected].2
32+
uses: advanced-security/[email protected].3
3333
with:
3434
# Repository reference (e.g. "owner/repo", "owner/repo@ref")
3535
extractor: "advanced-security/codeql-extractor-iac"

action.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
FROM ghcr.io/advanced-security/codeql-extractor-action:v0.1.2
1+
FROM ghcr.io/advanced-security/codeql-extractor-action:v0.1.3
22

33
ENTRYPOINT [ "codeql-extractor-action" ]

src/action.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,29 +202,35 @@ impl Action {
202202
/// # Errors
203203
/// - If `working_directory()` fails
204204
/// - If path canonicalization fails
205-
fn get_codeql_directories(&self) -> Result<Vec<PathBuf>> {
205+
fn get_codeql_directories(&self) -> Vec<PathBuf> {
206206
let mut paths = Vec::new();
207207

208208
// GITHUB_WORKSPACE
209209
if let Ok(github_workspace) = std::env::var("GITHUB_WORKSPACE") {
210+
log::debug!("GITHUB_WORKSPACE found: {}", github_workspace);
210211
paths.push(PathBuf::from(github_workspace).join(".codeql"));
211212
}
212213

213214
// Local CodeQL directory in the working directory
214-
if let Ok(local_codeql) = self.working_directory()?.join(".codeql").canonicalize() {
215-
paths.push(local_codeql);
215+
if let Ok(working_dir) = self.working_directory() {
216+
if let Ok(local_codeql) = working_dir.join(".codeql").canonicalize() {
217+
log::debug!("Local working directory found: {}", local_codeql.display());
218+
paths.push(local_codeql);
219+
}
216220
}
217221

218222
// Runner temp directory
219223
if let Ok(runner_temp) = std::env::var("RUNNER_TEMP") {
220-
paths.push(PathBuf::from(runner_temp).join(".codeql").canonicalize()?);
224+
log::debug!("RUNNER_TEMP found: {}", runner_temp);
225+
paths.push(PathBuf::from(runner_temp).join(".codeql"));
221226
}
222227
// temp_dir
223228
if let Ok(temp_dir) = std::env::temp_dir().canonicalize() {
229+
log::debug!("System temp directory found: {}", temp_dir.display());
224230
paths.push(temp_dir.join(".codeql"));
225231
}
226232

227-
Ok(paths)
233+
paths
228234
}
229235

230236
/// Returns the directory to use for CodeQL operations.
@@ -237,7 +243,10 @@ impl Action {
237243
/// It uses the parent of the working directory to to stop issues where the
238244
/// database/sarif files gets indexed by CodeQL.
239245
pub fn get_codeql_dir(&self) -> Result<PathBuf> {
240-
let paths = self.get_codeql_directories()?;
246+
let paths = self.get_codeql_directories();
247+
if paths.is_empty() {
248+
return Err(anyhow::anyhow!("No valid CodeQL directories were found"));
249+
}
241250
log::debug!("Possible CodeQL directories: {:?}", paths);
242251

243252
for path in paths {

src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ async fn main() -> Result<()> {
4040
let cwd = action
4141
.working_directory()
4242
.context("Failed to get working directory")?;
43+
log::info!("Working Directory :: {cwd:?}");
4344
let codeql_dir = action
4445
.get_codeql_dir()
4546
.context("Failed to get CodeQL directory")?;
47+
log::info!("CodeQL Directory :: {codeql_dir:?}");
4648

4749
let databases = codeql_dir.join("databases");
4850
let sarif_output = codeql_dir.join("results");

0 commit comments

Comments
 (0)