transformer

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNilClock is thrown when the option setclock is called with empty clock
	ErrNilClock = errors.Errorf("invalid nil clock")
	// ErrEmptyTarget is thrown when the option set target is called with empty target
	ErrEmptyTarget = errors.Errorf("invalid empty target")
	// ErrEmptyRawOutfilePath is thrown when the option raw outfile path is called with empty path
	ErrEmptyRawOutfilePath = errors.Errorf("invalid raw out file path")
	// ErrEmptyRawOutfileContents is thrown when the option raw outfile contents is called with empty contents
	ErrEmptyRawOutfileContents = errors.Errorf("empty raw out file contents")
	// ErrBadTargetType is thrown when the option set target type is called with an unspecified or empty target type
	ErrBadTargetType = errors.New("invalid empty target type")

	// ErrNoLineRange is thrown when bandit produces a finding without a line range
	ErrNoLineRange = errors.Errorf("bandit result does not contain a line range")
	// ErrBadDataSource is thrown when bandit produces a finding that cannot have a datasource (e.g. no filename)
	ErrBadDataSource = errors.Errorf("failed to marshal data source to JSON")
)

Functions

This section is empty.

Types

type BanditCWE

type BanditCWE struct {
	ID   int    `json:"id,omitempty"`
	Link string `json:"link,omitempty"`
}

BanditCWE represents how Bandit shows a CWE.

type BanditOut

type BanditOut struct {
	Errors      []any           `json:"errors,omitempty"`
	GeneratedAt time.Time       `json:"generated_at,omitempty"`
	Metrics     any             `json:"metrics,omitempty"`
	Results     []*BanditResult `json:"results"`
}

BanditOut represents the output of a bandit run.

type BanditResult

type BanditResult struct {
	Code            string    `json:"code,omitempty"`
	ColOffset       int       `json:"col_offset,omitempty"`
	EndColOffset    int       `json:"end_col_offset,omitempty"`
	Filename        string    `json:"filename,omitempty"`
	IssueConfidence string    `json:"issue_confidence,omitempty"`
	IssueCwe        BanditCWE `json:"issue_cwe,omitempty"`
	IssueSeverity   string    `json:"issue_severity,omitempty"`
	IssueText       string    `json:"issue_text,omitempty"`
	LineNumber      int       `json:"line_number,omitempty"`
	LineRange       []int     `json:"line_range,omitempty"`
	MoreInfo        string    `json:"more_info,omitempty"`
	TestID          string    `json:"test_id,omitempty"`
	TestName        string    `json:"test_name,omitempty"`
}

BanditResult represents a Bandit Result.

type BanditTransformer

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

BanditTransformer represents the bandit output parser

func New

New returns a new bandit transformer.

func (*BanditTransformer) Transform

Transform transforms raw sarif findings into ocsf vulnerability findings.

type BanditTransformerOption

type BanditTransformerOption func(b *BanditTransformer) error

BanditTransformerOption allows customising the transformer.

func BanditRawOutFileContents

func BanditRawOutFileContents(contents []byte) BanditTransformerOption

BanditRawOutFileContents allows customising the underlying raw out file contents.

func BanditRawOutFilePath

func BanditRawOutFilePath(path string) BanditTransformerOption

BanditRawOutFilePath allows customising the underlying raw out file path.

func BanditTransformerWithClock

func BanditTransformerWithClock(clock clockwork.Clock) BanditTransformerOption

BanditTransformerWithClock allows customising the underlying clock.

func BanditTransformerWithTarget

func BanditTransformerWithTarget(target ocsffindinginfo.DataSource_TargetType) BanditTransformerOption

BanditTransformerWithTarget allows customising the underlying target type.

Jump to

Keyboard shortcuts

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