Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Feature to select namespaces (match or exclude), resources within a namespace, and nodes in ClusterIntentBinding #108

Merged
merged 81 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 79 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
9f90b28
- Changing the types
shivaccuknox Apr 29, 2024
16e43dc
- Modified deepcopy functions
shivaccuknox Apr 30, 2024
bb9b3f2
- Predicate functions is defined
shivaccuknox May 2, 2024
64c90d0
- make run
shivaccuknox May 2, 2024
717b4f4
- Sample csib yamls
shivaccuknox May 3, 2024
579778e
- Add of the csib is working
shivaccuknox May 3, 2024
ab6615d
- Add subcase - of cases 1, 2, 3 - done
shivaccuknox May 3, 2024
e237649
- Add/Update/Delete of the Nimbus policies in the reconcile function…
shivaccuknox May 5, 2024
b072200
- Changes for kubeArmor, NetPol adapter
shivaccuknox May 6, 2024
fc42419
- Kyverno adapter watches for NimbusPolicy generated from
shivaccuknox May 6, 2024
cc7b098
- Fixes
shivaccuknox May 6, 2024
34d0b1f
- Copying the matchNames/excludeNames to the Kyverno Cluster Policy
shivaccuknox May 6, 2024
d96eed5
- Renamed v1alpha to v1alpha1
shivaccuknox May 15, 2024
d11497f
- Modified the version in the scheme
shivaccuknox May 15, 2024
4b70dd2
- chainsaw test controllers/nimbuspolicy/delete/ - working
shivaccuknox May 15, 2024
0e183ec
- Tests are passing individually
shivaccuknox May 15, 2024
bdb5ee8
- For a cluster SIB, cluster nimbus policy is created
shivaccuknox May 16, 2024
52d3b13
- Add of a csib, creates np in multiple ns
shivaccuknox May 17, 2024
81c1e0e
- Nimbus Policies are not updated if the expected and actual is same
shivaccuknox May 17, 2024
5f850ec
- First chainsaw test running
shivaccuknox May 17, 2024
9eeb173
- Updated the test
shivaccuknox May 17, 2024
98bf5d8
- Test case for matchNames case
shivaccuknox May 17, 2024
d0e4a17
- Test case for excludeName passing
shivaccuknox May 17, 2024
7fa6d4d
- Example yamls
shivaccuknox May 18, 2024
e8eb068
- Rebased the kcpbuilder.go
shivaccuknox May 18, 2024
176a5b8
- Rebased the kpbuilder.go
shivaccuknox May 18, 2024
6a28af5
- Changing the types
shivaccuknox Apr 29, 2024
cbfe53d
- Modified deepcopy functions
shivaccuknox Apr 30, 2024
340d74f
- Predicate functions is defined
shivaccuknox May 2, 2024
e692da8
- Rebase
shivaccuknox May 2, 2024
6c6711f
- Sample csib yamls
shivaccuknox May 3, 2024
cebc851
- Add of the csib is working
shivaccuknox May 3, 2024
6bc3053
- Add subcase - of cases 1, 2, 3 - done
shivaccuknox May 3, 2024
ced2fdc
- Add/Update/Delete of the Nimbus policies in the reconcile function…
shivaccuknox May 5, 2024
891d8fc
- Changes for kubeArmor, NetPol adapter
shivaccuknox May 6, 2024
7d2ab58
- Kyverno adapter watches for NimbusPolicy generated from
shivaccuknox May 6, 2024
f491192
- Fixes
shivaccuknox May 6, 2024
fb267c1
- Copying the matchNames/excludeNames to the Kyverno Cluster Policy
shivaccuknox May 6, 2024
5960db1
- Renamed v1alpha to v1alpha1
shivaccuknox May 15, 2024
01166c4
- Modified the version in the scheme
shivaccuknox May 15, 2024
4065a0f
- chainsaw test controllers/nimbuspolicy/delete/ - working
shivaccuknox May 15, 2024
c93144e
- Tests are passing individually
shivaccuknox May 15, 2024
ecae273
- For a cluster SIB, cluster nimbus policy is created
shivaccuknox May 16, 2024
6df96b1
- Add of a csib, creates np in multiple ns
shivaccuknox May 17, 2024
99184b3
- Nimbus Policies are not updated if the expected and actual is same
shivaccuknox May 17, 2024
1b78121
- First chainsaw test running
shivaccuknox May 17, 2024
32898b6
- Updated the test
shivaccuknox May 17, 2024
6c84d09
- Test case for matchNames case
shivaccuknox May 17, 2024
8937e76
- Test case for excludeName passing
shivaccuknox May 17, 2024
b4c7f2b
- Example yamls
shivaccuknox May 18, 2024
2cfccdd
- Rebased the kcpbuilder.go
shivaccuknox May 18, 2024
4a62947
- Rebased the kpbuilder.go
shivaccuknox May 18, 2024
241c861
- e2e/dns-manipulation successfull
shivaccuknox May 19, 2024
ef4dfc5
- Changes for e2e/escape-to-host
shivaccuknox May 19, 2024
c539ce5
Merge branch 'main' into shiv/namespace_exclude
shivaccuknox May 20, 2024
11c2a24
- chainsaw test test/controllers/ passing with these changes
shivaccuknox May 20, 2024
e2e68cf
Merge branch 'shiv/namespace_exclude' of github.com:shivaccuknox/nimb…
shivaccuknox May 20, 2024
0828068
- kyverno adapter compile
shivaccuknox May 20, 2024
d8511b5
- e2e tests passing
shivaccuknox May 20, 2024
ae09226
- Latest crds
shivaccuknox May 20, 2024
fe8d4f6
- Adding a dependency on jobs
shivaccuknox May 20, 2024
9d6482e
- Debug logs
shivaccuknox May 20, 2024
3fc7338
- Testing
shivaccuknox May 20, 2024
bacb5df
- Added testing yaml
shivaccuknox May 20, 2024
ff40b70
- $ make integration-test
shivaccuknox May 22, 2024
7ca9773
Merge branch 'main' into shiv/namespace_exclude
shivaccuknox May 22, 2024
9e43612
- Review feedback
shivaccuknox May 24, 2024
8712b82
Merge branch 'shiv/namespace_exclude' of github.com:shivaccuknox/nimb…
shivaccuknox May 24, 2024
c0bcb00
Merge branch 'main' into shiv/namespace_exclude
VedRatan May 24, 2024
ce71d72
- Review feedback
shivaccuknox May 27, 2024
ad6e5fc
Merge branch 'shiv/namespace_exclude' of github.com:shivaccuknox/nimb…
shivaccuknox May 27, 2024
abf64c8
Merge remote-tracking branch 'upstream/main' into shiv/namespace_exclude
shivaccuknox May 27, 2024
fa312b8
- Review feedback
shivaccuknox May 27, 2024
89ccb18
- fixing the static check fail
shivaccuknox May 27, 2024
75247e0
- To create csib for all ns, use "*" in matchNames
shivaccuknox May 30, 2024
62a42d3
- Fixed issue related to excludeNames path
shivaccuknox May 30, 2024
986b452
- test-doc
shivaccuknox May 31, 2024
8e48470
- Comments
shivaccuknox Jun 3, 2024
40b438c
Merge branch 'main' into shiv/namespace_exclude
shivaccuknox Jun 4, 2024
2a74492
- Review feedback
shivaccuknox Jun 4, 2024
636fa35
- Fix for lint check fail
shivaccuknox Jun 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ jobs:
run: |
kubectl wait --for=condition=ready --timeout=5m -n nimbus pod -l app.kubernetes.io/name=nimbus
kubectl get pods -A

- name: Run Tests
run: make integration-test

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 Authors of Nimbus

package v1
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// ClusterNimbusPolicySpec defines the desired state of ClusterNimbusPolicy
type ClusterNimbusPolicySpec struct {
Selector CwSelector `json:"selector"`
NimbusRules []NimbusRules `json:"rules"`
NodeSelector LabelSelector `json:"nodeSelector,omitempty"`
NsSelector NamespaceSelector `json:"nsSelector,omitempty"`
WorkloadSelector LabelSelector `json:"workloadSelector,omitempty"`
NimbusRules []NimbusRules `json:"rules"`
}

// ClusterNimbusPolicyStatus defines the observed state of ClusterNimbusPolicy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 Authors of Nimbus

package v1
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type CwResource struct {
Kind string `json:"kind"`
Name string `json:"name"`
Namespace string `json:"namespace,omitempty"`
MatchLabels map[string]string `json:"matchLabels,omitempty"`
type NamespaceSelector struct {
MatchNames []string `json:"matchNames,omitempty"`
ExcludeNames []string `json:"excludeNames,omitempty"`
}

type CwSelector struct {
Resources []CwResource `json:"resources,omitempty"`
CEL []string `json:"cel,omitempty"`
type ClusterMatchWorkloads struct {
NodeSelector LabelSelector `json:"nodeSelector,omitempty"`
NsSelector NamespaceSelector `json:"nsSelector,omitempty"`
WorkloadSelector LabelSelector `json:"workloadSelector,omitempty"`
}

// ClusterSecurityIntentBindingSpec defines the desired state of ClusterSecurityIntentBinding
type ClusterSecurityIntentBindingSpec struct {
Intents []MatchIntent `json:"intents"`
Selector CwSelector `json:"selector"`
Intents []MatchIntent `json:"intents"`
Selector ClusterMatchWorkloads `json:"selector,omitempty"`
shivaccuknox marked this conversation as resolved.
Show resolved Hide resolved
CEL []string `json:"cel,omitempty"`
}

// ClusterSecurityIntentBindingStatus defines the observed state of ClusterSecurityIntentBinding
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 Authors of Nimbus

// Package v1 contains API Schema definitions for the intent v1 API group
// Package v1alpha1 contains API Schema definitions for the intent v1 API group
// +kubebuilder:object:generate=true
// +groupName=intent.security.nimbus.com
package v1
package v1alpha1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
Expand All @@ -13,7 +13,7 @@ import (

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "intent.security.nimbus.com", Version: "v1"}
GroupVersion = schema.GroupVersion{Group: "intent.security.nimbus.com", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 Authors of Nimbus

package v1
package v1alpha1

import (
"reflect"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// NimbusPolicySpec defines the desired state of NimbusPolicy
type NimbusPolicySpec struct {
// Selector specifies the target resources to which the policy applies
Selector NimbusSelector `json:"selector"`
Selector LabelSelector `json:"selector"`

// PolicyType specifies the type of policy, e.g., "Network", "System", "Cluster"
NimbusRules []NimbusRules `json:"rules"`
}

// NimbusSelector is used to select specific resources based on labels.
type NimbusSelector struct {
// MatchLabels is a map that holds key-value pairs to match against labels of resources.
MatchLabels map[string]string `json:"matchLabels"`
}

// NimbusRules represents a single policy rule with an ID, type, description, and detailed rule configurations.
type NimbusRules struct {
ID string `json:"id"`
Expand Down Expand Up @@ -70,3 +66,26 @@ type NimbusPolicyList struct {
func init() {
SchemeBuilder.Register(&NimbusPolicy{}, &NimbusPolicyList{})
}

// Check equality of the spec to decide if we need to update the object
func (a NimbusPolicy) Equal(b NimbusPolicy) (string, bool) {
if a.ObjectMeta.Name != b.ObjectMeta.Name {
return "diff: name", false
}
if a.ObjectMeta.Namespace != b.ObjectMeta.Namespace {
return "diff: Namespace", false
}

if !reflect.DeepEqual(a.ObjectMeta.Labels, b.ObjectMeta.Labels) {
return "diff: Labels", false
}

if !reflect.DeepEqual(a.ObjectMeta.OwnerReferences, b.ObjectMeta.OwnerReferences) {
return "diff: OwnerReferences", false
}

if !reflect.DeepEqual(a.Spec, b.Spec) {
return "diff: Spec", false
}
return "", true
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 Authors of Nimbus

package v1
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 Authors of Nimbus

package v1
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// SecurityIntentBindingSpec defines the desired state of SecurityIntentBinding
type SecurityIntentBindingSpec struct {
Intents []MatchIntent `json:"intents"`
Selector Selector `json:"selector"`
Intents []MatchIntent `json:"intents"`
Selector MatchWorkloads `json:"selector"`
anurag-rajawat marked this conversation as resolved.
Show resolved Hide resolved
shivaccuknox marked this conversation as resolved.
Show resolved Hide resolved
CEL []string `json:"cel,omitempty"`
}

// MatchIntent struct defines the request for a specific SecurityIntent
Expand All @@ -19,21 +20,11 @@ type MatchIntent struct {
}

// Selector defines the selection criteria for resources
type Selector struct {
Any []ResourceFilter `json:"any,omitempty"`
All []ResourceFilter `json:"all,omitempty"`
CEL []string `json:"cel,omitempty"`
type MatchWorkloads struct {
WorkloadSelector LabelSelector `json:"workloadSelector,omitempty"`
}

// ResourceFilter is used for filtering resources
type ResourceFilter struct {
Resources Resources `json:"resources,omitempty"`
}

// Resources defines the properties for selecting Kubernetes resources
type Resources struct {
Kind string `json:"kind,omitempty"`
Namespace string `json:"namespace,omitempty"`
type LabelSelector struct {
MatchLabels map[string]string `json:"matchLabels,omitempty"`
}

Expand Down
Loading
Loading