Merge branch 'main' into feature/SSRF

This commit is contained in:
Natalia Pesaresi
2021-09-17 17:46:32 -03:00
committed by GitHub
179 changed files with 10429 additions and 1265 deletions

View File

@@ -7,10 +7,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.16
- name: Set up Go 1.17
uses: actions/setup-go@v1
with:
go-version: 1.16
go-version: 1.17
id: go
- name: Set up CodeQL CLI
@@ -20,7 +20,7 @@ jobs:
echo "Done"
cd $HOME
echo "Downloading CodeQL CLI..."
LATEST=$(gh release list --repo https://github.com/github/codeql-cli-binaries | cut -f 1 | sort --version-sort | tail -1)
LATEST=$(gh release list --repo https://github.com/github/codeql-cli-binaries | cut -f 1 | sort --version-sort | grep -v beta | tail -1)
gh release download --repo https://github.com/github/codeql-cli-binaries --pattern codeql-linux64.zip "$LATEST"
echo "Done"
echo "Unpacking CodeQL CLI..."
@@ -59,10 +59,10 @@ jobs:
name: Test MacOS
runs-on: macOS-latest
steps:
- name: Set up Go 1.16
- name: Set up Go 1.17
uses: actions/setup-go@v1
with:
go-version: 1.16
go-version: 1.17
id: go
- name: Set up CodeQL CLI
@@ -72,7 +72,7 @@ jobs:
echo "Done"
cd $HOME
echo "Downloading CodeQL CLI..."
LATEST=$(gh release list --repo https://github.com/github/codeql-cli-binaries | cut -f 1 | sort --version-sort | tail -1)
LATEST=$(gh release list --repo https://github.com/github/codeql-cli-binaries | cut -f 1 | sort --version-sort | grep -v beta | tail -1)
gh release download --repo https://github.com/github/codeql-cli-binaries --pattern codeql-osx64.zip "$LATEST"
echo "Done"
echo "Unpacking CodeQL CLI..."
@@ -99,10 +99,10 @@ jobs:
name: Test Windows
runs-on: windows-latest
steps:
- name: Set up Go 1.16
- name: Set up Go 1.17
uses: actions/setup-go@v1
with:
go-version: 1.16
go-version: 1.17
id: go
- name: Set up CodeQL CLI
@@ -112,7 +112,7 @@ jobs:
echo "Done"
cd "$HOME"
echo "Downloading CodeQL CLI..."
LATEST=$(gh release list --repo https://github.com/github/codeql-cli-binaries | cut -f 1 | sort --version-sort | tail -1)
LATEST=$(gh release list --repo https://github.com/github/codeql-cli-binaries | cut -f 1 | sort --version-sort | grep -v beta | tail -1)
gh release download --repo https://github.com/github/codeql-cli-binaries --pattern codeql-win64.zip "$LATEST"
echo "Done"
echo "Unpacking CodeQL CLI..."

View File

@@ -1,6 +1 @@
* @github/codeql-go
# Documentation
**/*.qhelp @shati-patel
# Exclude experimental
**/experimental/**/*.qhelp @github/codeql-go

View File

@@ -0,0 +1,2 @@
lgtm,codescanning
* Added support for the `xorm.io/xorm` package

View File

@@ -0,0 +1,2 @@
lgtm,codescanning
* Query "Use of a weak cryptographic key" (`go/insufficient-key-size`) is promoted from experimental status. This checks that any RSA keys which are generated have a size of at least 2048 bits.

View File

@@ -0,0 +1,2 @@
lgtm,codescanning
* The extractor now supports Go 1.17 features and models the changed libraries.

View File

@@ -0,0 +1,2 @@
lgtm,codescanning
* Added `AstNode.getPrimaryQlClasses()` predicate, which gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.

View File

@@ -6,6 +6,8 @@ pull_request_triggers:
- "**/glide.yaml"
- "**/Gopkg.toml"
column_kind: "utf8"
extra_env_vars:
CODEQL_REDUCE_FILES_FOLDERS_RELATIONS: "true"
file_types:
- name: go
display_name: Go

View File

@@ -1,6 +1,8 @@
@echo off
SETLOCAL EnableDelayedExpansion
SET CODEQL_REDUCE_FILES_FOLDERS_RELATIONS=true
if NOT "%CODEQL_EXTRACTOR_GO_EXTRACT_HTML%"=="no" (
type NUL && "%CODEQL_DIST%/codeql.exe" database index-files ^
--working-dir=. ^

View File

@@ -3,7 +3,7 @@
set -eu
if [ "${CODEQL_EXTRACTOR_GO_EXTRACT_HTML:-yes}" != "no" ]; then
"$CODEQL_DIST/codeql" database index-files \
CODEQL_REDUCE_FILES_FOLDERS_RELATIONS=true "$CODEQL_DIST/codeql" database index-files \
--working-dir=. \
--include-extension=.htm \
--include-extension=.html \

View File

@@ -896,16 +896,12 @@ var NumlinesTable = NewTable("numlines",
var FilesTable = NewTable("files",
EntityColumn(FileType, "id").Key(),
StringColumn("name"),
StringColumn("simple"),
StringColumn("ext"),
IntColumn("fromSource"),
)
// FoldersTable is the table defining folder entities
var FoldersTable = NewTable("folders",
EntityColumn(FolderType, "id").Key(),
StringColumn("name"),
StringColumn("simple"),
)
// ContainerParentTable is the table defining the parent-child relation among container entities

View File

@@ -458,7 +458,7 @@ func (extraction *Extraction) extractError(tw *trap.Writer, err packages.Error,
e error
)
if pos == "" {
if pos == "" || pos == "-" {
// extract a dummy file
wd, e := os.Getwd()
if e != nil {
@@ -590,15 +590,6 @@ func (extraction *Extraction) extractFile(ast *ast.File, pkg *packages.Package)
return nil
}
// stemAndExt splits a given file name into its stem (the part before the last '.')
// and extension (the part after the last '.')
func stemAndExt(base string) (string, string) {
if i := strings.LastIndexByte(base, '.'); i >= 0 {
return base[:i], base[i+1:]
}
return base, ""
}
// extractFileInfo extracts file-system level information for the given file, populating
// the `files` and `containerparent` tables
func (extraction *Extraction) extractFileInfo(tw *trap.Writer, file string) {
@@ -627,9 +618,8 @@ func (extraction *Extraction) extractFileInfo(tw *trap.Writer, file string) {
path = parentPath + "/" + component
}
if i == len(components)-1 {
stem, ext := stemAndExt(component)
lbl := tw.Labeler.FileLabelFor(file)
dbscheme.FilesTable.Emit(tw, lbl, path, stem, ext, 0)
dbscheme.FilesTable.Emit(tw, lbl, path)
dbscheme.ContainerParentTable.Emit(tw, parentLbl, lbl)
dbscheme.HasLocationTable.Emit(tw, lbl, emitLocation(tw, lbl, 0, 0, 0, 0))
extraction.Lock.Lock()
@@ -639,7 +629,7 @@ func (extraction *Extraction) extractFileInfo(tw *trap.Writer, file string) {
break
}
lbl := tw.Labeler.GlobalID(util.EscapeTrapSpecialChars(path) + ";folder")
dbscheme.FoldersTable.Emit(tw, lbl, path, component)
dbscheme.FoldersTable.Emit(tw, lbl, path)
if i > 0 {
dbscheme.ContainerParentTable.Emit(tw, parentLbl, lbl)
}

11
go.mod
View File

@@ -1,8 +1,13 @@
module github.com/github/codeql-go
go 1.16
go 1.17
require (
golang.org/x/mod v0.3.0
golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9
golang.org/x/mod v0.5.0
golang.org/x/tools v0.1.5
)
require (
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
)

22
go.sum
View File

@@ -1,23 +1,27 @@
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.5.0 h1:UG21uOlmZabA4fW5i7ZX6bjw1xELEGg/ZLgZq9auk/Q=
golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9 h1:sEvmEcJVKBNUvgCUClbUQeHOAa9U0I2Ce1BooMvVCY4=
golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=

View File

@@ -26,7 +26,7 @@
<sample src="InsufficientKeySizeBad.go" />
<p>
In the example below the key size is set to 2048 bits.
In the example below, the key size is set to 2048 bits.
</p>
<sample src="InsufficientKeySizeGood.go" />

View File

@@ -1,11 +1,13 @@
/**
* @name Use of a weak cryptographic key
* @description Using weak cryptographic key can allow an attacker to compromise security.
* @description Using a weak cryptographic key can allow an attacker to compromise security.
* @kind path-problem
* @problem.severity error
* @security-severity 7.5
* @precision high
* @id go/weak-crypto-key
* @tags security
* external/cwe/cwe-326
* external/cwe/cwe-326
*/
import go

View File

@@ -0,0 +1,8 @@
- description: Experimental queries showing how we use CodeQL internally for developer happiness
- qlpack: codeql-go
- include:
id: go/examples/database-call-in-loop
- include:
id: go/examples/deferinloop
- include:
id: go/examples/gorm-error-not-checked

View File

@@ -0,0 +1,13 @@
package main
import "gorm.io/gorm"
func getUsers(db *gorm.DB, names []string) []User {
res := make([]User, 0, len(names))
for _, name := range names {
var user User
db.Where("name = ?", name).First(&user)
res = append(res, user)
}
return res
}

View File

@@ -0,0 +1,29 @@
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>Database calls in loops are slower than running a single query and consume more resources. This
can lead to denial of service attacks if the loop bounds can be controlled by an attacker.</p>
</overview>
<recommendation>
<p>Ensure that where possible, database queries are not run in a loop, instead running a single query to get all relevant data.</p>
</recommendation>
<example>
<p>In the example below, users in a database are queried one by one in a loop:</p>
<sample src="DatabaseCallInLoop.go" />
<p>This is corrected by running a single query that selects all of the users at once:</p>
<sample src="DatabaseCallInLoopGood.go" />
</example>
<references>
</references>
</qhelp>

View File

@@ -0,0 +1,69 @@
/**
* @name Database call in loop
* @description Detects database operations within loops.
* Doing operations in series can be slow and lead to N+1 situations.
* @kind path-problem
* @problem.severity warning
* @precision high
* @id go/examples/database-call-in-loop
*/
import go
class DatabaseAccess extends DataFlow::MethodCallNode {
DatabaseAccess() {
exists(string name |
this.getTarget().hasQualifiedName(Gorm::packagePath(), "DB", name) and
// all terminating Gorm methods
name =
[
"Find", "Take", "Last", "Scan", "Row", "Rows", "ScanRows", "Pluck", "Count", "First",
"FirstOrInit", "FindOrCreate", "Update", "Updates", "UpdateColumn", "UpdateColumns",
"Save", "Create", "Delete", "Exec"
]
)
}
}
class CallGraphNode extends Locatable {
CallGraphNode() {
this instanceof LoopStmt
or
this instanceof CallExpr
or
this instanceof FuncDef
}
}
/**
* Holds if `pred` calls `succ`, i.e. is an edge in the call graph,
* This includes explicit edges from call -> callee, to produce better paths.
*/
predicate callGraphEdge(CallGraphNode pred, CallGraphNode succ) {
// Go from a loop to an enclosed expression.
pred.(LoopStmt).getBody().getAChild*() = succ.(CallExpr)
or
// Go from a call to the called function.
pred.(CallExpr) = succ.(FuncDef).getACall().asExpr()
or
// Go from a function to an enclosed loop.
pred.(FuncDef) = succ.(LoopStmt).getEnclosingFunction()
or
// Go from a function to an enclosed call.
pred.(FuncDef) = succ.(CallExpr).getEnclosingFunction()
}
query predicate edges(CallGraphNode pred, CallGraphNode succ) {
callGraphEdge(pred, succ) and
// Limit the range of edges to only those that are relevant.
// This helps to speed up the query by reducing the size of the outputted path information.
exists(LoopStmt loop, DatabaseAccess dbAccess |
// is between a loop and a db access
callGraphEdge*(loop, pred) and
callGraphEdge*(succ, dbAccess.asExpr())
)
}
from LoopStmt loop, DatabaseAccess dbAccess
where edges*(loop, dbAccess.asExpr())
select dbAccess, loop, dbAccess, "$@ is called in $@", dbAccess, dbAccess.toString(), loop, "a loop"

View File

@@ -0,0 +1,9 @@
package main
import "gorm.io/gorm"
func getUsersGood(db *gorm.DB, names []string) []User {
res := make([]User, 0, len(names))
db.Where("name IN ?", names).Find(&res)
return res
}

View File

@@ -0,0 +1,14 @@
package main
import "os"
func openFiles(filenames []string) {
for _, filename := range filenames {
file, err := os.Open(filename)
defer file.Close()
if err != nil {
// handle error
}
// work on file
}
}

View File

@@ -0,0 +1,32 @@
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>A deferred statement in a loop will not execute until the end of the function. This can lead to unintentionally holding resources open, like file handles or database transactions.</p>
</overview>
<recommendation>
<p>Either run the deferred function manually, or create a subroutine that contains the defer.</p>
</recommendation>
<example>
<p>In the example below, the files opened in the loop are not closed until the end of the function:</p>
<sample src="DeferInLoop.go" />
<p>The corrected version puts the loop body into a function.</p>
<sample src="DeferInLoopGood.go" />
</example>
<references>
<li>
<a href="https://golang.org/ref/spec#Defer_statements">Defer statements</a>.
</li>
</references>
</qhelp>

View File

@@ -0,0 +1,18 @@
package main
import "os"
func openFile(filename string) {
file, err := os.Open(filename)
defer file.Close()
if err != nil {
// handle error
}
// work on file
}
func openFilesGood(filenames []string) {
for _, filename := range filenames {
openFile(filename)
}
}

View File

@@ -0,0 +1,9 @@
package main
import "gorm.io/gorm"
func getUserId(db *gorm.DB, name string) int64 {
var user User
db.Where("name = ?", name).First(&user)
return user.Id
}

View File

@@ -0,0 +1,34 @@
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>GORM errors are returned as a field of the return value instead of a separate return value.</p>
<p>It is therefore very easy to miss that an error may occur and omit error handling routines.</p>
</overview>
<recommendation>
<p>Ensure that GORM errors are checked.</p>
</recommendation>
<example>
<p>In the example below, the error from the database query is never checked:</p>
<sample src="GORMErrorNotChecked.go" />
<p>The corrected version checks and handles the error before returning.</p>
<sample src="GORMErrorNotCheckedGood.go" />
</example>
<references>
<li>
<a href="https://gorm.io/docs/error_handling.html">GORM Error Handling</a>.
</li>
</references>
</qhelp>

View File

@@ -0,0 +1,35 @@
/**
* @name GORM error not checked
* @description A call that interacts with the database using the GORM library
* without checking whether there was an error.
* @kind problem
* @problem.severity warning
* @id go/examples/gorm-error-not-checked
* @precision high
*/
import go
import semmle.go.frameworks.SQL
from DataFlow::MethodCallNode call
where
exists(string name | call.getTarget().hasQualifiedName(Gorm::packagePath(), "DB", name) |
name != "InstantSet" and
name != "LogMode"
) and
// the value from the call does not:
not exists(DataFlow::Node succ | TaintTracking::localTaintStep*(call, succ) |
// get assigned to any variables
succ = any(Write w).getRhs()
or
// get returned
succ instanceof DataFlow::ResultNode
or
// have any methods chained on it
exists(DataFlow::MethodCallNode m | succ = m.getReceiver())
or
// have its `Error` field read
exists(DataFlow::FieldReadNode fr | fr.readsField(succ, _, _, "Error"))
)
select call,
"This call appears to interact with the database without checking whether an error was encountered."

View File

@@ -0,0 +1,11 @@
package main
import "gorm.io/gorm"
func getUserIdGood(db *gorm.DB, name string) int64 {
var user User
if err := db.Where("name = ?", name).First(&user).Error; err != nil {
// handle errors
}
return user.Id
}

View File

@@ -25,46 +25,46 @@ private module CleverGo {
|
receiverName = "Context" and
(
// signature: func (*Context).BasicAuth() (username string, password string, ok bool)
// signature: func (*Context) BasicAuth() (username string, password string, ok bool)
methodName = "BasicAuth" and
out.isResult([0, 1])
or
// signature: func (*Context).Decode(v interface{}) (err error)
// signature: func (*Context) Decode(v interface{}) (err error)
methodName = "Decode" and
out.isParameter(0)
or
// signature: func (*Context).DefaultQuery(key string, defaultVlue string) string
// signature: func (*Context) DefaultQuery(key string, defaultVlue string) string
methodName = "DefaultQuery" and
out.isResult()
or
// signature: func (*Context).FormValue(key string) string
// signature: func (*Context) FormValue(key string) string
methodName = "FormValue" and
out.isResult()
or
// signature: func (*Context).GetHeader(name string) string
// signature: func (*Context) GetHeader(name string) string
methodName = "GetHeader" and
out.isResult()
or
// signature: func (*Context).PostFormValue(key string) string
// signature: func (*Context) PostFormValue(key string) string
methodName = "PostFormValue" and
out.isResult()
or
// signature: func (*Context).QueryParam(key string) string
// signature: func (*Context) QueryParam(key string) string
methodName = "QueryParam" and
out.isResult()
or
// signature: func (*Context).QueryParams() net/url.Values
// signature: func (*Context) QueryParams() net/url.Values
methodName = "QueryParams" and
out.isResult()
or
// signature: func (*Context).QueryString() string
// signature: func (*Context) QueryString() string
methodName = "QueryString" and
out.isResult()
)
or
receiverName = "Params" and
(
// signature: func (Params).String(name string) string
// signature: func (Params) String(name string) string
methodName = "String" and
out.isResult()
)
@@ -77,7 +77,7 @@ private module CleverGo {
|
interfaceName = "Decoder" and
(
// signature: func (Decoder).Decode(req *net/http.Request, v interface{}) error
// signature: func (Decoder) Decode(req *net/http.Request, v interface{}) error
methodName = "Decode" and
out.isParameter(1)
)
@@ -135,31 +135,31 @@ private module CleverGo {
// Taint-tracking models for package: clevergo.tech/clevergo@v0.5.2
(
// Receiver type: Application
// signature: func (*Application).RouteURL(name string, args ...string) (*net/url.URL, error)
// signature: func (*Application) RouteURL(name string, args ...string) (*net/url.URL, error)
this.hasQualifiedName(packagePath(), "Application", "RouteURL") and
inp.isParameter(_) and
out.isResult(0)
or
// Receiver type: Context
// signature: func (*Context).Context() context.Context
// signature: func (*Context) Context() context.Context
this.hasQualifiedName(packagePath(), "Context", "Context") and
inp.isReceiver() and
out.isResult()
or
// Receiver type: Params
// signature: func (Params).String(name string) string
// signature: func (Params) String(name string) string
this.hasQualifiedName(packagePath(), "Params", "String") and
inp.isReceiver() and
out.isResult()
or
// Receiver interface: Decoder
// signature: func (Decoder).Decode(req *net/http.Request, v interface{}) error
// signature: func (Decoder) Decode(req *net/http.Request, v interface{}) error
this.implements(packagePath(), "Decoder", "Decode") and
inp.isParameter(0) and
out.isParameter(1)
or
// Receiver interface: Renderer
// signature: func (Renderer).Render(w io.Writer, name string, data interface{}, c *Context) error
// signature: func (Renderer) Render(w io.Writer, name string, data interface{}, c *Context) error
this.implements(packagePath(), "Renderer", "Render") and
inp.isParameter(2) and
out.isParameter(0)
@@ -183,7 +183,7 @@ private module CleverGo {
package = packagePath() and
// Receiver type: Context
(
// signature: func (*Context).Redirect(code int, url string) error
// signature: func (*Context) Redirect(code int, url string) error
this = any(Method m | m.hasQualifiedName(package, "Context", "Redirect")).getACall() and
urlNode = this.getArgument(1)
)
@@ -227,72 +227,72 @@ private module CleverGo {
// Receiver type: Context
receiverName = "Context" and
(
// signature: func (*Context).Error(code int, msg string) error
// signature: func (*Context) Error(code int, msg string) error
methodName = "Error" and
bodyNode = bodySetterCall.getArgument(1) and
contentTypeString = "text/plain"
or
// signature: func (*Context).HTML(code int, html string) error
// signature: func (*Context) HTML(code int, html string) error
methodName = "HTML" and
bodyNode = bodySetterCall.getArgument(1) and
contentTypeString = "text/html"
or
// signature: func (*Context).HTMLBlob(code int, bs []byte) error
// signature: func (*Context) HTMLBlob(code int, bs []byte) error
methodName = "HTMLBlob" and
bodyNode = bodySetterCall.getArgument(1) and
contentTypeString = "text/html"
or
// signature: func (*Context).JSON(code int, data interface{}) error
// signature: func (*Context) JSON(code int, data interface{}) error
methodName = "JSON" and
bodyNode = bodySetterCall.getArgument(1) and
contentTypeString = "application/json"
or
// signature: func (*Context).JSONBlob(code int, bs []byte) error
// signature: func (*Context) JSONBlob(code int, bs []byte) error
methodName = "JSONBlob" and
bodyNode = bodySetterCall.getArgument(1) and
contentTypeString = "application/json"
or
// signature: func (*Context).JSONP(code int, data interface{}) error
// signature: func (*Context) JSONP(code int, data interface{}) error
methodName = "JSONP" and
bodyNode = bodySetterCall.getArgument(1) and
contentTypeString = "application/javascript"
or
// signature: func (*Context).JSONPBlob(code int, bs []byte) error
// signature: func (*Context) JSONPBlob(code int, bs []byte) error
methodName = "JSONPBlob" and
bodyNode = bodySetterCall.getArgument(1) and
contentTypeString = "application/javascript"
or
// signature: func (*Context).JSONPCallback(code int, callback string, data interface{}) error
// signature: func (*Context) JSONPCallback(code int, callback string, data interface{}) error
methodName = "JSONPCallback" and
bodyNode = bodySetterCall.getArgument(2) and
contentTypeString = "application/javascript"
or
// signature: func (*Context).JSONPCallbackBlob(code int, callback string, bs []byte) (err error)
// signature: func (*Context) JSONPCallbackBlob(code int, callback string, bs []byte) (err error)
methodName = "JSONPCallbackBlob" and
bodyNode = bodySetterCall.getArgument(2) and
contentTypeString = "application/javascript"
or
// signature: func (*Context).String(code int, s string) error
// signature: func (*Context) String(code int, s string) error
methodName = "String" and
bodyNode = bodySetterCall.getArgument(1) and
contentTypeString = "text/plain"
or
// signature: func (*Context).StringBlob(code int, bs []byte) error
// signature: func (*Context) StringBlob(code int, bs []byte) error
methodName = "StringBlob" and
bodyNode = bodySetterCall.getArgument(1) and
contentTypeString = "text/plain"
or
// signature: func (*Context).Stringf(code int, format string, a ...interface{}) error
// signature: func (*Context) Stringf(code int, format string, a ...interface{}) error
methodName = "Stringf" and
bodyNode = bodySetterCall.getArgument([1, any(int i | i >= 2)]) and
contentTypeString = "text/plain"
or
// signature: func (*Context).XML(code int, data interface{}) error
// signature: func (*Context) XML(code int, data interface{}) error
methodName = "XML" and
bodyNode = bodySetterCall.getArgument(1) and
contentTypeString = "text/xml"
or
// signature: func (*Context).XMLBlob(code int, bs []byte) error
// signature: func (*Context) XMLBlob(code int, bs []byte) error
methodName = "XMLBlob" and
bodyNode = bodySetterCall.getArgument(1) and
contentTypeString = "text/xml"
@@ -335,12 +335,12 @@ private module CleverGo {
// Receiver type: Context
receiverName = "Context" and
(
// signature: func (*Context).Blob(code int, contentType string, bs []byte) (err error)
// signature: func (*Context) Blob(code int, contentType string, bs []byte) (err error)
methodName = "Blob" and
bodyNode = bodySetterCall.getArgument(2) and
contentTypeNode = bodySetterCall.getArgument(1)
or
// signature: func (*Context).Emit(code int, contentType string, body string) (err error)
// signature: func (*Context) Emit(code int, contentType string, body string) (err error)
methodName = "Emit" and
bodyNode = bodySetterCall.getArgument(2) and
contentTypeNode = bodySetterCall.getArgument(1)
@@ -378,11 +378,11 @@ private module CleverGo {
// Receiver type: Context
receiverName = "Context" and
(
// signature: func (*Context).Write(data []byte) (int, error)
// signature: func (*Context) Write(data []byte) (int, error)
methodName = "Write" and
bodyNode = bodySetterCall.getArgument(0)
or
// signature: func (*Context).WriteString(data string) (int, error)
// signature: func (*Context) WriteString(data string) (int, error)
methodName = "WriteString" and
bodyNode = bodySetterCall.getArgument(0)
)
@@ -425,7 +425,7 @@ private module CleverGo {
// Receiver type: Context
receiverName = "Context" and
(
// signature: func (*Context).SetHeader(key string, value string)
// signature: func (*Context) SetHeader(key string, value string)
methodName = "SetHeader" and
headerNameNode = headerSetterCall.getArgument(0) and
headerValueNode = headerSetterCall.getArgument(1)
@@ -471,19 +471,19 @@ private module CleverGo {
// Receiver type: Context
receiverName = "Context" and
(
// signature: func (*Context).SetContentTypeHTML()
// signature: func (*Context) SetContentTypeHTML()
methodName = "SetContentTypeHTML" and
valueString = "text/html"
or
// signature: func (*Context).SetContentTypeJSON()
// signature: func (*Context) SetContentTypeJSON()
methodName = "SetContentTypeJSON" and
valueString = "application/json"
or
// signature: func (*Context).SetContentTypeText()
// signature: func (*Context) SetContentTypeText()
methodName = "SetContentTypeText" and
valueString = "text/plain"
or
// signature: func (*Context).SetContentTypeXML()
// signature: func (*Context) SetContentTypeXML()
methodName = "SetContentTypeXML" and
valueString = "text/xml"
)
@@ -526,7 +526,7 @@ private module CleverGo {
// Receiver type: Context
receiverName = "Context" and
(
// signature: func (*Context).SetContentType(v string)
// signature: func (*Context) SetContentType(v string)
methodName = "SetContentType" and
valueNode = setterCall.getArgument(0)
)

View File

@@ -138,7 +138,7 @@ private module Fiber {
package = fiberPackagePath() and
// Receiver type: Ctx
(
// signature: func (*Ctx).Redirect(location string, status ...int)
// signature: func (*Ctx) Redirect(location string, status ...int)
this = any(Method m | m.hasQualifiedName(package, "Ctx", "Redirect")).getACall() and
urlNode = this.getArgument(0)
)
@@ -184,12 +184,12 @@ private module Fiber {
// Receiver type: Ctx
receiverName = "Ctx" and
(
// signature: func (*Ctx).Append(field string, values ...string)
// signature: func (*Ctx) Append(field string, values ...string)
methodName = "Append" and
headerNameNode = headerSetterCall.getArgument(0) and
headerValueNode = headerSetterCall.getArgument(any(int i | i >= 1))
or
// signature: func (*Ctx).Set(key string, val string)
// signature: func (*Ctx) Set(key string, val string)
methodName = "Set" and
headerNameNode = headerSetterCall.getArgument(0) and
headerValueNode = headerSetterCall.getArgument(1)
@@ -231,12 +231,12 @@ private module Fiber {
// Receiver type: Ctx
receiverName = "Ctx" and
(
// signature: func (*Ctx).JSON(data interface{}) error
// signature: func (*Ctx) JSON(data interface{}) error
methodName = "JSON" and
bodyNode = bodySetterCall.getArgument(0) and
contentTypeString = "application/json"
or
// signature: func (*Ctx).JSONP(data interface{}, callback ...string) error
// signature: func (*Ctx) JSONP(data interface{}, callback ...string) error
methodName = "JSONP" and
bodyNode = bodySetterCall.getArgument(0) and
contentTypeString = "application/javascript"
@@ -274,27 +274,27 @@ private module Fiber {
// Receiver type: Ctx
receiverName = "Ctx" and
(
// signature: func (*Ctx).Format(body interface{})
// signature: func (*Ctx) Format(body interface{})
methodName = "Format" and
bodyNode = bodySetterCall.getArgument(0)
or
// signature: func (*Ctx).Send(bodies ...interface{})
// signature: func (*Ctx) Send(bodies ...interface{})
methodName = "Send" and
bodyNode = bodySetterCall.getArgument(_)
or
// signature: func (*Ctx).SendBytes(body []byte)
// signature: func (*Ctx) SendBytes(body []byte)
methodName = "SendBytes" and
bodyNode = bodySetterCall.getArgument(0)
or
// signature: func (*Ctx).SendStream(stream io.Reader, size ...int)
// signature: func (*Ctx) SendStream(stream io.Reader, size ...int)
methodName = "SendStream" and
bodyNode = bodySetterCall.getArgument(0)
or
// signature: func (*Ctx).SendString(body string)
// signature: func (*Ctx) SendString(body string)
methodName = "SendString" and
bodyNode = bodySetterCall.getArgument(0)
or
// signature: func (*Ctx).Write(bodies ...interface{})
// signature: func (*Ctx) Write(bodies ...interface{})
methodName = "Write" and
bodyNode = bodySetterCall.getArgument(_)
)
@@ -314,71 +314,71 @@ private module Fiber {
|
receiverName = "Ctx" and
(
// signature: func (*Ctx).BaseURL() string
// signature: func (*Ctx) BaseURL() string
methodName = "BaseURL" and
out.isResult()
or
// signature: func (*Ctx).Body() string
// signature: func (*Ctx) Body() string
methodName = "Body" and
out.isResult()
or
// signature: func (*Ctx).BodyParser(out interface{}) error
// signature: func (*Ctx) BodyParser(out interface{}) error
methodName = "BodyParser" and
out.isParameter(0)
or
// signature: func (*Ctx).Cookies(key string, defaultValue ...string) string
// signature: func (*Ctx) Cookies(key string, defaultValue ...string) string
methodName = "Cookies" and
out.isResult()
or
// signature: func (*Ctx).FormFile(key string) (*mime/multipart.FileHeader, error)
// signature: func (*Ctx) FormFile(key string) (*mime/multipart.FileHeader, error)
methodName = "FormFile" and
out.isResult(0)
or
// signature: func (*Ctx).FormValue(key string) (value string)
// signature: func (*Ctx) FormValue(key string) (value string)
methodName = "FormValue" and
out.isResult()
or
// signature: func (*Ctx).Get(key string, defaultValue ...string) string
// signature: func (*Ctx) Get(key string, defaultValue ...string) string
methodName = "Get" and
out.isResult()
or
// signature: func (*Ctx).Hostname() string
// signature: func (*Ctx) Hostname() string
methodName = "Hostname" and
out.isResult()
or
// signature: func (*Ctx).Method(override ...string) string
// signature: func (*Ctx) Method(override ...string) string
methodName = "Method" and
out.isResult()
or
// signature: func (*Ctx).MultipartForm() (*mime/multipart.Form, error)
// signature: func (*Ctx) MultipartForm() (*mime/multipart.Form, error)
methodName = "MultipartForm" and
out.isResult(0)
or
// signature: func (*Ctx).OriginalURL() string
// signature: func (*Ctx) OriginalURL() string
methodName = "OriginalURL" and
out.isResult()
or
// signature: func (*Ctx).Params(key string, defaultValue ...string) string
// signature: func (*Ctx) Params(key string, defaultValue ...string) string
methodName = "Params" and
out.isResult()
or
// signature: func (*Ctx).Path(override ...string) string
// signature: func (*Ctx) Path(override ...string) string
methodName = "Path" and
out.isResult()
or
// signature: func (*Ctx).Query(key string, defaultValue ...string) string
// signature: func (*Ctx) Query(key string, defaultValue ...string) string
methodName = "Query" and
out.isResult()
or
// signature: func (*Ctx).QueryParser(out interface{}) error
// signature: func (*Ctx) QueryParser(out interface{}) error
methodName = "QueryParser" and
out.isParameter(0)
or
// signature: func (*Ctx).Range(size int) (rangeData Range, err error)
// signature: func (*Ctx) Range(size int) (rangeData Range, err error)
methodName = "Range" and
out.isResult(0)
or
// signature: func (*Ctx).Subdomains(offset ...int) []string
// signature: func (*Ctx) Subdomains(offset ...int) []string
methodName = "Subdomains" and
out.isResult()
)

View File

@@ -133,9 +133,9 @@ locations_default(unique int id: @location_default, int file: @file ref, int beg
numlines(int element_id: @sourceline ref, int num_lines: int ref, int num_code: int ref, int num_comment: int ref);
files(unique int id: @file, string name: string ref, string simple: string ref, string ext: string ref, int fromSource: int ref);
files(unique int id: @file, string name: string ref);
folders(unique int id: @folder, string name: string ref, string simple: string ref);
folders(unique int id: @folder, string name: string ref);
containerparent(int parent: @container ref, unique int child: @container ref);

View File

@@ -8175,18 +8175,6 @@
<k>name</k>
<v>529</v>
</e>
<e>
<k>simple</k>
<v>373</v>
</e>
<e>
<k>ext</k>
<v>3</v>
</e>
<e>
<k>fromSource</k>
<v>1</v>
</e>
</columnsizes>
<dependencies>
<dep>
@@ -8205,54 +8193,6 @@
</hist>
</val>
</dep>
<dep>
<src>id</src>
<trg>simple</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>529</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>id</src>
<trg>ext</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>529</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>id</src>
<trg>fromSource</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>529</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>name</src>
<trg>id</trg>
@@ -8269,301 +8209,6 @@
</hist>
</val>
</dep>
<dep>
<src>name</src>
<trg>simple</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>529</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>name</src>
<trg>ext</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>529</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>name</src>
<trg>fromSource</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>529</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>simple</src>
<trg>id</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>301</v>
</b>
<b>
<a>2</a>
<b>3</b>
<v>47</v>
</b>
<b>
<a>3</a>
<b>22</b>
<v>25</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>simple</src>
<trg>name</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>301</v>
</b>
<b>
<a>2</a>
<b>3</b>
<v>47</v>
</b>
<b>
<a>3</a>
<b>22</b>
<v>25</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>simple</src>
<trg>ext</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>368</v>
</b>
<b>
<a>2</a>
<b>3</b>
<v>5</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>simple</src>
<trg>fromSource</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>373</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>ext</src>
<trg>id</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>1</v>
</b>
<b>
<a>14</a>
<b>15</b>
<v>1</v>
</b>
<b>
<a>514</a>
<b>515</b>
<v>1</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>ext</src>
<trg>name</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>1</v>
</b>
<b>
<a>14</a>
<b>15</b>
<v>1</v>
</b>
<b>
<a>514</a>
<b>515</b>
<v>1</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>ext</src>
<trg>simple</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>1</v>
</b>
<b>
<a>14</a>
<b>15</b>
<v>1</v>
</b>
<b>
<a>363</a>
<b>364</b>
<v>1</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>ext</src>
<trg>fromSource</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>3</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>fromSource</src>
<trg>id</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>529</a>
<b>530</b>
<v>1</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>fromSource</src>
<trg>name</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>529</a>
<b>530</b>
<v>1</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>fromSource</src>
<trg>simple</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>373</a>
<b>374</b>
<v>1</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>fromSource</src>
<trg>ext</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>3</a>
<b>4</b>
<v>1</v>
</b>
</bs>
</hist>
</val>
</dep>
</dependencies>
</relation>
<relation>
@@ -8578,10 +8223,6 @@
<k>name</k>
<v>210</v>
</e>
<e>
<k>simple</k>
<v>178</v>
</e>
</columnsizes>
<dependencies>
<dep>
@@ -8600,22 +8241,6 @@
</hist>
</val>
</dep>
<dep>
<src>id</src>
<trg>simple</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>210</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>name</src>
<trg>id</trg>
@@ -8632,74 +8257,6 @@
</hist>
</val>
</dep>
<dep>
<src>name</src>
<trg>simple</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>210</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>simple</src>
<trg>id</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>157</v>
</b>
<b>
<a>2</a>
<b>3</b>
<v>18</v>
</b>
<b>
<a>3</a>
<b>10</b>
<v>3</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>simple</src>
<trg>name</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>157</v>
</b>
<b>
<a>2</a>
<b>3</b>
<v>18</v>
</b>
<b>
<a>3</a>
<b>10</b>
<v>3</v>
</b>
</bs>
</hist>
</val>
</dep>
</dependencies>
</relation>
<relation>

View File

@@ -81,6 +81,11 @@ class AstNode extends @node, Locatable {
/** Gets the innermost function definition to which this AST node belongs, if any. */
FuncDef getEnclosingFunction() { result = getParent().parentInSameFunction*() }
/**
* Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.
*/
final string getPrimaryQlClasses() { result = concat(getAPrimaryQlClass(), ",") }
/**
* Gets the name of a primary CodeQL class to which this node belongs.
*

View File

@@ -189,7 +189,7 @@ private Comment getInitialComment(File f, int i) {
}
/**
* A build constraint comment of the form `// +build ...`.
* A build constraint comment of the form `// +build ...` or `//go:build ...`.
*
* Examples:
*
@@ -203,17 +203,23 @@ class BuildConstraintComment extends LineComment {
// a line comment preceding the package declaration, itself only preceded by
// line comments
exists(File f, int i |
// correctness of the placement of the build constraint is not checked here;
// this is more lax than the actual rules for build constraints
this = getInitialComment(f, i) and
not getInitialComment(f, [0 .. i - 1]) instanceof BlockComment
) and
// comment text starts with `+build`
getText().regexpMatch("\\s*\\+build.*")
(
// comment text starts with `+build` or `go:build`
this.getText().regexpMatch("\\s*\\+build.*")
or
this.getText().regexpMatch("\\s*go:build.*")
)
}
override string getAPrimaryQlClass() { result = "BuildConstraintComment" }
/** Gets the body of this build constraint. */
string getConstraintBody() { result = getText().splitAt("+build ", 1) }
string getConstraintBody() { result = getText().splitAt("build ", 1) }
/** Gets a disjunct of this build constraint. */
string getADisjunct() { result = getConstraintBody().splitAt(" ") }

View File

@@ -155,7 +155,7 @@ abstract class Container extends @container {
/** A folder. */
class Folder extends Container, @folder {
override string getAbsolutePath() { folders(this, result, _) }
override string getAbsolutePath() { folders(this, result) }
/** Gets the file or subfolder in this folder that has the given `name`, if any. */
Container getChildContainer(string name) {
@@ -182,7 +182,7 @@ class ExtractedOrExternalFile extends Container, @file, Documentable, ExprParent
DeclParent, ScopeNode {
override Location getLocation() { has_location(this, result) }
override string getAbsolutePath() { files(this, result, _, _, _) }
override string getAbsolutePath() { files(this, result) }
/** Gets the number of lines in this file. */
int getNumberOfLines() { numlines(this, result, _, _) }
@@ -222,6 +222,8 @@ class ExtractedOrExternalFile extends Container, @file, Documentable, ExprParent
exists(BuildConstraintComment bcc | this = bcc.getFile() |
forex(string disjunct | disjunct = bcc.getADisjunct() |
disjunct.splitAt(",").(Architecture).getBitSize() = bitSize
or
disjunct.splitAt("/").(Architecture).getBitSize() = bitSize
)
)
}

View File

@@ -1184,6 +1184,14 @@ module CFG {
}
private class ConversionExprTree extends PostOrderTree, ConversionExpr {
override Completion getCompletion() {
// conversions of a slice to an array pointer are the only kind that may panic
this.getType().(PointerType).getBaseType() instanceof ArrayType and
result = Panic()
or
result = Done()
}
override ControlFlow::Node getNode() { result = MkExprNode(this) }
override ControlFlowTree getChildTree(int i) { i = 0 and result = getOperand() }

View File

@@ -1219,7 +1219,7 @@ abstract class BarrierGuard extends Node {
// Case: a function like "return someBarrierGuard(arg)"
// or "return !someBarrierGuard(arg) && otherCond(...)"
exists(boolean outcome |
not exists(DataFlow::Node otherRet | otherRet = outp.getEntryNode(fd) | otherRet != ret) and
ret = getUniqueOutputNode(fd, outp) and
this.checks(arg.asExpr(), outcome) and
// This predicate's contract is (p holds of ret ==> arg is checked),
// (and we have (this has outcome ==> arg is checked))
@@ -1234,7 +1234,7 @@ abstract class BarrierGuard extends Node {
Function f2, FunctionInput inp2, FunctionOutput outp2, CallNode c,
DataFlow::Property outpProp
|
not exists(DataFlow::Node otherRet | otherRet = outp.getEntryNode(fd) | otherRet != ret) and
ret = getUniqueOutputNode(fd, outp) and
this.guardingFunction(f2, inp2, outp2, outpProp) and
c = f2.getACall() and
arg = inp2.getNode(c) and
@@ -1252,6 +1252,10 @@ abstract class BarrierGuard extends Node {
}
}
DataFlow::Node getUniqueOutputNode(FuncDecl fd, FunctionOutput outp) {
result = unique(DataFlow::Node n | n = outp.getEntryNode(fd) | n)
}
/**
* Holds if `ret` is a data-flow node whose value contributes to the output `res` of `fd`,
* and that node may have Boolean value `b`.

View File

@@ -224,3 +224,33 @@ module Gorm {
result = package(["github.com/jinzhu/gorm", "github.com/go-gorm/gorm", "gorm.io/gorm"], "")
}
}
/**
* Provides classes for working with the [XORM](https://xorm.io/) package.
*/
module Xorm {
/** Gets the package name for Xorm. */
string packagePath() { result = package(["xorm.io/xorm", "github.com/go-xorm/xorm"], "") }
/** A model for sinks of XORM. */
private class XormSink extends SQL::QueryString::Range {
XormSink() {
exists(Method meth, string type, string name, int n |
meth.hasQualifiedName(Xorm::packagePath(), type, name) and
this = meth.getACall().getArgument(n) and
type = ["Engine", "Session"]
|
name =
[
"Query", "Exec", "QueryString", "QueryInterface", "SQL", "Where", "And", "Or", "Alias",
"NotIn", "In", "Select", "SetExpr", "OrderBy", "Having", "GroupBy"
] and
n = 0
or
name = ["SumInt", "Sum", "Sums", "SumsInt"] and n = 1
or
name = "Join" and n = [0, 1, 2]
)
}
}
}

View File

@@ -35,15 +35,15 @@ module ArchiveTar {
MethodModels() {
// Methods:
// signature: func (*Header).FileInfo() os.FileInfo
// signature: func (*Header) FileInfo() os.FileInfo
hasQualifiedName("archive/tar", "Header", "FileInfo") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*Reader).Next() (*Header, error)
// signature: func (*Reader) Next() (*Header, error)
hasQualifiedName("archive/tar", "Reader", "Next") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Writer).WriteHeader(hdr *Header) error
// signature: func (*Writer) WriteHeader(hdr *Header) error
hasQualifiedName("archive/tar", "Writer", "WriteHeader") and
(inp.isParameter(0) and outp.isReceiver())
}

View File

@@ -38,15 +38,27 @@ module ArchiveZip {
FunctionOutput outp;
MethodModels() {
// signature: func (*File).Open() (io.ReadCloser, error)
// signature: func (*File) Open() (io.ReadCloser, error)
hasQualifiedName("archive/zip", "File", "Open") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Writer).Create(name string) (io.Writer, error)
// signature: func (*File) OpenRaw() (io.Reader, error)
hasQualifiedName("archive/zip", "File", "OpenRaw") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Writer) Copy(f *File) error
hasQualifiedName("archive/zip", "Writer", "Copy") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*Writer) Create(name string) (io.Writer, error)
hasQualifiedName("archive/zip", "Writer", "Create") and
(inp.isResult(0) and outp.isReceiver())
or
// signature: func (*Writer).CreateHeader(fh *FileHeader) (io.Writer, error)
// signature: func (*Writer) CreateRaw(fh *FileHeader) (io.Writer, error)
hasQualifiedName("archive/zip", "Writer", "CreateRaw") and
(inp.isResult(0) and outp.isReceiver())
or
// signature: func (*Writer) CreateHeader(fh *FileHeader) (io.Writer, error)
hasQualifiedName("archive/zip", "Writer", "CreateHeader") and
(inp.isResult(0) and outp.isReceiver())
}

View File

@@ -79,39 +79,39 @@ module Bufio {
FunctionOutput outp;
MethodModels() {
// signature: func (*Reader).Peek(n int) ([]byte, error)
// signature: func (*Reader) Peek(n int) ([]byte, error)
hasQualifiedName("bufio", "Reader", "Peek") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Reader).ReadBytes(delim byte) ([]byte, error)
// signature: func (*Reader) ReadBytes(delim byte) ([]byte, error)
hasQualifiedName("bufio", "Reader", "ReadBytes") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Reader).ReadLine() (line []byte, isPrefix bool, err error)
// signature: func (*Reader) ReadLine() (line []byte, isPrefix bool, err error)
hasQualifiedName("bufio", "Reader", "ReadLine") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Reader).ReadSlice(delim byte) (line []byte, err error)
// signature: func (*Reader) ReadSlice(delim byte) (line []byte, err error)
hasQualifiedName("bufio", "Reader", "ReadSlice") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Reader).ReadString(delim byte) (string, error)
// signature: func (*Reader) ReadString(delim byte) (string, error)
hasQualifiedName("bufio", "Reader", "ReadString") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Reader).Reset(r io.Reader)
// signature: func (*Reader) Reset(r io.Reader)
hasQualifiedName("bufio", "Reader", "Reset") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*Scanner).Bytes() []byte
// signature: func (*Scanner) Bytes() []byte
hasQualifiedName("bufio", "Scanner", "Bytes") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*Scanner).Text() string
// signature: func (*Scanner) Text() string
hasQualifiedName("bufio", "Scanner", "Text") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*Writer).Reset(w io.Writer)
// signature: func (*Writer) Reset(w io.Writer)
hasQualifiedName("bufio", "Writer", "Reset") and
(inp.isReceiver() and outp.isParameter(0))
}

View File

@@ -150,23 +150,23 @@ module Bytes {
FunctionOutput outp;
MethodModels() {
// signature: func (*Buffer).Bytes() []byte
// signature: func (*Buffer) Bytes() []byte
hasQualifiedName("bytes", "Buffer", "Bytes") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*Buffer).Next(n int) []byte
// signature: func (*Buffer) Next(n int) []byte
hasQualifiedName("bytes", "Buffer", "Next") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*Buffer).ReadBytes(delim byte) (line []byte, err error)
// signature: func (*Buffer) ReadBytes(delim byte) (line []byte, err error)
hasQualifiedName("bytes", "Buffer", "ReadBytes") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Buffer).ReadString(delim byte) (line string, err error)
// signature: func (*Buffer) ReadString(delim byte) (line string, err error)
hasQualifiedName("bytes", "Buffer", "ReadString") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Reader).Reset(b []byte)
// signature: func (*Reader) Reset(b []byte)
hasQualifiedName("bytes", "Reader", "Reset") and
(inp.isParameter(0) and outp.isReceiver())
}

View File

@@ -38,11 +38,11 @@ module CompressFlate {
FunctionOutput outp;
MethodModels() {
// signature: func (*Writer).Reset(dst io.Writer)
// signature: func (*Writer) Reset(dst io.Writer)
hasQualifiedName("compress/flate", "Writer", "Reset") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (Resetter).Reset(r io.Reader, dict []byte) error
// signature: func (Resetter) Reset(r io.Reader, dict []byte) error
implements("compress/flate", "Resetter", "Reset") and
(inp.isParameter(0) and outp.isReceiver())
}

View File

@@ -34,11 +34,11 @@ module CompressGzip {
FunctionOutput outp;
MethodModels() {
// signature: func (*Reader).Reset(r io.Reader) error
// signature: func (*Reader) Reset(r io.Reader) error
hasQualifiedName("compress/gzip", "Reader", "Reset") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*Writer).Reset(w io.Writer)
// signature: func (*Writer) Reset(w io.Writer)
hasQualifiedName("compress/gzip", "Writer", "Reset") and
(inp.isReceiver() and outp.isParameter(0))
}

View File

@@ -42,11 +42,11 @@ module CompressZlib {
FunctionOutput outp;
MethodModels() {
// signature: func (*Writer).Reset(w io.Writer)
// signature: func (*Writer) Reset(w io.Writer)
hasQualifiedName("compress/zlib", "Writer", "Reset") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (Resetter).Reset(r io.Reader, dict []byte) error
// signature: func (Resetter) Reset(r io.Reader, dict []byte) error
implements("compress/zlib", "Resetter", "Reset") and
(inp.isParameter(0) and outp.isReceiver())
}

View File

@@ -34,11 +34,11 @@ module ContainerHeap {
FunctionOutput outp;
MethodModels() {
// signature: func (Interface).Pop() interface{}
// signature: func (Interface) Pop() interface{}
implements("container/heap", "Interface", "Pop") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Interface).Push(x interface{})
// signature: func (Interface) Push(x interface{})
implements("container/heap", "Interface", "Push") and
(inp.isParameter(0) and outp.isReceiver())
}

View File

@@ -11,79 +11,79 @@ module ContainerList {
FunctionOutput outp;
MethodModels() {
// signature: func (*Element).Next() *Element
// signature: func (*Element) Next() *Element
hasQualifiedName("container/list", "Element", "Next") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*Element).Prev() *Element
// signature: func (*Element) Prev() *Element
hasQualifiedName("container/list", "Element", "Prev") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*List).Back() *Element
// signature: func (*List) Back() *Element
hasQualifiedName("container/list", "List", "Back") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*List).Front() *Element
// signature: func (*List) Front() *Element
hasQualifiedName("container/list", "List", "Front") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*List).Init() *List
// signature: func (*List) Init() *List
hasQualifiedName("container/list", "List", "Init") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*List).InsertAfter(v interface{}, mark *Element) *Element
// signature: func (*List) InsertAfter(v interface{}, mark *Element) *Element
hasQualifiedName("container/list", "List", "InsertAfter") and
(
inp.isParameter(0) and
(outp.isReceiver() or outp.isResult())
)
or
// signature: func (*List).InsertBefore(v interface{}, mark *Element) *Element
// signature: func (*List) InsertBefore(v interface{}, mark *Element) *Element
hasQualifiedName("container/list", "List", "InsertBefore") and
(
inp.isParameter(0) and
(outp.isReceiver() or outp.isResult())
)
or
// signature: func (*List).MoveAfter(e *Element, mark *Element)
// signature: func (*List) MoveAfter(e *Element, mark *Element)
hasQualifiedName("container/list", "List", "MoveAfter") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*List).MoveBefore(e *Element, mark *Element)
// signature: func (*List) MoveBefore(e *Element, mark *Element)
hasQualifiedName("container/list", "List", "MoveBefore") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*List).MoveToBack(e *Element)
// signature: func (*List) MoveToBack(e *Element)
hasQualifiedName("container/list", "List", "MoveToBack") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*List).MoveToFront(e *Element)
// signature: func (*List) MoveToFront(e *Element)
hasQualifiedName("container/list", "List", "MoveToFront") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*List).PushBack(v interface{}) *Element
// signature: func (*List) PushBack(v interface{}) *Element
hasQualifiedName("container/list", "List", "PushBack") and
(
inp.isParameter(0) and
(outp.isReceiver() or outp.isResult())
)
or
// signature: func (*List).PushBackList(other *List)
// signature: func (*List) PushBackList(other *List)
hasQualifiedName("container/list", "List", "PushBackList") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*List).PushFront(v interface{}) *Element
// signature: func (*List) PushFront(v interface{}) *Element
hasQualifiedName("container/list", "List", "PushFront") and
(
inp.isParameter(0) and
(outp.isReceiver() or outp.isResult())
)
or
// signature: func (*List).PushFrontList(other *List)
// signature: func (*List) PushFrontList(other *List)
hasQualifiedName("container/list", "List", "PushFrontList") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*List).Remove(e *Element) interface{}
// signature: func (*List) Remove(e *Element) interface{}
hasQualifiedName("container/list", "List", "Remove") and
(inp.isParameter(0) and outp.isResult())
}

View File

@@ -11,23 +11,23 @@ module ContainerRing {
FunctionOutput outp;
MethodModels() {
// signature: func (*Ring).Link(s *Ring) *Ring
// signature: func (*Ring) Link(s *Ring) *Ring
hasQualifiedName("container/ring", "Ring", "Link") and
(inp.isParameter(0) and outp.isResult())
or
// signature: func (*Ring).Move(n int) *Ring
// signature: func (*Ring) Move(n int) *Ring
hasQualifiedName("container/ring", "Ring", "Move") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*Ring).Next() *Ring
// signature: func (*Ring) Next() *Ring
hasQualifiedName("container/ring", "Ring", "Next") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*Ring).Prev() *Ring
// signature: func (*Ring) Prev() *Ring
hasQualifiedName("container/ring", "Ring", "Prev") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*Ring).Unlink(n int) *Ring
// signature: func (*Ring) Unlink(n int) *Ring
hasQualifiedName("container/ring", "Ring", "Unlink") and
(inp.isReceiver() and outp.isResult())
}

View File

@@ -46,7 +46,7 @@ module Context {
FunctionOutput outp;
MethodModels() {
// signature: func (Context).Value(key interface{}) interface{}
// signature: func (Context) Value(key interface{}) interface{}
implements(packagePath(), "Context", "Value") and
(inp.isReceiver() and outp.isResult())
}

View File

@@ -11,7 +11,7 @@ module Crypto {
FunctionOutput outp;
MethodModels() {
// signature: func (Decrypter).Decrypt(rand io.Reader, msg []byte, opts DecrypterOpts) (plaintext []byte, err error)
// signature: func (Decrypter) Decrypt(rand io.Reader, msg []byte, opts DecrypterOpts) (plaintext []byte, err error)
implements("crypto", "Decrypter", "Decrypt") and
(inp.isParameter(1) and outp.isResult(0))
}

View File

@@ -11,11 +11,11 @@ module CryptoCipher {
FunctionOutput outp;
MethodModels() {
// signature: func (Block).Decrypt(dst []byte, src []byte)
// signature: func (Block) Decrypt(dst []byte, src []byte)
implements("crypto/cipher", "Block", "Decrypt") and
(inp.isParameter(1) and outp.isParameter(0))
or
// signature: func (AEAD).Open(dst []byte, nonce []byte, ciphertext []byte, additionalData []byte) ([]byte, error)
// signature: func (AEAD) Open(dst []byte, nonce []byte, ciphertext []byte, additionalData []byte) ([]byte, error)
implements("crypto/cipher", "AEAD", "Open") and
(
inp.isParameter(2) and

View File

@@ -30,7 +30,7 @@ module CryptoRsa {
FunctionOutput outp;
MethodModels() {
// signature: func (*PrivateKey).Decrypt(rand io.Reader, ciphertext []byte, opts crypto.DecrypterOpts) (plaintext []byte, err error)
// signature: func (*PrivateKey) Decrypt(rand io.Reader, ciphertext []byte, opts crypto.DecrypterOpts) (plaintext []byte, err error)
hasQualifiedName("crypto/rsa", "PrivateKey", "Decrypt") and
(inp.isParameter(1) and outp.isResult(0))
}

View File

@@ -128,15 +128,15 @@ module DatabaseSql {
FunctionOutput outp;
SqlMethodModels() {
// signature: func (*Row).Scan(dest ...interface{}) error
// signature: func (*Row) Scan(dest ...interface{}) error
this.hasQualifiedName("database/sql", "Row", "Scan") and
(inp.isReceiver() and outp.isParameter(_))
or
// signature: func (*Rows).Scan(dest ...interface{}) error
// signature: func (*Rows) Scan(dest ...interface{}) error
this.hasQualifiedName("database/sql", "Rows", "Scan") and
(inp.isReceiver() and outp.isParameter(_))
or
// signature: func (Scanner).Scan(src interface{}) error
// signature: func (Scanner) Scan(src interface{}) error
this.implements("database/sql", "Scanner", "Scan") and
(inp.isParameter(0) and outp.isReceiver())
or
@@ -159,27 +159,27 @@ module DatabaseSql {
FunctionOutput outp;
SqlDriverMethodModels() {
// signature: func (NotNull).ConvertValue(v interface{}) (Value, error)
// signature: func (NotNull) ConvertValue(v interface{}) (Value, error)
this.hasQualifiedName("database/sql/driver", "NotNull", "ConvertValue") and
(inp.isParameter(0) and outp.isResult(0))
or
// signature: func (Null).ConvertValue(v interface{}) (Value, error)
// signature: func (Null) ConvertValue(v interface{}) (Value, error)
this.hasQualifiedName("database/sql/driver", "Null", "ConvertValue") and
(inp.isParameter(0) and outp.isResult(0))
or
// signature: func (ValueConverter).ConvertValue(v interface{}) (Value, error)
// signature: func (ValueConverter) ConvertValue(v interface{}) (Value, error)
this.implements("database/sql/driver", "ValueConverter", "ConvertValue") and
(inp.isParameter(0) and outp.isResult(0))
or
// signature: func (Conn).Prepare(query string) (Stmt, error)
// signature: func (Conn) Prepare(query string) (Stmt, error)
this.implements("database/sql/driver", "Conn", "Prepare") and
(inp.isParameter(0) and outp.isResult(0))
or
// signature: func (ConnPrepareContext).PrepareContext(ctx context.Context, query string) (Stmt, error)
// signature: func (ConnPrepareContext) PrepareContext(ctx context.Context, query string) (Stmt, error)
this.implements("database/sql/driver", "ConnPrepareContext", "PrepareContext") and
(inp.isParameter(1) and outp.isResult(0))
or
// signature: func (Valuer).Value() (Value, error)
// signature: func (Valuer) Value() (Value, error)
this.implements("database/sql/driver", "Valuer", "Value") and
(inp.isReceiver() and outp.isResult(0))
}

View File

@@ -11,19 +11,19 @@ module Encoding {
FunctionOutput outp;
MethodModels() {
// signature: func (BinaryMarshaler).MarshalBinary() (data []byte, err error)
// signature: func (BinaryMarshaler) MarshalBinary() (data []byte, err error)
implements("encoding", "BinaryMarshaler", "MarshalBinary") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (TextMarshaler).MarshalText() (text []byte, err error)
// signature: func (TextMarshaler) MarshalText() (text []byte, err error)
implements("encoding", "TextMarshaler", "MarshalText") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (BinaryUnmarshaler).UnmarshalBinary(data []byte) error
// signature: func (BinaryUnmarshaler) UnmarshalBinary(data []byte) error
implements("encoding", "BinaryUnmarshaler", "UnmarshalBinary") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (TextUnmarshaler).UnmarshalText(text []byte) error
// signature: func (TextUnmarshaler) UnmarshalText(text []byte) error
implements("encoding", "TextUnmarshaler", "UnmarshalText") and
(inp.isParameter(0) and outp.isReceiver())
}

View File

@@ -26,11 +26,11 @@ module EncodingBase32 {
FunctionOutput outp;
MethodModels() {
// signature: func (*Encoding).Decode(dst []byte, src []byte) (n int, err error)
// signature: func (*Encoding) Decode(dst []byte, src []byte) (n int, err error)
hasQualifiedName("encoding/base32", "Encoding", "Decode") and
(inp.isParameter(1) and outp.isParameter(0))
or
// signature: func (*Encoding).DecodeString(s string) ([]byte, error)
// signature: func (*Encoding) DecodeString(s string) ([]byte, error)
hasQualifiedName("encoding/base32", "Encoding", "DecodeString") and
(inp.isParameter(0) and outp.isResult(0))
}

View File

@@ -26,11 +26,11 @@ module EncodingBase64 {
FunctionOutput outp;
MethodModels() {
// signature: func (*Encoding).Decode(dst []byte, src []byte) (n int, err error)
// signature: func (*Encoding) Decode(dst []byte, src []byte) (n int, err error)
hasQualifiedName("encoding/base64", "Encoding", "Decode") and
(inp.isParameter(1) and outp.isParameter(0))
or
// signature: func (*Encoding).DecodeString(s string) ([]byte, error)
// signature: func (*Encoding) DecodeString(s string) ([]byte, error)
hasQualifiedName("encoding/base64", "Encoding", "DecodeString") and
(inp.isParameter(0) and outp.isResult(0))
}

View File

@@ -30,19 +30,19 @@ module EncodingCsv {
FunctionOutput outp;
MethodModels() {
// signature: func (*Reader).Read() (record []string, err error)
// signature: func (*Reader) Read() (record []string, err error)
hasQualifiedName("encoding/csv", "Reader", "Read") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Reader).ReadAll() (records [][]string, err error)
// signature: func (*Reader) ReadAll() (records [][]string, err error)
hasQualifiedName("encoding/csv", "Reader", "ReadAll") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Writer).Write(record []string) error
// signature: func (*Writer) Write(record []string) error
hasQualifiedName("encoding/csv", "Writer", "Write") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*Writer).WriteAll(records [][]string) error
// signature: func (*Writer) WriteAll(records [][]string) error
hasQualifiedName("encoding/csv", "Writer", "WriteAll") and
(inp.isParameter(0) and outp.isReceiver())
}

View File

@@ -30,27 +30,27 @@ module EncodingGob {
FunctionOutput outp;
MethodModels() {
// signature: func (*Decoder).Decode(e interface{}) error
// signature: func (*Decoder) Decode(e interface{}) error
hasQualifiedName("encoding/gob", "Decoder", "Decode") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (*Decoder).DecodeValue(v reflect.Value) error
// signature: func (*Decoder) DecodeValue(v reflect.Value) error
hasQualifiedName("encoding/gob", "Decoder", "DecodeValue") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (*Encoder).Encode(e interface{}) error
// signature: func (*Encoder) Encode(e interface{}) error
hasQualifiedName("encoding/gob", "Encoder", "Encode") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*Encoder).EncodeValue(value reflect.Value) error
// signature: func (*Encoder) EncodeValue(value reflect.Value) error
hasQualifiedName("encoding/gob", "Encoder", "EncodeValue") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (GobDecoder).GobDecode([]byte) error
// signature: func (GobDecoder) GobDecode([]byte) error
implements("encoding/gob", "GobDecoder", "GobDecode") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (GobEncoder).GobEncode() ([]byte, error)
// signature: func (GobEncoder) GobEncode() ([]byte, error)
implements("encoding/gob", "GobEncoder", "GobEncode") and
(inp.isReceiver() and outp.isResult(0))
}

View File

@@ -81,31 +81,31 @@ module EncodingJson {
FunctionOutput outp;
MethodModels() {
// signature: func (*Decoder).Buffered() io.Reader
// signature: func (*Decoder) Buffered() io.Reader
hasQualifiedName("encoding/json", "Decoder", "Buffered") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*Decoder).Decode(v interface{}) error
// signature: func (*Decoder) Decode(v interface{}) error
hasQualifiedName("encoding/json", "Decoder", "Decode") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (*Decoder).Token() (Token, error)
// signature: func (*Decoder) Token() (Token, error)
hasQualifiedName("encoding/json", "Decoder", "Token") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Encoder).Encode(v interface{}) error
// signature: func (*Encoder) Encode(v interface{}) error
hasQualifiedName("encoding/json", "Encoder", "Encode") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*Encoder).SetIndent(prefix string, indent string)
// signature: func (*Encoder) SetIndent(prefix string, indent string)
hasQualifiedName("encoding/json", "Encoder", "SetIndent") and
(inp.isParameter(_) and outp.isReceiver())
or
// signature: func (Marshaler).MarshalJSON() ([]byte, error)
// signature: func (Marshaler) MarshalJSON() ([]byte, error)
implements("encoding/json", "Marshaler", "MarshalJSON") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (Unmarshaler).UnmarshalJSON([]byte) error
// signature: func (Unmarshaler) UnmarshalJSON([]byte) error
implements("encoding/json", "Unmarshaler", "UnmarshalJSON") and
(inp.isParameter(0) and outp.isReceiver())
}

View File

@@ -82,67 +82,67 @@ module EncodingXml {
FunctionOutput outp;
MethodModels() {
// signature: func (CharData).Copy() CharData
// signature: func (CharData) Copy() CharData
hasQualifiedName("encoding/xml", "CharData", "Copy") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Comment).Copy() Comment
// signature: func (Comment) Copy() Comment
hasQualifiedName("encoding/xml", "Comment", "Copy") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*Decoder).Decode(v interface{}) error
// signature: func (*Decoder) Decode(v interface{}) error
hasQualifiedName("encoding/xml", "Decoder", "Decode") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (*Decoder).DecodeElement(v interface{}, start *StartElement) error
// signature: func (*Decoder) DecodeElement(v interface{}, start *StartElement) error
hasQualifiedName("encoding/xml", "Decoder", "DecodeElement") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (*Decoder).RawToken() (Token, error)
// signature: func (*Decoder) RawToken() (Token, error)
hasQualifiedName("encoding/xml", "Decoder", "RawToken") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Decoder).Token() (Token, error)
// signature: func (*Decoder) Token() (Token, error)
hasQualifiedName("encoding/xml", "Decoder", "Token") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (Directive).Copy() Directive
// signature: func (Directive) Copy() Directive
hasQualifiedName("encoding/xml", "Directive", "Copy") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*Encoder).Encode(v interface{}) error
// signature: func (*Encoder) Encode(v interface{}) error
hasQualifiedName("encoding/xml", "Encoder", "Encode") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*Encoder).EncodeElement(v interface{}, start StartElement) error
// signature: func (*Encoder) EncodeElement(v interface{}, start StartElement) error
hasQualifiedName("encoding/xml", "Encoder", "EncodeElement") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*Encoder).EncodeToken(t Token) error
// signature: func (*Encoder) EncodeToken(t Token) error
hasQualifiedName("encoding/xml", "Encoder", "EncodeToken") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*Encoder).Indent(prefix string, indent string)
// signature: func (*Encoder) Indent(prefix string, indent string)
hasQualifiedName("encoding/xml", "Encoder", "Indent") and
(inp.isParameter(_) and outp.isReceiver())
or
// signature: func (ProcInst).Copy() ProcInst
// signature: func (ProcInst) Copy() ProcInst
hasQualifiedName("encoding/xml", "ProcInst", "Copy") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (StartElement).Copy() StartElement
// signature: func (StartElement) Copy() StartElement
hasQualifiedName("encoding/xml", "StartElement", "Copy") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Marshaler).MarshalXML(e *Encoder, start StartElement) error
// signature: func (Marshaler) MarshalXML(e *Encoder, start StartElement) error
this.implements("encoding/xml", "Marshaler", "MarshalXML") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (TokenReader).Token() (Token, error)
// signature: func (TokenReader) Token() (Token, error)
this.implements("encoding/xml", "TokenReader", "Token") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (Unmarshaler).UnmarshalXML(d *Decoder, start StartElement) error
// signature: func (Unmarshaler) UnmarshalXML(d *Decoder, start StartElement) error
this.implements("encoding/xml", "Unmarshaler", "UnmarshalXML") and
(inp.isParameter(0) and outp.isReceiver())
}

View File

@@ -11,27 +11,27 @@ module Expvar {
FunctionOutput outp;
MethodModels() {
// signature: func (Func).Value() interface{}
// signature: func (Func) Value() interface{}
hasQualifiedName("expvar", "Func", "Value") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*Map).Get(key string) Var
// signature: func (*Map) Get(key string) Var
hasQualifiedName("expvar", "Map", "Get") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*Map).Set(key string, av Var)
// signature: func (*Map) Set(key string, av Var)
hasQualifiedName("expvar", "Map", "Set") and
(inp.isParameter(_) and outp.isReceiver())
or
// signature: func (*String).Set(value string)
// signature: func (*String) Set(value string)
hasQualifiedName("expvar", "String", "Set") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*String).Value() string
// signature: func (*String) Value() string
hasQualifiedName("expvar", "String", "Value") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Var).String() string
// signature: func (Var) String() string
implements("expvar", "Var", "String") and
(inp.isReceiver() and outp.isResult())
}

View File

@@ -137,23 +137,23 @@ module Fmt {
FunctionOutput outp;
MethodModels() {
// signature: func (GoStringer).GoString() string
// signature: func (GoStringer) GoString() string
implements("fmt", "GoStringer", "GoString") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (ScanState).Read(buf []byte) (n int, err error)
// signature: func (ScanState) Read(buf []byte) (n int, err error)
implements("fmt", "ScanState", "Read") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (Stringer).String() string
// signature: func (Stringer) String() string
implements("fmt", "Stringer", "String") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (ScanState).Token(skipSpace bool, f func(rune) bool) (token []byte, err error)
// signature: func (ScanState) Token(skipSpace bool, f func(rune) bool) (token []byte, err error)
implements("fmt", "ScanState", "Token") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (State).Write(b []byte) (n int, err error)
// signature: func (State) Write(b []byte) (n int, err error)
this.implements("fmt", "State", "Write") and
(inp.isParameter(0) and outp.isReceiver())
}

View File

@@ -68,11 +68,11 @@ module HtmlTemplate {
FunctionOutput outp;
MethodModels() {
// signature: func (*Template).Execute(wr io.Writer, data interface{}) error
// signature: func (*Template) Execute(wr io.Writer, data interface{}) error
hasQualifiedName("html/template", "Template", "Execute") and
(inp.isParameter(1) and outp.isParameter(0))
or
// signature: func (*Template).ExecuteTemplate(wr io.Writer, name string, data interface{}) error
// signature: func (*Template) ExecuteTemplate(wr io.Writer, name string, data interface{}) error
hasQualifiedName("html/template", "Template", "ExecuteTemplate") and
(inp.isParameter(2) and outp.isParameter(0))
}

View File

@@ -81,31 +81,31 @@ module Io {
FunctionOutput outp;
MethodModels() {
// signature: func (Reader).Read(p []byte) (n int, err error)
// signature: func (Reader) Read(p []byte) (n int, err error)
implements("io", "Reader", "Read") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (ReaderAt).ReadAt(p []byte, off int64) (n int, err error)
// signature: func (ReaderAt) ReadAt(p []byte, off int64) (n int, err error)
implements("io", "ReaderAt", "ReadAt") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (ReaderFrom).ReadFrom(r Reader) (n int64, err error)
// signature: func (ReaderFrom) ReadFrom(r Reader) (n int64, err error)
implements("io", "ReaderFrom", "ReadFrom") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (Writer).Write(p []byte) (n int, err error)
// signature: func (Writer) Write(p []byte) (n int, err error)
implements("io", "Writer", "Write") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (WriterAt).WriteAt(p []byte, off int64) (n int, err error)
// signature: func (WriterAt) WriteAt(p []byte, off int64) (n int, err error)
implements("io", "WriterAt", "WriteAt") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (StringWriter).WriteString(s string) (n int, err error)
// signature: func (StringWriter) WriteString(s string) (n int, err error)
implements("io", "StringWriter", "WriteString") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (WriterTo).WriteTo(w Writer) (n int64, err error)
// signature: func (WriterTo) WriteTo(w Writer) (n int64, err error)
implements("io", "WriterTo", "WriteTo") and
(inp.isReceiver() and outp.isParameter(0))
}

View File

@@ -16,6 +16,10 @@ module IoFs {
FunctionOutput outp;
FunctionModels() {
//signature: func FileInfoToDirEntry(info FileInfo) DirEntry
this.hasQualifiedName(packagePath(), "FileInfoToDirEntry") and
(inp.isParameter(0) and outp.isResult())
or
//signature: func Glob(fsys FS, pattern string) (matches []string, err error)
this.hasQualifiedName(packagePath(), "Glob") and
(inp.isParameter(0) and outp.isResult(0))
@@ -60,35 +64,35 @@ module IoFs {
FunctionOutput outp;
MethodModels() {
//signature: func (DirEntry).Name() string
//signature: func (DirEntry) Name() string
this.implements(packagePath(), "DirEntry", "Name") and
(inp.isReceiver() and outp.isResult())
or
//signature: func (DirEntry).Info() (FileInfo, error)
//signature: func (DirEntry) Info() (FileInfo, error)
this.implements(packagePath(), "DirEntry", "Info") and
(inp.isReceiver() and outp.isResult(0))
or
//signature: func (FS).Open(name string) (File, error)
//signature: func (FS) Open(name string) (File, error)
this.implements(packagePath(), "FS", "Open") and
(inp.isReceiver() and outp.isResult(0))
or
//signature: func (GlobFS).Glob(pattern string) ([]string, error)
//signature: func (GlobFS) Glob(pattern string) ([]string, error)
this.implements(packagePath(), "GlobFS", "Glob") and
(inp.isReceiver() and outp.isResult(0))
or
//signature: func (ReadDirFS).ReadDir(name string) ([]DirEntry, error)
//signature: func (ReadDirFS) ReadDir(name string) ([]DirEntry, error)
this.implements(packagePath(), "ReadDirFS", "ReadDir") and
(inp.isReceiver() and outp.isResult(0))
or
//signature: func (ReadFileFS).ReadFile(name string) ([]byte, error)
//signature: func (ReadFileFS) ReadFile(name string) ([]byte, error)
this.implements(packagePath(), "ReadFileFS", "ReadFile") and
(inp.isReceiver() and outp.isResult(0))
or
//signature: func (SubFS).Sub(dir string) (FS, error)
//signature: func (SubFS) Sub(dir string) (FS, error)
this.implements(packagePath(), "SubFS", "Sub") and
(inp.isReceiver() and outp.isResult(0))
or
//signature: func (File).Read([]byte) (int, error)
//signature: func (File) Read([]byte) (int, error)
this.implements(packagePath(), "File", "Read") and
(inp.isReceiver() and outp.isParameter(0))
}

View File

@@ -51,51 +51,51 @@ module Log {
FunctionOutput outp;
MethodModels() {
// signature: func (*Logger).Fatal(v ...interface{})
// signature: func (*Logger) Fatal(v ...interface{})
hasQualifiedName("log", "Logger", "Fatal") and
(inp.isParameter(_) and outp.isReceiver())
or
// signature: func (*Logger).Fatalf(format string, v ...interface{})
// signature: func (*Logger) Fatalf(format string, v ...interface{})
hasQualifiedName("log", "Logger", "Fatalf") and
(inp.isParameter(_) and outp.isReceiver())
or
// signature: func (*Logger).Fatalln(v ...interface{})
// signature: func (*Logger) Fatalln(v ...interface{})
hasQualifiedName("log", "Logger", "Fatalln") and
(inp.isParameter(_) and outp.isReceiver())
or
// signature: func (*Logger).Panic(v ...interface{})
// signature: func (*Logger) Panic(v ...interface{})
hasQualifiedName("log", "Logger", "Panic") and
(inp.isParameter(_) and outp.isReceiver())
or
// signature: func (*Logger).Panicf(format string, v ...interface{})
// signature: func (*Logger) Panicf(format string, v ...interface{})
hasQualifiedName("log", "Logger", "Panicf") and
(inp.isParameter(_) and outp.isReceiver())
or
// signature: func (*Logger).Panicln(v ...interface{})
// signature: func (*Logger) Panicln(v ...interface{})
hasQualifiedName("log", "Logger", "Panicln") and
(inp.isParameter(_) and outp.isReceiver())
or
// signature: func (*Logger).Print(v ...interface{})
// signature: func (*Logger) Print(v ...interface{})
hasQualifiedName("log", "Logger", "Print") and
(inp.isParameter(_) and outp.isReceiver())
or
// signature: func (*Logger).Printf(format string, v ...interface{})
// signature: func (*Logger) Printf(format string, v ...interface{})
hasQualifiedName("log", "Logger", "Printf") and
(inp.isParameter(_) and outp.isReceiver())
or
// signature: func (*Logger).Println(v ...interface{})
// signature: func (*Logger) Println(v ...interface{})
hasQualifiedName("log", "Logger", "Println") and
(inp.isParameter(_) and outp.isReceiver())
or
// signature: func (*Logger).SetOutput(w io.Writer)
// signature: func (*Logger) SetOutput(w io.Writer)
hasQualifiedName("log", "Logger", "SetOutput") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (*Logger).SetPrefix(prefix string)
// signature: func (*Logger) SetPrefix(prefix string)
hasQualifiedName("log", "Logger", "SetPrefix") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*Logger).Writer() io.Writer
// signature: func (*Logger) Writer() io.Writer
hasQualifiedName("log", "Logger", "Writer") and
(inp.isReceiver() and outp.isResult())
}

View File

@@ -30,15 +30,15 @@ module Mime {
FunctionOutput outp;
MethodModels() {
// signature: func (*WordDecoder).Decode(word string) (string, error)
// signature: func (*WordDecoder) Decode(word string) (string, error)
hasQualifiedName("mime", "WordDecoder", "Decode") and
(inp.isParameter(0) and outp.isResult(0))
or
// signature: func (*WordDecoder).DecodeHeader(header string) (string, error)
// signature: func (*WordDecoder) DecodeHeader(header string) (string, error)
hasQualifiedName("mime", "WordDecoder", "DecodeHeader") and
(inp.isParameter(0) and outp.isResult(0))
or
// signature: func (WordEncoder).Encode(charset string, s string) string
// signature: func (WordEncoder) Encode(charset string, s string) string
hasQualifiedName("mime", "WordEncoder", "Encode") and
(inp.isParameter(1) and outp.isResult())
}

View File

@@ -30,43 +30,43 @@ module MimeMultipart {
FunctionOutput outp;
MethodModels() {
// signature: func (*FileHeader).Open() (File, error)
// signature: func (*FileHeader) Open() (File, error)
hasQualifiedName("mime/multipart", "FileHeader", "Open") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Part).FileName() string
// signature: func (*Part) FileName() string
hasQualifiedName("mime/multipart", "Part", "FileName") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Part).FormName() string
// signature: func (*Part) FormName() string
hasQualifiedName("mime/multipart", "Part", "FormName") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Reader).NextPart() (*Part, error)
// signature: func (*Reader) NextPart() (*Part, error)
hasQualifiedName("mime/multipart", "Reader", "NextPart") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Reader).NextRawPart() (*Part, error)
// signature: func (*Reader) NextRawPart() (*Part, error)
hasQualifiedName("mime/multipart", "Reader", "NextRawPart") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Reader).ReadForm(maxMemory int64) (*Form, error)
// signature: func (*Reader) ReadForm(maxMemory int64) (*Form, error)
hasQualifiedName("mime/multipart", "Reader", "ReadForm") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Writer).CreateFormField(fieldname string) (io.Writer, error)
// signature: func (*Writer) CreateFormField(fieldname string) (io.Writer, error)
hasQualifiedName("mime/multipart", "Writer", "CreateFormField") and
(inp.isResult(0) and outp.isReceiver())
or
// signature: func (*Writer).CreateFormFile(fieldname string, filename string) (io.Writer, error)
// signature: func (*Writer) CreateFormFile(fieldname string, filename string) (io.Writer, error)
hasQualifiedName("mime/multipart", "Writer", "CreateFormFile") and
(inp.isResult(0) and outp.isReceiver())
or
// signature: func (*Writer).CreatePart(header net/textproto.MIMEHeader) (io.Writer, error)
// signature: func (*Writer) CreatePart(header net/textproto.MIMEHeader) (io.Writer, error)
hasQualifiedName("mime/multipart", "Writer", "CreatePart") and
(inp.isResult(0) and outp.isReceiver())
or
// signature: func (*Writer).WriteField(fieldname string, value string) error
// signature: func (*Writer) WriteField(fieldname string, value string) error
hasQualifiedName("mime/multipart", "Writer", "WriteField") and
(inp.isParameter(_) and outp.isReceiver())
}

View File

@@ -54,15 +54,15 @@ module Net {
FunctionOutput outp;
MethodModels() {
// signature: func (*IPConn).ReadFromIP(b []byte) (int, *IPAddr, error)
// signature: func (*IPConn) ReadFromIP(b []byte) (int, *IPAddr, error)
hasQualifiedName("net", "IPConn", "ReadFromIP") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (*IPConn).ReadMsgIP(b []byte, oob []byte) (n int, oobn int, flags int, addr *IPAddr, err error)
// signature: func (*IPConn) ReadMsgIP(b []byte, oob []byte) (n int, oobn int, flags int, addr *IPAddr, err error)
hasQualifiedName("net", "IPConn", "ReadMsgIP") and
(inp.isReceiver() and outp.isParameter(_))
or
// signature: func (*IPConn).SyscallConn() (syscall.RawConn, error)
// signature: func (*IPConn) SyscallConn() (syscall.RawConn, error)
hasQualifiedName("net", "IPConn", "SyscallConn") and
(
inp.isReceiver() and outp.isResult(0)
@@ -70,15 +70,15 @@ module Net {
inp.isResult(0) and outp.isReceiver()
)
or
// signature: func (*IPConn).WriteMsgIP(b []byte, oob []byte, addr *IPAddr) (n int, oobn int, err error)
// signature: func (*IPConn) WriteMsgIP(b []byte, oob []byte, addr *IPAddr) (n int, oobn int, err error)
hasQualifiedName("net", "IPConn", "WriteMsgIP") and
(inp.isParameter([0, 1]) and outp.isReceiver())
or
// signature: func (*IPConn).WriteToIP(b []byte, addr *IPAddr) (int, error)
// signature: func (*IPConn) WriteToIP(b []byte, addr *IPAddr) (int, error)
hasQualifiedName("net", "IPConn", "WriteToIP") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*TCPConn).SyscallConn() (syscall.RawConn, error)
// signature: func (*TCPConn) SyscallConn() (syscall.RawConn, error)
hasQualifiedName("net", "TCPConn", "SyscallConn") and
(
inp.isReceiver() and outp.isResult(0)
@@ -86,7 +86,7 @@ module Net {
inp.isResult(0) and outp.isReceiver()
)
or
// signature: func (*TCPListener).File() (f *os.File, err error)
// signature: func (*TCPListener) File() (f *os.File, err error)
hasQualifiedName("net", "TCPListener", "File") and
(
inp.isReceiver() and outp.isResult(0)
@@ -94,7 +94,7 @@ module Net {
inp.isResult(0) and outp.isReceiver()
)
or
// signature: func (*TCPListener).SyscallConn() (syscall.RawConn, error)
// signature: func (*TCPListener) SyscallConn() (syscall.RawConn, error)
hasQualifiedName("net", "TCPListener", "SyscallConn") and
(
inp.isReceiver() and outp.isResult(0)
@@ -102,15 +102,15 @@ module Net {
inp.isResult(0) and outp.isReceiver()
)
or
// signature: func (*UDPConn).ReadFromUDP(b []byte) (int, *UDPAddr, error)
// signature: func (*UDPConn) ReadFromUDP(b []byte) (int, *UDPAddr, error)
hasQualifiedName("net", "UDPConn", "ReadFromUDP") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (*UDPConn).ReadMsgUDP(b []byte, oob []byte) (n int, oobn int, flags int, addr *UDPAddr, err error)
// signature: func (*UDPConn) ReadMsgUDP(b []byte, oob []byte) (n int, oobn int, flags int, addr *UDPAddr, err error)
hasQualifiedName("net", "UDPConn", "ReadMsgUDP") and
(inp.isReceiver() and outp.isParameter(_))
or
// signature: func (*UDPConn).SyscallConn() (syscall.RawConn, error)
// signature: func (*UDPConn) SyscallConn() (syscall.RawConn, error)
hasQualifiedName("net", "UDPConn", "SyscallConn") and
(
inp.isReceiver() and outp.isResult(0)
@@ -118,23 +118,23 @@ module Net {
inp.isResult(0) and outp.isReceiver()
)
or
// signature: func (*UDPConn).WriteMsgUDP(b []byte, oob []byte, addr *UDPAddr) (n int, oobn int, err error)
// signature: func (*UDPConn) WriteMsgUDP(b []byte, oob []byte, addr *UDPAddr) (n int, oobn int, err error)
hasQualifiedName("net", "UDPConn", "WriteMsgUDP") and
(inp.isParameter([0, 1]) and outp.isReceiver())
or
// signature: func (*UDPConn).WriteToUDP(b []byte, addr *UDPAddr) (int, error)
// signature: func (*UDPConn) WriteToUDP(b []byte, addr *UDPAddr) (int, error)
hasQualifiedName("net", "UDPConn", "WriteToUDP") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*UnixConn).ReadFromUnix(b []byte) (int, *UnixAddr, error)
// signature: func (*UnixConn) ReadFromUnix(b []byte) (int, *UnixAddr, error)
hasQualifiedName("net", "UnixConn", "ReadFromUnix") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (*UnixConn).ReadMsgUnix(b []byte, oob []byte) (n int, oobn int, flags int, addr *UnixAddr, err error)
// signature: func (*UnixConn) ReadMsgUnix(b []byte, oob []byte) (n int, oobn int, flags int, addr *UnixAddr, err error)
hasQualifiedName("net", "UnixConn", "ReadMsgUnix") and
(inp.isReceiver() and outp.isParameter(_))
or
// signature: func (*UnixConn).SyscallConn() (syscall.RawConn, error)
// signature: func (*UnixConn) SyscallConn() (syscall.RawConn, error)
hasQualifiedName("net", "UnixConn", "SyscallConn") and
(
inp.isReceiver() and outp.isResult(0)
@@ -142,15 +142,15 @@ module Net {
inp.isResult(0) and outp.isReceiver()
)
or
// signature: func (*UnixConn).WriteMsgUnix(b []byte, oob []byte, addr *UnixAddr) (n int, oobn int, err error)
// signature: func (*UnixConn) WriteMsgUnix(b []byte, oob []byte, addr *UnixAddr) (n int, oobn int, err error)
hasQualifiedName("net", "UnixConn", "WriteMsgUnix") and
(inp.isParameter([0, 1]) and outp.isReceiver())
or
// signature: func (*UnixConn).WriteToUnix(b []byte, addr *UnixAddr) (int, error)
// signature: func (*UnixConn) WriteToUnix(b []byte, addr *UnixAddr) (int, error)
hasQualifiedName("net", "UnixConn", "WriteToUnix") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*UnixListener).File() (f *os.File, err error)
// signature: func (*UnixListener) File() (f *os.File, err error)
hasQualifiedName("net", "UnixListener", "File") and
(
inp.isReceiver() and outp.isResult(0)
@@ -158,7 +158,7 @@ module Net {
inp.isResult(0) and outp.isReceiver()
)
or
// signature: func (*UnixListener).SyscallConn() (syscall.RawConn, error)
// signature: func (*UnixListener) SyscallConn() (syscall.RawConn, error)
hasQualifiedName("net", "UnixListener", "SyscallConn") and
(
inp.isReceiver() and outp.isResult(0)
@@ -166,23 +166,23 @@ module Net {
inp.isResult(0) and outp.isReceiver()
)
or
// signature: func (Conn).Read(b []byte) (n int, err error)
// signature: func (Conn) Read(b []byte) (n int, err error)
implements("net", "Conn", "Read") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (PacketConn).ReadFrom(p []byte) (n int, addr Addr, err error)
// signature: func (PacketConn) ReadFrom(p []byte) (n int, addr Addr, err error)
implements("net", "PacketConn", "ReadFrom") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (Addr).String() string
// signature: func (Addr) String() string
implements("net", "Addr", "String") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Conn).Write(b []byte) (n int, err error)
// signature: func (Conn) Write(b []byte) (n int, err error)
implements("net", "Conn", "Write") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (PacketConn).WriteTo(p []byte, addr Addr) (n int, err error)
// signature: func (PacketConn) WriteTo(p []byte, addr Addr) (n int, err error)
implements("net", "PacketConn", "WriteTo") and
(inp.isParameter(0) and outp.isReceiver())
}

View File

@@ -326,63 +326,63 @@ module NetHttp {
FunctionOutput outp;
MethodModels() {
// signature: func (Header).Add(key string, value string)
// signature: func (Header) Add(key string, value string)
hasQualifiedName("net/http", "Header", "Add") and
(inp.isParameter(_) and outp.isReceiver())
or
// signature: func (Header).Clone() Header
// signature: func (Header) Clone() Header
hasQualifiedName("net/http", "Header", "Clone") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Header).Get(key string) string
// signature: func (Header) Get(key string) string
hasQualifiedName("net/http", "Header", "Get") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Header).Set(key string, value string)
// signature: func (Header) Set(key string, value string)
hasQualifiedName("net/http", "Header", "Set") and
(inp.isParameter(_) and outp.isReceiver())
or
// signature: func (Header).Values(key string) []string
// signature: func (Header) Values(key string) []string
hasQualifiedName("net/http", "Header", "Values") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Header).Write(w io.Writer) error
// signature: func (Header) Write(w io.Writer) error
hasQualifiedName("net/http", "Header", "Write") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (Header).WriteSubset(w io.Writer, exclude map[string]bool) error
// signature: func (Header) WriteSubset(w io.Writer, exclude map[string]bool) error
hasQualifiedName("net/http", "Header", "WriteSubset") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (*Request).AddCookie(c *Cookie)
// signature: func (*Request) AddCookie(c *Cookie)
hasQualifiedName("net/http", "Request", "AddCookie") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*Request).Clone(ctx context.Context) *Request
// signature: func (*Request) Clone(ctx context.Context) *Request
hasQualifiedName("net/http", "Request", "Clone") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*Request).Write(w io.Writer) error
// signature: func (*Request) Write(w io.Writer) error
hasQualifiedName("net/http", "Request", "Write") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (*Request).WriteProxy(w io.Writer) error
// signature: func (*Request) WriteProxy(w io.Writer) error
hasQualifiedName("net/http", "Request", "WriteProxy") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (*Response).Write(w io.Writer) error
// signature: func (*Response) Write(w io.Writer) error
hasQualifiedName("net/http", "Response", "Write") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (*Transport).Clone() *Transport
// signature: func (*Transport) Clone() *Transport
hasQualifiedName("net/http", "Transport", "Clone") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Hijacker).Hijack() (net.Conn, *bufio.ReadWriter, error)
// signature: func (Hijacker) Hijack() (net.Conn, *bufio.ReadWriter, error)
implements("net/http", "Hijacker", "Hijack") and
(inp.isReceiver() and outp.isResult([0, 1]))
or
// signature: func (ResponseWriter).Write([]byte) (int, error)
// signature: func (ResponseWriter) Write([]byte) (int, error)
implements("net/http", "ResponseWriter", "Write") and
(inp.isParameter(0) and outp.isReceiver())
}

View File

@@ -58,7 +58,7 @@ module NetHttpHttputil {
FunctionOutput outp;
MethodModels() {
// signature: func (*ClientConn).Hijack() (c net.Conn, r *bufio.Reader)
// signature: func (*ClientConn) Hijack() (c net.Conn, r *bufio.Reader)
hasQualifiedName("net/http/httputil", "ClientConn", "Hijack") and
(
inp.isReceiver() and outp.isResult(_)
@@ -66,7 +66,7 @@ module NetHttpHttputil {
inp.isResult(0) and outp.isReceiver()
)
or
// signature: func (*ServerConn).Hijack() (net.Conn, *bufio.Reader)
// signature: func (*ServerConn) Hijack() (net.Conn, *bufio.Reader)
hasQualifiedName("net/http/httputil", "ServerConn", "Hijack") and
(
inp.isReceiver() and outp.isResult(_)
@@ -74,11 +74,11 @@ module NetHttpHttputil {
inp.isResult(0) and outp.isReceiver()
)
or
// signature: func (BufferPool).Get() []byte
// signature: func (BufferPool) Get() []byte
implements("net/http/httputil", "BufferPool", "Get") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (BufferPool).Put([]byte)
// signature: func (BufferPool) Put([]byte)
implements("net/http/httputil", "BufferPool", "Put") and
(inp.isParameter(0) and outp.isReceiver())
}

View File

@@ -34,15 +34,15 @@ module NetMail {
FunctionOutput outp;
MethodModels() {
// signature: func (*AddressParser).Parse(address string) (*Address, error)
// signature: func (*AddressParser) Parse(address string) (*Address, error)
hasQualifiedName("net/mail", "AddressParser", "Parse") and
(inp.isParameter(0) and outp.isResult(0))
or
// signature: func (*AddressParser).ParseList(list string) ([]*Address, error)
// signature: func (*AddressParser) ParseList(list string) ([]*Address, error)
hasQualifiedName("net/mail", "AddressParser", "ParseList") and
(inp.isParameter(0) and outp.isResult(0))
or
// signature: func (Header).Get(key string) string
// signature: func (Header) Get(key string) string
hasQualifiedName("net/mail", "Header", "Get") and
(inp.isReceiver() and outp.isResult())
}

View File

@@ -50,67 +50,67 @@ module NetTextproto {
FunctionOutput outp;
MethodModels() {
// signature: func (MIMEHeader).Add(key string, value string)
// signature: func (MIMEHeader) Add(key string, value string)
hasQualifiedName("net/textproto", "MIMEHeader", "Add") and
(inp.isParameter(_) and outp.isReceiver())
or
// signature: func (MIMEHeader).Get(key string) string
// signature: func (MIMEHeader) Get(key string) string
hasQualifiedName("net/textproto", "MIMEHeader", "Get") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (MIMEHeader).Set(key string, value string)
// signature: func (MIMEHeader) Set(key string, value string)
hasQualifiedName("net/textproto", "MIMEHeader", "Set") and
(inp.isParameter(_) and outp.isReceiver())
or
// signature: func (MIMEHeader).Values(key string) []string
// signature: func (MIMEHeader) Values(key string) []string
hasQualifiedName("net/textproto", "MIMEHeader", "Values") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*Reader).DotReader() io.Reader
// signature: func (*Reader) DotReader() io.Reader
hasQualifiedName("net/textproto", "Reader", "DotReader") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*Reader).ReadCodeLine(expectCode int) (code int, message string, err error)
// signature: func (*Reader) ReadCodeLine(expectCode int) (code int, message string, err error)
hasQualifiedName("net/textproto", "Reader", "ReadCodeLine") and
(inp.isReceiver() and outp.isResult(1))
or
// signature: func (*Reader).ReadContinuedLine() (string, error)
// signature: func (*Reader) ReadContinuedLine() (string, error)
hasQualifiedName("net/textproto", "Reader", "ReadContinuedLine") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Reader).ReadContinuedLineBytes() ([]byte, error)
// signature: func (*Reader) ReadContinuedLineBytes() ([]byte, error)
hasQualifiedName("net/textproto", "Reader", "ReadContinuedLineBytes") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Reader).ReadDotBytes() ([]byte, error)
// signature: func (*Reader) ReadDotBytes() ([]byte, error)
hasQualifiedName("net/textproto", "Reader", "ReadDotBytes") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Reader).ReadDotLines() ([]string, error)
// signature: func (*Reader) ReadDotLines() ([]string, error)
hasQualifiedName("net/textproto", "Reader", "ReadDotLines") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Reader).ReadLine() (string, error)
// signature: func (*Reader) ReadLine() (string, error)
hasQualifiedName("net/textproto", "Reader", "ReadLine") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Reader).ReadLineBytes() ([]byte, error)
// signature: func (*Reader) ReadLineBytes() ([]byte, error)
hasQualifiedName("net/textproto", "Reader", "ReadLineBytes") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Reader).ReadMIMEHeader() (MIMEHeader, error)
// signature: func (*Reader) ReadMIMEHeader() (MIMEHeader, error)
hasQualifiedName("net/textproto", "Reader", "ReadMIMEHeader") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Reader).ReadResponse(expectCode int) (code int, message string, err error)
// signature: func (*Reader) ReadResponse(expectCode int) (code int, message string, err error)
hasQualifiedName("net/textproto", "Reader", "ReadResponse") and
(inp.isReceiver() and outp.isResult(1))
or
// signature: func (*Writer).DotWriter() io.WriteCloser
// signature: func (*Writer) DotWriter() io.WriteCloser
hasQualifiedName("net/textproto", "Writer", "DotWriter") and
(inp.isResult() and outp.isReceiver())
or
// signature: func (*Writer).PrintfLine(format string, args ...interface{}) error
// signature: func (*Writer) PrintfLine(format string, args ...interface{}) error
hasQualifiedName("net/textproto", "Writer", "PrintfLine") and
(inp.isParameter(_) and outp.isReceiver())
}

View File

@@ -110,11 +110,11 @@ module Os {
FunctionOutput outp;
MethodModels() {
// signature: func (*File).Fd() uintptr
// signature: func (*File) Fd() uintptr
hasQualifiedName("os", "File", "Fd") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*File).SyscallConn() (syscall.RawConn, error)
// signature: func (*File) SyscallConn() (syscall.RawConn, error)
hasQualifiedName("os", "File", "SyscallConn") and
(
inp.isReceiver() and outp.isResult(0)

View File

@@ -42,139 +42,139 @@ module Reflect {
FunctionOutput outp;
MethodModels() {
// signature: func (*MapIter).Key() Value
// signature: func (*MapIter) Key() Value
hasQualifiedName("reflect", "MapIter", "Key") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*MapIter).Value() Value
// signature: func (*MapIter) Value() Value
hasQualifiedName("reflect", "MapIter", "Value") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (StructTag).Get(key string) string
// signature: func (StructTag) Get(key string) string
hasQualifiedName("reflect", "StructTag", "Get") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (StructTag).Lookup(key string) (value string, ok bool)
// signature: func (StructTag) Lookup(key string) (value string, ok bool)
hasQualifiedName("reflect", "StructTag", "Lookup") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (Value).Addr() Value
// signature: func (Value) Addr() Value
hasQualifiedName("reflect", "Value", "Addr") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Value).Bytes() []byte
// signature: func (Value) Bytes() []byte
hasQualifiedName("reflect", "Value", "Bytes") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Value).Convert(t Type) Value
// signature: func (Value) Convert(t Type) Value
hasQualifiedName("reflect", "Value", "Convert") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Value).Elem() Value
// signature: func (Value) Elem() Value
hasQualifiedName("reflect", "Value", "Elem") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Value).Field(i int) Value
// signature: func (Value) Field(i int) Value
hasQualifiedName("reflect", "Value", "Field") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Value).FieldByIndex(index []int) Value
// signature: func (Value) FieldByIndex(index []int) Value
hasQualifiedName("reflect", "Value", "FieldByIndex") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Value).FieldByName(name string) Value
// signature: func (Value) FieldByName(name string) Value
hasQualifiedName("reflect", "Value", "FieldByName") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Value).FieldByNameFunc(match func(string) bool) Value
// signature: func (Value) FieldByNameFunc(match func(string) bool) Value
hasQualifiedName("reflect", "Value", "FieldByNameFunc") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Value).Index(i int) Value
// signature: func (Value) Index(i int) Value
hasQualifiedName("reflect", "Value", "Index") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Value).Interface() (i interface{})
// signature: func (Value) Interface() (i interface{})
hasQualifiedName("reflect", "Value", "Interface") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Value).InterfaceData() [2]uintptr
// signature: func (Value) InterfaceData() [2]uintptr
hasQualifiedName("reflect", "Value", "InterfaceData") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Value).MapIndex(key Value) Value
// signature: func (Value) MapIndex(key Value) Value
hasQualifiedName("reflect", "Value", "MapIndex") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Value).MapKeys() []Value
// signature: func (Value) MapKeys() []Value
hasQualifiedName("reflect", "Value", "MapKeys") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Value).MapRange() *MapIter
// signature: func (Value) MapRange() *MapIter
hasQualifiedName("reflect", "Value", "MapRange") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Value).Method(i int) Value
// signature: func (Value) Method(i int) Value
hasQualifiedName("reflect", "Value", "Method") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Value).MethodByName(name string) Value
// signature: func (Value) MethodByName(name string) Value
hasQualifiedName("reflect", "Value", "MethodByName") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Value).Pointer() uintptr
// signature: func (Value) Pointer() uintptr
hasQualifiedName("reflect", "Value", "Pointer") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Value).Recv() (x Value, ok bool)
// signature: func (Value) Recv() (x Value, ok bool)
hasQualifiedName("reflect", "Value", "Recv") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (Value).Send(x Value)
// signature: func (Value) Send(x Value)
hasQualifiedName("reflect", "Value", "Send") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (Value).Set(x Value)
// signature: func (Value) Set(x Value)
hasQualifiedName("reflect", "Value", "Set") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (Value).SetBytes(x []byte)
// signature: func (Value) SetBytes(x []byte)
hasQualifiedName("reflect", "Value", "SetBytes") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (Value).SetMapIndex(key Value, elem Value)
// signature: func (Value) SetMapIndex(key Value, elem Value)
hasQualifiedName("reflect", "Value", "SetMapIndex") and
(inp.isParameter(_) and outp.isReceiver())
or
// signature: func (Value).SetPointer(x unsafe.Pointer)
// signature: func (Value) SetPointer(x unsafe.Pointer)
hasQualifiedName("reflect", "Value", "SetPointer") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (Value).SetString(x string)
// signature: func (Value) SetString(x string)
hasQualifiedName("reflect", "Value", "SetString") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (Value).Slice(i int, j int) Value
// signature: func (Value) Slice(i int, j int) Value
hasQualifiedName("reflect", "Value", "Slice") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Value).Slice3(i int, j int, k int) Value
// signature: func (Value) Slice3(i int, j int, k int) Value
hasQualifiedName("reflect", "Value", "Slice3") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Value).String() string
// signature: func (Value) String() string
hasQualifiedName("reflect", "Value", "String") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (Value).TryRecv() (x Value, ok bool)
// signature: func (Value) TryRecv() (x Value, ok bool)
hasQualifiedName("reflect", "Value", "TryRecv") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (Value).TrySend(x Value) bool
// signature: func (Value) TrySend(x Value) bool
hasQualifiedName("reflect", "Value", "TrySend") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (Value).UnsafeAddr() uintptr
// signature: func (Value) UnsafeAddr() uintptr
hasQualifiedName("reflect", "Value", "UnsafeAddr") and
(inp.isReceiver() and outp.isResult())
}

View File

@@ -85,77 +85,77 @@ module Regexp {
FunctionOutput outp;
MethodModels() {
// signature: func (*Regexp).Expand(dst []byte, template []byte, src []byte, match []int) []byte
// signature: func (*Regexp) Expand(dst []byte, template []byte, src []byte, match []int) []byte
hasQualifiedName("regexp", "Regexp", "Expand") and
(
inp.isParameter([1, 2]) and
(outp.isParameter(0) or outp.isResult())
)
or
// signature: func (*Regexp).ExpandString(dst []byte, template string, src string, match []int) []byte
// signature: func (*Regexp) ExpandString(dst []byte, template string, src string, match []int) []byte
hasQualifiedName("regexp", "Regexp", "ExpandString") and
(
inp.isParameter([1, 2]) and
(outp.isParameter(0) or outp.isResult())
)
or
// signature: func (*Regexp).Find(b []byte) []byte
// signature: func (*Regexp) Find(b []byte) []byte
hasQualifiedName("regexp", "Regexp", "Find") and
(inp.isParameter(0) and outp.isResult())
or
// signature: func (*Regexp).FindAll(b []byte, n int) [][]byte
// signature: func (*Regexp) FindAll(b []byte, n int) [][]byte
hasQualifiedName("regexp", "Regexp", "FindAll") and
(inp.isParameter(0) and outp.isResult())
or
// signature: func (*Regexp).FindAllString(s string, n int) []string
// signature: func (*Regexp) FindAllString(s string, n int) []string
hasQualifiedName("regexp", "Regexp", "FindAllString") and
(inp.isParameter(0) and outp.isResult())
or
// signature: func (*Regexp).FindAllStringSubmatch(s string, n int) [][]string
// signature: func (*Regexp) FindAllStringSubmatch(s string, n int) [][]string
hasQualifiedName("regexp", "Regexp", "FindAllStringSubmatch") and
(inp.isParameter(0) and outp.isResult())
or
// signature: func (*Regexp).FindAllSubmatch(b []byte, n int) [][][]byte
// signature: func (*Regexp) FindAllSubmatch(b []byte, n int) [][][]byte
hasQualifiedName("regexp", "Regexp", "FindAllSubmatch") and
(inp.isParameter(0) and outp.isResult())
or
// signature: func (*Regexp).FindString(s string) string
// signature: func (*Regexp) FindString(s string) string
hasQualifiedName("regexp", "Regexp", "FindString") and
(inp.isParameter(0) and outp.isResult())
or
// signature: func (*Regexp).FindStringSubmatch(s string) []string
// signature: func (*Regexp) FindStringSubmatch(s string) []string
hasQualifiedName("regexp", "Regexp", "FindStringSubmatch") and
(inp.isParameter(0) and outp.isResult())
or
// signature: func (*Regexp).FindSubmatch(b []byte) [][]byte
// signature: func (*Regexp) FindSubmatch(b []byte) [][]byte
hasQualifiedName("regexp", "Regexp", "FindSubmatch") and
(inp.isParameter(0) and outp.isResult())
or
// signature: func (*Regexp).ReplaceAll(src []byte, repl []byte) []byte
// signature: func (*Regexp) ReplaceAll(src []byte, repl []byte) []byte
hasQualifiedName("regexp", "Regexp", "ReplaceAll") and
(inp.isParameter(_) and outp.isResult())
or
// signature: func (*Regexp).ReplaceAllFunc(src []byte, repl func([]byte) []byte) []byte
// signature: func (*Regexp) ReplaceAllFunc(src []byte, repl func([]byte) []byte) []byte
hasQualifiedName("regexp", "Regexp", "ReplaceAllFunc") and
(inp.isParameter(_) and outp.isResult())
or
// signature: func (*Regexp).ReplaceAllLiteral(src []byte, repl []byte) []byte
// signature: func (*Regexp) ReplaceAllLiteral(src []byte, repl []byte) []byte
hasQualifiedName("regexp", "Regexp", "ReplaceAllLiteral") and
(inp.isParameter(_) and outp.isResult())
or
// signature: func (*Regexp).ReplaceAllLiteralString(src string, repl string) string
// signature: func (*Regexp) ReplaceAllLiteralString(src string, repl string) string
hasQualifiedName("regexp", "Regexp", "ReplaceAllLiteralString") and
(inp.isParameter(_) and outp.isResult())
or
// signature: func (*Regexp).ReplaceAllString(src string, repl string) string
// signature: func (*Regexp) ReplaceAllString(src string, repl string) string
hasQualifiedName("regexp", "Regexp", "ReplaceAllString") and
(inp.isParameter(_) and outp.isResult())
or
// signature: func (*Regexp).ReplaceAllStringFunc(src string, repl func(string) string) string
// signature: func (*Regexp) ReplaceAllStringFunc(src string, repl func(string) string) string
hasQualifiedName("regexp", "Regexp", "ReplaceAllStringFunc") and
(inp.isParameter(_) and outp.isResult())
or
// signature: func (*Regexp).Split(s string, n int) []string
// signature: func (*Regexp) Split(s string, n int) []string
hasQualifiedName("regexp", "Regexp", "Split") and
(inp.isParameter(0) and outp.isResult())
}

View File

@@ -56,6 +56,10 @@ module Strconv {
hasQualifiedName("strconv", "Quote") and
(inp.isParameter(0) and outp.isResult())
or
// signature: func QuotedPrefix(s string) (string, error)
hasQualifiedName("strconv", "QuotedPrefix") and
(inp.isParameter(0) and outp.isResult(0))
or
// signature: func QuoteToASCII(s string) string
hasQualifiedName("strconv", "QuoteToASCII") and
(inp.isParameter(0) and outp.isResult())

View File

@@ -142,15 +142,15 @@ module Strings {
FunctionOutput outp;
MethodModels() {
// signature: func (*Reader).Reset(s string)
// signature: func (*Reader) Reset(s string)
hasQualifiedName("strings", "Reader", "Reset") and
(inp.isParameter(0) and outp.isReceiver())
or
// signature: func (*Replacer).Replace(s string) string
// signature: func (*Replacer) Replace(s string) string
hasQualifiedName("strings", "Replacer", "Replace") and
(inp.isParameter(0) and outp.isResult())
or
// signature: func (*Replacer).WriteString(w io.Writer, s string) (n int, err error)
// signature: func (*Replacer) WriteString(w io.Writer, s string) (n int, err error)
hasQualifiedName("strings", "Replacer", "WriteString") and
(inp.isParameter(1) and outp.isParameter(0))
}

View File

@@ -11,11 +11,11 @@ module Sync {
FunctionOutput outp;
MethodModels() {
// signature: func (*Map).Load(key interface{}) (value interface{}, ok bool)
// signature: func (*Map) Load(key interface{}) (value interface{}, ok bool)
hasQualifiedName("sync", "Map", "Load") and
(inp.isReceiver() and outp.isResult(0))
or
// signature: func (*Map).LoadOrStore(key interface{}, value interface{}) (actual interface{}, loaded bool)
// signature: func (*Map) LoadOrStore(key interface{}, value interface{}) (actual interface{}, loaded bool)
hasQualifiedName("sync", "Map", "LoadOrStore") and
(
inp.isReceiver() and outp.isResult(0)
@@ -24,15 +24,15 @@ module Sync {
(outp.isReceiver() or outp.isResult(0))
)
or
// signature: func (*Map).Store(key interface{}, value interface{})
// signature: func (*Map) Store(key interface{}, value interface{})
hasQualifiedName("sync", "Map", "Store") and
(inp.isParameter(_) and outp.isReceiver())
or
// signature: func (*Pool).Get() interface{}
// signature: func (*Pool) Get() interface{}
hasQualifiedName("sync", "Pool", "Get") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*Pool).Put(x interface{})
// signature: func (*Pool) Put(x interface{})
hasQualifiedName("sync", "Pool", "Put") and
(inp.isParameter(0) and outp.isReceiver())
}

View File

@@ -69,11 +69,11 @@ module SyncAtomic {
FunctionOutput outp;
MethodModels() {
// signature: func (*Value).Load() (x interface{})
// signature: func (*Value) Load() (x interface{})
hasQualifiedName("sync/atomic", "Value", "Load") and
(inp.isReceiver() and outp.isResult())
or
// signature: func (*Value).Store(x interface{})
// signature: func (*Value) Store(x interface{})
hasQualifiedName("sync/atomic", "Value", "Store") and
(inp.isParameter(0) and outp.isReceiver())
}

View File

@@ -42,11 +42,11 @@ module Syscall {
FunctionOutput outp;
MethodModels() {
// signature: func (RawConn).Read(f func(fd uintptr) (done bool)) error
// signature: func (RawConn) Read(f func(fd uintptr) (done bool)) error
implements("syscall", "RawConn", "Read") and
(inp.isReceiver() and outp.isParameter(0))
or
// signature: func (Conn).SyscallConn() (RawConn, error)
// signature: func (Conn) SyscallConn() (RawConn, error)
implements("syscall", "Conn", "SyscallConn") and
(
inp.isReceiver() and outp.isResult(0)
@@ -54,7 +54,7 @@ module Syscall {
inp.isResult(0) and outp.isReceiver()
)
or
// signature: func (RawConn).Write(f func(fd uintptr) (done bool)) error
// signature: func (RawConn) Write(f func(fd uintptr) (done bool)) error
implements("syscall", "RawConn", "Write") and
(inp.isParameter(0) and outp.isReceiver())
}

View File

@@ -11,14 +11,14 @@ module TextScanner {
FunctionOutput outp;
MethodModels() {
// signature: func (*Scanner).Init(src io.Reader) *Scanner
// signature: func (*Scanner) Init(src io.Reader) *Scanner
hasQualifiedName("text/scanner", "Scanner", "Init") and
(
inp.isParameter(0) and
(outp.isReceiver() or outp.isResult())
)
or
// signature: func (*Scanner).TokenText() string
// signature: func (*Scanner) TokenText() string
hasQualifiedName("text/scanner", "Scanner", "TokenText") and
(inp.isReceiver() and outp.isResult())
}

View File

@@ -26,7 +26,7 @@ module TextTabwriter {
FunctionOutput outp;
MethodModels() {
// signature: func (*Writer).Init(output io.Writer, minwidth int, tabwidth int, padding int, padchar byte, flags uint) *Writer
// signature: func (*Writer) Init(output io.Writer, minwidth int, tabwidth int, padding int, padchar byte, flags uint) *Writer
hasQualifiedName("text/tabwriter", "Writer", "Init") and
(
(inp.isReceiver() or inp.isResult()) and

View File

@@ -87,11 +87,11 @@ module TextTemplate {
FunctionOutput outp;
MethodModels() {
// signature: func (*Template).Execute(wr io.Writer, data interface{}) error
// signature: func (*Template) Execute(wr io.Writer, data interface{}) error
hasQualifiedName("text/template", "Template", "Execute") and
(inp.isParameter(1) and outp.isParameter(0))
or
// signature: func (*Template).ExecuteTemplate(wr io.Writer, name string, data interface{}) error
// signature: func (*Template) ExecuteTemplate(wr io.Writer, name string, data interface{}) error
hasQualifiedName("text/template", "Template", "ExecuteTemplate") and
(inp.isParameter(2) and outp.isParameter(0))
}

View File

@@ -1 +0,0 @@
experimental/CWE-326/InsufficientKeySize.ql

View File

@@ -0,0 +1,13 @@
edges
| DatabaseCallInLoop.go:7:2:11:2 | range statement | DatabaseCallInLoop.go:9:3:9:41 | call to First |
| test.go:10:1:12:1 | function declaration | test.go:11:2:11:13 | call to Take |
| test.go:14:1:16:1 | function declaration | test.go:15:2:15:13 | call to runQuery |
| test.go:15:2:15:13 | call to runQuery | test.go:10:1:12:1 | function declaration |
| test.go:20:2:22:2 | for statement | test.go:21:3:21:14 | call to runQuery |
| test.go:21:3:21:14 | call to runQuery | test.go:10:1:12:1 | function declaration |
| test.go:24:2:26:2 | for statement | test.go:25:3:25:17 | call to runRunQuery |
| test.go:25:3:25:17 | call to runRunQuery | test.go:14:1:16:1 | function declaration |
#select
| DatabaseCallInLoop.go:9:3:9:41 | call to First | DatabaseCallInLoop.go:7:2:11:2 | range statement | DatabaseCallInLoop.go:9:3:9:41 | call to First | $@ is called in $@ | DatabaseCallInLoop.go:9:3:9:41 | call to First | call to First | DatabaseCallInLoop.go:7:2:11:2 | range statement | a loop |
| test.go:11:2:11:13 | call to Take | test.go:20:2:22:2 | for statement | test.go:11:2:11:13 | call to Take | $@ is called in $@ | test.go:11:2:11:13 | call to Take | call to Take | test.go:20:2:22:2 | for statement | a loop |
| test.go:11:2:11:13 | call to Take | test.go:24:2:26:2 | for statement | test.go:11:2:11:13 | call to Take | $@ is called in $@ | test.go:11:2:11:13 | call to Take | call to Take | test.go:24:2:26:2 | for statement | a loop |

View File

@@ -0,0 +1,13 @@
package main
import "gorm.io/gorm"
func getUsers(db *gorm.DB, names []string) []User {
res := make([]User, 0, len(names))
for _, name := range names {
var user User
db.Where("name = ?", name).First(&user)
res = append(res, user)
}
return res
}

View File

@@ -0,0 +1 @@
experimental/CWE-400/DatabaseCallInLoop.ql

View File

@@ -0,0 +1,9 @@
package main
import "gorm.io/gorm"
func getUsersGood(db *gorm.DB, names []string) []User {
res := make([]User, 0, len(names))
db.Where("name IN ?", names).Find(&res)
return res
}

View File

@@ -0,0 +1,5 @@
module query-tests/databasecallinloop
go 1.16
require gorm.io/gorm v1.21.12

View File

@@ -0,0 +1,27 @@
package main
import "gorm.io/gorm"
type User struct {
Id int64
Name string
}
func runQuery(db *gorm.DB) {
db.Take(nil)
}
func runRunQuery(db *gorm.DB) {
runQuery(db)
}
func main() {
var db *gorm.DB
for i := 0; i < 10; i++ {
runQuery(db)
}
for i := 10; i > 0; i-- {
runRunQuery(db)
}
}

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2013-NOW Jinzhu <wosmvp@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,803 @@
// Code generated by depstubber. DO NOT EDIT.
// This is a simple stub for gorm.io/gorm, strictly for use in testing.
// See the LICENSE file for information about the licensing of the original library.
// Source: gorm.io/gorm (exports: DB; functions: )
// Package gorm is a stub of gorm.io/gorm, generated by depstubber.
package gorm
import (
context "context"
sql "database/sql"
reflect "reflect"
strings "strings"
sync "sync"
time "time"
)
type Association struct {
DB *DB
Relationship interface{}
Error error
}
func (_ *Association) Append(_ ...interface{}) error {
return nil
}
func (_ *Association) Clear() error {
return nil
}
func (_ *Association) Count() int64 {
return 0
}
func (_ *Association) Delete(_ ...interface{}) error {
return nil
}
func (_ *Association) Find(_ interface{}, _ ...interface{}) error {
return nil
}
func (_ *Association) Replace(_ ...interface{}) error {
return nil
}
type ColumnType interface {
DatabaseTypeName() string
DecimalSize() (int64, int64, bool)
Length() (int64, bool)
Name() string
Nullable() (bool, bool)
}
type Config struct {
SkipDefaultTransaction bool
NamingStrategy interface{}
FullSaveAssociations bool
Logger interface{}
NowFunc func() time.Time
DryRun bool
PrepareStmt bool
DisableAutomaticPing bool
DisableForeignKeyConstraintWhenMigrating bool
DisableNestedTransaction bool
AllowGlobalUpdate bool
QueryFields bool
CreateBatchSize int
ClauseBuilders map[string]interface{}
ConnPool ConnPool
Dialector Dialector
Plugins map[string]Plugin
}
func (_ Config) BindVarTo(_ interface{}, _ *Statement, _ interface{}) {}
func (_ Config) DataTypeOf(_ interface{}) string {
return ""
}
func (_ Config) DefaultValueOf(_ interface{}) interface{} {
return nil
}
func (_ Config) Explain(_ string, _ ...interface{}) string {
return ""
}
func (_ Config) Initialize(_ *DB) error {
return nil
}
func (_ Config) Migrator(_ *DB) Migrator {
return nil
}
func (_ Config) Name() string {
return ""
}
func (_ Config) QuoteTo(_ interface{}, _ string) {}
func (_ *Config) AfterInitialize(_ *DB) error {
return nil
}
func (_ *Config) Apply(_ *Config) error {
return nil
}
type ConnPool interface {
ExecContext(_ context.Context, _ string, _ ...interface{}) (sql.Result, error)
PrepareContext(_ context.Context, _ string) (*sql.Stmt, error)
QueryContext(_ context.Context, _ string, _ ...interface{}) (*sql.Rows, error)
QueryRowContext(_ context.Context, _ string, _ ...interface{}) *sql.Row
}
type DB struct {
Config *Config
Error error
RowsAffected int64
Statement *Statement
}
func (_ DB) AfterInitialize(_ *DB) error {
return nil
}
func (_ DB) Apply(_ *Config) error {
return nil
}
func (_ DB) BindVarTo(_ interface{}, _ *Statement, _ interface{}) {}
func (_ DB) DataTypeOf(_ interface{}) string {
return ""
}
func (_ DB) DefaultValueOf(_ interface{}) interface{} {
return nil
}
func (_ DB) Explain(_ string, _ ...interface{}) string {
return ""
}
func (_ DB) Initialize(_ *DB) error {
return nil
}
func (_ DB) Name() string {
return ""
}
func (_ DB) QuoteTo(_ interface{}, _ string) {}
func (_ *DB) AddError(_ error) error {
return nil
}
func (_ *DB) Assign(_ ...interface{}) *DB {
return nil
}
func (_ *DB) Association(_ string) *Association {
return nil
}
func (_ *DB) Attrs(_ ...interface{}) *DB {
return nil
}
func (_ *DB) AutoMigrate(_ ...interface{}) error {
return nil
}
func (_ *DB) Begin(_ ...*sql.TxOptions) *DB {
return nil
}
func (_ *DB) Callback() interface{} {
return nil
}
func (_ *DB) Clauses(_ ...interface{}) *DB {
return nil
}
func (_ *DB) Commit() *DB {
return nil
}
func (_ *DB) Count(_ *int64) *DB {
return nil
}
func (_ *DB) Create(_ interface{}) *DB {
return nil
}
func (_ *DB) CreateInBatches(_ interface{}, _ int) *DB {
return nil
}
func (_ *DB) DB() (*sql.DB, error) {
return nil, nil
}
func (_ *DB) Debug() *DB {
return nil
}
func (_ *DB) Delete(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ *DB) Distinct(_ ...interface{}) *DB {
return nil
}
func (_ *DB) Exec(_ string, _ ...interface{}) *DB {
return nil
}
func (_ *DB) Find(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ *DB) FindInBatches(_ interface{}, _ int, _ func(*DB, int) error) *DB {
return nil
}
func (_ *DB) First(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ *DB) FirstOrCreate(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ *DB) FirstOrInit(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ *DB) Get(_ string) (interface{}, bool) {
return nil, false
}
func (_ *DB) Group(_ string) *DB {
return nil
}
func (_ *DB) Having(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ *DB) InstanceGet(_ string) (interface{}, bool) {
return nil, false
}
func (_ *DB) InstanceSet(_ string, _ interface{}) *DB {
return nil
}
func (_ *DB) Joins(_ string, _ ...interface{}) *DB {
return nil
}
func (_ *DB) Last(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ *DB) Limit(_ int) *DB {
return nil
}
func (_ *DB) Migrator() Migrator {
return nil
}
func (_ *DB) Model(_ interface{}) *DB {
return nil
}
func (_ *DB) Not(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ *DB) Offset(_ int) *DB {
return nil
}
func (_ *DB) Omit(_ ...string) *DB {
return nil
}
func (_ *DB) Or(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ *DB) Order(_ interface{}) *DB {
return nil
}
func (_ *DB) Pluck(_ string, _ interface{}) *DB {
return nil
}
func (_ *DB) Preload(_ string, _ ...interface{}) *DB {
return nil
}
func (_ *DB) Raw(_ string, _ ...interface{}) *DB {
return nil
}
func (_ *DB) Rollback() *DB {
return nil
}
func (_ *DB) RollbackTo(_ string) *DB {
return nil
}
func (_ *DB) Row() *sql.Row {
return nil
}
func (_ *DB) Rows() (*sql.Rows, error) {
return nil, nil
}
func (_ *DB) Save(_ interface{}) *DB {
return nil
}
func (_ *DB) SavePoint(_ string) *DB {
return nil
}
func (_ *DB) Scan(_ interface{}) *DB {
return nil
}
func (_ *DB) ScanRows(_ *sql.Rows, _ interface{}) error {
return nil
}
func (_ *DB) Scopes(_ ...func(*DB) *DB) *DB {
return nil
}
func (_ *DB) Select(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ *DB) Session(_ *Session) *DB {
return nil
}
func (_ *DB) Set(_ string, _ interface{}) *DB {
return nil
}
func (_ *DB) SetupJoinTable(_ interface{}, _ string, _ interface{}) error {
return nil
}
func (_ *DB) Table(_ string, _ ...interface{}) *DB {
return nil
}
func (_ *DB) Take(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ *DB) Transaction(_ func(*DB) error, _ ...*sql.TxOptions) error {
return nil
}
func (_ *DB) Unscoped() *DB {
return nil
}
func (_ *DB) Update(_ string, _ interface{}) *DB {
return nil
}
func (_ *DB) UpdateColumn(_ string, _ interface{}) *DB {
return nil
}
func (_ *DB) UpdateColumns(_ interface{}) *DB {
return nil
}
func (_ *DB) Updates(_ interface{}) *DB {
return nil
}
func (_ *DB) Use(_ Plugin) error {
return nil
}
func (_ *DB) Where(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ *DB) WithContext(_ context.Context) *DB {
return nil
}
type Dialector interface {
BindVarTo(_ interface{}, _ *Statement, _ interface{})
DataTypeOf(_ interface{}) string
DefaultValueOf(_ interface{}) interface{}
Explain(_ string, _ ...interface{}) string
Initialize(_ *DB) error
Migrator(_ *DB) Migrator
Name() string
QuoteTo(_ interface{}, _ string)
}
type Migrator interface {
AddColumn(_ interface{}, _ string) error
AlterColumn(_ interface{}, _ string) error
AutoMigrate(_ ...interface{}) error
ColumnTypes(_ interface{}) ([]ColumnType, error)
CreateConstraint(_ interface{}, _ string) error
CreateIndex(_ interface{}, _ string) error
CreateTable(_ ...interface{}) error
CreateView(_ string, _ ViewOption) error
CurrentDatabase() string
DropColumn(_ interface{}, _ string) error
DropConstraint(_ interface{}, _ string) error
DropIndex(_ interface{}, _ string) error
DropTable(_ ...interface{}) error
DropView(_ string) error
FullDataTypeOf(_ interface{}) interface{}
HasColumn(_ interface{}, _ string) bool
HasConstraint(_ interface{}, _ string) bool
HasIndex(_ interface{}, _ string) bool
HasTable(_ interface{}) bool
MigrateColumn(_ interface{}, _ interface{}, _ ColumnType) error
RenameColumn(_ interface{}, _ string, _ string) error
RenameIndex(_ interface{}, _ string, _ string) error
RenameTable(_ interface{}, _ interface{}) error
}
type Plugin interface {
Initialize(_ *DB) error
Name() string
}
type Session struct {
DryRun bool
PrepareStmt bool
NewDB bool
SkipHooks bool
SkipDefaultTransaction bool
DisableNestedTransaction bool
AllowGlobalUpdate bool
FullSaveAssociations bool
QueryFields bool
Context context.Context
Logger interface{}
NowFunc func() time.Time
CreateBatchSize int
}
type Statement struct {
DB *DB
TableExpr interface{}
Table string
Model interface{}
Unscoped bool
Dest interface{}
ReflectValue reflect.Value
Clauses map[string]interface{}
BuildClauses []string
Distinct bool
Selects []string
Omits []string
Joins []interface{}
Preloads map[string][]interface{}
Settings sync.Map
ConnPool ConnPool
Schema interface{}
Context context.Context
RaiseErrorOnNotFound bool
SkipHooks bool
SQL strings.Builder
Vars []interface{}
CurDestIndex int
}
func (_ Statement) AddError(_ error) error {
return nil
}
func (_ Statement) AfterInitialize(_ *DB) error {
return nil
}
func (_ Statement) Apply(_ *Config) error {
return nil
}
func (_ Statement) Assign(_ ...interface{}) *DB {
return nil
}
func (_ Statement) Association(_ string) *Association {
return nil
}
func (_ Statement) Attrs(_ ...interface{}) *DB {
return nil
}
func (_ Statement) AutoMigrate(_ ...interface{}) error {
return nil
}
func (_ Statement) Begin(_ ...*sql.TxOptions) *DB {
return nil
}
func (_ Statement) BindVarTo(_ interface{}, _ *Statement, _ interface{}) {}
func (_ Statement) Callback() interface{} {
return nil
}
func (_ Statement) Commit() *DB {
return nil
}
func (_ Statement) Count(_ *int64) *DB {
return nil
}
func (_ Statement) Create(_ interface{}) *DB {
return nil
}
func (_ Statement) CreateInBatches(_ interface{}, _ int) *DB {
return nil
}
func (_ Statement) DataTypeOf(_ interface{}) string {
return ""
}
func (_ Statement) Debug() *DB {
return nil
}
func (_ Statement) DefaultValueOf(_ interface{}) interface{} {
return nil
}
func (_ Statement) Delete(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ Statement) Exec(_ string, _ ...interface{}) *DB {
return nil
}
func (_ Statement) Explain(_ string, _ ...interface{}) string {
return ""
}
func (_ Statement) Find(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ Statement) FindInBatches(_ interface{}, _ int, _ func(*DB, int) error) *DB {
return nil
}
func (_ Statement) First(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ Statement) FirstOrCreate(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ Statement) FirstOrInit(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ Statement) Get(_ string) (interface{}, bool) {
return nil, false
}
func (_ Statement) Group(_ string) *DB {
return nil
}
func (_ Statement) Having(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ Statement) Initialize(_ *DB) error {
return nil
}
func (_ Statement) InstanceGet(_ string) (interface{}, bool) {
return nil, false
}
func (_ Statement) InstanceSet(_ string, _ interface{}) *DB {
return nil
}
func (_ Statement) Last(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ Statement) Limit(_ int) *DB {
return nil
}
func (_ Statement) Migrator() Migrator {
return nil
}
func (_ Statement) Name() string {
return ""
}
func (_ Statement) Not(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ Statement) Offset(_ int) *DB {
return nil
}
func (_ Statement) Omit(_ ...string) *DB {
return nil
}
func (_ Statement) Or(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ Statement) Order(_ interface{}) *DB {
return nil
}
func (_ Statement) Pluck(_ string, _ interface{}) *DB {
return nil
}
func (_ Statement) Preload(_ string, _ ...interface{}) *DB {
return nil
}
func (_ Statement) Raw(_ string, _ ...interface{}) *DB {
return nil
}
func (_ Statement) Rollback() *DB {
return nil
}
func (_ Statement) RollbackTo(_ string) *DB {
return nil
}
func (_ Statement) Row() *sql.Row {
return nil
}
func (_ Statement) Rows() (*sql.Rows, error) {
return nil, nil
}
func (_ Statement) Save(_ interface{}) *DB {
return nil
}
func (_ Statement) SavePoint(_ string) *DB {
return nil
}
func (_ Statement) Scan(_ interface{}) *DB {
return nil
}
func (_ Statement) ScanRows(_ *sql.Rows, _ interface{}) error {
return nil
}
func (_ Statement) Scopes(_ ...func(*DB) *DB) *DB {
return nil
}
func (_ Statement) Select(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ Statement) Session(_ *Session) *DB {
return nil
}
func (_ Statement) Set(_ string, _ interface{}) *DB {
return nil
}
func (_ Statement) SetupJoinTable(_ interface{}, _ string, _ interface{}) error {
return nil
}
func (_ Statement) Take(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ Statement) Transaction(_ func(*DB) error, _ ...*sql.TxOptions) error {
return nil
}
func (_ Statement) Update(_ string, _ interface{}) *DB {
return nil
}
func (_ Statement) UpdateColumn(_ string, _ interface{}) *DB {
return nil
}
func (_ Statement) UpdateColumns(_ interface{}) *DB {
return nil
}
func (_ Statement) Updates(_ interface{}) *DB {
return nil
}
func (_ Statement) Use(_ Plugin) error {
return nil
}
func (_ Statement) Where(_ interface{}, _ ...interface{}) *DB {
return nil
}
func (_ Statement) WithContext(_ context.Context) *DB {
return nil
}
func (_ *Statement) AddClause(_ interface{}) {}
func (_ *Statement) AddClauseIfNotExists(_ interface{}) {}
func (_ *Statement) AddVar(_ interface{}, _ ...interface{}) {}
func (_ *Statement) Build(_ ...string) {}
func (_ *Statement) BuildCondition(_ interface{}, _ ...interface{}) []interface{} {
return nil
}
func (_ *Statement) Changed(_ ...string) bool {
return false
}
func (_ *Statement) Parse(_ interface{}) error {
return nil
}
func (_ *Statement) Quote(_ interface{}) string {
return ""
}
func (_ *Statement) QuoteTo(_ interface{}, _ interface{}) {}
func (_ *Statement) SelectAndOmitColumns(_ bool, _ bool) (map[string]bool, bool) {
return nil, false
}
func (_ *Statement) SetColumn(_ string, _ interface{}, _ ...bool) {}
func (_ *Statement) WriteByte(_ byte) error {
return nil
}
func (_ *Statement) WriteQuoted(_ interface{}) {}
func (_ *Statement) WriteString(_ string) (int, error) {
return 0, nil
}
type ViewOption struct {
Replace bool
CheckOption string
Query *DB
}

View File

@@ -0,0 +1,3 @@
# gorm.io/gorm v1.21.12
## explicit
gorm.io/gorm

View File

@@ -0,0 +1,6 @@
| DeferInLoop.go:8:3:8:20 | defer statement | This defer statement is in a $@. | DeferInLoop.go:6:2:13:2 | range statement | loop |
| test.go:6:3:6:14 | defer statement | This defer statement is in a $@. | test.go:5:2:7:2 | range statement | loop |
| test.go:11:4:11:15 | defer statement | This defer statement is in a $@. | test.go:9:2:13:2 | range statement | loop |
| test.go:16:3:16:14 | defer statement | This defer statement is in a $@. | test.go:15:2:17:2 | for statement | loop |
| test.go:20:3:20:14 | defer statement | This defer statement is in a $@. | test.go:19:2:21:2 | for statement | loop |
| test.go:24:3:24:14 | defer statement | This defer statement is in a $@. | test.go:23:2:25:2 | for statement | loop |

View File

@@ -0,0 +1,14 @@
package main
import "os"
func openFiles(filenames []string) {
for _, filename := range filenames {
file, err := os.Open(filename)
defer file.Close()
if err != nil {
// handle error
}
// work on file
}
}

View File

@@ -0,0 +1 @@
experimental/InconsistentCode/DeferInLoop.ql

View File

@@ -0,0 +1,18 @@
package main
import "os"
func openFile(filename string) {
file, err := os.Open(filename)
defer file.Close()
if err != nil {
// handle error
}
// work on file
}
func openFilesGood(filenames []string) {
for _, filename := range filenames {
openFile(filename)
}
}

Some files were not shown because too many files have changed in this diff Show More