console

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommandLocal    = "local"
	CommandRemote   = "remote"
	CommandCarve    = "carve"
	CommandMode     = "mode"
	CommandExitMode = "exit-mode"

	StatusQueued    = "queued"
	StatusDelivered = "delivered"
	StatusCompleted = "completed"
	StatusError     = "error"
	StatusExpired   = "expired"
)

Variables

This section is empty.

Functions

func DefaultCWD

func DefaultCWD(platform string) string

Types

type Command

type Command struct {
	ID                   uint           `gorm:"primarykey" json:"id"`
	CreatedAt            time.Time      `json:"created_at"`
	UpdatedAt            time.Time      `json:"updated_at"`
	DeletedAt            gorm.DeletedAt `gorm:"index" json:"-"`
	SessionID            uint           `gorm:"not null;index" json:"session_id"`
	Input                string         `gorm:"not null" json:"input"`
	TranslatedSQL        string         `json:"translated_sql"`
	DistributedQueryName string         `gorm:"index" json:"distributed_query_name,omitempty"`
	Status               string         `gorm:"not null;index" json:"status"`
	Error                string         `json:"error,omitempty"`
	DeliveredAt          *time.Time     `json:"delivered_at,omitempty"`
	CompletedAt          *time.Time     `json:"completed_at,omitempty"`
	ExpiredAt            *time.Time     `json:"expired_at,omitempty"`
}

func (Command) TableName

func (Command) TableName() string

type HistoryEntry

type HistoryEntry struct {
	Command Command          `json:"command"`
	Results []map[string]any `json:"results"`
}

type Manager

type Manager struct {
	DB      *gorm.DB
	Queries *queries.Queries
}

func NewManager

func NewManager(db *gorm.DB, queryManager *queries.Queries) *Manager

func (*Manager) CloseSession

func (m *Manager) CloseSession(sessionID uint) error

func (*Manager) CommandResults

func (m *Manager) CommandResults(commandID uint) ([]map[string]any, error)

func (*Manager) CreateSession

func (m *Manager) CreateSession(env environments.TLSEnvironment, node nodes.OsqueryNode, creator string) (Session, error)

func (*Manager) GetCommand

func (m *Manager) GetCommand(sessionID, commandID uint) (Command, error)

func (*Manager) GetSession

func (m *Manager) GetSession(sessionID uint) (Session, error)

func (*Manager) History

func (m *Manager) History(envID, nodeID uint, creator string, limit int) ([]HistoryEntry, error)

func (*Manager) RefreshCommandStatus

func (m *Manager) RefreshCommandStatus(commandID uint) (Command, error)

func (*Manager) SubmitCommand

func (m *Manager) SubmitCommand(sessionID uint, input string, osqueryModeOpt ...bool) (Command, ParsedCommand, error)

func (*Manager) SubmitCommandWithTimeout

func (m *Manager) SubmitCommandWithTimeout(sessionID uint, input string, timeout time.Duration, osqueryModeOpt ...bool) (Command, ParsedCommand, error)

func (*Manager) TouchSession

func (m *Manager) TouchSession(sessionID uint) (Session, error)

type ParsedCommand

type ParsedCommand struct {
	Kind    string `json:"kind"`
	Command string `json:"command"`
	Mode    string `json:"mode,omitempty"`
	Path    string `json:"path,omitempty"`
	SQL     string `json:"sql,omitempty"`
	Output  string `json:"output,omitempty"`
	Message string `json:"message,omitempty"`
}

func Parse

func Parse(input, cwd, platform string) (ParsedCommand, error)

func ParseInput

func ParseInput(input, cwd, platform string, osqueryMode bool) (ParsedCommand, error)

type Session

type Session struct {
	ID            uint           `gorm:"primarykey" json:"id"`
	CreatedAt     time.Time      `json:"created_at"`
	UpdatedAt     time.Time      `json:"updated_at"`
	DeletedAt     gorm.DeletedAt `gorm:"index" json:"-"`
	EnvironmentID uint           `gorm:"not null;index" json:"environment_id"`
	NodeID        uint           `gorm:"not null;index" json:"node_id"`
	NodeUUID      string         `gorm:"not null;index" json:"node_uuid"`
	Creator       string         `gorm:"not null;index" json:"creator"`
	CWD           string         `gorm:"not null" json:"cwd"`
	Platform      string         `json:"platform"`
	Active        bool           `gorm:"not null;default:true" json:"active"`
	ClosedAt      *time.Time     `json:"closed_at,omitempty"`
}

func (Session) TableName

func (Session) TableName() string

Jump to

Keyboard shortcuts

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