compensatingcontrol

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: GPL-3.0 Imports: 4 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 compensatingcontrol provides public types and helpers reusable across the codebase.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompensatingControl

type CompensatingControl struct {
	// contains filtered or unexported fields
}

CompensatingControl represents a security control that mitigates risk without fixing the underlying vulnerability.

func NewCompensatingControl

func NewCompensatingControl(
	tenantID shared.ID,
	name string,
	controlType ControlType,
	reductionFactor float64,
	createdBy shared.ID,
) (*CompensatingControl, error)

NewCompensatingControl creates a new control.

func ReconstituteCompensatingControl

func ReconstituteCompensatingControl(data CompensatingControlData) *CompensatingControl

ReconstituteCompensatingControl recreates from persistence.

func (*CompensatingControl) Activate

func (c *CompensatingControl) Activate()

Activate marks the control as active.

func (*CompensatingControl) ControlType

func (c *CompensatingControl) ControlType() ControlType

func (*CompensatingControl) CreatedAt

func (c *CompensatingControl) CreatedAt() time.Time

func (*CompensatingControl) Deactivate

func (c *CompensatingControl) Deactivate()

Deactivate marks the control as inactive.

func (*CompensatingControl) Description

func (c *CompensatingControl) Description() string

func (*CompensatingControl) ExpiresAt

func (c *CompensatingControl) ExpiresAt() *time.Time

func (*CompensatingControl) ID

func (c *CompensatingControl) ID() shared.ID

Getters

func (*CompensatingControl) IsEffective

func (c *CompensatingControl) IsEffective() bool

IsEffective returns true if the control is active, tested successfully, and not expired.

func (*CompensatingControl) LastTestedAt

func (c *CompensatingControl) LastTestedAt() *time.Time

func (*CompensatingControl) Name

func (c *CompensatingControl) Name() string

func (*CompensatingControl) RecordTest

func (c *CompensatingControl) RecordTest(result TestResult, evidence string)

RecordTest records the result of a control effectiveness test.

func (*CompensatingControl) ReductionFactor

func (c *CompensatingControl) ReductionFactor() float64

func (*CompensatingControl) SetDescription

func (c *CompensatingControl) SetDescription(desc string)

SetDescription updates the description.

func (*CompensatingControl) SetReductionFactor

func (c *CompensatingControl) SetReductionFactor(factor float64) error

SetReductionFactor updates the reduction factor.

func (*CompensatingControl) Status

func (c *CompensatingControl) Status() ControlStatus

func (*CompensatingControl) TenantID

func (c *CompensatingControl) TenantID() shared.ID

func (*CompensatingControl) TestEvidence

func (c *CompensatingControl) TestEvidence() string

func (*CompensatingControl) TestResult

func (c *CompensatingControl) TestResult() *TestResult

type CompensatingControlData

type CompensatingControlData struct {
	ID              shared.ID
	TenantID        shared.ID
	Name            string
	Description     string
	ControlType     ControlType
	Status          ControlStatus
	ReductionFactor float64
	LastTestedAt    *time.Time
	TestResult      *TestResult
	TestEvidence    string
	ExpiresAt       *time.Time
	CreatedBy       *shared.ID
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

CompensatingControlData is the persistence representation.

type ControlStatus

type ControlStatus string

ControlStatus represents the lifecycle status of a control.

const (
	ControlStatusActive   ControlStatus = "active"
	ControlStatusInactive ControlStatus = "inactive"
	ControlStatusExpired  ControlStatus = "expired"
	ControlStatusUntested ControlStatus = "untested"
)

func AllControlStatuses added in v0.4.0

func AllControlStatuses() []ControlStatus

AllControlStatuses returns every valid lifecycle status. Mirrors the compensating_controls_status_check CHECK constraint.

func (ControlStatus) IsValid added in v0.4.0

func (s ControlStatus) IsValid() bool

IsValid reports whether s is a status the database will accept.

type ControlType

type ControlType string

ControlType represents the category of compensating control.

const (
	ControlTypeSegmentation ControlType = "segmentation"
	ControlTypeIdentity     ControlType = "identity"
	ControlTypeRuntime      ControlType = "runtime"
	ControlTypeDetection    ControlType = "detection"
	ControlTypeOther        ControlType = "other"
)

func AllControlTypes added in v0.4.0

func AllControlTypes() []ControlType

AllControlTypes returns every valid control type.

This set is the single source of truth for the vocabulary and mirrors the compensating_controls_control_type_check CHECK constraint exactly. Anything outside it reaches Postgres as a constraint violation, which surfaces to the caller as a 500 instead of a 400 — so validate against this list before writing.

func (ControlType) IsValid added in v0.4.0

func (t ControlType) IsValid() bool

IsValid reports whether t is a control type the database will accept.

type TestResult

type TestResult string

TestResult represents the outcome of a control effectiveness test.

const (
	TestResultPass    TestResult = "pass"
	TestResultFail    TestResult = "fail"
	TestResultPartial TestResult = "partial"
)

func AllTestResults added in v0.4.0

func AllTestResults() []TestResult

AllTestResults returns every valid test outcome. Mirrors the compensating_controls_test_result_check CHECK constraint.

func (TestResult) IsValid added in v0.4.0

func (r TestResult) IsValid() bool

IsValid reports whether r is a test result the database will accept.

Jump to

Keyboard shortcuts

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