|
| 1 | +--- |
| 2 | +title: "Cascading Scans" |
| 3 | +path: "hooks/declarative-subsequent-scans" |
| 4 | +category: "hook" |
| 5 | +type: "processing" |
| 6 | +state: "released" |
| 7 | +usecase: "Cascading Scans based declarative Rules." |
| 8 | +--- |
| 9 | + |
| 10 | +<!-- end --> |
| 11 | + |
| 12 | +## Deployment |
| 13 | + |
| 14 | +Installing the Cascading Scans hook will add a ReadOnly Hook to your namespace which looks for matching _CascadingRules_ in the namespace and start the according scans. |
| 15 | + |
| 16 | +```bash |
| 17 | +helm upgrade --install dssh ./hooks/declarative-subsequent-scans/ |
| 18 | +``` |
| 19 | + |
| 20 | +### Verification |
| 21 | +```bash |
| 22 | +kubectl get ScanCompletionHooks |
| 23 | +NAME TYPE IMAGE |
| 24 | +dssh ReadOnly docker.io/scbexperimental/hook-declarative-subsequent-scans:latest |
| 25 | +``` |
| 26 | + |
| 27 | +## CascadingScan Rules |
| 28 | +The CascadingRules are included directly in each helm chart of the individual scanners. |
| 29 | + |
| 30 | +```bash |
| 31 | +# Check your CascadingRules |
| 32 | +kubectl get CascadingRules |
| 33 | +NAME STARTS INVASIVENESS INTENSIVENESS |
| 34 | +https-tls-scan sslyze non-invasive light |
| 35 | +imaps-tls-scan sslyze non-invasive light |
| 36 | +nikto-http nikto non-invasive medium |
| 37 | +nmap-smb nmap non-invasive light |
| 38 | +pop3s-tls-scan sslyze non-invasive light |
| 39 | +smtps-tls-scan sslyze non-invasive light |
| 40 | +ssh-scan ssh-scan non-invasive light |
| 41 | +zap-http zap-baseline non-invasive medium |
| 42 | +``` |
| 43 | + |
| 44 | +## Starting a cascading Scan |
| 45 | +When you start a normal Scan, no CascadingRule will be applied. To use a _CascadingRule_ the scan must be marked to allow cascading rules. |
| 46 | +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. |
| 47 | + |
| 48 | +### Example |
| 49 | +```yaml |
| 50 | +cat <<EOF | kubectl apply -f - |
| 51 | +apiVersion: "execution.experimental.securecodebox.io/v1" |
| 52 | +kind: Scan |
| 53 | +metadata: |
| 54 | + name: "example.com" |
| 55 | +spec: |
| 56 | + scanType: nmap |
| 57 | + parameters: |
| 58 | + - -p22,80,443 |
| 59 | + - example.com |
| 60 | + cascades: |
| 61 | + matchLabels: |
| 62 | + securecodebox.io/intensive: light |
| 63 | +EOF |
| 64 | +``` |
| 65 | + |
| 66 | +This Scan will used all CascadingRules which are labeled with a "light" intensity. |
| 67 | +You can lookup which CascadingRules this selects by running: |
| 68 | + |
| 69 | +```bash |
| 70 | +kubectl get CascadingRules -l "securecodebox.io/intensive=light" |
| 71 | +NAME STARTS INVASIVENESS INTENSIVENESS |
| 72 | +https-tls-scan sslyze non-invasive light |
| 73 | +imaps-tls-scan sslyze non-invasive light |
| 74 | +nmap-smb nmap non-invasive light |
| 75 | +pop3s-tls-scan sslyze non-invasive light |
| 76 | +smtps-tls-scan sslyze non-invasive light |
| 77 | +ssh-scan ssh-scan non-invasive light |
| 78 | +``` |
| 79 | + |
| 80 | +The label selectors also allow the more powerful matchExpression selectors: |
| 81 | + |
| 82 | +```yaml |
| 83 | +cat <<EOF | kubectl apply -f - |
| 84 | +apiVersion: "execution.experimental.securecodebox.io/v1" |
| 85 | +kind: Scan |
| 86 | +metadata: |
| 87 | + name: "example.com" |
| 88 | +spec: |
| 89 | + scanType: nmap |
| 90 | + parameters: |
| 91 | + - -p22,80,443 |
| 92 | + - example.com |
| 93 | + cascades: |
| 94 | + # Using matchExpression instead of matchLabels |
| 95 | + matchExpression: |
| 96 | + key: "securecodebox.io/intensive" |
| 97 | + operator: In |
| 98 | + # This select both light and medium intensity rules |
| 99 | + values: [light, medium] |
| 100 | +EOF |
| 101 | +``` |
| 102 | + |
| 103 | +This selection can be replicated in kubectl using: |
| 104 | + |
| 105 | +```bash |
| 106 | +kubectl get CascadingRules -l "securecodebox.io/intensive in (light,medium)" |
| 107 | +NAME STARTS INVASIVENESS INTENSIVENESS |
| 108 | +https-tls-scan sslyze non-invasive light |
| 109 | +imaps-tls-scan sslyze non-invasive light |
| 110 | +nikto-http nikto non-invasive medium |
| 111 | +nmap-smb nmap non-invasive light |
| 112 | +pop3s-tls-scan sslyze non-invasive light |
| 113 | +smtps-tls-scan sslyze non-invasive light |
| 114 | +ssh-scan ssh-scan non-invasive light |
| 115 | +zap-http zap-baseline non-invasive medium |
| 116 | +``` |
0 commit comments