Skip to content

Commit

Permalink
Use platform path separators for file testing, and forward-slashes fo…
Browse files Browse the repository at this point in the history
…r reporting to CodeQL
  • Loading branch information
smowton committed Aug 21, 2024
1 parent c99a846 commit 2939cef
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions go/extractor/configurebaseline/configurebaseline.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func fileExists(path string) bool {
// Decides if `dirPath` is a vendor directory by testing whether it is called `vendor`
// and contains a `modules.txt` file.
func isGolangVendorDirectory(dirPath string) bool {
return path.Base(dirPath) == "vendor" && fileExists(path.Join(dirPath, "modules.txt"))
return filepath.Base(dirPath) == "vendor" && fileExists(filepath.Join(dirPath, "modules.txt"))
}

type BaselineConfig struct {
Expand All @@ -38,7 +38,8 @@ func GetConfigBaselineAsJSON(rootDir string) ([]byte, error) {
return nil
}
if isGolangVendorDirectory(dirPath) {
vendorDirs = append(vendorDirs, path.Join(dirPath, "**"))
// Note that CodeQL expects a forward-slash-separated path, even on Windows.
vendorDirs = append(vendorDirs, path.Join(filepath.ToSlash(dirPath), "**"))
return filepath.SkipDir
} else {
return nil
Expand Down

0 comments on commit 2939cef

Please sign in to comment.