Skip to content

Commit 3f00444

Browse files
Vivek Reddyclaude
andcommitted
Fix Copilot security scanning issues
- Add int32Param function with proper bounds checking using strconv.ParseInt to safely convert string parameters to int32 without potential overflow - Add documentation explaining why InsecureSkipVerify is required for E2E testing (self-signed Splunk certs via port-forward to localhost) - Add #nosec and //nolint:gosec annotations to suppress false positive 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 67ab8ea commit 3f00444

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

e2e/framework/runner/topology.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ func (r *Runner) runTopologyGroup(ctx context.Context, group topologyGroup) []re
153153
LicenseMasterRef: strings.TrimSpace(group.params["license_master_ref"]),
154154
MonitoringConsoleRef: strings.TrimSpace(group.params["monitoring_console_ref"]),
155155
ClusterManagerKind: strings.TrimSpace(group.params["cluster_manager_kind"]),
156-
IndexerReplicas: int32(intParam(group.params, "indexer_replicas", defaultIndexerReplicas(group.kind))),
157-
SHCReplicas: int32(intParam(group.params, "shc_replicas", defaultSHCReplicas(group.kind))),
156+
IndexerReplicas: int32Param(group.params, "indexer_replicas", int32(defaultIndexerReplicas(group.kind))),
157+
SHCReplicas: int32Param(group.params, "shc_replicas", int32(defaultSHCReplicas(group.kind))),
158158
WithSHC: boolParam(group.params, "with_shc", true),
159159
SiteCount: intParam(group.params, "site_count", defaultSiteCount(group.kind)),
160160
}
@@ -306,6 +306,20 @@ func intParam(params map[string]string, key string, fallback int) int {
306306
return value
307307
}
308308

309+
// int32Param safely parses a parameter as int32 with bounds checking.
310+
// Returns fallback if the value is empty, invalid, or out of int32 range.
311+
func int32Param(params map[string]string, key string, fallback int32) int32 {
312+
raw := strings.TrimSpace(params[key])
313+
if raw == "" {
314+
return fallback
315+
}
316+
value, err := strconv.ParseInt(raw, 10, 32)
317+
if err != nil {
318+
return fallback
319+
}
320+
return int32(value)
321+
}
322+
309323
func boolParam(params map[string]string, key string, fallback bool) bool {
310324
raw := strings.TrimSpace(params[key])
311325
if raw == "" {

e2e/framework/splunkd/client.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,18 @@ func (c *Client) doRequest(ctx context.Context, port int, method, path string, q
265265
req.Header.Set(key, value)
266266
}
267267

268+
// Note: InsecureSkipVerify is required for E2E testing because:
269+
// 1. Splunk pods use self-signed certificates by default
270+
// 2. This client connects via port-forward to localhost (127.0.0.1)
271+
// 3. Certificate hostname verification would fail for localhost connections
272+
// 4. This is test framework code, not production code
273+
// #nosec G402 -- This is intentional for E2E test framework connecting to self-signed Splunk certs
268274
client := &http.Client{
269275
Timeout: 60 * time.Second,
270276
Transport: &http.Transport{
271-
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
277+
TLSClientConfig: &tls.Config{
278+
InsecureSkipVerify: true, //nolint:gosec // Required for self-signed Splunk certs in E2E tests
279+
},
272280
},
273281
}
274282
resp, err := client.Do(req)

0 commit comments

Comments
 (0)