Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go: Add common tests for database source model PRs #18401

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package test

func sink(x ...any) {}

func ignore(...any) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
testFailures
invalidModelRow
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extensions:
- addsTo:
pack: codeql/threat-models
extensible: threatModelConfiguration
data:
- ["database", true, 0]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import go

Check failure on line 1 in go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/database/source.ql

View workflow job for this annotation

GitHub Actions / Test Linux (Ubuntu)

[312/579 comp 8.5s eval 279ms] FAILED(RESULT) /home/runner/work/codeql/codeql/go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/database/source.ql
import ModelValidation
import utils.test.InlineExpectationsTest

module SourceTest implements TestSig {
string getARelevantTag() { result = "source" }

predicate hasActualResult(Location location, string element, string tag, string value) {
exists(ActiveThreatModelSource 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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
testFailures
invalidModelRow
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extensions:

- addsTo:
pack: codeql/threat-models
extensible: threatModelConfiguration
data:
- ["database", true, 0]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import go

Check failure on line 1 in go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/database/test.ql

View workflow job for this annotation

GitHub Actions / Test Linux (Ubuntu)

[311/579 comp 24.5s eval 241ms] FAILED(RESULT) /home/runner/work/codeql/codeql/go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/database/test.ql
import semmle.go.dataflow.ExternalFlow
import ModelValidation
import experimental.frameworks.CleverGo
import utils.test.InlineFlowTest

module Config implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { source instanceof ActiveThreatModelSource }

predicate isSink(DataFlow::Node sink) {
sink.asExpr() = any(CallExpr c | c.getTarget().getName() = "sink").getAnArgument()
}
}

import TaintFlowTest<Config>
Loading