Skip to content

Commit 74eac76

Browse files
committed
refactors names
1 parent 86c9139 commit 74eac76

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+497
-693
lines changed

.github/workflows/build.yaml

Lines changed: 0 additions & 95 deletions
This file was deleted.

.github/workflows/on-tag.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
contents: read
1616
security-events: write
1717
with:
18-
go-version: ^1.20.1
18+
go-version: ^1.20.2
1919
scan-severity: 'CRITICAL,HIGH,MEDIUM'
2020

2121
release:

.github/workflows/sign.yaml

Lines changed: 0 additions & 87 deletions
This file was deleted.

.github/workflows/slsa.yaml

Lines changed: 0 additions & 87 deletions
This file was deleted.

.yamllint

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
ignore: |
22
/vendor
3-
/etc
43
.git
54

65
rules:

cmd/vulctl/main.go

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package main
22

33
import (
44
"flag"
5+
"fmt"
56
"os"
67

7-
"github.com/mchmarny/vulctl/pkg/types"
8-
"github.com/mchmarny/vulctl/pkg/vul"
8+
"github.com/mchmarny/vulctl/internal/processor"
99
"github.com/pkg/errors"
1010
"github.com/rs/zerolog"
1111
"github.com/rs/zerolog/log"
@@ -20,7 +20,7 @@ var (
2020
date = "unknown"
2121

2222
// flags
23-
digest = flag.String("digest", "", "digest of the source image")
23+
source = flag.String("source", "", "digest of the source image")
2424
file = flag.String("file", "", "path to vulnerability report file")
2525
format = flag.String("format", "", "scanner used to generate that file (e.g. grype, snyk, trivy)")
2626
output = flag.String("output", "", "path to write results to")
@@ -38,6 +38,8 @@ func main() {
3838
}
3939

4040
if err := execute(); err != nil {
41+
printVersion()
42+
printUsage()
4143
log.Error().Msg(err.Error())
4244
os.Exit(1)
4345
}
@@ -46,7 +48,24 @@ func main() {
4648
}
4749

4850
func printVersion() {
49-
log.Info().Str("version", version).Str("commit", commit).Str("date", date).Msg(name)
51+
fmt.Printf("%s - %s (commit: %s - build: %s)\n", name, version, commit, date)
52+
}
53+
54+
func printUsage() {
55+
fmt.Printf(`
56+
57+
usage:
58+
%s [flags]
59+
60+
flags:
61+
--source <digest> (required)
62+
--file <path> (required)
63+
--format <format> (required, e.g. grype, snyk, trivy)
64+
--output <path> (optional, defaults to stdout)
65+
--verbose (optional, prints debug logs, defaults to false)
66+
--version (optional, prints version and exits)
67+
68+
`, name)
5069
}
5170

5271
func initLogging(verbose *bool) {
@@ -68,23 +87,14 @@ func initLogging(verbose *bool) {
6887
}
6988

7089
func execute() error {
71-
f, err := types.ParseSourceFormat(*format)
72-
if err != nil {
73-
return errors.Wrap(err, "error parsing format")
74-
}
75-
76-
opt := &types.InputOptions{
77-
Source: *digest,
90+
opt := &processor.Options{
91+
Source: *source,
7892
File: *file,
93+
Format: *format,
7994
Output: output,
80-
Format: f,
81-
}
82-
83-
if err := opt.Validate(); err != nil {
84-
return errors.Wrap(err, "error validating input")
8595
}
8696

87-
if err := vul.Import(opt); err != nil {
97+
if err := processor.Process(opt); err != nil {
8898
return errors.Wrap(err, "error executing command")
8999
}
90100

0 commit comments

Comments
 (0)