tools

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InstallFailure       = FailureType("install")
	ExecutionFailure     = FailureType("execution")
	GarbledResultFailure = FailureType("garbled_result")
	ExitCodeFailure      = FailureType("exit_code")
	NoFailure            = FailureType("")
)
View Source
const (
	Terraform      = IACPlatform("terraform")
	TerraformPlan  = IACPlatform("terraform_plan")
	CDK            = IACPlatform("cdk")
	Helm           = IACPlatform("helm")
	Kustomize      = IACPlatform("kustomize")
	Cloudformation = IACPlatform("cloudformation")
	Dockerfile     = IACPlatform("dockerfile")
	ARM            = IACPlatform("arm")
	Kubernetes     = IACPlatform("kubernetes")
)
View Source
const AssessmentDirectoryValue = "ASSESSMENT_DIRECTORY"

Variables

This section is empty.

Functions

func CreateCommand added in v0.4.28

func CreateCommand(tool Interface) *cobra.Command

func ExtractArchives added in v0.5.43

func ExtractArchives(dir string, archives []string) error

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 AssessmentOpts added in v0.5.9

type AssessmentOpts struct {
	ToolOpts
	UploadOpts
	PrintResultOpt            bool
	SaveResult                string
	PrintResultValues         bool
	SaveResultValues          string
	DisableCustomPolicies     bool
	PrintFingerprints         bool
	SaveFingerprints          string
	CustomPoliciesDir         string
	PreparedCustomPoliciesDir string
	FailThresholds            []string

	CustomPolicyMetadata   map[string]string
	LaceworkPolicyMetadata map[string]string
	// contains filtered or unexported fields
}

func (*AssessmentOpts) GetAssessmentHiddenOptions added in v0.5.9

func (o *AssessmentOpts) GetAssessmentHiddenOptions() *options.HiddenOptionsGroup

func (*AssessmentOpts) GetAssessmentOptions added in v0.5.9

func (o *AssessmentOpts) GetAssessmentOptions() *AssessmentOpts

func (*AssessmentOpts) Register added in v0.5.9

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

func (*AssessmentOpts) Validate added in v0.5.9

func (o *AssessmentOpts) Validate() error

type AssessmentTool added in v0.5.45

type AssessmentTool interface {
	GetAssessmentOptions() *AssessmentOpts
	GetToolOptions() *ToolOpts
}

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

type Consolidated added in v0.5.0

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

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

type DirectoryBasedToolOpts added in v0.4.28

type DirectoryBasedToolOpts struct {
	AssessmentOpts
	DirectoryOpt
	Exclude []string
	// contains filtered or unexported fields
}

Options for assessment tools that run in a directory

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 DirectoryOpt added in v0.5.9

type DirectoryOpt struct {
	Directory string
	// contains filtered or unexported fields
}

func (*DirectoryOpt) GetDirectory added in v0.5.9

func (o *DirectoryOpt) GetDirectory() string

func (*DirectoryOpt) Register added in v0.5.9

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

func (*DirectoryOpt) SetDirectory added in v0.5.9

func (o *DirectoryOpt) SetDirectory(dir string)

func (*DirectoryOpt) Validate added in v0.5.9

func (o *DirectoryOpt) Validate(opts *ToolOpts) 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
	ExtraMounts         map[string]string
	Stdout              io.Writer
	Stderr              io.Writer
	Directory           string

	WorkingDirectory         string
	PropagateEnvironmentVars []string
	// contains filtered or unexported fields
}

func (*DockerTool) AppendArgs added in v0.5.8

func (t *DockerTool) AppendArgs(args ...string)

func (*DockerTool) Mount added in v0.5.8

func (t *DockerTool) Mount(name, mountpoint string)

type ExecuteResult added in v0.5.13

type ExecuteResult struct {
	Args           []string
	FailureType    FailureType
	FailureMessage string
	ExitCode       int
	CombinedOutput *strings.Builder
	Output         []byte
}

func (*ExecuteResult) AppendUploadOptions added in v0.5.13

func (r *ExecuteResult) AppendUploadOptions(compressFiles bool, options []api.Option) []api.Option

func (*ExecuteResult) ExpectExitCode added in v0.5.13

func (r *ExecuteResult) ExpectExitCode(codes ...int) bool

func (*ExecuteResult) ParseJSON added in v0.5.13

func (r *ExecuteResult) ParseJSON() (*jnode.Node, bool)

func (*ExecuteResult) SetFailureFromError added in v0.5.13

func (r *ExecuteResult) SetFailureFromError(ft FailureType, err error)

func (*ExecuteResult) SetUploadValues added in v0.5.13

func (r *ExecuteResult) SetUploadValues(values map[string]string)

func (*ExecuteResult) ToError added in v0.5.13

func (r *ExecuteResult) ToError() error

func (*ExecuteResult) ToResult added in v0.5.13

func (r *ExecuteResult) ToResult(dir string) *Result

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 FailureType added in v0.5.13

type FailureType string

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 HasDirectory added in v0.5.9

type HasDirectory interface {
	GetDirectory() string
	SetDirectory(dir string)
}

type IACPlatform added in v0.5.31

type IACPlatform string

type Interface

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

type Result

type Result struct {
	Tool             AssessmentTool
	Data             *jnode.Node
	Findings         assessments.Findings
	Values           map[string]string
	Directory        string
	FileFingerprints []*FileFingerprint
	UploadOptions    []api.Option
	ExecuteResult    *ExecuteResult
	ModuleName       string
	IACPlatform      IACPlatform

	Assessment    *assessments.Assessment
	AssessmentRaw *jnode.Node
}

func RunSingleAssessment added in v0.5.9

func RunSingleAssessment(tool Single) (*Result, error)

func (*Result) AddUploadOption added in v0.5.9

func (r *Result) AddUploadOption(options ...api.Option)

func (*Result) AddValue added in v0.4.21

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

func (*Result) AddValues added in v0.5.9

func (r *Result) AddValues(values map[string]string) *Result

func (*Result) UpdateFileFingerprints added in v0.5.0

func (r *Result) UpdateFileFingerprints()

type Results added in v0.5.0

type Results []*Result

func RunConsoliatedAssessments added in v0.5.9

func RunConsoliatedAssessments(tool Consolidated) (Results, error)

type RunOpts added in v0.4.39

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

	StrictLoading bool
	// contains filtered or unexported fields
}

func (*RunOpts) ExecuteCommand added in v0.5.13

func (o *RunOpts) ExecuteCommand(c *exec.Cmd) *ExecuteResult

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) (*ExecuteResult, error)

Run a docker tool. If the tool cannot be run because docker isn't running or the tool path isn't known then returns an error. Otherwise returns an ExecuteResult that holds the output, log and exit code of the command.

func (*RunOpts) UsingDocker added in v0.5.18

func (o *RunOpts) UsingDocker() bool

type Simple added in v0.5.9

type Simple interface {
	Interface
	Run() error
}

A Simple tool is a tool that does not generate findings

type Single added in v0.5.0

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

A Single tool runs and returns a single assessment result

type ToolOpts

type ToolOpts struct {
	RunOpts
	Tool               Interface
	RepoRoot           string
	UseEmptyConfigFile bool
	CacheDuration      time.Duration
	// contains filtered or unexported fields
}

func (*ToolOpts) GetConfig added in v0.4.39

func (o *ToolOpts) GetConfig() *Config

func (*ToolOpts) GetStandardXCPValues added in v0.5.9

func (o *ToolOpts) GetStandardXCPValues() map[string]string

func (*ToolOpts) GetToolOptions added in v0.4.28

func (o *ToolOpts) GetToolOptions() *ToolOpts

func (*ToolOpts) Register

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

func (*ToolOpts) Validate added in v0.4.32

func (o *ToolOpts) Validate() error

type UploadOpts added in v0.5.15

type UploadOpts struct {
	DefaultUploadEnabled bool
	UploadEnabled        bool
	GitPRBaseRef         string
	UploadErrors         bool
	CompressResults      bool
}

func (*UploadOpts) AppendUploadOptions added in v0.5.15

func (o *UploadOpts) AppendUploadOptions(dir string, options []api.Option) []api.Option

func (*UploadOpts) Register added in v0.5.15

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

Jump to

Keyboard shortcuts

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