nirmata / kyverno-policies

Curated Policy Sets from Nirmata
https://nirmata.com
13 stars 11 forks source link

NDEV-18111: add mutate policy for adding-capabilities-strict rule #171

Closed suhasgummanirmata closed 1 week ago

suhasgummanirmata commented 3 weeks ago

Description:

Final Changes:

Replace is not supported in kyverno1.10. So, used a combination of remove and add.

Add a rule to restrict-adding-capabilities-other-than-net-bind-service.

The patchesJson6902 method can be useful when a specific mutation is needed which cannot be performed by patchesStrategicMerge. For example, when needing to mutate a specific object within an array, the index can be specified as part of a patchesJson6902 mutation rule.

One distinction between this and other mutation methods is that patchesJson6902 does not support the use of conditional anchors. Use preconditions instead. Also, mutations using patchesJson6902 to Pods directly are not converted to higher-level controllers such as Deployments and StatefulSets through the use of the auto-gen feature. Therefore, when writing such mutation rules for Pods, it may be necessary to create multiple rules to cover all relevant Pod controllers.

Since we cannot use conditional anchors had to use two pre conditions.

Chandan-DK commented 3 weeks ago

@anusha94 - Please approve this PR, we can get it merged and the chainsaw tests will pass