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 ¶
- Variables
- func CleanImplementationGuidance(input *string) *models.ImplementationGuidance
- func CloneTrustCenterControls(ctx context.Context) error
- func ControlFilterByStandard(ctx context.Context, opts CloneFilterOptions, std *generated.Standard) ([]predicate.Control, error)
- func ConvertToCloneControlInput(input []*model.CloneControlUploadInput) ([]*model.CloneControlInput, error)
- func CreateCloneControlInput(c *generated.Control, programID *string, orgID string) (generated.CreateControlInput, bool)
- func CreateCloneSubcontrolInput(subcontrol *generated.Subcontrol, orgID string) *generated.CreateSubcontrolInput
- func CreateRevisionUpdateInput(c *generated.Control) generated.UpdateControlInput
- func CreateSubcontrolRevisionUpdateInput(sc *generated.Subcontrol, standardRevision *string) generated.UpdateSubcontrolInput
- func FilterByStandard(opts CloneFilterOptions) bool
- func GetControlIDFromRefCode(refCode string, controls []*generated.Control) (*string, bool)
- func GetFieldsToUpdate[T generated.UpdateControlInput | generated.UpdateSubcontrolInput](c *model.CloneControlUploadInput) (*T, bool, error)
- func HasRevisionChanged(existingRevision *string, standardRevision string) bool
- func StandardFilter(opts CloneFilterOptions) []predicate.Standard
- type CloneFilterOptions
- type CloneOption
- type CloneOptions
- type ControlToUpdate
- type SubcontrolToCreate
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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 ¶
func GetFieldsToUpdate[T generated.UpdateControlInput | generated.UpdateSubcontrolInput](c *model.CloneControlUploadInput) (*T, bool, error)
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 ¶
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 ¶
ControlToUpdate is used to track existing controls that need to be updated due to changes in the revision of their connected standards
type SubcontrolToCreate ¶
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