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
3
3
import (
4
4
"encoding/json"
5
5
"io/fs"
6
- "os"
7
6
"path"
8
7
"path/filepath"
9
8
10
9
"github.com/github/codeql-go/extractor/util"
11
10
)
12
11
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
-
24
12
type BaselineConfig struct {
25
13
PathsIgnore []string `json:"paths-ignore"`
26
14
}
@@ -38,7 +26,7 @@ func GetConfigBaselineAsJSON(rootDir string) ([]byte, error) {
38
26
// it will not be extracted either.
39
27
return nil
40
28
}
41
- if isGolangVendorDirectory (dirPath ) {
29
+ if util . IsGolangVendorDirectory (dirPath ) {
42
30
// Note that CodeQL expects a forward-slash-separated path, even on Windows.
43
31
vendorDirs = append (vendorDirs , path .Join (filepath .ToSlash (dirPath ), "**" ))
44
32
return filepath .SkipDir
Original file line number Diff line number Diff line change @@ -287,3 +287,15 @@ func getImportPathFromRepoURL(repourl string) string {
287
287
path = regexp .MustCompile (`^/+|\.git$` ).ReplaceAllString (path , "" )
288
288
return host + "/" + path
289
289
}
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