Skip to content

Commit fd2ef0f

Browse files
authored
feat: Make skip git the default behavior (#1584)
Also removes the `--json` flag since that has been deprecated for a while now. The json tests are not deleted, as there are the same tests with the `--format json` flag. Succeeds: #1311 Closes: #1277
1 parent f88dbb0 commit fd2ef0f

File tree

17 files changed

+35
-118
lines changed

17 files changed

+35
-118
lines changed

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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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/__snapshots__/main_test.snap

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ invalid verbosity level "unknown" - must be one of: error, warn, info, verbose
873873

874874
---
875875

876-
[TestRun/json_output_1 - 1]
876+
[TestRun/json_output - 1]
877877
{
878878
"results": [],
879879
"experimental_config": {
@@ -886,27 +886,7 @@ invalid verbosity level "unknown" - must be one of: error, warn, info, verbose
886886

887887
---
888888

889-
[TestRun/json_output_1 - 2]
890-
Scanning dir ./fixtures/locks-many/composer.lock
891-
Scanned <rootdir>/fixtures/locks-many/composer.lock file and found 1 package
892-
Loaded filter from: <rootdir>/fixtures/locks-many/osv-scanner.toml
893-
894-
---
895-
896-
[TestRun/json_output_2 - 1]
897-
{
898-
"results": [],
899-
"experimental_config": {
900-
"licenses": {
901-
"summary": false,
902-
"allowlist": null
903-
}
904-
}
905-
}
906-
907-
---
908-
909-
[TestRun/json_output_2 - 2]
889+
[TestRun/json_output - 2]
910890
Scanning dir ./fixtures/locks-many/composer.lock
911891
Scanned <rootdir>/fixtures/locks-many/composer.lock file and found 1 package
912892
Loaded filter from: <rootdir>/fixtures/locks-many/osv-scanner.toml
@@ -2633,48 +2613,6 @@ Loaded Packagist local db from <tempdir>/osv-scanner/Packagist/all.zip
26332613

26342614
---
26352615

2636-
[TestRun_LocalDatabases/output_with_json#01 - 1]
2637-
{
2638-
"results": [],
2639-
"experimental_config": {
2640-
"licenses": {
2641-
"summary": false,
2642-
"allowlist": null
2643-
}
2644-
}
2645-
}
2646-
2647-
---
2648-
2649-
[TestRun_LocalDatabases/output_with_json#01 - 2]
2650-
Scanning dir ./fixtures/locks-many/composer.lock
2651-
Scanned <rootdir>/fixtures/locks-many/composer.lock file and found 1 package
2652-
Loaded filter from: <rootdir>/fixtures/locks-many/osv-scanner.toml
2653-
Loaded Packagist local db from <tempdir>/osv-scanner/Packagist/all.zip
2654-
2655-
---
2656-
2657-
[TestRun_LocalDatabases/output_with_json#01 - 3]
2658-
{
2659-
"results": [],
2660-
"experimental_config": {
2661-
"licenses": {
2662-
"summary": false,
2663-
"allowlist": null
2664-
}
2665-
}
2666-
}
2667-
2668-
---
2669-
2670-
[TestRun_LocalDatabases/output_with_json#01 - 4]
2671-
Scanning dir ./fixtures/locks-many/composer.lock
2672-
Scanned <rootdir>/fixtures/locks-many/composer.lock file and found 1 package
2673-
Loaded filter from: <rootdir>/fixtures/locks-many/osv-scanner.toml
2674-
Loaded Packagist local db from <tempdir>/osv-scanner/Packagist/all.zip
2675-
2676-
---
2677-
26782616
[TestRun_LocalDatabases_AlwaysOffline/a_bunch_of_different_lockfiles_and_ecosystem - 1]
26792617
Scanning dir ./fixtures/locks-requirements
26802618
Scanned <rootdir>/fixtures/locks-requirements/my-requirements.txt file and found 1 package

cmd/osv-scanner/internal/helper/helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121

2222
// flags that require network access and values to disable them.
2323
var OfflineFlags = map[string]string{
24-
"skip-git": "true",
24+
"include-git-root": "true",
2525
"experimental-offline-vulnerabilities": "true",
2626
"experimental-no-resolve": "true",
2727
"experimental-licenses-summary": "false",

cmd/osv-scanner/main_test.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,8 @@ func TestRun(t *testing.T) {
244244
args: []string{"", "--recursive", "--no-ignore", "./fixtures/locks-gitignore"},
245245
exit: 0,
246246
},
247-
// output with json
248247
{
249-
name: "json output 1",
250-
args: []string{"", "--json", "./fixtures/locks-many/composer.lock"},
251-
exit: 0,
252-
},
253-
{
254-
name: "json output 2",
248+
name: "json output",
255249
args: []string{"", "--format", "json", "./fixtures/locks-many/composer.lock"},
256250
exit: 0,
257251
},
@@ -631,11 +625,6 @@ func TestRun_LocalDatabases(t *testing.T) {
631625
args: []string{"", "--experimental-offline", "--experimental-download-offline-databases", "--recursive", "--no-ignore", "./fixtures/locks-gitignore"},
632626
exit: 0,
633627
},
634-
{
635-
name: "output with json",
636-
args: []string{"", "--experimental-offline", "--experimental-download-offline-databases", "--json", "./fixtures/locks-many/composer.lock"},
637-
exit: 0,
638-
},
639628
{
640629
name: "output with json",
641630
args: []string{"", "--experimental-offline", "--experimental-download-offline-databases", "--format", "json", "./fixtures/locks-many/composer.lock"},

cmd/osv-scanner/scan/image/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func action(context *cli.Context, stdout, stderr io.Writer) (reporter.Reporter,
7676
Image: context.Args().First(),
7777
ConfigOverridePath: context.String("config"),
7878
IsImageArchive: context.Bool("archive"),
79-
SkipGit: context.Bool("skip-git"),
79+
IncludeGitRoot: context.Bool("include-git-root"),
8080
ExperimentalScannerActions: helper.GetExperimentalScannerActions(context, scanLicensesAllowlist),
8181
}
8282

cmd/osv-scanner/scan/source/main.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,6 @@ var projectScanFlags = []cli.Flag{
2727
Usage: "scan sbom file on this path",
2828
TakesFile: true,
2929
},
30-
&cli.BoolFlag{
31-
Name: "json",
32-
Usage: "sets output to json (deprecated, use --format json instead)",
33-
},
34-
&cli.BoolFlag{
35-
Name: "skip-git",
36-
Usage: "skip scanning git repositories",
37-
Value: false,
38-
},
3930
&cli.BoolFlag{
4031
Name: "recursive",
4132
Aliases: []string{"r"},
@@ -55,6 +46,11 @@ var projectScanFlags = []cli.Flag{
5546
Name: "no-call-analysis",
5647
Usage: "disables call graph analysis",
5748
},
49+
&cli.BoolFlag{
50+
Name: "include-git-root",
51+
Usage: "include scanning git root (non-submoduled) repositories",
52+
Value: false,
53+
},
5854
}
5955

6056
var projectScanExperimentalFlags = []cli.Flag{
@@ -106,10 +102,6 @@ func Command(stdout, stderr io.Writer, r *reporter.Reporter) *cli.Command {
106102
func Action(context *cli.Context, stdout, stderr io.Writer) (reporter.Reporter, error) {
107103
format := context.String("format")
108104

109-
if context.Bool("json") {
110-
format = "json"
111-
}
112-
113105
outputPath := context.String("output")
114106
serve := context.Bool("serve")
115107
if serve {
@@ -158,7 +150,7 @@ func Action(context *cli.Context, stdout, stderr io.Writer) (reporter.Reporter,
158150
LockfilePaths: context.StringSlice("lockfile"),
159151
SBOMPaths: context.StringSlice("sbom"),
160152
Recursive: context.Bool("recursive"),
161-
SkipGit: context.Bool("skip-git"),
153+
IncludeGitRoot: context.Bool("include-git-root"),
162154
NoIgnore: context.Bool("no-ignore"),
163155
ConfigOverridePath: context.String("config"),
164156
DirectoryPaths: context.Args().Slice(),

0 commit comments

Comments
 (0)