Skip to content

Commit bade8f2

Browse files
authored
Merge pull request #22 from advanced-security/output-location
feat: Add method to determine CodeQL directory for the action
2 parents e472216 + fc0fd7f commit bade8f2

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/action.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,24 @@ impl Action {
136136
.collect()
137137
}
138138

139+
/// Gets the CodeQL directory to use for the action. It will first check if a local
140+
/// `.codeql` directory exists in the working directory parent. If not, it will
141+
/// use the `RUNNER_TEMP` directory. If neither exists, it will create a new
142+
/// `.codeql` directory in the working directory parent.
143+
///
144+
/// It uses the parent of the working directory to to stop issues where the
145+
/// database/sarif files gets indexed by CodeQL.
139146
pub fn get_codeql_dir(&self) -> Result<PathBuf> {
140147
let paths = vec![
141-
// Local CodeQL directory in the working directory
142-
self.working_directory()?.join(".codeql"),
148+
// Local CodeQL directory in the working directory parent
149+
self.working_directory()?
150+
.join("..")
151+
.join(".codeql")
152+
.canonicalize()?,
143153
// Runner temp directory
144154
PathBuf::from(std::env::var("RUNNER_TEMP").unwrap_or_else(|_| "/tmp".to_string()))
145-
.join(".codeql"),
155+
.join(".codeql")
156+
.canonicalize()?,
146157
];
147158

148159
for path in paths {

0 commit comments

Comments
 (0)