Skip to content

Commit 2ca7261

Browse files
committed
Add reasoning to skip execution namespace for now in ADR
1 parent 02c5a75 commit 2ca7261

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎docs/adr/adr_0012.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ This fixed namespace mode has been added to the `ClusterScanCompletionHook` but
118118

119119
Can lead to conflicts between teams if a scan of "team 1" fails because of an error in the `ClusterScanCompletionHook` managed by a "central cluster team". Members of "team 1" will likely not even have access to the namespace the failing hooks run in and won't be able to debug / fix these issues by themselves.
120120

121-
122121
### Proposal 2: Distinct Cluster-wide and Namespace-local Resources
123122

124123
This alternative proposal uses the same cluster-wide CRDs mentioned above, but adds two new types: `ClusterScan` and `ClusterScheduledScan`. These are used to enforce a stricter separation between cluster-wide and namespace-local resources. Unless stated otherwise, non-`Cluster` resources do not interact in any way with their `Cluster` equivalents (e.g., a non-Cluster scan will not use a `ClusterScanType`, and vice versa).
@@ -149,12 +148,10 @@ Other than being cluster scoped, `ClusterCascadingRule`s are identical to the ex
149148

150149
`ClusterScanCompletionHook` behave mostly like their namespaced counterpart: when the parser for a `ClusterScan` completes, the operator fetches the list of `ClusterScanCompletionHook` (respecting the hookSelector of the `ClusterScan`), and processes them the same way it would regular `ScanCompletionHook`s (prioritization etc.). The concept of a "fixed namespace mode" from the other proposal can be maintained, if desireable.
151150

152-
153151
### Proposal 3: Mixed Cluster-wide and Namespace-local Resources, Mode Controlled by CRD Field
154152

155153
The third proposal is a middle ground between proposals 1 and 2. It uses the same CRDs as proposal 1, and does not include a `ClusterScan` or `ClusterScheduledScan` resource. However, it internally separates scans using namespace and global resources, based on a field in the Scan CRD. This facilitates a more predictable execution, as namespace-specific scans cannot be influenced by cluster resources, and vice versa.
156154

157-
158155
#### Changes to existing CRDs
159156

160157
The `Scan` CRD receives an extra field that describes the mode of the scan. It can be set to `namespace` (which is also the default if it is not specified), or `cluster`. A scan in namespace mode will behave exactly the way it does today, and ignore all cluster-wide resources. The behavior of scans in the cluster mode will be defined below.
@@ -221,7 +218,6 @@ This fixed namespace mode has been added to the `ClusterScanCompletionHook` but
221218
1. Hooks are usually used to interface with 3rd party systems which are often standardized for the entire company. Allowing to run them in a namespace separate from the individual teams / scans allows the hook to access these systems without having to distribute and thus potentially compromise the credentials for the 3rd party systems.
222219
2. In contrast to scans, hooks usually do not need to send requests to the scanned applications. Scanning an app from outside its namespace opens up a lot of potential issues with network policies blocking inter-network traffic between scanner and app. As the hooks only need to access the S3 bucket and the 3rd party system they are interfacing with, this is not an issue for hooks.
223220

224-
225221
### Changes to Existing Helm Charts
226222

227223
Existing charts for scanners and hooks should get a `clusterWide` boolean value which is `false` by default.
@@ -232,7 +228,6 @@ The following (not so) edge cases should be considered:
232228
1. Scanners and Hooks with namespaced resources (config maps, e.g. amass, zap-advanced...) should also contain the `clusterWide` parameter, when installed with it the installation should fail with guidance and links to a (non scanner specific) doc site which details on how a namespaced ScanType can be adjusted to as a ClusterScanType, e.g. on how to set up a init container to compensate the missing ConfigMaps, see [Issues with ConfigMap / Secret Mounts](#issues-with-configmap--secret-mounts).
233229
2. When a hook is installed in `clusterWide` mode and the `executionNamespace` being set (should be exposed as a value in all hook helm charts), the install should fail if the helm install namespace != `executionNamespace`. This should ensure that all namespaced resources (ConfigMaps, Secrets) are present in the `executionNamespace.`
234230

235-
236231
### RBAC Concept
237232

238233
- The RBAC System / guidelines for existing CRDs stays the exact same.
@@ -242,7 +237,9 @@ The following (not so) edge cases should be considered:
242237
This ensures that the security model remains intact as only cluster level users should be able to interact with resources shared across all resources and makes sure that it can't be used by attackers to escalate their privileges into other namespaces.
243238

244239
## Decision
240+
245241
We use Proposal 3, because:
242+
246243
- The strict separation in Proposal 2 makes the system hard debug (pods spawn randomly in your namespace and you don't know why).
247244
- RBAC becomes more difficult in Proposal 2
248245
- Currently, jobs have a child relationship with the underlying scan. This would have to be broken in proposal 2 (as the child relationship only works within a namespace), leading to more work for the cleanup. Prop 1 and 3 also have this problem, but a lot less so (only for scan completion hooks with fixed namespace mode).
@@ -256,4 +253,7 @@ We use Proposal 3, because:
256253

257254
## Consequences
258255

259-
TBD
256+
The only part which isn't done as described on the ADR is that the executionNamespace for ClusterScanCompletionHooks is missing. We had some major problems integrating it:
257+
258+
- Because the ownerReferences can't be set across namespaces the operator might not get notified of changes to the hook so that updates / hook completion could be missed by the operator
259+
- The hook sdk fetches the Scan on startup to make it available to the hook code (e.g. to read annotations from the scan CR), this doesn't work nicely with the executionNamespace because the service account with which the hook is running doesn't have the required access rights to fetch the scan from another namespace. To fix this we'd need to create ClusterRoles for these automatically which we didn't want to do as this might have effects on the RBAC model that we didn't anticipate previously.

0 commit comments

Comments
 (0)