Skip to content

Go: Add models for Go 1.27 and expand models for strings package - #22534

Open
owen-mc wants to merge 4 commits into
github:mainfrom
owen-mc:go/mad/1.27
Open

Go: Add models for Go 1.27 and expand models for strings package#22534
owen-mc wants to merge 4 commits into
github:mainfrom
owen-mc:go/mad/1.27

Conversation

@owen-mc

@owen-mc owen-mc commented Sep 9, 2026

Copy link
Copy Markdown
Contributor
  • Added or improved data flow models for the following Go standard-library APIs introduced or updated in Go 1.27:
    • bytes.CutLast, database/sql.ConvertAssign, database/sql/driver.RowsColumnScanner.ScanColumn, net/url.URL.Clone, net/url.Values.Clone and strings.CutLast.
    • The new encoding/json/jsontext package.
  • Added more data flow models for the strings package: strings.Clone, Cut, CutPrefix, CutSuffix, Fields, FieldsFunc, and Join; strings.Builder.String, Builder.WriteByte, and Builder.WriteRune; strings.Reader.ReadByte and Reader.ReadRune; and strings.Replacer.Replace and Replacer.WriteString.

Note that there are some new tests in the strings package that are commented out. They are all functions which return a iter.Seq, which is not supported yet. I intend to do a follow-up PR soon to add support for it.

@owen-mc
owen-mc requested a review from a team as a code owner September 9, 2026 13:07
@owen-mc
owen-mc requested review from a team and a balanced review from Copilot September 9, 2026 13:07
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged.

Click to show differences in coverage

go

Generated file changes for go

  • Changes to framework-coverage-go.rst:
-    `Standard library <https://pkg.go.dev/std>`_,"````, ``archive/*``, ``bufio``, ``bytes``, ``cmp``, ``compress/*``, ``container/*``, ``context``, ``crypto``, ``crypto/*``, ``database/*``, ``debug/*``, ``embed``, ``encoding``, ``encoding/*``, ``errors``, ``expvar``, ``flag``, ``fmt``, ``go/*``, ``hash``, ``hash/*``, ``html``, ``html/*``, ``image``, ``image/*``, ``index/*``, ``io``, ``io/*``, ``log``, ``log/*``, ``maps``, ``math``, ``math/*``, ``mime``, ``mime/*``, ``net``, ``net/*``, ``os``, ``os/*``, ``path``, ``path/*``, ``plugin``, ``reflect``, ``reflect/*``, ``regexp``, ``regexp/*``, ``slices``, ``sort``, ``strconv``, ``strings``, ``sync``, ``sync/*``, ``syscall``, ``syscall/*``, ``testing``, ``testing/*``, ``text/*``, ``time``, ``time/*``, ``unicode``, ``unicode/*``, ``unsafe``, ``weak``",52,625,127
+    `Standard library <https://pkg.go.dev/std>`_,"````, ``archive/*``, ``bufio``, ``bytes``, ``cmp``, ``compress/*``, ``container/*``, ``context``, ``crypto``, ``crypto/*``, ``database/*``, ``debug/*``, ``embed``, ``encoding``, ``encoding/*``, ``errors``, ``expvar``, ``flag``, ``fmt``, ``go/*``, ``hash``, ``hash/*``, ``html``, ``html/*``, ``image``, ``image/*``, ``index/*``, ``io``, ``io/*``, ``log``, ``log/*``, ``maps``, ``math``, ``math/*``, ``mime``, ``mime/*``, ``net``, ``net/*``, ``os``, ``os/*``, ``path``, ``path/*``, ``plugin``, ``reflect``, ``reflect/*``, ``regexp``, ``regexp/*``, ``slices``, ``sort``, ``strconv``, ``strings``, ``sync``, ``sync/*``, ``syscall``, ``syscall/*``, ``testing``, ``testing/*``, ``text/*``, ``time``, ``time/*``, ``unicode``, ``unicode/*``, ``unsafe``, ``weak``",52,675,127
-    Totals,,688,1085,1580
+    Totals,,688,1135,1580
  • Changes to framework-coverage-go.csv:
- bytes,,,44,,,,,,,,,,,,,,,,,,,,,,,44,
+ bytes,,,45,,,,,,,,,,,,,,,,,,,,,,,45,
- database/sql,30,18,12,,,,,,,,,,,,30,,,,,,18,,,,,12,
+ database/sql,30,18,14,,,,,,,,,,,,30,,,,,,18,,,,,14,
- encoding,,,81,,,,,,,,,,,,,,,,,,,,,,,81,
+ encoding,,,113,,,,,,,,,,,,,,,,,,,,,,,113,
- net,2,16,100,,,,,,1,,,,,,,,1,,,,,,,16,,100,
+ net,2,16,102,,,,,,1,,,,,,,,1,,,,,,,16,,100,2
- strings,,,34,,,,,,,,,,,,,,,,,,,,,,,34,
+ strings,,,47,,,,,,,,,,,,,,,,,,,,,,,46,1

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The iterator summary is ineffective for yielded values, and several new or refined models lack appropriate flow tests.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 4 Medium severity

New issues introduced by this change (4)
Severity Finding
Medium severity go/​ql/​lib/​ext/​encoding.json.jsontext.model.yml — No test under go/ql/test imports or calls encoding/json/jsontext, so none of the new summary…
Medium severity go/​ql/​lib/​ext/​encoding.json.jsontext.model.ymlPointer.Tokens returns an iter.Seq[string], so this edge taints only the returned iterator…
Medium severity go/​ql/​lib/​ext/​strings.model.yml — These summaries now target only the returned slice elements, but the existing tests still pass the…
Medium severity go/​ql/​lib/​semmle/​go/​frameworks/​stdlib/​EncodingJson.qll — The new reverse-flow branch has no jsontext.NewEncoder test. The existing encoding/json branch…
What changed in this PR

Adds Go 1.27 standard-library data-flow models and improves strings model precision.

Changes:

  • Models new Go 1.27 APIs and encoding/json/jsontext.
  • Expands and refines strings summaries.
  • Adds taint-flow fixtures and release notes.
File Description
Strings.go Adds and updates strings flow fixtures.
NetHttp.go Tests URL clone models.
go.mod Targets Go 1.27.
DatabaseSqlDriver.go Tests ScanColumn.
DatabaseSql.go Tests ConvertAssign.
Bytes.go Tests bytes.CutLast.
EncodingJson.qll Models jsontext encoder reverse flow.
strings.model.yml Expands strings summaries.
net.url.model.yml Adds URL clone summaries.
encoding.json.jsontext.model.yml Adds jsontext summaries.
database.sql.model.yml Models ConvertAssign.
database.sql.driver.model.yml Models ScanColumn.
bytes.model.yml Models bytes.CutLast.
2026-09-09-go-1.27-models.md Documents analysis improvements.
Files not reviewed (5)
  • go/ql/test/library-tests/semmle/go/frameworks/StdlibTaintFlow/Bytes.go: Generated file
  • go/ql/test/library-tests/semmle/go/frameworks/StdlibTaintFlow/DatabaseSql.go: Generated file
  • go/ql/test/library-tests/semmle/go/frameworks/StdlibTaintFlow/DatabaseSqlDriver.go: Generated file
  • go/ql/test/library-tests/semmle/go/frameworks/StdlibTaintFlow/NetHttp.go: Generated file
  • go/ql/test/library-tests/semmle/go/frameworks/StdlibTaintFlow/Strings.go: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +6 to +9
- ["encoding/json/jsontext", "", False, "AppendFloat", "", "", "Argument[0..1]", "ReturnValue", "taint", "manual"]
- ["encoding/json/jsontext", "", False, "AppendFormat", "", "", "Argument[0..1]", "ReturnValue[0]", "taint", "manual"]
- ["encoding/json/jsontext", "", False, "AppendQuote", "", "", "Argument[0..1]", "ReturnValue[0]", "taint", "manual"]
- ["encoding/json/jsontext", "", False, "AppendUnquote", "", "", "Argument[0..1]", "ReturnValue[0]", "taint", "manual"]
- ["encoding/json/jsontext", "Pointer", True, "AppendToken", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
- ["encoding/json/jsontext", "Pointer", True, "LastToken", "", "", "Argument[receiver]", "ReturnValue", "taint", "manual"]
- ["encoding/json/jsontext", "Pointer", True, "Parent", "", "", "Argument[receiver]", "ReturnValue", "taint", "manual"]
- ["encoding/json/jsontext", "Pointer", True, "Tokens", "", "", "Argument[receiver]", "ReturnValue", "taint", "manual"]
Comment on lines +11 to +12
- ["strings", "", False, "Fields", "", "", "Argument[0]", "ReturnValue.ArrayElement", "taint", "manual"]
- ["strings", "", False, "FieldsFunc", "", "", "Argument[0]", "ReturnValue.ArrayElement", "taint", "manual"]
Comment on lines +48 to +49
// signature: func NewEncoder(w io.Writer, opts ...Options) *Encoder
this.hasQualifiedName("encoding/json/jsontext", "NewEncoder")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants