Send all installed scenario to LAPI (#1277)
This commit is contained in:
parent
5f2797c83c
commit
71165bcd30
|
@ -137,7 +137,7 @@ func NewCapiCmd() *cobra.Command {
|
||||||
log.Fatalf("Failed to load hub index : %s", err)
|
log.Fatalf("Failed to load hub index : %s", err)
|
||||||
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
scenarios, err := cwhub.GetUpstreamInstalledScenariosAsString()
|
scenarios, err := cwhub.GetInstalledScenariosAsString()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to get scenarios : %s", err.Error())
|
log.Fatalf("failed to get scenarios : %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ After running this command your will need to validate the enrollment in the weba
|
||||||
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
|
|
||||||
scenarios, err := cwhub.GetUpstreamInstalledScenariosAsString()
|
scenarios, err := cwhub.GetInstalledScenariosAsString()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to get scenarios : %s", err.Error())
|
log.Fatalf("failed to get scenarios : %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,7 @@ Keep in mind the machine needs to be validated by an administrator on LAPI side
|
||||||
log.Fatalf("Failed to load hub index : %s", err)
|
log.Fatalf("Failed to load hub index : %s", err)
|
||||||
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
scenarios, err := cwhub.GetUpstreamInstalledScenariosAsString()
|
scenarios, err := cwhub.GetInstalledScenariosAsString()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to get scenarios : %s", err.Error())
|
log.Fatalf("failed to get scenarios : %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ func runOutput(input chan types.Event, overflow chan types.Event, buckets *leaky
|
||||||
var cache []types.RuntimeAlert
|
var cache []types.RuntimeAlert
|
||||||
var cacheMutex sync.Mutex
|
var cacheMutex sync.Mutex
|
||||||
|
|
||||||
scenarios, err := cwhub.GetUpstreamInstalledScenariosAsString()
|
scenarios, err := cwhub.GetInstalledScenariosAsString()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "loading list of installed hub scenarios: %s", err)
|
return errors.Wrapf(err, "loading list of installed hub scenarios: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ func runOutput(input chan types.Event, overflow chan types.Event, buckets *leaky
|
||||||
UserAgent: fmt.Sprintf("crowdsec/%s", cwversion.VersionStr()),
|
UserAgent: fmt.Sprintf("crowdsec/%s", cwversion.VersionStr()),
|
||||||
URL: apiURL,
|
URL: apiURL,
|
||||||
VersionPrefix: "v1",
|
VersionPrefix: "v1",
|
||||||
UpdateScenario: cwhub.GetUpstreamInstalledScenariosAsString,
|
UpdateScenario: cwhub.GetInstalledScenariosAsString,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "new client api: %s", err)
|
return errors.Wrapf(err, "new client api: %s", err)
|
||||||
|
|
|
@ -236,10 +236,10 @@ func ItemStatus(v Item) (string, bool, bool, bool) {
|
||||||
return strret, Ok, Warning, Managed
|
return strret, Ok, Warning, Managed
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUpstreamInstalledScenariosAsString() ([]string, error) {
|
func GetInstalledScenariosAsString() ([]string, error) {
|
||||||
var retStr []string
|
var retStr []string
|
||||||
|
|
||||||
items, err := GetUpstreamInstalledScenarios()
|
items, err := GetInstalledScenarios()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "while fetching scenarios")
|
return nil, errors.Wrap(err, "while fetching scenarios")
|
||||||
}
|
}
|
||||||
|
@ -249,14 +249,14 @@ func GetUpstreamInstalledScenariosAsString() ([]string, error) {
|
||||||
return retStr, nil
|
return retStr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUpstreamInstalledScenarios() ([]Item, error) {
|
func GetInstalledScenarios() ([]Item, error) {
|
||||||
var retItems []Item
|
var retItems []Item
|
||||||
|
|
||||||
if _, ok := hubIdx[SCENARIOS]; !ok {
|
if _, ok := hubIdx[SCENARIOS]; !ok {
|
||||||
return nil, fmt.Errorf("no scenarios in hubIdx")
|
return nil, fmt.Errorf("no scenarios in hubIdx")
|
||||||
}
|
}
|
||||||
for _, item := range hubIdx[SCENARIOS] {
|
for _, item := range hubIdx[SCENARIOS] {
|
||||||
if item.Installed && !item.Tainted {
|
if item.Installed {
|
||||||
retItems = append(retItems, item)
|
retItems = append(retItems, item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue