This repository was archived by the owner on Oct 31, 2025. It is now read-only.
Potential fix for code scanning alert no. 1: Potentially unsafe quoting #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Potential fix for https://github.com/cloudquery/databricks-sql-go/security/code-scanning/1
General Approach:
To robustly construct valid JSON objects from untrusted keys and values, avoid building string representations by hand. Instead, use the
encoding/jsonpackage to do the actual encoding (which always takes care of correct escaping and quoting), or — if hand-building is absolutely necessary due to performance or low-level requirements — make sure to JSON-escape and quote the key using standard library APIs such asjson.Marshal.Detailed Fix:
On line 301, instead of manually enclosing the key in double quotes (and trying to check if it's already quoted), we should always encode the key using
json.Marshal(k)(notmarshal(k), which encodes with custom logic) so that we get double-quoted, escaped key strings. This guarantees that, no matter what data is ink, the result will be valid JSON string key syntax.json.Marshal.json.Marshal(k)to produce the key and insert it as-is.marshal(k)is needed becausekcould be other types (like numbers or objects), and this must match a previous design, be extra careful about not stripping or adding redundant quotes. But, for JSON object keys, only strings (or types convertible to strings) are valid, so coercion viajson.Marshalis safest.Affected lines:
internal/rows/arrowbased/columnValues.go, replace lines 300–303 with logic that always usesjson.Marshal(k)for the object key and inserts the result directly, followed by a colon.keyin context, possibly movingkfrom before, or usingkey, but marshaling it again as needed.Suggested fixes powered by Copilot Autofix. Review carefully before merging.