controls

package
v1.13.4 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package controls provides functions for working with controls and subcontrols, including cloning and updating controls based on a standard set of controls.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrStandardNotFound is the error message returned when a standard cannot be found based on the provided filter options during control cloning
	ErrStandardNotFound = errors.New("standard not found, unable to clone controls")
)

Functions

func CleanImplementationGuidance

func CleanImplementationGuidance(input *string) *models.ImplementationGuidance

CleanImplementationGuidance cleans and formats the implementation guidance input by splitting on new lines and trimming spaces

func CloneTrustCenterControls

func CloneTrustCenterControls(ctx context.Context) error

CloneTrustCenterControl clones the trust center controls and assumes the the user has the trust center module already this is intended to be called from an internal-hook when a trust center is created

func ControlFilterByStandard

func ControlFilterByStandard(ctx context.Context, opts CloneFilterOptions, std *generated.Standard) ([]predicate.Control, error)

ControlFilterByStandard returns the predicate to filter controls by standard and other filter options to return the correct controls to clone

func ConvertToCloneControlInput

func ConvertToCloneControlInput(input []*model.CloneControlUploadInput) ([]*model.CloneControlInput, error)

ConvertToCloneControlInput converts a slice of CloneControlUploadInput to a slice of CloneControlInput this is used to process a bulk CSV upload of controls to be cloned and group them by standard

func CreateCloneControlInput

func CreateCloneControlInput(c *generated.Control, programID *string, orgID string) (generated.CreateControlInput, bool)

CreateCloneControlInput creates a CreateControlInput from the given control that is being cloned and returns the input, the standard ID that was set, and whether the control is a trust center control

func CreateCloneSubcontrolInput

func CreateCloneSubcontrolInput(subcontrol *generated.Subcontrol, orgID string) *generated.CreateSubcontrolInput

CreateCloneSubcontrolInput creates a CreateSubcontrolInput from the given subcontrol that is being cloned

func CreateRevisionUpdateInput

func CreateRevisionUpdateInput(c *generated.Control) generated.UpdateControlInput

CreateRevisionUpdateInput creates an UpdateControlInput from the given control that is being updated for a revision change

func CreateSubcontrolRevisionUpdateInput

func CreateSubcontrolRevisionUpdateInput(sc *generated.Subcontrol, standardRevision *string) generated.UpdateSubcontrolInput

CreateSubcontrolRevisionUpdateInput creates an UpdateSubcontrolInput from the given subcontrol that is being updated for a revision change

func FilterByStandard

func FilterByStandard(opts CloneFilterOptions) bool

FilterByStandard returns true if the filter options contain a standardID or standardShortName

func GetControlIDFromRefCode

func GetControlIDFromRefCode(refCode string, controls []*generated.Control) (*string, bool)

GetControlIDFromRefCode searches for a control ID by ref code or alias in the provided controls returns the control ID and a boolean indicating if it is a subcontrol or not

func GetFieldsToUpdate

GetFieldsToUpdate returns the fields to update for the given control or subcontrol input by converting the input to a map and checking for non-empty values and then converting back to the appropriate type it will return a boolean indicating if there are any fields to update

func HasRevisionChanged

func HasRevisionChanged(existingRevision *string, standardRevision string) bool

HasRevisionChanged checks if the revision of the control has changed compared to the standard revision

func StandardFilter

func StandardFilter(opts CloneFilterOptions) []predicate.Standard

StandardFilter returns the predicate to filter by standard based on the filter options

Types

type CloneFilterOptions

type CloneFilterOptions struct {
	// StandardID of the standard to filter the controls by
	StandardID *string
	// StandardShortName is the short name of the standard to filter the controls by
	StandardShortName *string
	// StandardFrameworkName is the name of the framework the standard belongs to, used in conjunction with StandardShortName to filter controls by standard when cloning
	StandardFrameworkName *string
	// StandardVersion is the revision of the standard to filter the controls by, this is optional, if more than one revision exists and this is not provided, the most recent revision will be used
	StandardVersion *string
	// RefCodes is a list of RefCodes to filter the controls by
	RefCodes []string
	// Categories is a list of Categories to filter the controls by
	Categories []string
}

CloneFilterOptions holds the filter options for cloning controls

func GetCloneFilterOptions

func GetCloneFilterOptions(input *model.CloneControlInput) CloneFilterOptions

GetCloneFilterOptions returns the filter options for cloning controls from the input based on the provided fields

type CloneOption

type CloneOption func(*CloneOptions)

CloneOption is a function type that modifies the CloneOptions

func WithOrgID

func WithOrgID(orgID string) CloneOption

WithOrgID sets the OrgID in the CloneOptions

func WithProgramID

func WithProgramID(programID string) CloneOption

WithProgramID sets the ProgramID in the CloneOptions

type CloneOptions

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

CloneOptions holds the options for cloning controls

type ControlToUpdate

type ControlToUpdate struct {
	ExistingControlID string
	SourceControl     *generated.Control
}

ControlToUpdate is used to track existing controls that need to be updated due to changes in the revision of their connected standards

type SubcontrolToCreate

type SubcontrolToCreate struct {
	NewControlID string
	RefControl   *generated.Control
}

SubcontrolToCreate is used to track which subcontrols need to be created for a given control

func CloneControls

func CloneControls(ctx context.Context, client *generated.Client, controlsToClone []*generated.Control, opts ...CloneOption) ([]string, []SubcontrolToCreate, error)

CloneControls clones the given controls with the provided options and returns the IDs of the created controls, the subcontrols to create, and any errors that occurred during cloning

Jump to

Keyboard shortcuts

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