Bug fix where kubescape fails to read from framework local paths

Fix typo in error description

Bug fix where kubescape get policies from file

Signed-off-by: Mehdi Moussaif <m.moussaif42@gmail.com>

Missing '.json' extension when getting Framework Paths

Signed-off-by: Mehdi Moussaif <m.moussaif42@gmail.com>

Appropriate test case for FrameworksPaths

Bug fix where kubescape fails to read from frameworks local paths

Signed-off-by: Mehdi Moussaif <m.moussaif42@gmail.com>
This commit is contained in:
Mehdi Moussaif
2023-11-23 12:46:44 +01:00
parent dc6c379aa2
commit fd390bbd37
3 changed files with 13 additions and 2 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ var (
ErrNameRequired = errors.New("missing required input framework name")
ErrIDRequired = errors.New("missing required input control ID")
ErrFrameworkNotMatching = errors.New("framework from file not matching")
ErrControlNotMatching = errors.New("framework from file not matching")
ErrControlNotMatching = errors.New("control from file not matching")
)
var (
+1 -1
View File
@@ -240,7 +240,7 @@ func getDownloadReleasedPolicy(ctx context.Context, downloadReleasedPolicy *gett
func getDefaultFrameworksPaths() []string {
fwPaths := []string{}
for i := range getter.NativeFrameworks {
fwPaths = append(fwPaths, getter.GetDefaultPath(getter.NativeFrameworks[i]))
fwPaths = append(fwPaths, getter.GetDefaultPath(getter.NativeFrameworks[i]+".json")) // GetDefaultPath expects a filename, not just the framework name
}
return fwPaths
}
+11
View File
@@ -3,6 +3,7 @@ package core
import (
"context"
"reflect"
"strings"
"testing"
"github.com/kubescape/go-logger"
@@ -229,3 +230,13 @@ func TestIsScanTypeForSubmission(t *testing.T) {
})
}
}
func TestGetDefaultFrameworksPaths(t *testing.T) {
result := getDefaultFrameworksPaths()
assert.NotEmpty(t, result)
for _, path := range result {
assert.NotEmpty(t, path)
assert.True(t, strings.HasSuffix(path, ".json"))
}
}