Documentation
¶
Index ¶
- Constants
- func GetHex(num int) string
- func GetStrTagName(fullTag string) string
- func RandomColor() string
- func SetCustomTag(tagType uint, custom string) string
- func TagTypeDecorator(tagType uint) string
- func TagTypeParser(tagType string) uint
- func TagsToStrings(tags []AdminTag) []string
- func ValidateCustom(anyCustom string) string
- type AdminTag
- type AdminTagForNode
- type TagCounter
- type TagManager
- func (m *TagManager) All() ([]AdminTag, error)
- func (m *TagManager) AutoTagNode(env string, node nodes.OsqueryNode, user string) error
- func (m *TagManager) ChangeColor(tag *AdminTag, color string) error
- func (m *TagManager) ChangeCustom(tag *AdminTag, custom string) error
- func (m *TagManager) ChangeDescription(tag *AdminTag, desc string) error
- func (m *TagManager) ChangeEnvironment(tag *AdminTag, envID uint) error
- func (m *TagManager) ChangeGetColor(name, color string, envID uint) error
- func (m *TagManager) ChangeGetCustom(name string, custom string, envID uint) error
- func (m *TagManager) ChangeGetDescription(name, description string, envID uint) error
- func (m *TagManager) ChangeGetEnvironment(name string, envID uint) error
- func (m *TagManager) ChangeGetIcon(name, icon string, envID uint) error
- func (m *TagManager) ChangeGetTagType(name string, tagType uint, envID uint) error
- func (m *TagManager) ChangeIcon(tag *AdminTag, icon string) error
- func (m *TagManager) ChangeTagType(tag *AdminTag, tagType uint) error
- func (m *TagManager) CountTaggedNodes(tags []AdminTag) (TagCounter, error)
- func (m *TagManager) Create(tag *AdminTag) error
- func (m *TagManager) Delete(tag *AdminTag) error
- func (m *TagManager) DeleteGet(name string, envID uint) error
- func (m *TagManager) Exists(name string) bool
- func (m *TagManager) ExistsByEnv(name string, envID uint) bool
- func (m *TagManager) ExistsGet(name string, envID uint) (bool, AdminTag)
- func (m *TagManager) Get(name string, envID uint) (AdminTag, error)
- func (m *TagManager) GetByEnv(envID uint) ([]AdminTag, error)
- func (m *TagManager) GetNodeTags(tagged []AdminTag) ([]AdminTagForNode, error)
- func (m *TagManager) GetTaggedNodes(tag AdminTag) ([]TaggedNode, error)
- func (m *TagManager) GetTags(node nodes.OsqueryNode) ([]AdminTag, error)
- func (m *TagManager) GetTagsByTypeEnv(tagType []uint, envID uint) ([]AdminTag, error)
- func (m *TagManager) IsTagged(name string, node nodes.OsqueryNode) bool
- func (m *TagManager) IsTaggedID(name string, nodeID uint) bool
- func (m *TagManager) New(name, description, color, icon, user string, envID uint, auto bool, ...) (AdminTag, error)
- func (m *TagManager) NewTag(name, description, color, icon, user string, envID uint, auto bool, ...) error
- func (m *TagManager) TagNode(name string, node nodes.OsqueryNode, user string, auto bool, tagType uint, ...) error
- func (m *TagManager) TagNodeMulti(tags []string, node nodes.OsqueryNode, user string, auto bool, custom string) error
- func (m *TagManager) UntagNode(name string, node nodes.OsqueryNode) error
- type TaggedNode
Constants ¶
const ( // DefaultTagIcon as default icon to use for tags DefaultTagIcon string = "fas fa-tag" // DefaultAutoTagUser as default user ID to be used for auto tagging DefaultAutoTagUser uint = 0 // DefaultAutocreated as default username and description for tags DefaultAutocreated = "Autocreated" // TagTypeEnv as tag type for environment name TagTypeEnv uint = 0 // TagTypePlatform as tag type for node platform TagTypePlatform uint = 2 // TagTypeCustom as tag type for custom tags TagTypeCustom uint = 4 // TagTypeUnknown as tag type for unknown tags TagTypeUnknown uint = 5 // TagTypeTag as tag type for regular tags TagTypeTag uint = 6 // ActionAdd as action to add a tag ActionAdd string = "add" // ActionEdit as action to edit a tag ActionEdit string = "edit" // ActionRemove as action to remove a tag ActionRemove string = "remove" // ActionTag as action to tag a node ActionTag string = "tag" // ActionUntag as action to untag a node ActionUntag string = "untag" // TagCustomEnv as custom tag for environment name TagCustomEnv string = TagTypeEnvStr // TagCustomPlatform as custom tag for node platform TagCustomPlatform string = TagTypePlatformStr // TagCustomUnknown as custom tag for unknown tags TagCustomUnknown string = TagTypeUnknownStr // TagCustomTag as custom tag for regular tags TagCustomTag string = TagTypeTagStr )
const ( // TagTypeEnvStr is the tag type for shortened environment TagTypeEnvStr = "env" // TagTypePlatformStr is the tag type for platform TagTypePlatformStr = "platform" // TagTypeCustomStr is the tag type for custom TagTypeCustomStr = "custom" // TagTypeUnknownStr is the tag type for unknown TagTypeUnknownStr = "unknown" // TagTypeTagStr is the tag type for tag TagTypeTagStr = "tag" )
Variables ¶
This section is empty.
Functions ¶
func GetStrTagName ¶ added in v0.4.7
Helper to extract custom tag and name from a full tag string
func SetCustomTag ¶ added in v0.4.7
Helper to define the custom tag value based on the type
func TagTypeDecorator ¶
Helper to convert the tag type to a string
func TagTypeParser ¶
Helper to convert the tag type string to a uint
func TagsToStrings ¶ added in v0.4.7
Helper to convert a slice of tags to a slice of strings
func ValidateCustom ¶ added in v0.4.7
Helper to make sure the custom value is valid
Types ¶
type AdminTag ¶
type AdminTag struct {
gorm.Model
Name string `gorm:"index"`
Description string
Color string
Icon string
CreatedBy string
CustomTag string
AutoTag bool
EnvironmentID uint
TagType uint
Cohort bool
}
AdminTag to hold all tags
type AdminTagForNode ¶
AdminTagForNode to check if this tag is used for an specific node
type TagCounter ¶ added in v0.4.8
TagCounter to hold tagged node counts
type TagManager ¶
TagManager have all tags
func CreateTagManager ¶
func CreateTagManager(backend *gorm.DB) *TagManager
CreateTagManager to initialize the tags struct and tables
func (*TagManager) AutoTagNode ¶
func (m *TagManager) AutoTagNode(env string, node nodes.OsqueryNode, user string) error
AutoTagNode to automatically tag a node based on multiple fields
func (*TagManager) ChangeColor ¶
func (m *TagManager) ChangeColor(tag *AdminTag, color string) error
ChangeColor to update color for a tag
func (*TagManager) ChangeCustom ¶ added in v0.4.7
func (m *TagManager) ChangeCustom(tag *AdminTag, custom string) error
ChangeCustom to update custom value for a tag
func (*TagManager) ChangeDescription ¶
func (m *TagManager) ChangeDescription(tag *AdminTag, desc string) error
ChangeDescription to update description for a tag
func (*TagManager) ChangeEnvironment ¶
func (m *TagManager) ChangeEnvironment(tag *AdminTag, envID uint) error
ChangeEnvironment to update environment for a tag
func (*TagManager) ChangeGetColor ¶
func (m *TagManager) ChangeGetColor(name, color string, envID uint) error
ChangeGetColor to update color for a tag
func (*TagManager) ChangeGetCustom ¶ added in v0.4.7
func (m *TagManager) ChangeGetCustom(name string, custom string, envID uint) error
ChangeGetCustom to update custom value for a tag
func (*TagManager) ChangeGetDescription ¶
func (m *TagManager) ChangeGetDescription(name, description string, envID uint) error
ChangeGetDescription to update description for a tag
func (*TagManager) ChangeGetEnvironment ¶
func (m *TagManager) ChangeGetEnvironment(name string, envID uint) error
ChangeGetEnvironment to update environment for a tag
func (*TagManager) ChangeGetIcon ¶
func (m *TagManager) ChangeGetIcon(name, icon string, envID uint) error
ChangeGetIcon to update icon for a tag
func (*TagManager) ChangeGetTagType ¶
func (m *TagManager) ChangeGetTagType(name string, tagType uint, envID uint) error
ChangeGetTagType to update tag type for a tag
func (*TagManager) ChangeIcon ¶
func (m *TagManager) ChangeIcon(tag *AdminTag, icon string) error
ChangeIcon to update icon for a tag
func (*TagManager) ChangeTagType ¶
func (m *TagManager) ChangeTagType(tag *AdminTag, tagType uint) error
ChangeTagType to update tag type for a tag
func (*TagManager) CountTaggedNodes ¶ added in v0.4.8
func (m *TagManager) CountTaggedNodes(tags []AdminTag) (TagCounter, error)
CountTaggedNodes to count tagged nodes for a given list of tags
func (*TagManager) DeleteGet ¶
func (m *TagManager) DeleteGet(name string, envID uint) error
DeleteGet tag by name
func (*TagManager) Exists ¶
func (m *TagManager) Exists(name string) bool
Exists checks if tag exists
func (*TagManager) ExistsByEnv ¶
func (m *TagManager) ExistsByEnv(name string, envID uint) bool
ExistsByEnv checks if tag exists by environment
func (*TagManager) ExistsGet ¶
func (m *TagManager) ExistsGet(name string, envID uint) (bool, AdminTag)
ExistsGet checks if tag exists and returns the tag
func (*TagManager) Get ¶
func (m *TagManager) Get(name string, envID uint) (AdminTag, error)
Get tag by name
func (*TagManager) GetByEnv ¶
func (m *TagManager) GetByEnv(envID uint) ([]AdminTag, error)
All get all tags by environment
func (*TagManager) GetNodeTags ¶
func (m *TagManager) GetNodeTags(tagged []AdminTag) ([]AdminTagForNode, error)
GetNodeTags to decorate tags for a given node
func (*TagManager) GetTaggedNodes ¶ added in v0.4.7
func (m *TagManager) GetTaggedNodes(tag AdminTag) ([]TaggedNode, error)
GetTaggedNodes to retrieve tagged nodes with a given tag name and environment
func (*TagManager) GetTags ¶
func (m *TagManager) GetTags(node nodes.OsqueryNode) ([]AdminTag, error)
GetTags to retrieve the tags of a given node
func (*TagManager) GetTagsByTypeEnv ¶ added in v0.4.7
func (m *TagManager) GetTagsByTypeEnv(tagType []uint, envID uint) ([]AdminTag, error)
GetTagsByTypeEnv to retrieve the tags of a given type and environment
func (*TagManager) IsTagged ¶
func (m *TagManager) IsTagged(name string, node nodes.OsqueryNode) bool
IsTagged to check if a node is already tagged
func (*TagManager) IsTaggedID ¶
func (m *TagManager) IsTaggedID(name string, nodeID uint) bool
IsTaggedID to check if a node is already tagged by node ID
func (*TagManager) New ¶
func (m *TagManager) New(name, description, color, icon, user string, envID uint, auto bool, tagType uint, custom string) (AdminTag, error)
New empty tag
func (*TagManager) NewTag ¶
func (m *TagManager) NewTag(name, description, color, icon, user string, envID uint, auto bool, tagType uint, custom string) error
NewTag to create a tag and creates it without returning it
func (*TagManager) TagNode ¶
func (m *TagManager) TagNode(name string, node nodes.OsqueryNode, user string, auto bool, tagType uint, custom string) error
TagNode to tag a node, tag is created if does not exist TODO use the correct user_id
func (*TagManager) TagNodeMulti ¶
func (m *TagManager) TagNodeMulti(tags []string, node nodes.OsqueryNode, user string, auto bool, custom string) error
TagNodeMulti to tag a node with multiple tags TODO use the correct user_id
func (*TagManager) UntagNode ¶
func (m *TagManager) UntagNode(name string, node nodes.OsqueryNode) error
UntagNode to untag a node