importer

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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):

  1. limits: size, nesting depth, node count and string length, checked on a token stream before anything is built in memory (SECARCH-001 SR-01);
  2. schema: the document is validated against the specification's schema for the version it declares, 1.6 or 1.7 (ADR-0017);
  3. 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);
  4. 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

View Source
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.

View Source
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

func CheckLimits(raw []byte, lim Limits) error

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.

func Parse

func Parse(raw []byte, lim Limits) (*Doc, error)

Parse applies the limits, schema and profile layers.

func (*Doc) Project

func (d *Doc) Project() estate.Result

Project is layer four: the observations an import contributes.

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.

func (*Error) Error

func (e *Error) Error() string

type Limits

type Limits struct {
	MaxBytes      int // total size
	MaxDepth      int // nesting of arrays and objects
	MaxNodes      int // JSON values in total
	MaxString     int // bytes in one string
	MaxComponents int // components, counting nested ones
}

Limits bound what a document may make the server do.

type Profile

type Profile struct {
	ID    string
	Label string
	Kind  estate.ImportKind
}

Profile names the producer a document says made it, and how its content is read.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL