mod fix_cost

module fix_cost

What each security finding costs to fix, two ways.

report reads a scanner export and a RebuildDocument for the same installed stack. It does not walk the dependency graph again.

  • A version bump is the patched module plus every installed reverse dependent. The module path changes, so the deployed stack is no longer the one that was built. That breaks reproducibility.

  • An in-place patch keeps the name and version and adds <Name>-<version>_<ID>.patch` to patches`. It rebuilds the patched module, a bundle that includes the package as an extension or as a ``components entry, and a dependent that links it statically.

A runtime dependency is a shared-library link. A builddependency-only dependent is a static link when the recipe asks for a static build, or when rebuild-set already proved it from the install prefix. Otherwise the report says the link cannot be known, and that dependent is not counted in the in-place total.

Variables

const FIX_COST_SCHEMA_VERSION: u32

Schema of FixCostDocument. Bumped when a field changes meaning.

const ROUTE_BUMP: &str

Recommended route: take the new version and rebuild the closure.

const ROUTE_DEFER: &str

Recommended route: do not backport.

const ROUTE_IN_PLACE: &str

Recommended route: keep the version and add a patch file.

const ROUTE_UNKNOWN: &str

The easyconfig is not in the deployed graph, so neither cost is known.

Functions

fn render_markdown(document: &FixCostDocument) -> String

The ranked table and the roll-up as Markdown.

fn render_tsv(document: &FixCostDocument) -> String

One line per finding, tab-separated, with a header.

fn report(findings: &[Finding], installed: &BTreeSet<String>, document: &RebuildDocument, evidence: &EvidenceScan, reach: &ReachTable) -> FixCostDocument

Build the per-finding report from a rebuild set and recipe evidence.

evidence comes from scan_candidates. An empty scan still prices the graph: extensions and runtime edges are on the rebuild rows, and every builddependency-only dependent stays unknown. reach is the same table rebuild-set --findings uses for backport.md.

fn scan_candidates<'a, I>(candidates: I, installed: &BTreeSet<String>) -> EvidenceScan
where
    I: IntoIterator<Item = &'a Candidate>

Read candidates in order. A later easyconfig filename replaces an earlier one, which is how a from-commit tree replaces the release tree.

Enums

enum LinkHint

What one recipe says about how it links, read from configopts and buildopts.

Static

The recipe asks for a static build and not a shared one.

Shared

The recipe asks for a shared build and not a static one.

Unknown

The recipe names both, or neither.

Structs and Unions

struct BumpCost

The version-bump route.

modules: usize

How many modules.

fraction: f64

modules / stack_modules, four decimal places.

names: Vec<String>

Module names, sorted.

breaks_reproducibility: bool

A new version is a new module path. The deployed stack changes.

struct EvidenceScan

Recipes read for report, and paths that could not be read.

recipes: Vec<RecipeEvidence>

One entry per installed easyconfig that was read.

notes: Vec<String>

Unreadable paths, and component entries whose version was not a literal.

struct FindingRoute

One finding, with both costs and a route.

vuln_id: String

Advisory id from the export.

package: String

Package the scanner matched.

version: String

Installed version from the export.

severity: String

Worst severity among the export rows for this finding.

fixed_in: String

Version that fixes it. Empty when the scanner names none.

fix_state: String

fixed, not-fixed, or empty.

reach: String

The class from ReachTable: cross-user, network-facing, local-only, not-reachable, or unclassified.

modules: Vec<String>

Installed modules that carry it, sorted.

not_in_graph: Vec<String>

Installed modules named by the export whose easyconfig is not in the graph.

patch_files: Vec<String>

<Name>-<version>_<ID>.patch, one per distinct name and version.

bump: BumpCost

Full reverse-dependency closure.

in_place: RouteCost

Patched module, bundles, and known static linkers.

bundles: Vec<String>

Bundles that ship the package as an extension or a component.

static_linkers: Vec<String>

Dependents known to link the package statically.

not_static: Vec<String>

Dependents known not to.

static_unknown: Vec<String>

Builddependency-only dependents whose link cannot be known.

ROUTE_IN_PLACE, ROUTE_BUMP, ROUTE_DEFER, or ROUTE_UNKNOWN.

reason: String

Why that route was chosen.

struct FixCostDocument

Per-finding costs for one installed stack.

schema_version: u32

FIX_COST_SCHEMA_VERSION.

generated_at: String

When the rebuild set was computed.

installed_source: String

Where the installed list came from.

stack_modules: usize

Installed modules.

rows: usize

Rows in the scanner export.

findings: usize

Findings in Self::ranked.

ranked: Vec<FindingRoute>

One row per advisory, package, and version.

rollup: FixCostRollup

What fraction of the stack each strategy rebuilds.

not_installed: Vec<String>

Modules the export names that are not installed.

not_in_graph: Vec<String>

Installed modules with a finding whose easyconfig is not in the graph.

notes: Vec<String>

Unreadable recipes, and component versions that were not literals.

struct FixCostRollup

Union of each strategy over every finding that has a closure.

stack_modules: usize

Installed modules. This is the denominator.

bump_modules: usize

Union of the bump closures.

bump_fraction: f64

Self::bump_modules over Self::stack_modules.

in_place_modules: usize

Union of the in-place sets.

in_place_fraction: f64

Self::in_place_modules over Self::stack_modules.

Union of the modules the recommended route rebuilds. A deferred finding contributes nothing.

Self::recommended_modules over Self::stack_modules.

static_unknown_modules: usize

Union of the dependents whose static link cannot be known.

struct RecipeEvidence

One installed recipe, as far as the fix-cost report needs it.

easyconfig: String

Easyconfig filename.

module: String

Installed module, Name/VersionFull.

components: Vec<(String, String)>

(name, version) from components.

How configopts and buildopts say this recipe links.

struct RouteCost

Modules one route rebuilds.

modules: usize

How many modules.

fraction: f64

modules / stack_modules, four decimal places.

names: Vec<String>

Module names, sorted.