tools

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCommand added in v0.4.28

func CreateCommand(tool Interface) *cobra.Command

func IsDockerError added in v0.5.4

func IsDockerError(err error) bool

func MissingFormatter added in v0.5.0

func MissingFormatter(n *jnode.Node) string

func MustRel added in v0.4.39

func MustRel(base, target string) string

func PassFormatter added in v0.4.39

func PassFormatter(n *jnode.Node) string

func TempFile added in v0.4.35

func TempFile(pattern string) (name string, err error)

Types

type Config added in v0.4.39

type Config struct {
	// contains filtered or unexported fields
}

func ReadConfigFile added in v0.5.0

func ReadConfigFile(path string) *Config

func (*Config) IsIgnored added in v0.4.39

func (c *Config) IsIgnored(path string) bool

type Consolidated added in v0.5.0

type Consolidated interface {
	Interface
	RunAll() (Results, error)
}

A Consolidated tool runs and returns multiple results (typically by invoking other tools)

type DirectoryBasedToolOpts added in v0.4.28

type DirectoryBasedToolOpts struct {
	ToolOpts
	Directory string
	Exclude   []string
	// contains filtered or unexported fields
}

func (*DirectoryBasedToolOpts) GetDirectory added in v0.4.28

func (o *DirectoryBasedToolOpts) GetDirectory() string

func (*DirectoryBasedToolOpts) GetDirectoryBasedToolOptions added in v0.4.34

func (o *DirectoryBasedToolOpts) GetDirectoryBasedToolOptions() *DirectoryBasedToolOpts

func (*DirectoryBasedToolOpts) GetDockerRunDirectory added in v0.4.45

func (o *DirectoryBasedToolOpts) GetDockerRunDirectory() string

Return the directory that a docker-based tool is run in. Normally this is /src, but if it's run out of PATH, then it's o.GetDirectory()

func (*DirectoryBasedToolOpts) GetFilesInDirectory added in v0.4.34

func (o *DirectoryBasedToolOpts) GetFilesInDirectory(files []string) ([]string, error)

func (*DirectoryBasedToolOpts) GetInventory added in v0.4.34

func (o *DirectoryBasedToolOpts) GetInventory() *inventory.Manifest

func (*DirectoryBasedToolOpts) IsExcluded added in v0.4.34

func (o *DirectoryBasedToolOpts) IsExcluded(file string) bool

func (*DirectoryBasedToolOpts) Register added in v0.4.28

func (o *DirectoryBasedToolOpts) Register(cmd *cobra.Command)

func (*DirectoryBasedToolOpts) RemoveExcluded added in v0.4.34

func (o *DirectoryBasedToolOpts) RemoveExcluded(files []string) []string

func (*DirectoryBasedToolOpts) Validate added in v0.4.34

func (o *DirectoryBasedToolOpts) Validate() error

type DockerError added in v0.5.4

type DockerError string

func (DockerError) Error added in v0.5.4

func (d DockerError) Error() string

func (DockerError) Is added in v0.5.4

func (d DockerError) Is(err error) bool

type DockerTool added in v0.4.29

type DockerTool struct {
	Name                string
	Image               string
	DockerArgs          []string
	Args                []string
	DefaultNoDockerName string
	PolicyDirectory     string
	Stdout              io.Writer
	Stderr              io.Writer
	Directory           string
}

type ExtraArgs added in v0.4.55

type ExtraArgs []string

ExtraArgs captures extra arguments to a command

func (*ExtraArgs) ArgsValue added in v0.4.55

func (ex *ExtraArgs) ArgsValue() func(cmd *cobra.Command, args []string) error

type FileFingerprint added in v0.5.0

type FileFingerprint struct {
	Line               int    `json:"line"`
	RepoPath           string `json:"repoPath,omitempty"`
	PartialFingerprint string `json:"partialFingerprint,omitempty"`
	FilePath           string `json:"filePath"`
	MultiDocumentFile  bool   `json:"multiDocumentFile,omitempty"`
}

type HasCommandTemplate added in v0.4.31

type HasCommandTemplate interface {
	CommandTemplate() *cobra.Command
}

type Interface

type Interface interface {
	options.Interface
	GetToolOptions() *ToolOpts
	GetDirectoryBasedToolOptions() *DirectoryBasedToolOpts
	Validate() error
	Name() string
	IsNonAssessment() bool
}

type Result

type Result struct {
	Data             *jnode.Node
	Findings         assessments.Findings
	Values           map[string]string
	Directory        string
	Files            *util.StringSet
	FileFingerprints []*FileFingerprint

	Assessment    *assessments.Assessment
	AssessmentRaw *jnode.Node
}

func (*Result) AddFile added in v0.4.21

func (r *Result) AddFile(path string) *Result

func (*Result) AddValue added in v0.4.21

func (r *Result) AddValue(name, value string) *Result

func (*Result) UpdateFileFingerprints added in v0.5.0

func (r *Result) UpdateFileFingerprints()

func (*Result) Upload added in v0.5.0

func (r *Result) Upload(client *api.Client, org, name string) error

type Results added in v0.5.0

type Results []*Result

type RunOpts added in v0.4.39

type RunOpts struct {
	options.PrintClientOpts
	ToolVersion     string
	ToolPath        string
	SkipDockerPull  bool
	ExtraDockerArgs []string
	NoDocker        bool
	Internal        bool
}

func (*RunOpts) GetRunHiddenOptions added in v0.4.55

func (o *RunOpts) GetRunHiddenOptions() *options.HiddenOptionsGroup

func (*RunOpts) InstallTool added in v0.4.39

func (o *RunOpts) InstallTool(spec *download.Spec) (*download.Download, error)

func (*RunOpts) LogCommand added in v0.4.55

func (o *RunOpts) LogCommand(c *exec.Cmd)

func (*RunOpts) Register added in v0.4.39

func (o *RunOpts) Register(cmd *cobra.Command)

func (*RunOpts) RunDocker added in v0.4.39

func (o *RunOpts) RunDocker(d *DockerTool) ([]byte, error)

type Single added in v0.5.0

type Single interface {
	Interface
	Run() (*Result, error)
}

A Single tool runs and returns a single result

type ToolOpts

type ToolOpts struct {
	RunOpts
	Tool                  Interface
	UploadEnabled         bool
	PrintResultOpt        bool
	SaveResult            string
	PrintResultValues     bool
	SaveResultValues      string
	DisableCustomPolicies bool
	RepoRoot              string
	PrintFingerprints     bool
	SaveFingerprints      string
	ConfigFile            string
	// contains filtered or unexported fields
}

func (*ToolOpts) GetConfig added in v0.4.39

func (o *ToolOpts) GetConfig() *Config

func (*ToolOpts) GetCustomPoliciesDir added in v0.4.39

func (o *ToolOpts) GetCustomPoliciesDir() (string, error)

func (*ToolOpts) GetDirectoryBasedToolOptions added in v0.4.34

func (o *ToolOpts) GetDirectoryBasedToolOptions() *DirectoryBasedToolOpts

func (*ToolOpts) GetToolHiddenOptions added in v0.4.55

func (o *ToolOpts) GetToolHiddenOptions() *options.HiddenOptionsGroup

func (*ToolOpts) GetToolOptions added in v0.4.28

func (o *ToolOpts) GetToolOptions() *ToolOpts

func (*ToolOpts) InstallAPIServerArtifact added in v0.4.28

func (o *ToolOpts) InstallAPIServerArtifact(name, urlPath string) (*download.Download, error)

func (*ToolOpts) IsNonAssessment added in v0.5.0

func (o *ToolOpts) IsNonAssessment() bool

func (*ToolOpts) Register

func (o *ToolOpts) Register(c *cobra.Command)

func (*ToolOpts) RunTool

func (o *ToolOpts) RunTool() (Results, error)

func (*ToolOpts) Validate added in v0.4.32

func (o *ToolOpts) Validate() error

Jump to

Keyboard shortcuts

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