Skip to content

Commit 0047a16

Browse files
committed
internal/govulncheck: briefly explain streaming JSON
Fixes golang/go#65132 Change-Id: I627902b737d699f9d52060dcc56219a6f3104b22 Reviewed-on: https://go-review.googlesource.com/c/vuln/+/556116 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Maceo Thompson <maceothompson@google.com> Reviewed-by: Ian Cottrell <iancottrell@google.com>
1 parent 4b54a8b commit 0047a16

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

cmd/govulncheck/doc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ Govulncheck exits successfully (exit code 0) if there are no vulnerabilities,
5656
and exits unsuccessfully if there are. It also exits successfully if the -json flag
5757
is provided, regardless of the number of detected vulnerabilities.
5858
59+
Govulncheck supports streaming JSON. For more details, please see [golang.org/x/vuln/internal/govulncheck].
60+
5961
# Limitations
6062
6163
Govulncheck has these limitations:

internal/govulncheck/govulncheck.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@
33
// license that can be found in the LICENSE file.
44

55
// Package govulncheck contains the JSON output structs for govulncheck.
6+
//
7+
// govulncheck supports streaming JSON by emitting a series of Message
8+
// objects as it analyzes user code and discovers vulnerabilities.
9+
// Streaming JSON is useful for displaying progress in real-time for
10+
// large projects where govulncheck execution might take some time.
11+
//
12+
// govulncheck JSON emits configuration used to perform the analysis,
13+
// a user-friendly message about what is being analyzed, and the
14+
// vulnerability findings. Findings for the same vulnerability can
15+
// can be emitted several times. For instance, govulncheck JSON will
16+
// emit a finding when it sees that a vulnerable module is required
17+
// before proceeding to check if the vulnerability is imported or called.
18+
// Please see documentation on Message and related types for precise
19+
// details on the stream encoding.
20+
//
21+
// There are no guarantees on the order of messages. The pattern of emitted
22+
// messages can change in the future. Clients can follow code in handler.go
23+
// for consuming the streaming JSON programmatically.
624
package govulncheck
725

826
import (
@@ -106,8 +124,10 @@ type Finding struct {
106124
// In binary mode, trace will contain a single-frame with no position
107125
// information.
108126
//
109-
// When a package is imported but no vulnerable symbol is called, the trace
110-
// will contain a single-frame with no symbol or position information.
127+
// For module level source findings, the trace will contain a single-frame
128+
// with no symbol, position, or package information. For package level source
129+
// findings, the trace will contain a single-frame with no symbol or position
130+
// information.
111131
Trace []*Frame `json:"trace,omitempty"`
112132
}
113133

0 commit comments

Comments
 (0)