Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyExist error
ErrAlreadyExist is the error code when there is an attempt to register an already existing item in the database (User : name, IP : (value & project), Port : (ip & project)...)
var ErrNotFound error
ErrNotFound is the internal representation used by the adapters to express a item was not found. (Instead of returning an empty <type>)
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database interface { // General purpose functions Name() string SetupDatabase() error DeleteDatabase() error SetupAuth(username, password, dbname string) error Connect(*config.ConfigToml) error //Users CreateOrUpdateUser(user User) error CreateUser(user User) error UpdateUser(user User) error GetUser(username string) (User, error) GetUserByToken(token string) (User, error) GenerateNewToken(user User) error DeleteUser(user User) error // Project CreateOrUpdateProject(Project) error CreateProject(Project) error UpdateProject(Project) error GetProjects() ([]Project, error) GetProject(projectName string) (Project, error) DeleteProject(project Project) error // IP CreateOrUpdateIP(projectName string, ip IP) error CreateIP(projectName string, ip IP) error UpdateIP(projectName string, ip IP) error CreateOrUpdateIPs(projectName string, ip []IP) error GetIPs(projectName string) ([]IP, error) GetIP(projectName string, ip string) (IP, error) DeleteIP(ip IP) error // Domain CreateOrUpdateDomain(projectName string, domain Domain) error CreateDomain(projectName string, domain Domain) error UpdateDomain(projectName string, domain Domain) error CreateOrUpdateDomains(projectName string, domain []Domain) error GetDomains(projectName string) ([]Domain, error) GetDomain(projectName string, domain string) (Domain, error) DeleteDomain(projectName string, domain Domain) error // Port CreateOrUpdatePort(projectName string, ip string, port Port) error CreatePort(projectName string, ip string, port Port) error UpdatePort(projectName string, ip string, port Port) error CreateOrUpdatePorts(projectName string, ip string, port []Port) error GetPorts(projectName string, ip string) ([]Port, error) GetPort(projectName string, ip string, port string) (Port, error) // TOFIX : includes protocols (tcp, upd...) *optionnal* parameters. Returns CodeAmbiguousRequest if 2 ports of differents type are found. DeletePort(projectName string, ip string, port Port) error // URI (directory and files) CreateOrUpdateURI(projectName string, ip string, port string, dir URI) error CreateURI(projectName string, ip string, port string, dir URI) error UpdateURI(projectName string, ip string, port string, dir URI) error CreateOrUpdateURIs(projectName string, ip string, port string, dir []URI) error GetURIs(projectName string, ip string, port string) ([]URI, error) GetURI(projectName string, ip string, port string, dir string) (URI, error) DeleteURI(projectName string, ip string, port string, dir URI) error // Raw data AppendRawData(projectName string, data Raw) error GetRaws(projectName string) ([]Raw, error) GetRawModule(projectName string, moduleName string) (map[string][]Raw, error) }
Database is the mandatory interface for all custom database adapter
type Domain ¶
type Domain struct { Name string `json:"name,omitempty"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
Domain defines the Domain address of a target.
type IP ¶
type IP struct { Value string `json:"value,omitempty" gorm:"primary_key"` // should be net.IP, but can't enforce that in the db... Network string `sql:"default:'external'" gorm:"primary_key"` // arbitrary value, default should be "external". CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
IP defines the IP address of a target.
type Network ¶
type Network struct { Name string `json:"name"` Description string `json:"description"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
Network represent the network used by one IP. By default, every ip should be in the "external" Network
type Port ¶
type Port struct { Number int16 `json:"number,omitempty"` Protocol string `json:"protocol,omitempty"` Status string `json:"status,omitempty"` // open, filtered, closed Banner string `json:"banner,omitempty"` Type string `json:"type,omitempty"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
Port defines the basic structure for each port scanned on the target
type PortType ¶
type PortType struct { Type string Description string CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
PortType is a categorie for one ports.
func GetPortTypes ¶
func GetPortTypes() []PortType
GetPortTypes returns all the port type to insert into the database during the setup. It might be augmented during runtime by the user interaction.
type Project ¶
type Project struct { Name string `json:"name" sql:",unique"` Description string `json:"description"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
Project is the top level struct for a target. It contains a list of IPs and other metadata.
type Raw ¶
type Raw struct { Content string ModuleName string CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
Raw defines the base structure for each module data. One module must save at least this one inside it's WriteDb function. The module should dump all it's result inside the Content field.
type Route ¶
type Route struct { Source string `json:"source,omitempty"` Destination string `json:"destination,omitempty"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
Route defines the route from the host (netm4ul client) to the target
type URI ¶
type URI struct { Name string `json:"name"` Code string `json:"code,omitempty"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
URI defines one ressource from a remote target (webserver), either files or directory
type User ¶
type User struct { Name string `json:"name" sql:",unique"` Password string `json:"password,omitempty"` Token string `json:"token,omitempty" toml:"token"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
User is the default struct for each users. The token is a random char stored in the database and needed for all the API calls (except the few non authenticated ones)