-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use application profile instead of sbomp
Signed-off-by: Matthias Bertschy <[email protected]>
- Loading branch information
Showing
19 changed files
with
1,047 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package adapters | ||
|
||
import ( | ||
"context" | ||
|
||
mapset "github.com/deckarep/golang-set/v2" | ||
"github.com/kubescape/kubevuln/core/ports" | ||
) | ||
|
||
type MockRelevancyAdapter struct { | ||
} | ||
|
||
var _ ports.Relevancy = (*MockRelevancyAdapter)(nil) | ||
|
||
func NewMockRelevancyAdapter() *MockRelevancyAdapter { | ||
return &MockRelevancyAdapter{} | ||
} | ||
|
||
func (m MockRelevancyAdapter) GetRelevantFiles(_ context.Context, _, _, _ string) (mapset.Set[string], map[string]string, error) { | ||
return mapset.NewSet[string](), nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package v1 | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"slices" | ||
|
||
mapset "github.com/deckarep/golang-set/v2" | ||
helpersv1 "github.com/kubescape/k8s-interface/instanceidhandler/v1/helpers" | ||
"github.com/kubescape/kubevuln/core/ports" | ||
) | ||
|
||
type ApplicationProfileAdapter struct { | ||
repository ports.ApplicationProfileRepository | ||
} | ||
|
||
var _ ports.Relevancy = (*ApplicationProfileAdapter)(nil) | ||
|
||
func NewApplicationProfileAdapter(repository ports.ApplicationProfileRepository) *ApplicationProfileAdapter { | ||
return &ApplicationProfileAdapter{ | ||
repository: repository, | ||
} | ||
} | ||
|
||
func (a *ApplicationProfileAdapter) GetRelevantFiles(ctx context.Context, namespace, name, container string) (mapset.Set[string], map[string]string, error) { | ||
applicationProfile, err := a.repository.GetApplicationProfile(ctx, namespace, name) | ||
if err != nil { | ||
return nil, nil, fmt.Errorf("GetApplicationProfile: %w", err) | ||
} | ||
files := mapset.NewSet[string]() | ||
for _, c := range slices.Concat(applicationProfile.Spec.InitContainers, applicationProfile.Spec.Containers, applicationProfile.Spec.EphemeralContainers) { | ||
if c.Name == container { | ||
for _, f := range c.Execs { | ||
files.Add(f.Path) | ||
} | ||
for _, f := range c.Opens { | ||
files.Add(f.Path) | ||
} | ||
} | ||
} | ||
labels := applicationProfile.Labels | ||
labels[helpersv1.ContainerNameMetadataKey] = container | ||
return files, labels, nil | ||
} |
Oops, something went wrong.