coverage

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package coverage compares a Policy's in-scope assessment requirements against enforcement artifacts in a policy directory, producing a structured coverage report.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ManualEntry

type ManualEntry struct {
	RequirementID string `json:"requirement_id"`
	PlanID        string `json:"plan_id"`
}

ManualEntry records a manual assessment requirement excluded from coverage metrics.

type MappingEntry

type MappingEntry struct {
	ID            string `json:"id"`
	RequirementID string `json:"requirement_id"`
}

MappingEntry maps a Rego package namespace to an assessment requirement ID.

type MappingFile

type MappingFile struct {
	Version  string         `json:"version"`
	Mappings []MappingEntry `json:"mappings"`
}

MappingFile represents the complytime-mapping.json structure.

type Metrics

type Metrics struct {
	TotalAutomated  int     `json:"total_automated"`
	Implemented     int     `json:"implemented"`
	Gaps            int     `json:"gaps"`
	CoveragePercent float64 `json:"coverage_percent"`
	Passing         int     `json:"passing,omitempty"`
	Failing         int     `json:"failing,omitempty"`
}

Metrics contains aggregate coverage statistics.

type Options

type Options struct {
	// ResolvedPolicy is the fully resolved policy to check coverage for.
	ResolvedPolicy *requirement.ResolvedPolicy

	// PolicyDir is the path to the directory containing enforcement artifacts.
	PolicyDir string

	// Evaluator is the policy-language evaluator to use for detection.
	Evaluator evaluator.Evaluator

	// RunTests enables test execution for pass/fail enrichment.
	RunTests bool
}

Options configures a coverage report run.

type Report

type Report struct {
	PolicyID     string             `json:"policy_id"`
	Requirements []RequirementEntry `json:"requirements"`
	Metrics      Metrics            `json:"metrics"`
	Warnings     []Warning          `json:"warnings"`
	Manual       []ManualEntry      `json:"manual,omitempty"`
}

Report is the structured output of a coverage run.

func Run

func Run(ctx context.Context, opts Options) (*Report, error)

Run executes a coverage analysis comparing the resolved policy's automated assessment requirements against enforcement artifacts in the policy directory.

type RequirementEntry

type RequirementEntry struct {
	RequirementID string            `json:"requirement_id"`
	ControlID     string            `json:"control_id,omitempty"`
	Status        RequirementStatus `json:"status"`
	RegoPackage   string            `json:"rego_package,omitempty"`
	TestErrors    []string          `json:"test_errors,omitempty"`
}

RequirementEntry describes the coverage status of a single assessment requirement.

type RequirementStatus

type RequirementStatus string

RequirementStatus classifies the implementation state of an assessment requirement.

const (
	// StatusImplemented indicates an enforcement artifact exists but tests were not run.
	StatusImplemented RequirementStatus = "implemented"
	// StatusImplementedPassing indicates an enforcement artifact exists and tests pass.
	StatusImplementedPassing RequirementStatus = "implemented_passing"
	// StatusImplementedFailing indicates an enforcement artifact exists but tests fail.
	StatusImplementedFailing RequirementStatus = "implemented_failing"
	// StatusGap indicates no enforcement artifact exists for this requirement.
	StatusGap RequirementStatus = "gap"
)

type Warning

type Warning struct {
	Message string `json:"message"`
}

Warning records a non-fatal issue encountered during the coverage scan.

Jump to

Keyboard shortcuts

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