From 4489ff2dabd62b60415c4639d1599448a365a048 Mon Sep 17 00:00:00 2001 From: Max Harley Date: Tue, 2 Apr 2024 16:39:48 -0400 Subject: [PATCH] Get NoseyParker rules from folder --- cmd/enrichment/enrichment/lib/helpers.py | 4 ++-- helm/nemesis/templates/enrichment.yaml | 3 +-- helm/nemesis/templates/noseyparker.yml | 12 ++++++++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/cmd/enrichment/enrichment/lib/helpers.py b/cmd/enrichment/enrichment/lib/helpers.py index 420e9fd..f4e0ba4 100644 --- a/cmd/enrichment/enrichment/lib/helpers.py +++ b/cmd/enrichment/enrichment/lib/helpers.py @@ -1311,8 +1311,8 @@ def run_noseyparker(path: str) -> Optional[pb.NoseyParker]: "scan", "--datastore", temp_dir, - "--rules", - "/opt/noseyparker/noseyparker.rules", + "--rules-path", + "/opt/noseyparker-rules", path, ], stdout=subprocess.PIPE, diff --git a/helm/nemesis/templates/enrichment.yaml b/helm/nemesis/templates/enrichment.yaml index c97f9f3..df21d1b 100644 --- a/helm/nemesis/templates/enrichment.yaml +++ b/helm/nemesis/templates/enrichment.yaml @@ -271,8 +271,7 @@ spec: - name: noseyparker mountPath: /opt/noseyparker/ - name: noseyparker-rules - mountPath: /opt/noseyparker/noseyparker.rules - subPath: noseyparker.rules + mountPath: /opt/noseyparker-rules readOnly: true readinessProbe: httpGet: diff --git a/helm/nemesis/templates/noseyparker.yml b/helm/nemesis/templates/noseyparker.yml index c01a671..07337e9 100644 --- a/helm/nemesis/templates/noseyparker.yml +++ b/helm/nemesis/templates/noseyparker.yml @@ -3,5 +3,13 @@ kind: ConfigMap metadata: name: noseyparker-rules data: - noseyparker.rules: | - {{.Files.Get "files/noseyparker/noseyparker.yaml" | nindent 4}} \ No newline at end of file + {{- $files := .Files.Glob "files/noseyparker/*.yaml" }} + {{- if $files }} + {{- range $path, $_ := $files }} + {{ $path | base | trimSuffix ".yaml" | printf "%s.rules" }}: | + {{- $.Files.Get $path | nindent 6 }} + {{- end }} + {{- else }} + noseyparker.rules: | + # Placeholder + {{- end }} \ No newline at end of file