Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance v6 search command #2303

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/scripts/json-schema-drift-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -u

if [ "$(git status --porcelain | wc -l)" -ne "0" ]; then
echo " 🔴 there are uncommitted changes, please commit them before running this check"
exit 1
fi

if ! make generate-json-schema; then
echo "Generating json schema failed"
exit 1
fi

if [ "$(git status --porcelain | wc -l)" -ne "0" ]; then
echo " 🔴 there are uncommitted changes, please commit them before running this check"
exit 1
fi
16 changes: 15 additions & 1 deletion Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ tasks:
- task: check-go-mod-tidy
- task: check-licenses
- task: lint
- task: check-json-schema-drift
- task: validate-cyclonedx-schema
# TODO: while developing v6, we need to disable this check (since v5 and v6 are imported in the same codebase)
# - task: validate-grype-db-schema
Expand Down Expand Up @@ -171,6 +172,11 @@ tasks:
- cmd: .github/scripts/go-mod-tidy-check.sh && echo "go.mod and go.sum are tidy!"
silent: true

check-json-schema-drift:
desc: Ensure there is no drift between the JSON schema and the code
cmds:
- .github/scripts/json-schema-drift-check.sh

validate-cyclonedx-schema:
desc: Run integration tests
cmds:
Expand Down Expand Up @@ -313,9 +319,17 @@ tasks:
## Code and data generation targets #################################

generate:
desc: Run data generation tasks
desc: Run code and data generation tasks
cmds:
- task: generate-json-schema

generate-json-schema:
desc: Generate a new JSON schema
cmds:
# re-generate package metadata
- "cd grype/internal && go generate"
# generate the JSON schema for the CLI output
- "cd cmd/grype/cli/commands/internal/jsonschema && go run ."


## Build-related targets #################################
Expand Down
2 changes: 1 addition & 1 deletion cmd/grype/cli/commands/db_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func DBCheck(app clio.Application) *cobra.Command {

return app.SetupCommand(&cobra.Command{
Use: "check",
Short: "check to see if there is a database update available",
Short: "Check to see if there is a database update available",
PreRunE: func(cmd *cobra.Command, args []string) error {
// DB commands should not opt into the low-pass check filter
opts.DB.MaxUpdateCheckFrequency = 0
Expand Down
2 changes: 1 addition & 1 deletion cmd/grype/cli/commands/db_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func DBDelete(app clio.Application) *cobra.Command {

return app.SetupCommand(&cobra.Command{
Use: "delete",
Short: "delete the vulnerability database",
Short: "Delete the vulnerability database",
Args: cobra.ExactArgs(0),
PreRunE: disableUI(app),
RunE: func(_ *cobra.Command, _ []string) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/grype/cli/commands/db_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func DBDiff(app clio.Application) *cobra.Command {

return app.SetupCommand(&cobra.Command{
Use: "diff [flags] base_db_url target_db_url",
Short: "diff two DBs and display the result",
Short: "Diff two DBs and display the result",
Args: cobra.MaximumNArgs(2),
RunE: func(_ *cobra.Command, args []string) (err error) {
var base, target string
Expand Down
2 changes: 1 addition & 1 deletion cmd/grype/cli/commands/db_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func DBImport(app clio.Application) *cobra.Command {

return app.SetupCommand(&cobra.Command{
Use: "import FILE",
Short: "import a vulnerability database archive",
Short: "Import a vulnerability database archive",
Long: fmt.Sprintf("import a vulnerability database archive from a local FILE.\nDB archives can be obtained from %q.", internal.DBUpdateURL),
Args: cobra.ExactArgs(1),
RunE: func(_ *cobra.Command, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/grype/cli/commands/db_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func DBList(app clio.Application) *cobra.Command {

return app.SetupCommand(&cobra.Command{
Use: "list",
Short: "list all DBs available according to the listing URL",
Short: "List all DBs available according to the listing URL",
PreRunE: disableUI(app),
Args: cobra.ExactArgs(0),
RunE: func(_ *cobra.Command, _ []string) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/grype/cli/commands/db_providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func DBProviders(app clio.Application) *cobra.Command {

return app.SetupCommand(&cobra.Command{
Use: "providers",
Short: "list vulnerability database providers",
Short: "List vulnerability providers that are in the database",
Args: cobra.ExactArgs(0),
RunE: func(_ *cobra.Command, _ []string) error {
return runDBProviders(opts, app)
Expand Down
Loading
Loading