mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
Port test to inline expectations test
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
| test.go:6:2:6:33 | ... := ...[0] |
|
||||
| test.go:15:2:15:51 | ... := ...[0] |
|
||||
| test.go:24:2:24:37 | ... := ...[0] |
|
||||
testFailures
|
||||
invalidModelRow
|
||||
failures
|
||||
|
||||
@@ -3,7 +3,7 @@ package test
|
||||
import "os"
|
||||
|
||||
func open() {
|
||||
file, err := os.Open("file.txt")
|
||||
file, err := os.Open("file.txt") // $ source
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -12,7 +12,7 @@ func open() {
|
||||
}
|
||||
|
||||
func openFile() {
|
||||
file, err := os.OpenFile("file.txt", os.O_RDWR, 0)
|
||||
file, err := os.OpenFile("file.txt", os.O_RDWR, 0) // $source
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -21,7 +21,7 @@ func openFile() {
|
||||
}
|
||||
|
||||
func readFile() {
|
||||
data, err := os.ReadFile("file.txt")
|
||||
data, err := os.ReadFile("file.txt") // $source
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
import go
|
||||
import ModelValidation
|
||||
import TestUtilities.InlineExpectationsTest
|
||||
|
||||
from DataFlow::Node source
|
||||
where source instanceof ThreatModelFlowSource
|
||||
select source
|
||||
module SourceTest implements TestSig {
|
||||
string getARelevantTag() { result = "source" }
|
||||
|
||||
predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
exists(ThreatModelFlowSource s |
|
||||
s.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
|
||||
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
|
||||
element = s.toString() and
|
||||
value = "" and
|
||||
tag = "source"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
import MakeTest<SourceTest>
|
||||
|
||||
Reference in New Issue
Block a user