Repository navigation
fix(chart): quote secret values - #251
Conversation
Render the FTP credentials and the OAuth client ID and secret with quote, so values with # or ': ' stay valid YAML and numeric values are strings, as Kubernetes requires. Values that rendered before render the same. Closes #250 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Helm parses numbers in values files as floats, which quote would render in scientific notation. Render whole numbers below 2^53 as written, fail on larger ones with a hint, and document it. Add tests for unset values and tidy the quoting tests. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Reviewer's GuideUses of the APIUse the secret-value helper for FTP credentials and OAuth client credentials so their rendered values remain strings.
ImplementationAdd a helper that quotes secret values while rendering exact supported whole numbers and rejecting oversized values with guidance.
DocumentationDocument how the chart handles numeric-looking credentials and when values must be quoted or passed with --set-string.
TestsCover quoting of tricky and numeric credentials, supported numeric rendering, unset values, and oversized-number errors.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #251 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 229 229
=========================================
Hits 229 229 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="charts/tesk/templates/_helpers.tpl" line_range="149" />
<code_context>
+{{- if and (lt . 9007199254740992.0) (gt . -9007199254740992.0) -}}
+{{- printf "%.0f" . | quote -}}
+{{- else -}}
+{{- fail (printf "the number %v is too large to be exact: quote it in the values file or use --set-string" .) -}}
+{{- end -}}
+{{- else -}}
</code_context>
<issue_to_address>
**Credentials leak into logs**
When an unquoted all-digit FTP or OAuth credential at or above 2^53 is supplied and Helm stderr is retained in logs readable by others, `fail` interpolates the parsed credential with `%v`, so Helm writes the secret to stderr and retained deployment or CI logs expose it to readers.
Remove the credential value from the `fail` message.
</issue_to_address>
### Comment 2
<location path="charts/tesk/templates/_helpers.tpl" line_range="149" />
<code_context>
+{{- if and (lt . 9007199254740992.0) (gt . -9007199254740992.0) -}}
+{{- printf "%.0f" . | quote -}}
+{{- else -}}
+{{- fail (printf "the number %v is too large to be exact: quote it in the values file or use --set-string" .) -}}
+{{- end -}}
+{{- else -}}
</code_context>
<issue_to_address>
**Large numbers fail**
The issue asks for every value to render as a string, but this branch fails for whole numbers at or above 2^53. Users must quote those values or use `--set-string` instead.
</issue_to_address>
### Comment 3
<location path="tests/test_chart.py" line_range="700" />
<code_context>
+ values.write_text("ftp:\n username: 12345678901234567890\n")
+ with pytest.raises(subprocess.CalledProcessError) as error:
+ render("-f", str(values))
+ assert "too large" in error.value.stderr
+
+
</code_context>
<issue_to_address>
**Missing hint goes undetected**
When the error message says “too large” but omits the remediation guidance, `test_secret_number_too_large` at line 700 checks only for “too large,” so removing the guidance to quote the value or use `--set-string` still passes; users get no remediation hint.
Assert that stderr includes the quoting or `--set-string` guidance.
</issue_to_address>Linked issues
#250 fix(chart): quote secret values · 3 of 4 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Render every secret value as a string, whatever it contains, while preserving values that already render correctly. | 🟡 Partly met | Values-file integers at or above 2^53 fail to render and must instead be quoted or passed with --set-string. |
| 2 | Add chart tests with #, : and numeric values for the new and old OAuth keys. |
✅ Met | Tests cover these values for FTP and both OAuth key forms. |
| 3 | Quote the FTP credentials and OAuth client ID and secret in the templates. | ✅ Met | |
| 4 | Note the behavior in the configuration reference. | ✅ Met | The configuration reference describes quoting, numeric values, and how to supply large numbers. |
Sourcery assessment
Approval pending. 3 findings to address first.
Blocking findings: charts/tesk/templates/_helpers.tpl:149, charts/tesk/templates/_helpers.tpl:149, tests/test_chart.py:700
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Summary
Quote the FTP credentials and the OAuth client ID and secret in the chart Secrets, so
#,:and numeric values render as strings. A helper (tesk.secretValue) renders whole numbers from values files exactly (Helm parses them as floats) and fails on numbers of 2^53 or more with a hint. Unset values still render as null. Other Secret and ConfigMap templates render no user scalars.Closes #250
Verification
pytest tests/test_chart.pywith helm 3.22.1: 218 passed (new tests failed before the fix).ruff checkandruff formaton tests: clean.Review
Full review (Helm chart): adversarial and quality reviewers, then adversarial round 2.
Declined review findings
Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Render chart credentials safely as strings while preserving values and warning about numbers that cannot be represented exactly.
Bug Fixes:
Enhancements:
Documentation:
Tests: