From 4d281770f704706bee2013f657560d2aa2909fcd Mon Sep 17 00:00:00 2001 From: Julie Qiu Date: Mon, 11 Oct 2021 20:03:14 -0400 Subject: [PATCH] report: moved to internal/report Package report is moved to internal/report, since that package is only used by the vulndb module. Change-Id: I773f6e00f4d99327ba65a28f8ba7ba4ed24d5bd6 Reviewed-on: https://go-review.googlesource.com/c/vulndb/+/355269 Trust: Julie Qiu Run-TryBot: Julie Qiu Reviewed-by: Roland Shoemaker --- README.md | 1 - cmd/gendb/main.go | 2 +- cmd/genhtml/main.go | 2 +- cmd/linter/main.go | 2 +- cmd/report2cve/main.go | 13 +++---------- {report => internal/report}/lint.go | 0 {report => internal/report}/report.go | 2 ++ lint_test.go | 2 +- osv/json.go | 2 +- osv/json_test.go | 2 +- 10 files changed, 11 insertions(+), 17 deletions(-) rename {report => internal/report}/lint.go (100%) rename {report => internal/report}/report.go (95%) diff --git a/README.md b/README.md index 40e86794..0912efff 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,6 @@ approved proposal. Some of these packages can probably be coalesced, but for now are easier to work on in a more segmented fashion. -* `report` provides a package for parsing and linting YAML reports * `osv` provides a package for generating OSV-style JSON vulnerability entries from a `report.Report` * `client` contains a client for accessing HTTP/fs based vulnerability diff --git a/cmd/gendb/main.go b/cmd/gendb/main.go index 36c20c00..0d175a46 100644 --- a/cmd/gendb/main.go +++ b/cmd/gendb/main.go @@ -14,8 +14,8 @@ import ( "reflect" "strings" + "golang.org/x/vulndb/internal/report" "golang.org/x/vulndb/osv" - "golang.org/x/vulndb/report" "gopkg.in/yaml.v2" ) diff --git a/cmd/genhtml/main.go b/cmd/genhtml/main.go index c2c4ccc6..aa00048d 100644 --- a/cmd/genhtml/main.go +++ b/cmd/genhtml/main.go @@ -14,7 +14,7 @@ import ( "sort" "strings" - "golang.org/x/vulndb/report" + "golang.org/x/vulndb/internal/report" "gopkg.in/yaml.v2" ) diff --git a/cmd/linter/main.go b/cmd/linter/main.go index 09e019a1..803aee3e 100644 --- a/cmd/linter/main.go +++ b/cmd/linter/main.go @@ -9,7 +9,7 @@ import ( "io/ioutil" "os" - "golang.org/x/vulndb/report" + "golang.org/x/vulndb/internal/report" "gopkg.in/yaml.v2" ) diff --git a/cmd/report2cve/main.go b/cmd/report2cve/main.go index e4c89735..4f3f5889 100644 --- a/cmd/report2cve/main.go +++ b/cmd/report2cve/main.go @@ -7,13 +7,12 @@ package main import ( "encoding/json" "errors" - "flag" "fmt" "io/ioutil" "os" "strings" - "golang.org/x/vulndb/report" + "golang.org/x/vulndb/internal/report" "gopkg.in/yaml.v2" ) @@ -213,14 +212,8 @@ func versionToVersion(versions []report.VersionRange) VersionData { } func main() { - flag.Usage = func() { - fmt.Fprintf(flag.CommandLine.Output(), "usage: report2cve GO-YYYY-NNNN.yaml\n") - fmt.Fprintf(flag.CommandLine.Output(), " Create a CVE report from a file with the name structure GO-YYYY-NNNN.yaml in the reports/ directory.\n") - flag.PrintDefaults() - } - flag.Parse() - if flag.NArg() != 2 { - flag.Usage() + if len(os.Args) != 2 { + fmt.Fprint(os.Stderr, "usage: report2cve report.yaml") os.Exit(1) } diff --git a/report/lint.go b/internal/report/lint.go similarity index 100% rename from report/lint.go rename to internal/report/lint.go diff --git a/report/report.go b/internal/report/report.go similarity index 95% rename from report/report.go rename to internal/report/report.go index a400a005..2c21af9f 100644 --- a/report/report.go +++ b/internal/report/report.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// Package report contains functionality for parsing and linting YAML reports +// in reports/. package report import "time" diff --git a/lint_test.go b/lint_test.go index 10460ebc..4a4d217e 100644 --- a/lint_test.go +++ b/lint_test.go @@ -11,7 +11,7 @@ import ( "strings" "testing" - "golang.org/x/vulndb/report" + "golang.org/x/vulndb/internal/report" "gopkg.in/yaml.v2" ) diff --git a/osv/json.go b/osv/json.go index fa7e5bd8..55779371 100644 --- a/osv/json.go +++ b/osv/json.go @@ -16,7 +16,7 @@ import ( "time" "golang.org/x/mod/semver" - "golang.org/x/vulndb/report" + "golang.org/x/vulndb/internal/report" ) // DBIndex contains a mapping of vulnerable packages to the diff --git a/osv/json_test.go b/osv/json_test.go index d55d5ca0..9ef2a050 100644 --- a/osv/json_test.go +++ b/osv/json_test.go @@ -11,7 +11,7 @@ import ( "time" "github.com/google/go-cmp/cmp" - "golang.org/x/vulndb/report" + "golang.org/x/vulndb/internal/report" ) func TestGenerate(t *testing.T) {