-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Go: Add BigQuery as a sink for SQLi queries #2 #19561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for treating cloud.google.com/go/bigquery.Client.Query
as a SQL-injection sink in CodeQL analyses, along with test scaffolding, expected outputs, and a change note.
- Introduce a Go test module (
bigquery.go
,go.mod
) demonstrating an untrusted string passed toClient.Query
. - Add CodeQL test query (
bigquery.ql
) and sink model (cloud.google.com.go.bigquery.model.yml
) to markQuery
as an SQLi sink. - Provide test expectations and change notes (
*.expected
,*.md
).
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
go/ql/test/library-tests/semmle/go/frameworks/SQL/bigquery/go.mod | New module with BigQuery dependency for tests |
go/ql/test/library-tests/semmle/go/frameworks/SQL/bigquery/bigquery.ql | CodeQL test that matches calls to BigQuery Query |
go/ql/test/library-tests/semmle/go/frameworks/SQL/bigquery/bigquery.go | Example Go code invoking Query with untrusted data |
go/ql/test/library-tests/semmle/go/frameworks/SQL/bigquery/bigquery.expected | Expected test output for the BigQuery sink |
go/ql/test/library-tests/semmle/go/frameworks/SQL/bigquery/QueryString.ql | Test modules for SQL::QueryString and dataflow validation |
go/ql/test/library-tests/semmle/go/frameworks/SQL/bigquery/QueryString.expected | Expected results placeholder for QueryString tests |
go/ql/lib/ext/cloud.google.com.go.bigquery.model.yml | Extension model marking Client.Query as a SQLi sink |
go/ql/lib/change-notes/2025-05-22-bigquery-client-query-sql-injection.md | Documentation of the newly recognized sink |
Comments suppressed due to low confidence (2)
go/ql/test/library-tests/semmle/go/frameworks/SQL/bigquery/bigquery.ql:3
- [nitpick] The variables
a
andb
are not descriptive. Consider renaming them topackageName
andfunctionName
(or similar) to clarify their roles inhasQualifiedName
.
from SQL::QueryString qs, Function func, string a, string b
go/ql/test/library-tests/semmle/go/frameworks/SQL/bigquery/QueryString.ql:24
- This forces
element
to be empty, which prevents capturing the actual query string in the QueryString test. Update this toelement = qs.toString()
(or remove the filter) so the test can validate the real value.
element = "" and
Click to show differences in coveragegoGenerated file changes for go
+ `bigquery <https://pkg.go.dev/cloud.google.com/go/bigquery>`_,``cloud.google.com/go/bigquery*``,,,1
- `gorqlite <https://github.com/rqlite/gorqlite>`_,"``github.com/raindog308/gorqlite*``, ``github.com/rqlite/gorqlite*``",16,4,48
+ `gorqlite <https://github.com/rqlite/gorqlite>`_,"``github.com/raindog308/gorqlite*``, ``github.com/rqlite/gorqlite*``, ``github.com/kanikanema/gorqlite*``",24,6,72
- Others,``github.com/kanikanema/gorqlite``,8,2,24
- Totals,,688,1069,1556
+ Totals,,688,1069,1557
+ cloud.google.com/go/bigquery,1,,,,,,,,,,,,,,1,,,,,,,,,,,, |
Also fix up github.com/kanikanema/gorqlite
Supersedes #18460.