cwhub

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2020 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var COLLECTIONS = "collections"
View Source
var Cfgdir = "/etc/crowdsec/cscli/"
View Source
var HubBranch = "master"
View Source
var HubIdx map[string]map[string]Item
View Source
var HubIndexFile = ".index.json"
View Source
var Hubdir = "/etc/crowdsec/cscli/hub/"
View Source
var Installdir = "/etc/crowdsec/"
View Source
var PARSERS = "parsers"
View Source
var PARSERS_OVFLW = "postoverflows"
View Source
var RawFileURLTemplate = "https://raw.githubusercontent.com/crowdsecurity/hub/%s/%s"
View Source
var ReferenceMissingError = errors.New("Reference(s) missing in collection")

To be used when reference(s) (is/are) missing in a collection

View Source
var SCENARIOS = "scenarios"

Functions

func CollecDepsCheck

func CollecDepsCheck(v *Item) error

func DisplaySummary

func DisplaySummary()

func DownloadHubIdx

func DownloadHubIdx() ([]byte, error)

func GetHubIdx

func GetHubIdx() error

func HubStatus

func HubStatus(itype string, name string, list_all bool) []map[string]string

Returns a list of entries for packages : name, status, local_path, local_version, utf8_status (fancy)

func ItemStatus

func ItemStatus(v Item) (string, bool, bool, bool)

returns: human-text, Enabled, Warning, Unmanaged

func LoadPkgIndex

func LoadPkgIndex(buff []byte) (map[string]map[string]Item, error)

LoadPkgIndex loads a local .index.json file and returns the map of parsers/scenarios/collections associated

func LocalSync

func LocalSync() error

Updates the infos from HubInit() with the local state

func UpdateHubIdx

func UpdateHubIdx() error

Types

type Item

type Item struct {
	/*descriptive info*/
	Type                 string   `yaml:"type,omitempty"`                         //parser|postoverflows|scenario|collection(|enrich)
	Stage                string   `json:"stage" yaml:"stage,omitempty,omitempty"` //Stage for parser|postoverflow : s00-raw/s01-...
	Name                 string   //as seen in .config.json, usually "author/name"
	FileName             string   //the filename, ie. apache2-logs.yaml
	Description          string   `yaml:"description,omitempty"`            //as seen in .config.json
	Author               string   `json:"author"`                           //as seen in .config.json
	References           []string `yaml:"references,omitempty"`             //as seen in .config.json
	BelongsToCollections []string `yaml:"belongs_to_collections,omitempty"` /*if it's part of collections, track name here*/

	/*remote (hub) infos*/
	RemoteURL  string                 `yaml:"remoteURL,omitempty"`               //the full remote uri of file in http
	RemotePath string                 `json:"path" yaml:"remote_path,omitempty"` //the path relative to git ie. /parsers/stage/author/file.yaml
	RemoteHash string                 `yaml:"hash,omitempty"`                    //the meow
	Version    string                 `json:"version"`                           //the last version
	Versions   map[string]ItemVersion `json:"versions" yaml:"-"`                 //the list of existing versions

	/*local (deployed) infos*/
	LocalPath string `yaml:"local_path,omitempty"` //the local path relative to ${CFG_DIR}
	//LocalHubPath string
	LocalVersion string
	LocalHash    string //the local meow
	Installed    bool
	Downloaded   bool
	UpToDate     bool
	Tainted      bool //has it been locally modified
	Local        bool //if it's a non versioned control one

	/*if it's a collection, it not a single file*/
	Parsers       []string `yaml:"parsers,omitempty"`
	PostOverflows []string `yaml:"postoverflows,omitempty"`
	Scenarios     []string `yaml:"scenarios,omitempty"`
	Collections   []string `yaml:"collections,omitempty"`
}

Item can be : parsed, scenario, collection

func DisableItem

func DisableItem(target Item, tdir string, hdir string, purge bool) (Item, error)

DisableItem to disable an item managed by the hub, removes the symlink

func DownloadItem

func DownloadItem(target Item, tdir string, overwrite bool, dataFolder string) (Item, error)

func DownloadLatest

func DownloadLatest(target Item, tdir string, overwrite bool, dataFolder string) (Item, error)

func EnableItem

func EnableItem(target Item, tdir string, hdir string) (Item, error)

type ItemVersion

type ItemVersion struct {
	Digest     string
	Deprecated bool
}

Jump to

Keyboard shortcuts

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