Documentation
¶
Overview ¶
Package models - hooks.go contains GORM lifecycle hooks for validation. These hooks replace PostgreSQL CHECK constraints and triggers to enable consistent validation across all supported databases.
Package models defines GORM models for the TMI database schema. These models support both PostgreSQL and Oracle databases through GORM's dialect abstraction.
Index ¶
- Variables
- func AllModels() []interface{}
- type Addon
- type AddonInvocationQuota
- type Administrator
- type Asset
- type ClientCredential
- type CollaborationSession
- type DBBool
- type DBText
- type Diagram
- type Document
- type Group
- type GroupMember
- type JSONMap
- type JSONRaw
- type Metadata
- type Note
- type NullableDBText
- type OracleBool
- type RefreshTokenRecord
- type Repository
- type SessionParticipant
- type StringArray
- type Threat
- type ThreatModel
- type ThreatModelAccess
- type User
- type UserAPIQuota
- type WebhookDelivery
- type WebhookQuota
- type WebhookSubscription
- type WebhookURLDenyList
Constants ¶
This section is empty.
Variables ¶
var UseUppercaseTableNames = false
UseUppercaseTableNames controls whether table names should be uppercase. Set to true for Oracle databases where unquoted identifiers are folded to uppercase. This must be set before any GORM operations occur.
Functions ¶
Types ¶
type Addon ¶
type Addon struct {
ID string `gorm:"primaryKey;type:varchar(36)"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
Name string `gorm:"type:varchar(256);not null"`
WebhookID string `gorm:"type:varchar(36);not null;index"`
Description *string `gorm:"type:varchar(1024)"`
Icon *string `gorm:"type:varchar(60)"`
Objects StringArray `gorm:""`
ThreatModelID *string `gorm:"type:varchar(36);index"`
// Relationships
Webhook WebhookSubscription `gorm:"foreignKey:WebhookID"`
ThreatModel *ThreatModel `gorm:"foreignKey:ThreatModelID"`
}
Addon represents an addon configuration Note: Explicit column tags removed for Oracle compatibility
func (*Addon) BeforeCreate ¶
BeforeCreate generates a UUID if not set
type AddonInvocationQuota ¶
type AddonInvocationQuota struct {
OwnerInternalUUID string `gorm:"primaryKey;type:varchar(36)"`
MaxActiveInvocations int `gorm:"default:1"`
MaxInvocationsPerHour int `gorm:"default:10"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
// Relationships
Owner User `gorm:"foreignKey:OwnerInternalUUID;references:InternalUUID"`
}
AddonInvocationQuota represents per-user addon invocation quotas Note: Explicit column tags removed for Oracle compatibility
func (AddonInvocationQuota) TableName ¶
func (AddonInvocationQuota) TableName() string
TableName specifies the table name for AddonInvocationQuota
type Administrator ¶
type Administrator struct {
ID string `gorm:"primaryKey;type:varchar(36)"`
UserInternalUUID *string `gorm:"type:varchar(36);index;uniqueIndex:idx_admin_user_type"`
GroupInternalUUID *string `gorm:"type:varchar(36);index;uniqueIndex:idx_admin_group_type_provider"`
SubjectType string `gorm:"type:varchar(10);not null;uniqueIndex:idx_admin_user_type;uniqueIndex:idx_admin_group_type_provider"`
Provider string `gorm:"type:varchar(100);not null;uniqueIndex:idx_admin_group_type_provider"`
GrantedAt time.Time `gorm:"not null;autoCreateTime"`
GrantedByInternalUUID *string `gorm:"type:varchar(36)"`
Notes *string `gorm:"type:varchar(1000)"`
// Relationships
User *User `gorm:"foreignKey:UserInternalUUID;references:InternalUUID"`
Group *Group `gorm:"foreignKey:GroupInternalUUID;references:InternalUUID"`
GrantedBy *User `gorm:"foreignKey:GrantedByInternalUUID;references:InternalUUID"`
}
Administrator represents an administrator (user or group) Note: Explicit column tags removed for Oracle compatibility Unique constraints required for ON CONFLICT upsert in administrator_store_gorm.go: - idx_admin_user_type: (user_internal_uuid, subject_type) for user admins - idx_admin_group_type_provider: (group_internal_uuid, subject_type, provider) for group admins
func (*Administrator) BeforeCreate ¶
func (a *Administrator) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set
func (*Administrator) BeforeSave ¶
func (a *Administrator) BeforeSave(tx *gorm.DB) error
BeforeSave validates Administrator before create or update
func (Administrator) TableName ¶
func (Administrator) TableName() string
TableName specifies the table name for Administrator
type Asset ¶
type Asset struct {
ID string `gorm:"primaryKey;type:varchar(36)"`
ThreatModelID string `` /* 131-byte string literal not displayed */
Name string `gorm:"type:varchar(256);not null;index:idx_assets_name"`
Description *string `gorm:"type:varchar(1024)"`
Type string `gorm:"type:varchar(64);not null;index:idx_assets_type"`
Criticality *string `gorm:"type:varchar(128)"`
Classification StringArray `gorm:""`
Sensitivity *string `gorm:"type:varchar(128)"`
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_assets_created;index:idx_assets_tm_created,priority:2"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime;index:idx_assets_modified;index:idx_assets_tm_modified,priority:2"`
// Relationships
ThreatModel ThreatModel `gorm:"foreignKey:ThreatModelID"`
}
Asset represents an asset within a threat model Note: Explicit column tags removed for Oracle compatibility
func (*Asset) BeforeCreate ¶
BeforeCreate generates a UUID if not set
func (*Asset) BeforeSave ¶
BeforeSave validates Asset before create or update
type ClientCredential ¶
type ClientCredential struct {
ID string `gorm:"primaryKey;type:varchar(36)"`
OwnerUUID string `gorm:"type:varchar(36);not null;index"`
ClientID string `gorm:"type:varchar(1000);not null;uniqueIndex"`
ClientSecretHash DBText `gorm:"not null"`
Name string `gorm:"type:varchar(256);not null"`
Description *string `gorm:"type:varchar(1024)"`
IsActive DBBool `gorm:"default:1"`
LastUsedAt *time.Time
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
ExpiresAt *time.Time
// Relationships
Owner User `gorm:"foreignKey:OwnerUUID;references:InternalUUID"`
}
ClientCredential represents OAuth 2.0 client credentials for machine-to-machine auth Note: Explicit column tags removed for Oracle compatibility
func (*ClientCredential) BeforeCreate ¶
func (c *ClientCredential) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set
func (ClientCredential) TableName ¶
func (ClientCredential) TableName() string
TableName specifies the table name for ClientCredential
type CollaborationSession ¶
type CollaborationSession struct {
ID string `gorm:"primaryKey;type:varchar(36)"`
ThreatModelID string `gorm:"type:varchar(36);not null;index"`
DiagramID string `gorm:"type:varchar(36);not null;index"`
WebsocketURL string `gorm:"type:varchar(1024);not null"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ExpiresAt *time.Time
// Relationships
ThreatModel ThreatModel `gorm:"foreignKey:ThreatModelID"`
Diagram Diagram `gorm:"foreignKey:DiagramID"`
Participants []SessionParticipant `gorm:"foreignKey:SessionID"`
}
CollaborationSession represents a real-time collaboration session Note: Explicit column tags removed for Oracle compatibility
func (*CollaborationSession) BeforeCreate ¶
func (c *CollaborationSession) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set
func (*CollaborationSession) BeforeSave ¶
func (c *CollaborationSession) BeforeSave(tx *gorm.DB) error
BeforeSave validates CollaborationSession before create or update
func (CollaborationSession) TableName ¶
func (CollaborationSession) TableName() string
TableName specifies the table name for CollaborationSession
type DBBool ¶
type DBBool bool
DBBool is a cross-database boolean type that handles different database representations of booleans. Oracle uses NUMBER(1), MySQL uses TINYINT(1), SQL Server uses BIT, while PostgreSQL and SQLite have native boolean support. This type implements sql.Scanner and driver.Valuer to handle the conversion for all supported databases.
func (DBBool) GormDBDataType ¶
GormDBDataType implements the GormDBDataTypeInterface to return dialect-specific column types for cross-database compatibility
func (*DBBool) Scan ¶
Scan implements the sql.Scanner interface for DBBool. It handles: - bool (PostgreSQL native boolean) - int64/int/int32 (numeric representation) - godror.Number (Oracle's numeric type, implements fmt.Stringer) - nil (NULL values)
type DBText ¶
type DBText string
DBText is a cross-database large text type. Uses TEXT on PostgreSQL, CLOB on Oracle, LONGTEXT on MySQL, NVARCHAR(MAX) on SQL Server, and TEXT on SQLite.
func (DBText) GormDBDataType ¶
GormDBDataType implements the GormDBDataTypeInterface to return dialect-specific column types for cross-database compatibility
type Diagram ¶
type Diagram struct {
ID string `gorm:"primaryKey;type:varchar(36)"`
ThreatModelID string `gorm:"type:varchar(36);not null;index:idx_diagrams_tm;index:idx_diagrams_tm_type,priority:1"`
Name string `gorm:"type:varchar(256);not null"`
Description *string `gorm:"type:varchar(1024)"`
Type *string `gorm:"type:varchar(64);index:idx_diagrams_type;index:idx_diagrams_tm_type,priority:2"`
Content NullableDBText `gorm:""`
Cells JSONRaw `gorm:""`
SVGImage NullableDBText `gorm:""`
ImageUpdateVector *int64
UpdateVector int64 `gorm:"default:0"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
// Relationships
ThreatModel ThreatModel `gorm:"foreignKey:ThreatModelID"`
}
Diagram represents a diagram within a threat model Note: Explicit column tags removed for Oracle compatibility
func (*Diagram) BeforeCreate ¶
BeforeCreate generates a UUID if not set
func (*Diagram) BeforeUpdate ¶
BeforeUpdate validates Diagram before update
type Document ¶
type Document struct {
ID string `gorm:"primaryKey;type:varchar(36)"`
ThreatModelID string `gorm:"type:varchar(36);not null;index:idx_docs_tm;index:idx_docs_tm_created,priority:1;index:idx_docs_tm_modified,priority:1"`
Name string `gorm:"type:varchar(256);not null;index:idx_docs_name"`
URI string `gorm:"type:varchar(1000);not null"`
Description *string `gorm:"type:varchar(1024)"`
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_docs_created;index:idx_docs_tm_created,priority:2"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime;index:idx_docs_modified;index:idx_docs_tm_modified,priority:2"`
// Relationships
ThreatModel ThreatModel `gorm:"foreignKey:ThreatModelID"`
}
Document represents a document attached to a threat model Note: Explicit column tags removed for Oracle compatibility
func (*Document) BeforeCreate ¶
BeforeCreate generates a UUID if not set
func (*Document) BeforeSave ¶
BeforeSave validates Document before create or update
type Group ¶
type Group struct {
InternalUUID string `gorm:"primaryKey;type:varchar(36)"`
Provider string `gorm:"type:varchar(100);not null;index:idx_groups_provider"`
GroupName string `gorm:"type:varchar(500);not null;index:idx_groups_group_name"`
Name *string `gorm:"type:varchar(256)"`
Description *string `gorm:"type:varchar(1024)"`
FirstUsed time.Time `gorm:"not null;autoCreateTime"`
LastUsed time.Time `gorm:"not null;autoUpdateTime;index:idx_groups_last_used"`
UsageCount int `gorm:"default:1"`
}
Group represents an identity provider group Note: Explicit column tags removed for Oracle compatibility
func (*Group) BeforeCreate ¶
BeforeCreate generates a UUID if not set
func (*Group) BeforeDelete ¶
BeforeDelete prevents deletion of the "everyone" pseudo-group
type GroupMember ¶
type GroupMember struct {
ID string `gorm:"primaryKey;type:varchar(36)"`
GroupInternalUUID string `gorm:"type:varchar(36);not null;index"`
UserInternalUUID string `gorm:"type:varchar(36);not null;index"`
AddedByInternalUUID *string `gorm:"type:varchar(36)"`
AddedAt time.Time `gorm:"not null;autoCreateTime"`
Notes *string `gorm:"type:varchar(1000)"`
// Relationships
Group Group `gorm:"foreignKey:GroupInternalUUID;references:InternalUUID"`
User User `gorm:"foreignKey:UserInternalUUID;references:InternalUUID"`
AddedBy *User `gorm:"foreignKey:AddedByInternalUUID;references:InternalUUID"`
}
GroupMember represents a user's membership in a group Note: Explicit column tags removed for Oracle compatibility
func (*GroupMember) BeforeCreate ¶
func (g *GroupMember) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set
func (*GroupMember) BeforeSave ¶
func (gm *GroupMember) BeforeSave(tx *gorm.DB) error
BeforeSave validates GroupMember and prevents adding to "everyone" group
func (GroupMember) TableName ¶
func (GroupMember) TableName() string
TableName specifies the table name for GroupMember
type JSONMap ¶
type JSONMap map[string]interface{}
JSONMap is a custom type that stores JSON objects This works across both PostgreSQL JSONB and Oracle JSON
func (JSONMap) GormDBDataType ¶
GormDBDataType implements the GormDBDataTypeInterface to return dialect-specific column types for cross-database compatibility
type JSONRaw ¶
type JSONRaw json.RawMessage
JSONRaw is a custom type for storing raw JSON (like cells in diagrams)
func (JSONRaw) GormDBDataType ¶
GormDBDataType implements the GormDBDataTypeInterface to return dialect-specific column types for cross-database compatibility
func (JSONRaw) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*JSONRaw) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
type Metadata ¶
type Metadata struct {
ID string `gorm:"primaryKey;type:varchar(36)"`
EntityType string `` /* 212-byte string literal not displayed */
EntityID string `` /* 183-byte string literal not displayed */
Key string `` /* 133-byte string literal not displayed */
Value string `gorm:"type:varchar(1024);not null;index:idx_metadata_key_value,priority:3"`
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_metadata_created;index:idx_metadata_entity_created,priority:2"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime;index:idx_metadata_modified;index:idx_metadata_entity_modified,priority:2"`
}
Metadata represents key-value metadata for entities Note: Explicit column tags removed for Oracle compatibility
func (*Metadata) BeforeCreate ¶
BeforeCreate generates a UUID if not set
func (*Metadata) BeforeSave ¶
BeforeSave validates Metadata before create or update
type Note ¶
type Note struct {
ID string `gorm:"primaryKey;type:varchar(36)"`
ThreatModelID string `` /* 128-byte string literal not displayed */
Name string `gorm:"type:varchar(256);not null;index:idx_notes_name"`
Content DBText `gorm:"not null"`
Description *string `gorm:"type:varchar(1024)"`
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_notes_created;index:idx_notes_tm_created,priority:2"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime;index:idx_notes_modified;index:idx_notes_tm_modified,priority:2"`
// Relationships
ThreatModel ThreatModel `gorm:"foreignKey:ThreatModelID"`
}
Note represents a note attached to a threat model Note: Explicit column tags removed for Oracle compatibility
func (*Note) BeforeCreate ¶
BeforeCreate generates a UUID if not set
func (*Note) BeforeSave ¶
BeforeSave validates Note before create or update
type NullableDBText ¶
NullableDBText is a nullable cross-database large text type. Wraps a string with a Valid flag for NULL handling. Uses TEXT on PostgreSQL, CLOB on Oracle, LONGTEXT on MySQL, NVARCHAR(MAX) on SQL Server, and TEXT on SQLite.
func NewNullableDBText ¶
func NewNullableDBText(s *string) NullableDBText
NewNullableDBText creates a NullableDBText from a string pointer
func (NullableDBText) GormDBDataType ¶
GormDBDataType implements the GormDBDataTypeInterface to return dialect-specific column types for cross-database compatibility
func (NullableDBText) Ptr ¶
func (t NullableDBText) Ptr() *string
Ptr returns a pointer to the string, or nil if not valid
func (*NullableDBText) Scan ¶
func (t *NullableDBText) Scan(value interface{}) error
Scan implements the sql.Scanner interface for database reads
type OracleBool ¶
type OracleBool = DBBool
OracleBool is an alias for DBBool for backward compatibility. Deprecated: Use DBBool instead.
type RefreshTokenRecord ¶
type RefreshTokenRecord struct {
ID string `gorm:"primaryKey;type:varchar(36)"`
UserInternalUUID string `gorm:"type:varchar(36);not null;index"`
Token string `gorm:"type:varchar(4000);not null;uniqueIndex"` // varchar(4000) for Oracle compatibility (CLOB cannot have unique index)
ExpiresAt time.Time `gorm:"not null"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
// Relationships
User User `gorm:"foreignKey:UserInternalUUID;references:InternalUUID"`
}
RefreshTokenRecord represents a refresh token for a user Note: Explicit column tags removed for Oracle compatibility
func (*RefreshTokenRecord) BeforeCreate ¶
func (r *RefreshTokenRecord) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set
func (RefreshTokenRecord) TableName ¶
func (RefreshTokenRecord) TableName() string
TableName specifies the table name for RefreshTokenRecord
type Repository ¶
type Repository struct {
ID string `gorm:"primaryKey;type:varchar(36)"`
ThreatModelID string `` /* 128-byte string literal not displayed */
Name *string `gorm:"type:varchar(256);index:idx_repos_name"`
URI string `gorm:"type:varchar(1000);not null"`
Description *string `gorm:"type:varchar(1024)"`
Type *string `gorm:"type:varchar(64);index:idx_repos_type"`
Parameters JSONMap `gorm:""`
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_repos_created;index:idx_repos_tm_created,priority:2"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime;index:idx_repos_modified;index:idx_repos_tm_modified,priority:2"`
// Relationships
ThreatModel ThreatModel `gorm:"foreignKey:ThreatModelID"`
}
Repository represents a repository attached to a threat model Note: Explicit column tags removed for Oracle compatibility
func (*Repository) BeforeCreate ¶
func (r *Repository) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set
func (*Repository) BeforeSave ¶
func (r *Repository) BeforeSave(tx *gorm.DB) error
BeforeSave validates Repository before create or update
func (Repository) TableName ¶
func (Repository) TableName() string
TableName specifies the table name for Repository
type SessionParticipant ¶
type SessionParticipant struct {
ID string `gorm:"primaryKey;type:varchar(36)"`
SessionID string `gorm:"type:varchar(36);not null;index"`
UserInternalUUID string `gorm:"type:varchar(36);not null;index"`
JoinedAt time.Time `gorm:"not null;autoCreateTime"`
LeftAt *time.Time
// Relationships
Session CollaborationSession `gorm:"foreignKey:SessionID"`
User User `gorm:"foreignKey:UserInternalUUID;references:InternalUUID"`
}
SessionParticipant represents a participant in a collaboration session Note: Explicit column tags removed for Oracle compatibility
func (*SessionParticipant) BeforeCreate ¶
func (s *SessionParticipant) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set
func (SessionParticipant) TableName ¶
func (SessionParticipant) TableName() string
TableName specifies the table name for SessionParticipant
type StringArray ¶
type StringArray []string
StringArray is a custom type that stores string arrays as JSON This outputs JSON array format ["val1","val2"] which works for both PostgreSQL JSONB columns and Oracle JSON columns
func (StringArray) GormDBDataType ¶
GormDBDataType implements the GormDBDataTypeInterface to return dialect-specific column types for cross-database compatibility
func (*StringArray) Scan ¶
func (a *StringArray) Scan(value interface{}) error
Scan implements the sql.Scanner interface for database reads
type Threat ¶
type Threat struct {
ID string `gorm:"primaryKey;type:varchar(36)"`
ThreatModelID string `` /* 134-byte string literal not displayed */
DiagramID *string `gorm:"type:varchar(36);index:idx_threats_diagram"`
CellID *string `gorm:"type:varchar(36);index:idx_threats_cell"`
AssetID *string `gorm:"type:varchar(36);index:idx_threats_asset"`
Name string `gorm:"type:varchar(256);not null;index:idx_threats_name"`
Description *string `gorm:"type:varchar(1024)"`
Severity *string `gorm:"type:varchar(50);index:idx_threats_severity"`
Likelihood *string `gorm:"type:varchar(50)"`
RiskLevel *string `gorm:"type:varchar(50);index:idx_threats_risk_level"`
Score *float64 `gorm:"type:decimal(3,1);index:idx_threats_score"`
Priority *string `gorm:"type:varchar(256);index:idx_threats_priority"`
Mitigated DBBool `gorm:"index:idx_threats_mitigated"`
Status *string `gorm:"type:varchar(128);index:idx_threats_status"`
ThreatType StringArray `gorm:"not null"`
Mitigation *string `gorm:"type:varchar(1024)"`
IssueURI *string `gorm:"type:varchar(1000)"`
// Note: autoCreateTime/autoUpdateTime tags removed for Oracle compatibility.
// Timestamps are set explicitly in the store layer (toGormModelForCreate).
CreatedAt time.Time `gorm:"not null;index:idx_threats_tm_created,priority:2"`
ModifiedAt time.Time `gorm:"not null;index:idx_threats_modified;index:idx_threats_tm_modified,priority:2"`
// Relationships
ThreatModel ThreatModel `gorm:"foreignKey:ThreatModelID"`
Diagram *Diagram `gorm:"foreignKey:DiagramID"`
Asset *Asset `gorm:"foreignKey:AssetID"`
}
Threat represents a threat within a threat model Note: Explicit column tags removed for Oracle compatibility
func (*Threat) BeforeCreate ¶
BeforeCreate ensures the ID is set before insert This is required for Oracle compatibility where the driver may not properly handle IDs set after struct initialization
func (*Threat) BeforeSave ¶
BeforeSave validates Threat before create or update
type ThreatModel ¶
type ThreatModel struct {
ID string `gorm:"primaryKey;type:varchar(36)"`
OwnerInternalUUID string `gorm:"type:varchar(36);not null;index:idx_tm_owner;index:idx_tm_owner_created,priority:1"`
Name string `gorm:"type:varchar(256);not null"`
Description *string `gorm:"type:varchar(1024)"`
CreatedByInternalUUID string `gorm:"type:varchar(36);not null;index:idx_tm_created_by"`
ThreatModelFramework string `gorm:"type:varchar(30);default:STRIDE;index:idx_tm_framework"`
IssueURI *string `gorm:"type:varchar(1000)"`
Status *string `gorm:"type:varchar(128);index:idx_tm_status"`
StatusUpdated *time.Time `gorm:"index:idx_tm_status_updated"`
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_tm_owner_created,priority:2"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
// Relationships
Owner User `gorm:"foreignKey:OwnerInternalUUID;references:InternalUUID"`
CreatedBy User `gorm:"foreignKey:CreatedByInternalUUID;references:InternalUUID"`
Diagrams []Diagram `gorm:"foreignKey:ThreatModelID"`
Threats []Threat `gorm:"foreignKey:ThreatModelID"`
Assets []Asset `gorm:"foreignKey:ThreatModelID"`
}
ThreatModel represents a threat model in the system Note: Explicit column tags removed for Oracle compatibility (Oracle stores column names as UPPERCASE, and the Oracle GORM driver doesn't handle case-insensitive matching with explicit column tags)
func (*ThreatModel) BeforeCreate ¶
func (t *ThreatModel) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set
func (*ThreatModel) BeforeUpdate ¶
func (t *ThreatModel) BeforeUpdate(tx *gorm.DB) error
BeforeUpdate validates ThreatModel before update
func (ThreatModel) TableName ¶
func (ThreatModel) TableName() string
TableName specifies the table name for ThreatModel
type ThreatModelAccess ¶
type ThreatModelAccess struct {
ID string `gorm:"primaryKey;type:varchar(36)"`
ThreatModelID string `gorm:"type:varchar(36);not null;index:idx_tma_tm;index:idx_tma_perf,priority:1"`
UserInternalUUID *string `gorm:"type:varchar(36);index:idx_tma_user;index:idx_tma_perf,priority:3"`
GroupInternalUUID *string `gorm:"type:varchar(36);index:idx_tma_group;index:idx_tma_perf,priority:4"`
SubjectType string `gorm:"type:varchar(10);not null;index:idx_tma_subject_type;index:idx_tma_perf,priority:2"`
Role string `gorm:"type:varchar(6);not null;index:idx_tma_role"`
GrantedByInternalUUID *string `gorm:"type:varchar(36)"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
// Relationships
ThreatModel ThreatModel `gorm:"foreignKey:ThreatModelID"`
User *User `gorm:"foreignKey:UserInternalUUID;references:InternalUUID"`
Group *Group `gorm:"foreignKey:GroupInternalUUID;references:InternalUUID"`
GrantedBy *User `gorm:"foreignKey:GrantedByInternalUUID;references:InternalUUID"`
}
ThreatModelAccess represents access control for threat models Note: Explicit column tags removed for Oracle compatibility (Oracle stores column names as UPPERCASE, and the Oracle GORM driver doesn't handle case-insensitive matching with explicit column tags)
func (*ThreatModelAccess) BeforeCreate ¶
func (t *ThreatModelAccess) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set
func (*ThreatModelAccess) BeforeSave ¶
func (t *ThreatModelAccess) BeforeSave(tx *gorm.DB) error
BeforeSave validates ThreatModelAccess before create or update
func (ThreatModelAccess) TableName ¶
func (ThreatModelAccess) TableName() string
TableName specifies the table name for ThreatModelAccess
type User ¶
type User struct {
InternalUUID string `gorm:"primaryKey;type:varchar(36)"`
Provider string `gorm:"type:varchar(100);not null;index:idx_users_provider;index:idx_users_provider_lookup,priority:1"`
ProviderUserID *string `gorm:"type:varchar(500);index:idx_users_provider_lookup,priority:2"`
Email string `gorm:"type:varchar(320);not null;index:idx_users_email"`
Name string `gorm:"type:varchar(256);not null"`
EmailVerified DBBool `gorm:"default:0"`
AccessToken NullableDBText `gorm:""`
RefreshToken NullableDBText `gorm:""`
TokenExpiry *time.Time
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
LastLogin *time.Time `gorm:"index:idx_users_last_login"`
}
User represents an authenticated user in the system Note: Column names are intentionally not specified to allow GORM's NamingStrategy to handle database-specific casing (lowercase for PostgreSQL, UPPERCASE for Oracle)
func (*User) BeforeCreate ¶
BeforeCreate generates a UUID if not set
type UserAPIQuota ¶
type UserAPIQuota struct {
UserInternalUUID string `gorm:"primaryKey;type:varchar(36)"`
MaxRequestsPerMinute int `gorm:"default:100"`
MaxRequestsPerHour *int
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
// Relationships
User User `gorm:"foreignKey:UserInternalUUID;references:InternalUUID"`
}
UserAPIQuota represents per-user API rate limits Note: Explicit column tags removed for Oracle compatibility
func (UserAPIQuota) TableName ¶
func (UserAPIQuota) TableName() string
TableName specifies the table name for UserAPIQuota
type WebhookDelivery ¶
type WebhookDelivery struct {
ID string `gorm:"primaryKey;type:varchar(36)"`
SubscriptionID string `gorm:"type:varchar(36);not null;index"`
EventType string `gorm:"type:varchar(1000);not null"`
Payload JSONRaw `gorm:"not null"`
Status string `gorm:"type:varchar(128);default:pending"`
Attempts int `gorm:"default:0"`
NextRetryAt *time.Time
LastError *string `gorm:"type:varchar(1000)"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
DeliveredAt *time.Time
// Relationships
Subscription WebhookSubscription `gorm:"foreignKey:SubscriptionID"`
}
WebhookDelivery represents a webhook delivery attempt Note: Explicit column tags removed for Oracle compatibility
func (*WebhookDelivery) BeforeCreate ¶
func (w *WebhookDelivery) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set
func (*WebhookDelivery) BeforeSave ¶
func (w *WebhookDelivery) BeforeSave(tx *gorm.DB) error
BeforeSave validates WebhookDelivery before create or update
func (WebhookDelivery) TableName ¶
func (WebhookDelivery) TableName() string
TableName specifies the table name for WebhookDelivery
type WebhookQuota ¶
type WebhookQuota struct {
OwnerID string `gorm:"primaryKey;type:varchar(36)"`
MaxSubscriptions int `gorm:"default:10"`
MaxEventsPerMinute int `gorm:"default:12"`
MaxSubscriptionRequestsPerMinute int `gorm:"default:10"`
MaxSubscriptionRequestsPerDay int `gorm:"default:20"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
// Relationships
Owner User `gorm:"foreignKey:OwnerID;references:InternalUUID"`
}
WebhookQuota represents per-user webhook quotas Note: Explicit column tags removed for Oracle compatibility
func (WebhookQuota) TableName ¶
func (WebhookQuota) TableName() string
TableName specifies the table name for WebhookQuota
type WebhookSubscription ¶
type WebhookSubscription struct {
ID string `gorm:"primaryKey;type:varchar(36)"`
OwnerInternalUUID string `gorm:"type:varchar(36);not null;index"`
ThreatModelID *string `gorm:"type:varchar(36);index"`
Name string `gorm:"type:varchar(256);not null"`
URL string `gorm:"type:varchar(1024);not null"`
Events StringArray `gorm:"not null"`
Secret *string `gorm:"type:varchar(128)"`
Status string `gorm:"type:varchar(128);default:pending_verification"`
Challenge *string `gorm:"type:varchar(1000)"`
ChallengesSent int `gorm:"default:0"`
TimeoutCount int `gorm:"default:0"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
ModifiedAt time.Time `gorm:"not null;autoUpdateTime"`
LastSuccessfulUse *time.Time
PublicationFailures int `gorm:"default:0"`
// Relationships
Owner User `gorm:"foreignKey:OwnerInternalUUID;references:InternalUUID"`
ThreatModel *ThreatModel `gorm:"foreignKey:ThreatModelID"`
}
WebhookSubscription represents a webhook subscription Note: Explicit column tags removed for Oracle compatibility
func (*WebhookSubscription) BeforeCreate ¶
func (w *WebhookSubscription) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set
func (*WebhookSubscription) BeforeSave ¶
func (w *WebhookSubscription) BeforeSave(tx *gorm.DB) error
BeforeSave validates WebhookSubscription before create or update
func (WebhookSubscription) TableName ¶
func (WebhookSubscription) TableName() string
TableName specifies the table name for WebhookSubscription
type WebhookURLDenyList ¶
type WebhookURLDenyList struct {
ID string `gorm:"primaryKey;type:varchar(36)"`
Pattern string `gorm:"type:varchar(256);not null"`
PatternType string `gorm:"type:varchar(64);not null"`
Description *string `gorm:"type:varchar(1024)"`
CreatedAt time.Time `gorm:"not null;autoCreateTime"`
}
WebhookURLDenyList represents URL patterns blocked for webhooks Note: Explicit column tags removed for Oracle compatibility
func (*WebhookURLDenyList) BeforeCreate ¶
func (w *WebhookURLDenyList) BeforeCreate(tx *gorm.DB) error
BeforeCreate generates a UUID if not set
func (*WebhookURLDenyList) BeforeSave ¶
func (w *WebhookURLDenyList) BeforeSave(tx *gorm.DB) error
BeforeSave validates WebhookURLDenyList before create or update
func (WebhookURLDenyList) TableName ¶
func (WebhookURLDenyList) TableName() string
TableName specifies the table name for WebhookURLDenyList