Library Usage
The CLI is a thin wrapper around github.com/gatecheckdev/gatecheck/pkg/gatecheck.
import "github.com/gatecheckdev/gatecheck/pkg/gatecheck"
NewDefaultConfigreturns the same defaults asgatecheck config init: rules disabled, coverage thresholds0.NewConfigDecoderreads.yaml,.yml,.json, or.toml. The extension selects the format. When the file has keys gatecheck does not read,Decodestill fills the config and returns an error wrappingErrUnknownConfigKeys. Check it witherrors.Isand treat it as a warning.DecodeConfigdoes the same for bytes you already have.EncodeConfigToandNewConfigEncoderwrite a config asjson,yaml,yml, ortoml, with or without the dot. JSON and YAML are indented by two spaces.ConfigFormatchecks a format name.Validatetakes the config, a reader, and the filename. The bytes select the report type. The filename is the fallback, with the same words as the CLI.Listwrites a table.WithDisplayFormattakestable,markdown, orjson. A Grype, CycloneDX, SARIF, Semgrep, Gitleaks, Trivy, or osv-scanner report with no findings writes one sentence instead, such asNo gitleaks findings,No trivy vulnerabilities, orNo osv-scanner vulnerabilities.WithDisplayFormat("markdown")matches--markdownand writes that same sentence when the report is empty.WithEPSSmatches--epssand takes an open CSV file or a URL.CreateBundle,AppendToBundle, andRemoveFromBundlearebundle create,bundle add, andbundle remove.DownloadEPSSandDownloadKEVwrite the API payloads.WithEPSSURL,WithKEVURL,WithEPSSFile, andWithKEVFileoverride the defaults.WithVEXFilesadds VEX documents toValidate.- Errors:
ErrValidationFailureis a threshold failure.ErrExternalDatameans EPSS or KEV data could not be loaded.ErrBundleLabelNotFoundcomes fromRemoveFromBundle. The CLI maps these to exit codes 1, 3, and 2 withcmd.ExitCode.
Report types are described in Supported Reports. Config fields are described in Configuration.