Documentation ¶
Index ¶
- Constants
- Variables
- func AddItem(itemType string, item Item) error
- func CheckName(vname string, fauthor string, fname string) bool
- func CheckSuffix(hubpath string, remotePath string) bool
- func CollecDepsCheck(v *Item) error
- func DisplaySummary()
- func DownloadDataIfNeeded(hub *csconfig.Hub, target Item, force bool) error
- func DownloadHubIdx(hub *csconfig.Hub) ([]byte, error)
- func GetHubIdx(hub *csconfig.Hub) error
- func GetInstalledCollectionsAsString() ([]string, error)
- func GetInstalledParsersAsString() ([]string, error)
- func GetInstalledPostOverflowsAsString() ([]string, error)
- func GetInstalledScenariosAsString() ([]string, error)
- func GetItemMap(itemType string) map[string]Item
- func GetVersionStatus(v *Item) int
- func InstallItem(csConfig *csconfig.Config, name string, obtype string, force bool, ...) error
- func ItemStatus(v Item) (string, bool, bool, bool)
- func LoadPkgIndex(buff []byte) (map[string]map[string]Item, error)
- func LocalSync(hub *csconfig.Hub) (error, []string)
- func RemoveMany(csConfig *csconfig.Config, itemType string, name string, all bool, purge bool, ...)
- func SetHubBranch() error
- func SyncDir(hub *csconfig.Hub, dir string) (error, []string)
- func UpdateHubIdx(hub *csconfig.Hub) error
- func UpgradeConfig(csConfig *csconfig.Config, itemType string, name string, force bool)
- type Item
- func DisableItem(hub *csconfig.Hub, target Item, purge bool, force bool) (Item, error)
- func DownloadItem(hub *csconfig.Hub, target Item, overwrite bool) (Item, error)
- func DownloadLatest(hub *csconfig.Hub, target Item, overwrite bool, updateOnly bool) (Item, error)
- func EnableItem(hub *csconfig.Hub, target Item) (Item, error)
- func GetInstalledCollections() ([]Item, error)
- func GetInstalledParsers() ([]Item, error)
- func GetInstalledPostOverflows() ([]Item, error)
- func GetInstalledScenarios() ([]Item, error)
- func GetItem(itemType string, itemName string) *Item
- func GetItemByPath(itemType string, itemPath string) (*Item, error)
- type ItemHubStatus
- type ItemVersion
Constants ¶
const PathSeparator = "/"
Variables ¶
var COLLECTIONS = "collections"
var HubBranch = "master"
var HubIndexFile = ".index.json"
var ItemTypes = []string{PARSERS, PARSERS_OVFLW, SCENARIOS, COLLECTIONS}
var MissingHubIndex = errors.New("hub index can't be found")
var PARSERS = "parsers"
managed configuration types
var PARSERS_OVFLW = "postoverflows"
var RawFileURLTemplate = "https://hub-cdn.crowdsec.net/%s/%s"
var ReferenceMissingError = errors.New("Reference(s) missing in collection")
To be used when reference(s) (is/are) missing in a collection
var SCENARIOS = "scenarios"
Functions ¶
func CheckSuffix ¶ added in v1.4.0
func CollecDepsCheck ¶
func DisplaySummary ¶
func DisplaySummary()
func DownloadDataIfNeeded ¶ added in v1.2.0
func GetInstalledCollectionsAsString ¶ added in v1.3.3
func GetInstalledParsersAsString ¶ added in v1.3.3
func GetInstalledPostOverflowsAsString ¶ added in v1.3.3
func GetInstalledScenariosAsString ¶ added in v1.3.3
func GetItemMap ¶ added in v1.0.0
func GetVersionStatus ¶ added in v1.0.10
GetVersionStatus : semver requires 'v' prefix
func InstallItem ¶ added in v1.3.3
func ItemStatus ¶
returns: human-text, Enabled, Warning, Unmanaged
func LoadPkgIndex ¶
LoadPkgIndex loads a local .index.json file and returns the map of parsers/scenarios/collections associated
func RemoveMany ¶ added in v1.3.3
func RemoveMany(csConfig *csconfig.Config, itemType string, name string, all bool, purge bool, forceAction bool)
XXX this must return errors instead of log.Fatal
func SetHubBranch ¶ added in v1.4.0
func SetHubBranch() error
SetHubBranch sets the package variable that points to the hub branch.
func UpdateHubIdx ¶
Types ¶
type Item ¶
type Item struct { /*descriptive info*/ Type string `yaml:"type,omitempty" json:"type,omitempty"` //parser|postoverflows|scenario|collection(|enrich) Stage string `json:"stage,omitempty" yaml:"stage,omitempty,omitempty"` //Stage for parser|postoverflow : s00-raw/s01-... Name string `json:"name,omitempty"` //as seen in .config.json, usually "author/name" FileName string `json:"file_name,omitempty"` //the filename, ie. apache2-logs.yaml Description string `yaml:"description,omitempty" json:"description,omitempty"` //as seen in .config.json Author string `json:"author,omitempty"` //as seen in .config.json References []string `yaml:"references,omitempty" json:"references,omitempty"` //as seen in .config.json BelongsToCollections []string `yaml:"belongs_to_collections,omitempty" json:"belongs_to_collections,omitempty"` /*if it's part of collections, track name here*/ /*remote (hub) infos*/ RemoteURL string `yaml:"remoteURL,omitempty" json:"remoteURL,omitempty"` //the full remote uri of file in http RemotePath string `json:"path,omitempty" yaml:"remote_path,omitempty"` //the path relative to git ie. /parsers/stage/author/file.yaml RemoteHash string `yaml:"hash,omitempty" json:"hash,omitempty"` //the meow Version string `json:"version,omitempty"` //the last version Versions map[string]ItemVersion `json:"versions,omitempty" yaml:"-"` //the list of existing versions /*local (deployed) infos*/ LocalPath string `yaml:"local_path,omitempty" json:"local_path,omitempty"` //the local path relative to ${CFG_DIR} //LocalHubPath string LocalVersion string `json:"local_version,omitempty"` LocalHash string `json:"local_hash,omitempty"` //the local meow Installed bool `json:"installed,omitempty"` Downloaded bool `json:"downloaded,omitempty"` UpToDate bool `json:"up_to_date,omitempty"` Tainted bool `json:"tainted,omitempty"` //has it been locally modified Local bool `json:"local,omitempty"` //if it's a non versioned control one /*if it's a collection, it not a single file*/ Parsers []string `yaml:"parsers,omitempty" json:"parsers,omitempty"` PostOverflows []string `yaml:"postoverflows,omitempty" json:"postoverflows,omitempty"` Scenarios []string `yaml:"scenarios,omitempty" json:"scenarios,omitempty"` Collections []string `yaml:"collections,omitempty" json:"collections,omitempty"` }
Item can be : parsed, scenario, collection
func DisableItem ¶
DisableItem to disable an item managed by the hub, removes the symlink if purge is true
func DownloadLatest ¶
DownloadLatest will download the latest version of Item to the tdir directory
func EnableItem ¶
creates symlink between actual config file at hub.HubDir and hub.ConfigDir Handles collections recursively
func GetInstalledCollections ¶ added in v1.3.3
func GetInstalledParsers ¶ added in v1.3.3
func GetInstalledPostOverflows ¶ added in v1.3.3
func GetInstalledScenarios ¶ added in v1.3.3
type ItemHubStatus ¶ added in v1.2.3
type ItemHubStatus struct { Name string `json:"name"` LocalVersion string `json:"local_version"` LocalPath string `json:"local_path"` Description string `json:"description"` UTF8_Status string `json:"utf8_status"` Status string `json:"status"` }
func GetHubStatusForItemType ¶ added in v1.2.3
func GetHubStatusForItemType(itemType string, name string, all bool) []ItemHubStatus
Returns a list of entries for packages : name, status, local_path, local_version, utf8_status (fancy)