diff --git a/cmd/govulncheck/testdata/convert_text.ct b/cmd/govulncheck/testdata/convert_text.ct index e12cbc25..5e4d460a 100644 --- a/cmd/govulncheck/testdata/convert_text.ct +++ b/cmd/govulncheck/testdata/convert_text.ct @@ -1,6 +1,6 @@ ##### # Test using the conversion from json on stdin to text on stdout -$ govulncheck -mode=convert < convert_input.json +$ govulncheck -mode=convert < convert_input.json --> FAIL 3 Scanning your code and P packages across M dependent modules for known vulnerabilities... Vulnerability #1: GO-2021-0265 diff --git a/internal/scan/run.go b/internal/scan/run.go index 83bc88d1..fa7fe37c 100644 --- a/internal/scan/run.go +++ b/internal/scan/run.go @@ -27,9 +27,6 @@ func RunGovulncheck(ctx context.Context, env []string, r io.Reader, stdout io.Wr if err := parseFlags(cfg, stderr, args); err != nil { return err } - if cfg.mode == modeConvert { - return convertJSONToText(r, stdout) - } client, err := client.NewClient(cfg.db, nil) if err != nil { @@ -60,6 +57,8 @@ func RunGovulncheck(ctx context.Context, env []string, r io.Reader, stdout io.Wr err = runBinary(ctx, handler, cfg, client) case modeQuery: err = runQuery(ctx, handler, cfg, client) + case modeConvert: + err = govulncheck.HandleJSON(r, handler) } if err != nil { return err @@ -132,14 +131,3 @@ func scannerVersion(cfg *config, bi *debug.BuildInfo) { } cfg.ScannerVersion = buf.String() } - -// convertJSONToText converts r, which is expected to be the JSON output of govulncheck, -// into the text output, and writes the output to w. -func convertJSONToText(r io.Reader, w io.Writer) error { - h := NewTextHandler(w) - if err := govulncheck.HandleJSON(r, h); err != nil { - return err - } - Flush(h) - return nil -}