Port test to inline expectations test

This commit is contained in:
Ed Minnix
2024-08-19 12:44:30 -04:00
parent 704cd8aee3
commit 5e8185ac4f
3 changed files with 23 additions and 9 deletions

View File

@@ -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

View File

@@ -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
}

View File

@@ -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>