outcome

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 0 Imported by: ? 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 outcome is the per-target outcome of a scan task: how each of the task's targets ended. A sensor reports one outcome per target when a task ends (completed, partial or stopped part-way); the platform settles every target that has an outcome and hands only the unfinished ones out again, so a task that stopped after part of its work never runs the finished targets a second time.

States:

  • done: the target was scanned (whatever it found, nothing included);
  • failed: the tool tried the target and it failed, with a class: unreachable (no answer, no route, no name), timeout (the target's own time budget ran out), tool_error (the tool failed on that target) or egress_refused (the sensor's network confinement refused every connection the tool made toward the target: it was not reached, and nothing can be said about it);
  • skipped: the target was not run on purpose, with a class: refused (a policy refused it) or excluded (the job's exclusions cover it);
  • unfinished: the task stopped before the target got an outcome.

Done, failed and skipped settle a target: retrying it would give the same answer, so it is not handed out again in the same run. Unfinished is the only state that asks for another attempt.

The platform never trusts a sensor's list as is. Normalize reads it against the task's own target list: a target the task does not carry is dropped (a sensor can never add work), an entry with an unknown state or class is ignored, and a task target with no valid entry is unfinished.

The package is part of the CTIS contract (standard library only): the platform and the sensor SDK both import it, so neither depends on the other for this shape.

Index

Constants

View Source
const MaxTargetLen = 2048

MaxTargetLen bounds one target value in an outcome.

View Source
const MaxTargets = 100000

MaxTargets bounds the outcomes one result may carry; Normalize reads no more entries than this.

View Source
const ResultKey = "target_outcomes"

ResultKey is the member of a command result (and the property of a CTIS report) that carries the task's per-target outcomes.

Variables

This section is empty.

Functions

func Remaining

func Remaining(reported []Target, taskTargets []string) []string

Remaining returns the task targets (distinct, in task order) that reported does not settle: what is handed out again.

Types

type Class

type Class string

Class says why a target failed or was skipped.

const (
	Unreachable Class = "unreachable"
	Timeout     Class = "timeout"
	ToolError   Class = "tool_error"
	// EgressRefused: the sensor's own egress confinement refused every
	// connection toward the target. It settles the target like the other
	// failures (the same sensor would refuse it again); a receiver shows it
	// as "not reached", never as "nothing found".
	EgressRefused Class = "egress_refused"
)

Classes of a failed target.

const (
	Refused  Class = "refused"
	Excluded Class = "excluded"
)

Classes of a skipped target.

type Counts

type Counts struct {
	Done       int `json:"done"`
	Failed     int `json:"failed"`
	Skipped    int `json:"skipped"`
	Unfinished int `json:"unfinished"`
}

Counts is how many targets ended in each state.

func Count

func Count(outcomes []Target) Counts

Count counts the states of outcomes (invalid entries are not counted).

type State

type State string

State is how a target ended.

const (
	Done       State = "done"
	Failed     State = "failed"
	Skipped    State = "skipped"
	Unfinished State = "unfinished"
)

States.

type Target

type Target struct {
	Target string `json:"target"`
	State  State  `json:"state"`
	Class  Class  `json:"class,omitempty"`
}

Target is one target's outcome.

func Normalize

func Normalize(reported []Target, taskTargets []string) []Target

Normalize returns exactly one outcome per distinct task target, in task order: the first valid entry of reported for that target, else unfinished. Entries for targets the task does not carry and invalid entries are dropped; at most MaxTargets entries of reported are read.

func (Target) Settled

func (t Target) Settled() bool

Settled reports whether the outcome settles its target (done, failed or skipped): the target is not handed out again in the same run.

func (Target) Valid

func (t Target) Valid() bool

Valid reports whether the outcome is well formed: a non-empty target of at most MaxTargetLen bytes, a known state, and a class that fits it (failed and skipped need one of theirs; done and unfinished take none).

Jump to

Keyboard shortcuts

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