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 ( // BeaconColumns holds the columns for the "beacon" table. BeaconColumns = []*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: "bid", Type: field.TypeUint32, Unique: 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.TypeUint32, 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.TypeInt}, } // BeaconTable holds the schema information for the "beacon" table. BeaconTable = &schema.Table{ Name: "beacon", Columns: BeaconColumns, PrimaryKey: []*schema.Column{BeaconColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "beacon_listener_beacon", Columns: []*schema.Column{BeaconColumns[23]}, 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: "from", Type: field.TypeInt, 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[3]}, RefColumns: []*schema.Column{OperatorColumns[0]}, OnDelete: schema.SetNull, }, }, } // CredentialColumns holds the columns for the "credential" table. CredentialColumns = []*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: "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]}, } // GroupColumns holds the columns for the "group" table. GroupColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, 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: "bid", Type: field.TypeInt}, {Name: "author", Type: field.TypeInt}, } // GroupTable holds the schema information for the "group" table. GroupTable = &schema.Table{ Name: "group", Columns: GroupColumns, PrimaryKey: []*schema.Column{GroupColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "group_beacon_group", Columns: []*schema.Column{GroupColumns[5]}, RefColumns: []*schema.Column{BeaconColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "group_operator_group", Columns: []*schema.Column{GroupColumns[6]}, RefColumns: []*schema.Column{OperatorColumns[0]}, OnDelete: schema.NoAction, }, }, } // ListenerColumns holds the columns for the "listener" table. ListenerColumns = []*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: "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: "gid", Type: field.TypeInt}, } // 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_group_message", Columns: []*schema.Column{MessageColumns[4]}, RefColumns: []*schema.Column{GroupColumns[0]}, OnDelete: schema.NoAction, }, }, } // OperatorColumns holds the columns for the "operator" table. OperatorColumns = []*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: "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.TypeInt, 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{"c_sleep", "c_ls", "c_pwd", "c_cd", "c_whoami", "c_ps", "c_cat", "c_exec", "c_cp", "c_jobs", "c_jobkill", "c_kill", "c_mv", "c_mkdir", "c_rm", "c_exec_assembly", "c_shell", "c_ppid", "c_exec_detach", "c_shellcode_injection", "c_download", "c_upload", "c_pause", "c_destruct", "c_exit", "c_socks5"}}, {Name: "output_big", Type: field.TypeBool, Nullable: true}, {Name: "bid", Type: field.TypeInt}, {Name: "args", Type: field.TypeInt}, {Name: "output", Type: field.TypeInt, Nullable: true}, {Name: "gid", Type: field.TypeInt}, } // 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_beacon_task", Columns: []*schema.Column{TaskColumns[7]}, RefColumns: []*schema.Column{BeaconColumns[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_group_task", Columns: []*schema.Column{TaskColumns[10]}, RefColumns: []*schema.Column{GroupColumns[0]}, OnDelete: schema.NoAction, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ BeaconTable, BlobberTable, ChatTable, CredentialTable, GroupTable, 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.