codeclient

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 2 Imported by: 2

README

code-client-go

A library that exposes scanning capabilities for Snyk Code that can be used in the Snyk CLI as well as Snyk IDE plugins using the Snyk Language Server.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArtifactLocation

type ArtifactLocation struct {
	URI       string `json:"uri"`
	URIBaseID string `json:"uriBaseId"`
}

type Category added in v0.2.0

type Category string
const (
	WontFix         Category = "wont-fix"
	NotVulnerable   Category = "not-vulnerable"
	TemporaryIgnore Category = "temporary-ignore"
)

type CodeFlow

type CodeFlow struct {
	ThreadFlows []ThreadFlow `json:"threadFlows"`
}

type DefaultConfiguration

type DefaultConfiguration struct {
	Level string `json:"level"`
}

type Driver

type Driver struct {
	Name            string `json:"name"`
	SemanticVersion string `json:"semanticVersion"`
	Version         string `json:"version"`
	Rules           []Rule `json:"rules"`
}

type ExampleCommitFix

type ExampleCommitFix struct {
	CommitURL string `json:"commitURL"`
	Lines     []struct {
		Line       string `json:"line"`
		LineNumber int    `json:"lineNumber"`
		LineChange string `json:"lineChange"`
	} `json:"lines"`
}

type Fingerprints

type Fingerprints struct {
	Num0 string `json:"0"`
	Num1 string `json:"1"`
}

type Help

type Help struct {
	Markdown string `json:"markdown"`
	Text     string `json:"text"`
}

type IgnoredBy added in v0.2.0

type IgnoredBy struct {
	Name  string  `json:"name"`
	Email *string `json:"email"`
}

type Location

type Location struct {
	ID               int              `json:"id"`
	PhysicalLocation PhysicalLocation `json:"PhysicalLocation"`
}

type PhysicalLocation

type PhysicalLocation struct {
	ArtifactLocation ArtifactLocation `json:"ArtifactLocation"`
	Region           region           `json:"region"`
}

type Result

type Result struct {
	RuleID       string           `json:"ruleId"`
	RuleIndex    int              `json:"ruleIndex"`
	Level        string           `json:"level"`
	Message      ResultMessage    `json:"message"`
	Locations    []Location       `json:"locations"`
	Fingerprints Fingerprints     `json:"Fingerprints"`
	CodeFlows    []CodeFlow       `json:"codeFlows"`
	Properties   ResultProperties `json:"properties"`
	Suppressions []Suppression    `json:"suppressions"`
}

type ResultMessage

type ResultMessage struct {
	Text      string   `json:"text"`
	Markdown  string   `json:"markdown"`
	Arguments []string `json:"arguments"`
}

type ResultProperties

type ResultProperties struct {
	PriorityScore        int `json:"priorityScore"`
	PriorityScoreFactors []struct {
		Label bool   `json:"label"`
		Type  string `json:"type"`
	} `json:"priorityScoreFactors"`
	IsAutofixable bool `json:"isAutofixable"`
}

type Rule

type Rule struct {
	ID                   string               `json:"id"`
	Name                 string               `json:"name"`
	ShortDescription     ShortDescription     `json:"ShortDescription"`
	DefaultConfiguration DefaultConfiguration `json:"DefaultConfiguration"`
	Help                 Help                 `json:"Help"`
	Properties           RuleProperties       `json:"properties"`
}

type RuleProperties

type RuleProperties struct {
	Tags             []string `json:"tags"`
	ShortDescription struct {
		Text string `json:"text"`
	} `json:"ShortDescription"`

	Help struct {
		Markdown string `json:"markdown"`
		Text     string `json:"text"`
	} `json:"Help"`

	Categories                []string           `json:"categories"`
	ExampleCommitFixes        []ExampleCommitFix `json:"exampleCommitFixes"`
	ExampleCommitDescriptions []string           `json:"exampleCommitDescriptions"`
	Precision                 string             `json:"precision"`
	RepoDatasetSize           int                `json:"repoDatasetSize"`
	Cwe                       []string           `json:"cwe"`
}

type Run

type Run struct {
	Tool       Tool          `json:"Tool"`
	Results    []Result      `json:"results"`
	Properties RunProperties `json:"RuleProperties"`
}

type RunProperties added in v0.2.0

type RunProperties struct {
	Coverage []struct {
		Files       int    `json:"files"`
		IsSupported bool   `json:"isSupported"`
		Lang        string `json:"lang"`
	} `json:"coverage"`
}

type SarifResponse

type SarifResponse struct {
	Type     string  `json:"type"`
	Progress float64 `json:"progress"`
	Status   string  `json:"status"`
	Timing   struct {
		FetchingCode int `json:"fetchingCode"`
		Queue        int `json:"queue"`
		Analysis     int `json:"analysis"`
	} `json:"timing"`
	Coverage []struct {
		Files       int    `json:"files"`
		IsSupported bool   `json:"isSupported"`
		Lang        string `json:"lang"`
	} `json:"coverage"`
	Sarif struct {
		Schema  string `json:"$schema"`
		Version string `json:"version"`
		Runs    []Run  `json:"runs"`
	} `json:"sarif"`
}

SarifResponse matches the spec in https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/schemas/sarif-schema-2.1.0.json

func UploadAndAnalyze

func UploadAndAnalyze() (*SarifResponse, error)

UploadAndAnalyze returns a fake SARIF response for testing. Use target-service to run analysis on.

type ShortDescription

type ShortDescription struct {
	Text string `json:"text"`
}

type Suppression added in v0.2.0

type Suppression struct {
	Justification string                `json:"justification"`
	Properties    SuppressionProperties `json:"properties"`
}

type SuppressionProperties added in v0.2.0

type SuppressionProperties struct {
	Category   Category  `json:"category"`
	Expiration *string   `json:"expiration"`
	IgnoredOn  string    `json:"ignoredOn"` // https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/sarif-v2.1.0-errata01-os-complete.html#_Toc141790703
	IgnoredBy  IgnoredBy `json:"ignoredBy"`
}

type ThreadFlow

type ThreadFlow struct {
	Locations []ThreadFlowLocation `json:"locations"`
}

type ThreadFlowLocation

type ThreadFlowLocation struct {
	Location Location `json:"Location"`
}

type Tool

type Tool struct {
	Driver Driver `json:"Driver"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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