Skip to content

Commit 512c534

Browse files
auto docker publishing, helm
1 parent ba97414 commit 512c534

7 files changed

Lines changed: 99 additions & 6 deletions

File tree

helm/Chart.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
dependencies:
22
- name: mongodb
33
repository: https://charts.bitnami.com/bitnami
4-
version: 18.6.0
4+
version: 18.6.1
55
- name: redis
66
repository: https://charts.bitnami.com/bitnami
77
version: 23.2.12
8-
digest: sha256:64bc4ed850429ba21e8274fad0bc986ddf5c1545b6777932b8df9a684c7d0dfa
9-
generated: "2026-02-20T14:00:32.835773574-05:00"
8+
digest: sha256:b7c9095489913f065ee0cca4ec6aee1b320e07fd089f693360d42501a1220615
9+
generated: "2026-02-25T16:20:43.56532327-05:00"

helm/templates/secrets.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ data:
1515
{{- if .Values.secrets.apiKey }}
1616
api-key: {{ .Values.secrets.apiKey | b64enc }}
1717
{{- else }}
18-
api-key: {{ randAlphaNum 32 | b64enc }}
18+
api-key: {{ uuidv4 | b64enc }}
1919
{{- end }}
2020
{{- end }}

helm/templates/server-deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.server.enabled }}
12
apiVersion: apps/v1
23
kind: Deployment
34
metadata:
@@ -103,3 +104,4 @@ spec:
103104
targetPort: {{ .Values.server.service.targetPort }}
104105
protocol: TCP
105106
name: http
107+
{{- end }}

helm/templates/watchdog-deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ spec:
2323
imagePullSecrets:
2424
{{- toYaml .Values.imagePullSecrets | nindent 8 }}
2525
{{- end }}
26+
{{- if .Values.server.enabled }}
2627
# Wait for the API server to become healthy before starting the watchdog
2728
initContainers:
2829
- name: wait-for-server
@@ -39,6 +40,7 @@ spec:
3940
sleep 5
4041
done
4142
echo "Server is healthy, starting watchdog."
43+
{{- end }}
4244
containers:
4345
- name: watchdog
4446
securityContext:

helm/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ imagePullSecrets: []
1616
# Server (API)
1717
# =============================================================================
1818
server:
19+
# -- Set to false to disable the API server (only deploy DBs + watchdog)
20+
enabled: true
1921
replicas: 1
2022
resources: {}
2123
# requests:

test_helm_deployment.py

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import unittest
33
import subprocess
44
import time
5+
import json
6+
import base64
57
import requests
68
import atexit
79
from contextlib import contextmanager
@@ -12,10 +14,10 @@
1214
Run it like so:
1315
1416
# all tests
15-
python test_helm_deployment.py
17+
uv run python test_helm_deployment.py
1618
1719
# specific test
18-
python -m unittest test_helm_deployment.TestHelmDeployment.test_swagger_ui
20+
uv run python -m unittest test_helm_deployment.TestHelmDeployment.test_swagger_ui
1921
2022
To bring up the test environment manually, run:
2123
@@ -264,6 +266,91 @@ def test_swagger_ui(self):
264266
self.assertEqual(response.status_code, 200, "Swagger UI should return 200")
265267
self.assertIn("swagger-ui", response.text.lower(), "Response should contain swagger-ui")
266268

269+
def test_ingest_and_query_assets(self):
270+
"""Test ingesting events from evilcorp.json.gz and querying assets via bbctl"""
271+
# Get the server pod name
272+
result = self.kubectl(
273+
"get",
274+
"pods",
275+
"-l",
276+
"app=bbot-server",
277+
"-o",
278+
"jsonpath={.items[0].metadata.name}",
279+
capture_output=True,
280+
)
281+
pod_name = result.stdout.strip()
282+
self.assertTrue(pod_name, "Should find a server pod")
283+
print(f"Server pod: {pod_name}")
284+
285+
# Get the API key from the kubernetes secret
286+
result = self.kubectl(
287+
"get",
288+
"secret",
289+
f"{self.release_name}-api-key",
290+
"-o",
291+
"jsonpath={.data.api-key}",
292+
capture_output=True,
293+
)
294+
api_key = base64.b64decode(result.stdout).decode()
295+
self.assertTrue(api_key, "Should retrieve API key from secret")
296+
297+
# Write a bbctl config file inside the pod
298+
server_url = f"http://{self.release_name}-server:8807/v1/"
299+
config_content = f'url: "{server_url}"\napi_keys:\n - "{api_key}"'
300+
self.kubectl(
301+
"exec",
302+
pod_name,
303+
"--",
304+
"sh",
305+
"-c",
306+
f"printf '%s\\n' '{config_content}' > /tmp/bbctl.yaml",
307+
)
308+
bbctl = "bbctl --no-color --config /tmp/bbctl.yaml"
309+
310+
# Copy test data into the pod
311+
self.kubectl("cp", "tests/evilcorp.json.gz", f"{pod_name}:/tmp/evilcorp.json.gz")
312+
313+
# Ingest events using bbctl
314+
print("Ingesting events...")
315+
result = self.kubectl(
316+
"exec",
317+
pod_name,
318+
"--",
319+
"sh",
320+
"-c",
321+
f"gunzip -c /tmp/evilcorp.json.gz | {bbctl} event ingest",
322+
capture_output=True,
323+
timeout=120,
324+
)
325+
print(f"Ingest stdout: {result.stdout}")
326+
print(f"Ingest stderr: {result.stderr}")
327+
self.assertEqual(result.returncode, 0, f"Event ingest failed: {result.stderr}")
328+
329+
# Wait for the watchdog to process events into assets
330+
print("Waiting for watchdog to process events into assets...")
331+
assets = []
332+
for i in range(30):
333+
result = self.kubectl(
334+
"exec",
335+
pod_name,
336+
"--",
337+
"sh",
338+
"-c",
339+
f"{bbctl} asset list --json",
340+
capture_output=True,
341+
check=False,
342+
timeout=30,
343+
)
344+
if result.returncode == 0 and result.stdout.strip():
345+
assets = [json.loads(line) for line in result.stdout.strip().splitlines() if line.strip()]
346+
if assets:
347+
break
348+
print(f" Attempt {i + 1}/30: {len(assets)} assets so far...")
349+
time.sleep(2)
350+
351+
print(f"Found {len(assets)} assets")
352+
self.assertGreater(len(assets), 0, "Should have ingested some assets from evilcorp.json.gz")
353+
267354
def tearDown(self):
268355
"""If a test fails, dump cluster debug info"""
269356
failed = False

tests/evilcorp.json.gz

179 KB
Binary file not shown.

0 commit comments

Comments
 (0)