Skip to content

Commit

Permalink
Merge pull request #120 from kubescape/feat/npv2
Browse files Browse the repository at this point in the history
Generate NP from NetworkNeighborhood
  • Loading branch information
matthyx authored Jun 17, 2024
2 parents bbafb63 + 7729c7f commit 968527e
Show file tree
Hide file tree
Showing 15 changed files with 3,598 additions and 8 deletions.
13 changes: 13 additions & 0 deletions known-servewr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: spdx.softwarecomposition.kubescape.io/v1beta1
kind: KnownServer
metadata:
name: armosec
spec:
- ipBlock: 16.170.0.0/15
name: armo
server: cloud.io
- ipBlock: 13.50.180.111/24
name: armo
server: cloud.io


2 changes: 1 addition & 1 deletion pkg/apis/softwarecomposition/networkpolicy/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ func init() {
}

// IsIgnoredLabel returns true if the label is ignored
func isIgnoredLabel(label string) bool {
func IsIgnoredLabel(label string) bool {
return ignoreLabels[label]
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/kubescape/go-logger"
"github.com/kubescape/go-logger/helpers"
"github.com/kubescape/storage/pkg/apis/softwarecomposition"
"github.com/kubescape/storage/pkg/apis/softwarecomposition/networkpolicy"
"golang.org/x/exp/maps"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -24,8 +25,6 @@ const (
storageV1ApiVersion = "spdx.softwarecomposition.kubescape.io"
)

// FIXME switch to NetworkNeighborhood

func GenerateNetworkPolicy(networkNeighbors softwarecomposition.NetworkNeighbors, knownServers []softwarecomposition.KnownServer, timeProvider metav1.Time) (softwarecomposition.GeneratedNetworkPolicy, error) {
if !IsAvailable(networkNeighbors) {
return softwarecomposition.GeneratedNetworkPolicy{}, fmt.Errorf("networkNeighbors %s/%s status annotation is not ready", networkNeighbors.Namespace, networkNeighbors.Name)
Expand Down Expand Up @@ -453,7 +452,7 @@ func getSingleIP(ipAddress string) *softwarecomposition.IPBlock {

func removeLabels(labels map[string]string) {
for key := range labels {
if isIgnoredLabel(key) {
if networkpolicy.IsIgnoredLabel(key) {
delete(labels, key)
}
}
Expand Down
Loading

0 comments on commit 968527e

Please sign in to comment.