Skip to content

Commit 373fdfe

Browse files
rguichardclaude
andcommitted
fix(helm): address Aikido review findings on validation scripts
Apply the fixes from the per-finding review branches directly: validate-helm-charts.sh: - process_chart now returns instead of exit, so the sequential loop validates every chart and reaches the summary (the parallel path is unaffected). - Use a single `mktemp -d` dir (lint/template files) instead of an unused base temp file; clean up with one `rm -rf`. - Pass the chart path to `helm dependency update` / `helm template` instead of cd-ing into the dir; drop the now-unused INITIAL_DIR. - Split the `helm template | kubeconform` pipeline for readability (keeping the `if !` guard, which is pipefail-safe). test-local.sh: - Redact LABELS_SERVICE_API_KEY when echoing the auth response. - Correct the eth_getLogs decimal block numbers (0x1254048f = 307,496,079, 0x12558b2f = 307,596,079, range = 100,000). The Aikido suggestion to move should_skip_validation before `helm lint` was intentionally not applied: lint is meant to run for all charts; only kubeconform is skipped for database charts. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5fd0b6c commit 373fdfe

2 files changed

Lines changed: 24 additions & 24 deletions

File tree

helm/charts/erpc/test-local.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ if [ -n "${LABELS_SERVICE_API_KEY:-}" ] && [ "$LABELS_SERVICE_API_KEY" != "your-
192192
echo "✅ Authentication with proper secret parameter works"
193193
else
194194
echo "⚠️ Authentication secret parameter didn't work as expected"
195-
echo " Response: $auth_response_with_secret"
195+
# Redact the API key in case the response (or a reflected error)
196+
# echoes back the request URL containing the secret.
197+
echo " Response: ${auth_response_with_secret//$LABELS_SERVICE_API_KEY/***REDACTED***}"
196198
fi
197199
else
198200
echo "⚠️ Authentication might not be properly configured (no auth rejection detected)"
@@ -222,8 +224,8 @@ if echo "$response" | grep -q '"result"'; then
222224
log_count=$(echo "$response" | jq -r '.result | length' 2>/dev/null || echo "unknown")
223225
echo "✅ Arbitrum eth_getLogs test successful"
224226
echo " Logs found: $log_count"
225-
echo " Block range: 0x1254048f (307,074,191) to 0x12558b2f (307,166,767)"
226-
echo " Range size: ~92,576 blocks"
227+
echo " Block range: 0x1254048f (307,496,079) to 0x12558b2f (307,596,079)"
228+
echo " Range size: 100,000 blocks"
227229
elif echo "$response" | grep -q '"error"'; then
228230
error_message=$(echo "$response" | jq -r '.error.message // .error' 2>/dev/null || echo "unknown")
229231
echo "⚠️ eth_getLogs returned error (expected for large ranges):"

validate-helm-charts.sh

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ if ! command -v helm &> /dev/null; then
3939
exit 1
4040
fi
4141

42-
# Store the initial working directory
43-
INITIAL_DIR=$(pwd)
44-
export INITIAL_DIR
45-
4642
# Set base directories to scan (erpc: base chart + prd env wrapper only)
4743
DIRS_TO_SCAN=("helm/charts/erpc" "helm/environments/prd/erpc")
4844

@@ -80,7 +76,9 @@ export SKIP_VALIDATION_CHARTS
8076
process_chart() {
8177
local chart_path=$1
8278
local chart_name=$(basename "$chart_path")
83-
local result_file=$(mktemp)
79+
local result_dir=$(mktemp -d)
80+
local lint_file="$result_dir/lint"
81+
local template_file="$result_dir/template"
8482
local has_error=0
8583

8684
# Store the absolute path to the chart
@@ -89,9 +87,9 @@ process_chart() {
8987
echo "Processing: ${chart_path}" >&2
9088

9189
# Run helm lint
92-
if ! helm lint "$chart_absolute_path" > "$result_file.lint" 2>&1; then
90+
if ! helm lint "$chart_absolute_path" > "$lint_file" 2>&1; then
9391
echo -e "${RED}✗ Helm lint failed for ${chart_name}${NC}" >&2
94-
cat "$result_file.lint" >&2
92+
cat "$lint_file" >&2
9593
has_error=1
9694
else
9795
echo -e "${GREEN}✓ Helm lint passed for ${chart_name}${NC}" >&2
@@ -100,39 +98,39 @@ process_chart() {
10098
# Check if this chart should skip validation
10199
if should_skip_validation "$chart_name"; then
102100
echo -e "${YELLOW}⊘ Skipping kubeconform for ${chart_name} (database chart)${NC}" >&2
103-
rm -f "$result_file" "$result_file.lint" "$result_file.template"
104-
exit $has_error
101+
rm -rf "$result_dir"
102+
return $has_error
105103
fi
106104

107105
# Build dependencies if Chart.yaml exists and has dependencies
108106
if [ -f "${chart_absolute_path}/Chart.yaml" ]; then
109107
if grep -q "dependencies:" "${chart_absolute_path}/Chart.yaml"; then
110-
cd "$chart_absolute_path"
111-
if ! helm dependency update > /dev/null 2>&1; then
108+
if ! helm dependency update "$chart_absolute_path" > /dev/null 2>&1; then
112109
echo -e "${RED}✗ Dependency update failed for ${chart_name}${NC}" >&2
113-
cd "$INITIAL_DIR"
114-
rm -f "$result_file" "$result_file.lint" "$result_file.template"
115-
exit 1
110+
rm -rf "$result_dir"
111+
return 1
116112
fi
117113
fi
118114

119-
# Run template validation
120-
cd "$chart_absolute_path"
121-
if ! helm template . 2>/dev/null | kubeconform --ignore-missing-schemas --summary --skip "$CUSTOM_RESOURCES" > "$result_file.template" 2>&1; then
115+
# Run template validation: render the chart and validate the
116+
# resulting manifests with kubeconform. The pipeline's exit status
117+
# reflects kubeconform (the last command), which is what we check.
118+
if ! helm template "$chart_absolute_path" 2>/dev/null \
119+
| kubeconform --ignore-missing-schemas --summary --skip "$CUSTOM_RESOURCES" \
120+
> "$template_file" 2>&1; then
122121
echo -e "${RED}✗ Kubeconform failed for ${chart_name}${NC}" >&2
123-
cat "$result_file.template" >&2
122+
cat "$template_file" >&2
124123
has_error=1
125124
else
126125
echo -e "${GREEN}✓ Kubeconform passed for ${chart_name}${NC}" >&2
127126
fi
128-
cd "$INITIAL_DIR"
129127
else
130128
echo -e "${RED}No Chart.yaml found in ${chart_path}${NC}" >&2
131129
has_error=1
132130
fi
133131

134-
rm -f "$result_file" "$result_file.lint" "$result_file.template"
135-
exit $has_error
132+
rm -rf "$result_dir"
133+
return $has_error
136134
}
137135

138136
# Export for parallel

0 commit comments

Comments
 (0)