gemara

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 16 Imported by: 12

README

go-gemara

Go Reference License Go Version CI Go Report Card

Go SDK for parsing and converting Gemara documents.

Overview

This repository provides Go types and utilities for working with Gemara documents. The Go types are generated from CUE schemas published in the Gemara CUE module (github.com/gemaraproj/gemara@v0) available in the CUE Central Registry.

Installation

go get github.com/gemaraproj/go-gemara

Usage

CLI Tool

The oscalexport command-line tool converts Gemara documents to OSCAL format.

Building the CLI
make build

This builds binaries to ./bin/ directory.

Converting a Control Catalog
./bin/oscalexport catalog ./path/to/catalog.yaml --output ./catalog.json
Converting a Guidance Catalog
./bin/oscalexport guidance ./path/to/guidance.yaml \
    --catalog-output ./guidance.json \
    --profile-output ./profile.json
Library Usage
Loading Gemara Documents
package main

import (
    "github.com/gemaraproj/go-gemara"
    "github.com/gemaraproj/go-gemara/fetcher"
)

func main() {
    f := &fetcher.File{}

    // Load a Guidance Catalog
    guidance, err := gemara.Load[gemara.GuidanceCatalog](f, "path/to/guidance.yaml")
    if err != nil {
        panic(err)
    }

    // Load a Control Catalog
    catalog, err := gemara.Load[gemara.ControlCatalog](f, "path/to/catalog.yaml")
    if err != nil {
        panic(err)
    }

    _ = guidance
    _ = catalog
}
Converting to OSCAL
package main

import (
    "github.com/gemaraproj/go-gemara"
    "github.com/gemaraproj/go-gemara/fetcher"
    "github.com/gemaraproj/go-gemara/gemaraconv"
)

func main() {
    f := &fetcher.File{}

    // Convert Control Catalog to OSCAL
    catalog, err := gemara.Load[gemara.ControlCatalog](f, "path/to/catalog.yaml")
    if err != nil {
        panic(err)
    }

    oscalCatalog, err := gemaraconv.ControlCatalog(catalog).ToOSCAL()
    if err != nil {
        panic(err)
    }

    // Convert Guidance Catalog to OSCAL
    guidance, err := gemara.Load[gemara.GuidanceCatalog](f, "path/to/guidance.yaml")
    if err != nil {
        panic(err)
    }

    _, oscalProfile, err := gemaraconv.GuidanceCatalog(guidance).ToOSCAL("relative/path/to/catalog.json")
    if err != nil {
        panic(err)
    }

    _ = oscalCatalog
    _ = oscalProfile
}
Bundling and Distributing Artifacts via OCI
package main

import (
	"context"
	"os"

	"github.com/gemaraproj/go-gemara/bundle"
	"github.com/gemaraproj/go-gemara/fetcher"
	"oras.land/oras-go/v2"
	"oras.land/oras-go/v2/content/oci"
	"oras.land/oras-go/v2/registry/remote"
)

func main() {
	ctx := context.Background()
	
	data, _ := os.ReadFile("policy.yaml")
	src := bundle.File{Name: "policy.yaml", Data: data}

	// Assemble the full dependency tree (extends + imports)
	m := bundle.Manifest{BundleVersion: "1", GemaraVersion: "v1.0.0"}
	asm := bundle.NewAssembler(&fetcher.URI{})
	b, _ := asm.Assemble(ctx, m, src)

	// Pack into a local OCI layout
	layoutStore, _ := oci.New("./bundle-output")
	desc, _ := bundle.Pack(ctx, layoutStore, b)
	_ = layoutStore.Tag(ctx, desc, "v1.0.0")

	// Push to a remote OCI registry
	repo, _ := remote.NewRepository("registry.example.com/org/bundle")
	tagDesc, _ := layoutStore.Resolve(ctx, "v1.0.0")
	_ = oras.CopyGraph(ctx, layoutStore, repo, tagDesc, oras.DefaultCopyGraphOptions)
	_ = repo.Tag(ctx, tagDesc, "v1.0.0")

	// Unpack from the registry
	unpacked, _ := bundle.Unpack(ctx, repo, "v1.0.0")
	_ = unpacked 
}
Converting to SARIF
package main

import (
    "github.com/gemaraproj/go-gemara"
    "github.com/gemaraproj/go-gemara/fetcher"
    "github.com/gemaraproj/go-gemara/gemaraconv"
)

func main() {
    f := &fetcher.File{}

    // Load Control Catalog (required for SARIF conversion)
    catalog, err := gemara.Load[gemara.ControlCatalog](f, "path/to/catalog.yaml")
    if err != nil {
        panic(err)
    }

    // Convert EvaluationLog to SARIF
    evaluationLog := gemara.EvaluationLog{
        // ... populate evaluation log ...
    }

    sarifBytes, err := gemaraconv.EvaluationLog(evaluationLog).ToSARIF(gemaraconv.WithArtifactURI("file:///path/to/artifact.md"), gemaraconv.WithCatalog(catalog))
    if err != nil {
        panic(err)
    }

    _ = sarifBytes
}
Fetching Remote Artifacts

The fetcher.HTTP and fetcher.URI types follow any URL without filtering, including private network addresses. Applications that process untrusted URLs should supply an http.Client with a safe dialer — see ExampleURI_ssrfSafe for a complete example that blocks private, loopback, and link-local addresses at connect time.

Development

Building
make build
Testing
# Run all tests
make test

# Run tests with coverage
make testcov

# Check coverage threshold
make coverage-check
Linting
make lint

License

Licensed under the Apache License, Version 2.0. See LICENSE for details.

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var SchemaVersion = "v1.0.0"

SchemaVersion displays the version of the Gemara schemas that this commit is configured to support

Functions

func Load added in v0.2.0

func Load[T any](ctx context.Context, f Fetcher, source string) (*T, error)

Load fetches and decodes a single artifact from the given source. Format (YAML or JSON) is detected from the file extension.

Types

type AcceptedMethod

type AcceptedMethod struct {
	Id string `json:"id" yaml:"id"`

	Type MethodType `json:"type" yaml:"type"`

	Mode ModeType `json:"mode" yaml:"mode"`

	Required bool `json:"required" yaml:"required"`

	Description string `json:"description,omitempty" yaml:"description,omitempty"`

	Executor Actor `json:"executor,omitempty" yaml:"executor,omitempty"`
}

AcceptedMethod defines a method for evaluation or enforcement.

type AcceptedRisk

type AcceptedRisk struct {
	// id allows this accepted risk entry to be referenced
	Id string `json:"id" yaml:"id"`

	// target-id optionally links this acceptance to a mitigated risk entry
	Target_id string `json:"target-id,omitempty" yaml:"target-id,omitempty"`

	// risk references the risk being accepted
	Risk EntryMapping `json:"risk" yaml:"risk"`

	// scope defines where the risk acceptance applies
	Scope Scope `json:"scope,omitempty" yaml:"scope,omitempty"`

	// justification explains why the risk is accepted
	Justification string `json:"justification,omitempty" yaml:"justification,omitempty"`
}

AcceptedRisk documents a risk the organization has chosen to accept, optionally linking it to a mitigated risk when the acceptance covers residual risk after partial mitigation.

type ActionResult added in v0.0.3

type ActionResult struct {
	// disposition is the enforcement action taken
	Disposition Disposition `json:"disposition" yaml:"disposition"`

	// method references the specific AcceptedMethod entry within the Policy being enforced
	Method EntryMapping `json:"method" yaml:"method"`

	// message provides additional context about the action
	Message *string `json:"message,omitempty" yaml:"message,omitempty"`

	// start is the timestamp when the enforcement action began
	Start Datetime `json:"start" yaml:"start"`

	// end is the timestamp when the enforcement action concluded
	End Datetime `json:"end,omitempty" yaml:"end,omitempty"`

	// steps references the code paths or addresses that carried out this enforcement action
	Steps []EnforcementStep `json:"steps" yaml:"steps"`

	// justification links the action to its assessment findings and any applicable exceptions
	Justification Justification `json:"justification" yaml:"justification"`
}

ActionResult captures a performed enforcement action.

type Actor

type Actor struct {
	// contact is contact information for the actor
	Contact Contact `json:"contact,omitempty" yaml:"contact,omitempty"`

	// id uniquely identifies the entity and allows this entry to be referenced by other elements
	Id string `json:"id" yaml:"id"`

	// name is the name of the entity
	Name string `json:"name" yaml:"name"`

	// type specifies the type of entity interacting in the workflow
	Type EntityType `json:"type" yaml:"type"`

	// version is the version of the entity (for tools; if applicable)
	Version string `json:"version,omitempty" yaml:"version,omitempty"`

	// description provides additional context about the entity
	Description string `json:"description,omitempty" yaml:"description,omitempty"`

	// uri is a general URI for the entity information
	Uri string `json:"uri,omitempty" yaml:"uri,omitempty"`
}

Actor represents an entity (human or tool) that performs actions in evaluations

type Adherence

type Adherence struct {
	EvaluationMethods []AcceptedMethod `json:"evaluation-methods,omitempty" yaml:"evaluation-methods,omitempty"`

	AssessmentPlans []AssessmentPlan `json:"assessment-plans,omitempty" yaml:"assessment-plans,omitempty"`

	EnforcementMethods []AcceptedMethod `json:"enforcement-methods,omitempty" yaml:"enforcement-methods,omitempty"`

	NonCompliance string `json:"non-compliance,omitempty" yaml:"non-compliance,omitempty"`
}

Adherence defines evaluation methods, assessment plans, enforcement methods, and non-compliance notifications.

type ArtifactMapping added in v0.0.1

type ArtifactMapping struct {
	// reference-id identifies an element from a MappingReference in the artifact's metadata
	ReferenceId string `json:"reference-id" yaml:"reference-id"`

	// remarks is prose regarding the mapped artifact or the mapping relationship
	Remarks string `json:"remarks,omitempty" yaml:"remarks,omitempty"`
}

ArtifactMapping represents a mapping to an external artifact or artifact entry

type ArtifactType added in v0.0.2

type ArtifactType int

ArtifactType identifies the kind of Gemara artifact for unambiguous parsing

const (
	InvalidArtifact ArtifactType = iota
	AuditLogArtifact
	CapabilityCatalogArtifact
	ControlCatalogArtifact
	EnforcementLogArtifact
	EvaluationLogArtifact
	GuidanceCatalogArtifact
	LexiconArtifact
	MappingDocumentArtifact
	PolicyArtifact
	PrincipleCatalogArtifact
	RiskCatalogArtifact
	ThreatCatalogArtifact
	VectorCatalogArtifact
)

func DetectType added in v0.4.0

func DetectType(data []byte) (ArtifactType, error)

DetectType parses only the metadata.type field from raw artifact data, returning the ArtifactType without requiring a full unmarshal.

func (ArtifactType) MarshalJSON added in v0.0.2

func (a ArtifactType) MarshalJSON() ([]byte, error)

MarshalJSON ensures that ArtifactType is serialized as a string in JSON

func (ArtifactType) MarshalYAML added in v0.0.2

func (a ArtifactType) MarshalYAML() (interface{}, error)

MarshalYAML ensures that ArtifactType is serialized as a string in YAML

func (ArtifactType) String added in v0.0.2

func (a ArtifactType) String() string

func (*ArtifactType) UnmarshalJSON added in v0.0.2

func (a *ArtifactType) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that ArtifactType can be deserialized from a JSON string

func (*ArtifactType) UnmarshalText added in v0.7.0

func (a *ArtifactType) UnmarshalText(data []byte) error

UnmarshalText lets yaml.v3-family decoders deserialize ArtifactType from a string

func (*ArtifactType) UnmarshalYAML added in v0.0.2

func (a *ArtifactType) UnmarshalYAML(data []byte) error

UnmarshalYAML ensures that ArtifactType can be deserialized from a YAML string

type AssessmentFinding added in v0.0.3

type AssessmentFinding struct {
	// result is the assessment outcome that triggered the enforcement action
	Result Result `json:"result" yaml:"result"`

	// requirement maps to the Layer 2 assessment requirement that was evaluated
	Requirement EntryMapping `json:"requirement,omitempty" yaml:"requirement,omitempty"`

	// plan maps to the Policy assessment plan that was executed
	Plan EntryMapping `json:"plan,omitempty" yaml:"plan,omitempty"`

	// log maps to the EvaluationLog entry containing the finding
	Log EntryMapping `json:"log" yaml:"log"`
}

AssessmentFinding maps an enforcement action to its originating assessment data across Layer 2, Layer 3, and Layer 5.

type AssessmentLog

type AssessmentLog struct {
	// Requirement should map to the assessment requirement for this assessment.
	Requirement EntryMapping `json:"requirement" yaml:"requirement"`

	// Plan maps to the policy assessment plan being executed.
	Plan *EntryMapping `json:"plan,omitempty" yaml:"plan,omitempty"`

	// Description provides a summary of the assessment procedure.
	Description string `json:"description" yaml:"description"`

	// Result is the overall outcome of the assessment procedure, matching the result of the last step that was run.
	Result Result `json:"result" yaml:"result"`

	// Message provides additional context about the assessment result.
	Message string `json:"message" yaml:"message"`

	// Applicability is elevated from the Layer 2 Assessment Requirement to aid in execution and reporting.
	Applicability []string `json:"applicability" yaml:"applicability"`

	// Steps are sequential actions taken as part of the assessment, which may halt the assessment if a failure occurs.
	Steps []AssessmentStep `json:"steps" yaml:"steps"`

	// Steps-executed is the number of steps that were executed as part of the assessment.
	StepsExecuted int64 `json:"steps-executed,omitempty" yaml:"steps-executed,omitempty"`

	// Start is the timestamp when the assessment began.
	Start Datetime `json:"start" yaml:"start"`

	// End is the timestamp when the assessment concluded.
	End Datetime `json:"end,omitempty" yaml:"end,omitempty"`

	// Recommendation provides guidance on how to address a failed assessment.
	Recommendation string `json:"recommendation,omitempty" yaml:"recommendation,omitempty"`

	// ConfidenceLevel indicates the evaluator's confidence level in this specific assessment result.
	ConfidenceLevel ConfidenceLevel `json:"confidence-level,omitempty" yaml:"confidence-level,omitempty"`

	// Evidence records the raw data cited to support this assessment's opinion.
	Evidence []Evidence `json:"evidence,omitempty" yaml:"evidence,omitempty"`
}

AssessmentLog contains the results of executing a single assessment procedure for a control requirement.

func NewAssessment

func NewAssessment(requirementId string, description string, applicability []string, steps []AssessmentStep) (*AssessmentLog, error)

NewAssessment creates a new AssessmentLog object and returns a pointer to it.

func (*AssessmentLog) AddStep

func (a *AssessmentLog) AddStep(step AssessmentStep)

AddStep queues a new step in the AssessmentLog

func (*AssessmentLog) Run

func (a *AssessmentLog) Run(targetData interface{}) Result

Run will execute all steps, halting if any step does not return Passed.

type AssessmentPlan

type AssessmentPlan struct {
	Id string `json:"id" yaml:"id"`

	RequirementId string `json:"requirement-id" yaml:"requirement-id"`

	Frequency string `json:"frequency" yaml:"frequency"`

	EvaluationMethods []AcceptedMethod `json:"evaluation-methods" yaml:"evaluation-methods"`

	EvidenceRequirements string `json:"evidence-requirements,omitempty" yaml:"evidence-requirements,omitempty"`

	Parameters []Parameter `json:"parameters,omitempty" yaml:"parameters,omitempty"`
}

AssessmentPlan defines how a specific assessment requirement is evaluated.

type AssessmentRequirement

type AssessmentRequirement struct {
	// id allows this entry to be referenced by other elements
	Id string `json:"id" yaml:"id"`

	// text is the body of the requirement, typically written as a MUST condition
	Text string `json:"text" yaml:"text"`

	// applicability is a list of strings describing the situations where this text functions as a requirement for its parent control
	Applicability []string `json:"applicability" yaml:"applicability"`

	// recommendation provides readers with non-binding suggestions to aid in evaluation or enforcement of the requirement
	Recommendation string `json:"recommendation,omitempty" yaml:"recommendation,omitempty"`

	// state is the lifecycle state of this assessment requirement
	State Lifecycle `json:"state" yaml:"state"`

	// replaced-by references the assessment requirement that supersedes this one when deprecated or retired
	ReplacedBy *EntryMapping `json:"replaced-by,omitempty" yaml:"replaced-by,omitempty"`
}

AssessmentRequirement describes a tightly scoped, verifiable condition that must be satisfied and confirmed by an evaluator

type AssessmentRequirementModifier

type AssessmentRequirementModifier struct {
	Id string `json:"id" yaml:"id"`

	TargetId string `json:"target-id" yaml:"target-id"`

	ModificationType ModType `json:"modification-type" yaml:"modification-type"`

	ModificationRationale string `json:"modification-rationale" yaml:"modification-rationale"`

	// The updated text of the assessment requirement
	Text string `json:"text,omitempty" yaml:"text,omitempty"`

	// The updated applicability of the assessment requirement
	Applicability []string `json:"applicability,omitempty" yaml:"applicability,omitempty"`

	// The updated recommendation for the assessment requirement
	Recommendation string `json:"recommendation,omitempty" yaml:"recommendation,omitempty"`
}

AssessmentRequirementModifier allows organizations to customize assessment requirements based on how an organization wants to gather evidence for the objective.

type AssessmentStep

type AssessmentStep func(payload interface{}) (Result, string, ConfidenceLevel)

AssessmentStep is a function type that inspects the provided targetData and returns a Result with a message and confidence level. The message may be an error string or other descriptive text.

func (AssessmentStep) MarshalJSON

func (as AssessmentStep) MarshalJSON() ([]byte, error)

func (AssessmentStep) MarshalYAML

func (as AssessmentStep) MarshalYAML() (interface{}, error)

func (AssessmentStep) String

func (as AssessmentStep) String() string

type AuditLog added in v0.0.3

type AuditLog struct {
	// metadata provides detailed data about this log
	Metadata Metadata `json:"metadata" yaml:"metadata"`

	// owner defines the RACI roles responsible for managing the audit
	Owner RACI `json:"owner,omitempty" yaml:"owner,omitempty"`

	// summary provides the high-level conclusion
	Summary string `json:"summary" yaml:"summary"`

	// criteria defines the acceptable state for the audited resource
	Criteria []ArtifactMapping `json:"criteria" yaml:"criteria"`

	// results records audit results against the criteria
	Results []*AuditResult `json:"results" yaml:"results"`

	// target identifies the resource being evaluated
	Target Resource `json:"target" yaml:"target"`
}

AuditLog records results from an audit performed against a target resource

type AuditResult added in v0.0.3

type AuditResult struct {
	// id uniquely identifies this result
	Id string `json:"id" yaml:"id"`

	// title describes this result at a glance
	Title string `json:"title" yaml:"title"`

	// type classifies the nature of this result
	Type ResultType `json:"type" yaml:"type"`

	// description explains the result in detail
	Description string `json:"description" yaml:"description"`

	// criteria-reference maps this result to specific criteria entries
	CriteriaReference MultiEntryMapping `json:"criteria-reference" yaml:"criteria-reference"`

	// evidence records the data sources that support this result
	Evidence []Evidence `json:"evidence,omitempty" yaml:"evidence,omitempty"`

	// recommendations records corrective actions for this result
	Recommendations []Recommendation `json:"recommendations,omitempty" yaml:"recommendations,omitempty"`
}

AuditResult records a single result with supporting evidence and recommendations.

type Capability

type Capability struct {
	// id allows this entry to be referenced by other elements
	Id string `json:"id" yaml:"id"`

	// title describes this capability at a glance
	Title string `json:"title" yaml:"title"`

	// description provides a detailed overview of this capability
	Description string `json:"description" yaml:"description"`

	// group references by id a catalog group that this capability belongs to
	Group string `json:"group" yaml:"group"`
}

Capability describes a system capability such as a feature, component or object.

type CapabilityCatalog added in v0.0.3

type CapabilityCatalog struct {
	// title describes the purpose of this catalog at a glance
	Title string `json:"title" yaml:"title"`

	// metadata provides detailed data about this catalog
	Metadata Metadata `json:"metadata" yaml:"metadata"`

	// capabilities is a list of capabilities defined by this catalog
	Capabilities []Capability `json:"capabilities,omitempty" yaml:"capabilities,omitempty"`

	// groups contains a list of groups that can be referenced by entries in this catalog
	Groups []Group `json:"groups,omitempty" yaml:"groups,omitempty"`

	// extends references catalogs that this catalog builds upon
	Extends []ArtifactMapping `json:"extends,omitempty" yaml:"extends,omitempty"`

	Imports []MultiEntryMapping `json:"imports,omitempty" yaml:"imports,omitempty"`
}

CapabilityCatalog describes a collection of system capabilities

type Catalog

type Catalog struct {
	// title describes the purpose of this catalog at a glance
	Title string `json:"title" yaml:"title"`

	// metadata provides detailed data about this catalog
	Metadata Metadata `json:"metadata" yaml:"metadata"`

	// groups contains a list of groups that can be referenced by entries in this catalog
	Groups []Group `json:"groups,omitempty" yaml:"groups,omitempty"`

	// extends references catalogs that this catalog builds upon
	Extends []ArtifactMapping `json:"extends,omitempty" yaml:"extends,omitempty"`

	Imports []MultiEntryMapping `json:"imports,omitempty" yaml:"imports,omitempty"`
}

Catalog describes a set of topically-associated entries

type CatalogImport

type CatalogImport struct {
	ReferenceId string `json:"reference-id" yaml:"reference-id"`

	Exclusions []string `json:"exclusions,omitempty" yaml:"exclusions,omitempty"`

	Constraints []Constraint `json:"constraints,omitempty" yaml:"constraints,omitempty"`

	AssessmentRequirementModifications []AssessmentRequirementModifier `json:"assessment-requirement-modifications,omitempty" yaml:"assessment-requirement-modifications,omitempty"`
}

CatalogImport defines how to import control catalogs with optional exclusions, constraints, and assessment requirement modifications.

type Checklist

type Checklist struct {
	// PolicyId identifies the policy.
	PolicyId string
	// PolicyTitle is the title of the policy.
	PolicyTitle string
	// Author is the name of the policy author.
	Author string
	// AuthorVersion is the version of the authoring tool or system.
	AuthorVersion string
	// Sections are the requirement sections
	Sections []RequirementSection
}

Checklist represents the structured checklist data.

type ChecklistItem

type ChecklistItem struct {
	// PlanId is the assessment plan identifier this item belongs to.
	PlanId string
	// MethodDescription provides additional context or a summary about the method.
	MethodDescription string
	// MethodType defines the category the method falls into.
	MethodType string
	// Frequency indicates how often this assessment should be performed.
	Frequency string
	// EvidenceRequirements describes what evidence is required for this assessment.
	EvidenceRequirements string
}

ChecklistItem represents a single checklist item.

type ConfidenceLevel

type ConfidenceLevel int

ConfidenceLevel indicates the evaluator's confidence level in an assessment result.

const (
	Undetermined ConfidenceLevel = iota
	Low
	Medium
	High
)

func (ConfidenceLevel) MarshalJSON

func (c ConfidenceLevel) MarshalJSON() ([]byte, error)

MarshalJSON ensures that ConfidenceLevel is serialized as a string in JSON

func (ConfidenceLevel) MarshalYAML

func (c ConfidenceLevel) MarshalYAML() (interface{}, error)

MarshalYAML ensures that ConfidenceLevel is serialized as a string in YAML

func (ConfidenceLevel) String

func (c ConfidenceLevel) String() string

func (*ConfidenceLevel) UnmarshalJSON added in v0.0.2

func (c *ConfidenceLevel) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that ConfidenceLevel can be deserialized from a JSON string

func (*ConfidenceLevel) UnmarshalText added in v0.7.0

func (c *ConfidenceLevel) UnmarshalText(data []byte) error

UnmarshalText lets yaml.v3-family decoders deserialize ConfidenceLevel from a string

func (*ConfidenceLevel) UnmarshalYAML added in v0.0.2

func (c *ConfidenceLevel) UnmarshalYAML(data []byte) error

UnmarshalYAML ensures that ConfidenceLevel can be deserialized from a YAML string

type Constraint

type Constraint struct {
	// Unique ID for this constraint to enable Layer 5/6 tracking
	Id string `json:"id" yaml:"id"`

	// Links to the specific Guidance or Control being constrained
	TargetId string `json:"target-id" yaml:"target-id"`

	// The prescriptive requirement/constraint text
	Text string `json:"text" yaml:"text"`
}

Constraint defines a prescriptive requirement that applies to a specific guidance or control.

type Contact

type Contact struct {
	// name is the preferred descriptor for the contact entity
	Name string `json:"name" yaml:"name"`

	// affiliation is the organization with which the contact entity is associated, such as a team, school, or employer
	Affiliation *string `json:"affiliation,omitempty" yaml:"affiliation,omitempty"`

	// email is the preferred email address to reach the contact
	Email *Email `json:"email,omitempty" yaml:"email,omitempty"`

	// social is a social media handle or other profile for the contact, such as GitHub
	Social *string `json:"social,omitempty" yaml:"social,omitempty"`
}

Contact is the contact information for a person or group

type Control

type Control struct {
	// id allows this entry to be referenced by other elements
	Id string `json:"id" yaml:"id"`

	// title describes the purpose of this control at a glance
	Title string `json:"title" yaml:"title"`

	// objective is a unified statement of intent, which may encompass multiple situationally applicable requirements
	Objective string `json:"objective" yaml:"objective"`

	// group references by id a catalog group that this control belongs to
	Group string `json:"group" yaml:"group"`

	// assessment-requirements is a list of requirements that must be verified to confirm the control objective has been met
	AssessmentRequirements []AssessmentRequirement `json:"assessment-requirements" yaml:"assessment-requirements"`

	// guidelines documents relationships between this control and Layer 1 guideline artifacts
	Guidelines []MultiEntryMapping `json:"guidelines,omitempty" yaml:"guidelines,omitempty"`

	// threats documents relationships between this control and Layer 2 threat artifacts
	Threats []MultiEntryMapping `json:"threats,omitempty" yaml:"threats,omitempty"`

	// state is the lifecycle state of this control
	State Lifecycle `json:"state" yaml:"state"`

	// replaced-by references the control that supersedes this one when deprecated or retired
	ReplacedBy *EntryMapping `json:"replaced-by,omitempty" yaml:"replaced-by,omitempty"`
}

Control describes a safeguard or countermeasure with a clear objective and assessment requirements

func (*Control) Sugar added in v0.0.3

func (c *Control) Sugar() *SControl

Sugar wraps this Control in a SControl for convenient cached helper access. Cached results are computed once on first access and never invalidated, so the wrapper should not be reused after the underlying data has changed. Call Sugar again or use FromBase to reset caches.

func (*Control) UnmarshalYAML added in v0.0.3

func (c *Control) UnmarshalYAML(data []byte) error

UnmarshalYAML allows decoding controls from older/alternate YAML schemas. In particular, it supports using `family` instead of the struct's `group` key.

type ControlCatalog added in v0.0.1

type ControlCatalog struct {
	// title describes the purpose of this catalog at a glance
	Title string `json:"title" yaml:"title"`

	// metadata provides detailed data about this catalog
	Metadata Metadata `json:"metadata" yaml:"metadata"`

	// controls is a list of unique controls defined by this catalog
	Controls []Control `json:"controls,omitempty" yaml:"controls,omitempty"`

	// groups contains a list of groups that can be referenced by entries in this catalog
	Groups []Group `json:"groups,omitempty" yaml:"groups,omitempty"`

	// extends references catalogs that this catalog builds upon
	Extends []ArtifactMapping `json:"extends,omitempty" yaml:"extends,omitempty"`

	Imports []MultiEntryMapping `json:"imports,omitempty" yaml:"imports,omitempty"`
}

ControlCatalog describes a set of related controls and relevant metadata

func (*ControlCatalog) LoadFiles added in v0.0.1

func (c *ControlCatalog) LoadFiles(ctx context.Context, f Fetcher, sources []string) error

LoadFiles loads and merges data from multiple sources into the ControlCatalog.

func (*ControlCatalog) LoadNestedCatalog added in v0.0.1

func (c *ControlCatalog) LoadNestedCatalog(ctx context.Context, f Fetcher, source, fieldName string) error

LoadNestedCatalog loads a YAML file where the ControlCatalog is nested under a single wrapper key (e.g. "catalog:"). Only supports one layer of nesting.

func (*ControlCatalog) Sugar added in v0.0.3

func (c *ControlCatalog) Sugar() *SControlCatalog

Sugar wraps this ControlCatalog in a SControlCatalog for convenient cached helper access. Cached results are computed once on first access and never invalidated, so the wrapper should not be reused after the underlying data has changed. Call Sugar again or use FromBase to reset caches.

func (*ControlCatalog) UnmarshalYAML added in v0.0.3

func (c *ControlCatalog) UnmarshalYAML(data []byte) error

UnmarshalYAML allows decoding control catalogs from older/alternate YAML schemas. It supports mapping `families` -> `groups`.

type ControlEvaluation

type ControlEvaluation struct {
	Name string `json:"name" yaml:"name"`

	Result Result `json:"result" yaml:"result"`

	Message string `json:"message" yaml:"message"`

	Control EntryMapping `json:"control" yaml:"control"`

	// Enforce that control reference and the assessments' references match
	// This formulation uses the control's reference if the assessment doesn't include a reference
	AssessmentLogs []*AssessmentLog `json:"assessment-logs" yaml:"assessment-logs"`
}

ControlEvaluation contains the results of evaluating a single Layer 5 control.

func (*ControlEvaluation) AddAssessment

func (c *ControlEvaluation) AddAssessment(requirementId string, description string, applicability []string, steps []AssessmentStep) (assessment *AssessmentLog)

AddAssessment creates a new AssessmentLog object and adds it to the ControlEvaluation.

func (*ControlEvaluation) Evaluate

func (c *ControlEvaluation) Evaluate(targetData interface{}, userApplicability []string)

Evaluate runs each step in each assessment, updating the relevant fields on the control evaluation. It will halt if a step returns a failed result. The targetData is the data that the assessment will be run against. The userApplicability is a slice of strings that determine when the assessment is applicable. The changesAllowed determines whether the assessment is allowed to execute its changes.

type Datetime

type Datetime string

Datetime represents an ISO 8601 formatted datetime string

type Dimensions

type Dimensions struct {
	// technologies is an optional list of technology categories or services
	Technologies []string `json:"technologies,omitempty" yaml:"technologies,omitempty"`

	// geopolitical is an optional list of geopolitical regions
	Geopolitical []string `json:"geopolitical,omitempty" yaml:"geopolitical,omitempty"`

	// sensitivity is an optional list of data classification levels
	Sensitivity []string `json:"sensitivity,omitempty" yaml:"sensitivity,omitempty"`

	// users is an optional list of user roles
	Users []string `json:"users,omitempty" yaml:"users,omitempty"`

	Groups []string `json:"groups,omitempty" yaml:"groups,omitempty"`
}

Dimensions specify the applicability criteria for a policy

type Disposition added in v0.0.3

type Disposition int

Disposition enumerates the possible enforcement outcomes.

const (
	DispositionUndetermined Disposition = iota
	DispositionEnforced
	DispositionTolerated
	DispositionClear
)

func (Disposition) MarshalJSON added in v0.0.3

func (d Disposition) MarshalJSON() ([]byte, error)

MarshalJSON ensures that Disposition is serialized as a string in JSON

func (Disposition) MarshalYAML added in v0.0.3

func (d Disposition) MarshalYAML() (interface{}, error)

MarshalYAML ensures that Disposition is serialized as a string in YAML

func (Disposition) String added in v0.0.3

func (d Disposition) String() string

func (*Disposition) UnmarshalJSON added in v0.0.3

func (d *Disposition) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that Disposition can be deserialized from a JSON string

func (*Disposition) UnmarshalText added in v0.7.0

func (d *Disposition) UnmarshalText(data []byte) error

UnmarshalText lets yaml.v3-family decoders deserialize Disposition from a string

func (*Disposition) UnmarshalYAML added in v0.0.3

func (d *Disposition) UnmarshalYAML(data []byte) error

UnmarshalYAML ensures that Disposition can be deserialized from a YAML string

type Email

type Email string

Email represents a validated email address pattern

type EnforcementLog added in v0.0.3

type EnforcementLog struct {
	// metadata provides detailed data about this log
	Metadata Metadata `json:"metadata" yaml:"metadata"`

	// disposition is the aggregate enforcement disposition across all actions in this log
	Disposition Disposition `json:"disposition" yaml:"disposition"`

	// actions is the list of enforcement actions performed
	//
	// Enforce that Clear dispositions only contain Passed assessment results
	Actions []*ActionResult `json:"actions" yaml:"actions"`

	// target identifies the resource being evaluated
	Target Resource `json:"target" yaml:"target"`
}

EnforcementLog records actions taken in response to noncompliance findings from Layer 5 evaluations.

type EnforcementStep added in v0.0.3

type EnforcementStep string

EnforcementStep is a reference to the code path that performed an enforcement action.

type Entity added in v0.0.2

type Entity struct {
	// id uniquely identifies the entity and allows this entry to be referenced by other elements
	Id string `json:"id" yaml:"id"`

	// name is the name of the entity
	Name string `json:"name" yaml:"name"`

	// type specifies the type of entity interacting in the workflow
	Type EntityType `json:"type" yaml:"type"`

	// version is the version of the entity (for tools; if applicable)
	Version string `json:"version,omitempty" yaml:"version,omitempty"`

	// description provides additional context about the entity
	Description string `json:"description,omitempty" yaml:"description,omitempty"`

	// uri is a general URI for the entity information
	Uri string `json:"uri,omitempty" yaml:"uri,omitempty"`
}

Entity represents a human or tool

type EntityType added in v0.0.2

type EntityType int

EntityType specifies the type of entity (human or tool) interacting in the workflow.

const (
	InvalidEntityType EntityType = iota
	Human
	Software
	SoftwareAssisted
)

func (EntityType) MarshalJSON added in v0.0.2

func (e EntityType) MarshalJSON() ([]byte, error)

MarshalJSON ensures that EntityType is serialized as a string in JSON

func (EntityType) MarshalYAML added in v0.0.2

func (e EntityType) MarshalYAML() (interface{}, error)

MarshalYAML ensures that EntityType is serialized as a string in YAML

func (EntityType) String added in v0.0.2

func (e EntityType) String() string

func (*EntityType) UnmarshalJSON added in v0.0.2

func (e *EntityType) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that EntityType can be deserialized from a JSON string

func (*EntityType) UnmarshalText added in v0.7.0

func (e *EntityType) UnmarshalText(data []byte) error

UnmarshalText lets yaml.v3-family decoders deserialize EntityType from a string

func (*EntityType) UnmarshalYAML added in v0.0.2

func (e *EntityType) UnmarshalYAML(data []byte) error

UnmarshalYAML ensures that EntityType can be deserialized from a YAML string

type EntryMapping added in v0.0.1

type EntryMapping struct {
	// reference-id is the id for a MappingReference entry in the artifact's metadata
	ReferenceId string `json:"reference-id" yaml:"reference-id"`

	// entry-id is the identifier being mapped to in the referenced artifact
	EntryId string `json:"entry-id" yaml:"entry-id"`

	// remarks is prose describing the mapping relationship
	Remarks string `json:"remarks,omitempty" yaml:"remarks,omitempty"`
}

EntryMapping represents how a specific entry maps to a MappingReference.

type EntryType added in v0.0.2

type EntryType int

EntryType enumerates the atomic units within Gemara artifacts that can participate in mappings

const (
	InvalidEntryType EntryType = iota
	EntryTypeGuideline
	EntryTypeStatement
	EntryTypeControl
	EntryTypeAssessmentRequirement
	EntryTypeCapability
	EntryTypeThreat
	EntryTypeRisk
	EntryTypeVector
	EntryTypePrinciple
)

func (EntryType) MarshalJSON added in v0.0.2

func (e EntryType) MarshalJSON() ([]byte, error)

MarshalJSON ensures that EntryType is serialized as a string in JSON

func (EntryType) MarshalYAML added in v0.0.2

func (e EntryType) MarshalYAML() (interface{}, error)

MarshalYAML ensures that EntryType is serialized as a string in YAML

func (EntryType) String added in v0.0.2

func (e EntryType) String() string

func (*EntryType) UnmarshalJSON added in v0.0.2

func (e *EntryType) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that EntryType can be deserialized from a JSON string

func (*EntryType) UnmarshalText added in v0.7.0

func (e *EntryType) UnmarshalText(data []byte) error

UnmarshalText lets yaml.v3-family decoders deserialize EntryType from a string

func (*EntryType) UnmarshalYAML added in v0.0.2

func (e *EntryType) UnmarshalYAML(data []byte) error

UnmarshalYAML ensures that EntryType can be deserialized from a YAML string

type EvaluationLog

type EvaluationLog struct {
	// metadata provides detailed data about this log
	Metadata Metadata `json:"metadata" yaml:"metadata"`

	// result is the aggregate outcome across all evaluations in this log
	Result Result `json:"result" yaml:"result"`

	Evaluations []*ControlEvaluation `json:"evaluations" yaml:"evaluations"`

	// target identifies the resource being evaluated
	Target Resource `json:"target" yaml:"target"`
}

EvaluationLog contains the results of evaluating a set of Layer 2 controls.

type Evidence added in v0.0.3

type Evidence struct {
	// id uniquely identifies this evidence
	Id string `json:"id" yaml:"id"`

	// type categorizes the kind of evidence
	Type EvidenceType `json:"type" yaml:"type"`

	// collected-at is the timestamp when the evidence was gathered
	CollectedAt Datetime `json:"collected-at" yaml:"collected-at"`

	// payload is the raw evidence data collected
	Payload any `json:"payload,omitempty" yaml:"payload,omitempty"`

	// description explains what this evidence represents
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
}

Evidence records what was cited to support an opinion for a specific activity: raw data for the evaluation layer, evaluation and enforcement artifacts for the audit layer.

type EvidenceCollector added in v0.7.0

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

EvidenceCollector is an embeddable helper that gives a targetData payload the well-known evidence location and satisfies HasEvidence via method promotion, so the consumer writes no methods. Embed it in a payload struct:

type myTarget struct {
	gemara.EvidenceCollector
	Config SomeConfig
}

t := &myTarget{Config: cfg}   // pointer, so step mutations propagate
t.AddEvidence(ev)             // inside a step; may be called more than once
assessment.Run(t)             // copies evidence into assessment.Evidence,
                              // clearing the payload after each step

func (*EvidenceCollector) AddEvidence added in v0.7.0

func (e *EvidenceCollector) AddEvidence(evidence Evidence)

AddEvidence appends a piece of evidence, so a single step may record evidence more than once. The accumulated evidence is copied into the log and cleared after each step runs.

func (*EvidenceCollector) ClearEvidence added in v0.7.0

func (e *EvidenceCollector) ClearEvidence()

ClearEvidence empties the evidence location. The assessment calls it after copying each step's evidence into the log, so evidence does not linger in memory or get re-copied by a later step that records nothing.

func (*EvidenceCollector) GetEvidence added in v0.7.0

func (e *EvidenceCollector) GetEvidence() []Evidence

GetEvidence returns the evidence recorded since the last clear.

type EvidenceType added in v0.0.3

type EvidenceType string

EvidenceType categorizes the kind of evidence referenced in an audit

func (EvidenceType) ToArtifactType added in v0.0.3

func (e EvidenceType) ToArtifactType() (ArtifactType, error)

ToArtifactType converts an EvidenceType to the corresponding ArtifactType.

type Exemption

type Exemption struct {
	// description identifies who or what is exempt from the full guidance
	Description string `json:"description" yaml:"description"`

	// reason explains why the exemption is granted
	Reason string `json:"reason" yaml:"reason"`

	// redirect points to alternative guidelines or controls that should be followed instead
	Redirect *MultiEntryMapping `json:"redirect,omitempty" yaml:"redirect,omitempty"`
}

Exemption describes a single scenario where the catalog is not applicable

type Fetcher added in v0.2.0

type Fetcher interface {
	Fetch(ctx context.Context, source string) (io.ReadCloser, error)
}

Fetcher retrieves content from a source location.

Network-capable implementations (e.g. [fetcher.HTTP], [fetcher.URI]) will follow any URL without filtering; see their documentation for details.

type Group added in v0.0.2

type Group struct {
	// id allows this entry to be referenced by other elements
	Id string `json:"id" yaml:"id"`

	// title describes the purpose of this group at a glance
	Title string `json:"title" yaml:"title"`

	// description explains the significance and traits of entries to this group
	Description string `json:"description" yaml:"description"`
}

Group represents a classification or grouping that can be used in different contexts with semantic meaning derived from its usage

type GuidanceCatalog added in v0.0.1

type GuidanceCatalog struct {
	// title describes the purpose of this catalog at a glance
	Title string `json:"title" yaml:"title"`

	// metadata provides detailed data about this catalog
	Metadata Metadata `json:"metadata" yaml:"metadata"`

	// groups contains a list of groups that can be referenced by entries in this catalog
	Groups []Group `json:"groups,omitempty" yaml:"groups,omitempty"`

	// extends references catalogs that this catalog builds upon
	Extends []ArtifactMapping `json:"extends,omitempty" yaml:"extends,omitempty"`

	Imports []MultiEntryMapping `json:"imports,omitempty" yaml:"imports,omitempty"`

	// type categorizes this document based on the intent of its contents
	GuidanceType GuidanceType `json:"type" yaml:"type"`

	// front-matter provides introductory text for the document to be used during rendering
	FrontMatter string `json:"front-matter,omitempty" yaml:"front-matter,omitempty"`

	// guidelines is a list of unique guidelines defined by this catalog
	Guidelines []Guideline `json:"guidelines,omitempty" yaml:"guidelines,omitempty"`

	// exemptions provides information about situations where this guidance is not applicable
	Exemptions []Exemption `json:"exemptions,omitempty" yaml:"exemptions,omitempty"`
}

GuidanceCatalog represents a concerted documentation effort to help bring about an optimal future without foreknowledge of the implementation details

Example
package main

import (
	"fmt"
	"os"
	"text/template"

	"github.com/gemaraproj/go-gemara/internal/codec"
)

// Adapted from: https://github.com/finos/ai-governance-framework/blob/main/docs/_mitigations/mi-11_human-feedback-loop-for-ai-systems.md

func main() {
	tmpl := `# {{ .Title }} ({{ .Metadata.Id }})
---
**Front Matter:** {{ .FrontMatter }}
---
{{- $doc := . }}{{ range .Groups }}

### {{ .Title }} ({{ .Id }})
{{ .Description }}
#### Guidelines:
{{- $familyId := .Id }}{{ range $doc.Guidelines }}{{ if eq .Group $familyId }}

##### {{ .Title }} ({{ .Id }})
**Objective:** {{ .Objective }}
{{- if .SeeAlso }}

**See Also:** {{ range $index, $item := .SeeAlso }}{{ if $index }} {{ end }}{{ $item }}{{ end }}
{{- end }}

{{- end }}{{ end -}}
{{ end }}`

	l1Docs, err := goodAIGFExample()
	if err != nil {
		fmt.Printf("error getting testdata: %v\n", err)
		return
	}
	t, err := template.New("guidance").Parse(tmpl)
	if err != nil {
		fmt.Printf("error parsing template: %v\n", err)
		return
	}

	err = t.Execute(os.Stdout, l1Docs)
	if err != nil {
		fmt.Printf("error executing template: %v\n", err)
	}
}

func goodAIGFExample() (GuidanceCatalog, error) {
	testdataPath := "./test-data/good-aigf.yaml"
	data, err := os.ReadFile(testdataPath)
	if err != nil {
		return GuidanceCatalog{}, err
	}
	var l1Docs GuidanceCatalog
	if err := codec.UnmarshalYAML(data, &l1Docs); err != nil {
		return GuidanceCatalog{}, err
	}
	return l1Docs, nil
}
Output:
# AI Governance Framework (FINOS-AIR)
---
**Front Matter:** The following framework has been developed by FINOS (Fintech Open Source Foundation).
---

### Detective (DET)
Detection and Continuous Improvement
#### Guidelines:

##### Human Feedback Loop for AI Systems (AIR-DET-011)
**Objective:** A Human Feedback Loop is a critical detective and continuous improvement mechanism that involves systematically collecting, analyzing, and acting upon feedback provided by human users, subject matter experts (SMEs), or reviewers regarding an AI system's performance, outputs, or behavior.

**See Also:** AIR-DET-015 AIR-DET-004 AIR-PREV-005

##### Example Detective Control 004 (AIR-DET-004)
**Objective:** Placeholder control for testing references.

##### Example Detective Control 015 (AIR-DET-015)
**Objective:** Placeholder control for testing references.

### Preventive (PREV)
Prevention and Risk Mitigation
#### Guidelines:

##### Example Preventive Control 005 (AIR-PREV-005)
**Objective:** Placeholder control for testing references.

func (*GuidanceCatalog) LoadFiles added in v0.0.1

func (g *GuidanceCatalog) LoadFiles(ctx context.Context, f Fetcher, sources []string) error

LoadFiles loads and merges data from multiple sources into the GuidanceCatalog.

func (*GuidanceCatalog) UnmarshalYAML added in v0.0.3

func (g *GuidanceCatalog) UnmarshalYAML(data []byte) error

UnmarshalYAML allows decoding guidance from older/alternate YAML schemas. It supports: - `families` -> `groups` - `document-type` -> `type`

type GuidanceImport

type GuidanceImport struct {
	ReferenceId string `json:"reference-id" yaml:"reference-id"`

	Exclusions []string `json:"exclusions,omitempty" yaml:"exclusions,omitempty"`

	// Constraints allow policy authors to define ad hoc minimum requirements (e.g., "review at least annually").
	Constraints []Constraint `json:"constraints,omitempty" yaml:"constraints,omitempty"`
}

GuidanceImport defines how to import guidance documents with optional exclusions and constraints.

type GuidanceType added in v0.0.1

type GuidanceType int

GuidanceType restricts the possible types that a catalog may be listed as.

const (
	InvalidGuidanceType GuidanceType = iota
	GuidanceStandard
	GuidanceRegulation
	GuidanceBestPractice
	GuidanceFramework
)

func (GuidanceType) MarshalJSON added in v0.0.2

func (g GuidanceType) MarshalJSON() ([]byte, error)

MarshalJSON ensures that GuidanceType is serialized as a string in JSON

func (GuidanceType) MarshalYAML added in v0.0.2

func (g GuidanceType) MarshalYAML() (interface{}, error)

MarshalYAML ensures that GuidanceType is serialized as a string in YAML

func (GuidanceType) String added in v0.0.2

func (g GuidanceType) String() string

func (*GuidanceType) UnmarshalJSON added in v0.0.2

func (g *GuidanceType) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that GuidanceType can be deserialized from a JSON string

func (*GuidanceType) UnmarshalText added in v0.7.0

func (g *GuidanceType) UnmarshalText(data []byte) error

UnmarshalText lets yaml.v3-family decoders deserialize GuidanceType from a string

func (*GuidanceType) UnmarshalYAML added in v0.0.2

func (g *GuidanceType) UnmarshalYAML(data []byte) error

UnmarshalYAML ensures that GuidanceType can be deserialized from a YAML string

type Guideline

type Guideline struct {
	// id allows this entry to be referenced by other elements
	Id string `json:"id" yaml:"id"`

	// title describes the contents of this guideline
	Title string `json:"title" yaml:"title"`

	// objective is a unified statement of intent, which may encompass multiple situationally applicable statements
	Objective string `json:"objective" yaml:"objective"`

	// group provides an id to the group that this guideline belongs to
	Group string `json:"group" yaml:"group"`

	// recommendations is a list of non-binding suggestions to aid in evaluation or enforcement of the guideline
	Recommendations []string `json:"recommendations,omitempty" yaml:"recommendations,omitempty"`

	// extends is an id for a guideline which this guideline adds to, in this document or elsewhere
	Extends *EntryMapping `json:"extends,omitempty" yaml:"extends,omitempty"`

	// applicability specifies the contexts in which this guideline applies
	Applicability []string `json:"applicability,omitempty" yaml:"applicability,omitempty"`

	// rationale provides the context for this guideline
	Rationale *Rationale `json:"rationale,omitempty" yaml:"rationale,omitempty"`

	// statements is a list of structural sub-requirements within a guideline
	Statements []Statement `json:"statements,omitempty" yaml:"statements,omitempty"`

	// principles documents the relationship between this guideline and one or more principles
	Principles []MultiEntryMapping `json:"principles,omitempty" yaml:"principles,omitempty"`

	// vector-mappings documents the relationship between this guideline and one or more vectors
	Vectors []MultiEntryMapping `json:"vectors,omitempty" yaml:"vectors,omitempty"`

	// see-also lists related guideline IDs within the same GuidanceCatalog
	SeeAlso []string `json:"see-also,omitempty" yaml:"see-also,omitempty"`

	// state is the lifecycle state of this guideline
	State Lifecycle `json:"state" yaml:"state"`

	// replaced-by references the guideline that supersedes this one when deprecated or retired
	ReplacedBy *EntryMapping `json:"replaced-by,omitempty" yaml:"replaced-by,omitempty"`
}

Guideline provides explanatory context and recommendations for designing optimal outcomes

func (*Guideline) UnmarshalYAML added in v0.0.3

func (g *Guideline) UnmarshalYAML(data []byte) error

UnmarshalYAML allows decoding guidance from older/alternate YAML schemas. In particular, it supports using `family` instead of the struct's `group` key.

type HasEvidence added in v0.7.0

type HasEvidence interface {
	// GetEvidence returns the evidence recorded since the last clear.
	GetEvidence() []Evidence

	// AddEvidence appends a piece of evidence; it may be called more than once
	// within a single step.
	AddEvidence(evidence Evidence)

	// ClearEvidence empties the evidence location. The assessment calls it after
	// copying each step's evidence into the log, so a later step that records
	// nothing does not cause this step's evidence to be re-copied.
	ClearEvidence()
}

HasEvidence is the well-known interface a targetData payload may implement to surface Evidence collected while an assessment runs. A step records evidence into the payload (typically by mutating a shared field, which requires the payload to be passed by reference), and the AssessmentLog harvests it from this single location after running.

Implementing the interface is optional: a payload that does not implement it simply contributes no evidence, which is not an error.

type ImplementationDetails

type ImplementationDetails struct {
	Start Datetime `json:"start" yaml:"start"`

	End Datetime `json:"end,omitempty" yaml:"end,omitempty"`

	Notes string `json:"notes" yaml:"notes"`
}

ImplementationDetails specifies the timeline for policy implementation.

type ImplementationPlan

type ImplementationPlan struct {
	NotificationProcess string `json:"notification-process,omitempty" yaml:"notification-process,omitempty"`

	EvaluationTimeline ImplementationDetails `json:"evaluation-timeline" yaml:"evaluation-timeline"`

	EnforcementTimeline ImplementationDetails `json:"enforcement-timeline" yaml:"enforcement-timeline"`
}

ImplementationPlan defines when and how the policy becomes active.

type Imports

type Imports struct {
	Policies []ArtifactMapping `json:"policies,omitempty" yaml:"policies,omitempty"`

	Catalogs []CatalogImport `json:"catalogs,omitempty" yaml:"catalogs,omitempty"`

	Guidance []GuidanceImport `json:"guidance,omitempty" yaml:"guidance,omitempty"`
}

Imports defines external policies, controls, and guidelines required by this policy.

type Justification added in v0.0.3

type Justification struct {
	// assessments links the action to one or more Assessment Findings
	Assessments []AssessmentFinding `json:"assessments" yaml:"assessments"`

	// exceptions references approved Policy exceptions that authorize the action
	Exceptions []ArtifactMapping `json:"exceptions,omitempty" yaml:"exceptions,omitempty"`
}

Justification provides the assessment data and exception references that justify an enforcement action.

type Lexicon added in v0.0.3

type Lexicon struct {
	// title describes the purpose of this lexicon at a glance
	Title string `json:"title" yaml:"title"`

	// metadata provides detailed data about this document
	Metadata Metadata `json:"metadata" yaml:"metadata"`

	// terms is one or more defined entries for linking and rendering
	Terms []LexiconTerm `json:"terms" yaml:"terms"`
}

Lexicon is a controlled vocabulary or glossary artifact referenced by Metadata.lexicon

type LexiconReference added in v0.0.3

type LexiconReference struct {
	// citation identifies the source material in prose
	Citation string `json:"citation" yaml:"citation"`

	// url points to supporting material when available
	Url string `json:"url,omitempty" yaml:"url,omitempty"`
}

LexiconReference cites a source supporting a lexicon definition

type LexiconTerm added in v0.0.3

type LexiconTerm struct {
	// id allows this entry to be referenced for anchors and tooling
	Id string `json:"id" yaml:"id"`

	// title is the canonical name of the defined concept
	Title string `json:"title" yaml:"title"`

	// definition explains the meaning of the term
	Definition string `json:"definition" yaml:"definition"`

	// synonyms lists alternative labels that should resolve to this term for linking
	Synonyms []string `json:"synonyms,omitempty" yaml:"synonyms,omitempty"`

	// references cites external authorities supporting the definition
	References []LexiconReference `json:"references,omitempty" yaml:"references,omitempty"`
}

LexiconTerm is a single definition within a lexicon

type Lifecycle added in v0.0.2

type Lifecycle int

Lifecycle represents the lifecycle state of a guideline, control, or assessment requirement

const (
	LifecycleActive Lifecycle = iota
	LifecycleDraft
	LifecycleDeprecated
	LifecycleRetired
)

func (Lifecycle) MarshalJSON added in v0.0.2

func (l Lifecycle) MarshalJSON() ([]byte, error)

MarshalJSON ensures that Lifecycle is serialized as a string in JSON

func (Lifecycle) MarshalYAML added in v0.0.2

func (l Lifecycle) MarshalYAML() (interface{}, error)

MarshalYAML ensures that Lifecycle is serialized as a string in YAML

func (Lifecycle) String added in v0.0.2

func (l Lifecycle) String() string

func (*Lifecycle) UnmarshalJSON added in v0.0.2

func (l *Lifecycle) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that Lifecycle can be deserialized from a JSON string

func (*Lifecycle) UnmarshalText added in v0.7.0

func (l *Lifecycle) UnmarshalText(data []byte) error

UnmarshalText lets yaml.v3-family decoders deserialize Lifecycle from a string

func (*Lifecycle) UnmarshalYAML added in v0.0.2

func (l *Lifecycle) UnmarshalYAML(data []byte) error

UnmarshalYAML ensures that Lifecycle can be deserialized from a YAML string

type Log added in v0.0.3

type Log struct {
	// metadata provides detailed data about this log
	Metadata Metadata `json:"metadata" yaml:"metadata"`

	// target identifies the resource being evaluated
	Target Resource `json:"target" yaml:"target"`
}

Log describes a set of recorded entries from a measurement activity

type Mapping added in v0.0.2

type Mapping struct {
	// id allows this mapping to be referenced by other elements
	Id string `json:"id" yaml:"id"`

	// source identifies the entry being mapped from by its entry-id
	Source string `json:"source" yaml:"source"`

	// targets identifies the entries being mapped to; absent when relationship is no-match
	Targets []MappingTarget `json:"targets,omitempty" yaml:"targets,omitempty"`

	// relationship describes the nature of the mapping between source and all targets
	Relationship RelationshipType `json:"relationship" yaml:"relationship"`

	// remarks is general prose regarding this mapping
	Remarks string `json:"remarks,omitempty" yaml:"remarks,omitempty"`
}

Mapping represents a relationship between a source entry and one or more target entries

type MappingDocument added in v0.0.2

type MappingDocument struct {
	// title describes the purpose of this mapping document at a glance
	Title string `json:"title" yaml:"title"`

	// metadata provides detailed data about this document
	Metadata Metadata `json:"metadata" yaml:"metadata"`

	// source-reference identifies the artifact being mapped from; must match a mapping-reference id
	SourceReference TypedMapping `json:"source-reference" yaml:"source-reference"`

	// target-reference identifies the artifact being mapped to; must match a mapping-reference id
	TargetReference TypedMapping `json:"target-reference" yaml:"target-reference"`

	// mappings is one or more atomic relationships between entries in the referenced artifacts
	Mappings []Mapping `json:"mappings" yaml:"mappings"`

	// remarks is prose regarding this mapping document
	Remarks string `json:"remarks,omitempty" yaml:"remarks,omitempty"`
}

MappingDocument captures the user's intent for how entries in a source artifact relate to entries in a target artifact

type MappingReference

type MappingReference struct {
	// id allows this entry to be referenced by other elements
	Id string `json:"id" yaml:"id"`

	// title describes the purpose of this mapping reference at a glance
	Title string `json:"title" yaml:"title"`

	// version is the version identifier of the artifact being mapped to
	Version string `json:"version" yaml:"version"`

	// description is prose regarding the artifact's purpose or content
	Description string `json:"description,omitempty" yaml:"description,omitempty"`

	// url is the path where the artifact may be retrieved; preferrably responds with Gemara-compatible YAML/JSON
	Url string `json:"url,omitempty" yaml:"url,omitempty"`
}

MappingReference represents a reference to an external document with full metadata.

type MappingTarget added in v0.0.3

type MappingTarget struct {
	// entry-id identifies the specific entry in the target artifact
	EntryId string `json:"entry-id" yaml:"entry-id"`

	// strength is the author's estimate of how completely the source satisfies this target; range 1-10
	Strength int64 `json:"strength,omitempty" yaml:"strength,omitempty"`

	ConfidenceLevel ConfidenceLevel `json:"confidence-level,omitempty" yaml:"confidence-level,omitempty"`

	// applicability constrains the contexts in which this target mapping holds
	Applicability []string `json:"applicability,omitempty" yaml:"applicability,omitempty"`

	// rationale explains why this relationship exists for this target
	Rationale string `json:"rationale,omitempty" yaml:"rationale,omitempty"`

	// remarks is general prose regarding this target mapping
	Remarks string `json:"remarks,omitempty" yaml:"remarks,omitempty"`
}

MappingTarget identifies a target entry with optional per-target metadata

type Metadata

type Metadata struct {
	// id allows this entry to be referenced by other elements
	Id string `json:"id" yaml:"id"`

	// type identifies the kind of Gemara artifact for unambiguous parsing
	Type ArtifactType `json:"type" yaml:"type"`

	// gemara-version declares which version of the Gemara specification this artifact conforms to
	GemaraVersion string `json:"gemara-version" yaml:"gemara-version"`

	// version is the version identifier of this artifact
	Version string `json:"version,omitempty" yaml:"version,omitempty"`

	// date is the publication or effective date of this artifact
	Date Datetime `json:"date,omitempty" yaml:"date,omitempty"`

	// description provides a high-level summary of the artifact's purpose and scope
	Description string `json:"description" yaml:"description"`

	// author is the person or group primarily responsible for this artifact
	Author Actor `json:"author" yaml:"author"`

	// mapping-references is a list of external documents referenced within this artifact
	MappingReferences []MappingReference `json:"mapping-references,omitempty" yaml:"mapping-references,omitempty"`

	// applicability-groups is a list of groups used to classify within this artifact to specify scope
	ApplicabilityGroups []Group `json:"applicability-groups,omitempty" yaml:"applicability-groups,omitempty"`

	// draft indicates whether this artifact is a pre-release version; open to modification
	Draft bool `json:"draft,omitempty" yaml:"draft,omitempty"`

	// lexicon is a URI pointing to a controlled vocabulary or glossary relevant to this artifact
	Lexicon *ArtifactMapping `json:"lexicon,omitempty" yaml:"lexicon,omitempty"`
}

Metadata represents common metadata fields shared across all layers

type MethodType

type MethodType int

MethodType enumerates the category of evaluation or enforcement method.

const (
	InvalidMethodType MethodType = iota
	MethodBehavioral
	MethodIntent
	MethodRemediation
	MethodGate
)

func (MethodType) MarshalJSON added in v0.0.2

func (m MethodType) MarshalJSON() ([]byte, error)

MarshalJSON ensures that MethodType is serialized as a string in JSON

func (MethodType) MarshalYAML added in v0.0.2

func (m MethodType) MarshalYAML() (interface{}, error)

MarshalYAML ensures that MethodType is serialized as a string in YAML

func (MethodType) String added in v0.0.2

func (m MethodType) String() string

func (*MethodType) UnmarshalJSON added in v0.0.2

func (m *MethodType) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that MethodType can be deserialized from a JSON string

func (*MethodType) UnmarshalText added in v0.7.0

func (m *MethodType) UnmarshalText(data []byte) error

UnmarshalText lets yaml.v3-family decoders deserialize MethodType from a string

func (*MethodType) UnmarshalYAML added in v0.0.2

func (m *MethodType) UnmarshalYAML(data []byte) error

UnmarshalYAML ensures that MethodType can be deserialized from a YAML string

type MitigatedRisk added in v0.0.2

type MitigatedRisk struct {
	// id allows this mitigated risk entry to be referenced by accepted risks
	Id string `json:"id" yaml:"id"`

	// risk references the risk being mitigated
	Risk EntryMapping `json:"risk" yaml:"risk"`
}

MitigatedRisk represents a risk addressed by the policy

type ModType

type ModType int

ModType defines the type of modification to the assessment requirement.

const (
	InvalidModType ModType = iota
	ModAdd
	ModModify
	ModRemove
	ModReplace
	ModOverride
)

func (ModType) MarshalJSON added in v0.0.2

func (m ModType) MarshalJSON() ([]byte, error)

MarshalJSON ensures that ModType is serialized as a string in JSON

func (ModType) MarshalYAML added in v0.0.2

func (m ModType) MarshalYAML() (interface{}, error)

MarshalYAML ensures that ModType is serialized as a string in YAML

func (ModType) String added in v0.0.2

func (m ModType) String() string

func (*ModType) UnmarshalJSON added in v0.0.2

func (m *ModType) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that ModType can be deserialized from a JSON string

func (*ModType) UnmarshalText added in v0.7.0

func (m *ModType) UnmarshalText(data []byte) error

UnmarshalText lets yaml.v3-family decoders deserialize ModType from a string

func (*ModType) UnmarshalYAML added in v0.0.2

func (m *ModType) UnmarshalYAML(data []byte) error

UnmarshalYAML ensures that ModType can be deserialized from a YAML string

type ModeType added in v0.0.3

type ModeType int

ModeType enumerates whether enforcement/evaluation is manual or automated.

const (
	InvalidModeType ModeType = iota
	ModeManual
	ModeAutomated
)

func (ModeType) MarshalJSON added in v0.0.3

func (m ModeType) MarshalJSON() ([]byte, error)

MarshalJSON ensures that ModeType is serialized as a string in JSON

func (ModeType) MarshalYAML added in v0.0.3

func (m ModeType) MarshalYAML() (interface{}, error)

MarshalYAML ensures that ModeType is serialized as a string in YAML

func (ModeType) String added in v0.0.3

func (m ModeType) String() string

func (*ModeType) UnmarshalJSON added in v0.0.3

func (m *ModeType) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that ModeType can be deserialized from a JSON string

func (*ModeType) UnmarshalText added in v0.7.0

func (m *ModeType) UnmarshalText(data []byte) error

UnmarshalText lets yaml.v3-family decoders deserialize ModeType from a string

func (*ModeType) UnmarshalYAML added in v0.0.3

func (m *ModeType) UnmarshalYAML(data []byte) error

UnmarshalYAML ensures that ModeType can be deserialized from a YAML string

type MultiEntryMapping added in v0.0.1

type MultiEntryMapping struct {
	// entries is a list of mapping entries
	Entries []ArtifactMapping `json:"entries" yaml:"entries"`

	// reference-id identifies an element from a MappingReference in the artifact's metadata
	ReferenceId string `json:"reference-id" yaml:"reference-id"`

	// remarks is prose regarding the mapped artifact or the mapping relationship
	Remarks string `json:"remarks,omitempty" yaml:"remarks,omitempty"`
}

MultiEntryMapping represents a mapping to an external reference with one or more entries.

type Parameter

type Parameter struct {
	Id string `json:"id" yaml:"id"`

	Label string `json:"label" yaml:"label"`

	Description string `json:"description" yaml:"description"`

	AcceptedValues []string `json:"accepted-values,omitempty" yaml:"accepted-values,omitempty"`
}

Parameter defines a configurable parameter for assessment or enforcement activities.

type Policy

type Policy struct {
	Title string `json:"title" yaml:"title"`

	Metadata Metadata `json:"metadata" yaml:"metadata"`

	Contacts RACI `json:"contacts" yaml:"contacts"`

	Scope Scope `json:"scope" yaml:"scope"`

	Imports Imports `json:"imports" yaml:"imports"`

	ImplementationPlan ImplementationPlan `json:"implementation-plan,omitempty" yaml:"implementation-plan,omitempty"`

	Risks Risks `json:"risks,omitempty" yaml:"risks,omitempty"`

	Adherence Adherence `json:"adherence" yaml:"adherence"`
}

Policy represents a policy document with metadata, contacts, scope, imports, implementation plan, risks, and adherence requirements.

func (*Policy) ToMarkdownChecklist

func (p *Policy) ToMarkdownChecklist() (string, error)

ToMarkdownChecklist converts a policy into a markdown checklist.

Example
policy := &Policy{
	Metadata: Metadata{
		Id:      "security-policy-v2.1",
		Version: "2.1.0",
		Author: Actor{
			Name:    "Security Team",
			Version: "1.0.0",
		},
	},
	Title: "Information Security Policy",
	Adherence: Adherence{
		AssessmentPlans: []AssessmentPlan{
			{
				Id:            "plan-access-control-monthly",
				RequirementId: "AC-01.01",
				Frequency:     "monthly",
				EvaluationMethods: []AcceptedMethod{
					{
						Type:        MethodIntent,
						Description: "Run automated access control audit script",
					},
					{
						Type:        MethodBehavioral,
						Description: "Review access control logs for anomalies",
					},
				},
				EvidenceRequirements: "Access logs, audit report, and review notes",
			},
			{
				Id:            "plan-encryption-quarterly",
				RequirementId: "SC-02.01",
				Frequency:     "quarterly",
				EvaluationMethods: []AcceptedMethod{
					{
						Type:        MethodIntent,
						Description: "Verify encryption is enabled on all data stores",
					},
				},
				EvidenceRequirements: "Configuration scan results and compliance report",
			},
			{
				Id:            "plan-backup-automated",
				RequirementId: "CP-01.01",
				Frequency:     "weekly",
				EvaluationMethods: []AcceptedMethod{
					{
						Type:        MethodIntent,
						Description: "Verify backup jobs completed successfully",
					},
				},
				EvidenceRequirements: "Backup job logs and success reports",
			},
			{
				Id:            "plan-backup-manual",
				RequirementId: "CP-01.01",
				Frequency:     "monthly",
				EvaluationMethods: []AcceptedMethod{
					{
						Type:        MethodBehavioral,
						Description: "Test restore procedure from backup",
					},
				},
				EvidenceRequirements: "Restore test results and documentation",
			},
		},
	},
}

checklist, err := policy.ToMarkdownChecklist()
if err != nil {
	fmt.Printf("Error generating checklist: %v\n", err)
	return
}

// Print the generated checklist
fmt.Println(checklist)
Output:
# Policy Checklist: Information Security Policy (security-policy-v2.1)

**Author:** Security Team (v1.0.0)

## Assessment Requirement: AC-01.01

- [ ] Run automated access control audit script (monthly) [Plan: plan-access-control-monthly]
    > **Evidence Required:** Access logs, audit report, and review notes
- [ ] Review access control logs for anomalies (monthly) [Plan: plan-access-control-monthly]
    > **Evidence Required:** Access logs, audit report, and review notes

---

## Assessment Requirement: SC-02.01

- [ ] Verify encryption is enabled on all data stores (quarterly) [Plan: plan-encryption-quarterly]
    > **Evidence Required:** Configuration scan results and compliance report

---

## Assessment Requirement: CP-01.01

- [ ] Verify backup jobs completed successfully (weekly) [Plan: plan-backup-automated]
    > **Evidence Required:** Backup job logs and success reports
- [ ] Test restore procedure from backup (monthly) [Plan: plan-backup-manual]
    > **Evidence Required:** Restore test results and documentation

type Principle added in v0.0.3

type Principle struct {
	// id allows this entry to be referenced by other elements
	Id string `json:"id" yaml:"id"`

	// title describes the principle at a glance
	Title string `json:"title" yaml:"title"`

	// description explains the principle and its expected outcomes
	Description string `json:"description" yaml:"description"`

	// group references by id a catalog group that this principle belongs to
	Group string `json:"group" yaml:"group"`

	// rationale provides the context for this principle
	Rationale string `json:"rationale,omitempty" yaml:"rationale,omitempty"`
}

Principle represents a foundational value or tenet that guides governance, design, and operational decisions

type PrincipleCatalog added in v0.0.3

type PrincipleCatalog struct {
	// title describes the purpose of this catalog at a glance
	Title string `json:"title" yaml:"title"`

	// metadata provides detailed data about this catalog
	Metadata Metadata `json:"metadata" yaml:"metadata"`

	// groups contains a list of groups that can be referenced by entries in this catalog
	Groups []Group `json:"groups,omitempty" yaml:"groups,omitempty"`

	// extends references catalogs that this catalog builds upon
	Extends []ArtifactMapping `json:"extends,omitempty" yaml:"extends,omitempty"`

	Imports []MultiEntryMapping `json:"imports,omitempty" yaml:"imports,omitempty"`

	// principles is a list of unique principles defined by this catalog
	Principles []Principle `json:"principles,omitempty" yaml:"principles,omitempty"`
}

PrincipleCatalog describes a set of related principles and relevant metadata

type RACI added in v0.0.2

type RACI struct {
	// responsible identifies the entities responsible for executing work to manage or mitigate the artifact
	Responsible []Contact `json:"responsible" yaml:"responsible"`

	// accountable identifies the entity ultimately accountable for the outcome
	Accountable []Contact `json:"accountable" yaml:"accountable"`

	// consulted identifies entities whose input is required when assessing or responding to the artifact
	Consulted []Contact `json:"consulted,omitempty" yaml:"consulted,omitempty"`

	// informed identifies entities that should be notified about changes to the artifact status
	Informed []Contact `json:"informed,omitempty" yaml:"informed,omitempty"`
}

RACI defines the roles responsible for managing an artifact

type Rationale

type Rationale struct {
	// importance is an explanation of why this guideline matters
	Importance string `json:"importance" yaml:"importance"`

	// goals is a list of outcomes this guideline seeks to achieve
	Goals []string `json:"goals" yaml:"goals"`
}

Rationale provides a structured way to communicate a guideline author's intent

type Recommendation added in v0.0.3

type Recommendation struct {
	// id uniquely identifies this recommendation
	Id string `json:"id,omitempty" yaml:"id,omitempty"`

	// text describes the recommended corrective action
	Text string `json:"text" yaml:"text"`

	// required indicates whether this recommendation is a mandatory corrective action
	Required bool `json:"required" yaml:"required"`
}

Recommendation provides a corrective action for an audit result

type RelationshipType added in v0.0.2

type RelationshipType int

RelationshipType enumerates the nature of the mapping between entries.

const (
	InvalidRelationshipType RelationshipType = iota
	RelImplements
	RelImplementedBy
	RelSupports
	RelSupportedBy
	RelEquivalent
	RelSubsumes
	RelNoMatch
	RelRelatesTo
)

func (RelationshipType) MarshalJSON added in v0.0.2

func (r RelationshipType) MarshalJSON() ([]byte, error)

MarshalJSON ensures that RelationshipType is serialized as a string in JSON

func (RelationshipType) MarshalYAML added in v0.0.2

func (r RelationshipType) MarshalYAML() (interface{}, error)

MarshalYAML ensures that RelationshipType is serialized as a string in YAML

func (RelationshipType) String added in v0.0.2

func (r RelationshipType) String() string

func (*RelationshipType) UnmarshalJSON added in v0.0.2

func (r *RelationshipType) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that RelationshipType can be deserialized from a JSON string

func (*RelationshipType) UnmarshalText added in v0.7.0

func (r *RelationshipType) UnmarshalText(data []byte) error

UnmarshalText lets yaml.v3-family decoders deserialize RelationshipType from a string

func (*RelationshipType) UnmarshalYAML added in v0.0.2

func (r *RelationshipType) UnmarshalYAML(data []byte) error

UnmarshalYAML ensures that RelationshipType can be deserialized from a YAML string

type RequirementSection

type RequirementSection struct {
	// RequirementId is the assessment requirement identifier (e.g., "OSPS-AC-01.01")
	RequirementId string
	// Items are the checklist items for this requirement
	Items []ChecklistItem
}

RequirementSection organizes checklist items by assessment requirement.

type Resource added in v0.0.2

type Resource struct {
	// environment describes where the resource exists (e.g., production, staging, development, specific region)
	Environment string `json:"environment,omitempty" yaml:"environment,omitempty"`

	// id uniquely identifies the entity and allows this entry to be referenced by other elements
	Id string `json:"id" yaml:"id"`

	// name is the name of the entity
	Name string `json:"name" yaml:"name"`

	// owner is the contact information for the person or group responsible for managing or owning this resource
	Owner Contact `json:"owner,omitempty" yaml:"owner,omitempty"`

	// type specifies the type of entity interacting in the workflow
	Type EntityType `json:"type" yaml:"type"`

	// version is the version of the entity (for tools; if applicable)
	Version string `json:"version,omitempty" yaml:"version,omitempty"`

	// description provides additional context about the entity
	Description string `json:"description,omitempty" yaml:"description,omitempty"`

	// uri is a general URI for the entity information
	Uri string `json:"uri,omitempty" yaml:"uri,omitempty"`
}

Resource represents an entity that exists in the system and can be evaluated

type Result

type Result int

Result represents the result of a control evaluation

const (
	NotRun Result = iota
	Passed
	Failed
	NeedsReview
	NotApplicable
	Unknown
)

func UpdateAggregateResult

func UpdateAggregateResult(previous Result, new Result) Result

UpdateAggregateResult compares the current result with the new result and returns the most severe of the two.

func (Result) MarshalJSON

func (r Result) MarshalJSON() ([]byte, error)

MarshalJSON ensures that Result is serialized as a string in JSON

func (Result) MarshalYAML

func (r Result) MarshalYAML() (interface{}, error)

MarshalYAML ensures that Result is serialized as a string in YAML

func (Result) String

func (r Result) String() string

func (*Result) UnmarshalJSON added in v0.0.2

func (r *Result) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that Result can be deserialized from a JSON string

func (*Result) UnmarshalText added in v0.7.0

func (r *Result) UnmarshalText(data []byte) error

UnmarshalText lets yaml.v3-family decoders deserialize Result from a string

func (*Result) UnmarshalYAML added in v0.0.2

func (r *Result) UnmarshalYAML(data []byte) error

UnmarshalYAML ensures that Result can be deserialized from a YAML string

type ResultType added in v0.0.3

type ResultType int

ResultType defines the nature of an audit result

const (
	InvalidResultType ResultType = iota
	ResultObservation
	ResultStrength
	ResultFinding
	ResultGap
)

func (ResultType) MarshalJSON added in v0.0.3

func (r ResultType) MarshalJSON() ([]byte, error)

func (ResultType) MarshalYAML added in v0.0.3

func (r ResultType) MarshalYAML() (interface{}, error)

func (ResultType) String added in v0.0.3

func (r ResultType) String() string

func (*ResultType) UnmarshalJSON added in v0.0.3

func (r *ResultType) UnmarshalJSON(data []byte) error

func (*ResultType) UnmarshalText added in v0.7.0

func (r *ResultType) UnmarshalText(data []byte) error

UnmarshalText lets yaml.v3-family decoders deserialize ResultType from a string

func (*ResultType) UnmarshalYAML added in v0.0.3

func (r *ResultType) UnmarshalYAML(data []byte) error

type Risk added in v0.0.2

type Risk struct {
	// id allows this risk to be referenced by other elements
	Id string `json:"id" yaml:"id"`

	// title describes the risk
	Title string `json:"title" yaml:"title"`

	// description explains the risk scenario
	Description string `json:"description" yaml:"description"`

	// group references by id a catalog group that this risk belongs to
	Group string `json:"group" yaml:"group"`

	// severity describes the assessed level of this risk
	Severity Severity `json:"severity" yaml:"severity"`

	// rank optionally orders risks for the same catalog (e.g. when several share the same severity).
	// Lower values mean higher relative importance. Omitted when the four severity levels are enough.
	// When set, each value must be unique among all risks in the catalog that specify rank.
	Rank int64 `json:"rank,omitempty" yaml:"rank,omitempty"`

	// owner defines the RACI roles responsible for managing this risk
	Owner RACI `json:"owner,omitempty" yaml:"owner,omitempty"`

	// impact describes the business or operational impact
	Impact string `json:"impact,omitempty" yaml:"impact,omitempty"`

	// threats link this risk to Layer 2 threats
	Threats []MultiEntryMapping `json:"threats,omitempty" yaml:"threats,omitempty"`
}

A Risk represents the potential for negative impact resulting from one or more threats.

type RiskAppetite added in v0.0.2

type RiskAppetite int

RiskAppetite defines the acceptable level of exposure for a risk category.

const (
	RiskAppetiteMinimal RiskAppetite = iota
	RiskAppetiteLow
	RiskAppetiteModerate
	RiskAppetiteHigh
)

func (RiskAppetite) MarshalJSON added in v0.0.2

func (r RiskAppetite) MarshalJSON() ([]byte, error)

MarshalJSON ensures that RiskAppetite is serialized as a string in JSON

func (RiskAppetite) MarshalYAML added in v0.0.2

func (r RiskAppetite) MarshalYAML() (interface{}, error)

MarshalYAML ensures that RiskAppetite is serialized as a string in YAML

func (RiskAppetite) String added in v0.0.2

func (r RiskAppetite) String() string

func (*RiskAppetite) UnmarshalJSON added in v0.0.2

func (r *RiskAppetite) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that RiskAppetite can be deserialized from a JSON string

func (*RiskAppetite) UnmarshalText added in v0.7.0

func (r *RiskAppetite) UnmarshalText(data []byte) error

UnmarshalText lets yaml.v3-family decoders deserialize RiskAppetite from a string

func (*RiskAppetite) UnmarshalYAML added in v0.0.2

func (r *RiskAppetite) UnmarshalYAML(data []byte) error

UnmarshalYAML ensures that RiskAppetite can be deserialized from a YAML string

type RiskCatalog added in v0.0.2

type RiskCatalog struct {
	// title describes the purpose of this catalog at a glance
	Title string `json:"title" yaml:"title"`

	// metadata provides detailed data about this catalog
	Metadata Metadata `json:"metadata" yaml:"metadata"`

	// groups narrows the base groups to risk categories with appetite and severity boundaries
	//
	// groups contains a list of groups that can be referenced by entries in this catalog
	Groups []RiskCategory `json:"groups,omitempty" yaml:"groups,omitempty"`

	// extends references catalogs that this catalog builds upon
	Extends []ArtifactMapping `json:"extends,omitempty" yaml:"extends,omitempty"`

	Imports []MultiEntryMapping `json:"imports,omitempty" yaml:"imports,omitempty"`

	// risks is a list of risks defined by this catalog
	Risks []Risk `json:"risks,omitempty" yaml:"risks,omitempty"`
}

A RiskCatalog is a structured collection of documented risks that may affect an organization, system, or service. It provides a centralized reference for risks that can be mapped to threats and referenced by policies when documenting how those risks are mitigated or accepted.

type RiskCategory added in v0.0.2

type RiskCategory struct {
	// appetite defines the acceptable level of risk for this category
	Appetite RiskAppetite `json:"appetite" yaml:"appetite"`

	// id allows this entry to be referenced by other elements
	Id string `json:"id" yaml:"id"`

	// max-severity defines the risk tolerance boundary: the highest severity
	// the organization will accept within this category
	MaxSeverity Severity `json:"max-severity,omitempty" yaml:"max-severity,omitempty"`

	// title describes the purpose of this group at a glance
	Title string `json:"title" yaml:"title"`

	// description explains the significance and traits of entries to this group
	Description string `json:"description" yaml:"description"`
}

RiskCategory describes a grouping of risks and defines appetite boundaries

type Risks

type Risks struct {
	// Mitigated risks only need reference-id and risk-id (no justification required)
	Mitigated []MitigatedRisk `json:"mitigated,omitempty" yaml:"mitigated,omitempty"`

	// Accepted risks require rationale (justification) and may include scope. Controls addressing these risks are implicitly identified through threat mappings.
	Accepted []AcceptedRisk `json:"accepted,omitempty" yaml:"accepted,omitempty"`
}

Risks defines mitigated and accepted risks addressed by this policy.

type SControl added in v0.0.3

type SControl struct {
	Control
	// contains filtered or unexported fields
}

SControl wraps a Control with cached cross-reference lookups.

func (*SControl) FromBase added in v0.2.0

func (c *SControl) FromBase(s *Control)

func (*SControl) GetMappingReferences added in v0.0.3

func (c *SControl) GetMappingReferences() []string

func (*SControl) MarshalYAML added in v0.2.0

func (c *SControl) MarshalYAML() ([]byte, error)

func (*SControl) ToBase added in v0.2.0

func (c *SControl) ToBase() Control

func (*SControl) UnmarshalYAML added in v0.2.0

func (c *SControl) UnmarshalYAML(data []byte) error

type SControlCatalog added in v0.0.3

type SControlCatalog struct {
	ControlCatalog
	// contains filtered or unexported fields
}

SControlCatalog wraps a ControlCatalog with pre-built indexes for efficient group, control, and requirement lookups.

func (*SControlCatalog) FromBase added in v0.2.0

func (c *SControlCatalog) FromBase(s *ControlCatalog)

func (*SControlCatalog) GetControlsForGroup added in v0.0.3

func (c *SControlCatalog) GetControlsForGroup(group string) []*SControl

func (*SControlCatalog) GetGroupNames added in v0.0.3

func (c *SControlCatalog) GetGroupNames() []string

func (*SControlCatalog) GetRequirementForApplicability added in v0.0.3

func (c *SControlCatalog) GetRequirementForApplicability(applicability string) []AssessmentRequirement

func (*SControlCatalog) MarshalYAML added in v0.2.0

func (c *SControlCatalog) MarshalYAML() ([]byte, error)

func (*SControlCatalog) SControls added in v0.0.3

func (c *SControlCatalog) SControls() []*SControl

SControls returns all controls as cached SControl instances.

func (*SControlCatalog) ToBase added in v0.2.0

func (c *SControlCatalog) ToBase() ControlCatalog

func (*SControlCatalog) UnmarshalYAML added in v0.2.0

func (c *SControlCatalog) UnmarshalYAML(data []byte) error

type Scope

type Scope struct {
	In Dimensions `json:"in" yaml:"in"`

	Out Dimensions `json:"out,omitempty" yaml:"out,omitempty"`
}

Scope defines what is included and excluded from policy applicability.

type Severity added in v0.0.2

type Severity int

Severity defines the allowed impact levels for a risk.

const (
	InvalidSeverity Severity = iota
	SeverityLow
	SeverityMedium
	SeverityHigh
	SeverityCritical
)

func (Severity) MarshalJSON added in v0.0.2

func (s Severity) MarshalJSON() ([]byte, error)

MarshalJSON ensures that Severity is serialized as a string in JSON

func (Severity) MarshalYAML added in v0.0.2

func (s Severity) MarshalYAML() (interface{}, error)

MarshalYAML ensures that Severity is serialized as a string in YAML

func (Severity) String added in v0.0.2

func (s Severity) String() string

func (*Severity) UnmarshalJSON added in v0.0.2

func (s *Severity) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that Severity can be deserialized from a JSON string

func (*Severity) UnmarshalText added in v0.7.0

func (s *Severity) UnmarshalText(data []byte) error

UnmarshalText lets yaml.v3-family decoders deserialize Severity from a string

func (*Severity) UnmarshalYAML added in v0.0.2

func (s *Severity) UnmarshalYAML(data []byte) error

UnmarshalYAML ensures that Severity can be deserialized from a YAML string

type Statement

type Statement struct {
	// id allows this entry to be referenced by other elements
	Id string `json:"id" yaml:"id"`

	// title describes the contents of this statement
	Title string `json:"title,omitempty" yaml:"title,omitempty"`

	// text is the body of this statement
	Text string `json:"text" yaml:"text"`

	// recommendations is a list of non-binding suggestions to aid in evaluation or enforcement of the statement
	Recommendations []string `json:"recommendations,omitempty" yaml:"recommendations,omitempty"`
}

Statement represents a structural sub-requirement within a guideline; They do not increase strictness and all statements within a guideline apply together

type Threat

type Threat struct {
	// id allows this entry to be referenced by other elements
	Id string `json:"id" yaml:"id"`

	// title describes this threat at a glance
	Title string `json:"title" yaml:"title"`

	// description provides a detailed explanation of an opportunity for negative impact
	Description string `json:"description" yaml:"description"`

	// group references by id a catalog group that this threat belongs to
	Group string `json:"group" yaml:"group"`

	// capabilities documents the relationship between this threat and a system capability
	Capabilities []MultiEntryMapping `json:"capabilities" yaml:"capabilities"`

	// vectors documents the relationship between this threat and one or more vectors
	Vectors []MultiEntryMapping `json:"vectors,omitempty" yaml:"vectors,omitempty"`

	// actors describes the relevant internal or external threat actors
	Actors []Actor `json:"actors,omitempty" yaml:"actors,omitempty"`
}

Threat describes a specifically-scoped opportunity for a negative impact to the organization

type ThreatCatalog added in v0.0.1

type ThreatCatalog struct {
	// title describes the purpose of this catalog at a glance
	Title string `json:"title" yaml:"title"`

	// metadata provides detailed data about this catalog
	Metadata Metadata `json:"metadata" yaml:"metadata"`

	// groups contains a list of groups that can be referenced by entries in this catalog
	Groups []Group `json:"groups,omitempty" yaml:"groups,omitempty"`

	// extends references catalogs that this catalog builds upon
	Extends []ArtifactMapping `json:"extends,omitempty" yaml:"extends,omitempty"`

	Imports []MultiEntryMapping `json:"imports,omitempty" yaml:"imports,omitempty"`

	// threats is a list of threats defined by this catalog
	Threats []Threat `json:"threats,omitempty" yaml:"threats,omitempty"`
}

ThreatCatalog describes a set of topically-associated threats

type TypeMeta added in v0.4.0

type TypeMeta struct {
	Metadata struct {
		Type ArtifactType `json:"type" yaml:"type"`
	} `json:"metadata" yaml:"metadata"`
}

TypeMeta is the minimal discriminator parsed from raw YAML/JSON to determine which concrete Gemara type to unmarshal into

type TypedMapping added in v0.0.3

type TypedMapping struct {
	// entry-type identifies the type of atomic unit entries in this direction
	EntryType EntryType `json:"entry-type" yaml:"entry-type"`

	// reference-id identifies an element from a MappingReference in the artifact's metadata
	ReferenceId string `json:"reference-id" yaml:"reference-id"`

	// remarks is prose regarding the mapped artifact or the mapping relationship
	Remarks string `json:"remarks,omitempty" yaml:"remarks,omitempty"`
}

TypedMapping extends ArtifactMapping with a required entry-type for all entries in this direction

type Vector added in v0.0.2

type Vector struct {
	// id allows this vector to be referenced by other elements
	Id string `json:"id" yaml:"id"`

	// title describes the vector
	Title string `json:"title" yaml:"title"`

	// description explains how the attack vector works
	Description string `json:"description" yaml:"description"`

	// group references by id a catalog group that this vector belongs to
	Group string `json:"group" yaml:"group"`

	// applicability specifies the contexts in which this vector can manifest
	Applicability []string `json:"applicability,omitempty" yaml:"applicability,omitempty"`
}

A Vector represents a method, pathway, or technique through which a threat may be realized or an attack may be carried out.

type VectorCatalog added in v0.0.2

type VectorCatalog struct {
	// title describes the purpose of this catalog at a glance
	Title string `json:"title" yaml:"title"`

	// metadata provides detailed data about this catalog
	Metadata Metadata `json:"metadata" yaml:"metadata"`

	// groups contains a list of groups that can be referenced by entries in this catalog
	Groups []Group `json:"groups,omitempty" yaml:"groups,omitempty"`

	// extends references catalogs that this catalog builds upon
	Extends []ArtifactMapping `json:"extends,omitempty" yaml:"extends,omitempty"`

	Imports []MultiEntryMapping `json:"imports,omitempty" yaml:"imports,omitempty"`

	// vectors is a list of attack vectors documented in this catalog
	Vectors []Vector `json:"vectors,omitempty" yaml:"vectors,omitempty"`
}

Directories

Path Synopsis
Package bundle defines the Gemara OCI artifact format and provides Assemble, Pack, and Unpack operations for building, storing, and retrieving Gemara artifacts in OCI-compliant registries.
Package bundle defines the Gemara OCI artifact format and provides Assemble, Pack, and Unpack operations for building, storing, and retrieving Gemara artifacts in OCI-compliant registries.
cmd
oscalexport command
typestagger command
Package gemaraconv provides conversion functions to transform Gemara documents into various standard formats.
Package gemaraconv provides conversion functions to transform Gemara documents into various standard formats.
internal

Jump to

Keyboard shortcuts

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