Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.

Conversation

@hermanschaaf
Copy link
Member

Potential fix for https://github.com/cloudquery/databricks-sql-go/security/code-scanning/2

To fix the problem in internal/rows/arrowbased/columnValues.go, we must ensure that when constructing a quoted string literal containing the output of t.String(), any embedded quotes or backslashes are escaped appropriately to avoid breaking the surrounding string. The best practice in Go, as discussed in the background, is to use json.Marshal() to quote and escape the value, since it produces a properly-quoted and escaped JSON string.

So, in the function marshal(val any) ([]byte, error), instead of manually concatenating quotes around t.String(), we should serialize it using json.Marshal(t.String()). This will add double quotes and escape any embedded characters according to JSON rules. Change line 546 from s := "\"" + t.String() + "\"", to use json.Marshal(t.String()), returning its bytes.

No additional imports are required since json is already imported.
Change only the code within the marshal function where a time.Time is detected. No other changes are required.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants