Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyDownMigrations(ctx context.Context, db *sql.DB, dir string) error
- func ApplyMigrations(ctx context.Context, db *sql.DB, dir string) error
- func MatchScope(scope Scope, tenantID string, workspaceID string) bool
- func NormalizeFindingTriage(triage domain.FindingTriage, now time.Time) domain.FindingTriage
- func NormalizeScanEventLevel(level string) (string, error)
- func QueueTraceContextFromContext(ctx context.Context) (string, string)
- func ResolveScopedWorkspaceID(scope Scope, workspaceID string) (string, error)
- func WithDefaultScope(ctx context.Context, fallback Scope) context.Context
- func WithQueueTraceContext(ctx context.Context, traceParent string, traceState string) context.Context
- func WithScope(ctx context.Context, scope Scope) context.Context
- type AuthzEntityAttributes
- type AuthzPolicyEvent
- type AuthzPolicyRollout
- type AuthzPolicySet
- type AuthzPolicyVersion
- type AuthzRelationship
- type AuthzRelationshipFilter
- type FindingListFilter
- type FindingMeta
- type FindingSummaryCounts
- type FindingTrendCount
- type FindingTriageEvent
- type FindingTriageState
- type IdentityConnection
- type IdentityFilter
- type Invitation
- type MemoryStore
- func (m *MemoryStore) AppendAuthzPolicyEvent(ctx context.Context, event AuthzPolicyEvent) error
- func (m *MemoryStore) AppendFindingTriageEvent(ctx context.Context, event FindingTriageEvent) error
- func (m *MemoryStore) AppendScanEvent(ctx context.Context, scanID string, level string, message string, ...) error
- func (m *MemoryStore) ApplyFindingTriageTransition(ctx context.Context, state FindingTriageState, event FindingTriageEvent) error
- func (m *MemoryStore) BeginWebhookEvent(ctx context.Context, event WebhookEvent, now time.Time) (WebhookEventStatus, string, error)
- func (m *MemoryStore) CancelRepoScan(ctx context.Context, repoScanID string, finishedAt time.Time, ...) (RepoScanRecord, error)
- func (m *MemoryStore) ClaimKubernetesEnrollmentToken(ctx context.Context, workspaceID string, projectID string, connectorID string, ...) (bool, error)
- func (m *MemoryStore) ClaimNextQueuedRepoScan(ctx context.Context) (RepoScanRecord, error)
- func (m *MemoryStore) ClaimNextQueuedRepoScanAnyScope(_ context.Context) (RepoScanRecord, error)
- func (m *MemoryStore) ClaimNextQueuedScan(ctx context.Context, provider string) (ScanRecord, error)
- func (m *MemoryStore) ClaimNextQueuedScanAnyScope(_ context.Context, provider string) (ScanRecord, error)
- func (m *MemoryStore) ClaimTenancyScanPolicySchedule(ctx context.Context, workspaceID string, projectID string, policyID string, ...) (bool, error)
- func (m *MemoryStore) Close() error
- func (m *MemoryStore) CompleteRepoScan(ctx context.Context, repoScanID string, status string, finishedAt time.Time, ...) error
- func (m *MemoryStore) CompleteScan(ctx context.Context, scanID string, status string, finishedAt time.Time, ...) error
- func (m *MemoryStore) CompleteWebhookEvent(ctx context.Context, provider string, eventID string, claimToken string, ...) error
- func (m *MemoryStore) ConsumeOAuthTransaction(ctx context.Context, nonce string, cookieToken string, now time.Time) (OAuthTransaction, error)
- func (m *MemoryStore) ConsumeSAMLRelayState(ctx context.Context, handle string, now time.Time) (SAMLRelayState, error)
- func (m *MemoryStore) CountPendingRepoScansByRepository(ctx context.Context, repository string) (int, error)
- func (m *MemoryStore) CountQueuedRepoScans(ctx context.Context) (int, error)
- func (m *MemoryStore) CountQueuedRepoScansAnyScope(_ context.Context) (int, error)
- func (m *MemoryStore) CountQueuedScans(ctx context.Context, provider string) (int, error)
- func (m *MemoryStore) CountQueuedScansAnyScope(_ context.Context, provider string) (int, error)
- func (m *MemoryStore) CreateAuthzPolicyVersion(ctx context.Context, version AuthzPolicyVersion) (AuthzPolicyVersion, error)
- func (m *MemoryStore) CreateIdentityConnection(ctx context.Context, connection IdentityConnection) (IdentityConnection, error)
- func (m *MemoryStore) CreateInvitation(ctx context.Context, invitation Invitation) (Invitation, error)
- func (m *MemoryStore) CreateOAuthTransaction(ctx context.Context, txn OAuthTransaction) (OAuthTransaction, error)
- func (m *MemoryStore) CreateQueuedRepoScan(ctx context.Context, repository string, source RepoScanSource, ...) (RepoScanRecord, error)
- func (m *MemoryStore) CreateQueuedRepoScanWithinLimit(ctx context.Context, repository string, source RepoScanSource, ...) (RepoScanRecord, error)
- func (m *MemoryStore) CreateQueuedScan(ctx context.Context, provider string, queuedAt time.Time) (ScanRecord, error)
- func (m *MemoryStore) CreateQueuedScanIfNoPending(ctx context.Context, provider string, queuedAt time.Time) (ScanRecord, error)
- func (m *MemoryStore) CreateQueuedScanWithinLimit(ctx context.Context, provider string, queuedAt time.Time, maxPending int) (ScanRecord, error)
- func (m *MemoryStore) CreateRepoScan(ctx context.Context, repository string, source RepoScanSource, ...) (RepoScanRecord, error)
- func (m *MemoryStore) CreateSAMLRelayState(ctx context.Context, state SAMLRelayState) (SAMLRelayState, error)
- func (m *MemoryStore) CreateSCIMProvisioningEvent(ctx context.Context, event SCIMProvisioningEventRecord) (SCIMProvisioningEventRecord, error)
- func (m *MemoryStore) CreateScan(ctx context.Context, provider string, startedAt time.Time) (ScanRecord, error)
- func (m *MemoryStore) CreateSession(ctx context.Context, session Session) (Session, error)
- func (m *MemoryStore) CreateVerifiedDomain(ctx context.Context, domain VerifiedDomain) (VerifiedDomain, error)
- func (m *MemoryStore) DeadLetterScan(ctx context.Context, scanID string, finishedAt time.Time, retryCount int, ...) error
- func (m *MemoryStore) DeleteAuthzRelationship(ctx context.Context, relationship AuthzRelationship) error
- func (m *MemoryStore) DeleteIdentityConnection(ctx context.Context, orgID, connectionID string) error
- func (m *MemoryStore) DeleteOrganization(ctx context.Context) error
- func (m *MemoryStore) DeleteProject(ctx context.Context, workspaceID string, projectID string) error
- func (m *MemoryStore) DeleteRepoFindings(ctx context.Context, repoScanID string) error
- func (m *MemoryStore) DeleteTenancyConnectorSecretEnvelope(ctx context.Context, workspaceID string, projectID string, connectorID string, ...) error
- func (m *MemoryStore) DeleteTenancyScanPolicy(ctx context.Context, workspaceID string, projectID string, policyID string) error
- func (m *MemoryStore) DeleteUserIdentity(ctx context.Context, provider string, subject string) error
- func (m *MemoryStore) DeleteWebhookEvent(ctx context.Context, provider string, eventID string, claimToken string) error
- func (m *MemoryStore) DeleteWorkspace(ctx context.Context, workspaceID string) error
- func (m *MemoryStore) DeleteWorkspaceMember(ctx context.Context, workspaceID string, memberID string) error
- func (m *MemoryStore) FailStaleRepoScansAnyScope(_ context.Context, staleBefore time.Time, limit int, errorMessage string) (int, error)
- func (m *MemoryStore) FindFirstWorkspaceMemberByUserUUID(ctx context.Context, userUUID string) (TenancyWorkspaceMember, error)
- func (m *MemoryStore) FindFirstWorkspaceMemberByUserUUIDAndTenantID(ctx context.Context, userUUID string, tenantID string) (TenancyWorkspaceMember, error)
- func (m *MemoryStore) GetAuthzEntityAttributes(ctx context.Context, entityKind string, entityType string, entityID string) (AuthzEntityAttributes, error)
- func (m *MemoryStore) GetAuthzPolicyRollout(ctx context.Context, policySetID string) (AuthzPolicyRollout, error)
- func (m *MemoryStore) GetAuthzPolicySet(ctx context.Context, policySetID string) (AuthzPolicySet, error)
- func (m *MemoryStore) GetAuthzPolicyVersion(ctx context.Context, policySetID string, version int) (AuthzPolicyVersion, error)
- func (m *MemoryStore) GetFinding(ctx context.Context, findingID string, scanID string) (domain.Finding, error)
- func (m *MemoryStore) GetFindingTriageState(ctx context.Context, findingID string) (FindingTriageState, error)
- func (m *MemoryStore) GetIdentityConnection(ctx context.Context, orgID string, connectionID string) (IdentityConnection, error)
- func (m *MemoryStore) GetIdentityConnectionByID(ctx context.Context, connectionID string) (IdentityConnection, error)
- func (m *MemoryStore) GetIdentityConnectionBySCIMBearerTokenHash(ctx context.Context, tokenHash string) (IdentityConnection, error)
- func (m *MemoryStore) GetInvitation(ctx context.Context, orgID string, invitationID string) (Invitation, error)
- func (m *MemoryStore) GetOnboardingState(ctx context.Context, userID string) (OnboardingState, error)
- func (m *MemoryStore) GetOrganization(ctx context.Context) (TenancyOrganization, error)
- func (m *MemoryStore) GetProject(ctx context.Context, workspaceID string, projectID string) (TenancyProject, error)
- func (m *MemoryStore) GetRepoScan(ctx context.Context, repoScanID string) (RepoScanRecord, error)
- func (m *MemoryStore) GetRepoScanCursor(ctx context.Context, repository string, source RepoScanSource) (RepoScanCursor, error)
- func (m *MemoryStore) GetScan(ctx context.Context, scanID string) (ScanRecord, error)
- func (m *MemoryStore) GetTenancyConnector(ctx context.Context, workspaceID string, projectID string, connectorID string) (TenancyConnectorWithState, error)
- func (m *MemoryStore) GetTenancyConnectorSecretEnvelope(ctx context.Context, workspaceID string, projectID string, connectorID string, ...) (TenancyConnectorSecretEnvelope, error)
- func (m *MemoryStore) GetTenancyScanPolicy(ctx context.Context, workspaceID string, projectID string, policyID string) (TenancyScanPolicy, error)
- func (m *MemoryStore) GetUser(ctx context.Context, userID string) (User, error)
- func (m *MemoryStore) GetUserByPrimaryEmail(ctx context.Context, email string) (User, error)
- func (m *MemoryStore) GetUserIdentity(ctx context.Context, provider string, subject string) (UserIdentity, error)
- func (m *MemoryStore) GetUserIdentityByProviderUserID(ctx context.Context, provider string, userID string) (UserIdentity, error)
- func (m *MemoryStore) GetVerifiedDomain(ctx context.Context, orgID string, domainID string) (VerifiedDomain, error)
- func (m *MemoryStore) GetWorkspace(ctx context.Context, workspaceID string) (TenancyWorkspace, error)
- func (m *MemoryStore) GetWorkspaceMember(ctx context.Context, workspaceID string, memberID string) (TenancyWorkspaceMember, error)
- func (m *MemoryStore) GetWorkspaceMemberByUserUUID(ctx context.Context, workspaceID string, userUUID string) (TenancyWorkspaceMember, error)
- func (m *MemoryStore) ListAllTenancyConnectorsByType(ctx context.Context, connectorType domain.ConnectorType, limit int) ([]TenancyConnectorWithState, error)
- func (m *MemoryStore) ListAuthzPolicyEvents(ctx context.Context, policySetID string, limit int) ([]AuthzPolicyEvent, error)
- func (m *MemoryStore) ListAuthzPolicyVersions(ctx context.Context, policySetID string, limit int) ([]AuthzPolicyVersion, error)
- func (m *MemoryStore) ListAuthzRelationships(ctx context.Context, filter AuthzRelationshipFilter, limit int) ([]AuthzRelationship, error)
- func (m *MemoryStore) ListFindingMetasByScan(ctx context.Context, scanID string) ([]FindingMeta, error)
- func (m *MemoryStore) ListFindingTrendCounts(ctx context.Context, scanIDs []string, severity string, findingType string) ([]FindingTrendCount, error)
- func (m *MemoryStore) ListFindingTriageEvents(ctx context.Context, findingID string, limit int) ([]FindingTriageEvent, error)
- func (m *MemoryStore) ListFindingTriageStates(ctx context.Context, findingIDs []string) ([]FindingTriageState, error)
- func (m *MemoryStore) ListFindings(ctx context.Context, limit int) ([]domain.Finding, error)
- func (m *MemoryStore) ListFindingsAll(ctx context.Context) ([]domain.Finding, error)
- func (m *MemoryStore) ListFindingsByScan(ctx context.Context, scanID string, limit int) ([]domain.Finding, error)
- func (m *MemoryStore) ListFindingsByScanAndIDs(ctx context.Context, scanID string, findingIDs []string) ([]domain.Finding, error)
- func (m *MemoryStore) ListFindingsFiltered(ctx context.Context, filter FindingListFilter) ([]domain.Finding, error)
- func (m *MemoryStore) ListIdentities(ctx context.Context, filter IdentityFilter, limit int) ([]domain.Identity, error)
- func (m *MemoryStore) ListIdentityConnections(ctx context.Context, orgID string, limit int) ([]IdentityConnection, error)
- func (m *MemoryStore) ListInvitations(ctx context.Context, orgID string, limit int) ([]Invitation, error)
- func (m *MemoryStore) ListProjects(ctx context.Context, workspaceID string, includeArchived bool, limit int) ([]TenancyProject, error)
- func (m *MemoryStore) ListRelationships(ctx context.Context, filter RelationshipFilter, limit int) ([]domain.Relationship, error)
- func (m *MemoryStore) ListRepoFindingClusters(ctx context.Context, filter RepoFindingClusterListFilter) ([]domain.RepoFindingCluster, error)
- func (m *MemoryStore) ListRepoFindingTrendCounts(ctx context.Context, repoScanIDs []string, severity string, findingType string) ([]FindingTrendCount, error)
- func (m *MemoryStore) ListRepoFindings(ctx context.Context, filter RepoFindingFilter, limit int) ([]domain.Finding, error)
- func (m *MemoryStore) ListRepoScans(ctx context.Context, limit int) ([]RepoScanRecord, error)
- func (m *MemoryStore) ListSCIMProvisioningEvents(ctx context.Context, orgID string, connectionID string, limit int) ([]SCIMProvisioningEventRecord, error)
- func (m *MemoryStore) ListScanEvents(ctx context.Context, scanID string, limit int) ([]ScanEvent, error)
- func (m *MemoryStore) ListScans(ctx context.Context, limit int) ([]ScanRecord, error)
- func (m *MemoryStore) ListScheduledTenancyScanPolicies(ctx context.Context, limit int, offset int) ([]TenancyScanPolicy, error)
- func (m *MemoryStore) ListTenancyConnectors(ctx context.Context, workspaceID string, projectID string, ...) ([]TenancyConnectorWithState, error)
- func (m *MemoryStore) ListTenancyConnectorsUnscoped(_ context.Context, connectorType domain.ConnectorType, limit int) ([]TenancyConnectorWithState, error)
- func (m *MemoryStore) ListTenancyScanPolicies(ctx context.Context, workspaceID string, projectID string, ...) ([]TenancyScanPolicy, error)
- func (m *MemoryStore) ListUserIdentitiesByProvider(ctx context.Context, provider string, limit int) ([]UserIdentity, error)
- func (m *MemoryStore) ListUserSessions(ctx context.Context, userID string, now time.Time, limit int) ([]Session, error)
- func (m *MemoryStore) ListVerifiedDomains(ctx context.Context, orgID string, limit int) ([]VerifiedDomain, error)
- func (m *MemoryStore) ListWorkspaceMembers(ctx context.Context, workspaceID string, limit int) ([]TenancyWorkspaceMember, error)
- func (m *MemoryStore) ListWorkspaceMembershipsByUserUUIDAndTenantID(ctx context.Context, userUUID string, tenantID string) ([]TenancyWorkspaceMember, error)
- func (m *MemoryStore) ListWorkspaces(ctx context.Context, limit int) ([]TenancyWorkspace, error)
- func (m *MemoryStore) RequeueRepoScan(ctx context.Context, repoScanID string) error
- func (m *MemoryStore) RevokeAllUserSessions(ctx context.Context, userID string, revokedAt time.Time) (int, error)
- func (m *MemoryStore) RevokeInvitation(ctx context.Context, orgID string, invitationID string, revokedAt time.Time) (Invitation, error)
- func (m *MemoryStore) RevokeOtherUserSessions(ctx context.Context, userID string, currentSessionIDHash []byte, ...) (int, error)
- func (m *MemoryStore) RevokeUserSession(ctx context.Context, userID string, sessionIDHash []byte, revokedAt time.Time) (Session, error)
- func (m *MemoryStore) ScheduleScanRetry(ctx context.Context, scanID string, queuedAt time.Time, retryCount int, ...) error
- func (m *MemoryStore) SummarizeFindings(ctx context.Context) (FindingSummaryCounts, error)
- func (m *MemoryStore) TouchSession(ctx context.Context, sessionIDHash []byte, now time.Time) (Session, error)
- func (m *MemoryStore) UpdateIdentityConnection(ctx context.Context, connection IdentityConnection) (IdentityConnection, error)
- func (m *MemoryStore) UpdateSessionContext(ctx context.Context, userID string, sessionIDHash []byte, orgID string, ...) (Session, error)
- func (m *MemoryStore) UpsertArtifacts(ctx context.Context, scanID string, artifacts ScanArtifacts) error
- func (m *MemoryStore) UpsertAuthzEntityAttributes(ctx context.Context, attributes AuthzEntityAttributes) error
- func (m *MemoryStore) UpsertAuthzPolicyRollout(ctx context.Context, rollout AuthzPolicyRollout) error
- func (m *MemoryStore) UpsertAuthzPolicySet(ctx context.Context, policySet AuthzPolicySet) error
- func (m *MemoryStore) UpsertAuthzRelationship(ctx context.Context, relationship AuthzRelationship) error
- func (m *MemoryStore) UpsertFindingTriageState(ctx context.Context, state FindingTriageState) error
- func (m *MemoryStore) UpsertFindings(ctx context.Context, scanID string, findings []domain.Finding) error
- func (m *MemoryStore) UpsertOnboardingState(ctx context.Context, state OnboardingState) (OnboardingState, error)
- func (m *MemoryStore) UpsertOrganization(ctx context.Context, organization TenancyOrganization) error
- func (m *MemoryStore) UpsertProject(ctx context.Context, project TenancyProject) error
- func (m *MemoryStore) UpsertRepoFindings(ctx context.Context, repoScanID string, findings []domain.Finding) error
- func (m *MemoryStore) UpsertRepoScanCursor(ctx context.Context, cursor RepoScanCursor) error
- func (m *MemoryStore) UpsertTenancyConnector(ctx context.Context, connector TenancyConnector, state TenancyConnectorState) error
- func (m *MemoryStore) UpsertTenancyConnectorSecretEnvelope(ctx context.Context, envelope TenancyConnectorSecretEnvelope) error
- func (m *MemoryStore) UpsertTenancyScanPolicy(ctx context.Context, policy TenancyScanPolicy) error
- func (m *MemoryStore) UpsertUser(ctx context.Context, user User) (User, error)
- func (m *MemoryStore) UpsertUserIdentity(ctx context.Context, identity UserIdentity) (UserIdentity, error)
- func (m *MemoryStore) UpsertWorkspace(ctx context.Context, workspace TenancyWorkspace) error
- func (m *MemoryStore) UpsertWorkspaceMember(ctx context.Context, member TenancyWorkspaceMember) error
- type OAuthTransaction
- type OnboardingState
- type PostgresStore
- func (p *PostgresStore) AppendAuthzPolicyEvent(ctx context.Context, event AuthzPolicyEvent) error
- func (p *PostgresStore) AppendFindingTriageEvent(ctx context.Context, event FindingTriageEvent) error
- func (p *PostgresStore) AppendScanEvent(ctx context.Context, scanID string, level string, message string, ...) error
- func (p *PostgresStore) ApplyDownMigrations(ctx context.Context, dir string) error
- func (p *PostgresStore) ApplyFindingTriageTransition(ctx context.Context, state FindingTriageState, event FindingTriageEvent) error
- func (p *PostgresStore) ApplyMigrations(ctx context.Context, dir string) error
- func (p *PostgresStore) BeginWebhookEvent(ctx context.Context, event WebhookEvent, now time.Time) (WebhookEventStatus, string, error)
- func (p *PostgresStore) CancelRepoScan(ctx context.Context, repoScanID string, finishedAt time.Time, ...) (RepoScanRecord, error)
- func (p *PostgresStore) ClaimKubernetesEnrollmentToken(ctx context.Context, workspaceID string, projectID string, connectorID string, ...) (bool, error)
- func (p *PostgresStore) ClaimNextQueuedRepoScan(ctx context.Context) (RepoScanRecord, error)
- func (p *PostgresStore) ClaimNextQueuedRepoScanAnyScope(ctx context.Context) (RepoScanRecord, error)
- func (p *PostgresStore) ClaimNextQueuedScan(ctx context.Context, provider string) (ScanRecord, error)
- func (p *PostgresStore) ClaimNextQueuedScanAnyScope(ctx context.Context, provider string) (ScanRecord, error)
- func (p *PostgresStore) ClaimTenancyScanPolicySchedule(ctx context.Context, workspaceID string, projectID string, policyID string, ...) (bool, error)
- func (p *PostgresStore) Close() error
- func (p *PostgresStore) CompleteRepoScan(ctx context.Context, repoScanID string, status string, finishedAt time.Time, ...) error
- func (p *PostgresStore) CompleteScan(ctx context.Context, scanID string, status string, finishedAt time.Time, ...) error
- func (p *PostgresStore) CompleteWebhookEvent(ctx context.Context, provider string, eventID string, claimToken string, ...) error
- func (p *PostgresStore) ConsumeOAuthTransaction(ctx context.Context, nonce string, cookieToken string, now time.Time) (OAuthTransaction, error)
- func (p *PostgresStore) ConsumeSAMLRelayState(ctx context.Context, handle string, now time.Time) (SAMLRelayState, error)
- func (p *PostgresStore) CountPendingRepoScansByRepository(ctx context.Context, repository string) (int, error)
- func (p *PostgresStore) CountQueuedRepoScans(ctx context.Context) (int, error)
- func (p *PostgresStore) CountQueuedRepoScansAnyScope(ctx context.Context) (int, error)
- func (p *PostgresStore) CountQueuedScans(ctx context.Context, provider string) (int, error)
- func (p *PostgresStore) CountQueuedScansAnyScope(ctx context.Context, provider string) (int, error)
- func (p *PostgresStore) CreateAuthzPolicyVersion(ctx context.Context, version AuthzPolicyVersion) (AuthzPolicyVersion, error)
- func (p *PostgresStore) CreateIdentityConnection(ctx context.Context, connection IdentityConnection) (IdentityConnection, error)
- func (p *PostgresStore) CreateInvitation(ctx context.Context, invitation Invitation) (Invitation, error)
- func (p *PostgresStore) CreateOAuthTransaction(ctx context.Context, txn OAuthTransaction) (OAuthTransaction, error)
- func (p *PostgresStore) CreateQueuedRepoScan(ctx context.Context, repository string, source RepoScanSource, ...) (RepoScanRecord, error)
- func (p *PostgresStore) CreateQueuedRepoScanWithinLimit(ctx context.Context, repository string, source RepoScanSource, ...) (RepoScanRecord, error)
- func (p *PostgresStore) CreateQueuedScan(ctx context.Context, provider string, queuedAt time.Time) (ScanRecord, error)
- func (p *PostgresStore) CreateQueuedScanIfNoPending(ctx context.Context, provider string, queuedAt time.Time) (ScanRecord, error)
- func (p *PostgresStore) CreateQueuedScanWithinLimit(ctx context.Context, provider string, queuedAt time.Time, maxPending int) (ScanRecord, error)
- func (p *PostgresStore) CreateRepoScan(ctx context.Context, repository string, source RepoScanSource, ...) (RepoScanRecord, error)
- func (p *PostgresStore) CreateSAMLRelayState(ctx context.Context, state SAMLRelayState) (SAMLRelayState, error)
- func (p *PostgresStore) CreateSCIMProvisioningEvent(ctx context.Context, event SCIMProvisioningEventRecord) (SCIMProvisioningEventRecord, error)
- func (p *PostgresStore) CreateScan(ctx context.Context, provider string, startedAt time.Time) (ScanRecord, error)
- func (p *PostgresStore) CreateSession(ctx context.Context, session Session) (Session, error)
- func (p *PostgresStore) CreateVerifiedDomain(ctx context.Context, domain VerifiedDomain) (VerifiedDomain, error)
- func (p *PostgresStore) DB() *sql.DB
- func (p *PostgresStore) DeadLetterScan(ctx context.Context, scanID string, finishedAt time.Time, retryCount int, ...) error
- func (p *PostgresStore) DeleteAuthzRelationship(ctx context.Context, relationship AuthzRelationship) error
- func (p *PostgresStore) DeleteIdentityConnection(ctx context.Context, orgID, connectionID string) error
- func (p *PostgresStore) DeleteOrganization(ctx context.Context) error
- func (p *PostgresStore) DeleteProject(ctx context.Context, workspaceID string, projectID string) error
- func (p *PostgresStore) DeleteRepoFindings(ctx context.Context, repoScanID string) error
- func (p *PostgresStore) DeleteTenancyConnectorSecretEnvelope(ctx context.Context, workspaceID string, projectID string, connectorID string, ...) error
- func (p *PostgresStore) DeleteTenancyScanPolicy(ctx context.Context, workspaceID string, projectID string, policyID string) error
- func (p *PostgresStore) DeleteUserIdentity(ctx context.Context, provider string, subject string) error
- func (p *PostgresStore) DeleteWebhookEvent(ctx context.Context, provider string, eventID string, claimToken string) error
- func (p *PostgresStore) DeleteWorkspace(ctx context.Context, workspaceID string) error
- func (p *PostgresStore) DeleteWorkspaceMember(ctx context.Context, workspaceID string, memberID string) error
- func (p *PostgresStore) FailStaleRepoScansAnyScope(ctx context.Context, staleBefore time.Time, limit int, errorMessage string) (int, error)
- func (p *PostgresStore) FindFirstWorkspaceMemberByUserUUID(ctx context.Context, userUUID string) (TenancyWorkspaceMember, error)
- func (p *PostgresStore) FindFirstWorkspaceMemberByUserUUIDAndTenantID(ctx context.Context, userUUID string, tenantID string) (TenancyWorkspaceMember, error)
- func (p *PostgresStore) GetAuthzEntityAttributes(ctx context.Context, entityKind string, entityType string, entityID string) (AuthzEntityAttributes, error)
- func (p *PostgresStore) GetAuthzPolicyRollout(ctx context.Context, policySetID string) (AuthzPolicyRollout, error)
- func (p *PostgresStore) GetAuthzPolicySet(ctx context.Context, policySetID string) (AuthzPolicySet, error)
- func (p *PostgresStore) GetAuthzPolicyVersion(ctx context.Context, policySetID string, version int) (AuthzPolicyVersion, error)
- func (p *PostgresStore) GetFinding(ctx context.Context, findingID string, scanID string) (domain.Finding, error)
- func (p *PostgresStore) GetFindingTriageState(ctx context.Context, findingID string) (FindingTriageState, error)
- func (p *PostgresStore) GetIdentityConnection(ctx context.Context, orgID string, connectionID string) (IdentityConnection, error)
- func (p *PostgresStore) GetIdentityConnectionByID(ctx context.Context, connectionID string) (IdentityConnection, error)
- func (p *PostgresStore) GetIdentityConnectionBySCIMBearerTokenHash(ctx context.Context, tokenHash string) (IdentityConnection, error)
- func (p *PostgresStore) GetInvitation(ctx context.Context, orgID string, invitationID string) (Invitation, error)
- func (p *PostgresStore) GetOnboardingState(ctx context.Context, userID string) (OnboardingState, error)
- func (p *PostgresStore) GetOrganization(ctx context.Context) (TenancyOrganization, error)
- func (p *PostgresStore) GetProject(ctx context.Context, workspaceID string, projectID string) (TenancyProject, error)
- func (p *PostgresStore) GetRepoScan(ctx context.Context, repoScanID string) (RepoScanRecord, error)
- func (p *PostgresStore) GetRepoScanCursor(ctx context.Context, repository string, source RepoScanSource) (RepoScanCursor, error)
- func (p *PostgresStore) GetScan(ctx context.Context, scanID string) (ScanRecord, error)
- func (p *PostgresStore) GetTenancyConnector(ctx context.Context, workspaceID string, projectID string, connectorID string) (TenancyConnectorWithState, error)
- func (p *PostgresStore) GetTenancyConnectorSecretEnvelope(ctx context.Context, workspaceID string, projectID string, connectorID string, ...) (TenancyConnectorSecretEnvelope, error)
- func (p *PostgresStore) GetTenancyScanPolicy(ctx context.Context, workspaceID string, projectID string, policyID string) (TenancyScanPolicy, error)
- func (p *PostgresStore) GetUser(ctx context.Context, userID string) (User, error)
- func (p *PostgresStore) GetUserByPrimaryEmail(ctx context.Context, email string) (User, error)
- func (p *PostgresStore) GetUserIdentity(ctx context.Context, provider string, subject string) (UserIdentity, error)
- func (p *PostgresStore) GetUserIdentityByProviderUserID(ctx context.Context, provider string, userID string) (UserIdentity, error)
- func (p *PostgresStore) GetVerifiedDomain(ctx context.Context, orgID string, domainID string) (VerifiedDomain, error)
- func (p *PostgresStore) GetWorkspace(ctx context.Context, workspaceID string) (TenancyWorkspace, error)
- func (p *PostgresStore) GetWorkspaceMember(ctx context.Context, workspaceID string, memberID string) (TenancyWorkspaceMember, error)
- func (p *PostgresStore) GetWorkspaceMemberByUserUUID(ctx context.Context, workspaceID string, userUUID string) (TenancyWorkspaceMember, error)
- func (p *PostgresStore) ListAllTenancyConnectorsByType(ctx context.Context, connectorType domain.ConnectorType, limit int) ([]TenancyConnectorWithState, error)
- func (p *PostgresStore) ListAuthzPolicyEvents(ctx context.Context, policySetID string, limit int) ([]AuthzPolicyEvent, error)
- func (p *PostgresStore) ListAuthzPolicyVersions(ctx context.Context, policySetID string, limit int) ([]AuthzPolicyVersion, error)
- func (p *PostgresStore) ListAuthzRelationships(ctx context.Context, filter AuthzRelationshipFilter, limit int) ([]AuthzRelationship, error)
- func (p *PostgresStore) ListFindingMetasByScan(ctx context.Context, scanID string) ([]FindingMeta, error)
- func (p *PostgresStore) ListFindingTrendCounts(ctx context.Context, scanIDs []string, severity string, findingType string) ([]FindingTrendCount, error)
- func (p *PostgresStore) ListFindingTriageEvents(ctx context.Context, findingID string, limit int) ([]FindingTriageEvent, error)
- func (p *PostgresStore) ListFindingTriageStates(ctx context.Context, findingIDs []string) ([]FindingTriageState, error)
- func (p *PostgresStore) ListFindings(ctx context.Context, limit int) ([]domain.Finding, error)
- func (p *PostgresStore) ListFindingsAll(ctx context.Context) ([]domain.Finding, error)
- func (p *PostgresStore) ListFindingsByScan(ctx context.Context, scanID string, limit int) ([]domain.Finding, error)
- func (p *PostgresStore) ListFindingsByScanAndIDs(ctx context.Context, scanID string, findingIDs []string) ([]domain.Finding, error)
- func (p *PostgresStore) ListFindingsFiltered(ctx context.Context, filter FindingListFilter) ([]domain.Finding, error)
- func (p *PostgresStore) ListIdentities(ctx context.Context, filter IdentityFilter, limit int) ([]domain.Identity, error)
- func (p *PostgresStore) ListIdentityConnections(ctx context.Context, orgID string, limit int) ([]IdentityConnection, error)
- func (p *PostgresStore) ListInvitations(ctx context.Context, orgID string, limit int) ([]Invitation, error)
- func (p *PostgresStore) ListProjects(ctx context.Context, workspaceID string, includeArchived bool, limit int) ([]TenancyProject, error)
- func (p *PostgresStore) ListRelationships(ctx context.Context, filter RelationshipFilter, limit int) ([]domain.Relationship, error)
- func (p *PostgresStore) ListRepoFindingClusters(ctx context.Context, filter RepoFindingClusterListFilter) ([]domain.RepoFindingCluster, error)
- func (p *PostgresStore) ListRepoFindingTrendCounts(ctx context.Context, repoScanIDs []string, severity string, findingType string) ([]FindingTrendCount, error)
- func (p *PostgresStore) ListRepoFindings(ctx context.Context, filter RepoFindingFilter, limit int) ([]domain.Finding, error)
- func (p *PostgresStore) ListRepoScans(ctx context.Context, limit int) ([]RepoScanRecord, error)
- func (p *PostgresStore) ListSCIMProvisioningEvents(ctx context.Context, orgID string, connectionID string, limit int) ([]SCIMProvisioningEventRecord, error)
- func (p *PostgresStore) ListScanEvents(ctx context.Context, scanID string, limit int) ([]ScanEvent, error)
- func (p *PostgresStore) ListScans(ctx context.Context, limit int) ([]ScanRecord, error)
- func (p *PostgresStore) ListScheduledTenancyScanPolicies(ctx context.Context, limit int, offset int) ([]TenancyScanPolicy, error)
- func (p *PostgresStore) ListTenancyConnectors(ctx context.Context, workspaceID string, projectID string, ...) ([]TenancyConnectorWithState, error)
- func (p *PostgresStore) ListTenancyConnectorsUnscoped(ctx context.Context, connectorType domain.ConnectorType, limit int) ([]TenancyConnectorWithState, error)
- func (p *PostgresStore) ListTenancyScanPolicies(ctx context.Context, workspaceID string, projectID string, ...) ([]TenancyScanPolicy, error)
- func (p *PostgresStore) ListUserIdentitiesByProvider(ctx context.Context, provider string, limit int) ([]UserIdentity, error)
- func (p *PostgresStore) ListUserSessions(ctx context.Context, userID string, now time.Time, limit int) ([]Session, error)
- func (p *PostgresStore) ListVerifiedDomains(ctx context.Context, orgID string, limit int) ([]VerifiedDomain, error)
- func (p *PostgresStore) ListWorkspaceMembers(ctx context.Context, workspaceID string, limit int) ([]TenancyWorkspaceMember, error)
- func (p *PostgresStore) ListWorkspaceMembershipsByUserUUIDAndTenantID(ctx context.Context, userUUID string, tenantID string) ([]TenancyWorkspaceMember, error)
- func (p *PostgresStore) ListWorkspaces(ctx context.Context, limit int) ([]TenancyWorkspace, error)
- func (p *PostgresStore) RequeueRepoScan(ctx context.Context, repoScanID string) error
- func (p *PostgresStore) RevokeAllUserSessions(ctx context.Context, userID string, revokedAt time.Time) (int, error)
- func (p *PostgresStore) RevokeInvitation(ctx context.Context, orgID string, invitationID string, revokedAt time.Time) (Invitation, error)
- func (p *PostgresStore) RevokeOtherUserSessions(ctx context.Context, userID string, currentSessionIDHash []byte, ...) (int, error)
- func (p *PostgresStore) RevokeUserSession(ctx context.Context, userID string, sessionIDHash []byte, revokedAt time.Time) (Session, error)
- func (p *PostgresStore) ScheduleScanRetry(ctx context.Context, scanID string, queuedAt time.Time, retryCount int, ...) error
- func (p *PostgresStore) ScopeRLSEnforcementEnabled() bool
- func (p *PostgresStore) SetScopeRLSEnforcement(enabled bool)
- func (p *PostgresStore) SummarizeFindings(ctx context.Context) (FindingSummaryCounts, error)
- func (p *PostgresStore) TouchSession(ctx context.Context, sessionIDHash []byte, now time.Time) (Session, error)
- func (p *PostgresStore) UpdateIdentityConnection(ctx context.Context, connection IdentityConnection) (IdentityConnection, error)
- func (p *PostgresStore) UpdateSessionContext(ctx context.Context, userID string, sessionIDHash []byte, orgID string, ...) (Session, error)
- func (p *PostgresStore) UpsertArtifacts(ctx context.Context, scanID string, artifacts ScanArtifacts) error
- func (p *PostgresStore) UpsertAuthzEntityAttributes(ctx context.Context, attributes AuthzEntityAttributes) error
- func (p *PostgresStore) UpsertAuthzPolicyRollout(ctx context.Context, rollout AuthzPolicyRollout) error
- func (p *PostgresStore) UpsertAuthzPolicySet(ctx context.Context, policySet AuthzPolicySet) error
- func (p *PostgresStore) UpsertAuthzRelationship(ctx context.Context, relationship AuthzRelationship) error
- func (p *PostgresStore) UpsertFindingTriageState(ctx context.Context, state FindingTriageState) error
- func (p *PostgresStore) UpsertFindings(ctx context.Context, scanID string, findings []domain.Finding) error
- func (p *PostgresStore) UpsertOnboardingState(ctx context.Context, state OnboardingState) (OnboardingState, error)
- func (p *PostgresStore) UpsertOrganization(ctx context.Context, organization TenancyOrganization) error
- func (p *PostgresStore) UpsertProject(ctx context.Context, project TenancyProject) error
- func (p *PostgresStore) UpsertRepoFindings(ctx context.Context, repoScanID string, findings []domain.Finding) error
- func (p *PostgresStore) UpsertRepoScanCursor(ctx context.Context, cursor RepoScanCursor) error
- func (p *PostgresStore) UpsertTenancyConnector(ctx context.Context, connector TenancyConnector, state TenancyConnectorState) error
- func (p *PostgresStore) UpsertTenancyConnectorSecretEnvelope(ctx context.Context, envelope TenancyConnectorSecretEnvelope) error
- func (p *PostgresStore) UpsertTenancyScanPolicy(ctx context.Context, policy TenancyScanPolicy) error
- func (p *PostgresStore) UpsertUser(ctx context.Context, user User) (User, error)
- func (p *PostgresStore) UpsertUserIdentity(ctx context.Context, identity UserIdentity) (UserIdentity, error)
- func (p *PostgresStore) UpsertWorkspace(ctx context.Context, workspace TenancyWorkspace) error
- func (p *PostgresStore) UpsertWorkspaceMember(ctx context.Context, member TenancyWorkspaceMember) error
- type RelationshipFilter
- type RepoFindingClusterListFilter
- type RepoFindingFilter
- type RepoScanContext
- type RepoScanCursor
- type RepoScanRecord
- type RepoScanSource
- type SAMLRelayState
- type SCIMProvisioningEventRecord
- type ScanArtifacts
- type ScanEvent
- type ScanRecord
- type Scope
- type Session
- type Store
- type TenancyConnector
- type TenancyConnectorSecretEnvelope
- type TenancyConnectorState
- type TenancyConnectorWithState
- type TenancyOrganization
- type TenancyProject
- type TenancyScanPolicy
- type TenancyWorkspace
- type TenancyWorkspaceMember
- type User
- type UserIdentity
- type VerifiedDomain
- type WebhookEvent
- type WebhookEventStatus
Constants ¶
const ( // DefaultTenantID applies when no tenant is explicitly provided in context. DefaultTenantID = "default" // DefaultWorkspaceID applies when no workspace is explicitly provided in context. DefaultWorkspaceID = "default" )
const ( ScanEventLevelDebug = "debug" ScanEventLevelInfo = "info" ScanEventLevelWarn = "warn" ScanEventLevelError = "error" RepoScanModeDeep = "deep" RepoScanModeDelta = "delta" RepoScanModeQuick = "quick" FindingTriageActionAcknowledged = "acknowledged" FindingTriageActionSuppressed = "suppressed" FindingTriageActionResolved = "resolved" FindingTriageActionReopened = "reopened" FindingTriageActionAssigned = "assignee_updated" FindingTriageActionSuppression = "suppression_updated" FindingTriageActionCommented = "commented" AuthzEntityKindSubject = "subject" AuthzEntityKindResource = "resource" AuthzAttributeEnvProd = "prod" AuthzAttributeEnvStaging = "staging" AuthzAttributeEnvDev = "dev" AuthzAttributeEnvTest = "test" AuthzAttributeEnvSandbox = "sandbox" AuthzAttributeRiskTierLow = "low" AuthzAttributeRiskTierMedium = "medium" AuthzAttributeRiskTierHigh = "high" AuthzAttributeRiskTierCritical = "critical" AuthzAttributeClassificationPublic = "public" AuthzAttributeClassificationInternal = "internal" AuthzAttributeClassificationConfidential = "confidential" AuthzAttributeClassificationRestricted = "restricted" AuthzRelationshipOwns = "owns" AuthzRelationshipManages = "manages" AuthzRelationshipDelegatedAdmin = "delegated_admin" AuthzRelationshipMemberOf = "member_of" AuthzPolicyRolloutModeDisabled = "disabled" AuthzPolicyRolloutModeShadow = "shadow" AuthzPolicyRolloutModeEnforce = "enforce" )
const DefaultScanMaxRetryCount = 3
const WebhookEventRetention = 30 * 24 * time.Hour
WebhookEventRetention bounds how long a webhook idempotency row is kept. It must comfortably exceed any provider's retry/replay window (WorkOS retries over days) while keeping the ledger from growing unbounded; rows older than this are opportunistically pruned on the claim path.
const WebhookProcessingReclaimAfter = 5 * time.Minute
WebhookProcessingReclaimAfter bounds how long a "processing" row may sit before another delivery may reclaim it. It protects against an instance that crashed mid-processing wedging an event forever; it is far longer than the webhook handler's own processing time.
Variables ¶
var ErrConflict = errors.New("record conflict")
ErrConflict indicates the requested write conflicts with an existing record.
var ErrNotFound = errors.New("record not found")
ErrNotFound indicates the requested record does not exist.
var ErrPendingRepoScanExists = errors.New("pending repo scan exists")
ErrPendingRepoScanExists indicates the target repository already has a queued or running scan.
var ErrPendingScanExists = errors.New("pending scan already exists")
ErrPendingScanExists indicates one queued or running scan already exists for the provider scope.
var ErrQueueLimitReached = errors.New("queue limit reached")
ErrQueueLimitReached indicates a bounded queue has no remaining capacity.
var ErrScopeRequired = errors.New("scope is required")
ErrScopeRequired indicates tenant/workspace scope must be provided in context.
Functions ¶
func ApplyDownMigrations ¶
ApplyDownMigrations applies down migration scripts in rollback order.
func ApplyMigrations ¶
ApplyMigrations applies migration scripts from directory against db.
func MatchScope ¶
MatchScope returns true when record scope matches the active scope.
func NormalizeFindingTriage ¶
func NormalizeFindingTriage(triage domain.FindingTriage, now time.Time) domain.FindingTriage
NormalizeFindingTriage returns a stable, API-shaped finding triage state.
func NormalizeScanEventLevel ¶
NormalizeScanEventLevel validates and normalizes event levels.
func QueueTraceContextFromContext ¶
QueueTraceContextFromContext returns queue trace propagation headers from context.
func ResolveScopedWorkspaceID ¶
ResolveScopedWorkspaceID normalizes one workspace identifier and enforces that it remains within the active request scope.
func WithDefaultScope ¶
WithDefaultScope applies fallback scope only when context has no scope.
Types ¶
type AuthzEntityAttributes ¶
type AuthzEntityAttributes struct {
TenantID string `json:"-"`
WorkspaceID string `json:"-"`
EntityKind string `json:"entity_kind"`
EntityType string `json:"entity_type"`
EntityID string `json:"entity_id"`
OwnerTeam string `json:"owner_team,omitempty"`
Environment string `json:"env,omitempty"`
RiskTier string `json:"risk_tier,omitempty"`
Classification string `json:"classification,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
}
AuthzEntityAttributes stores trusted policy attributes for one subject or resource.
func NormalizeAuthzEntityAttributesForWrite ¶
func NormalizeAuthzEntityAttributesForWrite(attrs AuthzEntityAttributes) (AuthzEntityAttributes, error)
NormalizeAuthzEntityAttributesForWrite validates and canonicalizes trusted authz attributes.
type AuthzPolicyEvent ¶
type AuthzPolicyEvent struct {
ID string `json:"id"`
TenantID string `json:"-"`
WorkspaceID string `json:"-"`
PolicySetID string `json:"policy_set_id"`
EventType string `json:"event_type"`
FromVersion *int `json:"from_version,omitempty"`
ToVersion *int `json:"to_version,omitempty"`
Actor string `json:"actor,omitempty"`
Message string `json:"message,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
AuthzPolicyEvent records one immutable policy lifecycle action.
func NormalizeAuthzPolicyEventForWrite ¶
func NormalizeAuthzPolicyEventForWrite(event AuthzPolicyEvent) (AuthzPolicyEvent, error)
NormalizeAuthzPolicyEventForWrite validates and canonicalizes one immutable policy event.
type AuthzPolicyRollout ¶
type AuthzPolicyRollout struct {
TenantID string `json:"-"`
WorkspaceID string `json:"-"`
PolicySetID string `json:"policy_set_id"`
ActiveVersion *int `json:"active_version,omitempty"`
CandidateVersion *int `json:"candidate_version,omitempty"`
Mode string `json:"mode"`
TenantAllowlist []string `json:"tenant_allowlist,omitempty"`
WorkspaceAllowlist []string `json:"workspace_allowlist,omitempty"`
CanaryPercentage int `json:"canary_percentage"`
ValidatedVersions []int `json:"validated_versions,omitempty"`
UpdatedBy string `json:"updated_by,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
}
AuthzPolicyRollout stores one scoped rollout pointer for active/candidate versions.
func NormalizeAuthzPolicyRolloutForWrite ¶
func NormalizeAuthzPolicyRolloutForWrite(rollout AuthzPolicyRollout) (AuthzPolicyRollout, error)
NormalizeAuthzPolicyRolloutForWrite validates and canonicalizes one rollout pointer row.
type AuthzPolicySet ¶
type AuthzPolicySet struct {
TenantID string `json:"-"`
WorkspaceID string `json:"-"`
PolicySetID string `json:"policy_set_id"`
DisplayName string `json:"display_name"`
Description string `json:"description,omitempty"`
CreatedBy string `json:"created_by,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
AuthzPolicySet stores one scoped policy namespace and metadata.
func NormalizeAuthzPolicySetForWrite ¶
func NormalizeAuthzPolicySetForWrite(policySet AuthzPolicySet) (AuthzPolicySet, error)
NormalizeAuthzPolicySetForWrite validates and canonicalizes one policy-set metadata row.
type AuthzPolicyVersion ¶
type AuthzPolicyVersion struct {
TenantID string `json:"-"`
WorkspaceID string `json:"-"`
PolicySetID string `json:"policy_set_id"`
Version int `json:"version"`
Bundle string `json:"bundle"`
Checksum string `json:"checksum"`
CreatedBy string `json:"created_by,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
AuthzPolicyVersion stores one immutable compiled policy bundle.
func NormalizeAuthzPolicyVersionForWrite ¶
func NormalizeAuthzPolicyVersionForWrite(version AuthzPolicyVersion) (AuthzPolicyVersion, error)
NormalizeAuthzPolicyVersionForWrite validates and canonicalizes one immutable policy bundle version.
type AuthzRelationship ¶
type AuthzRelationship struct {
TenantID string `json:"-"`
WorkspaceID string `json:"-"`
SubjectType string `json:"subject_type"`
SubjectID string `json:"subject_id"`
Relation string `json:"relation"`
ObjectType string `json:"object_type"`
ObjectID string `json:"object_id"`
Source string `json:"source,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
AuthzRelationship stores one directional relation tuple used by ReBAC checks.
func NormalizeAuthzRelationshipForWrite ¶
func NormalizeAuthzRelationshipForWrite(relationship AuthzRelationship) (AuthzRelationship, error)
NormalizeAuthzRelationshipForWrite validates and canonicalizes relationship tuples.
type AuthzRelationshipFilter ¶
type AuthzRelationshipFilter struct {
SubjectType string
SubjectID string
Relation string
ObjectType string
ObjectID string
IncludeExpired bool
}
AuthzRelationshipFilter controls scoped ReBAC tuple listing.
type FindingListFilter ¶
type FindingListFilter struct {
ScanID string
FindingID string
Severity string
Type string
LifecycleStatus string
Assignee string
SortBy string
SortDesc bool
Limit int
Offset int
Now time.Time
}
FindingListFilter controls filtered finding list queries.
func NormalizeFindingListFilter ¶
func NormalizeFindingListFilter(filter FindingListFilter) FindingListFilter
NormalizeFindingListFilter trims inputs and applies stable defaults.
type FindingMeta ¶
FindingMeta is the lightweight shape used for trend/diff set operations.
type FindingSummaryCounts ¶
FindingSummaryCounts captures aggregate finding counters for one scoped workspace.
type FindingTrendCount ¶
FindingTrendCount aggregates finding totals for one scan and severity bucket.
type FindingTriageEvent ¶
type FindingTriageEvent struct {
ID string `json:"id"`
FindingID string `json:"finding_id"`
Action string `json:"action"`
FromStatus domain.FindingLifecycleStatus `json:"from_status"`
ToStatus domain.FindingLifecycleStatus `json:"to_status"`
Assignee string `json:"assignee,omitempty"`
SuppressionExpiresAt *time.Time `json:"suppression_expires_at,omitempty"`
Comment string `json:"comment,omitempty"`
Actor string `json:"actor,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
FindingTriageEvent records one immutable workflow action.
type FindingTriageState ¶
type FindingTriageState struct {
FindingID string `json:"finding_id"`
Status domain.FindingLifecycleStatus `json:"status"`
Assignee string `json:"assignee,omitempty"`
SuppressionExpiresAt *time.Time `json:"suppression_expires_at,omitempty"`
// ResolvedAt is non-nil only while Status is resolved; it captures the
// resolution time so the executive report can compute accurate MTTR.
ResolvedAt *time.Time `json:"resolved_at,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
UpdatedBy string `json:"updated_by,omitempty"`
}
FindingTriageState stores mutable workflow metadata for one finding id.
type IdentityConnection ¶
type IdentityConnection struct {
ID string `json:"id"`
OrgID string `json:"org_id"`
Provider string `json:"provider"`
Type string `json:"type"`
WorkOSConnectionID string `json:"workos_connection_id,omitempty"`
Status string `json:"status"`
GroupRoleMap map[string]string `json:"group_role_map"`
SSORequired bool `json:"sso_required"`
JITProvisioningEnabled bool `json:"jit_provisioning_enabled"`
EntityID string `json:"entity_id,omitempty"`
SSOURL string `json:"sso_url,omitempty"`
CertificatePEM string `json:"certificate_pem,omitempty"`
AttributeMapping map[string]string `json:"attribute_mapping,omitempty"`
SCIMBearerTokenHash string `json:"scim_bearer_token_hash,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
IdentityConnection stores one enterprise SSO or directory-sync connection.
A row with Provider == "saml" must be either WorkOS-backed (the legacy path, WorkOSConnectionID populated and native fields zero) or native (EntityID, SSOURL, and CertificatePEM all populated; SSOURL must use https). The two modes are mutually exclusive at write time so callers cannot end up with a half-configured connection.
func NormalizeIdentityConnectionForWrite ¶
func NormalizeIdentityConnectionForWrite(connection IdentityConnection) (IdentityConnection, error)
NormalizeIdentityConnectionForWrite validates and canonicalizes one enterprise identity connection scaffold.
func (IdentityConnection) IsNativeSAML ¶
func (c IdentityConnection) IsNativeSAML() bool
IsNativeSAML reports whether this connection drives native SAML directly (as opposed to delegating to WorkOS). Only meaningful when Provider=="saml".
type IdentityFilter ¶
IdentityFilter controls identity list query shape.
type Invitation ¶
type Invitation struct {
ID string `json:"id"`
OrgID string `json:"org_id"`
Email string `json:"email"`
Role string `json:"role"`
InvitedByUserID string `json:"invited_by_user_id"`
TokenHash []byte `json:"-"`
ExpiresAt time.Time `json:"expires_at"`
AcceptedAt *time.Time `json:"accepted_at,omitempty"`
RevokedAt *time.Time `json:"revoked_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
Invitation stores one organization invitation scaffold for later invite flows.
func NormalizeInvitationForWrite ¶
func NormalizeInvitationForWrite(invitation Invitation) (Invitation, error)
NormalizeInvitationForWrite validates and canonicalizes one organization invite scaffold.
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is a concurrency-safe in-memory persistence adapter.
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
NewMemoryStore initializes an empty in-memory store.
func (*MemoryStore) AppendAuthzPolicyEvent ¶
func (m *MemoryStore) AppendAuthzPolicyEvent(ctx context.Context, event AuthzPolicyEvent) error
AppendAuthzPolicyEvent records one immutable policy lifecycle event.
func (*MemoryStore) AppendFindingTriageEvent ¶
func (m *MemoryStore) AppendFindingTriageEvent(ctx context.Context, event FindingTriageEvent) error
AppendFindingTriageEvent records one immutable triage action.
func (*MemoryStore) AppendScanEvent ¶
func (m *MemoryStore) AppendScanEvent(ctx context.Context, scanID string, level string, message string, metadata map[string]any) error
AppendScanEvent appends one scan event entry.
func (*MemoryStore) ApplyFindingTriageTransition ¶
func (m *MemoryStore) ApplyFindingTriageTransition(ctx context.Context, state FindingTriageState, event FindingTriageEvent) error
ApplyFindingTriageTransition persists state and audit history atomically.
func (*MemoryStore) BeginWebhookEvent ¶
func (m *MemoryStore) BeginWebhookEvent(ctx context.Context, event WebhookEvent, now time.Time) (WebhookEventStatus, string, error)
BeginWebhookEvent atomically claims a webhook event for processing. The mutex makes the read-decide-write sequence atomic, mirroring the Postgres INSERT ... ON CONFLICT path. A claim (insert or stale reclaim) mints a fresh claim token that fences the eventual Complete/Delete.
func (*MemoryStore) CancelRepoScan ¶
func (m *MemoryStore) CancelRepoScan(ctx context.Context, repoScanID string, finishedAt time.Time, errorMessage string) (RepoScanRecord, error)
CancelRepoScan marks a queued or running repository scan as terminal failed.
func (*MemoryStore) ClaimKubernetesEnrollmentToken ¶
func (m *MemoryStore) ClaimKubernetesEnrollmentToken(ctx context.Context, workspaceID string, projectID string, connectorID string, expectedEnrollmentTokenHash string, updatedMetadata map[string]any, status domain.ConnectorStatus, health string, lastErrorCode string, lastErrorMessage string, observedAt time.Time, updatedAt time.Time) (bool, error)
ClaimKubernetesEnrollmentToken marks a single connector enrollment token as consumed.
func (*MemoryStore) ClaimNextQueuedRepoScan ¶
func (m *MemoryStore) ClaimNextQueuedRepoScan(ctx context.Context) (RepoScanRecord, error)
ClaimNextQueuedRepoScan moves one queued repository scan to running for execution.
func (*MemoryStore) ClaimNextQueuedRepoScanAnyScope ¶
func (m *MemoryStore) ClaimNextQueuedRepoScanAnyScope(_ context.Context) (RepoScanRecord, error)
ClaimNextQueuedRepoScanAnyScope moves one queued repository scan to running across all tenant/workspace scopes.
func (*MemoryStore) ClaimNextQueuedScan ¶
func (m *MemoryStore) ClaimNextQueuedScan(ctx context.Context, provider string) (ScanRecord, error)
ClaimNextQueuedScan moves one queued scan to running for execution.
func (*MemoryStore) ClaimNextQueuedScanAnyScope ¶
func (m *MemoryStore) ClaimNextQueuedScanAnyScope(_ context.Context, provider string) (ScanRecord, error)
ClaimNextQueuedScanAnyScope moves one queued scan to running across all tenant/workspace scopes.
func (*MemoryStore) ClaimTenancyScanPolicySchedule ¶
func (m *MemoryStore) ClaimTenancyScanPolicySchedule(ctx context.Context, workspaceID string, projectID string, policyID string, scheduledAt time.Time, now time.Time) (bool, error)
ClaimTenancyScanPolicySchedule atomically records the scheduled tick claimed by a worker.
func (*MemoryStore) CompleteRepoScan ¶
func (m *MemoryStore) CompleteRepoScan(ctx context.Context, repoScanID string, status string, finishedAt time.Time, commitsScanned int, filesScanned int, findingCount int, truncated bool, scanContext RepoScanContext, errorMessage string) error
CompleteRepoScan finalizes repo scan metadata.
func (*MemoryStore) CompleteScan ¶
func (m *MemoryStore) CompleteScan(ctx context.Context, scanID string, status string, finishedAt time.Time, assetCount int, findingCount int, errorMessage string) error
CompleteScan finalizes persisted scan metadata.
func (*MemoryStore) CompleteWebhookEvent ¶
func (m *MemoryStore) CompleteWebhookEvent(ctx context.Context, provider string, eventID string, claimToken string, now time.Time) error
CompleteWebhookEvent marks a claimed event processed so later duplicates become no-op successes. It is a no-op unless claimToken still matches the active claim, so a superseded stale handler cannot complete the successor's claim.
func (*MemoryStore) ConsumeOAuthTransaction ¶
func (m *MemoryStore) ConsumeOAuthTransaction(ctx context.Context, nonce string, cookieToken string, now time.Time) (OAuthTransaction, error)
ConsumeOAuthTransaction atomically consumes the row matching nonce and cookieToken. Re-consuming, an expired row, a missing row, or a cookie-token mismatch all return ErrNotFound so the OAuth state cannot be replayed.
func (*MemoryStore) ConsumeSAMLRelayState ¶
func (m *MemoryStore) ConsumeSAMLRelayState(ctx context.Context, handle string, now time.Time) (SAMLRelayState, error)
ConsumeSAMLRelayState atomically marks one handle consumed and returns the stored state. Re-consuming the same handle returns ErrNotFound so the RelayState value cannot be replayed.
func (*MemoryStore) CountPendingRepoScansByRepository ¶
func (m *MemoryStore) CountPendingRepoScansByRepository(ctx context.Context, repository string) (int, error)
CountPendingRepoScansByRepository returns queued/running scan count for one repository.
func (*MemoryStore) CountQueuedRepoScans ¶
func (m *MemoryStore) CountQueuedRepoScans(ctx context.Context) (int, error)
CountQueuedRepoScans returns queued repository scan count.
func (*MemoryStore) CountQueuedRepoScansAnyScope ¶
func (m *MemoryStore) CountQueuedRepoScansAnyScope(_ context.Context) (int, error)
CountQueuedRepoScansAnyScope returns queued repository scan count across all scopes.
func (*MemoryStore) CountQueuedScans ¶
CountQueuedScans returns the queued scan count for one provider.
func (*MemoryStore) CountQueuedScansAnyScope ¶
CountQueuedScansAnyScope returns queued scan count across all scopes for one provider.
func (*MemoryStore) CreateAuthzPolicyVersion ¶
func (m *MemoryStore) CreateAuthzPolicyVersion(ctx context.Context, version AuthzPolicyVersion) (AuthzPolicyVersion, error)
CreateAuthzPolicyVersion persists one immutable policy bundle version.
func (*MemoryStore) CreateIdentityConnection ¶
func (m *MemoryStore) CreateIdentityConnection(ctx context.Context, connection IdentityConnection) (IdentityConnection, error)
CreateIdentityConnection persists one enterprise identity connection scaffold.
func (*MemoryStore) CreateInvitation ¶
func (m *MemoryStore) CreateInvitation(ctx context.Context, invitation Invitation) (Invitation, error)
CreateInvitation persists one invitation scaffold.
func (*MemoryStore) CreateOAuthTransaction ¶
func (m *MemoryStore) CreateOAuthTransaction(ctx context.Context, txn OAuthTransaction) (OAuthTransaction, error)
CreateOAuthTransaction persists one in-flight WorkOS OAuth login keyed by the signed-state nonce. Used by /auth/login and /auth/signup; one-shot consumed by /auth/callback.
func (*MemoryStore) CreateQueuedRepoScan ¶
func (m *MemoryStore) CreateQueuedRepoScan(ctx context.Context, repository string, source RepoScanSource, scanContext RepoScanContext, historyLimit int, maxFindings int, queuedAt time.Time) (RepoScanRecord, error)
CreateQueuedRepoScan persists one queued repository exposure scan request.
func (*MemoryStore) CreateQueuedRepoScanWithinLimit ¶
func (m *MemoryStore) CreateQueuedRepoScanWithinLimit(ctx context.Context, repository string, source RepoScanSource, scanContext RepoScanContext, historyLimit int, maxFindings int, queuedAt time.Time, maxPending int) (RepoScanRecord, error)
CreateQueuedRepoScanWithinLimit persists one queued repository scan only when the target is idle and queue capacity remains.
func (*MemoryStore) CreateQueuedScan ¶
func (m *MemoryStore) CreateQueuedScan(ctx context.Context, provider string, queuedAt time.Time) (ScanRecord, error)
CreateQueuedScan persists one queued scan request.
func (*MemoryStore) CreateQueuedScanIfNoPending ¶
func (m *MemoryStore) CreateQueuedScanIfNoPending(ctx context.Context, provider string, queuedAt time.Time) (ScanRecord, error)
CreateQueuedScanIfNoPending persists one queued scan only when no queued/running scan exists.
func (*MemoryStore) CreateQueuedScanWithinLimit ¶
func (m *MemoryStore) CreateQueuedScanWithinLimit(ctx context.Context, provider string, queuedAt time.Time, maxPending int) (ScanRecord, error)
CreateQueuedScanWithinLimit persists one queued scan request only when pending capacity remains.
func (*MemoryStore) CreateRepoScan ¶
func (m *MemoryStore) CreateRepoScan(ctx context.Context, repository string, source RepoScanSource, scanContext RepoScanContext, startedAt time.Time) (RepoScanRecord, error)
CreateRepoScan persists one repository exposure scan start event.
func (*MemoryStore) CreateSAMLRelayState ¶
func (m *MemoryStore) CreateSAMLRelayState(ctx context.Context, state SAMLRelayState) (SAMLRelayState, error)
CreateSAMLRelayState persists one SP-initiated SAML AuthnRequest record keyed by the opaque relay handle. Used by /auth/saml/login; consumed (one-shot) by /auth/saml/acs.
func (*MemoryStore) CreateSCIMProvisioningEvent ¶
func (m *MemoryStore) CreateSCIMProvisioningEvent(ctx context.Context, event SCIMProvisioningEventRecord) (SCIMProvisioningEventRecord, error)
CreateSCIMProvisioningEvent appends one SCIM provisioning event to the append-only audit log scoped to the org + connection.
func (*MemoryStore) CreateScan ¶
func (m *MemoryStore) CreateScan(ctx context.Context, provider string, startedAt time.Time) (ScanRecord, error)
CreateScan persists a scan start event.
func (*MemoryStore) CreateSession ¶
CreateSession persists one server-side session.
func (*MemoryStore) CreateVerifiedDomain ¶
func (m *MemoryStore) CreateVerifiedDomain(ctx context.Context, domain VerifiedDomain) (VerifiedDomain, error)
CreateVerifiedDomain persists one domain-verification scaffold.
func (*MemoryStore) DeadLetterScan ¶
func (m *MemoryStore) DeadLetterScan(ctx context.Context, scanID string, finishedAt time.Time, retryCount int, maxRetryCount int, assetCount int, findingCount int, failureCategory string, errorMessage string) error
DeadLetterScan marks a failed queued scan as operator-replayable.
func (*MemoryStore) DeleteAuthzRelationship ¶
func (m *MemoryStore) DeleteAuthzRelationship(ctx context.Context, relationship AuthzRelationship) error
DeleteAuthzRelationship removes one scoped ReBAC tuple.
func (*MemoryStore) DeleteIdentityConnection ¶
func (m *MemoryStore) DeleteIdentityConnection(ctx context.Context, orgID, connectionID string) error
DeleteIdentityConnection removes one persisted identity connection scoped to the (org_id, id) pair, cascading to its SCIM provisioning events. The cascade matches the ON DELETE CASCADE clause on scim_provisioning_events in Postgres so memory mode does not retain orphan audit rows for a connection that no longer exists.
func (*MemoryStore) DeleteOrganization ¶
func (m *MemoryStore) DeleteOrganization(ctx context.Context) error
DeleteOrganization removes the active scoped tenant organization record.
func (*MemoryStore) DeleteProject ¶
func (m *MemoryStore) DeleteProject(ctx context.Context, workspaceID string, projectID string) error
DeleteProject removes one scoped project.
func (*MemoryStore) DeleteRepoFindings ¶
func (m *MemoryStore) DeleteRepoFindings(ctx context.Context, repoScanID string) error
DeleteRepoFindings removes all persisted repository findings for one scan.
func (*MemoryStore) DeleteTenancyConnectorSecretEnvelope ¶
func (m *MemoryStore) DeleteTenancyConnectorSecretEnvelope(ctx context.Context, workspaceID string, projectID string, connectorID string, secretName string) error
DeleteTenancyConnectorSecretEnvelope removes one encrypted connector secret envelope.
func (*MemoryStore) DeleteTenancyScanPolicy ¶
func (m *MemoryStore) DeleteTenancyScanPolicy(ctx context.Context, workspaceID string, projectID string, policyID string) error
DeleteTenancyScanPolicy removes one scoped scan policy.
func (*MemoryStore) DeleteUserIdentity ¶
func (m *MemoryStore) DeleteUserIdentity(ctx context.Context, provider string, subject string) error
DeleteUserIdentity removes one provider identity by provider and subject.
func (*MemoryStore) DeleteWebhookEvent ¶
func (m *MemoryStore) DeleteWebhookEvent(ctx context.Context, provider string, eventID string, claimToken string) error
DeleteWebhookEvent rolls back a claim so a provider retry can reprocess an event whose side effects failed transiently. It is a no-op unless claimToken still matches the active claim, so a superseded stale handler cannot erase the successor's claim.
func (*MemoryStore) DeleteWorkspace ¶
func (m *MemoryStore) DeleteWorkspace(ctx context.Context, workspaceID string) error
DeleteWorkspace removes one scoped workspace and all child records.
func (*MemoryStore) DeleteWorkspaceMember ¶
func (m *MemoryStore) DeleteWorkspaceMember(ctx context.Context, workspaceID string, memberID string) error
DeleteWorkspaceMember removes one scoped workspace member.
func (*MemoryStore) FailStaleRepoScansAnyScope ¶
func (m *MemoryStore) FailStaleRepoScansAnyScope(_ context.Context, staleBefore time.Time, limit int, errorMessage string) (int, error)
FailStaleRepoScansAnyScope marks stale running repository scans failed across all scopes.
func (*MemoryStore) FindFirstWorkspaceMemberByUserUUID ¶
func (m *MemoryStore) FindFirstWorkspaceMemberByUserUUID(ctx context.Context, userUUID string) (TenancyWorkspaceMember, error)
FindFirstWorkspaceMemberByUserUUID returns the newest active workspace membership for one auth user.
func (*MemoryStore) FindFirstWorkspaceMemberByUserUUIDAndTenantID ¶
func (m *MemoryStore) FindFirstWorkspaceMemberByUserUUIDAndTenantID(ctx context.Context, userUUID string, tenantID string) (TenancyWorkspaceMember, error)
FindFirstWorkspaceMemberByUserUUIDAndTenantID returns the newest active workspace membership for one auth user in one tenant.
func (*MemoryStore) GetAuthzEntityAttributes ¶
func (m *MemoryStore) GetAuthzEntityAttributes(ctx context.Context, entityKind string, entityType string, entityID string) (AuthzEntityAttributes, error)
GetAuthzEntityAttributes returns trusted authorization attributes for one entity.
func (*MemoryStore) GetAuthzPolicyRollout ¶
func (m *MemoryStore) GetAuthzPolicyRollout(ctx context.Context, policySetID string) (AuthzPolicyRollout, error)
GetAuthzPolicyRollout returns one scoped rollout pointer row.
func (*MemoryStore) GetAuthzPolicySet ¶
func (m *MemoryStore) GetAuthzPolicySet(ctx context.Context, policySetID string) (AuthzPolicySet, error)
GetAuthzPolicySet returns one scoped policy set metadata record.
func (*MemoryStore) GetAuthzPolicyVersion ¶
func (m *MemoryStore) GetAuthzPolicyVersion(ctx context.Context, policySetID string, version int) (AuthzPolicyVersion, error)
GetAuthzPolicyVersion returns one scoped immutable policy bundle version.
func (*MemoryStore) GetFinding ¶
func (m *MemoryStore) GetFinding(ctx context.Context, findingID string, scanID string) (domain.Finding, error)
GetFinding returns one finding by id, optionally scoped to one scan id.
func (*MemoryStore) GetFindingTriageState ¶
func (m *MemoryStore) GetFindingTriageState(ctx context.Context, findingID string) (FindingTriageState, error)
GetFindingTriageState returns triage workflow state for one finding id.
func (*MemoryStore) GetIdentityConnection ¶
func (m *MemoryStore) GetIdentityConnection(ctx context.Context, orgID string, connectionID string) (IdentityConnection, error)
GetIdentityConnection returns one organization identity connection scaffold.
func (*MemoryStore) GetIdentityConnectionByID ¶
func (m *MemoryStore) GetIdentityConnectionByID(ctx context.Context, connectionID string) (IdentityConnection, error)
GetIdentityConnectionByID resolves a connection by its globally unique UUID. Used by entry points that do not know the org id yet (e.g. the SAML SP-initiated login route).
Memory mode does not have the SQL UNIQUE constraint Postgres uses to guarantee global uuid uniqueness, so a buggy seed could insert two rows with the same id. Return ErrConflict in that case rather than picking a non-deterministic match.
func (*MemoryStore) GetIdentityConnectionBySCIMBearerTokenHash ¶
func (m *MemoryStore) GetIdentityConnectionBySCIMBearerTokenHash(ctx context.Context, tokenHash string) (IdentityConnection, error)
GetIdentityConnectionBySCIMBearerTokenHash resolves a connection by its stored SCIM bearer-token hash for unauthenticated SCIM entry points.
func (*MemoryStore) GetInvitation ¶
func (m *MemoryStore) GetInvitation(ctx context.Context, orgID string, invitationID string) (Invitation, error)
GetInvitation returns one organization invitation scaffold.
func (*MemoryStore) GetOnboardingState ¶
func (m *MemoryStore) GetOnboardingState(ctx context.Context, userID string) (OnboardingState, error)
GetOnboardingState returns one user's onboarding progress row.
func (*MemoryStore) GetOrganization ¶
func (m *MemoryStore) GetOrganization(ctx context.Context) (TenancyOrganization, error)
GetOrganization returns the active scoped tenant organization.
func (*MemoryStore) GetProject ¶
func (m *MemoryStore) GetProject(ctx context.Context, workspaceID string, projectID string) (TenancyProject, error)
GetProject returns one scoped project by id.
func (*MemoryStore) GetRepoScan ¶
func (m *MemoryStore) GetRepoScan(ctx context.Context, repoScanID string) (RepoScanRecord, error)
GetRepoScan returns one persisted repo scan by id.
func (*MemoryStore) GetRepoScanCursor ¶
func (m *MemoryStore) GetRepoScanCursor(ctx context.Context, repository string, source RepoScanSource) (RepoScanCursor, error)
GetRepoScanCursor returns the last successful scan cursor for one repository source.
func (*MemoryStore) GetScan ¶
func (m *MemoryStore) GetScan(ctx context.Context, scanID string) (ScanRecord, error)
GetScan returns one persisted scan by id.
func (*MemoryStore) GetTenancyConnector ¶
func (m *MemoryStore) GetTenancyConnector(ctx context.Context, workspaceID string, projectID string, connectorID string) (TenancyConnectorWithState, error)
GetTenancyConnector returns one connector and its latest state.
func (*MemoryStore) GetTenancyConnectorSecretEnvelope ¶
func (m *MemoryStore) GetTenancyConnectorSecretEnvelope(ctx context.Context, workspaceID string, projectID string, connectorID string, secretName string) (TenancyConnectorSecretEnvelope, error)
GetTenancyConnectorSecretEnvelope loads one encrypted connector secret envelope.
func (*MemoryStore) GetTenancyScanPolicy ¶
func (m *MemoryStore) GetTenancyScanPolicy(ctx context.Context, workspaceID string, projectID string, policyID string) (TenancyScanPolicy, error)
GetTenancyScanPolicy returns one scoped scan policy by id.
func (*MemoryStore) GetUserByPrimaryEmail ¶
GetUserByPrimaryEmail returns one account by normalized primary email.
func (*MemoryStore) GetUserIdentity ¶
func (m *MemoryStore) GetUserIdentity(ctx context.Context, provider string, subject string) (UserIdentity, error)
GetUserIdentity returns one provider identity by provider and subject.
func (*MemoryStore) GetUserIdentityByProviderUserID ¶
func (m *MemoryStore) GetUserIdentityByProviderUserID(ctx context.Context, provider string, userID string) (UserIdentity, error)
GetUserIdentityByProviderUserID returns one provider identity for a user.
func (*MemoryStore) GetVerifiedDomain ¶
func (m *MemoryStore) GetVerifiedDomain(ctx context.Context, orgID string, domainID string) (VerifiedDomain, error)
GetVerifiedDomain returns one organization domain-verification scaffold.
func (*MemoryStore) GetWorkspace ¶
func (m *MemoryStore) GetWorkspace(ctx context.Context, workspaceID string) (TenancyWorkspace, error)
GetWorkspace returns one workspace by id in active tenant scope.
func (*MemoryStore) GetWorkspaceMember ¶
func (m *MemoryStore) GetWorkspaceMember(ctx context.Context, workspaceID string, memberID string) (TenancyWorkspaceMember, error)
GetWorkspaceMember returns one scoped workspace member by member id.
func (*MemoryStore) GetWorkspaceMemberByUserUUID ¶
func (m *MemoryStore) GetWorkspaceMemberByUserUUID(ctx context.Context, workspaceID string, userUUID string) (TenancyWorkspaceMember, error)
GetWorkspaceMemberByUserUUID returns one scoped workspace member by auth user UUID.
func (*MemoryStore) ListAllTenancyConnectorsByType ¶
func (m *MemoryStore) ListAllTenancyConnectorsByType(ctx context.Context, connectorType domain.ConnectorType, limit int) ([]TenancyConnectorWithState, error)
ListAllTenancyConnectorsByType returns connectors across all scopes for internal runtime matching.
func (*MemoryStore) ListAuthzPolicyEvents ¶
func (m *MemoryStore) ListAuthzPolicyEvents(ctx context.Context, policySetID string, limit int) ([]AuthzPolicyEvent, error)
ListAuthzPolicyEvents returns immutable lifecycle events for one policy set (newest first).
func (*MemoryStore) ListAuthzPolicyVersions ¶
func (m *MemoryStore) ListAuthzPolicyVersions(ctx context.Context, policySetID string, limit int) ([]AuthzPolicyVersion, error)
ListAuthzPolicyVersions returns policy bundle versions for one policy set (newest first).
func (*MemoryStore) ListAuthzRelationships ¶
func (m *MemoryStore) ListAuthzRelationships(ctx context.Context, filter AuthzRelationshipFilter, limit int) ([]AuthzRelationship, error)
ListAuthzRelationships returns filtered scoped ReBAC tuples.
func (*MemoryStore) ListFindingMetasByScan ¶
func (m *MemoryStore) ListFindingMetasByScan(ctx context.Context, scanID string) ([]FindingMeta, error)
ListFindingMetasByScan returns lightweight finding metadata for one scan.
func (*MemoryStore) ListFindingTrendCounts ¶
func (m *MemoryStore) ListFindingTrendCounts(ctx context.Context, scanIDs []string, severity string, findingType string) ([]FindingTrendCount, error)
ListFindingTrendCounts aggregates findings by scan and severity.
func (*MemoryStore) ListFindingTriageEvents ¶
func (m *MemoryStore) ListFindingTriageEvents(ctx context.Context, findingID string, limit int) ([]FindingTriageEvent, error)
ListFindingTriageEvents returns triage actions newest-first for one finding id.
func (*MemoryStore) ListFindingTriageStates ¶
func (m *MemoryStore) ListFindingTriageStates(ctx context.Context, findingIDs []string) ([]FindingTriageState, error)
ListFindingTriageStates returns triage states for provided finding ids.
func (*MemoryStore) ListFindings ¶
ListFindings returns latest findings first.
func (*MemoryStore) ListFindingsAll ¶
ListFindingsAll returns all findings for current scope ordered by recency.
func (*MemoryStore) ListFindingsByScan ¶
func (m *MemoryStore) ListFindingsByScan(ctx context.Context, scanID string, limit int) ([]domain.Finding, error)
ListFindingsByScan returns latest findings first for one scan.
func (*MemoryStore) ListFindingsByScanAndIDs ¶
func (m *MemoryStore) ListFindingsByScanAndIDs(ctx context.Context, scanID string, findingIDs []string) ([]domain.Finding, error)
ListFindingsByScanAndIDs returns detailed findings for one scan and ID set.
func (*MemoryStore) ListFindingsFiltered ¶
func (m *MemoryStore) ListFindingsFiltered(ctx context.Context, filter FindingListFilter) ([]domain.Finding, error)
ListFindingsFiltered returns findings after applying persistence-level filters and stable ordering.
func (*MemoryStore) ListIdentities ¶
func (m *MemoryStore) ListIdentities(ctx context.Context, filter IdentityFilter, limit int) ([]domain.Identity, error)
ListIdentities returns identities filtered by scan/provider/type/name.
func (*MemoryStore) ListIdentityConnections ¶
func (m *MemoryStore) ListIdentityConnections(ctx context.Context, orgID string, limit int) ([]IdentityConnection, error)
ListIdentityConnections returns organization identity connection scaffolds ordered by newest first.
func (*MemoryStore) ListInvitations ¶
func (m *MemoryStore) ListInvitations(ctx context.Context, orgID string, limit int) ([]Invitation, error)
ListInvitations returns organization invitations ordered by newest first.
func (*MemoryStore) ListProjects ¶
func (m *MemoryStore) ListProjects(ctx context.Context, workspaceID string, includeArchived bool, limit int) ([]TenancyProject, error)
ListProjects returns projects for one scoped workspace.
func (*MemoryStore) ListRelationships ¶
func (m *MemoryStore) ListRelationships(ctx context.Context, filter RelationshipFilter, limit int) ([]domain.Relationship, error)
ListRelationships returns relationships filtered by scan/type/from/to.
func (*MemoryStore) ListRepoFindingClusters ¶
func (m *MemoryStore) ListRepoFindingClusters(ctx context.Context, filter RepoFindingClusterListFilter) ([]domain.RepoFindingCluster, error)
ListRepoFindingClusters returns repository finding clusters using store-backed pagination semantics.
func (*MemoryStore) ListRepoFindingTrendCounts ¶
func (m *MemoryStore) ListRepoFindingTrendCounts(ctx context.Context, repoScanIDs []string, severity string, findingType string) ([]FindingTrendCount, error)
ListRepoFindingTrendCounts aggregates repository finding totals by repo scan and severity.
func (*MemoryStore) ListRepoFindings ¶
func (m *MemoryStore) ListRepoFindings(ctx context.Context, filter RepoFindingFilter, limit int) ([]domain.Finding, error)
ListRepoFindings returns repository findings using optional filters.
func (*MemoryStore) ListRepoScans ¶
func (m *MemoryStore) ListRepoScans(ctx context.Context, limit int) ([]RepoScanRecord, error)
ListRepoScans returns latest repo scans first.
func (*MemoryStore) ListSCIMProvisioningEvents ¶
func (m *MemoryStore) ListSCIMProvisioningEvents(ctx context.Context, orgID string, connectionID string, limit int) ([]SCIMProvisioningEventRecord, error)
ListSCIMProvisioningEvents returns events for one connection ordered newest first, capped at limit (default 100).
func (*MemoryStore) ListScanEvents ¶
func (m *MemoryStore) ListScanEvents(ctx context.Context, scanID string, limit int) ([]ScanEvent, error)
ListScanEvents returns most recent scan events first.
func (*MemoryStore) ListScans ¶
func (m *MemoryStore) ListScans(ctx context.Context, limit int) ([]ScanRecord, error)
ListScans returns latest scans first.
func (*MemoryStore) ListScheduledTenancyScanPolicies ¶
func (m *MemoryStore) ListScheduledTenancyScanPolicies(ctx context.Context, limit int, offset int) ([]TenancyScanPolicy, error)
ListScheduledTenancyScanPolicies returns all enabled scheduled policies for worker execution.
func (*MemoryStore) ListTenancyConnectors ¶
func (m *MemoryStore) ListTenancyConnectors(ctx context.Context, workspaceID string, projectID string, connectorType domain.ConnectorType, limit int) ([]TenancyConnectorWithState, error)
ListTenancyConnectors returns scoped connectors ordered by most recent update.
func (*MemoryStore) ListTenancyConnectorsUnscoped ¶
func (m *MemoryStore) ListTenancyConnectorsUnscoped(_ context.Context, connectorType domain.ConnectorType, limit int) ([]TenancyConnectorWithState, error)
ListTenancyConnectorsUnscoped returns connectors across all scopes for internal webhook dispatch.
func (*MemoryStore) ListTenancyScanPolicies ¶
func (m *MemoryStore) ListTenancyScanPolicies(ctx context.Context, workspaceID string, projectID string, triggerMode domain.ScanTriggerMode, enabled *bool, sortBy string, sortDesc bool, limit int) ([]TenancyScanPolicy, error)
ListTenancyScanPolicies returns scoped policies ordered before limiting.
func (*MemoryStore) ListUserIdentitiesByProvider ¶
func (m *MemoryStore) ListUserIdentitiesByProvider(ctx context.Context, provider string, limit int) ([]UserIdentity, error)
ListUserIdentitiesByProvider returns provider identities ordered by newest first. A non-positive limit returns all matching identities.
func (*MemoryStore) ListUserSessions ¶
func (m *MemoryStore) ListUserSessions(ctx context.Context, userID string, now time.Time, limit int) ([]Session, error)
ListUserSessions returns active sessions for one user.
func (*MemoryStore) ListVerifiedDomains ¶
func (m *MemoryStore) ListVerifiedDomains(ctx context.Context, orgID string, limit int) ([]VerifiedDomain, error)
ListVerifiedDomains returns organization domain-verification scaffolds ordered by newest first.
func (*MemoryStore) ListWorkspaceMembers ¶
func (m *MemoryStore) ListWorkspaceMembers(ctx context.Context, workspaceID string, limit int) ([]TenancyWorkspaceMember, error)
ListWorkspaceMembers returns members for one scoped workspace.
func (*MemoryStore) ListWorkspaceMembershipsByUserUUIDAndTenantID ¶
func (m *MemoryStore) ListWorkspaceMembershipsByUserUUIDAndTenantID(ctx context.Context, userUUID string, tenantID string) ([]TenancyWorkspaceMember, error)
ListWorkspaceMembershipsByUserUUIDAndTenantID returns every active workspace membership the user holds within one tenant. It is the authorization basis for organization-wide reads: a caller may only aggregate data from the workspaces they actually belong to.
func (*MemoryStore) ListWorkspaces ¶
func (m *MemoryStore) ListWorkspaces(ctx context.Context, limit int) ([]TenancyWorkspace, error)
ListWorkspaces returns tenant-scoped workspaces ordered by created_at descending.
func (*MemoryStore) RequeueRepoScan ¶
func (m *MemoryStore) RequeueRepoScan(ctx context.Context, repoScanID string) error
RequeueRepoScan moves a running repository scan back to queued state.
func (*MemoryStore) RevokeAllUserSessions ¶
func (m *MemoryStore) RevokeAllUserSessions(ctx context.Context, userID string, revokedAt time.Time) (int, error)
RevokeAllUserSessions revokes every active session for one user.
func (*MemoryStore) RevokeInvitation ¶
func (m *MemoryStore) RevokeInvitation(ctx context.Context, orgID string, invitationID string, revokedAt time.Time) (Invitation, error)
RevokeInvitation marks one pending invitation revoked.
func (*MemoryStore) RevokeOtherUserSessions ¶
func (m *MemoryStore) RevokeOtherUserSessions(ctx context.Context, userID string, currentSessionIDHash []byte, revokedAt time.Time) (int, error)
RevokeOtherUserSessions revokes every active session except the caller's.
func (*MemoryStore) RevokeUserSession ¶
func (m *MemoryStore) RevokeUserSession(ctx context.Context, userID string, sessionIDHash []byte, revokedAt time.Time) (Session, error)
RevokeUserSession revokes one active session if it belongs to the user.
func (*MemoryStore) ScheduleScanRetry ¶
func (m *MemoryStore) ScheduleScanRetry(ctx context.Context, scanID string, queuedAt time.Time, retryCount int, maxRetryCount int, failureCategory string, errorMessage string, nextRetryAt time.Time) error
ScheduleScanRetry moves a failed scan attempt back to queued state with backoff metadata.
func (*MemoryStore) SummarizeFindings ¶
func (m *MemoryStore) SummarizeFindings(ctx context.Context) (FindingSummaryCounts, error)
SummarizeFindings returns aggregate counters for current scope without materializing router-facing copies.
func (*MemoryStore) TouchSession ¶
func (m *MemoryStore) TouchSession(ctx context.Context, sessionIDHash []byte, now time.Time) (Session, error)
TouchSession renews idle expiry and returns the joined session/user row.
func (*MemoryStore) UpdateIdentityConnection ¶
func (m *MemoryStore) UpdateIdentityConnection(ctx context.Context, connection IdentityConnection) (IdentityConnection, error)
UpdateIdentityConnection replaces one persisted identity connection scoped to the (org_id, id) pair. The Postgres path enforces the create-time uniqueness invariants via SQL UNIQUE constraints and preserves the SCIM bearer token hash via COALESCE; this method mirrors both behaviors for memory mode so a parity bug cannot let callers do something through the memory store that Postgres would reject.
func (*MemoryStore) UpdateSessionContext ¶
func (m *MemoryStore) UpdateSessionContext(ctx context.Context, userID string, sessionIDHash []byte, orgID string, workspaceID string, projectID string, now time.Time) (Session, error)
UpdateSessionContext persists the active tenancy context for one browser session.
func (*MemoryStore) UpsertArtifacts ¶
func (m *MemoryStore) UpsertArtifacts(ctx context.Context, scanID string, artifacts ScanArtifacts) error
UpsertArtifacts persists raw and normalized scan artifacts idempotently.
func (*MemoryStore) UpsertAuthzEntityAttributes ¶
func (m *MemoryStore) UpsertAuthzEntityAttributes(ctx context.Context, attributes AuthzEntityAttributes) error
UpsertAuthzEntityAttributes creates or updates trusted authorization attributes.
func (*MemoryStore) UpsertAuthzPolicyRollout ¶
func (m *MemoryStore) UpsertAuthzPolicyRollout(ctx context.Context, rollout AuthzPolicyRollout) error
UpsertAuthzPolicyRollout creates or updates one scoped rollout pointer row.
func (*MemoryStore) UpsertAuthzPolicySet ¶
func (m *MemoryStore) UpsertAuthzPolicySet(ctx context.Context, policySet AuthzPolicySet) error
UpsertAuthzPolicySet creates or updates one scoped policy set metadata record.
func (*MemoryStore) UpsertAuthzRelationship ¶
func (m *MemoryStore) UpsertAuthzRelationship(ctx context.Context, relationship AuthzRelationship) error
UpsertAuthzRelationship creates or updates one scoped ReBAC tuple.
func (*MemoryStore) UpsertFindingTriageState ¶
func (m *MemoryStore) UpsertFindingTriageState(ctx context.Context, state FindingTriageState) error
UpsertFindingTriageState creates or updates mutable triage metadata.
func (*MemoryStore) UpsertFindings ¶
func (m *MemoryStore) UpsertFindings(ctx context.Context, scanID string, findings []domain.Finding) error
UpsertFindings persists findings idempotently by scan_id + finding_id.
func (*MemoryStore) UpsertOnboardingState ¶
func (m *MemoryStore) UpsertOnboardingState(ctx context.Context, state OnboardingState) (OnboardingState, error)
UpsertOnboardingState persists one user-scoped onboarding progress row.
func (*MemoryStore) UpsertOrganization ¶
func (m *MemoryStore) UpsertOrganization(ctx context.Context, organization TenancyOrganization) error
UpsertOrganization persists or updates one tenant organization record.
func (*MemoryStore) UpsertProject ¶
func (m *MemoryStore) UpsertProject(ctx context.Context, project TenancyProject) error
UpsertProject persists one scoped project record.
func (*MemoryStore) UpsertRepoFindings ¶
func (m *MemoryStore) UpsertRepoFindings(ctx context.Context, repoScanID string, findings []domain.Finding) error
UpsertRepoFindings persists repository findings idempotently by repo_scan_id + finding_id.
func (*MemoryStore) UpsertRepoScanCursor ¶
func (m *MemoryStore) UpsertRepoScanCursor(ctx context.Context, cursor RepoScanCursor) error
UpsertRepoScanCursor stores the latest successful scan cursor for one repository source.
func (*MemoryStore) UpsertTenancyConnector ¶
func (m *MemoryStore) UpsertTenancyConnector(ctx context.Context, connector TenancyConnector, state TenancyConnectorState) error
UpsertTenancyConnector persists one connector and its latest state atomically.
func (*MemoryStore) UpsertTenancyConnectorSecretEnvelope ¶
func (m *MemoryStore) UpsertTenancyConnectorSecretEnvelope(ctx context.Context, envelope TenancyConnectorSecretEnvelope) error
UpsertTenancyConnectorSecretEnvelope persists one encrypted connector secret envelope.
func (*MemoryStore) UpsertTenancyScanPolicy ¶
func (m *MemoryStore) UpsertTenancyScanPolicy(ctx context.Context, policy TenancyScanPolicy) error
UpsertTenancyScanPolicy persists one scan policy for a scoped project.
func (*MemoryStore) UpsertUser ¶
UpsertUser persists one account row.
func (*MemoryStore) UpsertUserIdentity ¶
func (m *MemoryStore) UpsertUserIdentity(ctx context.Context, identity UserIdentity) (UserIdentity, error)
UpsertUserIdentity persists one provider identity mapping.
func (*MemoryStore) UpsertWorkspace ¶
func (m *MemoryStore) UpsertWorkspace(ctx context.Context, workspace TenancyWorkspace) error
UpsertWorkspace persists or updates one scoped workspace record.
func (*MemoryStore) UpsertWorkspaceMember ¶
func (m *MemoryStore) UpsertWorkspaceMember(ctx context.Context, member TenancyWorkspaceMember) error
UpsertWorkspaceMember persists one workspace member assignment.
type OAuthTransaction ¶
type OAuthTransaction struct {
Nonce string `json:"nonce"`
CookieToken string `json:"cookie_token"`
Intent string `json:"intent"`
ReturnTo string `json:"return_to,omitempty"`
ExpectedUserID string `json:"expected_user_id,omitempty"`
ExpectedSessionID string `json:"expected_session_id,omitempty"`
ExpiresAt time.Time `json:"expires_at"`
CreatedAt time.Time `json:"created_at"`
ConsumedAt *time.Time `json:"consumed_at,omitempty"`
}
OAuthTransaction is the persisted server-side record for one in-flight WorkOS OAuth login. The signed `state` token carries Nonce; the matching callback must present both the signed state (Nonce) and the browser-bound CookieToken set when the redirect was issued. The row is one-shot consumed by the callback handler so a captured state cannot be replayed — including against a different API instance that shares this database.
type OnboardingState ¶
type OnboardingState struct {
UserID string `json:"user_id"`
CurrentStep string `json:"current_step"`
OrgID string `json:"org_id,omitempty"`
WorkspaceID string `json:"workspace_id,omitempty"`
ProjectID string `json:"project_id,omitempty"`
ConnectorID string `json:"connector_id,omitempty"`
ConnectorType string `json:"connector_type,omitempty"`
ConnectorSkipped bool `json:"connector_skipped"`
ScanSkipped bool `json:"scan_skipped"`
DashboardTourDismissedAt *time.Time `json:"dashboard_tour_dismissed_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
StartedAt time.Time `json:"started_at"`
UpdatedAt time.Time `json:"updated_at"`
}
OnboardingState stores the server-driven account setup progress for one user.
func NormalizeOnboardingStateForWrite ¶
func NormalizeOnboardingStateForWrite(state OnboardingState) (OnboardingState, error)
NormalizeOnboardingStateForWrite validates and canonicalizes one onboarding state row.
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
PostgresStore persists scans/findings in PostgreSQL.
func NewPostgresStore ¶
func NewPostgresStore(databaseURL string) (*PostgresStore, error)
NewPostgresStore opens a PostgreSQL connection and validates connectivity.
func NewPostgresStoreWithDB ¶
func NewPostgresStoreWithDB(db *sql.DB) *PostgresStore
NewPostgresStoreWithDB builds a store around an existing sql.DB (tests).
func (*PostgresStore) AppendAuthzPolicyEvent ¶
func (p *PostgresStore) AppendAuthzPolicyEvent(ctx context.Context, event AuthzPolicyEvent) error
AppendAuthzPolicyEvent records one immutable policy lifecycle event.
func (*PostgresStore) AppendFindingTriageEvent ¶
func (p *PostgresStore) AppendFindingTriageEvent(ctx context.Context, event FindingTriageEvent) error
AppendFindingTriageEvent records one immutable triage action.
func (*PostgresStore) AppendScanEvent ¶
func (p *PostgresStore) AppendScanEvent(ctx context.Context, scanID string, level string, message string, metadata map[string]any) error
AppendScanEvent writes one scan event row.
func (*PostgresStore) ApplyDownMigrations ¶
func (p *PostgresStore) ApplyDownMigrations(ctx context.Context, dir string) error
ApplyDownMigrations runs all *.down.sql files in reverse lexical order.
func (*PostgresStore) ApplyFindingTriageTransition ¶
func (p *PostgresStore) ApplyFindingTriageTransition(ctx context.Context, state FindingTriageState, event FindingTriageEvent) error
ApplyFindingTriageTransition persists state and audit history atomically.
func (*PostgresStore) ApplyMigrations ¶
func (p *PostgresStore) ApplyMigrations(ctx context.Context, dir string) error
ApplyMigrations runs all *.up.sql files in lexical order.
func (*PostgresStore) BeginWebhookEvent ¶
func (p *PostgresStore) BeginWebhookEvent(ctx context.Context, event WebhookEvent, now time.Time) (WebhookEventStatus, string, error)
BeginWebhookEvent atomically claims the (provider, event_id) row. It first tries to win the insert; on conflict it tries to reclaim a stale 'processing' row (claiming instance likely crashed); failing that it reads the current status. Every branch is a single atomic statement, so the claim holds across API restarts and concurrent instances.
func (*PostgresStore) CancelRepoScan ¶
func (p *PostgresStore) CancelRepoScan(ctx context.Context, repoScanID string, finishedAt time.Time, errorMessage string) (RepoScanRecord, error)
CancelRepoScan atomically marks a queued or running repository scan as terminal failed.
func (*PostgresStore) ClaimKubernetesEnrollmentToken ¶
func (p *PostgresStore) ClaimKubernetesEnrollmentToken(ctx context.Context, workspaceID string, projectID string, connectorID string, expectedEnrollmentTokenHash string, updatedMetadata map[string]any, status domain.ConnectorStatus, health string, lastErrorCode string, lastErrorMessage string, observedAt time.Time, updatedAt time.Time) (bool, error)
ClaimKubernetesEnrollmentToken atomically consumes one connector enrollment token if unused.
func (*PostgresStore) ClaimNextQueuedRepoScan ¶
func (p *PostgresStore) ClaimNextQueuedRepoScan(ctx context.Context) (RepoScanRecord, error)
ClaimNextQueuedRepoScan atomically claims one queued repository scan.
func (*PostgresStore) ClaimNextQueuedRepoScanAnyScope ¶
func (p *PostgresStore) ClaimNextQueuedRepoScanAnyScope(ctx context.Context) (RepoScanRecord, error)
ClaimNextQueuedRepoScanAnyScope atomically claims one queued repository scan across all scopes.
func (*PostgresStore) ClaimNextQueuedScan ¶
func (p *PostgresStore) ClaimNextQueuedScan(ctx context.Context, provider string) (ScanRecord, error)
ClaimNextQueuedScan atomically claims one queued scan for execution.
func (*PostgresStore) ClaimNextQueuedScanAnyScope ¶
func (p *PostgresStore) ClaimNextQueuedScanAnyScope(ctx context.Context, provider string) (ScanRecord, error)
ClaimNextQueuedScanAnyScope atomically claims one queued scan across all scopes.
func (*PostgresStore) ClaimTenancyScanPolicySchedule ¶
func (p *PostgresStore) ClaimTenancyScanPolicySchedule(ctx context.Context, workspaceID string, projectID string, policyID string, scheduledAt time.Time, now time.Time) (bool, error)
ClaimTenancyScanPolicySchedule atomically records that a scheduled tick was claimed.
func (*PostgresStore) Close ¶
func (p *PostgresStore) Close() error
Close closes database resources.
func (*PostgresStore) CompleteRepoScan ¶
func (p *PostgresStore) CompleteRepoScan(ctx context.Context, repoScanID string, status string, finishedAt time.Time, commitsScanned int, filesScanned int, findingCount int, truncated bool, scanContext RepoScanContext, errorMessage string) error
CompleteRepoScan updates repository scan completion metadata.
func (*PostgresStore) CompleteScan ¶
func (p *PostgresStore) CompleteScan(ctx context.Context, scanID string, status string, finishedAt time.Time, assetCount int, findingCount int, errorMessage string) error
CompleteScan updates scan completion metadata.
func (*PostgresStore) CompleteWebhookEvent ¶
func (p *PostgresStore) CompleteWebhookEvent(ctx context.Context, provider string, eventID string, claimToken string, now time.Time) error
CompleteWebhookEvent marks a claimed event processed so later duplicate deliveries become no-op successes. The claim_token predicate makes a superseded stale handler's completion a no-op.
func (*PostgresStore) ConsumeOAuthTransaction ¶
func (p *PostgresStore) ConsumeOAuthTransaction(ctx context.Context, nonce string, cookieToken string, now time.Time) (OAuthTransaction, error)
ConsumeOAuthTransaction atomically consumes the row matching nonce and cookieToken. The UPDATE ... RETURNING with WHERE consumed_at IS NULL AND expires_at > now() guarantees one-shot consumption even under concurrent callbacks hitting different API instances. Any later, expired, missing, or cookie-mismatched call returns ErrNotFound.
func (*PostgresStore) ConsumeSAMLRelayState ¶
func (p *PostgresStore) ConsumeSAMLRelayState(ctx context.Context, handle string, now time.Time) (SAMLRelayState, error)
ConsumeSAMLRelayState atomically marks a relay row consumed and returns the persisted state. The UPDATE ... RETURNING with WHERE consumed_at IS NULL AND expires_at > now() guarantees one-shot consumption even under concurrent ACS POSTs hitting different API instances. A subsequent call with the same handle returns ErrNotFound.
func (*PostgresStore) CountPendingRepoScansByRepository ¶
func (p *PostgresStore) CountPendingRepoScansByRepository(ctx context.Context, repository string) (int, error)
CountPendingRepoScansByRepository returns queued+running scan count for one repository.
func (*PostgresStore) CountQueuedRepoScans ¶
func (p *PostgresStore) CountQueuedRepoScans(ctx context.Context) (int, error)
CountQueuedRepoScans returns queued repository scan requests count.
func (*PostgresStore) CountQueuedRepoScansAnyScope ¶
func (p *PostgresStore) CountQueuedRepoScansAnyScope(ctx context.Context) (int, error)
CountQueuedRepoScansAnyScope returns queued repository scan requests count across all scopes.
func (*PostgresStore) CountQueuedScans ¶
CountQueuedScans returns queued scan requests count for one provider.
func (*PostgresStore) CountQueuedScansAnyScope ¶
CountQueuedScansAnyScope returns queued scan requests count across all scopes for one provider.
func (*PostgresStore) CreateAuthzPolicyVersion ¶
func (p *PostgresStore) CreateAuthzPolicyVersion(ctx context.Context, version AuthzPolicyVersion) (AuthzPolicyVersion, error)
CreateAuthzPolicyVersion persists one immutable policy bundle version.
func (*PostgresStore) CreateIdentityConnection ¶
func (p *PostgresStore) CreateIdentityConnection(ctx context.Context, connection IdentityConnection) (IdentityConnection, error)
CreateIdentityConnection persists one enterprise identity connection scaffold.
func (*PostgresStore) CreateInvitation ¶
func (p *PostgresStore) CreateInvitation(ctx context.Context, invitation Invitation) (Invitation, error)
CreateInvitation persists one invitation scaffold.
func (*PostgresStore) CreateOAuthTransaction ¶
func (p *PostgresStore) CreateOAuthTransaction(ctx context.Context, txn OAuthTransaction) (OAuthTransaction, error)
CreateOAuthTransaction persists one in-flight WorkOS OAuth login keyed by the signed-state nonce.
func (*PostgresStore) CreateQueuedRepoScan ¶
func (p *PostgresStore) CreateQueuedRepoScan(ctx context.Context, repository string, source RepoScanSource, scanContext RepoScanContext, historyLimit int, maxFindings int, queuedAt time.Time) (RepoScanRecord, error)
CreateQueuedRepoScan inserts one queued repository scan request row.
func (*PostgresStore) CreateQueuedRepoScanWithinLimit ¶
func (p *PostgresStore) CreateQueuedRepoScanWithinLimit(ctx context.Context, repository string, source RepoScanSource, scanContext RepoScanContext, historyLimit int, maxFindings int, queuedAt time.Time, maxPending int) (RepoScanRecord, error)
CreateQueuedRepoScanWithinLimit inserts one queued repository scan only when the target is idle and queue capacity remains.
func (*PostgresStore) CreateQueuedScan ¶
func (p *PostgresStore) CreateQueuedScan(ctx context.Context, provider string, queuedAt time.Time) (ScanRecord, error)
CreateQueuedScan inserts a queued scan request row.
func (*PostgresStore) CreateQueuedScanIfNoPending ¶
func (p *PostgresStore) CreateQueuedScanIfNoPending(ctx context.Context, provider string, queuedAt time.Time) (ScanRecord, error)
CreateQueuedScanIfNoPending inserts one queued scan only when no queued/running scan exists.
func (*PostgresStore) CreateQueuedScanWithinLimit ¶
func (p *PostgresStore) CreateQueuedScanWithinLimit(ctx context.Context, provider string, queuedAt time.Time, maxPending int) (ScanRecord, error)
CreateQueuedScanWithinLimit inserts one queued scan request only when pending capacity remains.
func (*PostgresStore) CreateRepoScan ¶
func (p *PostgresStore) CreateRepoScan(ctx context.Context, repository string, source RepoScanSource, scanContext RepoScanContext, startedAt time.Time) (RepoScanRecord, error)
CreateRepoScan inserts a new repository exposure scan row.
func (*PostgresStore) CreateSAMLRelayState ¶
func (p *PostgresStore) CreateSAMLRelayState(ctx context.Context, state SAMLRelayState) (SAMLRelayState, error)
CreateSAMLRelayState persists one SP-initiated SAML AuthnRequest record.
func (*PostgresStore) CreateSCIMProvisioningEvent ¶
func (p *PostgresStore) CreateSCIMProvisioningEvent(ctx context.Context, event SCIMProvisioningEventRecord) (SCIMProvisioningEventRecord, error)
CreateSCIMProvisioningEvent appends one SCIM provisioning event to the audit log scoped to the org + connection. Append-only by design.
func (*PostgresStore) CreateScan ¶
func (p *PostgresStore) CreateScan(ctx context.Context, provider string, startedAt time.Time) (ScanRecord, error)
CreateScan inserts a new scan row.
func (*PostgresStore) CreateSession ¶
CreateSession persists one server-side session.
func (*PostgresStore) CreateVerifiedDomain ¶
func (p *PostgresStore) CreateVerifiedDomain(ctx context.Context, domain VerifiedDomain) (VerifiedDomain, error)
CreateVerifiedDomain persists one domain-verification scaffold.
func (*PostgresStore) DB ¶
func (p *PostgresStore) DB() *sql.DB
DB exposes the underlying sql.DB for runtime wiring (locks, health checks).
func (*PostgresStore) DeadLetterScan ¶
func (p *PostgresStore) DeadLetterScan(ctx context.Context, scanID string, finishedAt time.Time, retryCount int, maxRetryCount int, assetCount int, findingCount int, failureCategory string, errorMessage string) error
DeadLetterScan marks a failed queued scan as operator-replayable.
func (*PostgresStore) DeleteAuthzRelationship ¶
func (p *PostgresStore) DeleteAuthzRelationship(ctx context.Context, relationship AuthzRelationship) error
DeleteAuthzRelationship removes one scoped ReBAC tuple.
func (*PostgresStore) DeleteIdentityConnection ¶
func (p *PostgresStore) DeleteIdentityConnection(ctx context.Context, orgID, connectionID string) error
DeleteIdentityConnection removes one identity connection row keyed on (org_id, id). Returns ErrNotFound when no matching row exists.
func (*PostgresStore) DeleteOrganization ¶
func (p *PostgresStore) DeleteOrganization(ctx context.Context) error
DeleteOrganization removes one scoped organization record.
func (*PostgresStore) DeleteProject ¶
func (p *PostgresStore) DeleteProject(ctx context.Context, workspaceID string, projectID string) error
DeleteProject removes one scoped project.
func (*PostgresStore) DeleteRepoFindings ¶
func (p *PostgresStore) DeleteRepoFindings(ctx context.Context, repoScanID string) error
DeleteRepoFindings removes repository findings for one scan.
func (*PostgresStore) DeleteTenancyConnectorSecretEnvelope ¶
func (p *PostgresStore) DeleteTenancyConnectorSecretEnvelope(ctx context.Context, workspaceID string, projectID string, connectorID string, secretName string) error
DeleteTenancyConnectorSecretEnvelope removes one encrypted connector secret envelope by name.
func (*PostgresStore) DeleteTenancyScanPolicy ¶
func (p *PostgresStore) DeleteTenancyScanPolicy(ctx context.Context, workspaceID string, projectID string, policyID string) error
DeleteTenancyScanPolicy removes one scoped scan policy by id.
func (*PostgresStore) DeleteUserIdentity ¶
func (p *PostgresStore) DeleteUserIdentity(ctx context.Context, provider string, subject string) error
DeleteUserIdentity removes one provider identity by provider and subject.
func (*PostgresStore) DeleteWebhookEvent ¶
func (p *PostgresStore) DeleteWebhookEvent(ctx context.Context, provider string, eventID string, claimToken string) error
DeleteWebhookEvent rolls back a claim so a provider retry can reprocess an event whose side effects failed transiently. The claim_token predicate makes a superseded stale handler's rollback a no-op so it cannot erase the successor's active claim.
func (*PostgresStore) DeleteWorkspace ¶
func (p *PostgresStore) DeleteWorkspace(ctx context.Context, workspaceID string) error
DeleteWorkspace deletes one scoped workspace by id.
func (*PostgresStore) DeleteWorkspaceMember ¶
func (p *PostgresStore) DeleteWorkspaceMember(ctx context.Context, workspaceID string, memberID string) error
DeleteWorkspaceMember removes one scoped member.
func (*PostgresStore) FailStaleRepoScansAnyScope ¶
func (p *PostgresStore) FailStaleRepoScansAnyScope(ctx context.Context, staleBefore time.Time, limit int, errorMessage string) (int, error)
FailStaleRepoScansAnyScope marks stale running repository scans failed across all scopes.
func (*PostgresStore) FindFirstWorkspaceMemberByUserUUID ¶
func (p *PostgresStore) FindFirstWorkspaceMemberByUserUUID(ctx context.Context, userUUID string) (TenancyWorkspaceMember, error)
FindFirstWorkspaceMemberByUserUUID returns the newest active workspace membership for one auth user.
func (*PostgresStore) FindFirstWorkspaceMemberByUserUUIDAndTenantID ¶
func (p *PostgresStore) FindFirstWorkspaceMemberByUserUUIDAndTenantID(ctx context.Context, userUUID string, tenantID string) (TenancyWorkspaceMember, error)
FindFirstWorkspaceMemberByUserUUIDAndTenantID returns the newest active workspace membership for one auth user in one tenant.
func (*PostgresStore) GetAuthzEntityAttributes ¶
func (p *PostgresStore) GetAuthzEntityAttributes(ctx context.Context, entityKind string, entityType string, entityID string) (AuthzEntityAttributes, error)
GetAuthzEntityAttributes returns trusted authorization attributes for one entity.
func (*PostgresStore) GetAuthzPolicyRollout ¶
func (p *PostgresStore) GetAuthzPolicyRollout(ctx context.Context, policySetID string) (AuthzPolicyRollout, error)
GetAuthzPolicyRollout returns one scoped rollout pointer row.
func (*PostgresStore) GetAuthzPolicySet ¶
func (p *PostgresStore) GetAuthzPolicySet(ctx context.Context, policySetID string) (AuthzPolicySet, error)
GetAuthzPolicySet returns one scoped policy set metadata record.
func (*PostgresStore) GetAuthzPolicyVersion ¶
func (p *PostgresStore) GetAuthzPolicyVersion(ctx context.Context, policySetID string, version int) (AuthzPolicyVersion, error)
GetAuthzPolicyVersion returns one immutable bundle version in scope.
func (*PostgresStore) GetFinding ¶
func (p *PostgresStore) GetFinding(ctx context.Context, findingID string, scanID string) (domain.Finding, error)
GetFinding returns one finding by id, optionally scoped to one scan id.
func (*PostgresStore) GetFindingTriageState ¶
func (p *PostgresStore) GetFindingTriageState(ctx context.Context, findingID string) (FindingTriageState, error)
GetFindingTriageState returns triage workflow state for one finding id.
func (*PostgresStore) GetIdentityConnection ¶
func (p *PostgresStore) GetIdentityConnection(ctx context.Context, orgID string, connectionID string) (IdentityConnection, error)
GetIdentityConnection returns one organization identity connection scaffold.
func (*PostgresStore) GetIdentityConnectionByID ¶
func (p *PostgresStore) GetIdentityConnectionByID(ctx context.Context, connectionID string) (IdentityConnection, error)
GetIdentityConnectionByID resolves a connection by its globally unique UUID, bypassing the org-scope filter applied by GetIdentityConnection. Used by entry points (SAML SP-initiated login) that do not know the org id in advance — the connection itself determines the org scope.
Uses queryRowContextAnyScope so the lookup runs without requiring a db.WithScope context, matching FindFirstWorkspaceMemberByUserUUIDAndTenantID. Under IDENTRAIL_POSTGRES_RLS_ENFORCED=true, the scoped path would short- circuit with ErrScopeRequired before reading any row because /auth/saml routes are unauthenticated entry points.
func (*PostgresStore) GetIdentityConnectionBySCIMBearerTokenHash ¶
func (p *PostgresStore) GetIdentityConnectionBySCIMBearerTokenHash(ctx context.Context, tokenHash string) (IdentityConnection, error)
GetIdentityConnectionBySCIMBearerTokenHash resolves a connection by its stored SCIM bearer-token hash without requiring an org-scoped context.
func (*PostgresStore) GetInvitation ¶
func (p *PostgresStore) GetInvitation(ctx context.Context, orgID string, invitationID string) (Invitation, error)
GetInvitation returns one organization invitation scaffold.
func (*PostgresStore) GetOnboardingState ¶
func (p *PostgresStore) GetOnboardingState(ctx context.Context, userID string) (OnboardingState, error)
GetOnboardingState returns one user's onboarding progress row.
func (*PostgresStore) GetOrganization ¶
func (p *PostgresStore) GetOrganization(ctx context.Context) (TenancyOrganization, error)
GetOrganization returns one scoped organization record.
func (*PostgresStore) GetProject ¶
func (p *PostgresStore) GetProject(ctx context.Context, workspaceID string, projectID string) (TenancyProject, error)
GetProject returns one scoped project.
func (*PostgresStore) GetRepoScan ¶
func (p *PostgresStore) GetRepoScan(ctx context.Context, repoScanID string) (RepoScanRecord, error)
GetRepoScan returns one repository scan by id.
func (*PostgresStore) GetRepoScanCursor ¶
func (p *PostgresStore) GetRepoScanCursor(ctx context.Context, repository string, source RepoScanSource) (RepoScanCursor, error)
GetRepoScanCursor returns the latest successful scan cursor for one repository source.
func (*PostgresStore) GetScan ¶
func (p *PostgresStore) GetScan(ctx context.Context, scanID string) (ScanRecord, error)
GetScan returns one scan by id.
func (*PostgresStore) GetTenancyConnector ¶
func (p *PostgresStore) GetTenancyConnector(ctx context.Context, workspaceID string, projectID string, connectorID string) (TenancyConnectorWithState, error)
GetTenancyConnector returns one connector and its latest state.
func (*PostgresStore) GetTenancyConnectorSecretEnvelope ¶
func (p *PostgresStore) GetTenancyConnectorSecretEnvelope(ctx context.Context, workspaceID string, projectID string, connectorID string, secretName string) (TenancyConnectorSecretEnvelope, error)
GetTenancyConnectorSecretEnvelope loads one encrypted connector secret envelope by name.
func (*PostgresStore) GetTenancyScanPolicy ¶
func (p *PostgresStore) GetTenancyScanPolicy(ctx context.Context, workspaceID string, projectID string, policyID string) (TenancyScanPolicy, error)
GetTenancyScanPolicy returns one scoped scan policy by id.
func (*PostgresStore) GetUserByPrimaryEmail ¶
GetUserByPrimaryEmail returns one account by normalized primary email.
func (*PostgresStore) GetUserIdentity ¶
func (p *PostgresStore) GetUserIdentity(ctx context.Context, provider string, subject string) (UserIdentity, error)
GetUserIdentity returns one provider identity by provider and subject.
func (*PostgresStore) GetUserIdentityByProviderUserID ¶
func (p *PostgresStore) GetUserIdentityByProviderUserID(ctx context.Context, provider string, userID string) (UserIdentity, error)
GetUserIdentityByProviderUserID returns one provider identity for a user.
func (*PostgresStore) GetVerifiedDomain ¶
func (p *PostgresStore) GetVerifiedDomain(ctx context.Context, orgID string, domainID string) (VerifiedDomain, error)
GetVerifiedDomain returns one organization domain-verification scaffold.
func (*PostgresStore) GetWorkspace ¶
func (p *PostgresStore) GetWorkspace(ctx context.Context, workspaceID string) (TenancyWorkspace, error)
GetWorkspace returns one scoped workspace by id.
func (*PostgresStore) GetWorkspaceMember ¶
func (p *PostgresStore) GetWorkspaceMember(ctx context.Context, workspaceID string, memberID string) (TenancyWorkspaceMember, error)
GetWorkspaceMember returns one scoped workspace member.
func (*PostgresStore) GetWorkspaceMemberByUserUUID ¶
func (p *PostgresStore) GetWorkspaceMemberByUserUUID(ctx context.Context, workspaceID string, userUUID string) (TenancyWorkspaceMember, error)
GetWorkspaceMemberByUserUUID returns one scoped workspace member by auth user UUID.
func (*PostgresStore) ListAllTenancyConnectorsByType ¶
func (p *PostgresStore) ListAllTenancyConnectorsByType(ctx context.Context, connectorType domain.ConnectorType, limit int) ([]TenancyConnectorWithState, error)
ListAllTenancyConnectorsByType returns connectors across all scopes for internal runtime matching.
func (*PostgresStore) ListAuthzPolicyEvents ¶
func (p *PostgresStore) ListAuthzPolicyEvents(ctx context.Context, policySetID string, limit int) ([]AuthzPolicyEvent, error)
ListAuthzPolicyEvents returns lifecycle events for one policy set (newest first).
func (*PostgresStore) ListAuthzPolicyVersions ¶
func (p *PostgresStore) ListAuthzPolicyVersions(ctx context.Context, policySetID string, limit int) ([]AuthzPolicyVersion, error)
ListAuthzPolicyVersions returns policy versions for one policy set ordered by newest first.
func (*PostgresStore) ListAuthzRelationships ¶
func (p *PostgresStore) ListAuthzRelationships(ctx context.Context, filter AuthzRelationshipFilter, limit int) ([]AuthzRelationship, error)
ListAuthzRelationships returns scoped ReBAC tuples using optional filters.
func (*PostgresStore) ListFindingMetasByScan ¶
func (p *PostgresStore) ListFindingMetasByScan(ctx context.Context, scanID string) ([]FindingMeta, error)
ListFindingMetasByScan returns lightweight finding metadata for one scan.
func (*PostgresStore) ListFindingTrendCounts ¶
func (p *PostgresStore) ListFindingTrendCounts(ctx context.Context, scanIDs []string, severity string, findingType string) ([]FindingTrendCount, error)
ListFindingTrendCounts aggregates finding totals per scan and severity.
func (*PostgresStore) ListFindingTriageEvents ¶
func (p *PostgresStore) ListFindingTriageEvents(ctx context.Context, findingID string, limit int) ([]FindingTriageEvent, error)
ListFindingTriageEvents returns triage history newest-first for one finding id.
func (*PostgresStore) ListFindingTriageStates ¶
func (p *PostgresStore) ListFindingTriageStates(ctx context.Context, findingIDs []string) ([]FindingTriageState, error)
ListFindingTriageStates returns triage states for provided finding ids.
func (*PostgresStore) ListFindings ¶
ListFindings returns latest findings first across scans.
func (*PostgresStore) ListFindingsAll ¶
ListFindingsAll returns all findings for current scope ordered by recency.
func (*PostgresStore) ListFindingsByScan ¶
func (p *PostgresStore) ListFindingsByScan(ctx context.Context, scanID string, limit int) ([]domain.Finding, error)
ListFindingsByScan returns latest findings first for one scan id.
func (*PostgresStore) ListFindingsByScanAndIDs ¶
func (p *PostgresStore) ListFindingsByScanAndIDs(ctx context.Context, scanID string, findingIDs []string) ([]domain.Finding, error)
ListFindingsByScanAndIDs returns detailed findings for one scan and ID set.
func (*PostgresStore) ListFindingsFiltered ¶
func (p *PostgresStore) ListFindingsFiltered(ctx context.Context, filter FindingListFilter) ([]domain.Finding, error)
ListFindingsFiltered returns one filtered findings page with stable persistence-level ordering.
func (*PostgresStore) ListIdentities ¶
func (p *PostgresStore) ListIdentities(ctx context.Context, filter IdentityFilter, limit int) ([]domain.Identity, error)
ListIdentities returns identities filtered by scan/provider/type/name prefix.
func (*PostgresStore) ListIdentityConnections ¶
func (p *PostgresStore) ListIdentityConnections(ctx context.Context, orgID string, limit int) ([]IdentityConnection, error)
ListIdentityConnections returns organization identity connection scaffolds ordered by newest first.
func (*PostgresStore) ListInvitations ¶
func (p *PostgresStore) ListInvitations(ctx context.Context, orgID string, limit int) ([]Invitation, error)
ListInvitations returns organization invitations ordered by newest first.
func (*PostgresStore) ListProjects ¶
func (p *PostgresStore) ListProjects(ctx context.Context, workspaceID string, includeArchived bool, limit int) ([]TenancyProject, error)
ListProjects returns scoped projects for a workspace.
func (*PostgresStore) ListRelationships ¶
func (p *PostgresStore) ListRelationships(ctx context.Context, filter RelationshipFilter, limit int) ([]domain.Relationship, error)
ListRelationships returns relationships filtered by scan/type/from/to.
func (*PostgresStore) ListRepoFindingClusters ¶
func (p *PostgresStore) ListRepoFindingClusters(ctx context.Context, filter RepoFindingClusterListFilter) ([]domain.RepoFindingCluster, error)
ListRepoFindingClusters returns repository finding clusters with bounded store-side pagination.
func (*PostgresStore) ListRepoFindingTrendCounts ¶
func (p *PostgresStore) ListRepoFindingTrendCounts(ctx context.Context, repoScanIDs []string, severity string, findingType string) ([]FindingTrendCount, error)
ListRepoFindingTrendCounts aggregates repository finding totals by repo scan and severity.
func (*PostgresStore) ListRepoFindings ¶
func (p *PostgresStore) ListRepoFindings(ctx context.Context, filter RepoFindingFilter, limit int) ([]domain.Finding, error)
ListRepoFindings returns latest repository findings first with optional filters.
func (*PostgresStore) ListRepoScans ¶
func (p *PostgresStore) ListRepoScans(ctx context.Context, limit int) ([]RepoScanRecord, error)
ListRepoScans returns latest repository scans first.
func (*PostgresStore) ListSCIMProvisioningEvents ¶
func (p *PostgresStore) ListSCIMProvisioningEvents(ctx context.Context, orgID string, connectionID string, limit int) ([]SCIMProvisioningEventRecord, error)
ListSCIMProvisioningEvents returns events for one connection ordered newest first, capped at limit (default 100).
func (*PostgresStore) ListScanEvents ¶
func (p *PostgresStore) ListScanEvents(ctx context.Context, scanID string, limit int) ([]ScanEvent, error)
ListScanEvents returns latest event entries for one scan.
func (*PostgresStore) ListScans ¶
func (p *PostgresStore) ListScans(ctx context.Context, limit int) ([]ScanRecord, error)
ListScans returns latest scans first.
func (*PostgresStore) ListScheduledTenancyScanPolicies ¶
func (p *PostgresStore) ListScheduledTenancyScanPolicies(ctx context.Context, limit int, offset int) ([]TenancyScanPolicy, error)
ListScheduledTenancyScanPolicies returns enabled scheduled policies for worker execution.
func (*PostgresStore) ListTenancyConnectors ¶
func (p *PostgresStore) ListTenancyConnectors(ctx context.Context, workspaceID string, projectID string, connectorType domain.ConnectorType, limit int) ([]TenancyConnectorWithState, error)
ListTenancyConnectors returns scoped connectors ordered by most recent update.
func (*PostgresStore) ListTenancyConnectorsUnscoped ¶
func (p *PostgresStore) ListTenancyConnectorsUnscoped(ctx context.Context, connectorType domain.ConnectorType, limit int) ([]TenancyConnectorWithState, error)
ListTenancyConnectorsUnscoped returns connectors across all scopes for internal webhook dispatch.
func (*PostgresStore) ListTenancyScanPolicies ¶
func (p *PostgresStore) ListTenancyScanPolicies(ctx context.Context, workspaceID string, projectID string, triggerMode domain.ScanTriggerMode, enabled *bool, sortBy string, sortDesc bool, limit int) ([]TenancyScanPolicy, error)
ListTenancyScanPolicies returns scoped scan policies ordered before limiting.
func (*PostgresStore) ListUserIdentitiesByProvider ¶
func (p *PostgresStore) ListUserIdentitiesByProvider(ctx context.Context, provider string, limit int) ([]UserIdentity, error)
ListUserIdentitiesByProvider returns provider identities ordered by newest first. A non-positive limit returns all matching identities.
func (*PostgresStore) ListUserSessions ¶
func (p *PostgresStore) ListUserSessions(ctx context.Context, userID string, now time.Time, limit int) ([]Session, error)
ListUserSessions returns active sessions for one user.
func (*PostgresStore) ListVerifiedDomains ¶
func (p *PostgresStore) ListVerifiedDomains(ctx context.Context, orgID string, limit int) ([]VerifiedDomain, error)
ListVerifiedDomains returns organization domain-verification scaffolds ordered by newest first.
func (*PostgresStore) ListWorkspaceMembers ¶
func (p *PostgresStore) ListWorkspaceMembers(ctx context.Context, workspaceID string, limit int) ([]TenancyWorkspaceMember, error)
ListWorkspaceMembers lists members for one scoped workspace.
func (*PostgresStore) ListWorkspaceMembershipsByUserUUIDAndTenantID ¶
func (p *PostgresStore) ListWorkspaceMembershipsByUserUUIDAndTenantID(ctx context.Context, userUUID string, tenantID string) ([]TenancyWorkspaceMember, error)
ListWorkspaceMembershipsByUserUUIDAndTenantID returns every active workspace membership the user holds within one tenant. It is the authorization basis for organization-wide reads: a caller may only aggregate data from the workspaces they actually belong to. AnyScope is used because the lookup spans every workspace in the tenant rather than one scoped workspace.
func (*PostgresStore) ListWorkspaces ¶
func (p *PostgresStore) ListWorkspaces(ctx context.Context, limit int) ([]TenancyWorkspace, error)
ListWorkspaces returns all tenant-scoped workspaces ordered by creation time.
func (*PostgresStore) RequeueRepoScan ¶
func (p *PostgresStore) RequeueRepoScan(ctx context.Context, repoScanID string) error
RequeueRepoScan moves one running repository scan back to queued.
func (*PostgresStore) RevokeAllUserSessions ¶
func (p *PostgresStore) RevokeAllUserSessions(ctx context.Context, userID string, revokedAt time.Time) (int, error)
RevokeAllUserSessions revokes every active session for one user.
func (*PostgresStore) RevokeInvitation ¶
func (p *PostgresStore) RevokeInvitation(ctx context.Context, orgID string, invitationID string, revokedAt time.Time) (Invitation, error)
RevokeInvitation marks one pending invitation revoked.
func (*PostgresStore) RevokeOtherUserSessions ¶
func (p *PostgresStore) RevokeOtherUserSessions(ctx context.Context, userID string, currentSessionIDHash []byte, revokedAt time.Time) (int, error)
RevokeOtherUserSessions revokes every active session except the caller's.
func (*PostgresStore) RevokeUserSession ¶
func (p *PostgresStore) RevokeUserSession(ctx context.Context, userID string, sessionIDHash []byte, revokedAt time.Time) (Session, error)
RevokeUserSession revokes one active session if it belongs to the user.
func (*PostgresStore) ScheduleScanRetry ¶
func (p *PostgresStore) ScheduleScanRetry(ctx context.Context, scanID string, queuedAt time.Time, retryCount int, maxRetryCount int, failureCategory string, errorMessage string, nextRetryAt time.Time) error
ScheduleScanRetry moves a failed scan attempt back into the queue with delay metadata.
func (*PostgresStore) ScopeRLSEnforcementEnabled ¶
func (p *PostgresStore) ScopeRLSEnforcementEnabled() bool
ScopeRLSEnforcementEnabled returns true when scoped RLS enforcement is enabled.
func (*PostgresStore) SetScopeRLSEnforcement ¶
func (p *PostgresStore) SetScopeRLSEnforcement(enabled bool)
SetScopeRLSEnforcement toggles statement-level RLS enforcement with scoped GUCs.
func (*PostgresStore) SummarizeFindings ¶
func (p *PostgresStore) SummarizeFindings(ctx context.Context) (FindingSummaryCounts, error)
SummarizeFindings returns aggregate counters for current scope.
func (*PostgresStore) TouchSession ¶
func (p *PostgresStore) TouchSession(ctx context.Context, sessionIDHash []byte, now time.Time) (Session, error)
TouchSession renews idle expiry and returns the joined session/user row.
func (*PostgresStore) UpdateIdentityConnection ¶
func (p *PostgresStore) UpdateIdentityConnection(ctx context.Context, connection IdentityConnection) (IdentityConnection, error)
UpdateIdentityConnection replaces a persisted identity connection row keyed on (org_id, id). Returns ErrNotFound when no matching row exists.
func (*PostgresStore) UpdateSessionContext ¶
func (p *PostgresStore) UpdateSessionContext(ctx context.Context, userID string, sessionIDHash []byte, orgID string, workspaceID string, projectID string, now time.Time) (Session, error)
UpdateSessionContext persists the active tenancy context for one browser session.
func (*PostgresStore) UpsertArtifacts ¶
func (p *PostgresStore) UpsertArtifacts(ctx context.Context, scanID string, artifacts ScanArtifacts) error
UpsertArtifacts inserts raw and normalized artifacts idempotently for one scan.
func (*PostgresStore) UpsertAuthzEntityAttributes ¶
func (p *PostgresStore) UpsertAuthzEntityAttributes(ctx context.Context, attributes AuthzEntityAttributes) error
UpsertAuthzEntityAttributes creates or updates trusted authorization attributes.
func (*PostgresStore) UpsertAuthzPolicyRollout ¶
func (p *PostgresStore) UpsertAuthzPolicyRollout(ctx context.Context, rollout AuthzPolicyRollout) error
UpsertAuthzPolicyRollout creates or updates one scoped rollout pointer row.
func (*PostgresStore) UpsertAuthzPolicySet ¶
func (p *PostgresStore) UpsertAuthzPolicySet(ctx context.Context, policySet AuthzPolicySet) error
UpsertAuthzPolicySet creates or updates one scoped policy set metadata record.
func (*PostgresStore) UpsertAuthzRelationship ¶
func (p *PostgresStore) UpsertAuthzRelationship(ctx context.Context, relationship AuthzRelationship) error
UpsertAuthzRelationship creates or updates one scoped ReBAC tuple.
func (*PostgresStore) UpsertFindingTriageState ¶
func (p *PostgresStore) UpsertFindingTriageState(ctx context.Context, state FindingTriageState) error
UpsertFindingTriageState creates or updates mutable triage metadata.
func (*PostgresStore) UpsertFindings ¶
func (p *PostgresStore) UpsertFindings(ctx context.Context, scanID string, findings []domain.Finding) error
UpsertFindings inserts findings idempotently for the scan.
func (*PostgresStore) UpsertOnboardingState ¶
func (p *PostgresStore) UpsertOnboardingState(ctx context.Context, state OnboardingState) (OnboardingState, error)
UpsertOnboardingState persists one user-scoped onboarding progress row.
func (*PostgresStore) UpsertOrganization ¶
func (p *PostgresStore) UpsertOrganization(ctx context.Context, organization TenancyOrganization) error
UpsertOrganization persists one scoped organization metadata row.
func (*PostgresStore) UpsertProject ¶
func (p *PostgresStore) UpsertProject(ctx context.Context, project TenancyProject) error
UpsertProject persists one scoped project record.
func (*PostgresStore) UpsertRepoFindings ¶
func (p *PostgresStore) UpsertRepoFindings(ctx context.Context, repoScanID string, findings []domain.Finding) error
UpsertRepoFindings inserts repository findings idempotently.
func (*PostgresStore) UpsertRepoScanCursor ¶
func (p *PostgresStore) UpsertRepoScanCursor(ctx context.Context, cursor RepoScanCursor) error
UpsertRepoScanCursor stores the latest successful scan cursor for one repository source.
func (*PostgresStore) UpsertTenancyConnector ¶
func (p *PostgresStore) UpsertTenancyConnector(ctx context.Context, connector TenancyConnector, state TenancyConnectorState) error
UpsertTenancyConnector persists one connector and its latest state atomically.
func (*PostgresStore) UpsertTenancyConnectorSecretEnvelope ¶
func (p *PostgresStore) UpsertTenancyConnectorSecretEnvelope(ctx context.Context, envelope TenancyConnectorSecretEnvelope) error
UpsertTenancyConnectorSecretEnvelope persists one encrypted connector secret envelope.
func (*PostgresStore) UpsertTenancyScanPolicy ¶
func (p *PostgresStore) UpsertTenancyScanPolicy(ctx context.Context, policy TenancyScanPolicy) error
UpsertTenancyScanPolicy persists one scan policy for a scoped project.
func (*PostgresStore) UpsertUser ¶
UpsertUser persists one account row.
func (*PostgresStore) UpsertUserIdentity ¶
func (p *PostgresStore) UpsertUserIdentity(ctx context.Context, identity UserIdentity) (UserIdentity, error)
UpsertUserIdentity persists one provider identity mapping.
func (*PostgresStore) UpsertWorkspace ¶
func (p *PostgresStore) UpsertWorkspace(ctx context.Context, workspace TenancyWorkspace) error
UpsertWorkspace persists one scoped workspace record.
func (*PostgresStore) UpsertWorkspaceMember ¶
func (p *PostgresStore) UpsertWorkspaceMember(ctx context.Context, member TenancyWorkspaceMember) error
UpsertWorkspaceMember persists one scoped workspace member record.
type RelationshipFilter ¶
RelationshipFilter controls relationship list query shape.
type RepoFindingClusterListFilter ¶
type RepoFindingClusterListFilter struct {
RepoScanID string
Severity string
Type string
SortBy string
SortDesc bool
Limit int
Offset int
}
RepoFindingClusterListFilter controls repository finding cluster list queries.
func NormalizeRepoFindingClusterListFilter ¶
func NormalizeRepoFindingClusterListFilter(filter RepoFindingClusterListFilter) RepoFindingClusterListFilter
NormalizeRepoFindingClusterListFilter trims inputs and applies stable defaults.
type RepoFindingFilter ¶
type RepoFindingFilter struct {
RepoScanID string
FindingID string
Repository string
Severity string
Type string
Status string
Detector string
Owner string
MinConfidence float64
MinAgeDays int
LifecycleStatus string
Assignee string
SortBy string
SortDesc bool
Now time.Time
IncludeHistorical bool
}
RepoFindingFilter controls repository finding list queries.
func NormalizeRepoFindingFilter ¶
func NormalizeRepoFindingFilter(filter RepoFindingFilter) RepoFindingFilter
NormalizeRepoFindingFilter trims optional filters for repository findings.
type RepoScanContext ¶
type RepoScanContext struct {
ScanMode string
BaseRevision string
HeadRevision string
CursorBefore string
CursorAfter string
ChangedPaths []string
}
RepoScanContext captures incremental execution metadata for one scan.
func NormalizeRepoScanContext ¶
func NormalizeRepoScanContext(scanContext RepoScanContext) RepoScanContext
NormalizeRepoScanContext returns stable scan-mode and revision metadata.
type RepoScanCursor ¶
type RepoScanCursor struct {
TenantID string `json:"-"`
WorkspaceID string `json:"-"`
Repository string `json:"repository"`
Source RepoScanSource `json:"-"`
LastScannedRevision string `json:"last_scanned_revision,omitempty"`
LastDeepScannedAt *time.Time `json:"last_deep_scanned_at,omitempty"`
LastScanID string `json:"last_scan_id,omitempty"`
LastScanMode string `json:"last_scan_mode,omitempty"`
LastScanCompletedAt time.Time `json:"last_scan_completed_at"`
UpdatedAt time.Time `json:"updated_at"`
}
RepoScanCursor stores the latest scanned revision for one scoped repository source.
func (RepoScanCursor) Normalize ¶
func (c RepoScanCursor) Normalize() RepoScanCursor
Normalize returns a stable cursor key and payload.
type RepoScanRecord ¶
type RepoScanRecord struct {
ID string `json:"id"`
TenantID string `json:"-"`
WorkspaceID string `json:"-"`
Repository string `json:"repository"`
Status string `json:"status"`
StartedAt time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
CommitsScanned int `json:"commits_scanned"`
FilesScanned int `json:"files_scanned"`
FindingCount int `json:"finding_count"`
Truncated bool `json:"truncated"`
ScanMode string `json:"scan_mode"`
BaseRevision string `json:"base_revision,omitempty"`
HeadRevision string `json:"head_revision,omitempty"`
CursorBefore string `json:"cursor_before,omitempty"`
CursorAfter string `json:"cursor_after,omitempty"`
ChangedPaths []string `json:"changed_paths,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
HistoryLimit int `json:"-"`
MaxFindings int `json:"-"`
Source RepoScanSource `json:"-"`
TraceParent string `json:"-"`
TraceState string `json:"-"`
}
RepoScanRecord tracks persisted repository exposure scan metadata.
type RepoScanSource ¶
type RepoScanSource struct {
Provider string
ProjectID string
ConnectorID string
InstallationID int64
}
RepoScanSource carries non-secret connector context for repository scans. It lets workers resolve short-lived credentials at execution time without persisting raw tokens in the queue.
func (RepoScanSource) Empty ¶
func (s RepoScanSource) Empty() bool
Empty reports whether the scan has no connector-backed source.
func (RepoScanSource) Normalize ¶
func (s RepoScanSource) Normalize() RepoScanSource
Normalize returns a copy with stable whitespace/casing.
type SAMLRelayState ¶
type SAMLRelayState struct {
Handle string `json:"handle"`
ConnectionID string `json:"connection_id"`
SAMLRequestID string `json:"saml_request_id"`
ReturnTo string `json:"return_to,omitempty"`
Intent string `json:"intent"`
ExpiresAt time.Time `json:"expires_at"`
CreatedAt time.Time `json:"created_at"`
ConsumedAt *time.Time `json:"consumed_at,omitempty"`
}
SAMLRelayState is the persisted SP-side context for one in-flight SAML SP-initiated AuthnRequest. The handle is the short opaque token that travels through the IdP as RelayState; the row is one-shot consumed by the ACS handler.
type SCIMProvisioningEventRecord ¶
type SCIMProvisioningEventRecord struct {
ID string `json:"id"`
OrgID string `json:"org_id"`
ConnectionID string `json:"connection_id"`
Op string `json:"op"`
ExternalID string `json:"external_id,omitempty"`
UserID string `json:"user_id,omitempty"`
Payload map[string]any `json:"payload,omitempty"`
OccurredAt time.Time `json:"occurred_at"`
}
SCIMProvisioningEventRecord is the persisted form of one SCIM op recorded for tenant-visible governance audit. Append-only.
func NormalizeSCIMProvisioningEventForWrite ¶
func NormalizeSCIMProvisioningEventForWrite(event SCIMProvisioningEventRecord) (SCIMProvisioningEventRecord, error)
NormalizeSCIMProvisioningEventForWrite validates and canonicalizes one persisted SCIM provisioning event prior to insert.
type ScanArtifacts ¶
type ScanArtifacts struct {
RawAssets []providers.RawAsset
Bundle providers.NormalizedBundle
Permissions []providers.PermissionTuple
Relationships []domain.Relationship
}
ScanArtifacts contains raw and normalized scan outputs to persist idempotently.
type ScanEvent ¶
type ScanEvent struct {
ID string `json:"id"`
ScanID string `json:"scan_id"`
Level string `json:"level"`
Message string `json:"message"`
Metadata map[string]any `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
ScanEvent tracks important state transitions for scan observability.
type ScanRecord ¶
type ScanRecord struct {
ID string `json:"id"`
TenantID string `json:"-"`
WorkspaceID string `json:"-"`
Provider string `json:"provider"`
Status string `json:"status"`
StartedAt time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
AssetCount int `json:"asset_count"`
FindingCount int `json:"finding_count"`
ErrorMessage string `json:"error_message,omitempty"`
RetryCount int `json:"retry_count"`
MaxRetryCount int `json:"max_retry_count"`
FailureCategory string `json:"failure_category,omitempty"`
NextRetryAt *time.Time `json:"next_retry_at,omitempty"`
DeadLettered bool `json:"dead_lettered"`
DeadLetteredAt *time.Time `json:"dead_lettered_at,omitempty"`
TraceParent string `json:"-"`
TraceState string `json:"-"`
}
ScanRecord tracks persisted scan execution metadata.
type Scope ¶
Scope represents the active tenant/workspace boundary for a request.
func LookupScope ¶
LookupScope returns scope from context when present.
func RequireScope ¶
RequireScope returns the active scope and fails when context is unscoped.
func ScopeFromContext ¶
ScopeFromContext always returns a non-empty scope.
type Session ¶
type Session struct {
ID []byte `json:"-"`
UserID string `json:"user_id"`
CurrentOrgID string `json:"current_org_id,omitempty"`
CurrentWorkspaceID string `json:"current_workspace_id,omitempty"`
CurrentProjectID string `json:"current_project_id,omitempty"`
AuthMethod string `json:"auth_method"`
IP string `json:"ip,omitempty"`
UserAgent string `json:"user_agent,omitempty"`
IdleExpiresAt time.Time `json:"idle_expires_at"`
AbsoluteExpiresAt time.Time `json:"absolute_expires_at"`
LastSeenAt time.Time `json:"last_seen_at"`
RevokedAt *time.Time `json:"revoked_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
User *User `json:"user,omitempty"`
}
Session stores one opaque server-side browser session.
func NormalizeSessionForWrite ¶
NormalizeSessionForWrite validates and canonicalizes one session row.
type Store ¶
type Store interface {
CreateScan(ctx context.Context, provider string, startedAt time.Time) (ScanRecord, error)
CreateQueuedScan(ctx context.Context, provider string, queuedAt time.Time) (ScanRecord, error)
CreateQueuedScanWithinLimit(ctx context.Context, provider string, queuedAt time.Time, maxPending int) (ScanRecord, error)
CreateQueuedScanIfNoPending(ctx context.Context, provider string, queuedAt time.Time) (ScanRecord, error)
ClaimNextQueuedScan(ctx context.Context, provider string) (ScanRecord, error)
ClaimNextQueuedScanAnyScope(ctx context.Context, provider string) (ScanRecord, error)
CountQueuedScans(ctx context.Context, provider string) (int, error)
GetScan(ctx context.Context, scanID string) (ScanRecord, error)
CompleteScan(ctx context.Context, scanID string, status string, finishedAt time.Time, assetCount int, findingCount int, errorMessage string) error
ScheduleScanRetry(ctx context.Context, scanID string, queuedAt time.Time, retryCount int, maxRetryCount int, failureCategory string, errorMessage string, nextRetryAt time.Time) error
DeadLetterScan(ctx context.Context, scanID string, finishedAt time.Time, retryCount int, maxRetryCount int, assetCount int, findingCount int, failureCategory string, errorMessage string) error
UpsertArtifacts(ctx context.Context, scanID string, artifacts ScanArtifacts) error
UpsertFindings(ctx context.Context, scanID string, findings []domain.Finding) error
GetFindingTriageState(ctx context.Context, findingID string) (FindingTriageState, error)
ListFindingTriageStates(ctx context.Context, findingIDs []string) ([]FindingTriageState, error)
UpsertFindingTriageState(ctx context.Context, state FindingTriageState) error
AppendFindingTriageEvent(ctx context.Context, event FindingTriageEvent) error
ApplyFindingTriageTransition(ctx context.Context, state FindingTriageState, event FindingTriageEvent) error
ListFindingTriageEvents(ctx context.Context, findingID string, limit int) ([]FindingTriageEvent, error)
ListScans(ctx context.Context, limit int) ([]ScanRecord, error)
ListFindings(ctx context.Context, limit int) ([]domain.Finding, error)
ListFindingsFiltered(ctx context.Context, filter FindingListFilter) ([]domain.Finding, error)
ListFindingsAll(ctx context.Context) ([]domain.Finding, error)
ListFindingsByScan(ctx context.Context, scanID string, limit int) ([]domain.Finding, error)
GetFinding(ctx context.Context, findingID string, scanID string) (domain.Finding, error)
ListFindingMetasByScan(ctx context.Context, scanID string) ([]FindingMeta, error)
ListFindingsByScanAndIDs(ctx context.Context, scanID string, findingIDs []string) ([]domain.Finding, error)
ListFindingTrendCounts(ctx context.Context, scanIDs []string, severity string, findingType string) ([]FindingTrendCount, error)
ListRepoFindingTrendCounts(ctx context.Context, repoScanIDs []string, severity string, findingType string) ([]FindingTrendCount, error)
UpsertAuthzEntityAttributes(ctx context.Context, attributes AuthzEntityAttributes) error
GetAuthzEntityAttributes(ctx context.Context, entityKind string, entityType string, entityID string) (AuthzEntityAttributes, error)
UpsertAuthzRelationship(ctx context.Context, relationship AuthzRelationship) error
DeleteAuthzRelationship(ctx context.Context, relationship AuthzRelationship) error
ListAuthzRelationships(ctx context.Context, filter AuthzRelationshipFilter, limit int) ([]AuthzRelationship, error)
UpsertAuthzPolicySet(ctx context.Context, policySet AuthzPolicySet) error
GetAuthzPolicySet(ctx context.Context, policySetID string) (AuthzPolicySet, error)
CreateAuthzPolicyVersion(ctx context.Context, version AuthzPolicyVersion) (AuthzPolicyVersion, error)
GetAuthzPolicyVersion(ctx context.Context, policySetID string, version int) (AuthzPolicyVersion, error)
ListAuthzPolicyVersions(ctx context.Context, policySetID string, limit int) ([]AuthzPolicyVersion, error)
UpsertAuthzPolicyRollout(ctx context.Context, rollout AuthzPolicyRollout) error
GetAuthzPolicyRollout(ctx context.Context, policySetID string) (AuthzPolicyRollout, error)
AppendAuthzPolicyEvent(ctx context.Context, event AuthzPolicyEvent) error
ListAuthzPolicyEvents(ctx context.Context, policySetID string, limit int) ([]AuthzPolicyEvent, error)
UpsertOrganization(ctx context.Context, organization TenancyOrganization) error
GetOrganization(ctx context.Context) (TenancyOrganization, error)
DeleteOrganization(ctx context.Context) error
UpsertWorkspace(ctx context.Context, workspace TenancyWorkspace) error
GetWorkspace(ctx context.Context, workspaceID string) (TenancyWorkspace, error)
ListWorkspaces(ctx context.Context, limit int) ([]TenancyWorkspace, error)
DeleteWorkspace(ctx context.Context, workspaceID string) error
UpsertWorkspaceMember(ctx context.Context, member TenancyWorkspaceMember) error
GetWorkspaceMember(ctx context.Context, workspaceID string, memberID string) (TenancyWorkspaceMember, error)
GetWorkspaceMemberByUserUUID(ctx context.Context, workspaceID string, userUUID string) (TenancyWorkspaceMember, error)
ListWorkspaceMembers(ctx context.Context, workspaceID string, limit int) ([]TenancyWorkspaceMember, error)
DeleteWorkspaceMember(ctx context.Context, workspaceID string, memberID string) error
UpsertProject(ctx context.Context, project TenancyProject) error
GetProject(ctx context.Context, workspaceID string, projectID string) (TenancyProject, error)
ListProjects(ctx context.Context, workspaceID string, includeArchived bool, limit int) ([]TenancyProject, error)
DeleteProject(ctx context.Context, workspaceID string, projectID string) error
UpsertTenancyConnector(ctx context.Context, connector TenancyConnector, state TenancyConnectorState) error
GetTenancyConnector(ctx context.Context, workspaceID string, projectID string, connectorID string) (TenancyConnectorWithState, error)
ListTenancyConnectors(ctx context.Context, workspaceID string, projectID string, connectorType domain.ConnectorType, limit int) ([]TenancyConnectorWithState, error)
ListTenancyConnectorsUnscoped(ctx context.Context, connectorType domain.ConnectorType, limit int) ([]TenancyConnectorWithState, error)
ClaimKubernetesEnrollmentToken(ctx context.Context, workspaceID string, projectID string, connectorID string, expectedEnrollmentTokenHash string, updatedMetadata map[string]any, status domain.ConnectorStatus, health string, lastErrorCode string, lastErrorMessage string, observedAt time.Time, updatedAt time.Time) (bool, error)
UpsertTenancyScanPolicy(ctx context.Context, policy TenancyScanPolicy) error
GetTenancyScanPolicy(ctx context.Context, workspaceID string, projectID string, policyID string) (TenancyScanPolicy, error)
ListTenancyScanPolicies(ctx context.Context, workspaceID string, projectID string, triggerMode domain.ScanTriggerMode, enabled *bool, sortBy string, sortDesc bool, limit int) ([]TenancyScanPolicy, error)
ListScheduledTenancyScanPolicies(ctx context.Context, limit int, offset int) ([]TenancyScanPolicy, error)
ClaimTenancyScanPolicySchedule(ctx context.Context, workspaceID string, projectID string, policyID string, scheduledAt time.Time, now time.Time) (bool, error)
DeleteTenancyScanPolicy(ctx context.Context, workspaceID string, projectID string, policyID string) error
UpsertTenancyConnectorSecretEnvelope(ctx context.Context, envelope TenancyConnectorSecretEnvelope) error
GetTenancyConnectorSecretEnvelope(ctx context.Context, workspaceID string, projectID string, connectorID string, secretName string) (TenancyConnectorSecretEnvelope, error)
DeleteTenancyConnectorSecretEnvelope(ctx context.Context, workspaceID string, projectID string, connectorID string, secretName string) error
UpsertUser(ctx context.Context, user User) (User, error)
GetUser(ctx context.Context, userID string) (User, error)
GetUserByPrimaryEmail(ctx context.Context, email string) (User, error)
UpsertUserIdentity(ctx context.Context, identity UserIdentity) (UserIdentity, error)
GetUserIdentity(ctx context.Context, provider string, subject string) (UserIdentity, error)
GetUserIdentityByProviderUserID(ctx context.Context, provider string, userID string) (UserIdentity, error)
ListUserIdentitiesByProvider(ctx context.Context, provider string, limit int) ([]UserIdentity, error)
DeleteUserIdentity(ctx context.Context, provider string, subject string) error
CreateSession(ctx context.Context, session Session) (Session, error)
TouchSession(ctx context.Context, sessionIDHash []byte, now time.Time) (Session, error)
UpdateSessionContext(ctx context.Context, userID string, sessionIDHash []byte, orgID string, workspaceID string, projectID string, now time.Time) (Session, error)
ListUserSessions(ctx context.Context, userID string, now time.Time, limit int) ([]Session, error)
RevokeUserSession(ctx context.Context, userID string, sessionIDHash []byte, revokedAt time.Time) (Session, error)
RevokeOtherUserSessions(ctx context.Context, userID string, currentSessionIDHash []byte, revokedAt time.Time) (int, error)
RevokeAllUserSessions(ctx context.Context, userID string, revokedAt time.Time) (int, error)
UpsertOnboardingState(ctx context.Context, state OnboardingState) (OnboardingState, error)
GetOnboardingState(ctx context.Context, userID string) (OnboardingState, error)
FindFirstWorkspaceMemberByUserUUID(ctx context.Context, userUUID string) (TenancyWorkspaceMember, error)
FindFirstWorkspaceMemberByUserUUIDAndTenantID(ctx context.Context, userUUID string, tenantID string) (TenancyWorkspaceMember, error)
ListWorkspaceMembershipsByUserUUIDAndTenantID(ctx context.Context, userUUID string, tenantID string) ([]TenancyWorkspaceMember, error)
CreateInvitation(ctx context.Context, invitation Invitation) (Invitation, error)
GetInvitation(ctx context.Context, orgID string, invitationID string) (Invitation, error)
ListInvitations(ctx context.Context, orgID string, limit int) ([]Invitation, error)
RevokeInvitation(ctx context.Context, orgID string, invitationID string, revokedAt time.Time) (Invitation, error)
CreateVerifiedDomain(ctx context.Context, domain VerifiedDomain) (VerifiedDomain, error)
GetVerifiedDomain(ctx context.Context, orgID string, domainID string) (VerifiedDomain, error)
ListVerifiedDomains(ctx context.Context, orgID string, limit int) ([]VerifiedDomain, error)
CreateIdentityConnection(ctx context.Context, connection IdentityConnection) (IdentityConnection, error)
GetIdentityConnection(ctx context.Context, orgID string, connectionID string) (IdentityConnection, error)
// GetIdentityConnectionByID looks up a connection by its globally unique
// UUID without requiring the caller to know the owning org id. Needed
// for unauthenticated entry points like /auth/saml/login/:connection_id
// where the org context is determined by the connection itself.
GetIdentityConnectionByID(ctx context.Context, connectionID string) (IdentityConnection, error)
GetIdentityConnectionBySCIMBearerTokenHash(ctx context.Context, tokenHash string) (IdentityConnection, error)
// CreateSAMLRelayState persists one in-flight SAML SP-initiated request
// so the matching ACS POST (potentially handled by a different API
// instance) can look the AuthnRequest id, connection scope, and
// return_to back up by the opaque handle.
CreateSAMLRelayState(ctx context.Context, state SAMLRelayState) (SAMLRelayState, error)
// ConsumeSAMLRelayState marks the row consumed and returns the persisted
// state. A subsequent call with the same handle returns ErrNotFound so
// the relay value cannot be replayed.
ConsumeSAMLRelayState(ctx context.Context, handle string, now time.Time) (SAMLRelayState, error)
// CreateOAuthTransaction persists one in-flight WorkOS OAuth login so the
// callback (potentially handled by a different API instance) can match
// the signed state nonce and browser-bound cookie token against a
// single-use, short-TTL row.
CreateOAuthTransaction(ctx context.Context, txn OAuthTransaction) (OAuthTransaction, error)
// ConsumeOAuthTransaction atomically consumes the row matching nonce and
// cookieToken when it is unexpired and unconsumed, returning the stored
// transaction. Any later, expired, missing, or cookie-mismatched call
// returns ErrNotFound so the OAuth state cannot be replayed.
ConsumeOAuthTransaction(ctx context.Context, nonce string, cookieToken string, now time.Time) (OAuthTransaction, error)
// BeginWebhookEvent atomically claims a provider webhook event for
// processing. It returns WebhookEventClaimed when this delivery inserted
// the row (or reclaimed a stale in-flight row older than
// WebhookProcessingReclaimAfter) and must apply the side effects;
// WebhookEventProcessing when another delivery of the same event is
// still in flight (the caller must return a retryable response, never a
// success acknowledgement); and WebhookEventProcessed when the event was
// already fully handled (the caller returns a no-op success). Atomic at
// the database, so it holds across restarts and concurrent API
// instances.
// When the status is WebhookEventClaimed the returned claim token
// identifies this specific claim; it must be passed back to
// CompleteWebhookEvent / DeleteWebhookEvent so a handler whose claim was
// reclaimed (because it ran past WebhookProcessingReclaimAfter and a
// retry took over) cannot complete or erase the successor's claim. The
// token is empty for the non-claimed statuses.
BeginWebhookEvent(ctx context.Context, event WebhookEvent, now time.Time) (WebhookEventStatus, string, error)
// CompleteWebhookEvent marks a claimed event as fully processed so later
// duplicate deliveries become no-op successes. Called after side effects
// are durably applied, or for a deterministic terminal outcome (bad
// payload, identity conflict) that an identical retry would not resolve.
// It only acts on the row if claimToken still matches the active claim,
// so a superseded stale handler cannot mark the successor's in-flight
// claim processed.
CompleteWebhookEvent(ctx context.Context, provider string, eventID string, claimToken string, now time.Time) error
// DeleteWebhookEvent rolls back a claimed webhook row when a transient
// (server-side) failure prevented the side effects from being applied,
// so a provider retry can reprocess it. It only deletes the row if
// claimToken still matches the active claim, so a superseded stale
// handler cannot erase the successor's claim.
DeleteWebhookEvent(ctx context.Context, provider string, eventID string, claimToken string) error
ListIdentityConnections(ctx context.Context, orgID string, limit int) ([]IdentityConnection, error)
UpdateIdentityConnection(ctx context.Context, connection IdentityConnection) (IdentityConnection, error)
DeleteIdentityConnection(ctx context.Context, orgID string, connectionID string) error
CreateSCIMProvisioningEvent(ctx context.Context, event SCIMProvisioningEventRecord) (SCIMProvisioningEventRecord, error)
ListSCIMProvisioningEvents(ctx context.Context, orgID string, connectionID string, limit int) ([]SCIMProvisioningEventRecord, error)
ListIdentities(ctx context.Context, filter IdentityFilter, limit int) ([]domain.Identity, error)
ListRelationships(ctx context.Context, filter RelationshipFilter, limit int) ([]domain.Relationship, error)
AppendScanEvent(ctx context.Context, scanID string, level string, message string, metadata map[string]any) error
ListScanEvents(ctx context.Context, scanID string, limit int) ([]ScanEvent, error)
SummarizeFindings(ctx context.Context) (FindingSummaryCounts, error)
CreateRepoScan(ctx context.Context, repository string, source RepoScanSource, scanContext RepoScanContext, startedAt time.Time) (RepoScanRecord, error)
CreateQueuedRepoScan(ctx context.Context, repository string, source RepoScanSource, scanContext RepoScanContext, historyLimit int, maxFindings int, queuedAt time.Time) (RepoScanRecord, error)
CreateQueuedRepoScanWithinLimit(ctx context.Context, repository string, source RepoScanSource, scanContext RepoScanContext, historyLimit int, maxFindings int, queuedAt time.Time, maxPending int) (RepoScanRecord, error)
ClaimNextQueuedRepoScan(ctx context.Context) (RepoScanRecord, error)
ClaimNextQueuedRepoScanAnyScope(ctx context.Context) (RepoScanRecord, error)
CountQueuedRepoScans(ctx context.Context) (int, error)
CountPendingRepoScansByRepository(ctx context.Context, repository string) (int, error)
RequeueRepoScan(ctx context.Context, repoScanID string) error
FailStaleRepoScansAnyScope(ctx context.Context, staleBefore time.Time, limit int, errorMessage string) (int, error)
GetRepoScan(ctx context.Context, repoScanID string) (RepoScanRecord, error)
CancelRepoScan(ctx context.Context, repoScanID string, finishedAt time.Time, errorMessage string) (RepoScanRecord, error)
CompleteRepoScan(ctx context.Context, repoScanID string, status string, finishedAt time.Time, commitsScanned int, filesScanned int, findingCount int, truncated bool, scanContext RepoScanContext, errorMessage string) error
GetRepoScanCursor(ctx context.Context, repository string, source RepoScanSource) (RepoScanCursor, error)
UpsertRepoScanCursor(ctx context.Context, cursor RepoScanCursor) error
UpsertRepoFindings(ctx context.Context, repoScanID string, findings []domain.Finding) error
DeleteRepoFindings(ctx context.Context, repoScanID string) error
ListRepoScans(ctx context.Context, limit int) ([]RepoScanRecord, error)
ListRepoFindings(ctx context.Context, filter RepoFindingFilter, limit int) ([]domain.Finding, error)
ListRepoFindingClusters(ctx context.Context, filter RepoFindingClusterListFilter) ([]domain.RepoFindingCluster, error)
Close() error
}
Store defines persistence operations required by API and scheduler orchestration.
type TenancyConnector ¶
type TenancyConnector struct {
TenantID string `json:"tenant_id"`
WorkspaceID string `json:"workspace_id"`
ProjectID string `json:"project_id"`
ConnectorID string `json:"connector_id"`
Type domain.ConnectorType `json:"type"`
DisplayName string `json:"display_name"`
Status domain.ConnectorStatus `json:"status"`
SecretProvider string `json:"secret_provider,omitempty"`
SecretRefID string `json:"secret_ref_id,omitempty"`
SecretRefVersion string `json:"secret_ref_version,omitempty"`
SecretLastRotatedAt *time.Time `json:"secret_last_rotated_at,omitempty"`
ConfigChecksum string `json:"config_checksum,omitempty"`
LastSyncAt *time.Time `json:"last_sync_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
TenancyConnector stores one project-scoped source connector record.
func NormalizeTenancyConnectorForWrite ¶
func NormalizeTenancyConnectorForWrite(connector TenancyConnector) (TenancyConnector, error)
NormalizeTenancyConnectorForWrite validates and canonicalizes source connector metadata.
type TenancyConnectorSecretEnvelope ¶
type TenancyConnectorSecretEnvelope struct {
TenantID string `json:"tenant_id"`
WorkspaceID string `json:"workspace_id"`
ProjectID string `json:"project_id"`
ConnectorID string `json:"connector_id"`
SecretName string `json:"secret_name"`
EnvelopeVersion int `json:"envelope_version"`
Envelope secretstore.Envelope `json:"envelope"`
SecretRefID string `json:"secret_ref_id,omitempty"`
RotatedAt time.Time `json:"rotated_at"`
RotationDueAt *time.Time `json:"rotation_due_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
TenancyConnectorSecretEnvelope stores one encrypted connector secret envelope.
func NormalizeTenancyConnectorSecretEnvelopeForWrite ¶
func NormalizeTenancyConnectorSecretEnvelopeForWrite(secret TenancyConnectorSecretEnvelope) (TenancyConnectorSecretEnvelope, error)
NormalizeTenancyConnectorSecretEnvelopeForWrite validates one connector secret envelope record.
type TenancyConnectorState ¶
type TenancyConnectorState struct {
TenantID string `json:"tenant_id"`
WorkspaceID string `json:"workspace_id"`
ProjectID string `json:"project_id"`
ConnectorID string `json:"connector_id"`
HealthStatus string `json:"health_status"`
SyncCursor string `json:"sync_cursor,omitempty"`
LastSuccessfulSyncAt *time.Time `json:"last_successful_sync_at,omitempty"`
LastErrorCode string `json:"last_error_code,omitempty"`
LastErrorMessage string `json:"last_error_message,omitempty"`
Metadata map[string]any `json:"metadata"`
ObservedAt time.Time `json:"observed_at"`
UpdatedAt time.Time `json:"updated_at"`
}
TenancyConnectorState stores observed health and provider metadata for a connector.
func NormalizeTenancyConnectorStateForWrite ¶
func NormalizeTenancyConnectorStateForWrite(state TenancyConnectorState) (TenancyConnectorState, error)
NormalizeTenancyConnectorStateForWrite validates and canonicalizes connector health state.
type TenancyConnectorWithState ¶
type TenancyConnectorWithState struct {
Connector TenancyConnector `json:"connector"`
State TenancyConnectorState `json:"state"`
}
TenancyConnectorWithState returns a connector with its latest persisted state.
type TenancyOrganization ¶
type TenancyOrganization struct {
TenantID string `json:"tenant_id"`
DisplayName string `json:"display_name"`
Slug string `json:"slug"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
TenancyOrganization stores one tenant root metadata record.
func NormalizeTenancyOrganizationForWrite ¶
func NormalizeTenancyOrganizationForWrite(organization TenancyOrganization) (TenancyOrganization, error)
NormalizeTenancyOrganizationForWrite validates and canonicalizes organization metadata.
type TenancyProject ¶
type TenancyProject struct {
TenantID string `json:"tenant_id"`
WorkspaceID string `json:"workspace_id"`
ProjectID string `json:"project_id"`
Name string `json:"name"`
Slug string `json:"slug"`
Description string `json:"description,omitempty"`
ArchivedAt *time.Time `json:"archived_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
TenancyProject stores one project metadata record.
func NormalizeTenancyProjectForWrite ¶
func NormalizeTenancyProjectForWrite(project TenancyProject) (TenancyProject, error)
NormalizeTenancyProjectForWrite validates and canonicalizes project metadata.
type TenancyScanPolicy ¶
type TenancyScanPolicy struct {
TenantID string `json:"tenant_id"`
WorkspaceID string `json:"workspace_id"`
ProjectID string `json:"project_id"`
PolicyID string `json:"policy_id"`
Name string `json:"name"`
Enabled bool `json:"enabled"`
TriggerMode domain.ScanTriggerMode `json:"trigger_mode"`
Cron string `json:"cron,omitempty"`
MaxConcurrentScans int `json:"max_concurrent_scans"`
HistoryLimit int `json:"history_limit"`
MaxFindings int `json:"max_findings"`
LastScheduledAt *time.Time `json:"last_scheduled_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
TenancyScanPolicy stores one project-scoped automation policy record.
func NormalizeTenancyScanPolicyForWrite ¶
func NormalizeTenancyScanPolicyForWrite(policy TenancyScanPolicy) (TenancyScanPolicy, error)
NormalizeTenancyScanPolicyForWrite validates and canonicalizes project scan policies.
type TenancyWorkspace ¶
type TenancyWorkspace struct {
TenantID string `json:"tenant_id"`
WorkspaceID string `json:"workspace_id"`
DisplayName string `json:"display_name"`
Slug string `json:"slug"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
TenancyWorkspace stores one workspace metadata record.
func NormalizeTenancyWorkspaceForWrite ¶
func NormalizeTenancyWorkspaceForWrite(workspace TenancyWorkspace) (TenancyWorkspace, error)
NormalizeTenancyWorkspaceForWrite validates and canonicalizes workspace metadata.
type TenancyWorkspaceMember ¶
type TenancyWorkspaceMember struct {
TenantID string `json:"tenant_id"`
WorkspaceID string `json:"workspace_id"`
MemberID string `json:"member_id"`
UserID string `json:"user_id"`
UserUUID string `json:"user_uuid,omitempty"`
Email string `json:"email,omitempty"`
Role string `json:"role"`
Status string `json:"status"`
JoinedAt time.Time `json:"joined_at"`
UpdatedAt time.Time `json:"updated_at"`
}
TenancyWorkspaceMember stores one workspace member assignment.
func NormalizeTenancyWorkspaceMemberForWrite ¶
func NormalizeTenancyWorkspaceMemberForWrite(member TenancyWorkspaceMember) (TenancyWorkspaceMember, error)
NormalizeTenancyWorkspaceMemberForWrite validates and canonicalizes workspace members.
type User ¶
type User struct {
ID string `json:"id"`
PrimaryEmail string `json:"primary_email"`
DisplayName string `json:"display_name,omitempty"`
AvatarURL string `json:"avatar_url,omitempty"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
}
User stores one human account independent of provider identities.
func NormalizeUserForWrite ¶
NormalizeUserForWrite validates and canonicalizes one account row.
type UserIdentity ¶
type UserIdentity struct {
ID string `json:"id"`
UserID string `json:"user_id"`
Provider string `json:"provider"`
Subject string `json:"subject"`
Email string `json:"email,omitempty"`
EmailVerified bool `json:"email_verified"`
RawClaims json.RawMessage `json:"raw_claims,omitempty"`
LastAuthenticatedAt time.Time `json:"last_authenticated_at"`
CreatedAt time.Time `json:"created_at"`
}
UserIdentity links one external identity provider subject to a user.
func NormalizeUserIdentityForWrite ¶
func NormalizeUserIdentityForWrite(identity UserIdentity) (UserIdentity, error)
NormalizeUserIdentityForWrite validates and canonicalizes one provider identity row.
type VerifiedDomain ¶
type VerifiedDomain struct {
ID string `json:"id"`
OrgID string `json:"org_id"`
Domain string `json:"domain"`
VerificationToken string `json:"verification_token"`
VerificationMethod string `json:"verification_method"`
VerifiedAt *time.Time `json:"verified_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
VerifiedDomain stores one organization domain-verification scaffold.
func NormalizeVerifiedDomainForWrite ¶
func NormalizeVerifiedDomainForWrite(domain VerifiedDomain) (VerifiedDomain, error)
NormalizeVerifiedDomainForWrite validates and canonicalizes one domain-verification scaffold.
type WebhookEvent ¶
type WebhookEvent struct {
Provider string `json:"provider"`
EventID string `json:"event_id"`
EventType string `json:"event_type,omitempty"`
ReceivedAt time.Time `json:"received_at"`
}
WebhookEvent is the persisted idempotency record for one provider-issued webhook delivery. (Provider, EventID) is unique. The row carries a status so concurrent deliveries of the same event are handled correctly: the first delivery claims the row ("processing") and applies side effects; only once it finishes ("processed") does a duplicate get a no-op success. A duplicate that arrives while the first is still in flight must be told to retry, never acknowledged — otherwise the provider could stop retrying before the side effects are durably applied. The row is recorded only after signature validation so an attacker cannot poison the table.
type WebhookEventStatus ¶
type WebhookEventStatus string
WebhookEventStatus is the result of BeginWebhookEvent. Claimed/Processing are transient outcomes for the caller; only Processed authorizes a no-op acknowledgement of a duplicate.
const ( // WebhookEventClaimed means this delivery won the insert (or reclaimed a // stale in-flight row) and must apply the side effects, then call // CompleteWebhookEvent. WebhookEventClaimed WebhookEventStatus = "claimed" // WebhookEventProcessing means another delivery of the same event is // still in flight. The caller must NOT acknowledge success; it should // return a retryable response so the provider redelivers later. WebhookEventProcessing WebhookEventStatus = "processing" // WebhookEventProcessed means the event was already fully handled. The // caller returns a successful no-op without reapplying side effects. WebhookEventProcessed WebhookEventStatus = "processed" )