profileparser

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPrefixedName

func GetPrefixedName(pbName, objName string) string

func LogAndReturnError

func LogAndReturnError(errormsg string) error

func ParseBundle

func ParseBundle(contentDom *xmlquery.Node, pb *cmpv1alpha1.ProfileBundle, pcfg *ParserConfig) error

func ParseCELBundle added in v1.9.0

func ParseCELBundle(celPath string, pb *cmpv1alpha1.ProfileBundle, pcfg *ParserConfig) error

ParseCELBundle reads a CEL content YAML file and creates Rule and Profile CRs. CEL rules are validated at parse time using celvalidation.ValidateCELRule.

func ParseProfilesAndDo

func ParseProfilesAndDo(contentDom *xmlquery.Node, pb *cmpv1alpha1.ProfileBundle, nonce string, action func(p *cmpv1alpha1.Profile) error) error

func ParseRulesAndDo

func ParseRulesAndDo(contentDom *xmlquery.Node, stdParser *referenceParser, pb *cmpv1alpha1.ProfileBundle, nonce string, action func(p *cmpv1alpha1.Rule) error) error

func ParseVariablesAndDo

func ParseVariablesAndDo(contentDom *xmlquery.Node, pb *cmpv1alpha1.ProfileBundle, nonce string, action func(v *cmpv1alpha1.Variable) error) error

Types

type CELBundleContent added in v1.9.0

type CELBundleContent struct {
	Rules    []CELRuleContent    `json:"rules"`
	Profiles []CELProfileContent `json:"profiles"`
}

CELBundleContent represents the top-level structure of a CEL content YAML file. It contains CEL-based rules and profiles that are shipped alongside XCCDF content. Variables are not defined here; CEL rules reuse Variable CRs created from the XCCDF DataStream in the same ProfileBundle. A future iteration may add a variables section for bundles that ship CEL-only content without XCCDF.

type CELProfileContent added in v1.9.0

type CELProfileContent struct {
	Name        string   `json:"name"`
	ID          string   `json:"id"`
	Title       string   `json:"title"`
	Description string   `json:"description,omitempty"`
	ProductType string   `json:"productType,omitempty"`
	ProductName string   `json:"productName,omitempty"`
	Rules       []string `json:"rules"`
	// Values lists the Variable CR names this profile references.
	// Stored in Profile.Values so the CEL scanner can load them.
	// +optional
	Values []string `json:"values,omitempty"`
	// +optional
	Version string `json:"version,omitempty"`
}

CELProfileContent represents a single CEL profile definition in the content file.

type CELRuleContent added in v1.9.0

type CELRuleContent struct {
	Name          string                     `json:"name"`
	ID            string                     `json:"id"`
	Title         string                     `json:"title"`
	Description   string                     `json:"description,omitempty"`
	Rationale     string                     `json:"rationale,omitempty"`
	Severity      string                     `json:"severity"`
	CheckType     string                     `json:"checkType"`
	Expression    string                     `json:"expression"`
	Inputs        []cmpv1alpha1.InputPayload `json:"inputs"`
	FailureReason string                     `json:"failureReason,omitempty"`
	Instructions  string                     `json:"instructions,omitempty"`
	// Variables lists the Variable CR names that this rule depends on.
	// Sets the compliance.openshift.io/rule-variable annotation.
	// +optional
	Variables []string `json:"variables,omitempty"`
	// Controls maps compliance standard names to their control IDs.
	// Sets control.compliance.openshift.io/<standard> and RHACM annotations.
	// Example: {"NIST-800-53": ["IA-5(f)", "CM-6(a)"], "CIS-OCP": ["1.2.3"]}
	// +optional
	Controls map[string][]string `json:"controls,omitempty"`
}

CELRuleContent represents a single CEL rule definition in the content file.

type ParserConfig

type ParserConfig struct {
	DataStreamPath   string
	CELContentPath   string
	ProfileBundleKey types.NamespacedName
	Client           runtimeclient.Client
	Scheme           *k8sruntime.Scheme
}

Jump to

Keyboard shortcuts

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