Skip to content

fix(connectors): use json.Marshal in CreateTestResult to prevent injection and panics#341

Open
Harishrs2006 wants to merge 1 commit into
microcks:masterfrom
Harishrs2006:fix/json-injection-create-test-result
Open

fix(connectors): use json.Marshal in CreateTestResult to prevent injection and panics#341
Harishrs2006 wants to merge 1 commit into
microcks:masterfrom
Harishrs2006:fix/json-injection-create-test-result

Conversation

@Harishrs2006
Copy link
Copy Markdown

Replace hand-rolled string concatenation in CreateTestResult with a typed struct and json.Marshal — special characters in serviceID, testEndpoint, and secretName are now safely escaped

  1. Eliminates JSON field injection risk when values come from environment variables or external sources in CI/CD pipelines
  2. Replace three panic() calls with proper error returns
  3. Add safe checked type assertion for the response id field instead of bare .(string) that panics on unexpected server response

Related issues: Fixes #340

…ction and panics

Replace hand-rolled string concatenation in CreateTestResult with a typed
struct and json.Marshal. The old approach embedded serviceID, testEndpoint,
and secretName directly into a JSON string without escaping, allowing:
- Malformed JSON when values contain quotes or backslashes
- JSON field injection when values contain control characters

Also replace three panic() calls with proper error returns, and add a safe
checked type assertion for the response 'id' field.

Fixes microcks#338

Signed-off-by: Harish R S <harishrs21082006@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(connectors): CreateTestResult builds JSON via string concat — field injection and panic risks

1 participant