intent

package
v0.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: MIT Imports: 7 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 intent carries what access a project INTENDED, so a scan can say whether reality matches it.

unruly proves what an attacker can reach. Until this, it did not know what the attacker was SUPPOSED to reach -- so a relation readable by anyone was reported identically whether it held a public price list or a table of payslips, and a relation that was correctly locked was reported as nothing at all. The operator supplies the missing half.

NO MODEL RUNS DURING A SCAN. An agent reads the application once, out of band, and writes this down; verification is then a comparison. The same manifest and the same target give the same answer, every time, and the answer can be re-checked after a fix -- which is the whole difference between an assessment and a test.

Index

Constants

View Source
const SchemaVersion = 1

SchemaVersion is the manifest format this binary understands.

A manifest from a newer version is REFUSED rather than half-read: ignoring unrecognised fields would silently drop expectations and report the remainder as full coverage, which is the failure this package exists to prevent, committed by the package itself.

Variables

This section is empty.

Functions

func Findings

func Findings(target string, outcomes []Outcome) []finding.Finding

Findings turns policy outcomes into the ordinary report contract. Violations are actionable; unverified expectations are coverage gaps and therefore use the scanner-wide not-assessed ID that already drives exit 3.

Types

type Expectation

type Expectation struct {
	Resource  string    `yaml:"resource"`
	Operation Operation `yaml:"operation"`
	Subject   Subject   `yaml:"subject"`
	Scope     Scope     `yaml:"scope,omitempty"`
	// Result defaults to allow when a scope is given and deny otherwise, but
	// it is written out in practice: an omitted field is a decision nobody can
	// see.
	Result Result `yaml:"result,omitempty"`
}

An Expectation is one intended rule.

type Manifest

type Manifest struct {
	SchemaVersion int           `yaml:"schema_version"`
	Expect        []Expectation `yaml:"expect"`
}

A Manifest is the whole intended policy.

func Parse

func Parse(b []byte) (Manifest, error)

Parse reads a manifest and refuses anything it cannot fully understand.

type Observation

type Observation struct {
	Resource  string
	Operation Operation
	Subject   Subject
	// Scope is what the measurement established. Empty means the instrument
	// did not distinguish own rows from all rows and cannot satisfy an own-only
	// expectation.
	Scope   Scope
	Allowed bool
}

An Observation is what the scan actually established.

Only facts the scan MEASURED belong here. A relation nobody probed produces no observation, which is what makes the expectation unverified rather than satisfied.

func Observations

func Observations(access scan.Access) []Observation

Observations translates the provider-neutral pipeline artifact.

type Operation

type Operation string

An Operation is what they are trying to do.

const (
	Read   Operation = "read"
	Insert Operation = "insert"
	Update Operation = "update"
	Delete Operation = "delete"
)

type Outcome

type Outcome struct {
	Expectation Expectation
	State       State
	// Detail says what was observed, or why nothing was.
	Detail string
}

An Outcome is one expectation, checked.

func Verify

func Verify(m Manifest, obs []Observation) []Outcome

Verify compares intent against what the scan measured.

Pure and total: every expectation produces exactly one outcome, in the manifest's own order, so the result is a statement about the WHOLE intended policy rather than a list of the parts that went wrong.

type Result

type Result string

A Result is whether the operation should succeed.

const (
	Allow Result = "allow"
	Deny  Result = "deny"
)

type Scope

type Scope string

A Scope narrows an allow to the subject's own rows.

`owner` may read invoices -- their own. Recorded because the difference between "the owner can read invoices" and "the owner can read ALL invoices" is the difference between a working product and a data breach, and a manifest that cannot express it would have to be written the loose way.

const (
	ScopeOwn Scope = "own"
	ScopeAll Scope = "all"
)

type State

type State string

State is how one expectation came out.

const (
	// Matched: reality agrees with the intent.
	Matched State = "matched"
	// Violated: reality and the intent disagree. Usually reality is more
	// permissive, which is a hole; occasionally more restrictive, which is an
	// outage waiting to happen and still evidence that one of the two is
	// wrong.
	Violated State = "violated"
	// Unverified: the scan never established this, so nothing is known. NOT a
	// pass -- counting it as one would let a manifest of intentions produce a
	// clean report from a scan that measured none of them.
	Unverified State = "unverified"
)

type Subject

type Subject string

A Subject is who is asking.

The five tiers a real policy distinguishes. anonymous and authenticated are what unruly already measures; owner and other_tenant are the pair that catches broken ownership, which anonymous testing cannot see at all -- a relation correctly closed to strangers and open to every signed-in user reads as protected until somebody asks as a DIFFERENT signed-in user.

const (
	Anonymous     Subject = "anonymous"
	Authenticated Subject = "authenticated"
	Owner         Subject = "owner"
	OtherTenant   Subject = "other_tenant"
	Admin         Subject = "admin"
)

Jump to

Keyboard shortcuts

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