Skip to content

Commit c1409f3

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 e054385 commit c1409f3

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
@@ -74,8 +74,8 @@ func Command(stdout, stderr io.Writer, r *reporter.Reporter) *cli.Command {
7474
TakesFile: true,
7575
},
7676
&cli.BoolFlag{
77-
Name: "skip-git",
78-
Usage: "skip scanning git repositories",
77+
Name: "include-git",
78+
Usage: "include scanning git repositories",
7979
Value: false,
8080
},
8181
&cli.BoolFlag{
@@ -226,7 +226,7 @@ func action(context *cli.Context, stdout, stderr io.Writer) (reporter.Reporter,
226226
SBOMPaths: context.StringSlice("sbom"),
227227
DockerContainerNames: context.StringSlice("docker"),
228228
Recursive: context.Bool("recursive"),
229-
SkipGit: context.Bool("skip-git"),
229+
IncludeGit: context.Bool("include-git"),
230230
NoIgnore: context.Bool("no-ignore"),
231231
ConfigOverridePath: context.String("config"),
232232
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
@@ -114,7 +114,7 @@ const (
114114
// - Any lockfiles with scanLockfile
115115
// - Any SBOM files with scanSBOMFile
116116
// - Any git repositories with scanGit
117-
func scanDir(r reporter.Reporter, dir string, skipGit bool, recursive bool, useGitIgnore bool, compareOffline bool, transitiveAct TransitiveScanningActions) ([]scannedPackage, error) {
117+
func scanDir(r reporter.Reporter, dir string, includeGit bool, recursive bool, useGitIgnore bool, compareOffline bool, transitiveAct TransitiveScanningActions) ([]scannedPackage, error) {
118118
var ignoreMatcher *gitIgnoreMatcher
119119
if useGitIgnore {
120120
var err error
@@ -158,7 +158,7 @@ func scanDir(r reporter.Reporter, dir string, skipGit bool, recursive bool, useG
158158
}
159159
}
160160

161-
if !skipGit && info.IsDir() && info.Name() == ".git" {
161+
if includeGit && info.IsDir() && info.Name() == ".git" {
162162
pkgs, err := scanGit(r, filepath.Dir(path)+"/")
163163
if err != nil {
164164
r.Infof("scan failed for git repository, %s: %v\n", path, err)
@@ -857,7 +857,7 @@ func DoScan(actions ScannerActions, r reporter.Reporter) (models.VulnerabilityRe
857857
}
858858

859859
if actions.CompareOffline {
860-
actions.SkipGit = true
860+
actions.IncludeGit = false
861861

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

933933
for _, dir := range actions.DirectoryPaths {
934934
r.Infof("Scanning dir %s\n", dir)
935-
pkgs, err := scanDir(r, dir, actions.SkipGit, actions.Recursive, !actions.NoIgnore, actions.CompareOffline, actions.TransitiveScanningActions)
935+
pkgs, err := scanDir(r, dir, actions.IncludeGit, actions.Recursive, !actions.NoIgnore, actions.CompareOffline, actions.TransitiveScanningActions)
936936
if err != nil {
937937
return models.VulnerabilityResults{}, err
938938
}

0 commit comments

Comments
 (0)