model

package
v0.0.0-...-539d32a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppTypeMySQL = "mysql"
	AppTypeK8s   = "k8s"

	AppTypeMariaDB   = "mariadb"
	AppTypeSQLServer = "sqlserver"
	AppTypePostgres  = "postgresql"
	AppTypeRedis     = "redis"
	AppTypeMongoDB   = "mongodb"
	AppTypeSQLite    = "sqlite"
	AppTypeOracle    = "oracle"
)
View Source
const (
	ProtocolSSH    = "ssh"
	ProtocolTelnet = "telnet"
	ProtocolK8S    = "k8s"
	ProtocolMysql  = "mysql"
)
View Source
const (
	OperateDownload = "Download"
	OperateUpload   = "Upload"
)
View Source
const (
	OperateRemoveDir = "Rmdir"
	OperateRename    = "Rename"
	OperateMkdir     = "Mkdir"
	OperateDelete    = "Delete"
	OperateSymlink   = "Symlink"
)
View Source
const (
	HighRiskFlag = "1"
	LessRiskFlag = "0"
)
View Source
const (
	DangerLevel = 5
	NormalLevel = 0
)
View Source
const (
	TreeTypeNode  = "node"
	TreeTypeAsset = "asset"
)
View Source
const (
	ActionALL            = "all"
	ActionConnect        = "connect"
	ActionUpload         = "upload_file"
	ActionDownload       = "download_file"
	ActionUploadDownLoad = "updownload"
	ActionCopy           = "clipboard_copy"
	ActionPaste          = "clipboard_paste"
	ActionCopyPaste      = "clipboard_copy_paste"
)
View Source
const (
	SuffixReplayGz = ".replay.gz"
	SuffixCastGz   = ".cast.gz"
	SuffixCast     = ".cast"
	SuffixGz       = ".gz"
)
View Source
const (
	AllAction      = "all"
	ConnectAction  = "connect"
	UploadAction   = "upload_file"
	DownloadAction = "download_file"
)
View Source
const (
	TicketOpen     = "pending"
	TicketApproved = "approved"
	TicketRejected = "rejected"
	TicketClosed   = "closed"
)
View Source
const AppType = "Application"
View Source
const LoginModeManual = "manual"
View Source
const (
	TaskKillSession = "kill_session"
)

Variables

View Source
var (
	AccessKeyNotFound     = errors.New("access key not found")
	AccessKeyFileNotFound = errors.New("access key file not found")
	AccessKeyInvalid      = errors.New("access key not valid")
)

Functions

func SortNodesByKey

func SortNodesByKey(nodes []Node)

func SortSystemUserByPriority

func SortSystemUserByPriority(sysUsers []SystemUser)

Types

type AccessKey

type AccessKey struct {
	ID     string `json:"id"`
	Secret string `json:"secret"`
}

func (*AccessKey) LoadFromFile

func (ak *AccessKey) LoadFromFile(keyPath string) error

func (*AccessKey) LoadFromStr

func (ak *AccessKey) LoadFromStr(key string) error

func (*AccessKey) SaveToFile

func (ak *AccessKey) SaveToFile(path string) error

type Application

type Application struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Category string `json:"category"`
	TypeName string `json:"type"`
	Domain   string `json:"domain"`
	Comment  string `json:"comment"`
	OrgID    string `json:"org_id"`
	OrgName  string `json:"org_name"`

	Attrs Attrs `json:"attrs"`
}

func (Application) String

func (app Application) String() string

type Asset

type Asset struct {
	ID        string   `json:"id"`
	Hostname  string   `json:"hostname"`
	IP        string   `json:"ip"`
	Os        string   `json:"os"`
	Domain    string   `json:"domain"` // 是否需要走网域
	Comment   string   `json:"comment"`
	Protocols []string `json:"protocols"`
	OrgID     string   `json:"org_id"`
	OrgName   string   `json:"org_name"`
	Platform  string   `json:"platform"`
	IsActive  bool     `json:"is_active"` // 判断资产是否禁用
}

func (*Asset) IsSupportProtocol

func (a *Asset) IsSupportProtocol(protocol string) bool

func (*Asset) ProtocolPort

func (a *Asset) ProtocolPort(protocol string) int

func (*Asset) String

func (a *Asset) String() string

type AssetList

type AssetList []Asset

func (AssetList) SortBy

func (a AssetList) SortBy(tp string) AssetList

type AssetLoginTicketInfo

type AssetLoginTicketInfo struct {
	TicketId    string `json:"ticket_id"`
	NeedConfirm bool   `json:"need_confirm"`
	TicketInfo
}

type AssetMeta

type AssetMeta struct {
	Hostname  string   `json:"hostname"`
	IP        string   `json:"ip"`
	Protocols []string `json:"protocols"`
	Platform  string   `json:"platform"`
	OrgName   string   `json:"org_name"`
}

type AssetNodeSorter

type AssetNodeSorter struct {
	// contains filtered or unexported fields
}

func (*AssetNodeSorter) Len

func (a *AssetNodeSorter) Len() int

func (*AssetNodeSorter) Less

func (a *AssetNodeSorter) Less(i, j int) bool

func (*AssetNodeSorter) Swap

func (a *AssetNodeSorter) Swap(i, j int)

type Attrs

type Attrs struct {
	// contains filtered or unexported fields
}

type Command

type Command struct {
	SessionID  string `json:"session"`
	OrgID      string `json:"org_id"`
	Input      string `json:"input"`
	Output     string `json:"output"`
	User       string `json:"user"`
	Server     string `json:"asset"`
	SystemUser string `json:"system_user"`
	Timestamp  int64  `json:"timestamp"`
	RiskLevel  int64  `json:"risk_level"`

	DateCreated time.Time `json:"@timestamp"`
}

type CommandTicketInfo

type CommandTicketInfo struct {
	TicketInfo
}

type ConnectTokenInfo

type ConnectTokenInfo struct {
	Id          string       `json:"id"`
	Secret      string       `json:"secret"`
	TypeName    ConnectType  `json:"type"`
	User        *User        `json:"user"`
	Actions     []string     `json:"actions,omitempty"`
	Application *Application `json:"application,omitempty"`
	Asset       *Asset       `json:"asset,omitempty"`
	ExpiredAt   int64        `json:"expired_at"`
	Gateway     Gateway      `json:"gateway,omitempty"`
	Domain      *Domain      `json:"domain"`

	CmdFilterRules FilterRules `json:"cmd_filter_rules,omitempty"`

	SystemUserAuthInfo *SystemUserAuthInfo `json:"system_user"`
}

type ConnectType

type ConnectType string
const (
	ConnectApplication ConnectType = "application"
	ConnectAsset       ConnectType = "asset"
)

type Domain

type Domain struct {
	ID       string    `json:"id"`
	Gateways []Gateway `json:"gateways"`
	Name     string    `json:"name"`
}

type ExpireInfo

type ExpireInfo struct {
	HasPermission bool  `json:"has_permission"`
	ExpireAt      int64 `json:"expire_at"`

	Permission
}

func (*ExpireInfo) IsExpired

func (e *ExpireInfo) IsExpired(now time.Time) bool

type FTPLog

type FTPLog struct {
	User       string         `json:"user"`
	Hostname   string         `json:"asset"`
	OrgID      string         `json:"org_id"`
	SystemUser string         `json:"system_user"`
	RemoteAddr string         `json:"remote_addr"`
	Operate    string         `json:"operate"`
	Path       string         `json:"filename"`
	DateStart  common.UTCTime `json:"date_start"`
	IsSuccess  bool           `json:"is_success"`
}

type FilterRule

type FilterRule struct {
	ID         string     `json:"id"`
	Priority   int        `json:"priority"`
	Type       string     `json:"type"`
	Content    string     `json:"content"`
	Action     RuleAction `json:"action"`
	OrgId      string     `json:"org_id"`
	RePattern  string     `json:"pattern"` // 已经处理过的正则字符
	IgnoreCase bool       `json:"ignore_case"`
	// contains filtered or unexported fields
}

func (*FilterRule) Match

func (sf *FilterRule) Match(cmd string) (RuleAction, string)

func (*FilterRule) Pattern

func (sf *FilterRule) Pattern() *regexp.Regexp

type FilterRules

type FilterRules []FilterRule

func (FilterRules) Len

func (f FilterRules) Len() int

func (FilterRules) Less

func (f FilterRules) Less(i, j int) bool

func (FilterRules) Swap

func (f FilterRules) Swap(i, j int)

type Gateway

type Gateway struct {
	ID         string `json:"id"`
	Name       string `json:"Name"`
	IP         string `json:"ip"`
	Port       int    `json:"port"`
	Protocol   string `json:"protocol"`
	Username   string `json:"username"`
	Password   string `json:"password"`
	PrivateKey string `json:"private_key"`
}

type HeartbeatData

type HeartbeatData struct {
	SessionOnlineIds []string `json:"sessions"`
	SessionOnline    int      `json:"session_online"`
	CpuUsed          float64  `json:"cpu_load"`
	MemoryUsed       float64  `json:"memory_used"`
	DiskUsed         float64  `json:"disk_used"`
}

type MiniUser

type MiniUser struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Username string `json:"username"`
}

type Node

type Node struct {
	ID           string `json:"id"`
	Key          string `json:"key"`
	Name         string `json:"name"`
	Value        string `json:"value"`
	Parent       string `json:"parent"`
	AssetsAmount int    `json:"assets_amount"`
	OrgID        string `json:"org_id"`
}

type NodeList

type NodeList []Node

type NodeMeta

type NodeMeta struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type NodeTree

type NodeTree struct {
	ID       string   `json:"id"`
	Name     string   `json:"name"`
	Title    string   `json:"title"`
	Pid      string   `json:"pId"`
	IsParent bool     `json:"isParent"`
	Meta     TreeMeta `json:"meta"`

	ChkDisabled bool `json:"chkDisabled"` // 判断资产是否禁用
}

type NodeTreeList

type NodeTreeList []NodeTree

type NodeTreeMeta

type NodeTreeMeta struct {
	ID string `json:"id"`

	NodeMeta
	AssetMeta
}

func (NodeTreeMeta) IsSupportProtocol

func (n NodeTreeMeta) IsSupportProtocol(protocol string) bool

type PaginationParam

type PaginationParam struct {
	PageSize int
	Offset   int
	Searches []string
	Refresh  bool
}

type PaginationResponse

type PaginationResponse struct {
	Total       int                      `json:"count"`
	NextURL     string                   `json:"next"`
	PreviousURL string                   `json:"previous"`
	Data        []map[string]interface{} `json:"results"`
}

type Permission

type Permission struct {
	Actions []string `json:"actions"`
}

func (*Permission) EnableConnect

func (p *Permission) EnableConnect() bool

func (*Permission) EnableCopy

func (p *Permission) EnableCopy() bool

func (*Permission) EnableDownload

func (p *Permission) EnableDownload() bool

func (*Permission) EnableDrive

func (p *Permission) EnableDrive() bool

func (*Permission) EnablePaste

func (p *Permission) EnablePaste() bool

func (*Permission) EnableUpload

func (p *Permission) EnableUpload() bool

type Platform

type Platform struct {
	Name     string                 `json:"name"`
	BaseOs   string                 `json:"base"`
	Charset  string                 `json:"charset"`
	MetaData map[string]interface{} `json:"meta"`
}

type PublicSetting

type PublicSetting struct {
	LoginTitle string `json:"LOGIN_TITLE"`
	LogoURLS   struct {
		LogOut  string `json:"logo_logout"`
		Index   string `json:"logo_index"`
		Image   string `json:"login_image"`
		Favicon string `json:"favicon"`
	} `json:"LOGO_URLS"`
	EnableWatermark    bool `json:"SECURITY_WATERMARK_ENABLED"`
	EnableSessionShare bool `json:"SECURITY_SESSION_SHARE"`
}

type RemoteAPP

type RemoteAPP struct {
	ID         string             `json:"id"`
	Name       string             `json:"name"`
	AssetId    string             `json:"asset"`
	Parameters RemoteAppParameter `json:"parameter_remote_app"`
}

type RemoteAppParameter

type RemoteAppParameter struct {
	Parameters       string `json:"parameters"`
	Program          string `json:"program"`
	WorkingDirectory string `json:"working_directory"`
}

type ReplayConfig

type ReplayConfig struct {
	TypeName string `json:"TYPE"`

	/*
		obs oss
	*/
	Endpoint  string `json:"ENDPOINT,omitempty"`
	Bucket    string `json:"BUCKET,omitempty"`
	AccessKey string `json:"ACCESS_KEY,omitempty"`
	SecretKey string `json:"SECRET_KEY,omitempty"`

	Region string `json:"REGION,omitempty"`

	/*
		azure 专属
	*/
	AccountName    string `json:"ACCOUNT_NAME,omitempty"`
	AccountKey     string `json:"ACCOUNT_KEY,omitempty"`
	EndpointSuffix string `json:"ENDPOINT_SUFFIX,omitempty"`
	ContainerName  string `json:"CONTAINER_NAME,omitempty"`
}

type ReplayVersion

type ReplayVersion string
const (
	UnKnown  ReplayVersion = ""
	Version2 ReplayVersion = "2"
	Version3 ReplayVersion = "3"
)

func ParseReplayVersion

func ParseReplayVersion(gzFile string, defaultValue ReplayVersion) ReplayVersion

type ReqInfo

type ReqInfo struct {
	Method string `json:"method"`
	URL    string `json:"url"`
}

type RuleAction

type RuleAction int
const (
	ActionDeny    RuleAction = 0
	ActionAllow   RuleAction = 9
	ActionConfirm RuleAction = 2
	ActionUnknown RuleAction = 3

	TypeRegex = "regex"
	TypeCmd   = "command"
)

type Session

type Session struct {
	ID string `json:"id"`
	// "%s(%s)" Name Username
	User         string         `json:"user"`
	Asset        string         `json:"asset"`
	SystemUser   string         `json:"system_user"`
	LoginFrom    string         `json:"login_from"`
	RemoteAddr   string         `json:"remote_addr"`
	Protocol     string         `json:"protocol"`
	DateStart    common.UTCTime `json:"date_start"`
	OrgID        string         `json:"org_id"`
	UserID       string         `json:"user_id"`
	AssetID      string         `json:"asset_id"`
	SystemUserID string         `json:"system_user_id"`
}

type ShareRecord

type ShareRecord struct {
	ID        string      `json:"id"`
	Code      string      `json:"verify_code"`
	SessionId string      `json:"session"`
	ShareId   string      `json:"sharing"`
	OrgId     string      `json:"org_id"`
	OrgName   string      `json:"org_name"`
	Joiner    string      `json:"joiner"`
	Err       interface{} `json:"error"`
}

type SharingSession

type SharingSession struct {
	ID          string `json:"id"`
	IsActive    bool   `json:"is_active"`
	ExpiredTime int    `json:"expired_time"`
	Session     string `json:"session"`
	OrgId       string `json:"org_id"`
	OrgName     string `json:"org_name"`
	Code        string `json:"verify_code"`
}

type SystemUser

type SystemUser struct {
	ID                   string   `json:"id"`
	Name                 string   `json:"name"`
	Username             string   `json:"username"`
	Priority             int      `json:"priority"`
	Protocol             string   `json:"protocol"`
	AdDomain             string   `json:"ad_domain"`
	Comment              string   `json:"comment"`
	LoginMode            string   `json:"login_mode"`
	Password             string   `json:"-"`
	PrivateKey           string   `json:"-"`
	Actions              []string `json:"actions"`
	SftpRoot             string   `json:"sftp_root"`
	OrgId                string   `json:"org_id"`
	OrgName              string   `json:"org_name"`
	UsernameSameWithUser bool     `json:"username_same_with_user"`
	Token                string   `json:"-"`
	SuEnabled            bool     `json:"su_enabled"`
	SuFrom               string   `json:"su_from"`
}

func (*SystemUser) IsProtocol

func (s *SystemUser) IsProtocol(p string) bool

func (*SystemUser) String

func (s *SystemUser) String() string

type SystemUserAuthInfo

type SystemUserAuthInfo struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	Username   string `json:"username"`
	Protocol   string `json:"protocol"`
	LoginMode  string `json:"login_mode"`
	Password   string `json:"password"`
	PrivateKey string `json:"private_key"`
	AdDomain   string `json:"ad_domain"`
	Token      string `json:"token"`
	OrgId      string `json:"org_id"`
	OrgName    string `json:"org_name"`
	PublicKey  string `json:"public_key"`

	UsernameSameWithUser bool `json:"username_same_with_user"`
}

func (*SystemUserAuthInfo) String

func (s *SystemUserAuthInfo) String() string

type TaskKwargs

type TaskKwargs struct {
	TerminatedBy string `json:"terminated_by"`
}

type Terminal

type Terminal struct {
	Name           string `json:"name"`
	Comment        string `json:"comment"`
	ServiceAccount struct {
		ID        string    `json:"id"`
		Name      string    `json:"name"`
		AccessKey AccessKey `json:"access_key"`
	} `json:"service_account"`
}

type TerminalConfig

type TerminalConfig struct {
	AssetListPageSize   string                 `json:"TERMINAL_ASSET_LIST_PAGE_SIZE"`
	AssetListSortBy     string                 `json:"TERMINAL_ASSET_LIST_SORT_BY"`
	HeaderTitle         string                 `json:"TERMINAL_HEADER_TITLE"`
	PasswordAuth        bool                   `json:"TERMINAL_PASSWORD_AUTH"`
	PublicKeyAuth       bool                   `json:"TERMINAL_PUBLIC_KEY_AUTH"`
	ReplayStorage       ReplayConfig           `json:"TERMINAL_REPLAY_STORAGE"`
	CommandStorage      map[string]interface{} `json:"TERMINAL_COMMAND_STORAGE"`
	SessionKeepDuration int                    `json:"TERMINAL_SESSION_KEEP_DURATION"`
	TelnetRegex         string                 `json:"TERMINAL_TELNET_REGEX"`
	MaxIdleTime         int                    `json:"SECURITY_MAX_IDLE_TIME"`
	HeartbeatDuration   int                    `json:"TERMINAL_HEARTBEAT_INTERVAL"`
	HostKey             string                 `json:"TERMINAL_HOST_KEY"`
	EnableSessionShare  bool                   `json:"SECURITY_SESSION_SHARE"`
}

type TerminalTask

type TerminalTask struct {
	ID         string     `json:"id"`
	Name       string     `json:"name"`
	Args       string     `json:"args"`
	Kwargs     TaskKwargs `json:"kwargs"`
	IsFinished bool
}

type TicketInfo

type TicketInfo struct {
	CheckReq        ReqInfo  `json:"check_confirm_status"`
	CloseReq        ReqInfo  `json:"close_confirm"`
	TicketDetailUrl string   `json:"ticket_detail_url"`
	Reviewers       []string `json:"reviewers"`
}

type TicketState

type TicketState struct {
	ID        string `json:"id"`
	Processor string `json:"processor,omitempty"`
	State     string `json:"state"`
	Status    string `json:"status"`
}

type TokenUser

type TokenUser struct {
	UserID         string `json:"user"`
	UserName       string `json:"username"`
	AssetID        string `json:"asset"`
	Hostname       string `json:"hostname"`
	SystemUserID   string `json:"system_user"`
	SystemUserName string `json:"system_user_name"`

	Type          ConnectType `json:"type"`
	ApplicationID string      `json:"application"`
}

type TreeMeta

type TreeMeta struct {
	Type string       `json:"type"`
	Data NodeTreeMeta `json:"data"`
}

type User

type User struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Username string `json:"username"`
	Email    string `json:"email"`
	Role     string `json:"role"`
	IsValid  bool   `json:"is_valid"`
	IsActive bool   `json:"is_active"`
	OTPLevel int    `json:"otp_level"`
}

{'id': '1f8e54a8-d99d-4074-b35d-45264adb4e34', 'name': 'EricdeMBP.lan', 'username': 'EricdeMBP.lan', 'email': 'EricdeMBP.lan@serviceaccount.local', 'groups': [], 'groups_display': ”, 'role': 'App','role_display': '应用程序', 'avatar_url': '/static/img/avatar/user.png', 'wechat': ”,'phone': None, 'otp_level': 0, 'comment': ”, 'source': 'local', 'source_display': 'Local', 'is_valid': True, 'is_expired': False, 'is_active': True, 'created_by': ”, 'is_first_login': True, 'date_password_last_updated': '2019-04-08 18:18:24 +0800', 'date_expired': '2089-03-21 18:18:24 +0800'}

func (*User) String

func (u *User) String() string

type ValidateResult

type ValidateResult struct {
	Ok  bool   `json:"ok"`
	Msg string `json:"msg"`
	Err string `json:"error"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL