semgrep

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package semgrep provides an adapter to convert Semgrep JSON output to CTIS.

Package semgrep provides an adapter to convert Semgrep JSON output to CTIS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseToCTIS

func ParseToCTIS(data []byte, opts *core.ParseOptions) (*ctis.Report, error)

ParseToCTIS is a convenience function to parse Semgrep JSON to CTIS format.

Types

type Adapter

type Adapter struct{}

Adapter converts Semgrep JSON output to CTIS.

func NewAdapter

func NewAdapter() *Adapter

NewAdapter creates a new Semgrep adapter.

func (*Adapter) CanConvert

func (a *Adapter) CanConvert(input []byte) bool

CanConvert checks if the input can be converted.

func (*Adapter) Convert

func (a *Adapter) Convert(ctx context.Context, input []byte, opts *core.AdapterOptions) (*ctis.Report, error)

Convert transforms Semgrep JSON input to CTIS Report.

func (*Adapter) InputFormats

func (a *Adapter) InputFormats() []string

InputFormats returns supported input formats.

func (*Adapter) Name

func (a *Adapter) Name() string

Name returns the adapter name.

func (*Adapter) OutputFormat

func (a *Adapter) OutputFormat() string

OutputFormat returns the output format.

type SemgrepDataflow

type SemgrepDataflow struct {
	TaintSource      []SemgrepDataflowLoc `json:"taint_source,omitempty"`
	IntermediateVars []SemgrepDataflowLoc `json:"intermediate_vars,omitempty"`
	TaintSink        []SemgrepDataflowLoc `json:"taint_sink,omitempty"`
}

SemgrepDataflow contains taint tracking data.

type SemgrepDataflowLoc

type SemgrepDataflowLoc struct {
	Content  string     `json:"content,omitempty"`
	Location SemgrepLoc `json:"location,omitempty"`
}

SemgrepDataflowLoc represents a location in a dataflow trace.

type SemgrepError

type SemgrepError struct {
	Code    int    `json:"code,omitempty"`
	Level   string `json:"level,omitempty"`
	Message string `json:"message,omitempty"`
	Type    string `json:"type,omitempty"`
}

SemgrepError represents a Semgrep error.

type SemgrepExtra

type SemgrepExtra struct {
	Message     string           `json:"message"`
	Severity    string           `json:"severity"`
	Metadata    SemgrepMetadata  `json:"metadata,omitempty"`
	Lines       string           `json:"lines,omitempty"`
	IsIgnored   bool             `json:"is_ignored,omitempty"`
	Fingerprint string           `json:"fingerprint,omitempty"`
	Fix         string           `json:"fix,omitempty"`
	FixRegex    *SemgrepFixRegex `json:"fix_regex,omitempty"`
	Dataflow    *SemgrepDataflow `json:"dataflow_trace,omitempty"`
}

SemgrepExtra contains additional result information.

type SemgrepFixRegex

type SemgrepFixRegex struct {
	Regex       string `json:"regex,omitempty"`
	Replacement string `json:"replacement,omitempty"`
	Count       int    `json:"count,omitempty"`
}

SemgrepFixRegex contains regex-based fix information.

type SemgrepLoc

type SemgrepLoc struct {
	Path  string     `json:"path,omitempty"`
	Start SemgrepPos `json:"start,omitempty"`
	End   SemgrepPos `json:"end,omitempty"`
}

SemgrepLoc is a file location in a dataflow trace.

type SemgrepMetadata

type SemgrepMetadata struct {
	CWE                interface{} `json:"cwe,omitempty"`
	OWASP              interface{} `json:"owasp,omitempty"`
	Confidence         string      `json:"confidence,omitempty"`
	Impact             string      `json:"impact,omitempty"`
	Likelihood         string      `json:"likelihood,omitempty"`
	Category           string      `json:"category,omitempty"`
	Subcategory        interface{} `json:"subcategory,omitempty"`
	Technology         interface{} `json:"technology,omitempty"`
	References         interface{} `json:"references,omitempty"`
	Source             string      `json:"source,omitempty"`
	SourceRuleURL      string      `json:"source-rule-url,omitempty"`
	VulnerabilityClass interface{} `json:"vulnerability_class,omitempty"`
}

SemgrepMetadata contains rule metadata.

type SemgrepOutput

type SemgrepOutput struct {
	Results []SemgrepResult `json:"results"`
	Errors  []SemgrepError  `json:"errors,omitempty"`
	Version string          `json:"version,omitempty"`
}

SemgrepOutput is the root Semgrep JSON document.

type SemgrepPos

type SemgrepPos struct {
	Line   int `json:"line"`
	Col    int `json:"col"`
	Offset int `json:"offset,omitempty"`
}

SemgrepPos represents a position in a file.

type SemgrepResult

type SemgrepResult struct {
	CheckID string       `json:"check_id"`
	Path    string       `json:"path"`
	Start   SemgrepPos   `json:"start"`
	End     SemgrepPos   `json:"end"`
	Extra   SemgrepExtra `json:"extra"`
}

SemgrepResult represents a single Semgrep finding.

Jump to

Keyboard shortcuts

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