File tree Expand file tree Collapse file tree 2 files changed +13
-13
lines changed
Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -3,24 +3,12 @@ package configurebaseline
33import (
44 "encoding/json"
55 "io/fs"
6- "os"
76 "path"
87 "path/filepath"
98
109 "github.com/github/codeql-go/extractor/util"
1110)
1211
13- func fileExists (path string ) bool {
14- stat , err := os .Stat (path )
15- return err == nil && stat .Mode ().IsRegular ()
16- }
17-
18- // Decides if `dirPath` is a vendor directory by testing whether it is called `vendor`
19- // and contains a `modules.txt` file.
20- func isGolangVendorDirectory (dirPath string ) bool {
21- return filepath .Base (dirPath ) == "vendor" && fileExists (filepath .Join (dirPath , "modules.txt" ))
22- }
23-
2412type BaselineConfig struct {
2513 PathsIgnore []string `json:"paths-ignore"`
2614}
@@ -38,7 +26,7 @@ func GetConfigBaselineAsJSON(rootDir string) ([]byte, error) {
3826 // it will not be extracted either.
3927 return nil
4028 }
41- if isGolangVendorDirectory (dirPath ) {
29+ if util . IsGolangVendorDirectory (dirPath ) {
4230 // Note that CodeQL expects a forward-slash-separated path, even on Windows.
4331 vendorDirs = append (vendorDirs , path .Join (filepath .ToSlash (dirPath ), "**" ))
4432 return filepath .SkipDir
Original file line number Diff line number Diff line change @@ -287,3 +287,15 @@ func getImportPathFromRepoURL(repourl string) string {
287287 path = regexp .MustCompile (`^/+|\.git$` ).ReplaceAllString (path , "" )
288288 return host + "/" + path
289289}
290+
291+ // Decides if `path` refers to a file that exists.
292+ func fileExists (path string ) bool {
293+ stat , err := os .Stat (path )
294+ return err == nil && stat .Mode ().IsRegular ()
295+ }
296+
297+ // Decides if `dirPath` is a vendor directory by testing whether it is called `vendor`
298+ // and contains a `modules.txt` file.
299+ func IsGolangVendorDirectory (dirPath string ) bool {
300+ return filepath .Base (dirPath ) == "vendor" && fileExists (filepath .Join (dirPath , "modules.txt" ))
301+ }
You can’t perform that action at this time.
0 commit comments