Documentation
¶
Overview ¶
Package integration provides public types and helpers reusable across the codebase.
Index ¶
- Constants
- Variables
- func GetRequiredModuleForEventType(eventType EventType) string
- func SeverityFilterApplies(eventType EventType) bool
- type AuthType
- type Category
- type EventCategory
- type EventCategoryInfo
- type EventType
- func AllKnownEventTypes() []EventType
- func DefaultEnabledEventTypes() []EventType
- func GetDefaultEventTypesByModules(enabledModuleIDs []string) []EventType
- func MapLegacyEventType(eventType EventType) EventType
- func ValidateEventTypes(eventTypes []EventType, enabledModuleIDs []string) (valid bool, invalidTypes []EventType)
- type EventTypeInfo
- type Filter
- type ID
- type Integration
- func (i *Integration) AuthType() AuthType
- func (i *Integration) BaseURL() string
- func (i *Integration) Category() Category
- func (i *Integration) Config() map[string]any
- func (i *Integration) CreatedAt() time.Time
- func (i *Integration) CreatedBy() *ID
- func (i *Integration) CredentialsEncrypted() string
- func (i *Integration) Description() string
- func (i *Integration) ID() ID
- func (i *Integration) IsConnected() bool
- func (i *Integration) IsSCM() bool
- func (i *Integration) LastSyncAt() *time.Time
- func (i *Integration) Metadata() map[string]any
- func (i *Integration) Name() string
- func (i *Integration) NextSyncAt() *time.Time
- func (i *Integration) Provider() Provider
- func (i *Integration) RecordSyncFailure(errMsg string)
- func (i *Integration) RecordSyncSuccess()
- func (i *Integration) SetBaseURL(baseURL string)
- func (i *Integration) SetConfig(config map[string]any)
- func (i *Integration) SetConnected()
- func (i *Integration) SetCredentials(encrypted string)
- func (i *Integration) SetDescription(description string)
- func (i *Integration) SetDisconnected()
- func (i *Integration) SetError(err string)
- func (i *Integration) SetMetadata(metadata map[string]any)
- func (i *Integration) SetName(name string)
- func (i *Integration) SetStats(stats Stats)
- func (i *Integration) SetStatus(status Status)
- func (i *Integration) SetStatusMessage(message string)
- func (i *Integration) SetSyncInterval(minutes int)
- func (i *Integration) Stats() Stats
- func (i *Integration) Status() Status
- func (i *Integration) StatusMessage() string
- func (i *Integration) SyncError() string
- func (i *Integration) SyncIntervalMinutes() int
- func (i *Integration) TenantID() ID
- func (i *Integration) UpdateLastSync()
- func (i *Integration) UpdatedAt() time.Time
- type IntegrationWithNotification
- type IntegrationWithSCM
- type ListResult
- type NotificationExtension
- func NewNotificationExtension(integrationID ID) *NotificationExtension
- func ReconstructNotificationExtension(integrationID ID, _ string, _ string, enabledSeverities []Severity, ...) *NotificationExtension
- func ReconstructNotificationExtensionFromBooleans(integrationID ID, _ string, _ string, notifyOnCritical bool, notifyOnHigh bool, ...) *NotificationExtension
- func (n *NotificationExtension) ChannelID() string
- func (n *NotificationExtension) ChannelName() string
- func (n *NotificationExtension) EnabledEventTypes() []EventType
- func (n *NotificationExtension) EnabledSeverities() []Severity
- func (n *NotificationExtension) IncludeDetails() bool
- func (n *NotificationExtension) IntegrationID() ID
- func (n *NotificationExtension) IsEventTypeEnabled(eventType EventType) bool
- func (n *NotificationExtension) IsSeverityEnabled(severity Severity) bool
- func (n *NotificationExtension) MessageTemplate() string
- func (n *NotificationExtension) MinIntervalMinutes() int
- func (n *NotificationExtension) NotifyOnCritical() bool
- func (n *NotificationExtension) NotifyOnHigh() bool
- func (n *NotificationExtension) NotifyOnLow() bool
- func (n *NotificationExtension) NotifyOnMedium() bool
- func (n *NotificationExtension) SetChannel(_, _ string)
- func (n *NotificationExtension) SetEnabledEventTypes(types []EventType)
- func (n *NotificationExtension) SetEnabledSeverities(severities []Severity)
- func (n *NotificationExtension) SetIncludeDetails(include bool)
- func (n *NotificationExtension) SetMessageTemplate(template string)
- func (n *NotificationExtension) SetMinIntervalMinutes(minutes int)
- func (n *NotificationExtension) SetNotifyOnCritical(notify bool)
- func (n *NotificationExtension) SetNotifyOnHigh(notify bool)
- func (n *NotificationExtension) SetNotifyOnLow(notify bool)
- func (n *NotificationExtension) SetNotifyOnMedium(notify bool)
- func (n *NotificationExtension) ShouldNotify(severity string) bool
- func (n *NotificationExtension) ShouldNotifyEventType(eventType EventType) bool
- type NotificationExtensionRepository
- type Provider
- type Repository
- type SCMExtension
- func (s *SCMExtension) AutoImportRepos() bool
- func (s *SCMExtension) DefaultBranchPattern() string
- func (s *SCMExtension) ExcludePatterns() []string
- func (s *SCMExtension) ImportArchivedRepos() bool
- func (s *SCMExtension) ImportPrivateRepos() bool
- func (s *SCMExtension) IncludePatterns() []string
- func (s *SCMExtension) IntegrationID() ID
- func (s *SCMExtension) LastRepoSyncAt() *time.Time
- func (s *SCMExtension) RepositoryCount() int
- func (s *SCMExtension) SCMOrganization() string
- func (s *SCMExtension) SetAutoImportRepos(auto bool)
- func (s *SCMExtension) SetDefaultBranchPattern(pattern string)
- func (s *SCMExtension) SetExcludePatterns(patterns []string)
- func (s *SCMExtension) SetImportArchivedRepos(archived bool)
- func (s *SCMExtension) SetImportPrivateRepos(private bool)
- func (s *SCMExtension) SetIncludePatterns(patterns []string)
- func (s *SCMExtension) SetRepositoryCount(count int)
- func (s *SCMExtension) SetSCMOrganization(org string)
- func (s *SCMExtension) SetWebhook(id string, secretCiphertext []byte, url string)
- func (s *SCMExtension) UpdateLastRepoSync()
- func (s *SCMExtension) WebhookID() string
- func (s *SCMExtension) WebhookSecretEncrypted() []byte
- func (s *SCMExtension) WebhookURL() string
- type SCMExtensionRepository
- type Severity
- type Stats
- type Status
Constants ¶
const ( ModuleAssets = "assets" ModuleScans = "scans" ModuleFindings = "findings" )
Module IDs that map to event types. These must match the module IDs in the modules table.
Variables ¶
var ( // Not found errors ErrIntegrationNotFound = fmt.Errorf("%w: integration not found", shared.ErrNotFound) ErrSCMExtensionNotFound = fmt.Errorf("%w: SCM extension not found", shared.ErrNotFound) ErrNotificationExtensionNotFound = fmt.Errorf("%w: notification extension not found", shared.ErrNotFound) // Conflict errors ErrIntegrationNameExists = fmt.Errorf("%w: integration name already exists", shared.ErrConflict) ErrIntegrationInUse = fmt.Errorf("%w: integration is in use", shared.ErrConflict) // Validation errors ErrInvalidCategory = fmt.Errorf("%w: invalid integration category", shared.ErrValidation) ErrInvalidProvider = fmt.Errorf("%w: invalid integration provider", shared.ErrValidation) ErrInvalidStatus = fmt.Errorf("%w: invalid integration status", shared.ErrValidation) ErrInvalidAuthType = fmt.Errorf("%w: invalid authentication type", shared.ErrValidation) ErrCredentialsRequired = fmt.Errorf("%w: credentials are required", shared.ErrValidation) ErrProviderCategoryMismatch = fmt.Errorf("%w: provider does not match category", shared.ErrValidation) // Connection errors ErrConnectionFailed = fmt.Errorf("%w: connection test failed", shared.ErrValidation) ErrCredentialsInvalid = fmt.Errorf("%w: credentials are invalid", shared.ErrValidation) )
Domain errors for integration.
Functions ¶
func GetRequiredModuleForEventType ¶
GetRequiredModuleForEventType returns the module ID required for an event type. Returns empty string if the event type is always available (system events).
func SeverityFilterApplies ¶ added in v0.5.0
SeverityFilterApplies reports whether the per-integration severity filter is meaningful for this event type.
EnqueueParams.Severity carries two different things depending on the event:
For finding-shaped events (new_finding, sla_breach, ...) it IS the finding's severity. An operator who leaves the filter at its default is saying "only tell me about critical and high findings", and honoring that is the whole point of the filter.
For approval lifecycle events it is a hardcoded constant chosen by the enqueue site ("medium" for requested/rejected, "low" for approved). It describes nothing about a finding, and no operator ever asked to suppress it.
Running the second kind through a filter built for the first kind silently defeats it. That is not hypothetical: DefaultEnabledEventTypes deliberately includes EventTypeApprovalRequested, with the comment "if it reaches nobody the finding stays blocked indefinitely" — and then the severity gate dropped it anyway, because "medium" is not in the default critical+high set. The event-type gate was opened on purpose and the severity gate closed it again.
Events exempted here remain fully controllable through the event-type filter, which is the switch that actually means "I do not want these".
Types ¶
type AuthType ¶
type AuthType string
AuthType represents the authentication type.
type EventCategory ¶
type EventCategory string
EventCategory groups event types for UI organization.
const ( EventCategorySystem EventCategory = "system" EventCategoryAsset EventCategory = "asset" EventCategoryScan EventCategory = "scan" EventCategoryFinding EventCategory = "finding" EventCategoryExposure EventCategory = "exposure" EventCategoryApproval EventCategory = "approval" EventCategoryWorkflow EventCategory = "workflow" )
Event categories for UI grouping.
type EventCategoryInfo ¶ added in v0.4.0
type EventCategoryInfo struct {
Category EventCategory
Label string
}
EventCategoryInfo pairs an event category with its display label.
func AllEventCategories ¶ added in v0.4.0
func AllEventCategories() []EventCategoryInfo
AllEventCategories returns every event category with its display label, in the order categories should be presented.
The labels live here rather than in the UI for the same reason AllEventTypes does: a category added to the constant block above but missing from a client-side label map renders as "undefined" (or crashes a lookup) with nothing failing at build time. Both approval and workflow categories were added without the UI's map learning about them.
type EventType ¶
type EventType string
EventType represents the type of event that triggers notifications.
const ( // System events EventTypeSecurityAlert EventType = "security_alert" EventTypeSystemError EventType = "system_error" // Asset events EventTypeNewAsset EventType = "new_asset" EventTypeAssetChanged EventType = "asset_changed" EventTypeAssetDeleted EventType = "asset_deleted" // Scan events EventTypeScanStarted EventType = "scan_started" EventTypeScanCompleted EventType = "scan_completed" EventTypeScanFailed EventType = "scan_failed" // Finding events EventTypeNewFinding EventType = "new_finding" EventTypeFindingConfirmed EventType = "finding_confirmed" EventTypeFindingTriaged EventType = "finding_triaged" EventTypeFindingFixed EventType = "finding_fixed" EventTypeFindingReopened EventType = "finding_reopened" // EventTypeFindingPriorityEscalated fires when an already-classified // finding is re-classified UP (e.g. P3 -> P0 because its CVE was newly // listed in KEV, or a compensating control was removed). Without it a // priority escalation is a silent dashboard update. EventTypeFindingPriorityEscalated EventType = "finding_priority_escalated" // EventTypeFindingAssigned fires when an assignment rule routes a finding to // a group AND that rule has its "notify group" option switched on. The // operator has already opted in at the rule; an unregistered event type made // that checkbox inert. EventTypeFindingAssigned EventType = "finding_assigned" // EventTypeSLABreach fires when the SLA escalation controller marks a // finding as having missed its remediation deadline. EventTypeSLABreach EventType = "sla_breach" // Approval events (risk-acceptance / status-change approvals on findings) EventTypeApprovalRequested EventType = "approval_requested" EventTypeApprovalApproved EventType = "approval_approved" EventTypeApprovalRejected EventType = "approval_rejected" // EventTypeWorkflowNotification fires from a workflow notification action // node that has no provider-specific integration bound to it, i.e. the // operator authored a workflow step whose only purpose is to notify. EventTypeWorkflowNotification EventType = "workflow_notification" // Exposure events EventTypeNewExposure EventType = "new_exposure" EventTypeExposureResolved EventType = "exposure_resolved" // Legacy event types (for backward compatibility) EventTypeFindings EventType = "findings" // Maps to new_finding EventTypeExposures EventType = "exposures" // Maps to new_exposure EventTypeScans EventType = "scans" // Maps to scan_completed EventTypeAlerts EventType = "alerts" // Maps to security_alert )
Known event types for notification routing. Add new event types here - no database migration required (JSONB array).
func AllKnownEventTypes ¶
func AllKnownEventTypes() []EventType
AllKnownEventTypes returns all known event types (for backward compatibility API).
func DefaultEnabledEventTypes ¶
func DefaultEnabledEventTypes() []EventType
DefaultEnabledEventTypes returns the default enabled event types for new integrations.
enabled_event_types is an opt-in whitelist, so anything absent here is not delivered to an integration created with the defaults. The bar for inclusion is therefore not "is this interesting" but "would a reasonable operator be surprised to learn this reached nobody".
func GetDefaultEventTypesByModules ¶
GetDefaultEventTypesByModules returns default event types filtered by enabled modules.
func MapLegacyEventType ¶
MapLegacyEventType maps old event types to new ones for backward compatibility.
func ValidateEventTypes ¶
func ValidateEventTypes(eventTypes []EventType, enabledModuleIDs []string) (valid bool, invalidTypes []EventType)
ValidateEventTypes checks if all event types are available for the given modules. Returns a list of invalid event types that require modules not in enabledModuleIDs.
type EventTypeInfo ¶
type EventTypeInfo struct {
Type EventType
Category EventCategory
Label string
Description string
RequiredModule string // Module ID required for this event type (empty = always available)
}
EventTypeInfo contains metadata about an event type.
func AllEventTypes ¶
func AllEventTypes() []EventTypeInfo
AllEventTypes returns all event types with metadata for UI. RequiredModule maps to modules.id in the database. Empty RequiredModule means the event type is always available (system events).
func GetEventTypesByModules ¶
func GetEventTypesByModules(enabledModuleIDs []string) []EventTypeInfo
GetEventTypesByModules returns event types filtered by enabled modules. System events (no required module) are always included.
type Filter ¶
type Filter struct {
TenantID *ID
Category *Category
Provider *Provider
Status *Status
Search string
Page int
PerPage int
SortBy string
SortOrder string
}
Filter represents filters for listing integrations.
type Integration ¶
type Integration struct {
// contains filtered or unexported fields
}
Integration represents a connection to an external service.
func NewIntegration ¶
func NewIntegration( id ID, tenantID ID, name string, category Category, provider Provider, authType AuthType, ) *Integration
NewIntegration creates a new integration.
func Reconstruct ¶
func Reconstruct( id ID, tenantID ID, name string, description string, category Category, provider Provider, status Status, statusMessage string, authType AuthType, baseURL string, credentialsEncrypted string, lastSyncAt *time.Time, nextSyncAt *time.Time, syncIntervalMinutes int, syncError string, config map[string]any, metadata map[string]any, stats Stats, createdAt time.Time, updatedAt time.Time, createdBy *ID, ) *Integration
Reconstruct creates an integration from stored data.
func (*Integration) AuthType ¶
func (i *Integration) AuthType() AuthType
func (*Integration) BaseURL ¶
func (i *Integration) BaseURL() string
func (*Integration) Category ¶
func (i *Integration) Category() Category
func (*Integration) Config ¶
func (i *Integration) Config() map[string]any
func (*Integration) CreatedAt ¶
func (i *Integration) CreatedAt() time.Time
func (*Integration) CreatedBy ¶
func (i *Integration) CreatedBy() *ID
func (*Integration) CredentialsEncrypted ¶
func (i *Integration) CredentialsEncrypted() string
func (*Integration) Description ¶
func (i *Integration) Description() string
func (*Integration) ID ¶
func (i *Integration) ID() ID
func (*Integration) IsConnected ¶
func (i *Integration) IsConnected() bool
IsConnected returns true if the integration is connected.
func (*Integration) IsSCM ¶
func (i *Integration) IsSCM() bool
IsSCM returns true if this is an SCM integration.
func (*Integration) LastSyncAt ¶
func (i *Integration) LastSyncAt() *time.Time
func (*Integration) Metadata ¶
func (i *Integration) Metadata() map[string]any
func (*Integration) Name ¶
func (i *Integration) Name() string
func (*Integration) NextSyncAt ¶
func (i *Integration) NextSyncAt() *time.Time
func (*Integration) Provider ¶
func (i *Integration) Provider() Provider
func (*Integration) RecordSyncFailure ¶ added in v0.4.0
func (i *Integration) RecordSyncFailure(errMsg string)
RecordSyncFailure records a failed scheduled sync but keeps the integration scheduled — nextSyncAt still advances so it retries next interval rather than hammering. Only the syncError message is set; the status is not flipped for a transient sync error.
func (*Integration) RecordSyncSuccess ¶ added in v0.4.0
func (i *Integration) RecordSyncSuccess()
RecordSyncSuccess stamps a successful scheduled sync: lastSyncAt=now, nextSyncAt=now+interval, and clears any prior sync error. Status is left unchanged (a connected integration stays connected).
func (*Integration) SetBaseURL ¶
func (i *Integration) SetBaseURL(baseURL string)
func (*Integration) SetConfig ¶
func (i *Integration) SetConfig(config map[string]any)
func (*Integration) SetConnected ¶
func (i *Integration) SetConnected()
func (*Integration) SetCredentials ¶
func (i *Integration) SetCredentials(encrypted string)
func (*Integration) SetDescription ¶
func (i *Integration) SetDescription(description string)
func (*Integration) SetDisconnected ¶
func (i *Integration) SetDisconnected()
func (*Integration) SetError ¶
func (i *Integration) SetError(err string)
func (*Integration) SetMetadata ¶
func (i *Integration) SetMetadata(metadata map[string]any)
func (*Integration) SetName ¶
func (i *Integration) SetName(name string)
func (*Integration) SetStats ¶
func (i *Integration) SetStats(stats Stats)
func (*Integration) SetStatus ¶
func (i *Integration) SetStatus(status Status)
func (*Integration) SetStatusMessage ¶
func (i *Integration) SetStatusMessage(message string)
func (*Integration) SetSyncInterval ¶
func (i *Integration) SetSyncInterval(minutes int)
func (*Integration) Stats ¶
func (i *Integration) Stats() Stats
func (*Integration) Status ¶
func (i *Integration) Status() Status
func (*Integration) StatusMessage ¶
func (i *Integration) StatusMessage() string
func (*Integration) SyncError ¶
func (i *Integration) SyncError() string
func (*Integration) SyncIntervalMinutes ¶
func (i *Integration) SyncIntervalMinutes() int
func (*Integration) TenantID ¶
func (i *Integration) TenantID() ID
func (*Integration) UpdateLastSync ¶
func (i *Integration) UpdateLastSync()
func (*Integration) UpdatedAt ¶
func (i *Integration) UpdatedAt() time.Time
type IntegrationWithNotification ¶
type IntegrationWithNotification struct {
*Integration
Notification *NotificationExtension
}
IntegrationWithNotification combines an Integration with its notification extension.
func NewIntegrationWithNotification ¶
func NewIntegrationWithNotification(integration *Integration, notification *NotificationExtension) *IntegrationWithNotification
NewIntegrationWithNotification creates a new integration with notification extension.
type IntegrationWithSCM ¶
type IntegrationWithSCM struct {
*Integration
SCM *SCMExtension
}
IntegrationWithSCM combines an Integration with its SCM extension.
func NewIntegrationWithSCM ¶
func NewIntegrationWithSCM(integration *Integration, scm *SCMExtension) *IntegrationWithSCM
NewIntegrationWithSCM creates a new integration with SCM extension.
type ListResult ¶
type ListResult struct {
Data []*Integration
Total int64
Page int
PerPage int
TotalPages int
}
ListResult represents a paginated list result.
type NotificationExtension ¶
type NotificationExtension struct {
// contains filtered or unexported fields
}
NotificationExtension represents notification-specific extension data for an integration. This follows the same pattern as SCM extension. Note: channel_id (for Telegram) and channel_name (for Slack/Teams) are now stored in integrations.metadata instead of this extension table.
func NewNotificationExtension ¶
func NewNotificationExtension(integrationID ID) *NotificationExtension
NewNotificationExtension creates a new notification extension with defaults.
func ReconstructNotificationExtension ¶
func ReconstructNotificationExtension( integrationID ID, _ string, _ string, enabledSeverities []Severity, enabledEventTypes []EventType, messageTemplate string, includeDetails bool, minIntervalMinutes int, ) *NotificationExtension
ReconstructNotificationExtension creates a notification extension from stored data. Note: channelID and channelName parameters are deprecated and ignored. They are now stored in integrations.metadata.
func ReconstructNotificationExtensionFromBooleans ¶
func ReconstructNotificationExtensionFromBooleans( integrationID ID, _ string, _ string, notifyOnCritical bool, notifyOnHigh bool, notifyOnMedium bool, notifyOnLow bool, enabledEventTypes []EventType, messageTemplate string, includeDetails bool, minIntervalMinutes int, ) *NotificationExtension
ReconstructNotificationExtensionFromBooleans creates extension from old boolean fields. Used for backward compatibility during migration. Note: channelID and channelName parameters are deprecated and ignored.
func (*NotificationExtension) ChannelID ¶
func (n *NotificationExtension) ChannelID() string
ChannelID returns empty string - deprecated, now stored in integrations.metadata as chat_id
func (*NotificationExtension) ChannelName ¶
func (n *NotificationExtension) ChannelName() string
ChannelName returns empty string - deprecated, now stored in integrations.metadata as channel_name
func (*NotificationExtension) EnabledEventTypes ¶
func (n *NotificationExtension) EnabledEventTypes() []EventType
func (*NotificationExtension) EnabledSeverities ¶
func (n *NotificationExtension) EnabledSeverities() []Severity
func (*NotificationExtension) IncludeDetails ¶
func (n *NotificationExtension) IncludeDetails() bool
func (*NotificationExtension) IntegrationID ¶
func (n *NotificationExtension) IntegrationID() ID
func (*NotificationExtension) IsEventTypeEnabled ¶
func (n *NotificationExtension) IsEventTypeEnabled(eventType EventType) bool
IsEventTypeEnabled checks if a specific event type is enabled.
func (*NotificationExtension) IsSeverityEnabled ¶
func (n *NotificationExtension) IsSeverityEnabled(severity Severity) bool
IsSeverityEnabled checks if a specific severity is enabled.
func (*NotificationExtension) MessageTemplate ¶
func (n *NotificationExtension) MessageTemplate() string
func (*NotificationExtension) MinIntervalMinutes ¶
func (n *NotificationExtension) MinIntervalMinutes() int
func (*NotificationExtension) NotifyOnCritical ¶
func (n *NotificationExtension) NotifyOnCritical() bool
Backward compatibility getters (derived from enabledSeverities)
func (*NotificationExtension) NotifyOnHigh ¶
func (n *NotificationExtension) NotifyOnHigh() bool
func (*NotificationExtension) NotifyOnLow ¶
func (n *NotificationExtension) NotifyOnLow() bool
func (*NotificationExtension) NotifyOnMedium ¶
func (n *NotificationExtension) NotifyOnMedium() bool
func (*NotificationExtension) SetChannel ¶
func (n *NotificationExtension) SetChannel(_, _ string)
SetChannel is deprecated - channel info is now stored in integrations.metadata This function is kept for backward compatibility but does nothing.
func (*NotificationExtension) SetEnabledEventTypes ¶
func (n *NotificationExtension) SetEnabledEventTypes(types []EventType)
func (*NotificationExtension) SetEnabledSeverities ¶
func (n *NotificationExtension) SetEnabledSeverities(severities []Severity)
func (*NotificationExtension) SetIncludeDetails ¶
func (n *NotificationExtension) SetIncludeDetails(include bool)
func (*NotificationExtension) SetMessageTemplate ¶
func (n *NotificationExtension) SetMessageTemplate(template string)
func (*NotificationExtension) SetMinIntervalMinutes ¶
func (n *NotificationExtension) SetMinIntervalMinutes(minutes int)
func (*NotificationExtension) SetNotifyOnCritical ¶
func (n *NotificationExtension) SetNotifyOnCritical(notify bool)
Backward compatibility setters
func (*NotificationExtension) SetNotifyOnHigh ¶
func (n *NotificationExtension) SetNotifyOnHigh(notify bool)
func (*NotificationExtension) SetNotifyOnLow ¶
func (n *NotificationExtension) SetNotifyOnLow(notify bool)
func (*NotificationExtension) SetNotifyOnMedium ¶
func (n *NotificationExtension) SetNotifyOnMedium(notify bool)
func (*NotificationExtension) ShouldNotify ¶
func (n *NotificationExtension) ShouldNotify(severity string) bool
ShouldNotify checks if a notification should be sent for the given severity string.
func (*NotificationExtension) ShouldNotifyEventType ¶
func (n *NotificationExtension) ShouldNotifyEventType(eventType EventType) bool
ShouldNotifyEventType checks if a notification should be sent for the given event type.
type NotificationExtensionRepository ¶
type NotificationExtensionRepository interface {
// CRUD operations
Create(ctx context.Context, ext *NotificationExtension) error
GetByIntegrationID(ctx context.Context, integrationID ID) (*NotificationExtension, error)
Update(ctx context.Context, ext *NotificationExtension) error
Delete(ctx context.Context, integrationID ID) error
// Combined operations (integration + extension)
GetIntegrationWithNotification(ctx context.Context, id ID) (*IntegrationWithNotification, error)
ListIntegrationsWithNotification(ctx context.Context, tenantID ID) ([]*IntegrationWithNotification, error)
}
NotificationExtensionRepository defines the interface for notification extension persistence.
type Provider ¶
type Provider string
Provider represents the integration provider.
const ( ProviderGitHub Provider = "github" ProviderGitLab Provider = "gitlab" ProviderBitbucket Provider = "bitbucket" ProviderAzureDevOps Provider = "azure_devops" )
SCM Providers
const ( ProviderWiz Provider = "wiz" ProviderSnyk Provider = "snyk" ProviderTenable Provider = "tenable" ProviderCrowdStrike Provider = "crowdstrike" // ProviderDefectDojo is a vulnerability-aggregation front-end whose 200+ // scanner parsers we ingest via CTIS (RFC-013 co-existence connector). ProviderDefectDojo Provider = "defectdojo" )
Security Providers
const ( ProviderAWS Provider = "aws" ProviderGCP Provider = "gcp" ProviderAzure Provider = "azure" )
Cloud Providers
const ( ProviderJira Provider = "jira" ProviderLinear Provider = "linear" ProviderAsana Provider = "asana" )
Ticketing Providers
const ( ProviderSlack Provider = "slack" ProviderTeams Provider = "teams" ProviderTelegram Provider = "telegram" ProviderEmail Provider = "email" ProviderWebhook Provider = "webhook" )
Notification Providers
type Repository ¶
type Repository interface {
// CRUD operations
Create(ctx context.Context, i *Integration) error
GetByID(ctx context.Context, id ID) (*Integration, error)
// GetByTenantAndID fetches an integration scoped to a tenant, returning
// ErrIntegrationNotFound if it does not exist OR belongs to another tenant.
// Prefer this over GetByID + a post-fetch tenant check on tenant-facing paths
// (no fetch-then-check window).
GetByTenantAndID(ctx context.Context, tenantID ID, id ID) (*Integration, error)
GetByTenantAndName(ctx context.Context, tenantID ID, name string) (*Integration, error)
Update(ctx context.Context, i *Integration) error
Delete(ctx context.Context, id ID) error
// List operations
List(ctx context.Context, filter Filter) (ListResult, error)
Count(ctx context.Context, filter Filter) (int64, error)
// Batch operations
ListByTenant(ctx context.Context, tenantID ID) ([]*Integration, error)
ListByCategory(ctx context.Context, tenantID ID, category Category) ([]*Integration, error)
ListByProvider(ctx context.Context, tenantID ID, provider Provider) ([]*Integration, error)
}
Repository defines the interface for integration persistence.
type SCMExtension ¶
type SCMExtension struct {
// contains filtered or unexported fields
}
SCMExtension represents SCM-specific extension data for an integration. This follows the same pattern as asset + asset_repositories extension.
func NewSCMExtension ¶
func NewSCMExtension(integrationID ID) *SCMExtension
NewSCMExtension creates a new SCM extension.
func ReconstructSCMExtension ¶
func ReconstructSCMExtension( integrationID ID, scmOrganization string, repositoryCount int, webhookID string, webhookSecretEncrypted []byte, webhookURL string, defaultBranchPattern string, autoImportRepos bool, importPrivateRepos bool, importArchivedRepos bool, includePatterns []string, excludePatterns []string, lastRepoSyncAt *time.Time, ) *SCMExtension
ReconstructSCMExtension creates an SCM extension from stored data. webhookSecretEncrypted is the AES-GCM ciphertext read from the DB; the service layer calls Encryptor.DecryptString when (and only when) a live HMAC verify needs the plaintext.
func (*SCMExtension) AutoImportRepos ¶
func (s *SCMExtension) AutoImportRepos() bool
func (*SCMExtension) DefaultBranchPattern ¶
func (s *SCMExtension) DefaultBranchPattern() string
func (*SCMExtension) ExcludePatterns ¶
func (s *SCMExtension) ExcludePatterns() []string
func (*SCMExtension) ImportArchivedRepos ¶
func (s *SCMExtension) ImportArchivedRepos() bool
func (*SCMExtension) ImportPrivateRepos ¶
func (s *SCMExtension) ImportPrivateRepos() bool
func (*SCMExtension) IncludePatterns ¶
func (s *SCMExtension) IncludePatterns() []string
func (*SCMExtension) IntegrationID ¶
func (s *SCMExtension) IntegrationID() ID
func (*SCMExtension) LastRepoSyncAt ¶
func (s *SCMExtension) LastRepoSyncAt() *time.Time
func (*SCMExtension) RepositoryCount ¶
func (s *SCMExtension) RepositoryCount() int
func (*SCMExtension) SCMOrganization ¶
func (s *SCMExtension) SCMOrganization() string
func (*SCMExtension) SetAutoImportRepos ¶
func (s *SCMExtension) SetAutoImportRepos(auto bool)
func (*SCMExtension) SetDefaultBranchPattern ¶
func (s *SCMExtension) SetDefaultBranchPattern(pattern string)
func (*SCMExtension) SetExcludePatterns ¶
func (s *SCMExtension) SetExcludePatterns(patterns []string)
func (*SCMExtension) SetImportArchivedRepos ¶
func (s *SCMExtension) SetImportArchivedRepos(archived bool)
func (*SCMExtension) SetImportPrivateRepos ¶
func (s *SCMExtension) SetImportPrivateRepos(private bool)
func (*SCMExtension) SetIncludePatterns ¶
func (s *SCMExtension) SetIncludePatterns(patterns []string)
func (*SCMExtension) SetRepositoryCount ¶
func (s *SCMExtension) SetRepositoryCount(count int)
func (*SCMExtension) SetSCMOrganization ¶
func (s *SCMExtension) SetSCMOrganization(org string)
func (*SCMExtension) SetWebhook ¶
func (s *SCMExtension) SetWebhook(id string, secretCiphertext []byte, url string)
SetWebhook persists the webhook configuration. secretCiphertext MUST be the output of pkg/crypto.Encryptor.EncryptString — service-layer callers encrypt before reaching the domain. Passing a plaintext string here would land the secret on disk unencrypted (the threat this refactor is closing); tests that want a placeholder should pass []byte("dummy-ciphertext").
func (*SCMExtension) UpdateLastRepoSync ¶
func (s *SCMExtension) UpdateLastRepoSync()
func (*SCMExtension) WebhookID ¶
func (s *SCMExtension) WebhookID() string
func (*SCMExtension) WebhookSecretEncrypted ¶ added in v0.2.0
func (s *SCMExtension) WebhookSecretEncrypted() []byte
func (*SCMExtension) WebhookURL ¶
func (s *SCMExtension) WebhookURL() string
type SCMExtensionRepository ¶
type SCMExtensionRepository interface {
// CRUD operations
Create(ctx context.Context, ext *SCMExtension) error
GetByIntegrationID(ctx context.Context, integrationID ID) (*SCMExtension, error)
Update(ctx context.Context, ext *SCMExtension) error
Delete(ctx context.Context, integrationID ID) error
// Combined operations (integration + extension)
GetIntegrationWithSCM(ctx context.Context, id ID) (*IntegrationWithSCM, error)
ListIntegrationsWithSCM(ctx context.Context, tenantID ID) ([]*IntegrationWithSCM, error)
}
SCMExtensionRepository defines the interface for SCM extension persistence.
type Severity ¶
type Severity string
Severity represents notification severity level. Stored as JSONB array in database for flexibility.
const ( SeverityCritical Severity = "critical" SeverityHigh Severity = "high" SeverityMedium Severity = "medium" SeverityLow Severity = "low" SeverityInfo Severity = "info" SeverityNone Severity = "none" )
Known severity levels. Add new severity here - no database migration required (JSONB array).
func AllKnownSeverities ¶
func AllKnownSeverities() []Severity
AllKnownSeverities returns all known severity levels (for UI display).
func DefaultEnabledSeverities ¶
func DefaultEnabledSeverities() []Severity
DefaultEnabledSeverities returns the default enabled severities for new integrations.
type Stats ¶
type Stats struct {
TotalAssets int `json:"total_assets"`
TotalFindings int `json:"total_findings"`
TotalRepositories int `json:"total_repositories,omitempty"`
}
Stats represents integration statistics.