scan

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2023 License: BSD-3-Clause Imports: 27 Imported by: 0

Documentation

Overview

Package govulncheck provides functionality to support the govulncheck command.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrVulnerabilitiesFound indicates that vulnerabilities were detected
	// when running govulncheck. This returns exit status 3 when running
	// without the -json flag.
	ErrVulnerabilitiesFound = errors.New("vulnerabilities found")

	// ErrNoPatterns indicates that no patterns were passed in when running
	// govulncheck.
	//
	// In this case, we assume that the user does not know how to run
	// govulncheck, and print the usage message with exit status 1.
	ErrNoPatterns = errors.New("no patterns provided")
)

LoadMode is the level of information needed for each package for running golang.org/x/tools/go/packages.Load.

Functions

func AbsRelShorter

func AbsRelShorter(path string) string

AbsRelShorter takes path and returns its path relative to the current directory, if shorter. Returns path when path is an empty string or upon any error.

func Flush

func Flush(h govulncheck.Handler) error

func FuncName

func FuncName(frame *govulncheck.StackFrame) string

FuncName returns the full qualified function name from a stack frame, adjusted to remove pointer annotations.

func IsCalled

func IsCalled(v *govulncheck.Vuln) bool

IsCalled reports whether the vulnerability is called, therefore affecting the target source code or binary.

func NewTextHandler

func NewTextHandler(w io.Writer, source, verbose bool) govulncheck.Handler

NewtextHandler returns a handler that writes govulncheck output as text.

func Pos

func Pos(sf *govulncheck.StackFrame) string

Pos returns the position of the call in sf as string. If position is not available, return "".

Types

type Cmd

type Cmd struct {
	// Stdout specifies the standard output. If nil, Run connects os.Stdout.
	Stdout io.Writer
	// contains filtered or unexported fields
}

Cmd represents an external govulncheck command being prepared or run, similar to exec.Cmd.

func Command

func Command(ctx context.Context, arg ...string) *Cmd

Command returns the Cmd struct to execute govulncheck with the given arguments.

func (*Cmd) Run

func (c *Cmd) Run() error

Run starts govulncheck and waits for it to complete.

func (*Cmd) Start

func (c *Cmd) Start() error

Start starts the specified command but does not wait for it to complete.

After a successful call to Start the Wait method must be called in order to release associated system resources.

func (*Cmd) StdoutPipe

func (c *Cmd) StdoutPipe() io.ReadCloser

StdoutPipe returns a pipe that will be connected to the command's standard output when the command starts.

func (*Cmd) Wait

func (c *Cmd) Wait() error

Wait waits for the command to exit. The command must have been started by Start.

Wait releases any resources associated with the Cmd.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL