Documentation
¶
Index ¶
Constants ¶
const ( BeginMarker = "-----BEGIN KNOBE B64-----" EndMarker = "-----END KNOBE B64-----" )
const MaxFileSize = 64 << 20
MaxFileSize bounds what VerifyFile reads. Parsing costs roughly 30 bytes of memory per input byte, so an unbounded hostile file could exhaust a constrained host. Larger files are reported unreadable.
Variables ¶
This section is empty.
Functions ¶
func NormalizeBody ¶
NormalizeBody applies the §6 body normalization.
func PayloadHash ¶
PayloadHash is the §5 payload hash of a payload object; its own payload_hash member is ignored.
func SafeString ¶
SafeString is lens.py safe() for a string: escape C0/C1 controls and DEL as \xNN so a crafted string cannot spoof the report or inject terminal escape sequences, then truncate to limit code points (limit <= 0: no limit). Stricter than lens.py, it also escapes bidi overrides, isolates and zero-width characters (\uNNNN), which could reorder or hide report text.
Types ¶
type BodyVerified ¶
type BodyVerified string
BodyVerified is the optional body-hash result (spec §6, §7).
const ( BodyYes BodyVerified = "yes" BodyModified BodyVerified = "modified" BodyOmitted BodyVerified = "omitted" )
type Conformance ¶
type Conformance string
Conformance is the schema/spec compliance result (spec §7).
const ( Valid Conformance = "valid" Warnings Conformance = "warnings" Invalid Conformance = "invalid" )
type ParseError ¶
type ParseError struct {
DuplicateKey string
IsDuplicate bool
NonJSONConst bool
Msg string
Offset int
}
ParseError kinds, so the verifier can word its unreadable reason as lens.py does.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
type ParseResult ¶
ParseResult carries the parsed value plus a flag for unpaired UTF-16 surrogate escapes. Python accepts those while parsing but cannot UTF-8-encode them, so the verifier rejects the payload after its structural checks, as lens.py does.
type Report ¶
type Report struct {
Status Status
// Computed is the recomputed payload hash; empty when unreadable.
Computed string
// Stored is the payload_hash member as found (any JSON type; the empty
// string if absent). Nil when unreadable.
Stored *Value
// Payload is the decoded payload, when one was decoded.
Payload *Value
// BodyVerified is empty when unreadable (machine output then says null).
BodyVerified BodyVerified
Conformance Conformance
ConformanceIssues []string
// BlockCount is the number of payload blocks found; the last is evaluated.
BlockCount int
// Reason says why the file is unreadable; empty otherwise.
Reason string
}
Report is a verification result with lens.py's fields and semantics.
func VerifyBytes ¶
VerifyBytes verifies the contents of a .knobe.md file. Callers passing untrusted input should bound its size, as VerifyFile does.
func VerifyFile ¶
VerifyFile reads and verifies a .knobe.md file of at most MaxFileSize bytes. It never panics on file contents; read errors are reported as unreadable.
func (Report) BlockUsed ¶
BlockUsed is the 1-based index of the evaluated block: always the last (spec §3.3).
func (Report) ExitCode ¶
ExitCode is lens.py's: 0 when integrity holds and conformance is valid or warnings; 1 when the payload failed or conformance is invalid; 2 when the file is unreadable.
func (Report) JSON ¶
JSON renders the report exactly as `python3 lens.py --json` does: the same keys in the same order, two-space indent, literal UTF-8.
func (Report) MultipleBlocks ¶
MultipleBlocks reports whether more than one payload block was present.
func (Report) WriteHuman ¶
WriteHuman writes the human-readable report in lens.py's layout. Every payload-derived string is escaped first, so control characters and terminal escape sequences in a hostile file are shown, never executed.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
knobe-verify
command
Command knobe-verify checks a KNOBE Protocol v1 file and reports its integrity (status), body hash result (body_verified) and spec conformance, with the same report and exit codes as the reference verifier lens.py.
|
Command knobe-verify checks a KNOBE Protocol v1 file and reports its integrity (status), body hash result (body_verified) and spec conformance, with the same report and exit codes as the reference verifier lens.py. |