Documentation
¶
Overview ¶
Package scanners holds Draugr's built-in scanners, which wrap individual security tools and normalize their output to SARIF.
See docs/ARCHITECTURE.md.
Index ¶
- Constants
- func DescribeBound(ctx context.Context, data []byte, ft plugin.FileTarget, ...) (string, error)
- func DescribeFile(data []byte, ft plugin.FileTarget) (string, error)
- func DescribeImport(data []byte, format string) (string, error)
- func FeedMaxAge() time.Duration
- func NewCosign() plugin.Scanner
- func NewGitleaks() plugin.Scanner
- func NewGosec() plugin.Scanner
- func NewGovulncheck() plugin.Scanner
- func NewGrype() plugin.Scanner
- func NewGrypeFS() plugin.Scanner
- func NewHTTPHeaders() plugin.Scanner
- func NewK8sPolicies() plugin.Scanner
- func NewKICS() plugin.Scanner
- func NewKubeBench() plugin.Scanner
- func NewKubeBenchJob() plugin.Scanner
- func NewMendLicenses() plugin.Scanner
- func NewMendSCA() plugin.Scanner
- func NewNotation() plugin.Scanner
- func NewNuclei() plugin.Scanner
- func NewOSVScanner() plugin.Scanner
- func NewProwler() plugin.Scanner
- func NewRetireJS() plugin.Scanner
- func NewSARIFImport() plugin.Scanner
- func NewSemgrep() plugin.Scanner
- func NewTLSProbe() plugin.Scanner
- func NewTrivy() plugin.Scanner
- func NewTrivyConfig() plugin.Scanner
- func NewTrivyFS() plugin.Scanner
- func NewTrivyLicense() plugin.Scanner
- func NewURLhaus() plugin.Scanner
- func NewVirusTotal() plugin.Scanner
- func SetFeedMaxAge(d time.Duration)
- func SourceCheck(ft plugin.FileTarget) (detail string, ok bool)
- type Signature
Constants ¶
const ReportPathToken = "{{draugr:report-path}}" // #nosec G101 -- an argv placeholder, not a credential
ReportPathToken marks the argv slot where a tool wants a path to write its report to. The harness replaces it with a real file and reads that back.
A tool that *opens* a file cannot be pointed at /dev/stdout. That is a symlink to the process's own fd 1, and opening it is not the same as writing to the descriptor it inherited: where stdout is a pipe. Which is every containerised runner, the open lands somewhere the parent never reads, and the tool exits 0 having written nothing. The parse then fails on empty input and blames the JSON.
Variables ¶
This section is empty.
Functions ¶
func DescribeBound ¶ added in v0.188.0
func DescribeBound(ctx context.Context, data []byte, ft plugin.FileTarget, resolve func(ctx context.Context, url, revision string) (string, error)) (string, error)
DescribeBound is DescribeFile followed by the commit the scan holds the file to, worked out by the scan's own rule (sarifImport.bind), with resolve turning a repository's revision into a commit: "SARIF 2.1.0, 1 result, commit 0123456789ab", or the scan's account of a file nothing binds, "…, commit not stated, ${{ GITHUB_SHA }} is not set". A file the scan would refuse as written for another commit returns the scan's error, so a preflight fails it in the scan's words before the scan runs. An error resolve returns reaches the caller wrapped, for errors.Is.
func DescribeFile ¶ added in v0.184.0
func DescribeFile(data []byte, ft plugin.FileTarget) (string, error)
DescribeFile is DescribeImport for the import ft plans, which for a converter's file carries the converter the descriptor declares and what it may set, both of which decide whether the file is read.
func DescribeImport ¶ added in v0.182.0
DescribeImport reads data as an import of format would, empty being SARIF, and says what it is and how much it holds: "SARIF 2.1.0, 3 results", "Trivy JSON, 4 findings". A file the scan would refuse returns the scan's error. Nothing is held to a commit or placed in a repository; DescribeBound does that.
func FeedMaxAge ¶ added in v0.135.1
FeedMaxAge is the limit SetFeedMaxAge last set.
func NewGitleaks ¶ added in v0.2.0
NewGitleaks returns a Scanner that runs Gitleaks over a checked-out repository to detect leaked secrets (credentials, tokens, keys). It serves the "secrets" control.
func NewGosec ¶ added in v0.14.0
NewGosec returns a Scanner that runs gosec, a Go-specialized static analyzer, over a checked-out repository. It is an optional second scanner for the "sast" control (alongside Semgrep); it only makes sense on Go components, so it is opt-in via controls.sast.gosec.enabled.
func NewGovulncheck ¶ added in v0.101.0
NewGovulncheck returns the govulncheck scanner: reachability analysis for Go modules.
It answers a different question from the other sca scanners. Trivy reads a manifest and says which dependencies have known vulnerabilities; govulncheck builds a call graph from the packages that are actually in the build and says which of those vulnerabilities this code can reach. The two are complementary rather than competing, which is why what this produces is folded onto existing findings rather than reported alongside them.
func NewGrype ¶ added in v0.91.0
NewGrype returns a Scanner that runs Anchore Grype against container images and returns its native SARIF output. It serves the "images" control, alongside Trivy rather than instead of it.
func NewGrypeFS ¶ added in v0.91.0
NewGrypeFS returns a Scanner that runs Grype over a checked-out repository to find dependency vulnerabilities (SCA). It serves the "sca" control.
func NewHTTPHeaders ¶ added in v0.9.0
NewHTTPHeaders returns the native HTTP security-header scanner.
func NewK8sPolicies ¶ added in v0.47.0
NewK8sPolicies returns a Scanner that reads the CIS policies section through the Kubernetes API.
func NewKICS ¶ added in v0.187.0
NewKICS returns a Scanner that runs Checkmarx KICS over a checked-out repository, from KICS's own image, as a second scanner for the "iac" control. A descriptor turns it on with `iac: { kics: { enabled: true } }`; trivy-config stays the default and runs alone otherwise.
func NewKubeBench ¶ added in v0.45.0
NewKubeBench returns a Scanner for the "kubernetes" control.
func NewKubeBenchJob ¶ added in v0.46.0
NewKubeBenchJob returns a Scanner that runs the CIS benchmark inside the cluster.
func NewMendLicenses ¶ added in v0.71.0
NewMendLicenses returns a Scanner for the "licenses" control backed by Mend.
func NewMendSCA ¶ added in v0.70.0
NewMendSCA returns a Scanner for the "sca" control backed by Mend.
func NewNotation ¶ added in v0.126.0
NewNotation returns the Notary Project verification scanner.
func NewNuclei ¶ added in v0.28.0
NewNuclei returns a Scanner that runs Nuclei for the "dast" control. Nuclei is a single Go binary that probes a live endpoint with a large community template library; Draugr parses its JSONL output rather than its SARIF export, so severity, the matched URL, and CWEs map cleanly onto Draugr's model.
func NewOSVScanner ¶ added in v0.187.0
NewOSVScanner returns a Scanner that runs OSV-Scanner over a checked-out repository to find dependency vulnerabilities. It serves the "sca" control, opt-in beside Trivy rather than instead of it.
What it adds is data. OSV-Scanner matches against OSV's export of every advisory database it aggregates, which includes four that neither Trivy's database nor Grype's carries: PyPA's, RustSec's, the Go vulnerability database and the Erlang ecosystem's. A Cargo.lock pinning a crate RustSec has published an advisory for scans clean under Trivy and Grype alike.
Every scan runs with --offline. Without it OSV-Scanner sends the list of packages it read to api.osv.dev, a disclosure this scanner never makes; with it, OSV-Scanner reads the databases on disk and contacts nothing. Draugr has the databases downloaded once per ecosystem per run (see osvDatabases).
func NewProwler ¶ added in v0.145.0
NewProwler returns the scanner for the "cloud" control.
func NewRetireJS ¶ added in v0.94.0
NewRetireJS returns a Scanner that runs retire.js over a checked-out repository to find known vulnerable JavaScript that never appears in a lockfile. It serves the "sca" control, opt-in beside Trivy rather than instead of it.
Lockfile-based SCA answers for what the package manager installed. Front-end code routinely ships JavaScript it did not: a library pulled from a CDN, a vendored file under static/, bundled output shipped without its manifest. retire.js fingerprints those by content, which is the only way to identify a file whose provenance was never recorded.
The gap matters because of its shape rather than its size. A repository serving a five-year-old jQuery scans clean today. The control runs, reports, and passes, so nothing about the output suggests anywhere left to look.
func NewSARIFImport ¶ added in v0.151.0
NewSARIFImport returns the scanner every import is planned for.
func NewSemgrep ¶ added in v0.3.0
NewSemgrep returns a Scanner that runs Semgrep over a checked-out repository for static application security testing (SAST). It serves the "sast" control.
func NewTLSProbe ¶ added in v0.31.0
NewTLSProbe returns the native TLS configuration scanner.
func NewTrivy ¶
NewTrivy returns a Scanner that runs Aqua Trivy against container images. It serves the "images" control.
JSON rather than SARIF, for the reason the filesystem scanner already reads JSON: the SARIF names the package only in prose. An image finding needs three facts a consumer can act on, which package, which image, and which operating system. And the last two have no SARIF field at all, so a platform that files findings by report type has nothing to file these under.
func NewTrivyConfig ¶ added in v0.4.0
NewTrivyConfig returns a Scanner that runs Trivy's misconfiguration scanner over a checked-out repository to find insecure Infrastructure-as-Code (Terraform, Kubernetes manifests, Dockerfiles, Helm, …). It serves the "iac" control.
func NewTrivyFS ¶
NewTrivyFS returns a Scanner that runs Trivy in filesystem mode over a checked-out repository to find dependency vulnerabilities (SCA). It serves the "sca" control. (License findings are not included in Trivy's SARIF output and are tracked separately.)
func NewTrivyLicense ¶ added in v0.43.0
NewTrivyLicense returns a Scanner that reports licenses carrying an obligation, in a component's repositories and in its images.
Both, because the reader's question, what am I obliged by. Has no target kind in it. A license obligation inside an image was invisible while this read repositories only, and silently so: the control ran, reported covered, and the surface it had not examined had no name in the output. A third-party image is exactly where the source repository is not declared, because the team does not build it, so the gap landed hardest where the question was least answerable by hand.
One scanner over two kinds rather than two scanners, so a component's license policy cannot differ by where the code happens to live, and `doctor` lists one tool.
func NewURLhaus ¶ added in v0.66.0
NewURLhaus returns the abuse.ch URLhaus threat-intelligence scanner.
func NewVirusTotal ¶ added in v0.66.0
NewVirusTotal returns the VirusTotal domain-reputation scanner.
func SetFeedMaxAge ¶ added in v0.133.0
SetFeedMaxAge sets how old a cached feed may be before a scan refuses to read it. Zero or less means never too old, for a runner deliberately pinned to a known copy.
func SourceCheck ¶ added in v0.183.0
func SourceCheck(ft plugin.FileTarget) (detail string, ok bool)
SourceCheck says whether an import of a service's alerts has its token to send, for doctor: the variable it names may be read and is set. Nothing is sent, so the token's scope and the repository's settings are left to the scan, which names what GitHub refused. The detail never holds the token.
Types ¶
type Signature ¶ added in v0.129.0
type Signature struct {
Identity string // the Fulcio SAN, empty where a signature is present and its identity is not
Issuer string // the OIDC issuer that vouched for it
Signed bool // whether the registry holds a signature at all
}
Signature is who a registry says signed an image.
Unsigned and unreadable are separate answers. An image nobody signed is the ordinary case for anything published by somebody else, and an image signed by an identity that could not be read is a signature the reader should go and look at.
func WhoSigned ¶ added in v0.129.0
WhoSigned reports the Sigstore signature on an image, for a caller proposing who should be trusted to sign it.
The same read the control performs when a descriptor has declared no signer, exported so that discovery and verification ask the registry the same question. Written twice they would answer differently on the case that matters: an attestation carries its identity in the certificate rather than the payload, so the naive read succeeds with an empty answer and the images most likely to have provenance are the ones discovery would say nothing about. trustRoot is the descriptor's own Sigstore root where it set one, and empty for the public root. A discovery that skipped it would report nothing for exactly the organizations that run their own Sigstore, which are the ones whose signers are least guessable.
Source Files
¶
- aside.go
- cis_policies_catalog.go
- cosign.go
- csp.go
- csp_page.go
- datasources.go
- datastate.go
- detectsecrets.go
- doc.go
- entrypoint_shell.go
- fingerprint.go
- githubalerts.go
- gitleaks.go
- gitleaks_allowed.go
- gitleaks_config.go
- gitleaks_csv.go
- gitleaks_named.go
- gitleaks_report.go
- gitleaks_rewrite.go
- gitleaks_unread.go
- goplatforms.go
- gosec.go
- gosec_nolint.go
- gotests.go
- gotools.go
- govulncheck.go
- govulncheck_buildgo.go
- govulncheck_gowork.go
- govulncheck_unloaded.go
- govulndb.go
- grype.go
- grype_excluded.go
- grypepoms.go
- headers.go
- importaqua.go
- importcheckmarx.go
- importconverter.go
- importgitlab.go
- importjfrog.go
- importjson.go
- importmend.go
- importosv.go
- importsemgrep.go
- importtwistcli.go
- importveracode.go
- k8s_policies.go
- k8s_policies_decide.go
- k8s_policies_refused.go
- kics.go
- kics_same.go
- kube_bench.go
- kube_bench_job.go
- kube_bench_platform.go
- lockretry.go
- mend_licenses.go
- mend_sca.go
- mend_schema.go
- mend_session.go
- mend_settings.go
- notation.go
- nuclei.go
- nuclei_drop.go
- nuclei_options.go
- nuclei_scope.go
- openapi.go
- options.go
- osvscanner.go
- own_jobs.go
- ownpackage.go
- pomscope.go
- prowler.go
- prowler_aws_reads.go
- prowler_azure_reads.go
- prowler_gcp_reads.go
- rating.go
- repo.go
- retirejs.go
- sarif_append.go
- sarifimport.go
- sarifimport_bandit.go
- sarifimport_rating.go
- schemas.go
- semgrep.go
- semgrep_rating.go
- semgrep_unread.go
- settingfiles.go
- sonarqube.go
- tls.go
- toolversion.go
- trivy-config.go
- trivy.go
- trivy_config_charts.go
- trivy_config_downloaded.go
- trivy_config_entrypoint.go
- trivy_config_excluded.go
- trivy_config_modules.go
- trivy_config_whole_file.go
- trivy_license.go
- trivy_version.go
- trivy_vuln_json.go
- trivy_walk.go
- unscored.go
- urlhaus.go
- virustotal.go