Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ metadata:
labels:
hyperfleet.io/cluster-id: "{{ .clusterId }}"
hyperfleet.io/resource-type: "job"
e2e.hyperfleet.io/run-id: "{{ .runId }}"
app: test-job
e2e.hyperfleet.io/run-id: "{{ .runId }}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why moving it?

annotations:
hyperfleet.io/generation: "{{ .generationSpec }}"
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ metadata:
hyperfleet.io/component: "infrastructure"
hyperfleet.io/generation: "{{ .generation }}"
hyperfleet.io/resource-group: "cluster-setup"
e2e.hyperfleet.io/run-id: "{{ .runId }}"

# Maestro-specific labels
maestro.io/source-id: "{{ .adapter.name }}"
Expand All @@ -27,7 +28,6 @@ metadata:
app.kubernetes.io/part-of: "hyperfleet"
app.kubernetes.io/managed-by: "cl-maestro"
app.kubernetes.io/created-by: "{{ .adapter.name }}"
e2e.hyperfleet.io/run-id: "{{ .runId }}"
{{ if .platformType }}
hyperfleet.io/platform-type: "{{ .platformType }}"
{{ end }}
Expand Down
8 changes: 6 additions & 2 deletions helmfile/helmfile.yaml.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ environments:
- projectId: {{ env "PROJECT_ID" | default "hcm-hyperfleet" }}
brokerType: googlepubsub
serviceType: {{ env "API_SERVICE_TYPE" | default "LoadBalancer" }}
runId: {{ env "RUN_ID" | quote }}
runId: {{ requiredEnv "RUN_ID" | quote }}
labels:
e2e.hyperfleet.io/run-id: {{ requiredEnv "RUN_ID" }}
- environments/e2e-gcp/adapter-configs.yaml.gotmpl
- environments/e2e-gcp/sentinel-configs.yaml
e2e-kind:
values:
- brokerType: rabbitmq
serviceType: {{ env "API_SERVICE_TYPE" | default "ClusterIP" }}
runId: {{ env "RUN_ID" | quote }}
runId: {{ requiredEnv "RUN_ID" | quote }}
labels:
e2e.hyperfleet.io/run-id: {{ requiredEnv "RUN_ID" }}
- environments/e2e-kind/adapter-configs.yaml.gotmpl
- environments/e2e-kind/sentinel-configs.yaml
kind:
Expand Down
8 changes: 7 additions & 1 deletion helmfile/values/base-adapter.yaml.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,20 @@ broker:
rabbitmq:
url: {{ env "RABBITMQ_URL" | default "amqp://guest:guest@rabbitmq:5672" }}
{{ end }}

{{- if hasKey .Values "labels" }}
labels:
{{- toYaml .Values.labels | nindent 2 }}
{{- end }}

env:
- name: SIMULATE_RESULT
value: success
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
{{- if and (hasKey .Values "runId") .Values.runId }}
{{- if hasKey .Values "runId" }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need the hasKey to prevent issues. Addressed this yesterday in the first pr.

- name: RUN_ID
value: {{ .Values.runId | quote }}
{{- end }}
Comment on lines +40 to 43

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

CWE-703: hasKey check lets empty RUN_ID through.

requiredEnv "RUN_ID" only verifies the var is set, not non-empty. RUN_ID="" produces runId: "", which now passes hasKey .Values "runId" and injects RUN_ID="" into the container — a silently corrupted trust-boundary value instead of a hard failure.

Fix
-  {{- if hasKey .Values "runId" }}
+  {{- if and (hasKey .Values "runId") .Values.runId }}
   - name: RUN_ID
     value: {{ .Values.runId | quote }}
   {{- end }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{{- if hasKey .Values "runId" }}
- name: RUN_ID
value: {{ .Values.runId | quote }}
{{- end }}
{{- if and (hasKey .Values "runId") .Values.runId }}
- name: RUN_ID
value: {{ .Values.runId | quote }}
{{- end }}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@helmfile/values/base-adapter.yaml.gotmpl` around lines 40 - 43, The RUN_ID
guard in the base-adapter template only checks for the presence of
.Values.runId, so an empty value still gets injected into the container. Update
the conditional around the RUN_ID env entry to reject empty strings as well as
missing values, using the existing runId/hasKey logic in
base-adapter.yaml.gotmpl so only non-empty RUN_ID values are rendered.

7 changes: 6 additions & 1 deletion helmfile/values/base-api.yaml.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ config:
{{- if eq .resourceType "nodepools" }}
- {{ .name }}
{{- end }}
{{- end }}
{{- end }}

{{- if hasKey .Values "labels" }}
labels:
{{- toYaml .Values.labels | nindent 2 }}
{{- end }}
5 changes: 5 additions & 0 deletions helmfile/values/base-sentinel.yaml.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ broker:
rabbitmq:
url: {{ env "RABBITMQ_URL" | default "amqp://guest:guest@rabbitmq:5672" }}
{{ end }}

{{- if hasKey .Values "labels" }}
labels:
{{- toYaml .Values.labels | nindent 2 }}
{{- end }}