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.
Index ¶
- Variables
- func Analyze(ctx context.Context, a *Analyzer) (model.AnalyzedPaths, error)
- func ClassifyFile(ctx context.Context, fsys vfs.FS, path string, content []byte, ...) string
- func ClassifyParsedFile(ctx context.Context, fsys vfs.FS, platforms []string, kind model.FileKind, ...) string
- func PlatformForKind(kind model.FileKind) (string, bool)
- func PossibleFileTypes() []string
- type Analyzer
- type Parameters
Constants ¶
This section is empty.
Variables ¶
var ( OpenAPIRegex = regexp.MustCompile(`("(openapi|swagger)"|(openapi|swagger))\s*:`) OpenAPIRegexInfo = regexp.MustCompile(`("info"|info)\s*:`) OpenAPIRegexPath = regexp.MustCompile(`("(paths|components|webhooks)"|(paths|components|webhooks))\s*:`) )
move the openApi regex to public to be used on file.go openAPIRegex - Regex that finds OpenAPI defining property "openapi" or "swagger" openAPIRegexInfo - Regex that finds OpenAPI defining property "info" openAPIRegexPath - Regex that finds OpenAPI defining property "paths", "components", or "webhooks" (from 3.1.0) cloudRegex - Regex that finds CloudFormation defining property "Resources" k8sRegex - Regex that finds Kubernetes defining property "apiVersion" k8sRegexKind - Regex that finds Kubernetes defining property "kind" k8sRegexMetadata - Regex that finds Kubernetes defining property "metadata" k8sRegexSpec - Regex that finds Kubernetes defining property "spec"
Functions ¶
func Analyze ¶
nolint:gocyclo Analyze will go through the slice paths given and determine what type of queries should be loaded should be loaded based on the extension of the file and the content
func ClassifyFile ¶ added in v1.7.0
func ClassifyFile(ctx context.Context, fsys vfs.FS, path string, content []byte, typesFlag []string) string
ClassifyFile returns the platform a file would be classified as (lowercased, e.g. "ansible", "kubernetes", "terraform", "bicep"), or "" when undetermined. It mirrors the per-file detection used during analysis so callers (e.g. the parsing sink) can attribute each parsed document to its platform without re-running the full analyzer. content is the raw file bytes; typesFlag restricts candidate platforms (case-insensitive; pass nil to consider all). Passing the same platform set the analyzer used keeps the sink's classification consistent with the analyzer's. fsys is the filesystem used for extension detection; pass the in-memory FS for pushed content that never touches disk, or nil to default to the real disk.
func ClassifyParsedFile ¶ added in v1.7.0
func ClassifyParsedFile(ctx context.Context, fsys vfs.FS, platforms []string, kind model.FileKind, path string, content []byte) string
ClassifyParsedFile attributes a parsed file to its platform for payload bucketing. FileKind overrides extension/content detection for unambiguous types (Helm rendered manifests are Kubernetes, etc.). Returns "" when undetermined. platforms is the scan's effective platform set, forwarded to ClassifyFile so the sink classifies ambiguous files with the same candidate set the analyzer used (e.g. a Crossplane file is "kubernetes" in a default scan, "crossplane" only when Crossplane is enabled). fsys is forwarded for extension detection so the server's in-memory pushed content (not on disk) is classified correctly.
func PlatformForKind ¶ added in v1.7.2
PlatformForKind returns the fixed platform for kind when known.
func PossibleFileTypes ¶ added in v1.7.0
func PossibleFileTypes() []string
PossibleFileTypes returns the sorted set of file extensions and filenames the scanner can analyze. Exposed so the server's supported-files endpoint can stay in sync with the scanner's capabilities.
Types ¶
type Analyzer ¶
type Analyzer struct {
RepoPath string
Paths []string
Types []string
Exc []string
Only []string
GitIgnoreFileName string
ExcludeGitIgnore bool
MaxFileSize int
NumWorkers int
}
Analyzer keeps all the relevant info for the function Analyze