|
1 | 1 | # Using the secureCodeBox |
2 | 2 |
|
3 | | -follwing... |
| 3 | +## Declarative Combines Scans |
| 4 | +### Install Hook |
| 5 | +Installing the Declarative Combined Scan hook will add a ReadOnly Hook to your namespace which looks for matching CascadingRules in the namespace and start subsequent scans accordingly. |
| 6 | + |
| 7 | +```bash |
| 8 | +helm install combined-scans ./hooks/declarative-subsequent-scans |
| 9 | +``` |
| 10 | + |
| 11 | +### Verify Hook Installation |
| 12 | + |
| 13 | +Successful installation can be verified by retrieving installed ScanCompletionHooks. |
| 14 | + |
| 15 | +```bash |
| 16 | +$ kubectl get ScanCompletionHooks |
| 17 | +``` |
| 18 | + |
| 19 | +The result should contain a hook for declarative subsequent scans. |
| 20 | + |
| 21 | +```bash |
| 22 | +NAME TYPE IMAGE |
| 23 | +combined-scans-declarative-subsequent-scans ReadOnly docker.io/scbexperimental/hook-declarative-subsequent-scans:latest |
| 24 | +``` |
| 25 | + |
| 26 | +### Verify CascadingRules |
| 27 | + |
| 28 | +CascadingRules are included in each individual scanner's Helm chart. |
| 29 | + |
| 30 | +```bash |
| 31 | +$ kubectl get CascadingRules |
| 32 | +``` |
| 33 | +Output should show these CascadingRules: |
| 34 | + |
| 35 | +```bash |
| 36 | +NAME STARTS INVASIVENESS INTENSIVENESS |
| 37 | +https-tls-scan sslyze non-invasive light |
| 38 | +imaps-tls-scan sslyze non-invasive light |
| 39 | +nikto-http nikto non-invasive medium |
| 40 | +nmap-smb nmap non-invasive light |
| 41 | +pop3s-tls-scan sslyze non-invasive light |
| 42 | +smtps-tls-scan sslyze non-invasive light |
| 43 | +ssh-scan ssh-scan non-invasive light |
| 44 | +zap-http zap-baseline non-invasive medium |
| 45 | +``` |
| 46 | + |
| 47 | +### Start Scans |
| 48 | + |
| 49 | +When you start a normal Scan, no CascadingRule will be applied. |
| 50 | +To use CascadingRules the scan must be marked to allow cascading rules. |
| 51 | +This is implemented using kubernetes label selectors, meaning that scans mark the classes of scans which are allowed to be cascaded by the current one. |
| 52 | + |
| 53 | +### Example |
| 54 | + |
| 55 | +```bash |
| 56 | +cat <<EOF | kubectl apply -f - |
| 57 | +apiVersion: "execution.experimental.securecodebox.io/v1" |
| 58 | +kind: Scan |
| 59 | +metadata: |
| 60 | + name: "example.com" |
| 61 | +spec: |
| 62 | + scanType: nmap |
| 63 | + parameters: |
| 64 | + - -p22,80,443 |
| 65 | + - example.com |
| 66 | + cascades: |
| 67 | + matchLabels: |
| 68 | + securecodebox.io/intensive: light |
| 69 | +EOF |
| 70 | +``` |
| 71 | + |
| 72 | +This Scan will used all CascadingRules which are labeled with a "light" intensity. |
| 73 | + |
| 74 | +You can lookup which CascadingRules this selects by running: |
| 75 | + |
| 76 | +```bash |
| 77 | +$ kubectl get CascadingRules -l "securecodebox.io/intensive=light" |
| 78 | +NAME STARTS INVASIVENESS INTENSIVENESS |
| 79 | +https-tls-scan sslyze non-invasive light |
| 80 | +imaps-tls-scan sslyze non-invasive light |
| 81 | +nmap-smb nmap non-invasive light |
| 82 | +pop3s-tls-scan sslyze non-invasive light |
| 83 | +smtps-tls-scan sslyze non-invasive light |
| 84 | +ssh-scan ssh-scan non-invasive light |
| 85 | +``` |
| 86 | + |
| 87 | +The label selectors also allow the more powerful [matchExpression](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#set-based-requirement) selectors: |
| 88 | + |
| 89 | +```bash |
| 90 | +cat <<EOF | kubectl apply -f - |
| 91 | +apiVersion: "execution.experimental.securecodebox.io/v1" |
| 92 | +kind: Scan |
| 93 | +metadata: |
| 94 | + name: "example.com" |
| 95 | +spec: |
| 96 | + scanType: nmap |
| 97 | + parameters: |
| 98 | + - -p22,80,443 |
| 99 | + - example.com |
| 100 | + cascades: |
| 101 | + # Using matchExpression instead of matchLabels |
| 102 | + matchExpression: |
| 103 | + key: "securecodebox.io/intensive" |
| 104 | + operator: In |
| 105 | + # This select both light and medium intensity rules |
| 106 | + values: [light, medium] |
| 107 | +EOF |
| 108 | +``` |
| 109 | + |
| 110 | +This selection can be replicated in kubectl using: |
| 111 | + |
| 112 | +```bash |
| 113 | +kubectl get CascadingRules -l "securecodebox.io/intensive in (light,medium)" |
| 114 | +NAME STARTS INVASIVENESS INTENSIVENESS |
| 115 | +https-tls-scan sslyze non-invasive light |
| 116 | +imaps-tls-scan sslyze non-invasive light |
| 117 | +nikto-http nikto non-invasive medium |
| 118 | +nmap-smb nmap non-invasive light |
| 119 | +pop3s-tls-scan sslyze non-invasive light |
| 120 | +smtps-tls-scan sslyze non-invasive light |
| 121 | +ssh-scan ssh-scan non-invasive light |
| 122 | +zap-http zap-baseline non-invasive medium |
| 123 | +``` |
0 commit comments