Skip to content

Commit f17cacf

Browse files
committed
feat: replace "skip-git" with "include-git", making git repository scanning not the default
BREAKING CHANGE: don't scan git repositories by default, replacing "--skip-git" with "--include-git"
1 parent 2f87877 commit f17cacf

File tree

8 files changed

+8
-17
lines changed

8 files changed

+8
-17
lines changed

.github/workflows/osv-scanner-reusable-pr.yml

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ on:
2626
type: string
2727
default: |-
2828
-r
29-
--skip-git
3029
./
3130
results-file-name:
3231
description: "File name of the result SARIF file"

.github/workflows/osv-scanner-reusable.yml

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ on:
2626
type: string
2727
default: |-
2828
-r
29-
--skip-git
3029
./
3130
results-file-name:
3231
description: "File name of the result SARIF file"

.github/workflows/osv-scanner-unified-action.yml

-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ jobs:
3838
with:
3939
# Just scan the root directory and docs, since everything else is fixtures
4040
scan-args: |-
41-
--skip-git
4241
./
4342
./docs/
4443
scan-pr:
@@ -52,6 +51,5 @@ jobs:
5251
with:
5352
# Just scan the root directory and docs, since everything else is fixtures
5453
scan-args: |-
55-
--skip-git
5654
./
5755
./docs/

.github/workflows/prerelease-check.yml

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ jobs:
2727
# Only scan the top level go.mod file without recursively scanning directories since
2828
# this is pipeline is about releasing the go module and binary
2929
scan-args: |-
30-
--skip-git
3130
./
3231
3332
format:

actions/scanner/action.yml

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ inputs:
55
scan-args:
66
description: "Arguments to osv-scanner, separated by new line"
77
default: |-
8-
--skip-git
98
--recursive
109
./
1110
runs:

cmd/osv-scanner/scan/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ func Command(stdout, stderr io.Writer, r *reporter.Reporter) *cli.Command {
6868
TakesFile: true,
6969
},
7070
&cli.BoolFlag{
71-
Name: "skip-git",
72-
Usage: "skip scanning git repositories",
71+
Name: "include-git",
72+
Usage: "include scanning git repositories",
7373
Value: false,
7474
},
7575
&cli.BoolFlag{
@@ -204,7 +204,7 @@ func action(context *cli.Context, stdout, stderr io.Writer) (reporter.Reporter,
204204
SBOMPaths: context.StringSlice("sbom"),
205205
DockerContainerNames: context.StringSlice("docker"),
206206
Recursive: context.Bool("recursive"),
207-
SkipGit: context.Bool("skip-git"),
207+
IncludeGit: context.Bool("include-git"),
208208
NoIgnore: context.Bool("no-ignore"),
209209
ConfigOverridePath: context.String("config"),
210210
DirectoryPaths: context.Args().Slice(),

docs/github-action.md

-3
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ jobs:
138138
# Only scan the top level go.mod file without recursively scanning directories since
139139
# this is pipeline is about releasing the go module and binary
140140
scan-args: |-
141-
--skip-git
142141
./
143142
permissions:
144143
# Require writing security events to upload SARIF file to security tab
@@ -167,7 +166,6 @@ The GitHub Actions have the following optional inputs:
167166
Default:
168167
```bash
169168
--recursive # Recursively scan subdirectories
170-
--skip-git=true # Skip commit scanning to focus on dependencies
171169
./ # Start the scan from the root of the repository
172170
```
173171
- `results-file-name`: This is the name of the final SARIF file uploaded to Github.
@@ -202,7 +200,6 @@ jobs:
202200
with:
203201
scan-args: |-
204202
--recursive
205-
--skip-git=true
206203
./
207204
```
208205

pkg/osvscanner/osvscanner.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type ScannerActions struct {
4242
DirectoryPaths []string
4343
GitCommits []string
4444
Recursive bool
45-
SkipGit bool
45+
IncludeGit bool
4646
NoIgnore bool
4747
DockerContainerNames []string
4848
ConfigOverridePath string
@@ -108,7 +108,7 @@ const (
108108
// - Any lockfiles with scanLockfile
109109
// - Any SBOM files with scanSBOMFile
110110
// - Any git repositories with scanGit
111-
func scanDir(r reporter.Reporter, dir string, skipGit bool, recursive bool, useGitIgnore bool, compareOffline bool) ([]scannedPackage, error) {
111+
func scanDir(r reporter.Reporter, dir string, includeGit bool, recursive bool, useGitIgnore bool, compareOffline bool) ([]scannedPackage, error) {
112112
var ignoreMatcher *gitIgnoreMatcher
113113
if useGitIgnore {
114114
var err error
@@ -152,7 +152,7 @@ func scanDir(r reporter.Reporter, dir string, skipGit bool, recursive bool, useG
152152
}
153153
}
154154

155-
if !skipGit && info.IsDir() && info.Name() == ".git" {
155+
if includeGit && info.IsDir() && info.Name() == ".git" {
156156
pkgs, err := scanGit(r, filepath.Dir(path)+"/")
157157
if err != nil {
158158
r.Infof("scan failed for git repository, %s: %v\n", path, err)
@@ -828,7 +828,7 @@ func DoScan(actions ScannerActions, r reporter.Reporter) (models.VulnerabilityRe
828828
}
829829

830830
if actions.CompareOffline {
831-
actions.SkipGit = true
831+
actions.IncludeGit = false
832832

833833
if len(actions.ScanLicensesAllowlist) > 0 || actions.ScanLicensesSummary {
834834
return models.VulnerabilityResults{}, errors.New("cannot retrieve licenses locally")
@@ -903,7 +903,7 @@ func DoScan(actions ScannerActions, r reporter.Reporter) (models.VulnerabilityRe
903903

904904
for _, dir := range actions.DirectoryPaths {
905905
r.Infof("Scanning dir %s\n", dir)
906-
pkgs, err := scanDir(r, dir, actions.SkipGit, actions.Recursive, !actions.NoIgnore, actions.CompareOffline)
906+
pkgs, err := scanDir(r, dir, actions.IncludeGit, actions.Recursive, !actions.NoIgnore, actions.CompareOffline)
907907
if err != nil {
908908
return models.VulnerabilityResults{}, err
909909
}

0 commit comments

Comments
 (0)