Documentation
¶
Index ¶
- func IsValidSubjectTemplateSourceMode(value string) bool
- func IsValidSubjectTemplateType(value string) bool
- func IsValidationError(err error) bool
- func NormalizeSubjectTemplateSourceMode(value string) string
- func NormalizeSubjectTemplateType(value string) string
- func RenderTemplate(tmplStr string, labels map[string]string) (string, error)
- type AssessmentSubjectIdentity
- type BatchRiskTemplateItem
- type BatchSubjectTemplateItem
- type BatchUpsertRiskTemplatesResult
- type BatchUpsertSubjectTemplatesResult
- type ComponentDefinitionIdentity
- type RemediationTask
- type RemediationTaskInput
- type RemediationTemplate
- type RemediationTemplateInput
- type ResolveOrUpsertAssessmentSubjectInput
- type ResolveOrUpsertComponentDefinitionInput
- type ResolveOrUpsertComponentDefinitionResult
- type ResolveOrUpsertSystemComponentInput
- type ResolveOrUpsertSystemComponentsForEvidenceInput
- type RiskTemplate
- type RiskTemplateLabelSchemaField
- type RiskTemplateLabelSchemaFieldInput
- type RiskTemplateListFilters
- type RiskTemplateListParams
- type RiskTemplatePayload
- type RiskTemplateService
- func (s *RiskTemplateService) BatchUpsert(pluginID, policyPackage string, items []BatchRiskTemplateItem) (*BatchUpsertRiskTemplatesResult, error)
- func (s *RiskTemplateService) Create(payload RiskTemplatePayload) (*RiskTemplate, error)
- func (s *RiskTemplateService) Delete(id uuid.UUID) error
- func (s *RiskTemplateService) GetByID(id uuid.UUID) (*RiskTemplate, error)
- func (s *RiskTemplateService) List(params RiskTemplateListParams) ([]RiskTemplate, int64, error)
- func (s *RiskTemplateService) Update(id uuid.UUID, payload RiskTemplatePayload) (*RiskTemplate, error)
- func (s *RiskTemplateService) ValidateViolationMatch(violationIDs []string, violationID string) bool
- type RiskTemplateThreatRef
- type SubjectTemplate
- type SubjectTemplateLabelSchemaField
- type SubjectTemplateLabelSchemaFieldInput
- type SubjectTemplateListFilters
- type SubjectTemplateListParams
- type SubjectTemplatePayload
- type SubjectTemplateSelectorLabel
- type SubjectTemplateSelectorLabelInput
- type SubjectTemplateService
- func (s *SubjectTemplateService) BatchUpsert(pluginID string, items []BatchSubjectTemplateItem) (*BatchUpsertSubjectTemplatesResult, error)
- func (s *SubjectTemplateService) Create(payload SubjectTemplatePayload) (*SubjectTemplate, error)
- func (s *SubjectTemplateService) FindSystemComponentsByDefinedComponentIDs(definedComponentIDs []uuid.UUID) ([]relational.SystemComponent, error)
- func (s *SubjectTemplateService) GetByID(id uuid.UUID) (*SubjectTemplate, error)
- func (s *SubjectTemplateService) List(params SubjectTemplateListParams) ([]SubjectTemplate, int64, error)
- func (s *SubjectTemplateService) ResolveOrUpsertAssessmentSubject(input ResolveOrUpsertAssessmentSubjectInput) (*relational.AssessmentSubject, error)
- func (s *SubjectTemplateService) ResolveOrUpsertComponentDefinition(input ResolveOrUpsertComponentDefinitionInput) (*ResolveOrUpsertComponentDefinitionResult, error)
- func (s *SubjectTemplateService) ResolveOrUpsertSystemComponent(input ResolveOrUpsertSystemComponentInput) (*relational.SystemComponent, error)
- func (s *SubjectTemplateService) ResolveOrUpsertSystemComponentsForEvidence(input ResolveOrUpsertSystemComponentsForEvidenceInput) ([]relational.SystemComponent, error)
- func (s *SubjectTemplateService) Update(id uuid.UUID, payload SubjectTemplatePayload) (*SubjectTemplate, error)
- type SystemComponentIdentity
- type ThreatRefInput
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidationError ¶
Types ¶
type AssessmentSubjectIdentity ¶
type AssessmentSubjectIdentity struct {
EntityType string `json:"entityType" gorm:"column:entity_type;type:text;primaryKey"`
IdentityHash string `json:"identityHash" gorm:"column:identity_hash;type:char(64);primaryKey"`
AssessmentSubjectID uuid.UUID `json:"assessmentSubjectId" gorm:"column:assessment_subject_id;type:uuid;not null;index"`
}
func (AssessmentSubjectIdentity) TableName ¶
func (AssessmentSubjectIdentity) TableName() string
type BatchRiskTemplateItem ¶
type BatchRiskTemplateItem struct {
ID uuid.UUID
Name string
Title string
Statement string
LikelihoodHint *string
ImpactHint *string
ViolationIDs []string
IsActive *bool
ThreatRefs []ThreatRefInput
RemediationTemplate *RemediationTemplateInput
TitleTemplate *string
StatementTemplate *string
LikelihoodHintTemplate *string
ImpactHintTemplate *string
DedupeLabelKeys []string
LabelSchema []RiskTemplateLabelSchemaFieldInput
}
BatchRiskTemplateItem is a single item in a batch upsert request. PluginID and PolicyPackage are inherited from the batch-level scope and must not be set here. ID is mandatory and must be provided by the caller (agent-side UUID generation).
type BatchSubjectTemplateItem ¶
type BatchSubjectTemplateItem struct {
ID uuid.UUID
Name string
Type string
TitleTemplate *string
DescriptionTemplate *string
PurposeTemplate *string
RemarksTemplate *string
IdentityLabelKeys []string
Props []relational.Prop
Links []relational.Link
SourceMode string
SelectorLabels []SubjectTemplateSelectorLabelInput
LabelSchema []SubjectTemplateLabelSchemaFieldInput
}
BatchSubjectTemplateItem is a single item in a batch upsert request. The plugin_id is inherited from the batch-level scope (via selector-label) and each item is expected to carry a selector-label with key=pluginSelectorLabelKey and value=pluginID. ID is mandatory and must be provided by the caller (agent-side UUID generation). TODO: agents should use deterministic/generational UUID derivation so that re-running a batch produces the same IDs for the same logical templates. The derivation strategy (e.g. sha1(plugin_id + name + type)) must be decided and implemented on the agent side.
type BatchUpsertRiskTemplatesResult ¶
type BatchUpsertRiskTemplatesResult struct {
Created []RiskTemplate
Updated []RiskTemplate
Deleted []uuid.UUID
Unchanged []uuid.UUID
}
BatchUpsertRiskTemplatesResult is the result of a RiskTemplateService.BatchUpsert call.
type BatchUpsertSubjectTemplatesResult ¶
type BatchUpsertSubjectTemplatesResult struct {
Created []SubjectTemplate
Updated []SubjectTemplate
Deleted []uuid.UUID
Unchanged []uuid.UUID
}
BatchUpsertSubjectTemplatesResult is the result of a SubjectTemplateService.BatchUpsert call.
type ComponentDefinitionIdentity ¶
type ComponentDefinitionIdentity struct {
EntityType string `json:"entityType" gorm:"column:entity_type;type:text;primaryKey"`
IdentityHash string `json:"identityHash" gorm:"column:identity_hash;type:char(64);primaryKey"`
ComponentDefinitionID uuid.UUID `json:"componentDefinitionId" gorm:"column:component_definition_id;type:uuid;not null;index"`
DefinedComponentID uuid.UUID `json:"definedComponentId" gorm:"column:defined_component_id;type:uuid;not null;index"`
}
func (ComponentDefinitionIdentity) TableName ¶
func (ComponentDefinitionIdentity) TableName() string
type RemediationTask ¶
type RemediationTask struct {
relational.UUIDModel
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
RemediationTemplateID uuid.UUID `json:"remediationTemplateId" gorm:"type:uuid;not null;index"`
Title string `json:"title" gorm:"type:text;not null"`
OrderIndex int `json:"orderIndex" gorm:"not null"`
}
func (RemediationTask) TableName ¶
func (RemediationTask) TableName() string
type RemediationTaskInput ¶
type RemediationTemplate ¶
type RemediationTemplate struct {
relational.UUIDModel
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Title string `json:"title" gorm:"type:text;not null"`
Description *string `json:"description" gorm:"type:text"`
Tasks []RemediationTask `json:"tasks,omitempty" gorm:"foreignKey:RemediationTemplateID;constraint:OnDelete:CASCADE"`
}
func (RemediationTemplate) TableName ¶
func (RemediationTemplate) TableName() string
type RemediationTemplateInput ¶
type RemediationTemplateInput struct {
Title string
Description *string
Tasks []RemediationTaskInput
}
type ResolveOrUpsertAssessmentSubjectInput ¶
type ResolveOrUpsertAssessmentSubjectInput struct {
SubjectTemplateID uuid.UUID
EvidenceLabels []relational.Labels
}
type ResolveOrUpsertComponentDefinitionInput ¶
type ResolveOrUpsertComponentDefinitionInput struct {
EvidenceLabels []relational.Labels
}
type ResolveOrUpsertSystemComponentsForEvidenceInput ¶
type ResolveOrUpsertSystemComponentsForEvidenceInput struct {
SystemSecurityPlanID uuid.UUID
EvidenceLabels []relational.Labels
}
type RiskTemplate ¶
type RiskTemplate struct {
relational.UUIDModel
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
PluginID string `json:"pluginId" gorm:"type:text;not null;index"`
PolicyPackage string `json:"policyPackage" gorm:"type:text;not null;index"`
Name string `json:"name" gorm:"type:text;not null"`
Title string `json:"title" gorm:"type:text;not null"`
Statement string `json:"statement" gorm:"type:text;not null"`
LikelihoodHint *string `json:"likelihoodHint" gorm:"type:varchar(32)"`
ImpactHint *string `json:"impactHint" gorm:"type:varchar(32)"`
TitleTemplate *string `json:"titleTemplate" gorm:"type:text"`
StatementTemplate *string `json:"statementTemplate" gorm:"type:text"`
LikelihoodHintTemplate *string `json:"likelihoodHintTemplate" gorm:"type:text"`
ImpactHintTemplate *string `json:"impactHintTemplate" gorm:"type:text"`
DedupeLabelKeys datatypes.JSONSlice[string] `json:"dedupeLabelKeys" gorm:"type:jsonb"`
RemediationTemplateID *uuid.UUID `json:"remediationTemplateId" gorm:"type:uuid;index"`
RemediationTemplate *RemediationTemplate `json:"remediationTemplate,omitempty" gorm:"foreignKey:RemediationTemplateID;references:ID"`
ViolationIDs datatypes.JSONSlice[string] `json:"violationIds" gorm:"type:jsonb"`
IsActive bool `json:"isActive" gorm:"not null;default:false;index"`
ThreatRefs []RiskTemplateThreatRef `json:"threatRefs,omitempty" gorm:"foreignKey:RiskTemplateID;constraint:OnDelete:CASCADE"`
LabelSchema []RiskTemplateLabelSchemaField `json:"labelSchema,omitempty" gorm:"foreignKey:RiskTemplateID;constraint:OnDelete:CASCADE"`
}
func (RiskTemplate) TableName ¶
func (RiskTemplate) TableName() string
type RiskTemplateLabelSchemaField ¶ added in v0.14.0
type RiskTemplateLabelSchemaField struct {
relational.UUIDModel
RiskTemplateID uuid.UUID `json:"riskTemplateId" gorm:"type:uuid;not null;uniqueIndex:idx_risk_template_label_schema_fields_template_key,priority:1"`
Key string `json:"key" gorm:"type:text;not null;uniqueIndex:idx_risk_template_label_schema_fields_template_key,priority:2"`
Description *string `json:"description" gorm:"type:text"`
}
func (RiskTemplateLabelSchemaField) TableName ¶ added in v0.14.0
func (RiskTemplateLabelSchemaField) TableName() string
type RiskTemplateLabelSchemaFieldInput ¶ added in v0.14.0
type RiskTemplateListFilters ¶
type RiskTemplateListParams ¶
type RiskTemplateListParams struct {
Filters RiskTemplateListFilters
Limit int
Offset int
}
type RiskTemplatePayload ¶
type RiskTemplatePayload struct {
PluginID string
PolicyPackage string
Name string
Title string
Statement string
LikelihoodHint *string
ImpactHint *string
ViolationIDs []string
IsActive *bool
ThreatRefs []ThreatRefInput
TitleTemplate *string
StatementTemplate *string
LikelihoodHintTemplate *string
ImpactHintTemplate *string
DedupeLabelKeys []string
LabelSchema []RiskTemplateLabelSchemaFieldInput
// Optional: nil means "no remediation template".
RemediationTemplate *RemediationTemplateInput
}
type RiskTemplateService ¶
type RiskTemplateService struct {
// contains filtered or unexported fields
}
func NewRiskTemplateService ¶
func NewRiskTemplateService(db *gorm.DB) *RiskTemplateService
func (*RiskTemplateService) BatchUpsert ¶
func (s *RiskTemplateService) BatchUpsert(pluginID, policyPackage string, items []BatchRiskTemplateItem) (*BatchUpsertRiskTemplatesResult, error)
BatchUpsert reconciles the full set of risk templates for a given (pluginID, policyPackage) pair. It creates, updates, and deletes templates as needed in a single atomic transaction. Templates not present in the payload are always deleted.
func (*RiskTemplateService) Create ¶
func (s *RiskTemplateService) Create(payload RiskTemplatePayload) (*RiskTemplate, error)
func (*RiskTemplateService) GetByID ¶
func (s *RiskTemplateService) GetByID(id uuid.UUID) (*RiskTemplate, error)
func (*RiskTemplateService) List ¶
func (s *RiskTemplateService) List(params RiskTemplateListParams) ([]RiskTemplate, int64, error)
func (*RiskTemplateService) Update ¶
func (s *RiskTemplateService) Update(id uuid.UUID, payload RiskTemplatePayload) (*RiskTemplate, error)
func (*RiskTemplateService) ValidateViolationMatch ¶
func (s *RiskTemplateService) ValidateViolationMatch(violationIDs []string, violationID string) bool
type RiskTemplateThreatRef ¶
type RiskTemplateThreatRef struct {
relational.UUIDModel
RiskTemplateID uuid.UUID `json:"riskTemplateId" gorm:"type:uuid;not null;index"`
System string `json:"system" gorm:"type:text;not null"`
ExternalID string `json:"externalId" gorm:"column:external_id;type:text;not null"`
Title string `json:"title" gorm:"type:text;not null"`
URL *string `json:"url" gorm:"type:text"`
}
func (RiskTemplateThreatRef) TableName ¶
func (RiskTemplateThreatRef) TableName() string
type SubjectTemplate ¶
type SubjectTemplate struct {
relational.UUIDModel
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Name string `json:"name" gorm:"type:text;not null"`
Type string `json:"type" gorm:"type:text;not null;index"`
TitleTemplate *string `json:"titleTemplate" gorm:"type:text"`
DescriptionTemplate *string `json:"descriptionTemplate" gorm:"type:text"`
PurposeTemplate *string `json:"purposeTemplate" gorm:"type:text"`
RemarksTemplate *string `json:"remarksTemplate" gorm:"type:text"`
IdentityLabelKeys datatypes.JSONSlice[string] `json:"identityLabelKeys" gorm:"type:jsonb"`
Props datatypes.JSONSlice[relational.Prop] `json:"props" gorm:"type:jsonb"`
Links datatypes.JSONSlice[relational.Link] `json:"links" gorm:"type:jsonb"`
SourceMode string `json:"sourceMode" gorm:"type:text;not null;index"`
SelectorLabels []SubjectTemplateSelectorLabel `json:"selectorLabels,omitempty" gorm:"foreignKey:SubjectTemplateID;constraint:OnDelete:CASCADE"`
LabelSchema []SubjectTemplateLabelSchemaField `json:"labelSchema,omitempty" gorm:"foreignKey:SubjectTemplateID;constraint:OnDelete:CASCADE"`
}
func (SubjectTemplate) TableName ¶
func (SubjectTemplate) TableName() string
type SubjectTemplateLabelSchemaField ¶
type SubjectTemplateLabelSchemaField struct {
relational.UUIDModel
SubjectTemplateID uuid.UUID `` /* 127-byte string literal not displayed */
Key string `json:"key" gorm:"type:text;not null;uniqueIndex:idx_subject_template_label_schema_fields_template_key,priority:2"`
Description *string `json:"description" gorm:"type:text"`
}
func (SubjectTemplateLabelSchemaField) TableName ¶
func (SubjectTemplateLabelSchemaField) TableName() string
type SubjectTemplateListParams ¶
type SubjectTemplateListParams struct {
Filters SubjectTemplateListFilters
Limit int
Offset int
}
type SubjectTemplatePayload ¶
type SubjectTemplatePayload struct {
Name string
Type string
TitleTemplate *string
DescriptionTemplate *string
PurposeTemplate *string
RemarksTemplate *string
IdentityLabelKeys []string
Props []relational.Prop
Links []relational.Link
SourceMode string
SelectorLabels []SubjectTemplateSelectorLabelInput
LabelSchema []SubjectTemplateLabelSchemaFieldInput
}
type SubjectTemplateSelectorLabel ¶
type SubjectTemplateSelectorLabel struct {
relational.UUIDModel
SubjectTemplateID uuid.UUID `json:"subjectTemplateId" gorm:"type:uuid;not null;uniqueIndex:idx_subject_template_selector_labels_template_key,priority:1"`
Key string `json:"key" gorm:"type:text;not null;uniqueIndex:idx_subject_template_selector_labels_template_key,priority:2"`
Value string `json:"value" gorm:"type:text;not null"`
}
func (SubjectTemplateSelectorLabel) TableName ¶
func (SubjectTemplateSelectorLabel) TableName() string
type SubjectTemplateService ¶
type SubjectTemplateService struct {
// contains filtered or unexported fields
}
func NewSubjectTemplateService ¶
func NewSubjectTemplateService(db *gorm.DB) *SubjectTemplateService
func (*SubjectTemplateService) BatchUpsert ¶
func (s *SubjectTemplateService) BatchUpsert(pluginID string, items []BatchSubjectTemplateItem) (*BatchUpsertSubjectTemplatesResult, error)
BatchUpsert reconciles the full set of subject templates scoped to a given pluginID. Scope is determined by templates that carry a selector-label with key=pluginSelectorLabelKey ("_plugin") and value=pluginID. All mutations are executed in a single atomic transaction. Templates not present in the payload are always deleted (no in-use guard).
func (*SubjectTemplateService) Create ¶
func (s *SubjectTemplateService) Create(payload SubjectTemplatePayload) (*SubjectTemplate, error)
func (*SubjectTemplateService) FindSystemComponentsByDefinedComponentIDs ¶
func (s *SubjectTemplateService) FindSystemComponentsByDefinedComponentIDs(definedComponentIDs []uuid.UUID) ([]relational.SystemComponent, error)
func (*SubjectTemplateService) GetByID ¶
func (s *SubjectTemplateService) GetByID(id uuid.UUID) (*SubjectTemplate, error)
func (*SubjectTemplateService) List ¶
func (s *SubjectTemplateService) List(params SubjectTemplateListParams) ([]SubjectTemplate, int64, error)
func (*SubjectTemplateService) ResolveOrUpsertAssessmentSubject ¶
func (s *SubjectTemplateService) ResolveOrUpsertAssessmentSubject(input ResolveOrUpsertAssessmentSubjectInput) (*relational.AssessmentSubject, error)
TODO[codex-review]: Dead code. Consider removing. For Copilot - this is a known issue and the moment the code will be removed is afterwards a full integration test battery. Please ignore review comments related to these methods / this comment
func (*SubjectTemplateService) ResolveOrUpsertComponentDefinition ¶
func (s *SubjectTemplateService) ResolveOrUpsertComponentDefinition(input ResolveOrUpsertComponentDefinitionInput) (*ResolveOrUpsertComponentDefinitionResult, error)
func (*SubjectTemplateService) ResolveOrUpsertSystemComponent ¶
func (s *SubjectTemplateService) ResolveOrUpsertSystemComponent(input ResolveOrUpsertSystemComponentInput) (*relational.SystemComponent, error)
TODO[codex-review]: Dead code. Consider removing. For Copilot - this is a known issue and the moment the code will be removed is afterwards a full integration test battery. Please ignore review comments related to these methods / this comment
func (*SubjectTemplateService) ResolveOrUpsertSystemComponentsForEvidence ¶
func (s *SubjectTemplateService) ResolveOrUpsertSystemComponentsForEvidence(input ResolveOrUpsertSystemComponentsForEvidenceInput) ([]relational.SystemComponent, error)
TODO[codex-review]: Dead code. Consider removing. For Copilot - this is a known issue and the moment the code will be removed is afterwards a full integration test battery. Please ignore review comments related to these methods / this comment
func (*SubjectTemplateService) Update ¶
func (s *SubjectTemplateService) Update(id uuid.UUID, payload SubjectTemplatePayload) (*SubjectTemplate, error)
type SystemComponentIdentity ¶
type SystemComponentIdentity struct {
EntityType string `json:"entityType" gorm:"column:entity_type;type:text;primaryKey"`
IdentityHash string `json:"identityHash" gorm:"column:identity_hash;type:char(64);primaryKey"`
SystemImplementationID uuid.UUID `json:"systemImplementationId" gorm:"column:system_implementation_id;type:uuid;primaryKey;index"`
SystemComponentID uuid.UUID `json:"systemComponentId" gorm:"column:system_component_id;type:uuid;not null;index"`
}
func (SystemComponentIdentity) TableName ¶
func (SystemComponentIdentity) TableName() string
type ThreatRefInput ¶
type ValidationError ¶
type ValidationError struct {
// contains filtered or unexported fields
}
func (ValidationError) Error ¶
func (e ValidationError) Error() string