Documentation
¶
Overview ¶
Package importer turns an untrusted third-party CycloneDX document into something the estate graph can hold, in four layers that are applied in a fixed order and tested separately (ENG-HANDOFF-002 D9):
- limits: size, nesting depth, node count and string length, checked on a token stream before anything is built in memory (SECARCH-001 SR-01);
- schema: the document is validated against the specification's schema for the version it declares, 1.6 or 1.7 (ADR-0017);
- producer profile: which tool the document says made it, used only to choose how far its content may be read (a label for the person, never a trust input, SR-03);
- projection: observations on the imported stream (internal/estate).
Nothing here decides which system a document describes. The document's own claim about its subject is returned so it can be shown; the operator assigns the subject (SR-04).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ProfileCBOMkit = Profile{"cbomkit", "IBM CBOMkit (source scan)", estate.ImportSource} ProfileCdxgen = Profile{"cdxgen", "cdxgen (source scan)", estate.ImportSource} ProfileLens = Profile{"cbom-lens", "CBOM-Lens (host and network scan)", estate.ImportHost} ProfileTheia = Profile{"cbomkit-theia", "CBOMkit Theia (filesystem and image scan)", estate.ImportHost} ProfileOwn = Profile{"cipherhorizon", "CipherHorizon", estate.ImportHost} ProfileGeneric = Profile{"generic", "Unrecognised producer", estate.ImportGeneric} )
The profiles. Detection is by the tool names a document records; an unrecognised producer is Generic and is read at the weakest level.
var DefaultLimits = Limits{MaxBytes: 32 << 20, MaxDepth: 64, MaxNodes: 1_000_000, MaxString: 1 << 20, MaxComponents: 200_000}
DefaultLimits are generous for real documents (the largest sample seen, a source scan of Keycloak, is 60 KB) and small enough that a hostile one cannot exhaust memory.
Functions ¶
func CheckLimits ¶
CheckLimits applies only the limits layer: size, nesting depth, value count and string length, walking the token stream without building the document. Run it before decoding any untrusted JSON into a CycloneDX BOM.
Types ¶
type Doc ¶
type Doc struct {
Raw []byte
SHA256 string
SpecVersion string
BOM *cdx.BOM
Profile Profile
// ToolName and ToolVersion are what the document says made it: a claim, shown and recorded.
ToolName, ToolVersion string
// SubjectClaim is what the document says it describes: a claim, never used for placement.
SubjectClaim string
Components int
}
Doc is a document that passed the first three layers.
type Error ¶
type Error struct {
Stage string // limits | format | schema
Message string
Problems []cdxschema.Problem
}
Error is a document refusal that is safe to show to the person who uploaded it.