Documentation
¶
Overview ¶
Package conformance runs the CTIS conformance vectors (conformance/v2) against this implementation. The same vectors let any other implementation check itself: they are plain JSON, see conformance/README.md, and conformance/PROTOCOL.md describes the line protocol (Serve) through which scripts/conformance_harness.py drives any implementation.
Index ¶
- Constants
- Variables
- func Canonical(fn string, in json.RawMessage) (any, error)
- func Cases(dir string) ([]Case, []LoadError)
- func Info(implementation, version string) map[string]any
- func Serve(r io.Reader, w io.Writer, implementation, version string) error
- type Case
- type LoadError
- type OpError
- type Result
- type WantError
Constants ¶
const ( CategoryProtocol = "protocol" // the request is malformed CategoryUnsupported = "unsupported" // the implementation does not provide the op CategoryCanonical = "canonical" // the value has no canonical form CategoryFingerprint = "fingerprint" // the input forms no fingerprint CategoryWebURL = "web_url" // the URL is refused CategoryVersion = validatedoc.CategoryVersion CategoryDecode = validatedoc.CategoryDecode CategoryValidate = validatedoc.CategoryValidate CategoryMapping = "mapping" // a mapping file is refused CategoryInput = "input" // the input of a mapping is refused as a whole )
Error categories of an operation. The document categories (version, decode, validate) are those of the documents manifest.
const MaxRequestBytes = 64 << 20
MaxRequestBytes bounds one request line of the protocol.
Variables ¶
var ( RequiredOps = []string{ "canonical", "asset_key", "vulnerability_id", "preferred_id", "location_key", "fingerprint", "secret_digest", "correlation_key", "web_url", "decode", "validate", } OptionalOps = []string{"mapping_apply", "interop_path_match", "interop_select", "interop_collect"} )
RequiredOps are the operations every CTIS implementation provides (the core); OptionalOps belong to the declarative mapping language and the interoperability engine, which a binding may leave out.
var CanonicalFunctions = []string{
"CanonicalAssetValue", "CanonicalDomain", "CanonicalIP", "CanonicalCIDR", "CanonicalService",
"CanonicalOrigin", "CanonicalURL", "CanonicalRepository", "CanonicalPurl", "CanonicalCPE",
"CanonicalImage", "CanonicalARN", "CanonicalAzureResourceID", "CanonicalGCPResourceName",
"CanonicalCertificateFingerprint",
}
CanonicalFunctions are the function names of the "canonical" operation.
Functions ¶
func Canonical ¶
func Canonical(fn string, in json.RawMessage) (any, error)
Canonical applies a canonical-form function named by a vector file to the vector's input and returns the result (a string, or an object for CanonicalPurl).
func Cases ¶ added in v2.0.2
Cases reads every vector family under dir (a conformance/v2 directory).
func Serve ¶ added in v2.0.2
Serve answers protocol requests (conformance/PROTOCOL.md): one JSON object per line on r, one answer per line on w, in order. It returns when r ends, or with the error of a failed read or write. implementation and version name this implementation in the answer to "info".
Types ¶
type Case ¶ added in v2.0.2
type Case struct {
Suite string
Name string
Op string
Input json.RawMessage
Want json.RawMessage // the expected output when WantErr is nil
WantErr *WantError
}
Case is one vector as a protocol request and the answer it expects. scripts/conformance_harness.py builds the same cases from the same files.
type LoadError ¶ added in v2.0.2
type LoadError struct {
Suite, Name, Err string
}
LoadError is a vector file that could not be read; it counts as a failed vector.
type OpError ¶ added in v2.0.2
OpError is the error answer of an operation.