Add integration tests

This commit is contained in:
Owen Mansel-Chan
2023-06-20 17:02:00 +01:00
parent f8b1dc9f59
commit 6eda207997
44 changed files with 333 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
{
"markdownMessage": "1 package could not be found:\n\n`subdir/subsubdir`.\n\nDefinitions in those packages may not be recognized by CodeQL, and files that use them may only be partially analyzed.\n\nCheck that the paths are correct and make sure any private packages can be accessed. If any of the packages are present in the repository then you may need a [custom build command](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages).",
"severity": "warning",
"source": {
"extractorName": "go",
"id": "go/autobuilder/package-not-found",
"name": "Some packages could not be found"
},
"visibility": {
"cliSummaryTable": true,
"statusPage": true,
"telemetry": true
}
}

View File

@@ -0,0 +1,5 @@
go 1.14
require golang.org/x/net v0.0.0-20200505041828-1ed23360d12c
module subdir

View File

@@ -0,0 +1,7 @@
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20200505041828-1ed23360d12c h1:zJ0mtu4jCalhKg6Oaukv6iIkb+cOvDrajDH9DH46Q4M=
golang.org/x/net v0.0.0-20200505041828-1ed23360d12c/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

View File

@@ -0,0 +1,5 @@
package subsubdir
func Add(a, b int) int {
return a + b
}

View File

@@ -0,0 +1,14 @@
package subdir
import (
"subdir/subsubdir"
"golang.org/x/net/ipv4"
)
func test() {
header := ipv4.Header{}
header.Version = subsubdir.Add(2, 2)
}

View File

@@ -0,0 +1,2 @@
| Extraction failed in subdir/test.go with error cannot find package "subdir/subsubdir" in any of:\n\t/usr/local/Cellar/go/1.20.5/libexec/src/subdir/subsubdir (from $GOROOT)\n\t/Users/owen-mc/go/src/subdir/subsubdir (from $GOPATH) | 2 |
| Extraction failed in subdir/test.go with error could not import subdir/subsubdir (invalid package name: "") | 2 |

View File

@@ -0,0 +1,8 @@
import sys
from create_database_utils import *
from diagnostics_test_utils import *
run_codeql_database_create([], lang="go")
check_diagnostics()

View File

@@ -0,0 +1,6 @@
import go
import semmle.go.DiagnosticsReporting
from string msg, int sev
where reportableDiagnostics(_, msg, sev)
select msg, sev

View File

@@ -0,0 +1,14 @@
{
"markdownMessage": "2 packages could not be found:\n\n`subdir1/subsubdir1`, `subdir2/subsubdir2`.\n\nDefinitions in those packages may not be recognized by CodeQL, and files that use them may only be partially analyzed.\n\nCheck that the paths are correct and make sure any private packages can be accessed. If any of the packages are present in the repository then you may need a [custom build command](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages).",
"severity": "warning",
"source": {
"extractorName": "go",
"id": "go/autobuilder/package-not-found",
"name": "Some packages could not be found"
},
"visibility": {
"cliSummaryTable": true,
"statusPage": true,
"telemetry": true
}
}

View File

@@ -0,0 +1,6 @@
go 1.19
use (
./subdir1
./subdir2
)

View File

@@ -0,0 +1,5 @@
go 1.14
require golang.org/x/net v0.0.0-20200505041828-1ed23360d12c
module subdir1

View File

@@ -0,0 +1,7 @@
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20200505041828-1ed23360d12c h1:zJ0mtu4jCalhKg6Oaukv6iIkb+cOvDrajDH9DH46Q4M=
golang.org/x/net v0.0.0-20200505041828-1ed23360d12c/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

View File

@@ -0,0 +1,5 @@
package subsubdir1
func Add(a, b int) int {
return a + b
}

View File

@@ -0,0 +1,14 @@
package subdir
import (
"subdir1/subsubdir1"
"golang.org/x/net/ipv4"
)
func test() {
header := ipv4.Header{}
header.Version = subsubdir1.Add(2, 2)
}

View File

@@ -0,0 +1,5 @@
go 1.14
require golang.org/x/net v0.0.0-20200505041828-1ed23360d12c
module subdir2

View File

@@ -0,0 +1,7 @@
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20200505041828-1ed23360d12c h1:zJ0mtu4jCalhKg6Oaukv6iIkb+cOvDrajDH9DH46Q4M=
golang.org/x/net v0.0.0-20200505041828-1ed23360d12c/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

View File

@@ -0,0 +1,5 @@
package subsubdir2
func Add(a, b int) int {
return a + b
}

View File

@@ -0,0 +1,14 @@
package subdir
import (
"subdir2/subsubdir2"
"golang.org/x/net/ipv4"
)
func test() {
header := ipv4.Header{}
header.Version = subsubdir2.Add(2, 2)
}

View File

@@ -0,0 +1,4 @@
| Extraction failed in modules/subdir1/test.go with error cannot find package "subdir1/subsubdir1" in any of:\n\t/usr/local/Cellar/go/1.20.5/libexec/src/subdir1/subsubdir1 (from $GOROOT)\n\t/Users/owen-mc/go/src/subdir1/subsubdir1 (from $GOPATH) | 2 |
| Extraction failed in modules/subdir1/test.go with error could not import subdir1/subsubdir1 (invalid package name: "") | 2 |
| Extraction failed in modules/subdir2/test.go with error cannot find package "subdir2/subsubdir2" in any of:\n\t/usr/local/Cellar/go/1.20.5/libexec/src/subdir2/subsubdir2 (from $GOROOT)\n\t/Users/owen-mc/go/src/subdir2/subsubdir2 (from $GOPATH) | 2 |
| Extraction failed in modules/subdir2/test.go with error could not import subdir2/subsubdir2 (invalid package name: "") | 2 |

View File

@@ -0,0 +1,8 @@
import sys
from create_database_utils import *
from diagnostics_test_utils import *
run_codeql_database_create([], lang="go")
check_diagnostics()

View File

@@ -0,0 +1,6 @@
import go
import semmle.go.DiagnosticsReporting
from string msg, int sev
where reportableDiagnostics(_, msg, sev)
select msg, sev

View File

@@ -0,0 +1,14 @@
{
"markdownMessage": "2 packages could not be found:\n\n`subdir1/subsubdir1`, `subdir2/subsubdir2`.\n\nDefinitions in those packages may not be recognized by CodeQL, and files that use them may only be partially analyzed.\n\nCheck that the paths are correct and make sure any private packages can be accessed. If any of the packages are present in the repository then you may need a [custom build command](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages).",
"severity": "warning",
"source": {
"extractorName": "go",
"id": "go/autobuilder/package-not-found",
"name": "Some packages could not be found"
},
"visibility": {
"cliSummaryTable": true,
"statusPage": true,
"telemetry": true
}
}

View File

@@ -0,0 +1,5 @@
go 1.14
require golang.org/x/net v0.0.0-20200505041828-1ed23360d12c
module subdir1

View File

@@ -0,0 +1,7 @@
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20200505041828-1ed23360d12c h1:zJ0mtu4jCalhKg6Oaukv6iIkb+cOvDrajDH9DH46Q4M=
golang.org/x/net v0.0.0-20200505041828-1ed23360d12c/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

View File

@@ -0,0 +1,5 @@
package subsubdir1
func Add(a, b int) int {
return a + b
}

View File

@@ -0,0 +1,14 @@
package subdir
import (
"subdir1/subsubdir1"
"golang.org/x/net/ipv4"
)
func test() {
header := ipv4.Header{}
header.Version = subsubdir1.Add(2, 2)
}

View File

@@ -0,0 +1,5 @@
go 1.14
require golang.org/x/net v0.0.0-20200505041828-1ed23360d12c
module subdir2

View File

@@ -0,0 +1,7 @@
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20200505041828-1ed23360d12c h1:zJ0mtu4jCalhKg6Oaukv6iIkb+cOvDrajDH9DH46Q4M=
golang.org/x/net v0.0.0-20200505041828-1ed23360d12c/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

View File

@@ -0,0 +1,5 @@
package subsubdir2
func Add(a, b int) int {
return a + b
}

View File

@@ -0,0 +1,14 @@
package subdir
import (
"subdir2/subsubdir2"
"golang.org/x/net/ipv4"
)
func test() {
header := ipv4.Header{}
header.Version = subsubdir2.Add(2, 2)
}

View File

@@ -0,0 +1,4 @@
| Extraction failed in subdir1/test.go with error cannot find package "subdir1/subsubdir1" in any of:\n\t/usr/local/Cellar/go/1.20.5/libexec/src/subdir1/subsubdir1 (from $GOROOT)\n\t/Users/owen-mc/go/src/subdir1/subsubdir1 (from $GOPATH) | 2 |
| Extraction failed in subdir1/test.go with error could not import subdir1/subsubdir1 (invalid package name: "") | 2 |
| Extraction failed in subdir2/test.go with error cannot find package "subdir2/subsubdir2" in any of:\n\t/usr/local/Cellar/go/1.20.5/libexec/src/subdir2/subsubdir2 (from $GOROOT)\n\t/Users/owen-mc/go/src/subdir2/subsubdir2 (from $GOPATH) | 2 |
| Extraction failed in subdir2/test.go with error could not import subdir2/subsubdir2 (invalid package name: "") | 2 |

View File

@@ -0,0 +1,8 @@
import sys
from create_database_utils import *
from diagnostics_test_utils import *
run_codeql_database_create([], lang="go")
check_diagnostics()

View File

@@ -0,0 +1,6 @@
import go
import semmle.go.DiagnosticsReporting
from string msg, int sev
where reportableDiagnostics(_, msg, sev)
select msg, sev

View File

@@ -0,0 +1,5 @@
go 1.14
require golang.org/x/net v0.0.0-20200505041828-1ed23360d12c
module test

View File

@@ -0,0 +1,7 @@
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20200505041828-1ed23360d12c h1:zJ0mtu4jCalhKg6Oaukv6iIkb+cOvDrajDH9DH46Q4M=
golang.org/x/net v0.0.0-20200505041828-1ed23360d12c/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

View File

@@ -0,0 +1,5 @@
go 1.14
require golang.org/x/net v0.0.0-20200505041828-1ed23360d12c
module subdir1

View File

@@ -0,0 +1,7 @@
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20200505041828-1ed23360d12c h1:zJ0mtu4jCalhKg6Oaukv6iIkb+cOvDrajDH9DH46Q4M=
golang.org/x/net v0.0.0-20200505041828-1ed23360d12c/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

View File

@@ -0,0 +1,5 @@
package subsubdir1
func Add(a, b int) int {
return a + b
}

View File

@@ -0,0 +1,14 @@
package subdir
import (
"subdir1/subsubdir1"
"golang.org/x/net/ipv4"
)
func test() {
header := ipv4.Header{}
header.Version = subsubdir1.Add(2, 2)
}

View File

@@ -0,0 +1,5 @@
package subdir2
func Add(a, b int) int {
return a + b
}

View File

@@ -0,0 +1,2 @@
| Extraction failed in test.go with error could not import subdir2 (invalid package name: "") | 2 |
| Extraction failed in test.go with error package subdir2 is not in GOROOT (/usr/local/Cellar/go/1.20.5/libexec/src/subdir2) | 2 |

View File

@@ -0,0 +1,14 @@
package test
import (
"subdir2"
"golang.org/x/net/ipv4"
)
func test() {
header := ipv4.Header{}
header.Version = subdir2.Add(2, 2)
}

View File

@@ -0,0 +1,8 @@
import sys
from create_database_utils import *
from diagnostics_test_utils import *
run_codeql_database_create([], lang="go")
check_diagnostics()

View File

@@ -0,0 +1,6 @@
import go
import semmle.go.DiagnosticsReporting
from string msg, int sev
where reportableDiagnostics(_, msg, sev)
select msg, sev