-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ved Ratan <[email protected]>
- Loading branch information
Showing
14 changed files
with
253 additions
and
0 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,7 @@ | ||
# Description | ||
|
||
This test ensures the creation of nimbus-policy. | ||
|
||
# Expected Behaviour | ||
|
||
Upon creation of SecurityIntent and SecurityIntentBinding the NimbusPolicy should get created. |
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,29 @@ | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
name: np-creation | ||
spec: | ||
timeouts: | ||
assert: 10s | ||
steps: | ||
- try: | ||
# first operation: create the config map | ||
- apply: | ||
# file is relative to the test folder | ||
file: ../../../../examples/namespaced/dns-manipulation-si-sib.yaml | ||
# second operation: verify the config map exists and contains the expected data | ||
- assert: | ||
# file is relative to the test folder | ||
file: ../../../../examples/namespaced/dns-manipulation-si-sib.yaml | ||
- assert: | ||
file: nimbus-policy.yaml | ||
# - try: | ||
# - script: | ||
# content: kubectl get si | ||
# check: | ||
# (contains($stdout, 'dns-manipulation')): true | ||
# - try: | ||
# - script: | ||
# content: kubectl get sib | ||
# check: | ||
# (contains($stdout, 'dns-manipulation-binding')): true |
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 @@ | ||
apiVersion: intent.security.nimbus.com/v1 | ||
kind: NimbusPolicy | ||
metadata: | ||
name: dns-manipulation-binding | ||
ownerReferences: | ||
- apiVersion: intent.security.nimbus.com/v1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: SecurityIntentBinding | ||
name: dns-manipulation-binding | ||
spec: | ||
rules: | ||
- description: An adversary can manipulate DNS requests to redirect network traffic | ||
and potentially reveal end user activity. | ||
id: dnsManipulation | ||
rule: | ||
action: Block | ||
mode: best-effort | ||
selector: | ||
matchLabels: | ||
app: nginx |
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,7 @@ | ||
# Description | ||
|
||
This test ensures the persistant nature of nimbus-policy. | ||
|
||
# Expected Behaviour | ||
|
||
On updation of NimbusPolicy the policy by modifying the value of the key in .spec.selector.matchLablels.app the policy should get reverted back to its original state. |
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,27 @@ | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
name: np-updation | ||
spec: | ||
timeouts: | ||
assert: 10s | ||
steps: | ||
|
||
- name: step-01 | ||
try: | ||
- apply: | ||
# file is relative to the test folder | ||
file: ../../../../examples/namespaced/dns-manipulation-si-sib.yaml | ||
- assert: | ||
file: ../../../../examples/namespaced/dns-manipulation-si-sib.yaml | ||
- name: step-02 | ||
try: | ||
- apply: | ||
file: updated-nimbus-policy.yaml | ||
- name: step-03 | ||
try: | ||
- script: | ||
content: kubectl get np -n $NAMESPACE dns-manipulation-binding -o=jsonpath='{.spec.selector.matchLabels.app}' | ||
check: | ||
(contains($stdout, 'frontend')): false | ||
|
22 changes: 22 additions & 0 deletions
22
internal/controller/tests/np-updation/updated-nimbus-policy.yaml
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,22 @@ | ||
apiVersion: intent.security.nimbus.com/v1 | ||
kind: NimbusPolicy | ||
metadata: | ||
name: dns-manipulation-binding | ||
ownerReferences: | ||
- apiVersion: intent.security.nimbus.com/v1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: SecurityIntentBinding | ||
name: dns-manipulation-binding | ||
uid: "123456789" | ||
spec: | ||
rules: | ||
- description: An adversary can manipulate DNS requests to redirect network traffic | ||
and potentially reveal end user activity. | ||
id: dnsManipulation | ||
rule: | ||
action: Block | ||
mode: best-effort | ||
selector: | ||
matchLabels: | ||
app: frontend |
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,7 @@ | ||
# Description | ||
|
||
This test ensures that NimbusPolicy is tightly coupled with SecurityIntentBinding. | ||
|
||
# Expected Behaviour | ||
|
||
On deletion of SecurityIntentBinding, NimbusPolicy should automatically get deleted. |
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,28 @@ | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
name: sib-deletion | ||
spec: | ||
timeouts: | ||
assert: 10s | ||
steps: | ||
|
||
- name: step-01 | ||
try: | ||
- apply: | ||
# file is relative to the test folder | ||
file: ../../../../examples/namespaced/dns-manipulation-si-sib.yaml | ||
- assert: | ||
file: ../../../../examples/namespaced/dns-manipulation-si-sib.yaml | ||
- name: step-02 | ||
try: | ||
- script: | ||
content: kubectl delete sib -n $NAMESPACE dns-manipulation-binding | ||
- name: step-03 | ||
try: | ||
- script: | ||
content: kubectl get np -n $NAMESPACE dns-manipulation-binding | ||
check: | ||
($error != null): true | ||
|
||
|
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 @@ | ||
apiVersion: intent.security.nimbus.com/v1 | ||
kind: NimbusPolicy | ||
metadata: | ||
name: dns-manipulation-binding | ||
ownerReferences: | ||
- apiVersion: intent.security.nimbus.com/v1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: SecurityIntentBinding | ||
name: dns-manipulation-binding | ||
spec: | ||
rules: | ||
- description: An adversary can manipulate DNS requests to redirect network traffic | ||
and potentially reveal end user activity. | ||
id: dnsManipulation | ||
rule: | ||
action: Block | ||
mode: best-effort | ||
selector: | ||
matchLabels: | ||
app: nginx |
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,14 @@ | ||
apiVersion: intent.security.nimbus.com/v1 | ||
kind: SecurityIntentBinding | ||
metadata: | ||
name: dns-manipulation-binding | ||
spec: | ||
intents: | ||
- name: dns-manipulation | ||
selector: | ||
any: | ||
- resources: | ||
kind: Pod | ||
namespace: default | ||
matchLabels: | ||
app: frontend |
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,7 @@ | ||
# Description | ||
|
||
This test ensures that the change in SecurityIntentBinding by should get reflected in NimbusPolicy. | ||
|
||
# Expected Behaviour | ||
|
||
On updation of SecurityIntentBinding by updating the selector value, the corresponding selector in the NimbusPolicy should get updated. |
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,28 @@ | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
name: np-updation | ||
spec: | ||
timeouts: | ||
assert: 10s | ||
steps: | ||
|
||
- name: step-01 | ||
try: | ||
- apply: | ||
# file is relative to the test folder | ||
file: ../../../../examples/namespaced/dns-manipulation-si-sib.yaml | ||
- assert: | ||
file: ../../../../examples/namespaced/dns-manipulation-si-sib.yaml | ||
- name: step-02 | ||
try: | ||
- apply: | ||
file: updated-sib.yaml | ||
- name: step-03 | ||
try: | ||
- script: | ||
content: kubectl get np -n $NAMESPACE dns-manipulation-binding -o=jsonpath='{.spec.selector.matchLabels.app}' | ||
check: | ||
(contains($stdout, 'frontend')): true | ||
|
||
|
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 @@ | ||
apiVersion: intent.security.nimbus.com/v1 | ||
kind: NimbusPolicy | ||
metadata: | ||
name: dns-manipulation-binding | ||
ownerReferences: | ||
- apiVersion: intent.security.nimbus.com/v1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: SecurityIntentBinding | ||
name: dns-manipulation-binding | ||
spec: | ||
rules: | ||
- description: An adversary can manipulate DNS requests to redirect network traffic | ||
and potentially reveal end user activity. | ||
id: dnsManipulation | ||
rule: | ||
action: Block | ||
mode: best-effort | ||
selector: | ||
matchLabels: | ||
app: nginx |
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,14 @@ | ||
apiVersion: intent.security.nimbus.com/v1 | ||
kind: SecurityIntentBinding | ||
metadata: | ||
name: dns-manipulation-binding | ||
spec: | ||
intents: | ||
- name: dns-manipulation | ||
selector: | ||
any: | ||
- resources: | ||
kind: Pod | ||
namespace: default | ||
matchLabels: | ||
app: frontend |