Skip to content

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

Open
owen-mc wants to merge 8 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 8 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,674,127
-    Totals,,688,1085,1580
+    Totals,,688,1134,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,,,112,,,,,,,,,,,,,,,,,,,,,,,112,
- net,2,16,100,,,,,,1,,,,,,,,1,,,,,,,16,,100,
+ net,2,16,102,,,,,,1,,,,,,,,1,,,,,,,16,,102,
- 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 thread go/ql/lib/ext/encoding.json.jsontext.model.yml
Comment thread go/ql/lib/ext/encoding.json.jsontext.model.yml Outdated
Comment thread go/ql/lib/ext/strings.model.yml
Comment thread go/ql/lib/semmle/go/frameworks/stdlib/EncodingJson.qll

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

URL clone summaries misuse value-preserving flow, and unrelated C++ and documentation changes should be split out.

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

Review tier: Balanced
Findings: 2 Medium severity · 3 Low severity

New issues introduced by this change (5)
Severity Finding
Medium severity go/​ql/​lib/​ext/​net.url.model.ymlvalue declares a globally value-preserving edge, but URL.Clone allocates and returns a…
Medium severity go/​ql/​lib/​ext/​net.url.model.ymlValues.Clone creates a distinct map, so receiver-to-return flow is not value-preserving. The…
Low severity cpp/​ql/​lib/​ext/​Boost.Asio.model.yml — The stated PR scope is Go 1.27 and strings, but this starts an independent Boost.Asio…
Low severity docs/​codeql/​index.html — This documentation asset update, together with the added CodeQL 2.27 release pages, is unrelated to…
Low severity go/​ql/​lib/​ext/​strings.model.yml — The separator flow introduced on this line is not exercised: the current Join fixture only…
Issues resolved since last review (4)
Severity Finding
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… View resolved comment
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… View resolved comment
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… View resolved comment
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… View resolved comment
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

Comment thread go/ql/lib/ext/net.url.model.yml Outdated
Comment thread go/ql/lib/ext/net.url.model.yml Outdated
Comment thread cpp/ql/lib/ext/Boost.Asio.model.yml
Comment thread docs/codeql/index.html
Comment thread go/ql/lib/ext/strings.model.yml
@github-actions github-actions Bot added the C++ label Sep 10, 2026
owen-mc and others added 7 commits September 10, 2026 18:59
Functions returning an `iter.Seq` are not yet modeled.
drop jsontext Pointer.Tokens model, add jsontext tests, fix strings
Fields tests

Co-authored-by: owen-mc <62447351+owen-mc@users.noreply.github.com>

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

🔵 Needs a closer look

Boolean jsontext summaries are missing, and unrelated C++ and documentation changes should be separated.

Review tier: Balanced
Findings: None

Issues resolved since last review (5)
Severity Finding
Low severity go/​ql/​lib/​ext/​strings.model.yml — The separator flow introduced on this line is not exercised: the current Join fixture only… View resolved comment
Low severity docs/​codeql/​index.html — This documentation asset update, together with the added CodeQL 2.27 release pages, is unrelated to… View resolved comment
Low severity cpp/​ql/​lib/​ext/​Boost.Asio.model.yml — The stated PR scope is Go 1.27 and strings, but this starts an independent Boost.Asio… View resolved comment
Medium severity go/​ql/​lib/​ext/​net.url.model.ymlValues.Clone creates a distinct map, so receiver-to-return flow is not value-preserving. The… View resolved comment
Medium severity go/​ql/​lib/​ext/​net.url.model.ymlvalue declares a globally value-preserving edge, but URL.Clone allocates and returns a… View resolved comment
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
Previously missed findings (2)

In code that hasn't changed since last review

go/ql/lib/ext/encoding.json.jsontext.model.yml:15

  • The scalar-token models skip jsontext.Bool(bool) Token and Token.Bool() bool, although the same constructor/accessor pairs are modeled for strings and every numeric token type. Calls through either boolean API therefore lose taint. Please add both summary rows and corresponding StdlibTaintFlow cases.
    docs/codeql/codeql-overview/codeql-changelog/index.rst:14
  • Adding the CodeQL 2.27.0 release changelog and toctree entry is unrelated to the PR's stated Go modeling scope. Please exclude the release-documentation changes from this pull request.

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

🔵 Needs a closer look

Both net/url deep-copy models are incorrectly marked as globally value-preserving.

Review tier: Balanced
Findings: None

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

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.

3 participants