result

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SeverityColor

func SeverityColor(s Severity) string

SeverityColor returns the ANSI color code associated with the severity.

Types

type Issue

type Issue struct {
	ID          string   `json:"id"`            // Unique identifier of the rule (e.g., "sql-injection")
	Title       string   `json:"title"`         // Short title of the issue
	Description string   `json:"description"`   // Detailed description of the issue
	Severity    Severity `json:"severity"`      // Issue severity
	Location    Location `json:"location"`      // Where the issue was found
	Category    string   `json:"category"`      // Category (security, performance, style, etc.)
	Suggestion  string   `json:"suggestion"`    // Suggested fix
	References  []string `json:"references"`    // Links to documentation or references
	FalsePos    bool     `json:"falsePositive"` // Marked as false positive (optional)
	Ignored     bool     `json:"ignored"`       // Manually ignored via CLI or config
}

Issue represents a single detected vulnerability, warning or code smell.

func (Issue) IsCritical

func (i Issue) IsCritical() bool

IsCritical returns true if severity is CRITICAL.

func (Issue) IsIgnored

func (i Issue) IsIgnored() bool

IsIgnored returns true if the issue is manually ignored or marked as false positive.

func (Issue) IsSecurity

func (i Issue) IsSecurity() bool

IsSecurity returns true if the issue is of security-related category.

func (Issue) String

func (i Issue) String() string

String returns a concise human-readable summary of the issue.

type Location

type Location struct {
	File        string `json:"file"`     // Path to the file
	Line        int    `json:"line"`     // Line number in the file (1-based)
	Column      int    `json:"column"`   // Column number in the line (1-based)
	Function    string `json:"function"` // Function or method name (optional)
	PackagePath string `json:"package"`  // Go package path (e.g., github.com/user/project/foo)
}

Location represents the position in the source code where an issue was found.

func NewLocationFromPos

func NewLocationFromPos(pos token.Position, fallbackFile, fallbackPkg string) Location

NewLocationFromPos creates a Location from a token.Position and optional metadata.

func (Location) String

func (l Location) String() string

String returns a human-readable string for the location.

type Severity

type Severity string

Severity represents the level of importance or impact of an issue.

const (
	SeverityCritical Severity = "CRITICAL"
	SeverityHigh     Severity = "HIGH"
	SeverityMedium   Severity = "MEDIUM"
	SeverityLow      Severity = "LOW"
	SeverityInfo     Severity = "INFO"
	SeverityUnknown  Severity = "UNKNOWN"
)

func AllSeverities

func AllSeverities() []Severity

AllSeverities returns the full list of valid severity levels in order.

func ParseSeverity

func ParseSeverity(s string) Severity

ParseSeverity parses a string into a Severity value. Falls back to SeverityUnknown.

func (Severity) Colored

func (s Severity) Colored() string

Colored returns the colored string of severity for CLI output.

func (Severity) Compare added in v0.2.1

func (s Severity) Compare(other Severity) int

Compare returns -1 if s < other, 0 if s == other, 1 if s > other

func (Severity) GreaterThanOrEqual added in v0.2.1

func (s Severity) GreaterThanOrEqual(other Severity) bool

GreaterThanOrEqual returns true if s >= other

func (Severity) String

func (s Severity) String() string

String returns the string representation of the severity.

Jump to

Keyboard shortcuts

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