|
@@ -12,7 +12,7 @@ import (
|
|
func (t *HubTestItem) installPostoverflowItem(hubPostOverflow *cwhub.Item) error {
|
|
func (t *HubTestItem) installPostoverflowItem(hubPostOverflow *cwhub.Item) error {
|
|
postoverflowSource, err := filepath.Abs(filepath.Join(t.HubPath, hubPostOverflow.RemotePath))
|
|
postoverflowSource, err := filepath.Abs(filepath.Join(t.HubPath, hubPostOverflow.RemotePath))
|
|
if err != nil {
|
|
if err != nil {
|
|
- return fmt.Errorf("can't get absolute path of '%s': %s", postoverflowSource, err)
|
|
|
|
|
|
+ return fmt.Errorf("can't get absolute path of '%s': %w", postoverflowSource, err)
|
|
}
|
|
}
|
|
|
|
|
|
postoverflowFileName := filepath.Base(postoverflowSource)
|
|
postoverflowFileName := filepath.Base(postoverflowSource)
|
|
@@ -24,24 +24,24 @@ func (t *HubTestItem) installPostoverflowItem(hubPostOverflow *cwhub.Item) error
|
|
postoverflowDirDest := fmt.Sprintf("%s/postoverflows/%s/", t.RuntimePath, hubPostOverflow.Stage)
|
|
postoverflowDirDest := fmt.Sprintf("%s/postoverflows/%s/", t.RuntimePath, hubPostOverflow.Stage)
|
|
|
|
|
|
if err := os.MkdirAll(hubDirPostoverflowDest, os.ModePerm); err != nil {
|
|
if err := os.MkdirAll(hubDirPostoverflowDest, os.ModePerm); err != nil {
|
|
- return fmt.Errorf("unable to create folder '%s': %s", hubDirPostoverflowDest, err)
|
|
|
|
|
|
+ return fmt.Errorf("unable to create folder '%s': %w", hubDirPostoverflowDest, err)
|
|
}
|
|
}
|
|
|
|
|
|
if err := os.MkdirAll(postoverflowDirDest, os.ModePerm); err != nil {
|
|
if err := os.MkdirAll(postoverflowDirDest, os.ModePerm); err != nil {
|
|
- return fmt.Errorf("unable to create folder '%s': %s", postoverflowDirDest, err)
|
|
|
|
|
|
+ return fmt.Errorf("unable to create folder '%s': %w", postoverflowDirDest, err)
|
|
}
|
|
}
|
|
|
|
|
|
// runtime/hub/postoverflows/s00-enrich/crowdsecurity/rdns.yaml
|
|
// runtime/hub/postoverflows/s00-enrich/crowdsecurity/rdns.yaml
|
|
hubDirPostoverflowPath := filepath.Join(hubDirPostoverflowDest, postoverflowFileName)
|
|
hubDirPostoverflowPath := filepath.Join(hubDirPostoverflowDest, postoverflowFileName)
|
|
if err := Copy(postoverflowSource, hubDirPostoverflowPath); err != nil {
|
|
if err := Copy(postoverflowSource, hubDirPostoverflowPath); err != nil {
|
|
- return fmt.Errorf("unable to copy '%s' to '%s': %s", postoverflowSource, hubDirPostoverflowPath, err)
|
|
|
|
|
|
+ return fmt.Errorf("unable to copy '%s' to '%s': %w", postoverflowSource, hubDirPostoverflowPath, err)
|
|
}
|
|
}
|
|
|
|
|
|
// runtime/postoverflows/s00-enrich/rdns.yaml
|
|
// runtime/postoverflows/s00-enrich/rdns.yaml
|
|
postoverflowDirParserPath := filepath.Join(postoverflowDirDest, postoverflowFileName)
|
|
postoverflowDirParserPath := filepath.Join(postoverflowDirDest, postoverflowFileName)
|
|
if err := os.Symlink(hubDirPostoverflowPath, postoverflowDirParserPath); err != nil {
|
|
if err := os.Symlink(hubDirPostoverflowPath, postoverflowDirParserPath); err != nil {
|
|
if !os.IsExist(err) {
|
|
if !os.IsExist(err) {
|
|
- return fmt.Errorf("unable to symlink postoverflow '%s' to '%s': %s", hubDirPostoverflowPath, postoverflowDirParserPath, err)
|
|
|
|
|
|
+ return fmt.Errorf("unable to symlink postoverflow '%s' to '%s': %w", hubDirPostoverflowPath, postoverflowDirParserPath, err)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -62,26 +62,24 @@ func (t *HubTestItem) installPostoverflowCustomFrom(postoverflow string, customP
|
|
|
|
|
|
// check if stage exist
|
|
// check if stage exist
|
|
hubStagePath := filepath.Join(t.HubPath, fmt.Sprintf("postoverflows/%s", customPostoverflowStage))
|
|
hubStagePath := filepath.Join(t.HubPath, fmt.Sprintf("postoverflows/%s", customPostoverflowStage))
|
|
-
|
|
|
|
if _, err := os.Stat(hubStagePath); os.IsNotExist(err) {
|
|
if _, err := os.Stat(hubStagePath); os.IsNotExist(err) {
|
|
return false, fmt.Errorf("stage '%s' from extracted '%s' doesn't exist in the hub", customPostoverflowStage, hubStagePath)
|
|
return false, fmt.Errorf("stage '%s' from extracted '%s' doesn't exist in the hub", customPostoverflowStage, hubStagePath)
|
|
}
|
|
}
|
|
|
|
|
|
postoverflowDirDest := fmt.Sprintf("%s/postoverflows/%s/", t.RuntimePath, customPostoverflowStage)
|
|
postoverflowDirDest := fmt.Sprintf("%s/postoverflows/%s/", t.RuntimePath, customPostoverflowStage)
|
|
if err := os.MkdirAll(postoverflowDirDest, os.ModePerm); err != nil {
|
|
if err := os.MkdirAll(postoverflowDirDest, os.ModePerm); err != nil {
|
|
- return false, fmt.Errorf("unable to create folder '%s': %s", postoverflowDirDest, err)
|
|
|
|
|
|
+ return false, fmt.Errorf("unable to create folder '%s': %w", postoverflowDirDest, err)
|
|
}
|
|
}
|
|
|
|
|
|
customPostoverflowDest := filepath.Join(postoverflowDirDest, customPostoverflowName)
|
|
customPostoverflowDest := filepath.Join(postoverflowDirDest, customPostoverflowName)
|
|
// if path to postoverflow exist, copy it
|
|
// if path to postoverflow exist, copy it
|
|
if err := Copy(customPostOverflowPath, customPostoverflowDest); err != nil {
|
|
if err := Copy(customPostOverflowPath, customPostoverflowDest); err != nil {
|
|
- return false, fmt.Errorf("unable to copy custom parser '%s' to '%s': %s", customPostOverflowPath, customPostoverflowDest, err)
|
|
|
|
|
|
+ return false, fmt.Errorf("unable to copy custom parser '%s' to '%s': %w", customPostOverflowPath, customPostoverflowDest, err)
|
|
}
|
|
}
|
|
|
|
|
|
return true, nil
|
|
return true, nil
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
func (t *HubTestItem) installPostoverflowCustom(postoverflow string) error {
|
|
func (t *HubTestItem) installPostoverflowCustom(postoverflow string) error {
|
|
for _, customPath := range t.CustomItemsLocation {
|
|
for _, customPath := range t.CustomItemsLocation {
|
|
found, err := t.installPostoverflowCustomFrom(postoverflow, customPath)
|
|
found, err := t.installPostoverflowCustomFrom(postoverflow, customPath)
|