mirror of
https://github.com/github/codeql.git
synced 2026-01-29 14:23:03 +01:00
Add go.mod expression tests
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
| pkg1/go.mod:10:1:10:44 | go.mod exclude line | module | github.com/github/codeql-go | v1.23.1 |
|
||||
| pkg2/go.mod:14:2:14:35 | go.mod exclude line | module | github.com/sirupsen/logrus | v1.4.2 |
|
||||
| pkg2/go.mod:15:2:15:37 | go.mod exclude line | module | github.com/github/codeql-go | v1.23.1 |
|
||||
@@ -0,0 +1,5 @@
|
||||
import go
|
||||
|
||||
from GoModExcludeLine excl, GoModModuleLine mod
|
||||
where excl.getFile() = mod.getFile()
|
||||
select excl, mod.getPath(), excl.getPath(), excl.getVer()
|
||||
11
ql/test/library-tests/semmle/go/GoModExpr/ReplaceLines.ql
Normal file
11
ql/test/library-tests/semmle/go/GoModExpr/ReplaceLines.ql
Normal file
@@ -0,0 +1,11 @@
|
||||
import go
|
||||
|
||||
from GoModReplaceLine repl, GoModModuleLine mod, string repVer
|
||||
where
|
||||
repl.getFile() = mod.getFile() and
|
||||
(
|
||||
repVer = repl.getReplacementVer() or
|
||||
repVer = "no version"
|
||||
)
|
||||
select repl, mod.getPath(), repl.getOriginalPath(), repl.getReplacementPath(),
|
||||
repl.getReplacementVer()
|
||||
@@ -0,0 +1,5 @@
|
||||
| pkg1/go.mod:6:2:6:67 | go.mod require line | module | github.com/github/codeql-go | v1.23.2-0.20200302182241-5e71a04fdf30 |
|
||||
| pkg1/go.mod:7:2:7:55 | go.mod require line | module | golang.org/x/tools | v0.0.0-20200109174759-ac4f524c1612 |
|
||||
| pkg2/go.mod:7:1:7:38 | go.mod require line | module | github.com/gorilla/mux | v1.7.4 |
|
||||
| pkg2/go.mod:9:2:9:35 | go.mod require line | module | github.com/sirupsen/logrus | v1.4.1 |
|
||||
| pkg2/go.mod:10:2:10:40 | go.mod require line | module | github.com/Masterminds/squirrel | v1.2.0 |
|
||||
@@ -0,0 +1,5 @@
|
||||
import go
|
||||
|
||||
from GoModRequireLine req, GoModModuleLine mod
|
||||
where req.getFile() = mod.getFile()
|
||||
select req, mod.getPath(), req.getPath(), req.getVer()
|
||||
10
ql/test/library-tests/semmle/go/GoModExpr/pkg1/go.mod
Normal file
10
ql/test/library-tests/semmle/go/GoModExpr/pkg1/go.mod
Normal file
@@ -0,0 +1,10 @@
|
||||
module codeql-go-tests/gomod/dep1
|
||||
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/github/codeql-go v1.23.2-0.20200302182241-5e71a04fdf30
|
||||
golang.org/x/tools v0.0.0-20200109174759-ac4f524c1612
|
||||
)
|
||||
|
||||
exclude github.com/github/codeql-go v1.23.1
|
||||
16
ql/test/library-tests/semmle/go/GoModExpr/pkg1/pkg1.go
Normal file
16
ql/test/library-tests/semmle/go/GoModExpr/pkg1/pkg1.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package pkg1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/github/codeql-go/extractor/dbscheme"
|
||||
"github.com/github/codeql-go/extractor/trap"
|
||||
"golang.org/x/tools/go/packages"
|
||||
)
|
||||
|
||||
func usePkgs() {
|
||||
fmt.Println(packages.NeedImports)
|
||||
fmt.Println(dbscheme.LabelObjectType.Index())
|
||||
var lbl trap.Label
|
||||
fmt.Println(lbl)
|
||||
}
|
||||
16
ql/test/library-tests/semmle/go/GoModExpr/pkg2/go.mod
Normal file
16
ql/test/library-tests/semmle/go/GoModExpr/pkg2/go.mod
Normal file
@@ -0,0 +1,16 @@
|
||||
module codeql-go-tests/gomod/dep2
|
||||
|
||||
go 1.14
|
||||
|
||||
replace github.com/Masterminds/squirrel => ../squirrel
|
||||
|
||||
require github.com/gorilla/mux v1.7.4
|
||||
require (
|
||||
github.com/sirupsen/logrus v1.4.1
|
||||
github.com/Masterminds/squirrel v1.2.0
|
||||
)
|
||||
|
||||
exclude (
|
||||
github.com/sirupsen/logrus v1.4.2
|
||||
github.com/github/codeql-go v1.23.1
|
||||
)
|
||||
13
ql/test/library-tests/semmle/go/GoModExpr/pkg2/pkg2.go
Normal file
13
ql/test/library-tests/semmle/go/GoModExpr/pkg2/pkg2.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package pkg2
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func useDeps() {
|
||||
|
||||
}
|
||||
23
ql/test/library-tests/semmle/go/GoModExpr/squirrel/LICENSE
Normal file
23
ql/test/library-tests/semmle/go/GoModExpr/squirrel/LICENSE
Normal file
@@ -0,0 +1,23 @@
|
||||
Squirrel
|
||||
The Masterminds
|
||||
Copyright (C) 2014-2015, Lann Martin
|
||||
Copyright (C) 2015-2016, Google
|
||||
Copyright (C) 2015, Matt Farina and Matt Butcher
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,3 @@
|
||||
This is a simple stub for https://github.com/Masterminds/squirrel, strictly for use in query testing.
|
||||
|
||||
See the LICENSE file in this folder for information about the licensing of the original library.
|
||||
@@ -0,0 +1,3 @@
|
||||
module github.com/github/codeql-go/ql/test/library-tests/semmle/go/GoModExpr/squirrel
|
||||
|
||||
go 1.14
|
||||
@@ -0,0 +1,24 @@
|
||||
package squirrel
|
||||
|
||||
type StatementBuilderType struct{}
|
||||
|
||||
func Expr(e string, args ...interface{}) string {
|
||||
return Expr(e, args...)
|
||||
}
|
||||
|
||||
var StatementBuilder = &StatementBuilderType{}
|
||||
|
||||
func (b *StatementBuilderType) Insert(table string) *StatementBuilderType {
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *StatementBuilderType) Columns(columns ...string) *StatementBuilderType {
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *StatementBuilderType) Values(strings ...string) *StatementBuilderType {
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *StatementBuilderType) Exec() {
|
||||
}
|
||||
Reference in New Issue
Block a user