Skip to content
Draft
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
15 changes: 15 additions & 0 deletions braintrust/templates/api-configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{{- $unsafeUrlRequestMode := .Values.api.unsafeUrlRequestMode | default "" | toString | trim -}}
{{- if not (has $unsafeUrlRequestMode (list "" "off" "warn" "reject")) -}}
{{- fail "api.unsafeUrlRequestMode must be empty or one of: off, warn, reject." -}}
{{- end -}}
{{- $urlSecurityDnsServers := .Values.api.urlSecurityDnsServers | default "" | toString | trim -}}
{{- $urlSecurityAllowCidrs := .Values.api.urlSecurityAllowCidrs | default "" | toString | trim -}}
---

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.

Remove these from the top so they are not hoisted and have them inline with the values to match how we have other values in the config map. We also aren't using fail today for validation.

apiVersion: v1
kind: ConfigMap
Expand Down Expand Up @@ -55,6 +61,15 @@ data:
INSERT_LOGS2: "true"
ALLOW_INVALID_BASE64: {{ .Values.api.allowInvalidBase64 | default "false" | quote }}
NODE_MEMORY_PERCENT: {{ .Values.api.nodeMemoryPercent | default "80" | quote }}
{{- with $unsafeUrlRequestMode }}
BRAINTRUST_UNSAFE_URL_REQUEST_MODE: {{ . | quote }}
{{- end }}
{{- with $urlSecurityDnsServers }}
BRAINTRUST_URL_SECURITY_DNS_SERVERS: {{ . | quote }}
{{- end }}
{{- with $urlSecurityAllowCidrs }}
BRAINTRUST_URL_SECURITY_ALLOW_CIDRS: {{ . | quote }}
{{- end }}
{{- if .Values.brainstoreWalFooterVersion }}
BRAINSTORE_WAL_FOOTER_VERSION: {{ .Values.brainstoreWalFooterVersion | quote }}
{{- end }}
Expand Down
44 changes: 44 additions & 0 deletions braintrust/tests/api-configmap_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,50 @@ tests:
path: data.BRAINSTORE_DEFAULT
value: "force"

- it: should omit URL security env vars when unset
values:
- __fixtures__/base-values.yaml
release:
namespace: "braintrust"
asserts:
- isNull:
path: data.BRAINTRUST_UNSAFE_URL_REQUEST_MODE
- isNull:
path: data.BRAINTRUST_URL_SECURITY_DNS_SERVERS
- isNull:
path: data.BRAINTRUST_URL_SECURITY_ALLOW_CIDRS

- it: should include URL security env vars when configured
values:
- __fixtures__/base-values.yaml
set:
api.unsafeUrlRequestMode: " reject "
api.urlSecurityDnsServers: " 1.1.1.1,8.8.8.8 "
api.urlSecurityAllowCidrs: " 10.0.0.0/8,192.168.0.0/16 "
release:
namespace: "braintrust"
asserts:
- equal:
path: data.BRAINTRUST_UNSAFE_URL_REQUEST_MODE
value: "reject"
- equal:
path: data.BRAINTRUST_URL_SECURITY_DNS_SERVERS
value: "1.1.1.1,8.8.8.8"
- equal:
path: data.BRAINTRUST_URL_SECURITY_ALLOW_CIDRS
value: "10.0.0.0/8,192.168.0.0/16"

- it: should reject invalid URL request mode
values:
- __fixtures__/base-values.yaml
set:
api.unsafeUrlRequestMode: "block"
release:
namespace: "braintrust"
asserts:
- failedTemplate:
errorMessage: "api.unsafeUrlRequestMode must be empty or one of: off, warn, reject."

- it: should use correct namespace from helper when createNamespace is false
values:
- __fixtures__/base-values.yaml
Expand Down
14 changes: 14 additions & 0 deletions braintrust/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ api:
backfillDisableNonhistorical: false
allowInvalidBase64: false # By default, we will error on invalid base64 strings. Setting this to true will allow invalid base64 strings to be processed.
nodeMemoryPercent: "80"
# Controls how Braintrust backends handle outbound requests to user-supplied URLs
# that fail URL-security checks, such as URLs resolving to private or reserved IP
# ranges. Use "off" to allow, "warn" to allow with warnings, or "reject" to block.
# Leave empty to use the application default of "warn".
unsafeUrlRequestMode: ""
# Comma-separated DNS resolver IP addresses Braintrust backends should query when
# checking user-supplied URLs. Set this to force URL-security validation through
# trusted resolvers, such as VNet or corporate DNS, before falling back to the host
# resolver. Leave empty to use the application default resolver behavior.
urlSecurityDnsServers: ""
# Optional comma-separated CIDR ranges that Braintrust backend URL-security
# validation may allow even if private or reserved. Hard-blocked metadata,
# link-local, multicast, unspecified, and future-use ranges remain blocked.
urlSecurityAllowCidrs: ""
extraEnvVars:
# Example:
# - name: MY_ENV_VAR
Expand Down
Loading