Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // WithGlobalUniqueID sets the universal ids options to the migration. // If this option is enabled, ent migration will allocate a 1<<32 range // for the ids of each entity (table). // Note that this option cannot be applied on tables that already exist. WithGlobalUniqueID = schema.WithGlobalUniqueID // WithDropColumn sets the drop column option to the migration. // If this option is enabled, ent migration will drop old columns // that were used for both fields and edges. This defaults to false. WithDropColumn = schema.WithDropColumn // WithDropIndex sets the drop index option to the migration. // If this option is enabled, ent migration will drop old indexes // that were defined in the schema. This defaults to false. // Note that unique constraints are defined using `UNIQUE INDEX`, // and therefore, it's recommended to enable this option to get more // flexibility in the schema changes. WithDropIndex = schema.WithDropIndex // WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true. WithForeignKeys = schema.WithForeignKeys )
View Source
var ( // AgentColumns holds the columns for the "agent" table. AgentColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint32, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "ext_ip", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "inet"}}, {Name: "int_ip", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "inet"}}, {Name: "os", Type: field.TypeEnum, Enums: []string{"unknown", "linux", "windows", "macos"}}, {Name: "os_meta", Type: field.TypeString, Nullable: true, Size: 1024}, {Name: "hostname", Type: field.TypeString, Nullable: true, Size: 256}, {Name: "username", Type: field.TypeString, Nullable: true, Size: 256}, {Name: "domain", Type: field.TypeString, Nullable: true, Size: 256}, {Name: "privileged", Type: field.TypeBool, Nullable: true}, {Name: "process_name", Type: field.TypeString, Nullable: true, Size: 1024}, {Name: "pid", Type: field.TypeInt64, Nullable: true}, {Name: "arch", Type: field.TypeEnum, Enums: []string{"unknown", "x86", "x64", "arm32", "arm64"}}, {Name: "sleep", Type: field.TypeUint32}, {Name: "jitter", Type: field.TypeUint8}, {Name: "first", Type: field.TypeTime}, {Name: "last", Type: field.TypeTime}, {Name: "caps", Type: field.TypeUint32}, {Name: "note", Type: field.TypeString, Nullable: true, Size: 256}, {Name: "color", Type: field.TypeUint32, Default: 0}, {Name: "listener_id", Type: field.TypeInt64}, } // AgentTable holds the schema information for the "agent" table. AgentTable = &schema.Table{ Name: "agent", Columns: AgentColumns, PrimaryKey: []*schema.Column{AgentColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "agent_listener_agent", Columns: []*schema.Column{AgentColumns[22]}, RefColumns: []*schema.Column{ListenerColumns[0]}, OnDelete: schema.NoAction, }, }, } // BlobberColumns holds the columns for the "blobber" table. BlobberColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "hash", Type: field.TypeBytes, Unique: true}, {Name: "blob", Type: field.TypeBytes}, {Name: "size", Type: field.TypeInt}, } // BlobberTable holds the schema information for the "blobber" table. BlobberTable = &schema.Table{ Name: "blobber", Columns: BlobberColumns, PrimaryKey: []*schema.Column{BlobberColumns[0]}, } // ChatColumns holds the columns for the "chat" table. ChatColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "message", Type: field.TypeString, Size: 4096}, {Name: "is_server", Type: field.TypeBool, Default: false}, {Name: "author_id", Type: field.TypeInt64, Nullable: true}, } // ChatTable holds the schema information for the "chat" table. ChatTable = &schema.Table{ Name: "chat", Columns: ChatColumns, PrimaryKey: []*schema.Column{ChatColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "chat_operator_chat", Columns: []*schema.Column{ChatColumns[4]}, RefColumns: []*schema.Column{OperatorColumns[0]}, OnDelete: schema.SetNull, }, }, } // CommandColumns holds the columns for the "command" table. CommandColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "cmd", Type: field.TypeString, Size: 4096}, {Name: "visible", Type: field.TypeBool}, {Name: "created_at", Type: field.TypeTime}, {Name: "closed_at", Type: field.TypeTime, Nullable: true}, {Name: "agent_id", Type: field.TypeUint32}, {Name: "author_id", Type: field.TypeInt64}, } // CommandTable holds the schema information for the "command" table. CommandTable = &schema.Table{ Name: "command", Columns: CommandColumns, PrimaryKey: []*schema.Column{CommandColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "command_agent_command", Columns: []*schema.Column{CommandColumns[5]}, RefColumns: []*schema.Column{AgentColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "command_operator_command", Columns: []*schema.Column{CommandColumns[6]}, RefColumns: []*schema.Column{OperatorColumns[0]}, OnDelete: schema.NoAction, }, }, } // CredentialColumns holds the columns for the "credential" table. CredentialColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "username", Type: field.TypeString, Nullable: true, Size: 256}, {Name: "secret", Type: field.TypeString, Nullable: true, Size: 4096}, {Name: "realm", Type: field.TypeString, Nullable: true, Size: 256}, {Name: "host", Type: field.TypeString, Nullable: true, Size: 256}, {Name: "note", Type: field.TypeString, Nullable: true, Size: 256}, {Name: "color", Type: field.TypeUint32, Default: 0}, } // CredentialTable holds the schema information for the "credential" table. CredentialTable = &schema.Table{ Name: "credential", Columns: CredentialColumns, PrimaryKey: []*schema.Column{CredentialColumns[0]}, } // ListenerColumns holds the columns for the "listener" table. ListenerColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "token", Type: field.TypeString, Unique: true, Nullable: true, Size: 32}, {Name: "name", Type: field.TypeString, Nullable: true, Size: 256}, {Name: "ip", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "inet"}}, {Name: "port", Type: field.TypeUint16, Nullable: true}, {Name: "color", Type: field.TypeUint32, Default: 0}, {Name: "note", Type: field.TypeString, Nullable: true, Size: 256}, {Name: "last", Type: field.TypeTime}, } // ListenerTable holds the schema information for the "listener" table. ListenerTable = &schema.Table{ Name: "listener", Columns: ListenerColumns, PrimaryKey: []*schema.Column{ListenerColumns[0]}, } // MessageColumns holds the columns for the "message" table. MessageColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "type", Type: field.TypeEnum, Enums: []string{"notify", "info", "warning", "error"}}, {Name: "message", Type: field.TypeString, Size: 4096}, {Name: "created_at", Type: field.TypeTime}, {Name: "command_id", Type: field.TypeInt64}, } // MessageTable holds the schema information for the "message" table. MessageTable = &schema.Table{ Name: "message", Columns: MessageColumns, PrimaryKey: []*schema.Column{MessageColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "message_command_message", Columns: []*schema.Column{MessageColumns[4]}, RefColumns: []*schema.Column{CommandColumns[0]}, OnDelete: schema.NoAction, }, }, } // OperatorColumns holds the columns for the "operator" table. OperatorColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "username", Type: field.TypeString, Size: 255}, {Name: "token", Type: field.TypeString, Nullable: true, Size: 32}, {Name: "color", Type: field.TypeUint32, Default: 0}, {Name: "last", Type: field.TypeTime}, } // OperatorTable holds the schema information for the "operator" table. OperatorTable = &schema.Table{ Name: "operator", Columns: OperatorColumns, PrimaryKey: []*schema.Column{OperatorColumns[0]}, } // PkiColumns holds the columns for the "pki" table. PkiColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "type", Type: field.TypeEnum, Enums: []string{"ca", "listener", "operator", "management"}}, {Name: "key", Type: field.TypeBytes}, {Name: "cert", Type: field.TypeBytes}, } // PkiTable holds the schema information for the "pki" table. PkiTable = &schema.Table{ Name: "pki", Columns: PkiColumns, PrimaryKey: []*schema.Column{PkiColumns[0]}, } // TaskColumns holds the columns for the "task" table. TaskColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "pushed_at", Type: field.TypeTime, Nullable: true}, {Name: "done_at", Type: field.TypeTime, Nullable: true}, {Name: "status", Type: field.TypeEnum, Enums: []string{"new", "in-progress", "cancelled", "success", "error"}}, {Name: "cap", Type: field.TypeEnum, Enums: []string{"cap_sleep", "cap_ls", "cap_pwd", "cap_cd", "cap_whoami", "cap_ps", "cap_cat", "cap_exec", "cap_cp", "cap_jobs", "cap_jobkill", "cap_kill", "cap_mv", "cap_mkdir", "cap_rm", "cap_exec_assembly", "cap_shell", "cap_ppid", "cap_exec_detach", "cap_shellcode_injection", "cap_download", "cap_upload", "cap_pause", "cap_destroy", "cap_exit"}}, {Name: "output_big", Type: field.TypeBool, Nullable: true}, {Name: "agent_id", Type: field.TypeUint32}, {Name: "args_id", Type: field.TypeInt}, {Name: "output_id", Type: field.TypeInt, Nullable: true}, {Name: "command_id", Type: field.TypeInt64}, } // TaskTable holds the schema information for the "task" table. TaskTable = &schema.Table{ Name: "task", Columns: TaskColumns, PrimaryKey: []*schema.Column{TaskColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "task_agent_task", Columns: []*schema.Column{TaskColumns[7]}, RefColumns: []*schema.Column{AgentColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "task_blobber_task_args", Columns: []*schema.Column{TaskColumns[8]}, RefColumns: []*schema.Column{BlobberColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "task_blobber_task_output", Columns: []*schema.Column{TaskColumns[9]}, RefColumns: []*schema.Column{BlobberColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "task_command_task", Columns: []*schema.Column{TaskColumns[10]}, RefColumns: []*schema.Column{CommandColumns[0]}, OnDelete: schema.NoAction, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ AgentTable, BlobberTable, ChatTable, CommandTable, CredentialTable, ListenerTable, MessageTable, OperatorTable, PkiTable, TaskTable, } )
Functions ¶
Types ¶
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema is the API for creating, migrating and dropping a schema.
Click to show internal directories.
Click to hide internal directories.