mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-11-25 06:35:21 +00:00
fix(govulncheck): scan the module as a dependency and read the stream
govulncheck prints indented JSON objects. The line parser read none of them, so every module read clean. govulncheck also never reports advisories against the main module of the tree it scans. A scan of the x/text 0.3.5 source found nothing. The module is now a dependency of a wrapper module that imports its packages, and the scan runs at module level.
This commit is contained in:
@@ -3,17 +3,24 @@
|
||||
package govulncheck
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/lukaszraczylo/gohoarder/pkg/config"
|
||||
"github.com/lukaszraczylo/gohoarder/pkg/metadata"
|
||||
"github.com/lukaszraczylo/gohoarder/pkg/scanner/gomodule"
|
||||
"github.com/lukaszraczylo/gohoarder/pkg/scanner/scanerr"
|
||||
"github.com/lukaszraczylo/gohoarder/pkg/uuid"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
@@ -64,62 +71,67 @@ func (s *Scanner) Scan(ctx context.Context, registry, packageName, version strin
|
||||
Str("version", version).
|
||||
Msg("Starting govulncheck scan")
|
||||
|
||||
// Create a temporary directory for extraction
|
||||
module := gomodule.Path(packageName)
|
||||
if !validModule.MatchString(module) || !validVersion.MatchString(version) {
|
||||
return s.errorResult(ctx, registry, packageName, version,
|
||||
fmt.Sprintf("not a module path and version: %q %q", module, version), ""), nil
|
||||
}
|
||||
|
||||
tmpDir, err := os.MkdirTemp("", "govulncheck-*")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create temp dir: %w", err)
|
||||
}
|
||||
defer func() { _ = os.RemoveAll(tmpDir) }()
|
||||
|
||||
// Extract the .zip file
|
||||
if extractErr := s.extractZip(filePath, tmpDir); extractErr != nil {
|
||||
return nil, fmt.Errorf("failed to extract zip: %w", extractErr)
|
||||
// govulncheck never reports advisories against the main module of the tree it scans, so
|
||||
// scanning the module's own source reports a vulnerable module clean. The module is
|
||||
// scanned as a dependency of a wrapper module instead, and the wrapper imports its
|
||||
// packages because module-mode scanning only considers modules that provide an import.
|
||||
// Resolving the module reaches the module proxy.
|
||||
env := append(os.Environ(), "GOFLAGS=-mod=mod", "GOTOOLCHAIN=local", "GOWORK=off")
|
||||
goMod := fmt.Sprintf("module gohoarder.audit\n\nrequire %s %s\n", module, version)
|
||||
if err = os.WriteFile(filepath.Join(tmpDir, "go.mod"), []byte(goMod), 0o600); err != nil {
|
||||
return nil, fmt.Errorf("failed to write go.mod: %w", err)
|
||||
}
|
||||
|
||||
// Locate the Go module root (directory containing go.mod). Go modules
|
||||
// in the proxy zip layout are nested under <module>@<version>/.
|
||||
moduleDir, err := findGoModDir(tmpDir)
|
||||
listCmd := exec.CommandContext(ctx, "go", "list", "-e", "-f", listFormat, module+"/...") // #nosec G204 -- module path is validated
|
||||
listCmd.Dir = tmpDir
|
||||
listCmd.Env = env
|
||||
var listErr bytes.Buffer
|
||||
listCmd.Stderr = &listErr
|
||||
listOut, err := listCmd.Output()
|
||||
if err != nil {
|
||||
log.Warn().
|
||||
Err(err).
|
||||
Str("package", packageName).
|
||||
Str("version", version).
|
||||
Msg("Could not locate go.mod in extracted module, skipping govulncheck")
|
||||
return s.skippedResult(registry, packageName, version, "no go.mod in extracted module"), nil
|
||||
return s.errorResult(ctx, registry, packageName, version,
|
||||
fmt.Sprintf("go list failed: %v: %s", err, strings.TrimSpace(listErr.String())), listErr.String()), nil
|
||||
}
|
||||
|
||||
// Run govulncheck in source mode against the module's package set.
|
||||
// -mode=binary requires a compiled binary which we do not have; the
|
||||
// default (source) mode wants a Go source tree with a go.mod.
|
||||
cmd := exec.CommandContext(ctx, "govulncheck", "-json", "./...") // #nosec G204 -- fixed args, cwd is controlled temp dir
|
||||
cmd.Dir = moduleDir
|
||||
output, _ := cmd.CombinedOutput()
|
||||
imports := importable(string(listOut))
|
||||
if len(imports) == 0 {
|
||||
return s.skippedResult(registry, packageName, version, "no importable package in module"), nil
|
||||
}
|
||||
var mainSrc strings.Builder
|
||||
mainSrc.WriteString("package main\n\nimport (\n")
|
||||
for _, pkg := range imports {
|
||||
fmt.Fprintf(&mainSrc, "\t_ %q\n", pkg)
|
||||
}
|
||||
mainSrc.WriteString(")\n\nfunc main() {}\n")
|
||||
if err = os.WriteFile(filepath.Join(tmpDir, "main.go"), []byte(mainSrc.String()), 0o600); err != nil {
|
||||
return nil, fmt.Errorf("failed to write main.go: %w", err)
|
||||
}
|
||||
|
||||
// govulncheck returns non-zero when vulnerabilities are found
|
||||
// Parse output regardless of error
|
||||
var vulns []GovulncheckVuln
|
||||
if len(output) > 0 {
|
||||
// Parse line-delimited JSON
|
||||
lines := strings.Split(string(output), "\n")
|
||||
for _, line := range lines {
|
||||
if strings.TrimSpace(line) == "" {
|
||||
continue
|
||||
}
|
||||
var entry GovulncheckEntry
|
||||
if err := json.Unmarshal([]byte(line), &entry); err != nil {
|
||||
log.Warn().Err(err).Str("line", line).Msg("Failed to parse govulncheck line")
|
||||
continue
|
||||
}
|
||||
if entry.Finding != nil && entry.Finding.OSV != "" {
|
||||
vulns = append(vulns, GovulncheckVuln{
|
||||
OSV: entry.Finding.OSV,
|
||||
FixedVersion: entry.Finding.FixedVersion,
|
||||
})
|
||||
}
|
||||
}
|
||||
cmd := exec.CommandContext(ctx, "govulncheck", "-json", "-scan", "module") // #nosec G204 -- fixed args, cwd is controlled temp dir
|
||||
cmd.Dir = tmpDir
|
||||
cmd.Env = env
|
||||
var stderr bytes.Buffer
|
||||
cmd.Stderr = &stderr
|
||||
output, _ := cmd.Output() // govulncheck -json exits 0 whether or not it finds anything
|
||||
|
||||
vulns, err := parseFindings(output)
|
||||
if err != nil {
|
||||
return s.errorResult(ctx, registry, packageName, version,
|
||||
fmt.Sprintf("govulncheck failed: %v: %s", err, strings.TrimSpace(stderr.String())), stderr.String()), nil
|
||||
}
|
||||
|
||||
// Convert to our format
|
||||
result := s.convertResult(vulns, registry, packageName, version)
|
||||
|
||||
log.Info().
|
||||
@@ -131,6 +143,76 @@ func (s *Scanner) Scan(ctx context.Context, registry, packageName, version strin
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// listFormat prints "import-path name go-files cgo-files [ERR]" per package.
|
||||
const listFormat = "{{.ImportPath}} {{.Name}} {{len .GoFiles}} {{len .CgoFiles}} {{if .Error}}ERR{{end}}"
|
||||
|
||||
var (
|
||||
validModule = regexp.MustCompile(`^[A-Za-z0-9._~/-]+$`)
|
||||
validVersion = regexp.MustCompile(`^v[0-9A-Za-z.+_-]+$`)
|
||||
)
|
||||
|
||||
// importable lists the packages of `go list` output that another module can import.
|
||||
func importable(listOut string) []string {
|
||||
var pkgs []string
|
||||
for _, line := range strings.Split(listOut, "\n") {
|
||||
f := strings.Fields(line)
|
||||
if len(f) < 4 || f[1] == "main" || (len(f) > 4 && f[4] == "ERR") {
|
||||
continue
|
||||
}
|
||||
if f[2] == "0" && f[3] == "0" {
|
||||
continue
|
||||
}
|
||||
if hasPathElement(f[0], "internal") || hasPathElement(f[0], "testdata") || hasPathElement(f[0], "vendor") {
|
||||
continue
|
||||
}
|
||||
pkgs = append(pkgs, f[0])
|
||||
}
|
||||
return pkgs
|
||||
}
|
||||
|
||||
func hasPathElement(importPath, element string) bool {
|
||||
return slices.Contains(strings.Split(importPath, "/"), element)
|
||||
}
|
||||
|
||||
// parseFindings reads govulncheck's stream of JSON messages. An output without the config
|
||||
// message did not come from a completed run.
|
||||
func parseFindings(output []byte) ([]GovulncheckVuln, error) {
|
||||
summaries := make(map[string]string)
|
||||
var vulns []GovulncheckVuln
|
||||
seen := make(map[string]bool)
|
||||
sawConfig := false
|
||||
dec := json.NewDecoder(bytes.NewReader(output))
|
||||
for {
|
||||
var msg GovulncheckEntry
|
||||
if err := dec.Decode(&msg); err == io.EOF {
|
||||
break
|
||||
} else if err != nil {
|
||||
return nil, fmt.Errorf("parse govulncheck output: %w", err)
|
||||
}
|
||||
switch {
|
||||
case msg.Config != nil:
|
||||
sawConfig = true
|
||||
case msg.OSV != nil:
|
||||
summaries[msg.OSV.ID] = msg.OSV.Summary
|
||||
case msg.Finding != nil && msg.Finding.OSV != "" && !seen[msg.Finding.OSV]:
|
||||
seen[msg.Finding.OSV] = true
|
||||
v := GovulncheckVuln{OSV: msg.Finding.OSV, FixedVersion: msg.Finding.FixedVersion}
|
||||
if len(msg.Finding.Trace) > 0 {
|
||||
v.Module = msg.Finding.Trace[0].Module
|
||||
v.ModuleVersion = msg.Finding.Trace[0].Version
|
||||
}
|
||||
vulns = append(vulns, v)
|
||||
}
|
||||
}
|
||||
if !sawConfig {
|
||||
return nil, errors.New("no config message in output")
|
||||
}
|
||||
for i := range vulns {
|
||||
vulns[i].Summary = summaries[vulns[i].OSV]
|
||||
}
|
||||
return vulns, nil
|
||||
}
|
||||
|
||||
// Health checks if govulncheck is available
|
||||
func (s *Scanner) Health(ctx context.Context) error {
|
||||
cmd := exec.CommandContext(ctx, "govulncheck", "-version")
|
||||
@@ -140,48 +222,26 @@ func (s *Scanner) Health(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// extractZip extracts a zip file to destination
|
||||
func (s *Scanner) extractZip(zipPath, destDir string) error {
|
||||
cmd := exec.Command("unzip", "-q", zipPath, "-d", destDir)
|
||||
return cmd.Run()
|
||||
// errorResult returns a scan-error result. The manager leaves it out of the merge and counts it as
|
||||
// an infrastructure failure when the context ended or the tool output shows the network was unreachable.
|
||||
func (s *Scanner) errorResult(ctx context.Context, registry, packageName, version, reason, toolOutput string) *metadata.ScanResult {
|
||||
infra := ctx.Err() != nil || scanerr.NetworkFailure(toolOutput)
|
||||
return &metadata.ScanResult{
|
||||
ID: uuid.New().String(),
|
||||
Registry: registry,
|
||||
PackageName: packageName,
|
||||
PackageVersion: version,
|
||||
Scanner: ScannerName,
|
||||
ScannedAt: time.Now(),
|
||||
Status: metadata.ScanStatusError,
|
||||
VulnerabilityCount: 0,
|
||||
Vulnerabilities: []metadata.Vulnerability{},
|
||||
Details: scanerr.ErrorDetails(reason, infra),
|
||||
}
|
||||
}
|
||||
|
||||
// findGoModDir walks the directory tree under root looking for a directory
|
||||
// that contains a go.mod file. The Go module proxy ships zips with layout
|
||||
// "<module>@<version>/...", so the module root is typically one or two
|
||||
// levels below the extraction directory. Returns an error if none is found.
|
||||
func findGoModDir(root string) (string, error) {
|
||||
// Quick check: does the root itself contain go.mod?
|
||||
if _, err := os.Stat(filepath.Join(root, "go.mod")); err == nil {
|
||||
return root, nil
|
||||
}
|
||||
|
||||
var found string
|
||||
err := filepath.WalkDir(root, func(path string, d os.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return nil // keep searching
|
||||
}
|
||||
if d.IsDir() {
|
||||
return nil
|
||||
}
|
||||
if d.Name() == "go.mod" {
|
||||
found = filepath.Dir(path)
|
||||
return filepath.SkipAll
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if found == "" {
|
||||
return "", fmt.Errorf("go.mod not found under %s", root)
|
||||
}
|
||||
return found, nil
|
||||
}
|
||||
|
||||
// skippedResult returns a clean ScanResult marked as skipped with an
|
||||
// explanation. Using clean (not error) here because the package is simply
|
||||
// not a Go module we can analyse — not a scanner failure.
|
||||
// skippedResult returns a clean ScanResult marked as skipped with an explanation: the module has
|
||||
// nothing another module can import, so there is nothing to audit.
|
||||
func (s *Scanner) skippedResult(registry, packageName, version, reason string) *metadata.ScanResult {
|
||||
return &metadata.ScanResult{
|
||||
ID: uuid.New().String(),
|
||||
@@ -221,7 +281,7 @@ func (s *Scanner) convertResult(vulns []GovulncheckVuln, registry, packageName,
|
||||
ID: vuln.OSV,
|
||||
Severity: severity,
|
||||
Title: vuln.OSV,
|
||||
Description: fmt.Sprintf("Vulnerability %s found by govulncheck", vuln.OSV),
|
||||
Description: describe(vuln),
|
||||
References: []string{fmt.Sprintf("https://pkg.go.dev/vuln/%s", vuln.OSV)},
|
||||
FixedIn: vuln.FixedVersion,
|
||||
})
|
||||
@@ -249,17 +309,46 @@ func (s *Scanner) convertResult(vulns []GovulncheckVuln, registry, packageName,
|
||||
}
|
||||
}
|
||||
|
||||
// GovulncheckEntry represents a single line of govulncheck JSON output
|
||||
func describe(v GovulncheckVuln) string {
|
||||
desc := v.Summary
|
||||
if desc == "" {
|
||||
desc = "Vulnerability " + v.OSV
|
||||
}
|
||||
if v.Module != "" {
|
||||
desc += fmt.Sprintf(" (%s@%s)", v.Module, v.ModuleVersion)
|
||||
}
|
||||
return desc
|
||||
}
|
||||
|
||||
// GovulncheckEntry is one message of govulncheck's JSON stream; exactly one field is set.
|
||||
type GovulncheckEntry struct {
|
||||
Config *struct{} `json:"config,omitempty"`
|
||||
OSV *GovulncheckOSV `json:"osv,omitempty"`
|
||||
Finding *GovulncheckFinding `json:"finding,omitempty"`
|
||||
}
|
||||
|
||||
// GovulncheckOSV is the advisory a finding refers to.
|
||||
type GovulncheckOSV struct {
|
||||
ID string `json:"id"`
|
||||
Summary string `json:"summary"`
|
||||
}
|
||||
|
||||
type GovulncheckFinding struct {
|
||||
OSV string `json:"osv"`
|
||||
FixedVersion string `json:"fixed_version,omitempty"`
|
||||
OSV string `json:"osv"`
|
||||
FixedVersion string `json:"fixed_version,omitempty"`
|
||||
Trace []GovulncheckModule `json:"trace"`
|
||||
}
|
||||
|
||||
// GovulncheckModule is the module a finding is in.
|
||||
type GovulncheckModule struct {
|
||||
Module string `json:"module"`
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
type GovulncheckVuln struct {
|
||||
OSV string
|
||||
FixedVersion string
|
||||
OSV string
|
||||
FixedVersion string
|
||||
Module string
|
||||
ModuleVersion string
|
||||
Summary string
|
||||
}
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
package govulncheck
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/lukaszraczylo/gohoarder/pkg/config"
|
||||
"github.com/lukaszraczylo/gohoarder/pkg/metadata"
|
||||
"github.com/lukaszraczylo/gohoarder/pkg/scanner/scanerr"
|
||||
"github.com/lukaszraczylo/gohoarder/pkg/scanner/scannertest"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// The .stream fixtures are real govulncheck 1.9.0 `-json` output, cut down to the config, finding and
|
||||
// referenced osv messages, and real `go list` output (see FINDINGS GH-25).
|
||||
func abs(t *testing.T, name string) string {
|
||||
t.Helper()
|
||||
p, err := filepath.Abs(filepath.Join("testdata", name))
|
||||
require.NoError(t, err)
|
||||
return p
|
||||
}
|
||||
|
||||
// module is a zip as the module proxy serves it; the scanner audits the module by path and version.
|
||||
func module(t *testing.T) string {
|
||||
t.Helper()
|
||||
p := filepath.Join(t.TempDir(), "m.zip")
|
||||
f, err := os.Create(p) // #nosec G304 -- test temp dir
|
||||
require.NoError(t, err)
|
||||
zw := zip.NewWriter(f)
|
||||
w, err := zw.Create("example.com/[email protected]/go.mod")
|
||||
require.NoError(t, err)
|
||||
_, err = w.Write([]byte("module example.com/m\n"))
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, zw.Close())
|
||||
require.NoError(t, f.Close())
|
||||
return p
|
||||
}
|
||||
|
||||
// fakeGo fakes `go list`, recording the working directory's go.mod and main.go for the audit.
|
||||
func fakeGo(t *testing.T, listFixture string, exit int, stderr string) (rec string) {
|
||||
t.Helper()
|
||||
rec = t.TempDir()
|
||||
body := fmt.Sprintf(`
|
||||
case "$1" in
|
||||
list) cp go.mod %[1]q/go.mod; echo "$GOFLAGS|$GOTOOLCHAIN" > %[1]q/env; %[2]s; printf '%%s' %[3]q >&2; exit %[4]d ;;
|
||||
esac`, rec, catOrNothing(listFixture), stderr, exit)
|
||||
scannertest.Script(t, "go", body)
|
||||
return rec
|
||||
}
|
||||
|
||||
func catOrNothing(path string) string {
|
||||
if path == "" {
|
||||
return "true"
|
||||
}
|
||||
return "cat " + fmt.Sprintf("%q", path)
|
||||
}
|
||||
|
||||
// fakeGovulncheck fakes govulncheck: it records main.go and the arguments, prints fixture.
|
||||
func fakeGovulncheck(t *testing.T, fixture string, exit int, stderr string) (argsFile, mainCopy string) {
|
||||
t.Helper()
|
||||
dir := t.TempDir()
|
||||
argsFile = filepath.Join(dir, "args")
|
||||
mainCopy = filepath.Join(dir, "main.go")
|
||||
scannertest.Script(t, "govulncheck", fmt.Sprintf(`
|
||||
cp main.go %[2]q
|
||||
for a in "$@"; do echo "$a" >> %[1]q; done
|
||||
%[3]s
|
||||
printf '%%s' %[4]q >&2
|
||||
exit %[5]d`, argsFile, mainCopy, catOrNothing(fixture), stderr, exit))
|
||||
return argsFile, mainCopy
|
||||
}
|
||||
|
||||
func ids(res *metadata.ScanResult) map[string]string {
|
||||
out := map[string]string{}
|
||||
for _, v := range res.Vulnerabilities {
|
||||
out[v.ID] = v.FixedIn
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func TestScanReadsPrettyPrintedFindings(t *testing.T) {
|
||||
// govulncheck -json prints indented objects, not one object per line.
|
||||
fakeGo(t, abs(t, "golist-gin-v1.6.0.txt"), 0, "")
|
||||
fakeGovulncheck(t, abs(t, "gin-v1.6.0-source-scan.stream"), 0, "")
|
||||
|
||||
res, err := New(config.GovulncheckConfig{}).Scan(context.Background(), "go", "github.com/gin-gonic/gin/@v/v1.6.0.zip", "v1.6.0", module(t))
|
||||
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, metadata.ScanStatusVulnerable, res.Status)
|
||||
assert.Equal(t, map[string]string{
|
||||
"GO-2022-0493": "v0.0.0-20220412211240-33da011f77ad",
|
||||
"GO-2026-5024": "v0.44.0",
|
||||
}, ids(res), "one entry per advisory, with the fixed version")
|
||||
}
|
||||
|
||||
func TestScanAuditsTheModuleItself(t *testing.T) {
|
||||
rec := fakeGo(t, abs(t, "golist-x-text-v0.3.5.txt"), 0, "")
|
||||
args, mainCopy := fakeGovulncheck(t, abs(t, "x-text-v0.3.5.stream"), 0, "")
|
||||
|
||||
res, err := New(config.GovulncheckConfig{}).Scan(context.Background(), "go", "golang.org/x/text/@v/v0.3.5.zip", "v0.3.5", module(t))
|
||||
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, metadata.ScanStatusVulnerable, res.Status)
|
||||
assert.Equal(t, map[string]string{
|
||||
"GO-2021-0113": "v0.3.7", "GO-2022-1059": "v0.3.8", "GO-2026-5970": "v0.39.0", "GO-2026-6629": "v0.41.0",
|
||||
}, ids(res), "advisories against the scanned module, which a scan of its own source never reports")
|
||||
for _, v := range res.Vulnerabilities {
|
||||
assert.Equal(t, "HIGH", v.Severity)
|
||||
assert.Equal(t, []string{"https://pkg.go.dev/vuln/" + v.ID}, v.References)
|
||||
}
|
||||
|
||||
gomod, err := os.ReadFile(filepath.Join(rec, "go.mod")) // #nosec G304 -- test temp dir
|
||||
require.NoError(t, err)
|
||||
assert.Contains(t, string(gomod), "require golang.org/x/text v0.3.5")
|
||||
|
||||
env, err := os.ReadFile(filepath.Join(rec, "env")) // #nosec G304 -- test temp dir
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "-mod=mod|local\n", string(env))
|
||||
|
||||
assert.Equal(t, []string{"-json", "-scan", "module"}, scannertest.Args(t, args))
|
||||
|
||||
src, err := os.ReadFile(mainCopy) // #nosec G304 -- test temp dir
|
||||
require.NoError(t, err)
|
||||
imports := string(src)
|
||||
assert.Contains(t, imports, `_ "golang.org/x/text/language"`)
|
||||
assert.NotContains(t, imports, "/cmd/gotext\"", "package main cannot be imported")
|
||||
assert.NotContains(t, imports, "/internal", "internal packages cannot be imported")
|
||||
}
|
||||
|
||||
func TestScanCleanModule(t *testing.T) {
|
||||
scannertest.Script(t, "go", `echo "github.com/google/uuid uuid 12 0 "`)
|
||||
_, _ = fakeGovulncheck(t, abs(t, "google-uuid-v1.6.0.stream"), 0, "")
|
||||
|
||||
res, err := New(config.GovulncheckConfig{}).Scan(context.Background(), "go", "github.com/google/uuid/@v/v1.6.0.zip", "v1.6.0", module(t))
|
||||
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, metadata.ScanStatusClean, res.Status)
|
||||
}
|
||||
|
||||
func TestScanModuleWithoutImportablePackagesIsSkipped(t *testing.T) {
|
||||
scannertest.Script(t, "go", `echo "example.com/m/cmd/tool main 1 0 "`)
|
||||
|
||||
res, err := New(config.GovulncheckConfig{}).Scan(context.Background(), "go", "example.com/m/@v/v1.0.0.zip", "v1.0.0", module(t))
|
||||
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, metadata.ScanStatusClean, res.Status)
|
||||
assert.Contains(t, res.Details["skipped"], "no importable package")
|
||||
}
|
||||
|
||||
func TestScanFailuresAreErrorResultsWithACause(t *testing.T) {
|
||||
cases := []struct {
|
||||
setup func(t *testing.T)
|
||||
name string
|
||||
infra bool
|
||||
}{
|
||||
{name: "module download fails on the network", setup: func(t *testing.T) { fakeGo(t, "", 1, "dial tcp: lookup proxy.golang.org: no such host") }, infra: true},
|
||||
{name: "module is not in the proxy", setup: func(t *testing.T) { fakeGo(t, "", 1, "reading example.com/m/@v/v1.0.0.mod: 404 Not Found") }, infra: false},
|
||||
{name: "govulncheck prints nothing", setup: func(t *testing.T) {
|
||||
fakeGo(t, abs(t, "golist-gin-v1.6.0.txt"), 0, "")
|
||||
fakeGovulncheck(t, "", 1, "govulncheck: loading packages: boom")
|
||||
}, infra: false},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
tc.setup(t)
|
||||
|
||||
res, err := New(config.GovulncheckConfig{}).Scan(context.Background(), "go", "example.com/m/@v/v1.0.0.zip", "v1.0.0", module(t))
|
||||
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, metadata.ScanStatusError, res.Status)
|
||||
assert.Equal(t, tc.infra, res.Details[scanerr.DetailInfrastructure])
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestScanRefusesModuleCoordinatesThatCouldInjectGoMod(t *testing.T) {
|
||||
fakeGo(t, abs(t, "golist-gin-v1.6.0.txt"), 0, "")
|
||||
|
||||
res, err := New(config.GovulncheckConfig{}).Scan(context.Background(), "go", "example.com/m/@v/v1.0.0\nreplace x => y.zip", "v1.0.0\nreplace a => b", module(t))
|
||||
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, metadata.ScanStatusError, res.Status)
|
||||
}
|
||||
|
||||
func TestScanSkipsOtherRegistries(t *testing.T) {
|
||||
res, err := New(config.GovulncheckConfig{}).Scan(context.Background(), "npm", "p", "1", "/x")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, metadata.ScanStatusClean, res.Status)
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
{
|
||||
"config": {
|
||||
"protocol_version": "v1.0.0",
|
||||
"scanner_name": "govulncheck",
|
||||
"scanner_version": "v1.9.0",
|
||||
"db": "https://vuln.go.dev",
|
||||
"db_last_modified": "2026-11-11T02:51:11Z",
|
||||
"go_version": "go1.26.11",
|
||||
"scan_level": "symbol",
|
||||
"scan_mode": "source"
|
||||
}
|
||||
}
|
||||
{
|
||||
"progress": {
|
||||
"message": "Fetching vulnerabilities from the database..."
|
||||
}
|
||||
}
|
||||
{
|
||||
"osv": {
|
||||
"schema_version": "1.3.1",
|
||||
"id": "GO-2022-0493",
|
||||
"modified": "2024-05-20T16:03:47Z",
|
||||
"published": "2022-07-15T23:30:12Z",
|
||||
"aliases": [
|
||||
"CVE-2022-29526",
|
||||
"GHSA-p782-xgp4-8hr8"
|
||||
],
|
||||
"summary": "Incorrect privilege reporting in syscall and golang.org/x/sys/unix",
|
||||
"details": "When called with a non-zero flags parameter, the Faccessat function can incorrectly report that a file is accessible.",
|
||||
"affected": [
|
||||
{
|
||||
"package": {
|
||||
"name": "stdlib",
|
||||
"ecosystem": "Go"
|
||||
},
|
||||
"ranges": [
|
||||
{
|
||||
"type": "SEMVER",
|
||||
"events": [
|
||||
{
|
||||
"introduced": "0"
|
||||
},
|
||||
{
|
||||
"fixed": "1.17.10"
|
||||
},
|
||||
{
|
||||
"introduced": "1.18.0-0"
|
||||
},
|
||||
{
|
||||
"fixed": "1.18.2"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"ecosystem_specific": {
|
||||
"imports": [
|
||||
{
|
||||
"path": "syscall",
|
||||
"symbols": [
|
||||
"Faccessat"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": {
|
||||
"name": "golang.org/x/sys",
|
||||
"ecosystem": "Go"
|
||||
},
|
||||
"ranges": [
|
||||
{
|
||||
"type": "SEMVER",
|
||||
"events": [
|
||||
{
|
||||
"introduced": "0"
|
||||
},
|
||||
{
|
||||
"fixed": "0.0.0-20220412211240-33da011f77ad"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"ecosystem_specific": {
|
||||
"imports": [
|
||||
{
|
||||
"path": "golang.org/x/sys/unix",
|
||||
"symbols": [
|
||||
"Faccessat"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://go.dev/cl/399539"
|
||||
},
|
||||
{
|
||||
"type": "REPORT",
|
||||
"url": "https://go.dev/issue/52313"
|
||||
},
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://go.dev/cl/400074"
|
||||
},
|
||||
{
|
||||
"type": "WEB",
|
||||
"url": "https://groups.google.com/g/golang-announce/c/Y5qrqw_lWdU"
|
||||
}
|
||||
],
|
||||
"credits": [
|
||||
{
|
||||
"name": "Jo\u00ebl G\u00e4hwiler (@256dpi)"
|
||||
}
|
||||
],
|
||||
"database_specific": {
|
||||
"url": "https://pkg.go.dev/vuln/GO-2022-0493",
|
||||
"review_status": "REVIEWED"
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
"osv": {
|
||||
"schema_version": "1.3.1",
|
||||
"id": "GO-2026-5024",
|
||||
"modified": "2026-05-22T18:28:47Z",
|
||||
"published": "2026-05-22T18:28:47Z",
|
||||
"aliases": [
|
||||
"CVE-2026-39824"
|
||||
],
|
||||
"summary": "Invoking integer overflow in NewNTUnicodeString in golang.org/x/sys/windows",
|
||||
"details": "NewNTUnicodeString does not check for string length overflow. When provided with a string that overflows the maximum size of a NTUnicodeString (a 16-bit number of bytes), it returns a truncated string rather than an error.",
|
||||
"affected": [
|
||||
{
|
||||
"package": {
|
||||
"name": "golang.org/x/sys",
|
||||
"ecosystem": "Go"
|
||||
},
|
||||
"ranges": [
|
||||
{
|
||||
"type": "SEMVER",
|
||||
"events": [
|
||||
{
|
||||
"introduced": "0"
|
||||
},
|
||||
{
|
||||
"fixed": "0.44.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"ecosystem_specific": {
|
||||
"imports": [
|
||||
{
|
||||
"path": "golang.org/x/sys/windows",
|
||||
"goos": [
|
||||
"windows"
|
||||
],
|
||||
"symbols": [
|
||||
"NewNTUnicodeString"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"type": "REPORT",
|
||||
"url": "https://go.dev/issue/78916"
|
||||
},
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://go.dev/cl/770080"
|
||||
},
|
||||
{
|
||||
"type": "WEB",
|
||||
"url": "https://groups.google.com/g/golang-announce/c/6MMI8Lj-Atg"
|
||||
}
|
||||
],
|
||||
"database_specific": {
|
||||
"url": "https://pkg.go.dev/vuln/GO-2026-5024",
|
||||
"review_status": "REVIEWED"
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
"osv": {
|
||||
"schema_version": "1.3.1",
|
||||
"id": "GO-2022-0493",
|
||||
"modified": "2024-05-20T16:03:47Z",
|
||||
"published": "2022-07-15T23:30:12Z",
|
||||
"aliases": [
|
||||
"CVE-2022-29526",
|
||||
"GHSA-p782-xgp4-8hr8"
|
||||
],
|
||||
"summary": "Incorrect privilege reporting in syscall and golang.org/x/sys/unix",
|
||||
"details": "When called with a non-zero flags parameter, the Faccessat function can incorrectly report that a file is accessible.",
|
||||
"affected": [
|
||||
{
|
||||
"package": {
|
||||
"name": "stdlib",
|
||||
"ecosystem": "Go"
|
||||
},
|
||||
"ranges": [
|
||||
{
|
||||
"type": "SEMVER",
|
||||
"events": [
|
||||
{
|
||||
"introduced": "0"
|
||||
},
|
||||
{
|
||||
"fixed": "1.17.10"
|
||||
},
|
||||
{
|
||||
"introduced": "1.18.0-0"
|
||||
},
|
||||
{
|
||||
"fixed": "1.18.2"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"ecosystem_specific": {
|
||||
"imports": [
|
||||
{
|
||||
"path": "syscall",
|
||||
"symbols": [
|
||||
"Faccessat"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": {
|
||||
"name": "golang.org/x/sys",
|
||||
"ecosystem": "Go"
|
||||
},
|
||||
"ranges": [
|
||||
{
|
||||
"type": "SEMVER",
|
||||
"events": [
|
||||
{
|
||||
"introduced": "0"
|
||||
},
|
||||
{
|
||||
"fixed": "0.0.0-20220412211240-33da011f77ad"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"ecosystem_specific": {
|
||||
"imports": [
|
||||
{
|
||||
"path": "golang.org/x/sys/unix",
|
||||
"symbols": [
|
||||
"Faccessat"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://go.dev/cl/399539"
|
||||
},
|
||||
{
|
||||
"type": "REPORT",
|
||||
"url": "https://go.dev/issue/52313"
|
||||
},
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://go.dev/cl/400074"
|
||||
},
|
||||
{
|
||||
"type": "WEB",
|
||||
"url": "https://groups.google.com/g/golang-announce/c/Y5qrqw_lWdU"
|
||||
}
|
||||
],
|
||||
"credits": [
|
||||
{
|
||||
"name": "Jo\u00ebl G\u00e4hwiler (@256dpi)"
|
||||
}
|
||||
],
|
||||
"database_specific": {
|
||||
"url": "https://pkg.go.dev/vuln/GO-2022-0493",
|
||||
"review_status": "REVIEWED"
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
"progress": {
|
||||
"message": "Checking the code against the vulnerabilities..."
|
||||
}
|
||||
}
|
||||
{
|
||||
"finding": {
|
||||
"osv": "GO-2022-0493",
|
||||
"fixed_version": "v0.0.0-20220412211240-33da011f77ad",
|
||||
"trace": [
|
||||
{
|
||||
"module": "golang.org/x/sys",
|
||||
"version": "v0.0.0-20200116001909-b77594299b42"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
{
|
||||
"finding": {
|
||||
"osv": "GO-2026-5024",
|
||||
"fixed_version": "v0.44.0",
|
||||
"trace": [
|
||||
{
|
||||
"module": "golang.org/x/sys",
|
||||
"version": "v0.0.0-20200116001909-b77594299b42"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
{
|
||||
"finding": {
|
||||
"osv": "GO-2022-0493",
|
||||
"fixed_version": "v0.0.0-20220412211240-33da011f77ad",
|
||||
"trace": [
|
||||
{
|
||||
"module": "golang.org/x/sys",
|
||||
"version": "v0.0.0-20200116001909-b77594299b42",
|
||||
"package": "golang.org/x/sys/unix"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
+522
@@ -0,0 +1,522 @@
|
||||
{
|
||||
"config": {
|
||||
"protocol_version": "v1.0.0",
|
||||
"scanner_name": "govulncheck",
|
||||
"scanner_version": "v1.9.0",
|
||||
"db": "https://vuln.go.dev",
|
||||
"db_last_modified": "2026-11-11T02:51:11Z",
|
||||
"go_version": "go1.26.11",
|
||||
"scan_level": "module",
|
||||
"scan_mode": "source"
|
||||
}
|
||||
}
|
||||
{
|
||||
"progress": {
|
||||
"message": "Fetching vulnerabilities from the database..."
|
||||
}
|
||||
}
|
||||
{
|
||||
"osv": {
|
||||
"schema_version": "1.3.1",
|
||||
"id": "GO-2022-0493",
|
||||
"modified": "2024-05-20T16:03:47Z",
|
||||
"published": "2022-07-15T23:30:12Z",
|
||||
"aliases": [
|
||||
"CVE-2022-29526",
|
||||
"GHSA-p782-xgp4-8hr8"
|
||||
],
|
||||
"summary": "Incorrect privilege reporting in syscall and golang.org/x/sys/unix",
|
||||
"details": "When called with a non-zero flags parameter, the Faccessat function can incorrectly report that a file is accessible.",
|
||||
"affected": [
|
||||
{
|
||||
"package": {
|
||||
"name": "stdlib",
|
||||
"ecosystem": "Go"
|
||||
},
|
||||
"ranges": [
|
||||
{
|
||||
"type": "SEMVER",
|
||||
"events": [
|
||||
{
|
||||
"introduced": "0"
|
||||
},
|
||||
{
|
||||
"fixed": "1.17.10"
|
||||
},
|
||||
{
|
||||
"introduced": "1.18.0-0"
|
||||
},
|
||||
{
|
||||
"fixed": "1.18.2"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"ecosystem_specific": {
|
||||
"imports": [
|
||||
{
|
||||
"path": "syscall",
|
||||
"symbols": [
|
||||
"Faccessat"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": {
|
||||
"name": "golang.org/x/sys",
|
||||
"ecosystem": "Go"
|
||||
},
|
||||
"ranges": [
|
||||
{
|
||||
"type": "SEMVER",
|
||||
"events": [
|
||||
{
|
||||
"introduced": "0"
|
||||
},
|
||||
{
|
||||
"fixed": "0.0.0-20220412211240-33da011f77ad"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"ecosystem_specific": {
|
||||
"imports": [
|
||||
{
|
||||
"path": "golang.org/x/sys/unix",
|
||||
"symbols": [
|
||||
"Faccessat"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://go.dev/cl/399539"
|
||||
},
|
||||
{
|
||||
"type": "REPORT",
|
||||
"url": "https://go.dev/issue/52313"
|
||||
},
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://go.dev/cl/400074"
|
||||
},
|
||||
{
|
||||
"type": "WEB",
|
||||
"url": "https://groups.google.com/g/golang-announce/c/Y5qrqw_lWdU"
|
||||
}
|
||||
],
|
||||
"credits": [
|
||||
{
|
||||
"name": "Jo\u00ebl G\u00e4hwiler (@256dpi)"
|
||||
}
|
||||
],
|
||||
"database_specific": {
|
||||
"url": "https://pkg.go.dev/vuln/GO-2022-0493",
|
||||
"review_status": "REVIEWED"
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
"osv": {
|
||||
"schema_version": "1.3.1",
|
||||
"id": "GO-2021-0052",
|
||||
"modified": "2024-05-20T16:03:47Z",
|
||||
"published": "2021-04-14T20:04:52Z",
|
||||
"aliases": [
|
||||
"CVE-2020-28483",
|
||||
"GHSA-h395-qcrw-5vmq"
|
||||
],
|
||||
"summary": "Inconsistent interpretation of HTTP Requests in github.com/gin-gonic/gin",
|
||||
"details": "Due to improper HTTP header sanitization, a malicious user can spoof their source IP address by setting the X-Forwarded-For header. This may allow a user to bypass IP based restrictions, or obfuscate their true source.",
|
||||
"affected": [
|
||||
{
|
||||
"package": {
|
||||
"name": "github.com/gin-gonic/gin",
|
||||
"ecosystem": "Go"
|
||||
},
|
||||
"ranges": [
|
||||
{
|
||||
"type": "SEMVER",
|
||||
"events": [
|
||||
{
|
||||
"introduced": "0"
|
||||
},
|
||||
{
|
||||
"fixed": "1.7.7"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"ecosystem_specific": {
|
||||
"imports": [
|
||||
{
|
||||
"path": "github.com/gin-gonic/gin",
|
||||
"symbols": [
|
||||
"Context.ClientIP",
|
||||
"Context.Next",
|
||||
"Context.RemoteIP",
|
||||
"Engine.HandleContext",
|
||||
"Engine.Run",
|
||||
"Engine.RunFd",
|
||||
"Engine.RunListener",
|
||||
"Engine.RunTLS",
|
||||
"Engine.RunUnix",
|
||||
"Engine.ServeHTTP"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"type": "REPORT",
|
||||
"url": "https://github.com/gin-gonic/gin/issues/2862"
|
||||
},
|
||||
{
|
||||
"type": "REPORT",
|
||||
"url": "https://github.com/gin-gonic/gin/issues/2473"
|
||||
},
|
||||
{
|
||||
"type": "REPORT",
|
||||
"url": "https://github.com/gin-gonic/gin/issues/2232"
|
||||
},
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://github.com/gin-gonic/gin/pull/2844"
|
||||
},
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://github.com/gin-gonic/gin/commit/5929d521715610c9dd14898ebbe1d188d5de8937"
|
||||
},
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://github.com/gin-gonic/gin/pull/2632"
|
||||
},
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://github.com/gin-gonic/gin/commit/bfc8ca285eb46dad60e037d57c545cd260636711"
|
||||
},
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://github.com/gin-gonic/gin/pull/2675"
|
||||
},
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://github.com/gin-gonic/gin/commit/03e5e05ae089bc989f1ca41841f05504d29e3fd9"
|
||||
},
|
||||
{
|
||||
"type": "WEB",
|
||||
"url": "https://github.com/gin-gonic/gin/pull/2474"
|
||||
}
|
||||
],
|
||||
"credits": [
|
||||
{
|
||||
"name": "@sorenisanerd"
|
||||
}
|
||||
],
|
||||
"database_specific": {
|
||||
"url": "https://pkg.go.dev/vuln/GO-2021-0052",
|
||||
"review_status": "REVIEWED"
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
"osv": {
|
||||
"schema_version": "1.3.1",
|
||||
"id": "GO-2023-1737",
|
||||
"modified": "2024-05-20T16:03:47Z",
|
||||
"published": "2023-05-11T18:59:56Z",
|
||||
"aliases": [
|
||||
"CVE-2023-29401",
|
||||
"GHSA-2c4m-59x9-fr2g"
|
||||
],
|
||||
"summary": "Improper handling of filenames in Content-Disposition HTTP header in github.com/gin-gonic/gin",
|
||||
"details": "The filename parameter of the Context.FileAttachment function is not properly sanitized. A maliciously crafted filename can cause the Content-Disposition header to be sent with an unexpected filename value or otherwise modify the Content-Disposition header. For example, a filename of \"setup.bat";x=.txt\" will be sent as a file named \"setup.bat\".\n\nIf the FileAttachment function is called with names provided by an untrusted source, this may permit an attacker to cause a file to be served with a name different than provided. Maliciously crafted attachment file name can modify the Content-Disposition header.",
|
||||
"affected": [
|
||||
{
|
||||
"package": {
|
||||
"name": "github.com/gin-gonic/gin",
|
||||
"ecosystem": "Go"
|
||||
},
|
||||
"ranges": [
|
||||
{
|
||||
"type": "SEMVER",
|
||||
"events": [
|
||||
{
|
||||
"introduced": "1.3.1-0.20190301021747-ccb9e902956d"
|
||||
},
|
||||
{
|
||||
"fixed": "1.9.1"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"ecosystem_specific": {
|
||||
"imports": [
|
||||
{
|
||||
"path": "github.com/gin-gonic/gin",
|
||||
"symbols": [
|
||||
"Context.FileAttachment"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"type": "REPORT",
|
||||
"url": "https://github.com/gin-gonic/gin/issues/3555"
|
||||
},
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://github.com/gin-gonic/gin/pull/3556"
|
||||
},
|
||||
{
|
||||
"type": "WEB",
|
||||
"url": "https://github.com/gin-gonic/gin/releases/tag/v1.9.1"
|
||||
}
|
||||
],
|
||||
"credits": [
|
||||
{
|
||||
"name": "motoyasu-saburi"
|
||||
}
|
||||
],
|
||||
"database_specific": {
|
||||
"url": "https://pkg.go.dev/vuln/GO-2023-1737",
|
||||
"review_status": "REVIEWED"
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
"osv": {
|
||||
"schema_version": "1.3.1",
|
||||
"id": "GO-2022-0493",
|
||||
"modified": "2024-05-20T16:03:47Z",
|
||||
"published": "2022-07-15T23:30:12Z",
|
||||
"aliases": [
|
||||
"CVE-2022-29526",
|
||||
"GHSA-p782-xgp4-8hr8"
|
||||
],
|
||||
"summary": "Incorrect privilege reporting in syscall and golang.org/x/sys/unix",
|
||||
"details": "When called with a non-zero flags parameter, the Faccessat function can incorrectly report that a file is accessible.",
|
||||
"affected": [
|
||||
{
|
||||
"package": {
|
||||
"name": "stdlib",
|
||||
"ecosystem": "Go"
|
||||
},
|
||||
"ranges": [
|
||||
{
|
||||
"type": "SEMVER",
|
||||
"events": [
|
||||
{
|
||||
"introduced": "0"
|
||||
},
|
||||
{
|
||||
"fixed": "1.17.10"
|
||||
},
|
||||
{
|
||||
"introduced": "1.18.0-0"
|
||||
},
|
||||
{
|
||||
"fixed": "1.18.2"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"ecosystem_specific": {
|
||||
"imports": [
|
||||
{
|
||||
"path": "syscall",
|
||||
"symbols": [
|
||||
"Faccessat"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": {
|
||||
"name": "golang.org/x/sys",
|
||||
"ecosystem": "Go"
|
||||
},
|
||||
"ranges": [
|
||||
{
|
||||
"type": "SEMVER",
|
||||
"events": [
|
||||
{
|
||||
"introduced": "0"
|
||||
},
|
||||
{
|
||||
"fixed": "0.0.0-20220412211240-33da011f77ad"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"ecosystem_specific": {
|
||||
"imports": [
|
||||
{
|
||||
"path": "golang.org/x/sys/unix",
|
||||
"symbols": [
|
||||
"Faccessat"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://go.dev/cl/399539"
|
||||
},
|
||||
{
|
||||
"type": "REPORT",
|
||||
"url": "https://go.dev/issue/52313"
|
||||
},
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://go.dev/cl/400074"
|
||||
},
|
||||
{
|
||||
"type": "WEB",
|
||||
"url": "https://groups.google.com/g/golang-announce/c/Y5qrqw_lWdU"
|
||||
}
|
||||
],
|
||||
"credits": [
|
||||
{
|
||||
"name": "Jo\u00ebl G\u00e4hwiler (@256dpi)"
|
||||
}
|
||||
],
|
||||
"database_specific": {
|
||||
"url": "https://pkg.go.dev/vuln/GO-2022-0493",
|
||||
"review_status": "REVIEWED"
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
"osv": {
|
||||
"schema_version": "1.3.1",
|
||||
"id": "GO-2026-5024",
|
||||
"modified": "2026-05-22T18:28:47Z",
|
||||
"published": "2026-05-22T18:28:47Z",
|
||||
"aliases": [
|
||||
"CVE-2026-39824"
|
||||
],
|
||||
"summary": "Invoking integer overflow in NewNTUnicodeString in golang.org/x/sys/windows",
|
||||
"details": "NewNTUnicodeString does not check for string length overflow. When provided with a string that overflows the maximum size of a NTUnicodeString (a 16-bit number of bytes), it returns a truncated string rather than an error.",
|
||||
"affected": [
|
||||
{
|
||||
"package": {
|
||||
"name": "golang.org/x/sys",
|
||||
"ecosystem": "Go"
|
||||
},
|
||||
"ranges": [
|
||||
{
|
||||
"type": "SEMVER",
|
||||
"events": [
|
||||
{
|
||||
"introduced": "0"
|
||||
},
|
||||
{
|
||||
"fixed": "0.44.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"ecosystem_specific": {
|
||||
"imports": [
|
||||
{
|
||||
"path": "golang.org/x/sys/windows",
|
||||
"goos": [
|
||||
"windows"
|
||||
],
|
||||
"symbols": [
|
||||
"NewNTUnicodeString"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"type": "REPORT",
|
||||
"url": "https://go.dev/issue/78916"
|
||||
},
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://go.dev/cl/770080"
|
||||
},
|
||||
{
|
||||
"type": "WEB",
|
||||
"url": "https://groups.google.com/g/golang-announce/c/6MMI8Lj-Atg"
|
||||
}
|
||||
],
|
||||
"database_specific": {
|
||||
"url": "https://pkg.go.dev/vuln/GO-2026-5024",
|
||||
"review_status": "REVIEWED"
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
"progress": {
|
||||
"message": "Checking the code against the vulnerabilities..."
|
||||
}
|
||||
}
|
||||
{
|
||||
"finding": {
|
||||
"osv": "GO-2021-0052",
|
||||
"fixed_version": "v1.7.7",
|
||||
"trace": [
|
||||
{
|
||||
"module": "github.com/gin-gonic/gin",
|
||||
"version": "v1.6.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
{
|
||||
"finding": {
|
||||
"osv": "GO-2023-1737",
|
||||
"fixed_version": "v1.9.1",
|
||||
"trace": [
|
||||
{
|
||||
"module": "github.com/gin-gonic/gin",
|
||||
"version": "v1.6.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
{
|
||||
"finding": {
|
||||
"osv": "GO-2022-0493",
|
||||
"fixed_version": "v0.0.0-20220412211240-33da011f77ad",
|
||||
"trace": [
|
||||
{
|
||||
"module": "golang.org/x/sys",
|
||||
"version": "v0.0.0-20200116001909-b77594299b42"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
{
|
||||
"finding": {
|
||||
"osv": "GO-2026-5024",
|
||||
"fixed_version": "v0.44.0",
|
||||
"trace": [
|
||||
{
|
||||
"module": "golang.org/x/sys",
|
||||
"version": "v0.0.0-20200116001909-b77594299b42"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
github.com/gin-gonic/gin gin 18 0
|
||||
github.com/gin-gonic/gin/binding binding 13 0
|
||||
github.com/gin-gonic/gin/ginS ginS 1 0
|
||||
github.com/gin-gonic/gin/internal/bytesconv bytesconv 1 0
|
||||
github.com/gin-gonic/gin/internal/json json 1 0
|
||||
github.com/gin-gonic/gin/render render 11 0
|
||||
@@ -0,0 +1,63 @@
|
||||
golang.org/x/text text 1 0
|
||||
golang.org/x/text/cases cases 7 0
|
||||
golang.org/x/text/cmd/gotext main 7 0
|
||||
golang.org/x/text/cmd/gotext/examples/extract main 2 0
|
||||
golang.org/x/text/cmd/gotext/examples/extract_http main 2 0
|
||||
golang.org/x/text/cmd/gotext/examples/extract_http/pkg pkg 1 0
|
||||
golang.org/x/text/cmd/gotext/examples/rewrite main 1 0
|
||||
golang.org/x/text/collate collate 5 0
|
||||
golang.org/x/text/collate/build build 6 0
|
||||
golang.org/x/text/collate/tools/colcmp main 4 0
|
||||
golang.org/x/text/currency currency 5 0
|
||||
golang.org/x/text/date date 1 0
|
||||
golang.org/x/text/encoding encoding 1 0
|
||||
golang.org/x/text/encoding/charmap charmap 2 0
|
||||
golang.org/x/text/encoding/htmlindex htmlindex 3 0
|
||||
golang.org/x/text/encoding/ianaindex ianaindex 3 0
|
||||
golang.org/x/text/encoding/internal internal 1 0
|
||||
golang.org/x/text/encoding/internal/enctest enctest 1 0
|
||||
golang.org/x/text/encoding/internal/identifier identifier 2 0
|
||||
golang.org/x/text/encoding/japanese japanese 5 0
|
||||
golang.org/x/text/encoding/korean korean 2 0
|
||||
golang.org/x/text/encoding/simplifiedchinese simplifiedchinese 4 0
|
||||
golang.org/x/text/encoding/traditionalchinese traditionalchinese 2 0
|
||||
golang.org/x/text/encoding/unicode unicode 2 0
|
||||
golang.org/x/text/encoding/unicode/utf32 utf32 1 0
|
||||
golang.org/x/text/feature/plural plural 4 0
|
||||
golang.org/x/text/internal internal 2 0
|
||||
golang.org/x/text/internal/catmsg catmsg 3 0
|
||||
golang.org/x/text/internal/cldrtree cldrtree 5 0
|
||||
golang.org/x/text/internal/colltab colltab 8 0
|
||||
golang.org/x/text/internal/export/idna idna 5 0
|
||||
golang.org/x/text/internal/export/unicode unicode 1 0
|
||||
golang.org/x/text/internal/format format 2 0
|
||||
golang.org/x/text/internal/gen gen 2 0
|
||||
golang.org/x/text/internal/gen/bitfield bitfield 1 0
|
||||
golang.org/x/text/internal/language language 10 0
|
||||
golang.org/x/text/internal/language/compact compact 5 0
|
||||
golang.org/x/text/internal/number number 7 0
|
||||
golang.org/x/text/internal/stringset stringset 1 0
|
||||
golang.org/x/text/internal/tag tag 1 0
|
||||
golang.org/x/text/internal/testtext testtext 5 0
|
||||
golang.org/x/text/internal/triegen triegen 3 0
|
||||
golang.org/x/text/internal/ucd ucd 1 0
|
||||
golang.org/x/text/internal/utf8internal utf8internal 1 0
|
||||
golang.org/x/text/language language 8 0
|
||||
golang.org/x/text/language/display display 4 0
|
||||
golang.org/x/text/message message 5 0
|
||||
golang.org/x/text/message/catalog catalog 3 0
|
||||
golang.org/x/text/message/pipeline pipeline 5 0
|
||||
golang.org/x/text/number number 4 0
|
||||
golang.org/x/text/runes runes 2 0
|
||||
golang.org/x/text/search search 4 0
|
||||
golang.org/x/text/secure secure 1 0
|
||||
golang.org/x/text/secure/bidirule bidirule 2 0
|
||||
golang.org/x/text/secure/precis precis 10 0
|
||||
golang.org/x/text/transform transform 1 0
|
||||
golang.org/x/text/unicode unicode 1 0
|
||||
golang.org/x/text/unicode/bidi bidi 6 0
|
||||
golang.org/x/text/unicode/cldr cldr 7 0
|
||||
golang.org/x/text/unicode/norm norm 9 0
|
||||
golang.org/x/text/unicode/rangetable rangetable 3 0
|
||||
golang.org/x/text/unicode/runenames runenames 2 0
|
||||
golang.org/x/text/width width 5 0
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"config": {
|
||||
"protocol_version": "v1.0.0",
|
||||
"scanner_name": "govulncheck",
|
||||
"scanner_version": "v1.9.0",
|
||||
"db": "https://vuln.go.dev",
|
||||
"db_last_modified": "2026-11-11T02:51:11Z",
|
||||
"go_version": "go1.26.11",
|
||||
"scan_level": "module",
|
||||
"scan_mode": "source"
|
||||
}
|
||||
}
|
||||
{
|
||||
"progress": {
|
||||
"message": "Fetching vulnerabilities from the database..."
|
||||
}
|
||||
}
|
||||
{
|
||||
"progress": {
|
||||
"message": "Checking the code against the vulnerabilities..."
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,369 @@
|
||||
{
|
||||
"config": {
|
||||
"protocol_version": "v1.0.0",
|
||||
"scanner_name": "govulncheck",
|
||||
"scanner_version": "v1.9.0",
|
||||
"db": "https://vuln.go.dev",
|
||||
"db_last_modified": "2026-11-11T02:51:11Z",
|
||||
"go_version": "go1.26.11",
|
||||
"scan_level": "module",
|
||||
"scan_mode": "source"
|
||||
}
|
||||
}
|
||||
{
|
||||
"progress": {
|
||||
"message": "Fetching vulnerabilities from the database..."
|
||||
}
|
||||
}
|
||||
{
|
||||
"osv": {
|
||||
"schema_version": "1.3.1",
|
||||
"id": "GO-2021-0113",
|
||||
"modified": "2024-05-20T16:03:47Z",
|
||||
"published": "2021-10-06T17:51:21Z",
|
||||
"aliases": [
|
||||
"CVE-2021-38561",
|
||||
"GHSA-ppp9-7jff-5vj2"
|
||||
],
|
||||
"summary": "Out-of-bounds read in golang.org/x/text/language",
|
||||
"details": "Due to improper index calculation, an incorrectly formatted language tag can cause Parse to panic via an out of bounds read. If Parse is used to process untrusted user inputs, this may be used as a vector for a denial of service attack.",
|
||||
"affected": [
|
||||
{
|
||||
"package": {
|
||||
"name": "golang.org/x/text",
|
||||
"ecosystem": "Go"
|
||||
},
|
||||
"ranges": [
|
||||
{
|
||||
"type": "SEMVER",
|
||||
"events": [
|
||||
{
|
||||
"introduced": "0"
|
||||
},
|
||||
{
|
||||
"fixed": "0.3.7"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"ecosystem_specific": {
|
||||
"imports": [
|
||||
{
|
||||
"path": "golang.org/x/text/language",
|
||||
"symbols": [
|
||||
"MatchStrings",
|
||||
"MustParse",
|
||||
"Parse",
|
||||
"ParseAcceptLanguage"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://go.dev/cl/340830"
|
||||
},
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://go.googlesource.com/text/+/383b2e75a7a4198c42f8f87833eefb772868a56f"
|
||||
}
|
||||
],
|
||||
"credits": [
|
||||
{
|
||||
"name": "Guido Vranken"
|
||||
}
|
||||
],
|
||||
"database_specific": {
|
||||
"url": "https://pkg.go.dev/vuln/GO-2021-0113",
|
||||
"review_status": "REVIEWED"
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
"osv": {
|
||||
"schema_version": "1.3.1",
|
||||
"id": "GO-2022-1059",
|
||||
"modified": "2024-05-20T16:03:47Z",
|
||||
"published": "2022-10-11T18:16:24Z",
|
||||
"aliases": [
|
||||
"CVE-2022-32149",
|
||||
"GHSA-69ch-w2m2-3vjp"
|
||||
],
|
||||
"summary": "Denial of service via crafted Accept-Language header in golang.org/x/text/language",
|
||||
"details": "An attacker may cause a denial of service by crafting an Accept-Language header which ParseAcceptLanguage will take significant time to parse.",
|
||||
"affected": [
|
||||
{
|
||||
"package": {
|
||||
"name": "golang.org/x/text",
|
||||
"ecosystem": "Go"
|
||||
},
|
||||
"ranges": [
|
||||
{
|
||||
"type": "SEMVER",
|
||||
"events": [
|
||||
{
|
||||
"introduced": "0"
|
||||
},
|
||||
{
|
||||
"fixed": "0.3.8"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"ecosystem_specific": {
|
||||
"imports": [
|
||||
{
|
||||
"path": "golang.org/x/text/language",
|
||||
"symbols": [
|
||||
"MatchStrings",
|
||||
"ParseAcceptLanguage"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"type": "REPORT",
|
||||
"url": "https://go.dev/issue/56152"
|
||||
},
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://go.dev/cl/442235"
|
||||
},
|
||||
{
|
||||
"type": "WEB",
|
||||
"url": "https://groups.google.com/g/golang-announce/c/-hjNw559_tE/m/KlGTfid5CAAJ"
|
||||
}
|
||||
],
|
||||
"credits": [
|
||||
{
|
||||
"name": "Adam Korczynski (ADA Logics)"
|
||||
},
|
||||
{
|
||||
"name": "OSS-Fuzz"
|
||||
}
|
||||
],
|
||||
"database_specific": {
|
||||
"url": "https://pkg.go.dev/vuln/GO-2022-1059",
|
||||
"review_status": "REVIEWED"
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
"osv": {
|
||||
"schema_version": "1.3.1",
|
||||
"id": "GO-2026-5970",
|
||||
"modified": "2026-08-10T22:42:36Z",
|
||||
"published": "2026-07-14T17:29:56Z",
|
||||
"aliases": [
|
||||
"CVE-2026-56852"
|
||||
],
|
||||
"summary": "Infinite loop on invalid input in golang.org/x/text",
|
||||
"details": "A norm.Iter can enter an infinite loop when handling input containing invalid UTF-8 bytes.",
|
||||
"affected": [
|
||||
{
|
||||
"package": {
|
||||
"name": "golang.org/x/text",
|
||||
"ecosystem": "Go"
|
||||
},
|
||||
"ranges": [
|
||||
{
|
||||
"type": "SEMVER",
|
||||
"events": [
|
||||
{
|
||||
"introduced": "0"
|
||||
},
|
||||
{
|
||||
"fixed": "0.39.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"ecosystem_specific": {
|
||||
"imports": [
|
||||
{
|
||||
"path": "golang.org/x/text/unicode/norm",
|
||||
"symbols": [
|
||||
"Form.Append",
|
||||
"Form.AppendString",
|
||||
"Form.Bytes",
|
||||
"Form.FirstBoundary",
|
||||
"Form.FirstBoundaryInString",
|
||||
"Form.IsNormal",
|
||||
"Form.IsNormalString",
|
||||
"Form.LastBoundary",
|
||||
"Form.NextBoundary",
|
||||
"Form.NextBoundaryInString",
|
||||
"Form.Properties",
|
||||
"Form.PropertiesString",
|
||||
"Form.QuickSpan",
|
||||
"Form.QuickSpanString",
|
||||
"Form.Span",
|
||||
"Form.SpanString",
|
||||
"Form.String",
|
||||
"Form.Transform",
|
||||
"Iter.Init",
|
||||
"Iter.InitString",
|
||||
"Iter.Next",
|
||||
"Iter.Seek",
|
||||
"nextComposed",
|
||||
"normReader.Read",
|
||||
"normWriter.Write"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"type": "REPORT",
|
||||
"url": "https://go.dev/issue/80142"
|
||||
},
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://go.dev/cl/794100"
|
||||
}
|
||||
],
|
||||
"credits": [
|
||||
{
|
||||
"name": "Viky Choi (\"vikychoi\" on GitHub)"
|
||||
}
|
||||
],
|
||||
"database_specific": {
|
||||
"url": "https://pkg.go.dev/vuln/GO-2026-5970",
|
||||
"review_status": "REVIEWED"
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
"osv": {
|
||||
"schema_version": "1.3.1",
|
||||
"id": "GO-2026-6629",
|
||||
"modified": "2026-10-07T14:09:43Z",
|
||||
"published": "2026-10-07T14:09:43Z",
|
||||
"aliases": [
|
||||
"CVE-2026-56851"
|
||||
],
|
||||
"summary": "Panic parsing crafted input in x/text/secure/precis in golang.org/x/text",
|
||||
"details": "The Nickname profile can panic with an out-of-bounds slice error when transforming crafted input into a short destination buffer.",
|
||||
"affected": [
|
||||
{
|
||||
"package": {
|
||||
"name": "golang.org/x/text",
|
||||
"ecosystem": "Go"
|
||||
},
|
||||
"ranges": [
|
||||
{
|
||||
"type": "SEMVER",
|
||||
"events": [
|
||||
{
|
||||
"introduced": "0"
|
||||
},
|
||||
{
|
||||
"fixed": "0.41.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"ecosystem_specific": {
|
||||
"imports": [
|
||||
{
|
||||
"path": "golang.org/x/text/secure/precis",
|
||||
"symbols": [
|
||||
"Profile.Append",
|
||||
"Profile.AppendCompareKey",
|
||||
"Profile.Bytes",
|
||||
"Profile.Compare",
|
||||
"Profile.CompareKey",
|
||||
"Profile.NewTransformer",
|
||||
"Profile.String",
|
||||
"Transformer.Bytes",
|
||||
"Transformer.String",
|
||||
"Transformer.Transform",
|
||||
"nickAdditionalMapping.Transform"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"type": "FIX",
|
||||
"url": "https://go.dev/cl/793360"
|
||||
},
|
||||
{
|
||||
"type": "REPORT",
|
||||
"url": "https://go.dev/issue/80112"
|
||||
}
|
||||
],
|
||||
"credits": [
|
||||
{
|
||||
"name": "Omkhar Arasaratnam (GitHub: omkhar)"
|
||||
}
|
||||
],
|
||||
"database_specific": {
|
||||
"url": "https://pkg.go.dev/vuln/GO-2026-6629",
|
||||
"review_status": "REVIEWED"
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
"progress": {
|
||||
"message": "Checking the code against the vulnerabilities..."
|
||||
}
|
||||
}
|
||||
{
|
||||
"finding": {
|
||||
"osv": "GO-2021-0113",
|
||||
"fixed_version": "v0.3.7",
|
||||
"trace": [
|
||||
{
|
||||
"module": "golang.org/x/text",
|
||||
"version": "v0.3.5"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
{
|
||||
"finding": {
|
||||
"osv": "GO-2022-1059",
|
||||
"fixed_version": "v0.3.8",
|
||||
"trace": [
|
||||
{
|
||||
"module": "golang.org/x/text",
|
||||
"version": "v0.3.5"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
{
|
||||
"finding": {
|
||||
"osv": "GO-2026-5970",
|
||||
"fixed_version": "v0.39.0",
|
||||
"trace": [
|
||||
{
|
||||
"module": "golang.org/x/text",
|
||||
"version": "v0.3.5"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
{
|
||||
"finding": {
|
||||
"osv": "GO-2026-6629",
|
||||
"fixed_version": "v0.41.0",
|
||||
"trace": [
|
||||
{
|
||||
"module": "golang.org/x/text",
|
||||
"version": "v0.3.5"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user