github / github/codeql

False positive - when json.Marshal output is used - cant result in "Potentially unsafe quoting"

Open
#14,159 3 comments 0 reactions 0 assignees View on GitHub
acknowledged false-positive Go
Dominant language
CodeQL
Stars
10.1k
Forks
2.1k
Avg merge
2d 15h
Merged PRs (30d)
141

Description

**Description of the false positive**

An output of golang json.Marshal is apparently not at risk for `unsafe quoting`

**Code samples or links to source code**
```
...
learned, errMarshal := json.Marshal(guardianSpec.Learned)
...
str := fmt.Sprintf(`[{"op":"replace","path":"/spec/learned","value":%s},{"op":"replace","path":"/spec/samples","value":%d}]`, learned, guardianSpec.NumSamples)
...
```

**URL to the alert on GitHub code scanning (optional)**
https://github.com/knative-extensions/security-guard/pull/236

Contributor guide

Open the contributing guide

Research direction

No repository file or test entry point is named. Start by reviewing the linked code-scanning alert and the Go snippet using json.Marshal, then locate the CodeQL query responsible for the unsafe-quoting warning. Done means the reported safe usage is no longer flagged and coverage for this case is verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.