Skip to content

Commit 54eccb9

Browse files
authored
fix: make list-ecosystems flag actually useful again (#70)
1 parent 7fdb42c commit 54eccb9

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

README.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,18 @@ which can be useful for debugging issues and general exploring.
7474

7575
#### `--list-ecosystems`
7676

77-
Lists all the ecosystems that exist in the loaded OSV database. This can be
78-
useful when exploring new parsers, or building wrappers around the detector
79-
since a valid ecosystem is required to determine if a package has a
80-
vulnerability, and the ecosystem names are case-sensitive:
77+
Lists all the ecosystems that the detector knows about (aka there is a parser
78+
that results in packages from that ecosystem):
8179

8280
```
8381
$ osv-detector --list-ecosystems
84-
Loaded 6532 vulnerabilities (including withdrawn, last updated Fri, 04 Mar 2022 00:11:50 GMT)
85-
The loaded OSV has vulnerabilities for the following ecosystems:
86-
Packagist
87-
Go
82+
The detector supports parsing for the following ecosystems:
83+
npm
8884
crates.io
8985
RubyGems
90-
npm
86+
Packagist
87+
Go
9188
PyPI
92-
Maven
93-
NuGet
9489
```
9590

9691
#### `--list-packages`

main.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ func loadOSVDatabase(offline bool, archiveURL string) database.OSVDatabase {
3636
return *db
3737
}
3838

39-
func printEcosystems(db database.OSVDatabase) {
40-
ecosystems := db.ListEcosystems()
39+
func printKnownEcosystems() {
40+
ecosystems := lockfile.KnownEcosystems()
4141

42-
fmt.Println("The loaded OSV has vulnerabilities for the following ecosystems:")
42+
fmt.Println("The detector supports parsing for the following ecosystems:")
4343

4444
for _, ecosystem := range ecosystems {
4545
fmt.Printf(" %s\n", ecosystem)
@@ -135,6 +135,11 @@ func main() {
135135
os.Exit(0)
136136
}
137137

138+
if *listEcosystems {
139+
printKnownEcosystems()
140+
os.Exit(0)
141+
}
142+
138143
pathToLockOrDirectory := flag.Arg(0)
139144

140145
packages, err := lockfile.Parse(pathToLockOrDirectory, *parseAs)
@@ -151,13 +156,6 @@ func main() {
151156

152157
dbs := loadEcosystemDatabases(packages.Ecosystems(), *offline)
153158

154-
if *listEcosystems {
155-
for _, db := range dbs {
156-
printEcosystems(db)
157-
}
158-
os.Exit(0)
159-
}
160-
161159
file := path.Base(pathToLockOrDirectory)
162160

163161
knownVulnerabilitiesCount := 0

0 commit comments

Comments
 (0)