Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KnownSignalNames ¶
func NormalizeSignalName ¶
Types ¶
type DiffResult ¶
type DiffResult struct {
SchemaVersion string `json:"schemaVersion"`
Target Target `json:"target"`
Signals []Signal `json:"signals"`
Score int `json:"score"`
Summary string `json:"summary"`
Disabled bool `json:"disabled,omitempty"`
}
DiffResult holds the complete comparison between two package versions.
func Compare ¶
func Compare(target Target, from, to *PackageContents, suspiciousAPIs []string) *DiffResult
Compare runs all heuristics against two package versions and returns a DiffResult.
type Heuristic ¶
type Heuristic func(from, to *PackageContents) []Signal
Heuristic is a function that analyzes two package versions and returns signals.
type PackageContents ¶
type PackageContents struct {
PackageJSON map[string]any // parsed package.json
Files map[string][]byte // relative path -> content
FileList []string // sorted list of file paths
}
PackageContents represents the expanded contents of a package tarball.
func FetchPackageContents ¶
func FetchPackageContents(ctx context.Context, root, name, version string) (*PackageContents, error)
FetchPackageContents downloads and expands a package tarball from the registry.
func LoadLocalContents ¶
func LoadLocalContents(dir string) (*PackageContents, error)
LoadLocalContents reads package contents from a local directory.
type Signal ¶
type Signal struct {
ID string `json:"id"`
Severity model.Severity `json:"severity"`
Title string `json:"title"`
Message string `json:"message"`
File string `json:"file,omitempty"`
Line int `json:"line,omitempty"`
Evidence map[string]any `json:"evidence,omitempty"`
}
Signal represents a single risk signal found during diff comparison.
Click to show internal directories.
Click to hide internal directories.