Documentation
¶
Overview ¶
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
Index ¶
- Constants
- Variables
- func ClearYAMLScalarInterner()
- func GetDatadogFingerprintHash(sciInfo SCIInfo, ...) string
- func GetIgnoreLines(file *FileMetadata) []int
- func Range(start, end int) (lines []int)
- func RedactURLCredentials(s string) string
- func RemoveDuplicates(lines []int) []int
- type AnalyzedPaths
- type ArgumentControl
- type ArtifactChange
- type ArtifactLocation
- type CodeLine
- type CommentCommand
- type CommentsCommands
- type Counters
- type DiffAware
- type Document
- type Documents
- type Extensions
- type ExtractedPathObject
- type FileKind
- type FileMetadata
- func (f *FileMetadata) DiscardLineInfoDocument()
- func (f *FileMetadata) EnsureLineInfoDocument(ctx context.Context) error
- func (f *FileMetadata) KnownPaths() []string
- func (f *FileMetadata) Lines() []string
- func (f *FileMetadata) LinesContaining(sub string) (indexes []int, ok bool)
- func (f *FileMetadata) LinesMatching(name string, pred func(line string) bool) (indexes []int, ok bool)
- func (f *FileMetadata) ReleasePostEvalData()
- func (f *FileMetadata) SetLazyLines()
- func (f *FileMetadata) SetLineInfoLoader(...)
- func (f *FileMetadata) SetReleaseOriginalDataAfterLineInfo(release bool)
- func (f *FileMetadata) ShallowCopy() *FileMetadata
- func (f *FileMetadata) UseLineInfoDocument(ctx context.Context, fn func(map[string]interface{}) error) error
- type FileMetadatas
- type FixContent
- type FixMessage
- type FixReplacement
- type Framework
- type HelmAttribution
- type HelmIDLineRange
- type HelmInvocationAt
- type HelmInvocations
- type Ignore
- type LineObject
- type ModuleArgument
- type ModuleAttribution
- type ModuleAttributionSARIF
- type ModulePathHop
- type PathParameters
- type QueryConfig
- type QueryMetadata
- type QueryResult
- type QueryResultSlice
- type ReportedLocation
- type RepositoryCommitInfo
- type ResolvedFile
- type ResolvedFileSplit
- type ResolvedFiles
- type ResolvedHelm
- type ResourceLine
- type ResourceLocation
- type SCIInfo
- type SarifFix
- type SarifRegion
- type SarifResourceLocation
- type Severity
- type SeveritySummary
- type SourceLocation
- type Summary
- type Times
- type Vulnerability
- type VulnerabilityLines
- type VulnerableFile
Constants ¶
const ( SuppressionJustificationIgnoreComment = "dd-iac-scan ignore" SuppressionJustificationDisableInFile = "dd-iac-scan disable" )
Suppression justifications surfaced in SARIF `suppressions[].justification`. `IgnoreComment` covers both `ignore-line` and `ignore-block` because `LinesIgnore` flattens block directives to individual line numbers, so the originating directive is no longer recoverable at suppression time.
const ( SeverityCritical = "CRITICAL" SeverityHigh = "HIGH" SeverityMedium = "MEDIUM" SeverityLow = "LOW" SeverityInfo = "INFO" SeverityTrace = "TRACE" )
Constants to describe vulnerability's severity
const (
SuppressionKindInSource = "inSource"
)
Suppression kinds map to SARIF 2.1.0 `suppressions[].kind`.
Variables ¶
var ( // DDCommentRgxp identifies dd-iac-scan inline suppression comments DDCommentRgxp = regexp.MustCompile(`(^|\n)((/{2})|#|;)*\s*dd-iac-scan\s*`) // DDGetContentCommentRgxp extracts the dd-iac-scan comment content DDGetContentCommentRgxp = regexp.MustCompile(`(^|\n)((/{2})|#|;)*\s*dd-iac-scan([^\n]*)\n`) // DDCommentRgxpYaml identifies dd-iac-scan suppression comments in YAML DDCommentRgxpYaml = regexp.MustCompile(`((/{2})|#)*\s*dd-iac-scan\s*(ignore-line|ignore-block)\s*\n*$`) )
var ( AllSeverities = []Severity{ SeverityCritical, SeverityHigh, SeverityMedium, SeverityLow, SeverityInfo, SeverityTrace, } )
Arrays to group all constants of one type
Functions ¶
func ClearYAMLScalarInterner ¶ added in v1.16.0
func ClearYAMLScalarInterner()
ClearYAMLScalarInterner drops the intern lookup after prepare. Live documents still share the interned strings; the table is not retained across scans in a long-lived process.
func GetDatadogFingerprintHash ¶ added in v1.6.0
func GetDatadogFingerprintHash( sciInfo SCIInfo, filePath, platform, resourceType, resourceName, ruleID, vulnLine, moduleCallChain string, ) string
GetDatadogFingerprintHash is the single source of truth for a finding's stable identity. It is computed once when the summary is built and reused by every report format, so the fingerprint never diverges across outputs. nolint:gocritic
func GetIgnoreLines ¶ added in v1.12.0
func GetIgnoreLines(file *FileMetadata) []int
GetIgnoreLines recomputes YAML ignore comments from OriginalData after reference resolution shifted line numbers.
func RedactURLCredentials ¶ added in v1.13.0
RedactURLCredentials strips embedded userinfo (`user`, `user:password`, `:password`) from the authority of every URL in s, whatever its scheme, leaving the rest of the string — scheme, host, port, path and query — untouched. An `@` outside the authority (`.../repo@ref`, `?user=a@b`) is not userinfo and is preserved. It is safe to call on arbitrary text such as error messages, not just on bare URLs.
func RemoveDuplicates ¶
RemoveDuplicates removes duplicate lines from a slice of lines.
Types ¶
type AnalyzedPaths ¶
type AnalyzedPaths struct {
Types []string
Exc []string
ExpectedLOC int
FilePlatform map[string]string
Inventory []string
ChartRoots []string
TotalFiles int
ContentCache map[string][]byte
}
AnalyzedPaths is a slice of types and excluded files obtained from the Analyzer
type ArgumentControl ¶ added in v1.20.0
type ArgumentControl uint8
ArgumentControl tells which side of a module call sets the value a module finding reads.
const ( // ArgumentControlUnknown is a value that reads module inputs without // tracing back to a single argument of the root call. ArgumentControlUnknown ArgumentControl = iota // ArgumentControlModule is a value the module sets without reading any of // its inputs, so it is changed in the module body. ArgumentControlModule // ArgumentControlCaller is a value set by a single argument of the root // call, so it is changed at that argument. ArgumentControlCaller )
type ArtifactChange ¶
type ArtifactChange struct {
ArtifactLocation ArtifactLocation `json:"artifactLocation"`
Replacements []FixReplacement `json:"replacements"`
}
type ArtifactLocation ¶
type ArtifactLocation struct {
URI string `json:"uri"`
}
type CodeLine ¶
CodeLine is the lines containing and adjacent to the vulnerability line with their respective positions
type CommentCommand ¶
type CommentCommand string
CommentCommand represents a command given from a comment
const ( IgnoreLine CommentCommand = "ignore-line" IgnoreBlock CommentCommand = "ignore-block" IgnoreComment CommentCommand = "ignore-comment" )
Constants to describe commands given from comments
func ProcessCommands ¶
func ProcessCommands(commands []string) CommentCommand
ProcessCommands processes a slice of commands.
type CommentsCommands ¶
CommentsCommands list of commands on a file that will be parsed
type Counters ¶
type Counters struct {
ScannedFiles int `json:"files_scanned"`
ScannedFilesLines int `json:"lines_scanned"`
ParsedFiles int `json:"files_parsed"`
ParsedFilesLines int `json:"lines_parsed"`
IgnoredFilesLines int `json:"lines_ignored"`
FailedToScanFiles int `json:"files_failed_to_scan"`
TotalQueries int `json:"queries_total"`
FailedToExecuteQueries int `json:"queries_failed_to_execute"`
FoundResources int `json:"resources_found"`
}
Counters hold information about how many files were scanned, parsed, failed to be scaned, the total of queries and how many queries failed to execute
type DiffAware ¶
type DiffAware struct {
Enabled bool `json:"enabled"`
ConfigDigest string `json:"config_digest"`
BaseSha string `json:"base_sha"`
Files string `json:"files"`
}
DiffAware contains the necessary information to be able to perform a diff between two reports
type Extensions ¶
type Extensions map[string]struct{}
Extensions represents a list of supported extensions
func (Extensions) Include ¶
func (e Extensions) Include(ext string) bool
Include returns true if an extension is included in supported extensions listed otherwise returns false
func (Extensions) MatchedFilesRegex ¶
func (e Extensions) MatchedFilesRegex() string
MatchedFilesRegex returns the regex rule to identify if an extension is supported or not
type ExtractedPathObject ¶
ExtractedPathObject is the struct that contains the path location of extracted source and a boolean to check if it is a local source
type FileKind ¶
type FileKind string
FileKind is the extension of a file
const ( KindTerraform FileKind = "TF" KindTerraformPlan FileKind = "TFPLAN" KindBICEP FileKind = "BICEP" KindDOCKER FileKind = "DOCKER" KindJSON FileKind = "JSON" KindYAML FileKind = "YAML" KindYML FileKind = "YML" KindPROTO FileKind = "PROTO" KindCOMMON FileKind = "*" KindHELM FileKind = "HELM" KindBUILDAH FileKind = "SH" KindCFG FileKind = "CFG" KindINI FileKind = "INI" )
Constants to describe what kind of file refers
type FileMetadata ¶
type FileMetadata struct {
ID string `db:"id"`
ScanID string `db:"scan_id"`
Document Document
LineInfoDocument map[string]interface{}
OriginalData string `db:"orig_data"`
Kind FileKind `db:"kind"`
FilePath string `db:"file_path"`
HelmID string
IDInfo map[int]interface{}
Commands CommentsCommands
LinesIgnore []int
ResolvedFiles map[string]ResolvedFile
LinesOriginalData *[]string
IsMinified bool
// HelmAttribution says which source actions emitted a rendered Helm
// resource whose YAML lives in named templates; nil when none is known.
HelmAttribution *HelmAttribution
// Reported, when set, is where this file's findings are reported instead of
// FilePath (see ResolvedHelm.Reported).
Reported *ReportedLocation
// Archive is the chart archive the file was rendered from, if any (see
// ResolvedHelm.Archive).
Archive string
// ModuleCallChain: synthetic rows for instantiated local modules; used in SARIF fingerprint (Terraform only).
ModuleCallChain string
// ModuleAttributions maps resourceType.resourceName to attribution when a synthetic
// document groups multiple module resources from the same file.
ModuleAttributions map[string]*ModuleAttribution
// Platform is the lowercased platform the file was classified as (e.g.
// "ansible", "kubernetes", "terraform"); "" when undetermined. Used by the
// engine to evaluate each query only against documents of its own platform.
Platform string
// contains filtered or unexported fields
}
FileMetadata is a representation of basic information and content of a file
func (*FileMetadata) DiscardLineInfoDocument ¶ added in v1.17.0
func (f *FileMetadata) DiscardLineInfoDocument()
DiscardLineInfoDocument drops a memoized line-info tree while keeping the loader so a later decode pass can rebuild it. No-op when line info was never lazily loaded: without a loader the tree could not be rebuilt, and writing the field outside the state mutex would race concurrent readers (UseLineInfoDocument reads it unlocked when no loader is configured).
func (*FileMetadata) EnsureLineInfoDocument ¶ added in v1.10.0
func (f *FileMetadata) EnsureLineInfoDocument(ctx context.Context) error
EnsureLineInfoDocument lazily materializes LineInfoDocument on first access, memoizing the result (or error) so repeat calls are cheap. Safe for concurrent callers. No-op when line info is already populated or unset.
func (*FileMetadata) KnownPaths ¶ added in v1.20.0
func (f *FileMetadata) KnownPaths() []string
KnownPaths lists the paths a file answers to in the scan's path filters; see ResolvedHelm.KnownPaths.
func (*FileMetadata) Lines ¶ added in v1.16.0
func (f *FileMetadata) Lines() []string
Lines returns the file's content split into lines, computing it lazily from OriginalData on first access when SetLazyLines was configured. Safe for concurrent callers.
func (*FileMetadata) LinesContaining ¶ added in v1.20.0
func (f *FileMetadata) LinesContaining(sub string) (indexes []int, ok bool)
LinesContaining returns the indexes of Lines() that contain sub, in ascending order, memoized per file. ok is false when the file has no lazy line state to cache on; callers then scan the lines themselves.
func (*FileMetadata) LinesMatching ¶ added in v1.20.0
func (f *FileMetadata) LinesMatching(name string, pred func(line string) bool) (indexes []int, ok bool)
LinesMatching returns the indexes of Lines() for which pred reports true, in ascending order, memoized per file under name. pred must always give the same answer for a given name. ok is false when the file has no lazy line state to cache on; callers then scan the lines themselves.
func (*FileMetadata) ReleasePostEvalData ¶ added in v1.16.0
func (f *FileMetadata) ReleasePostEvalData()
ReleasePostEvalData drops OriginalData and LinesOriginalData after eval — detectors have run and line-info documents are lazily reparsed — reclaiming the raw input content before the report phase.
func (*FileMetadata) SetLazyLines ¶ added in v1.16.0
func (f *FileMetadata) SetLazyLines()
SetLazyLines configures on-demand computation of LinesOriginalData from OriginalData on first access via Lines().
func (*FileMetadata) SetLineInfoLoader ¶ added in v1.10.0
func (f *FileMetadata) SetLineInfoLoader( loader func(ctx context.Context, fm *FileMetadata) (map[string]interface{}, error), )
SetLineInfoLoader configures on-demand reconstruction of LineInfoDocument.
func (*FileMetadata) SetReleaseOriginalDataAfterLineInfo ¶ added in v1.16.0
func (f *FileMetadata) SetReleaseOriginalDataAfterLineInfo(release bool)
SetReleaseOriginalDataAfterLineInfo instructs EnsureLineInfoDocument to release OriginalData after populating LineInfoDocument and LinesOriginalData (for non-Terraform kinds).
func (*FileMetadata) ShallowCopy ¶ added in v1.10.0
func (f *FileMetadata) ShallowCopy() *FileMetadata
ShallowCopy returns a copy of f with independent lazy line-info memoization.
func (*FileMetadata) UseLineInfoDocument ¶ added in v1.17.0
func (f *FileMetadata) UseLineInfoDocument(ctx context.Context, fn func(map[string]interface{}) error) error
UseLineInfoDocument loads line info (when configured) and runs fn against it while holding the file's line-info lock, so concurrent decoders serialize on the file. The decode loop owns discarding trees between files (see DiscardLineInfoDocument); fn must not retain the map.
type FileMetadatas ¶
type FileMetadatas []*FileMetadata
FileMetadatas is a slice of FileMetadata pointers
func (FileMetadatas) Combine ¶
func (m FileMetadatas) Combine(ctx context.Context, lineInfo bool) Documents
Combine merge documents from FileMetadatas using the ID as reference for Document ID and FileName as reference for file
func (FileMetadatas) ToMap ¶
func (m FileMetadatas) ToMap() map[string]*FileMetadata
ToMap creates a map of FileMetadatas, which the key is the FileMetadata ID and the value is a pointer to the FileMetadata
type FixContent ¶
type FixContent struct {
Text string `json:"text"`
}
type FixMessage ¶
type FixMessage struct {
Text string `json:"text"`
}
type FixReplacement ¶
type FixReplacement struct {
DeletedRegion SarifRegion `json:"deletedRegion"`
InsertedContent FixContent `json:"insertedContent,omitempty"`
}
type Framework ¶
type Framework struct {
Framework string `json:"framework"`
FrameworkVersion string `json:"framework_version"`
Requirement string `json:"requirement"`
Control string `json:"control"`
}
Framework represents a framework mapping for a query
type HelmAttribution ¶ added in v1.20.0
type HelmAttribution struct {
Invocations HelmInvocations
// RenderedContent is the rendered document the invocations' lines refer
// to, to find which rendered line a finding is on.
RenderedContent string
}
HelmAttribution ties a rendered Helm resource back to the source actions that emitted it.
func NewHelmAttribution ¶ added in v1.20.0
func NewHelmAttribution(invocations HelmInvocations, renderedContent string) *HelmAttribution
NewHelmAttribution returns the attribution of a rendered document, or nil when there is no rendered document to resolve keys on. A document no invocation emitted is attributed too, with no invocations: its keys are still resolved on the rendered document.
func (*HelmAttribution) First ¶ added in v1.20.0
func (a *HelmAttribution) First() ResourceLine
First is the position of the invocation that emitted the start of the document, or the zero position when there is no attribution.
type HelmIDLineRange ¶ added in v1.14.0
HelmIDLineRange is the inclusive source-line range owned by a Helm marker.
type HelmInvocationAt ¶ added in v1.20.0
type HelmInvocationAt struct {
// RenderedLine is a 1-based line of the rendered document as stored, ID
// stamps included.
RenderedLine int
// RenderedEnd is the rendered line after the last one the action emitted,
// or 0 when unknown: the output then runs up to an unknown later line.
RenderedEnd int
// Position is in the template as written, without ID stamps: a 1-based
// line and a 0-based byte column.
Position ResourceLine
}
HelmInvocationAt is an include-like action that emitted part of a rendered Helm document: the rendered lines from RenderedLine up to RenderedEnd came from the action at Position.
type HelmInvocations ¶ added in v1.20.0
type HelmInvocations []HelmInvocationAt
HelmInvocations are the invocations that emitted a rendered Helm document, in order of the rendered lines they emitted.
func (HelmInvocations) Containing ¶ added in v1.20.0
func (h HelmInvocations) Containing(renderedLine int) (HelmInvocationAt, bool)
Containing is the invocation whose output is known to hold renderedLine.
func (HelmInvocations) First ¶ added in v1.20.0
func (h HelmInvocations) First() ResourceLine
First is the invocation that emitted the start of the document, or the zero position when none is known.
func (HelmInvocations) KnownBefore ¶ added in v1.20.0
func (h HelmInvocations) KnownBefore(renderedLine int) bool
KnownBefore reports whether every invocation starting at or before renderedLine has a known extent, so the lines up to it are all accounted for.
type Ignore ¶
type Ignore struct {
// Lines is the lines to ignore
Lines []int
}
Ignore is a struct that holds the lines to ignore
type LineObject ¶
type LineObject struct {
Line int `json:"_dd_line"`
Arr []map[string]*LineObject `json:"_dd_arr,omitempty"`
}
LineObject is the struct that will hold line information for each key
type ModuleArgument ¶ added in v1.20.0
type ModuleArgument struct {
LineStart int
LineEnd int
Control ArgumentControl
CallSite SourceLocation
}
ModuleArgument binds a line range of a module resource whose value reads module inputs to who controls it. CallSite is the root call argument setting it when Control is ArgumentControlCaller.
type ModuleAttribution ¶ added in v1.12.1
type ModuleAttribution struct {
Source string `json:"source,omitempty"`
SourceType string `json:"source_type,omitempty"`
Version string `json:"version,omitempty"`
DependencyType string `json:"dependency_type,omitempty"`
CallSite SourceLocation `json:"call_site,omitempty"`
ModuleCodeLocation SourceLocation `json:"code_location,omitempty"`
ModulePath []ModulePathHop `json:"module_path,omitempty"`
ModuleCodeOwned bool `json:"-"`
Arguments []ModuleArgument `json:"-"`
ArgumentControl ArgumentControl `json:"-"`
}
ModuleAttribution carries module provenance for instantiated Terraform findings.
CallSite is the call-site declaration the finding anchors on (SARIF primary location, IDE code bit): the root call argument setting the finding's value when it traces back to one, the root call's source argument otherwise.
ModulePath lists the module calls from the root file down to the module holding the flagged resource, root first and never empty.
ModuleCodeLocation is the flagged location inside the module loaded by the last hop. Its file name is relative to the root of Source, or to the scanned repository when SourceType is local.
Source, SourceType and Version identify the repository or package holding that file: the package root without its subdirectory, the resolved registry version or the declared git ref (the resolved commit when none is declared). Source and Version are empty for local modules.
DependencyType is direct for a single call and transitive for more.
ArgumentControl tells who sets the flagged value; only a value the module sets can be fixed in the module body without changing it for every caller.
type ModuleAttributionSARIF ¶ added in v1.12.1
type ModuleAttributionSARIF struct {
Source string `json:"source,omitempty"`
SourceType string `json:"source_type,omitempty"`
Version string `json:"version,omitempty"`
DependencyType string `json:"dependency_type,omitempty"`
ModuleCodeLocation SourceLocation `json:"code_location,omitempty"`
ModulePath []ModulePathHop `json:"module_path"`
}
ModuleAttributionSARIF is the properties.module payload emitted for instantiated findings. ModulePath lists the module calls from the root file down to the module holding the flagged resource, ModuleCodeLocation is the flagged location inside that module, and Source, SourceType and Version identify the repository or package holding it.
func ModuleAttributionForSARIF ¶ added in v1.12.1
func ModuleAttributionForSARIF(attr *ModuleAttribution) *ModuleAttributionSARIF
type ModulePathHop ¶ added in v1.12.1
type ModulePathHop struct {
Name string `json:"name,omitempty"`
Source string `json:"source,omitempty"`
SourceType string `json:"source_type,omitempty"`
Version string `json:"version,omitempty"`
CodeLocation SourceLocation `json:"code_location,omitempty"`
}
ModulePathHop is one module call on the path to a finding. Name and CodeLocation describe the module block as written in the caller's file, named from the scanned repository for the first hop and from the package the previous hop loaded otherwise. Source, SourceType and Version describe the module the block loads; a local module's source is its directory relative to the scanned repository, not the string as written.
type PathParameters ¶
type PathParameters struct {
ScannedPaths []string
PathExtractionMap map[string]ExtractedPathObject
}
PathParameters - structure wraps the required fields for temporary path translation
type QueryConfig ¶
QueryConfig is a struct that contains the fileKind and platform of the rego query
type QueryMetadata ¶
type QueryMetadata struct {
InputData string
Query string
Content string
Metadata map[string]interface{}
Platform string
CWE string
// special field for generic queries
// represents how many queries are aggregated into a single rego file
Aggregation int
Experimental bool
}
QueryMetadata is a representation of general information about a query
type QueryResult ¶
type QueryResult struct {
QueryName string `json:"query_name"`
QueryID string `json:"query_id"`
LegacyQueryID string `json:"legacy_query_id"`
QueryURI string `json:"query_url"`
Severity Severity `json:"severity"`
Platform string `json:"platform"`
CWE string `json:"cwe,omitempty"`
CloudProvider string `json:"cloud_provider,omitempty"`
Category string `json:"category"`
Experimental bool `json:"experimental"`
Description string `json:"description"`
DescriptionID string `json:"description_id"`
CISDescriptionIDFormatted string `json:"cis_description_id,omitempty"`
CISDescriptionTitle string `json:"cis_description_title,omitempty"`
CISDescriptionTextFormatted string `json:"cis_description_text,omitempty"`
CISDescriptionID string `json:"cis_description_id_raw,omitempty"`
CISDescriptionText string `json:"cis_description_text_raw,omitempty"`
CISRationaleText string `json:"cis_description_rationale,omitempty"`
CISBenchmarkName string `json:"cis_benchmark_name,omitempty"`
CISBenchmarkVersion string `json:"cis_benchmark_version,omitempty"`
Frameworks []Framework `json:"frameworks,omitempty"`
Files []VulnerableFile `json:"files"`
}
QueryResult contains a query that tested positive ID, name, severity and a list of files that tested vulnerable
type QueryResultSlice ¶
type QueryResultSlice []QueryResult
QueryResultSlice is a slice of QueryResult
type ReportedLocation ¶ added in v1.20.0
type ReportedLocation struct {
Path string
Line int
// LineText and Snippet are the content around Line in Path.
LineText string
Snippet []CodeLine
}
ReportedLocation replaces the location of the findings of a file whose own path and lines cannot be pointed at, with a place in the repository that can.
func (*ReportedLocation) Apply ¶ added in v1.20.0
func (r *ReportedLocation) Apply(v *Vulnerability)
Apply moves v to the reported location. Positions that belong to the file the finding was detected in no longer mean anything there and are cleared, and so is the remediation: it edits the detected file, not the reported one.
func (*ReportedLocation) PathOr ¶ added in v1.20.0
func (r *ReportedLocation) PathOr(detected string) string
PathOr is the reported path, or detected when nothing is reported elsewhere.
type RepositoryCommitInfo ¶
type ResolvedFile ¶
ResolvedFile is a struct that contains the information of a resolved file, the path and the content in bytes of the file
type ResolvedFileSplit ¶
ResolvedFileSplit is a struct that contains the information of a resolved file, the path and the lines of the file
type ResolvedFiles ¶
type ResolvedFiles struct {
File []ResolvedHelm
Excluded []string
// Covered lists the Helm template files the render loaded, at the paths they
// are reported at, including those that rendered to nothing. A raw copy of one
// is not scanned: the render already covered it.
Covered []string
}
ResolvedFiles keeps the information of all file/template resolved
type ResolvedHelm ¶
type ResolvedHelm struct {
FileName string
// Reported is where findings are reported when FileName is not a place in
// the repository: a dependency packaged as an archive renders from unpacked
// file names that exist only inside the archive.
Reported *ReportedLocation
// Archive is the chart archive in the repository the file was rendered from,
// when it is a packaged dependency, so that path filters can name it.
Archive string
Content []byte
OriginalData []byte
SplitID string
SourceDocumentIndex int
// HelmInvocations lists every invocation that emitted part of Content, in
// order, at their positions in the template as written.
HelmInvocations HelmInvocations
IDInfo map[int]interface{}
IsCRD bool
}
ResolvedHelm keeps the information of a file/template resolved
func (*ResolvedHelm) KnownPaths ¶ added in v1.20.0
func (r *ResolvedHelm) KnownPaths() []string
KnownPaths lists the paths a rendered file answers to in the scan's path filters: the file itself, where its findings are reported, and the chart archive it was rendered from. Every filter checks this same list.
type ResourceLine ¶
ResourceLine is the line information of the resource with their respective positions
type ResourceLocation ¶
type ResourceLocation struct {
Start ResourceLine
End ResourceLine
}
ResourceLocation is the line information of the resource with their respective start and end positions
type SCIInfo ¶
type SCIInfo struct {
DiffAware DiffAware
RepositoryDir string
RepositoryCommitInfo RepositoryCommitInfo `json:"repository_commit_info"`
OrgId int64 `json:"org_id"`
}
type SarifFix ¶
type SarifFix struct {
ArtifactChanges []ArtifactChange `json:"artifactChanges"`
Description FixMessage `json:"description"`
}
type SarifRegion ¶
type SarifResourceLocation ¶
type SeveritySummary ¶
type SeveritySummary struct {
ScanID string `json:"scan_id"`
SeverityCounters map[Severity]int `json:"severity_counters"`
TotalCounter int `json:"total_counter"`
TotalBOMResources int `json:"total_bom_resources"`
}
SeveritySummary contains scans' result numbers, how many vulnerabilities of each severity was detected
type SourceLocation ¶ added in v1.12.1
type SourceLocation struct {
Filename string `json:"filename,omitempty"`
LineStart int `json:"line_start,omitempty"`
LineEnd int `json:"line_end,omitempty"`
ColumnStart int `json:"column_start,omitempty"`
ColumnEnd int `json:"column_end,omitempty"`
}
SourceLocation is a filename plus an inclusive line/column range.
type Summary ¶
type Summary struct {
Version string `json:"kics_version,omitempty"`
Counters
SeveritySummary
Times
ScannedPaths []string `json:"paths"`
Queries QueryResultSlice `json:"queries"`
Bom QueryResultSlice `json:"bill_of_materials,omitempty"`
FilePaths map[string]string `json:"-"`
}
Summary is a report of a single scan
func CreateSummary ¶
func CreateSummary(ctx context.Context, counters Counters, vulnerabilities []Vulnerability, scanID string, pathExtractionMap map[string]ExtractedPathObject, repoDir string, sciInfo SCIInfo) Summary
CreateSummary creates a report for a single scan, based on its scanID
func (*Summary) WithoutSuppressed ¶ added in v1.3.2
WithoutSuppressed returns a shallow copy of the Summary with suppressed VulnerableFile entries removed from Queries and Bom; QueryResult entries whose Files become empty after filtering are dropped entirely.
SARIF reporting must continue to use the original Summary so suppressed findings can be emitted under the SARIF `suppressions` array. Every other report format (json, csv, gitlab_sast, sonarqube, asff, junit, pdf, html, cyclonedx, code_climate) has no notion of suppressions and would otherwise expose ignored findings that the CLI counters already filtered out.
type Vulnerability ¶
type Vulnerability struct {
ID int `json:"id"`
ScanID string `db:"scan_id" json:"-"`
FileID string `db:"file_id" json:"-"`
FileName string `db:"file_name" json:"fileName"`
QueryID string `db:"query_id" json:"queryID"`
LegacyQueryID string `db:"legacy_query_id" json:"legacyQueryID"`
QueryName string `db:"query_name" json:"queryName"`
QueryURI string `json:"-"`
Category string `json:"category"`
Experimental bool `json:"experimental"`
Description string `json:"description"`
DescriptionID string `json:"descriptionID"`
Platform string `db:"platform" json:"platform"`
CWE string `db:"cwe" json:"cwe"`
Severity Severity `json:"severity"`
Line int `json:"line"`
VulnerabilityLocation ResourceLocation `json:"resourceLocation"`
VulnLines *[]CodeLine `json:"vulnLines"`
ResourceType string `db:"resource_type" json:"resourceType"`
ResourceName string `db:"resource_name" json:"resourceName"`
SearchKey string `db:"search_key" json:"searchKey"`
SearchLine int `db:"search_line" json:"searchLine"`
SearchValue string `db:"search_value" json:"searchValue"`
Value *string `db:"value" json:"value"`
CloudProvider string `json:"cloud_provider"`
Remediation string `db:"remediation" json:"remediation"`
RemediationType string `db:"remediation_type" json:"remediation_type"`
RemediationLocation ResourceLocation `json:"remediationLocation"`
QueryDuration time.Duration `json:"query_duration"`
LineWithVulnerability string `json:"lineWithVulnerability"`
ResourceSource string `json:"resourceSource"`
FileSource []string `json:"fileSource"`
BlockLocation ResourceLocation `json:"blockLocation"`
Frameworks []Framework `json:"frameworks,omitempty"`
// IsSuppressed marks a finding as kept-for-SARIF but excluded from
// severity counters; the kind/justification map directly to SARIF
// `suppressions[]`.
IsSuppressed bool `json:"isSuppressed,omitempty"`
SuppressionKind string `json:"suppressionKind,omitempty"`
SuppressionJustification string `json:"suppressionJustification,omitempty"`
// ModuleCallChain: local-module instantiation path; empty for root resources; folded into fingerprint.
ModuleCallChain string `json:"moduleCallChain,omitempty"`
// ModuleAttribution: provenance for instantiated module findings, serialized
// so content-push consumers can anchor them on the call site like SARIF does.
ModuleAttribution *ModuleAttribution `json:"moduleAttribution,omitempty"`
// DetectedFileName and DetectedLineWithVulnerability are where the finding
// was detected when it is reported at another place (see ReportedLocation).
// They stay its identity: every file of a packaged dependency is reported
// at one declaration line.
DetectedFileName string `json:"-"`
DetectedLineWithVulnerability string `json:"-"`
}
Vulnerability is a representation of a detected vulnerability in scanned files after running a query
func (*Vulnerability) Identity ¶ added in v1.20.0
func (v *Vulnerability) Identity() (fileName, lineWithVulnerability string)
Identity returns the file and line text that tell v apart from other findings of the same rule and resource: where it was detected.
type VulnerabilityLines ¶
type VulnerabilityLines struct {
Line int
VulnLines *[]CodeLine
LineWithVulnerability string
ResolvedFile string
VulnerablilityLocation ResourceLocation
RemediationLocation ResourceLocation
ResourceSource string
FileSource []string
BlockLocation ResourceLocation
}
VulnerabilityLines is the representation of the found line for issue
type VulnerableFile ¶
type VulnerableFile struct {
FileName string `json:"file_name"`
Fingerprint string `json:"fingerprint,omitempty"`
Line int `json:"line"`
ResourceLocation ResourceLocation `json:"resource_location"`
VulnLines *[]CodeLine `json:"-"`
ResourceType string `json:"resource_type,omitempty"`
ResourceName string `json:"resource_name,omitempty"`
SearchKey string `json:"search_key"`
SearchLine int `json:"search_line"`
SearchValue string `json:"search_value"`
Value *string `json:"value,omitempty"`
Remediation string `json:"remediation,omitempty"`
RemediationType string `json:"remediation_type,omitempty"`
RemediationLocation ResourceLocation `json:"remediation_location,omitempty"`
LineWithVulnerability string `json:"line_content,omitempty"`
ResourceSource string `json:"resource_source,omitempty"`
FileSource []string `json:"file_source,omitempty"`
BlockLocation ResourceLocation `json:"block_location,omitempty"`
// Suppression metadata; see Vulnerability.IsSuppressed.
IsSuppressed bool `json:"is_suppressed,omitempty"`
SuppressionKind string `json:"suppression_kind,omitempty"`
SuppressionJustification string `json:"suppression_justification,omitempty"`
// ModuleCallChain: local-module call path; empty for root; included in fingerprint.
ModuleCallChain string `json:"module_call_chain,omitempty"`
// ModuleAttribution: declaration and body locations for instantiated module findings.
ModuleAttribution *ModuleAttribution `json:"-"`
}
VulnerableFile contains information of a vulnerable file and where the vulnerability was found