IF Commons GitHub

logical/risk

Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0003-estate-logical FR-005, 0003-estate-logical FR-006

Accepted risk and the status of a policy (Stolos 067-adopt FR-013, 117-adopted-in-status): a person accepts a failing policy of a machine with a reason and a date at most a year away, the policy then shows as accepted and never as passing, and after the date it fails again, saying so. A machine never observed, and a policy that could not tell, are waiting: never a failure and never a warning.

import { acceptRisk, judgePolicy } from "./risk.ts";
const risk = acceptRisk({ policy: "disk-encryption", reason: "holds only open-source code", by: "an owner", until: "2027-03-01" }, "2026-12-01");
risk.kind; // "ok"
judgePolicy({ result: { id: "disk-encryption", status: "fail", controls: ["SC-28"] }, observed: true, accepted: risk.kind === "ok" ? [risk.value] : [], now: "2026-12-02" }).status; // "accepted"

Source: commons/estate/src/logical/risk.ts

4 of 8 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

PolicyFindingtypeno test imports it
type PolicyFinding = "pass" | "fail" | "warn" | "unknown";

What a policy found on a machine: pass, fail, warn (not required, but worth doing) or unknown (cannot tell).

PolicyOutcometype
type PolicyOutcome = { readonly id: string; readonly status: PolicyFinding; readonly controls: readonly string[] };

What a policy found, by its id, with the controls it gives evidence for (identifiers of a framework's controls, such as NIST SP 800-53 Rev 5's).

Imported by 2 tests of the run (2 passed, 0 failed): the library's results

PolicyStatustypeno test imports it
type PolicyStatus = "pass" | "fail" | "warn" | "accepted" | "waiting";

The status shown for a policy: accepted is a failing policy a person accepted until a date; waiting is a policy nothing was observed for or that could not tell.

AcceptedRisktype
type AcceptedRisk = { readonly policy: string; readonly reason: string; readonly by: string; readonly until: string };

A risk a person accepted: the policy, why, who and until when (a day, YYYY-MM-DD).

Imported by 2 tests of the run (2 passed, 0 failed): the library's results

acceptRiskfunction
function acceptRisk(input: AcceptedRisk, now: string): Result<AcceptedRisk, readonly string[]>

An accepted risk, or every reason it is refused: the date is a day after today and within a year (366 days), and the reason is at least ten characters, in words an auditor reads.

Imported by 2 tests of the run (2 passed, 0 failed): the library's results

JudgedPolicytypeno test imports it
type JudgedPolicy = { readonly id: string; readonly status: PolicyStatus; readonly controls: readonly string[]; readonly detail: string };

The status of a policy and why.

JudgeInputtypeno test imports it
type JudgeInput = { readonly result: PolicyOutcome; readonly observed: boolean; readonly accepted: readonly AcceptedRisk[]; readonly now: string };

What judgePolicy takes: what the policy found, whether the machine was observed at all, the risks accepted and the instant now.

judgePolicyfunction
function judgePolicy(i: JudgeInput): JudgedPolicy

The status of one policy. A machine never observed, and a policy that is unknown, are waiting; a pass stays a pass; a failing or warning policy a person accepted is accepted until the day after its date, and after that it is what it was, with the end of the acceptance said.

Imported by 2 tests of the run (2 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.