Skip to content
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
2 changes: 1 addition & 1 deletion .release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "codeql-extractor-action"
repository: "advanced-security/codeql-extractor-action"
version: 0.1.2
version: 0.1.3

ecosystems:
- Docs
Expand Down
33 changes: 21 additions & 12 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected].2
uses: advanced-security/[email protected].3
with:
# Repository reference (e.g. "owner/repo", "owner/repo@ref")
extractor: "advanced-security/codeql-extractor-iac"
Expand Down
2 changes: 1 addition & 1 deletion action.Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
21 changes: 15 additions & 6 deletions src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,29 +202,35 @@
/// # Errors
/// - If `working_directory()` fails
/// - If path canonicalization fails
fn get_codeql_directories(&self) -> Result<Vec<PathBuf>> {
fn get_codeql_directories(&self) -> Vec<PathBuf> {
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.
Expand All @@ -237,7 +243,10 @@
/// 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<PathBuf> {
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 {
Expand Down
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Loading