session

package
v0.0.0-...-6a08245 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INT    = 1
	STRING = 2
	BOOL   = 3
	FLOAT  = 4
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	ConnectionInstance
	ORM        *gorm.DB               `json:"-"`
	Migrations map[string]interface{} `json:"-"`
}

func (*Connection) GetDB

func (c *Connection) GetDB() *sql.DB

func (*Connection) GetORM

func (c *Connection) GetORM() *gorm.DB

func (*Connection) LoadMigration

func (c *Connection) LoadMigration()

func (*Connection) Migrate

func (c *Connection) Migrate() bool

type ConnectionInstance

type ConnectionInstance interface {
	GetORM() *gorm.DB
	GetDB() *sql.DB
	Migrate() bool
}

type CronJob

type CronJob interface {
	Name() string
	Run() (bool, error)
	GetHibernate() time.Duration
	HasConfiguration() bool
	GetConfiguration() map[string]string
	GetRequired() []string
}

type Headers

type Headers map[string]string

func (Headers) Add

func (header Headers) Add(key string, value string)

type Information

type Information struct {
	ApiStatus      bool `json:"api_status"`
	ModuleLaunched int  `json:"module_launched"`
	Event          int  `json:"event"`
}

func (*Information) AddEvent

func (i *Information) AddEvent()

func (*Information) AddModule

func (i *Information) AddModule()

func (*Information) SetApi

func (i *Information) SetApi(s bool)

type Linking

type Linking struct {
	LinkingId      int    `json:"-" gorm:"primary_key:yes;column:id;AUTO_INCREMENT"`
	SessionId      int    `json:"session_id" gorm:"column:session_id"`
	TargetBase     string `json:"target_base" gorm:"column:target_base"`
	TargetId       string `json:"target_id" gorm:"column:target_id"`
	TargetName     string `json:"target_name" gorm:"column:target_name"`
	TargetType     string `json:"target_type" gorm:"column:target_type"`
	TargetResultId string `json:"target_result_id" gorm:"column:target_result_id"`
}

func (Linking) TableName

func (Linking) TableName() string

type Listener

type Listener struct {
	ExecutedAt    time.Time `json:"executed_at"`
	NextExecution time.Time `json:"next_execution"`
	CronJob       CronJob   `json:"cron_job"`
}

type Module

type Module interface {
	Start()
	Name() string
	Author() string
	Description() string
	GetType() string
	ListArguments()
	GetExport() []TargetResults
	SetExport(result TargetResults)
	GetResults() []string
	GetInformation() ModuleInformation
	CheckRequired() bool
	SetParameter(name string, value string) (bool, error)
	GetParameter(name string) (Param, error)
	GetAllParameters() []Param
	WithProgram(name string) bool
	GetExternal() []string
	CreateNewParam(name string, description string, value string, isRequired bool, paramType int)
}

type ModuleFilter

type ModuleFilter interface {
	Start(mod Module)
	Name() string
	Description() string
	Author() string
	WorkWith(name string) bool
}

type ModuleInformation

type ModuleInformation struct {
	Name        string  `json:"name"`
	Description string  `json:"description"`
	Author      string  `json:"author"`
	Type        string  `json:"type"`
	Parameters  []Param `json:"parameters"`
}

type Note

type Note struct {
	Id   int    `json:"id"`
	Text string `json:"text"`
}

type OpfClient

type OpfClient struct {
	Client  http.Client
	Header  Headers
	Data    interface{}
	WithTor bool
}

func GetOpfClient

func GetOpfClient() OpfClient

func (*OpfClient) Perform

func (c *OpfClient) Perform(method string, uri string, body io.Reader) (*http.Response, error)

type Param

type Param struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Value       string `json:"value"`
	IsRequired  bool   `json:"is_required"`
	ParamType   int    `json:"param_type"`
}

type Session

type Session struct {
	Id            int         `json:"-" gorm:"primary_key:yes;column:id;AUTO_INCREMENT"`
	SessionName   string      `json:"session_name"`
	Information   Information `json:"information"`
	Connection    Connection  `json:"-" sql:"-"`
	Client        OpfClient
	Config        config.Config     `json:"config" sql:"-"`
	Version       string            `json:"version" sql:"-"`
	Targets       []*Target         `json:"subjects" sql:"-"`
	Modules       []Module          `json:"modules" sql:"-"`
	Filters       []ModuleFilter    `json:"filters" sql:"-"`
	Prompt        *readline.Config  `json:"-" sql:"-"`
	Stream        Stream            `json:"-" sql:"-"`
	TypeLists     []string          `json:"type_lists" sql:"-"`
	ServiceFolder string            `json:"home_folder"`
	Services      []Listener        `json:"services"`
	Alias         map[string]string `json:"-" sql:"-"`
}

func (*Session) AddAlias

func (s *Session) AddAlias(alias string, module string)

func (*Session) AddService

func (s *Session) AddService(service Listener)

func (*Session) AddTarget

func (s *Session) AddTarget(t string, name string) (string, error)

func (*Session) BooleanToString

func (s *Session) BooleanToString(element bool) string

func (*Session) ClearScreen

func (s *Session) ClearScreen()

func (*Session) ExportNow

func (s *Session) ExportNow() SessionExport

func (*Session) FindLinked

func (s *Session) FindLinked(m string, res TargetResults) ([]string, error)

func (*Session) FindLinkedTargetByResult

func (s *Session) FindLinkedTargetByResult(t *Target)

func (*Session) GetAlias

func (s *Session) GetAlias(alias string) (string, error)

func (*Session) GetId

func (s *Session) GetId() int

func (*Session) GetResult

func (s *Session) GetResult(id string) (*TargetResults, error)

func (*Session) GetTarget

func (s *Session) GetTarget(id string) (*Target, error)

func (*Session) GetTargetByName

func (s *Session) GetTargetByName(name string) (*Target, error)

func (*Session) IntegerToString

func (s *Session) IntegerToString(element int) string

func (*Session) ListAlias

func (s *Session) ListAlias()

func (*Session) ListTargets

func (s *Session) ListTargets()

func (*Session) ListType

func (s *Session) ListType() []string

func (*Session) ParseCommand

func (s *Session) ParseCommand(line string) []string

func (*Session) PushPrompt

func (s *Session) PushPrompt()

func (*Session) PushType

func (s *Session) PushType(t string)

func (*Session) ReadLineAutoCompleteFilters

func (s *Session) ReadLineAutoCompleteFilters() func(string) []string

func (*Session) ReadLineAutoCompleteListAlias

func (s *Session) ReadLineAutoCompleteListAlias() func(string) []string

func (*Session) ReadLineAutoCompleteListModules

func (s *Session) ReadLineAutoCompleteListModules() func(string) []string

func (*Session) ReadLineAutoCompleteModuleResults

func (s *Session) ReadLineAutoCompleteModuleResults() func(string) []string

func (*Session) ReadLineAutoCompleteResults

func (s *Session) ReadLineAutoCompleteResults() func(string) []string

func (*Session) ReadLineAutoCompleteTargets

func (s *Session) ReadLineAutoCompleteTargets() func(string) []string

func (*Session) ReadLineAutoCompleteType

func (s *Session) ReadLineAutoCompleteType() func(string) []string

func (*Session) RemoveTarget

func (s *Session) RemoveTarget(id string) (bool, error)

func (*Session) SearchFilter

func (s *Session) SearchFilter(name string) (ModuleFilter, error)

func (*Session) SearchModule

func (s *Session) SearchModule(name string) (Module, error)

func (*Session) StringToBoolean

func (s *Session) StringToBoolean(element string) bool

func (*Session) StringToInteger

func (s *Session) StringToInteger(element string) int

func (Session) TableName

func (Session) TableName() string

func (*Session) UpdateTarget

func (s *Session) UpdateTarget(id string, value string)

type SessionExport

type SessionExport struct {
	Id            int            `json:"-"`
	SessionName   string         `json:"session_name"`
	Information   Information    `json:"information"`
	Config        config.Config  `json:"config" sql:"-"`
	Version       string         `json:"version" sql:"-"`
	Targets       []*Target      `json:"subjects" sql:"-"`
	Modules       []Module       `json:"modules" sql:"-"`
	Filters       []ModuleFilter `json:"filters" sql:"-"`
	Stream        Stream         `json:"-" sql:"-"`
	TypeLists     []string       `json:"type_lists" sql:"-"`
	ServiceFolder string         `json:"home_folder"`
	Services      []Listener     `json:"services"`
}

type SessionFilter

type SessionFilter struct {
	ModuleFilter
	With []string
}

func (*SessionFilter) AddModule

func (filter *SessionFilter) AddModule(name string)

func (*SessionFilter) WorkWith

func (filter *SessionFilter) WorkWith(name string) bool

type SessionModule

type SessionModule struct {
	Module
	Export     []TargetResults
	Parameters []Param  `json:"parameters"`
	History    []string `json:"history"`
	External   []string `json:"external"`
	Results    []string
}

func (*SessionModule) CheckRequired

func (module *SessionModule) CheckRequired() bool

func (*SessionModule) CreateNewParam

func (module *SessionModule) CreateNewParam(name string, description string, value string, isRequired bool, paramType int)

func (*SessionModule) GetAllParameters

func (module *SessionModule) GetAllParameters() []Param

func (*SessionModule) GetExport

func (module *SessionModule) GetExport() []TargetResults

func (*SessionModule) GetExternal

func (module *SessionModule) GetExternal() []string

func (*SessionModule) GetParameter

func (module *SessionModule) GetParameter(name string) (Param, error)

func (*SessionModule) GetResults

func (module *SessionModule) GetResults() []string

func (*SessionModule) ListArguments

func (module *SessionModule) ListArguments()

func (*SessionModule) SetExport

func (module *SessionModule) SetExport(result TargetResults)

func (*SessionModule) SetParameter

func (module *SessionModule) SetParameter(name string, value string) (bool, error)

func (*SessionModule) WithProgram

func (module *SessionModule) WithProgram(name string) bool

type Stream

type Stream struct {
	Sess    *Session          `json:"-"`
	Verbose bool              `json:"verbose"`
	JSON    bool              `json:"json"`
	History map[string]string `json:"history"`
}

func (*Stream) Error

func (stream *Stream) Error(text string)

func (*Stream) GenerateTable

func (stream *Stream) GenerateTable() table.Writer

func (*Stream) Render

func (stream *Stream) Render(t table.Writer)

func (*Stream) Standard

func (stream *Stream) Standard(text string)

func (*Stream) Success

func (stream *Stream) Success(text string)

func (*Stream) Warning

func (stream *Stream) Warning(text string)

func (*Stream) WithoutDate

func (stream *Stream) WithoutDate(text string)

type Target

type Target struct {
	Id           int                         `json:"-" gorm:"primary_key:yes;column:id;AUTO_INCREMENT"`
	SessionId    int                         `json:"-" gorm:"column:session_id"`
	TargetId     string                      `json:"id" gorm:"column:target_id"`
	Sess         *Session                    `json:"-" gorm:"-"`
	Name         string                      `json:"name" gorm:"column:target_name"`
	Type         string                      `json:"type" gorm:"column:target_type"`
	Results      map[string][]*TargetResults `sql:"-" json:"results"`
	TargetLinked []Linking                   `json:"target_linked" sql:"-"`
	Notes        []Note                      `json:"notes" sql:"-"`
	Tags         []string                    `json:"tags"  sql:"-"`
}

func (*Target) AddNote

func (target *Target) AddNote(text string)

func (*Target) AddTag

func (target *Target) AddTag(tag string) (bool, error)

func (*Target) CheckType

func (target *Target) CheckType() bool

func (*Target) GetFormatedResults

func (target *Target) GetFormatedResults(module string) ([]map[string]string, error)

func (*Target) GetId

func (sub *Target) GetId() string

func (*Target) GetLinked

func (sub *Target) GetLinked() []Linking

func (*Target) GetModuleResults

func (target *Target) GetModuleResults(name string) ([]*TargetResults, error)

func (*Target) GetName

func (sub *Target) GetName() string

func (*Target) GetResult

func (target *Target) GetResult(id string) (*TargetResults, error)

func (*Target) GetResults

func (sub *Target) GetResults() map[string][]*TargetResults

func (*Target) GetSeparator

func (target *Target) GetSeparator() string

func (*Target) GetTags

func (target *Target) GetTags() []string

func (*Target) GetType

func (sub *Target) GetType() string

func (*Target) HasTag

func (target *Target) HasTag(tag string) bool
func (target *Target) Link(target2 Linking)

func (*Target) Linked

func (target *Target) Linked()

func (*Target) PushLinked

func (sub *Target) PushLinked(t Linking)

func (*Target) Save

func (target *Target) Save(module Module, result TargetResults) bool

type TargetResults

type TargetResults struct {
	Id         int    `json:"-" gorm:"primary_key:yes;column:id;AUTO_INCREMENT"`
	SessionId  int    `json:"-" gorm:"session_id"`
	ModuleName string `json:"module_name"`
	ResultId   string `json:"result_id" gorm:"primary_key:yes;column:result_id"`
	TargetId   string `json:"target_id" gorm:"target_id"`
	Header     string `json:"key" gorm:"result_header"`
	Value      string `json:"value" gorm:"result_value"`
	Notes      []Note
}

func (*TargetResults) AddNote

func (result *TargetResults) AddNote(text string)

Jump to

Keyboard shortcuts

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