-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
77,187 additions
and
0 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
go/ql/test/library-tests/semmle/go/controlflow/ControlFlowGraph2/CFG.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
edges | ||
| tst.go:0:0:0:0 | entry | tst.go:3:1:3:12 | skip | | ||
| tst.go:3:1:3:12 | skip | tst.go:5:1:7:1 | skip | | ||
| tst.go:5:1:7:1 | skip | tst.go:9:1:11:1 | skip | | ||
| tst.go:9:1:11:1 | skip | tst.go:13:15:13:20 | skip | | ||
| tst.go:13:1:13:1 | entry | tst.go:13:7:13:7 | argument corresponding to r | | ||
| tst.go:13:1:15:1 | function declaration | tst.go:17:6:17:12 | skip | | ||
| tst.go:13:7:13:7 | argument corresponding to r | tst.go:13:7:13:7 | initialization of r | | ||
| tst.go:13:7:13:7 | initialization of r | tst.go:14:9:14:9 | r | | ||
| tst.go:13:15:13:20 | skip | tst.go:13:1:15:1 | function declaration | | ||
| tst.go:14:2:14:14 | return statement | tst.go:15:1:15:1 | exit | | ||
| tst.go:14:9:14:9 | implicit dereference | tst.go:14:9:14:14 | selection of data | | ||
| tst.go:14:9:14:9 | implicit dereference | tst.go:15:1:15:1 | exit | | ||
| tst.go:14:9:14:9 | r | tst.go:14:9:14:9 | implicit dereference | | ||
| tst.go:14:9:14:14 | selection of data | tst.go:14:2:14:14 | return statement | | ||
| tst.go:17:1:17:1 | entry | tst.go:17:14:17:19 | argument corresponding to source | | ||
| tst.go:17:1:19:1 | function declaration | tst.go:21:6:21:12 | skip | | ||
| tst.go:17:6:17:12 | skip | tst.go:17:1:19:1 | function declaration | | ||
| tst.go:17:14:17:19 | argument corresponding to source | tst.go:17:14:17:19 | initialization of source | | ||
| tst.go:17:14:17:19 | initialization of source | tst.go:18:10:18:26 | struct literal | | ||
| tst.go:18:2:18:26 | return statement | tst.go:19:1:19:1 | exit | | ||
| tst.go:18:9:18:26 | &... | tst.go:18:2:18:26 | return statement | | ||
| tst.go:18:10:18:26 | struct literal | tst.go:18:20:18:25 | source | | ||
| tst.go:18:14:18:25 | init of key-value pair | tst.go:18:9:18:26 | &... | | ||
| tst.go:18:20:18:25 | source | tst.go:18:14:18:25 | init of key-value pair | | ||
| tst.go:21:1:21:1 | entry | tst.go:21:14:21:19 | argument corresponding to source | | ||
| tst.go:21:1:28:1 | function declaration | tst.go:30:6:30:9 | skip | | ||
| tst.go:21:6:21:12 | skip | tst.go:21:1:28:1 | function declaration | | ||
| tst.go:21:14:21:19 | argument corresponding to source | tst.go:21:14:21:19 | initialization of source | | ||
| tst.go:21:14:21:19 | initialization of source | tst.go:22:2:22:2 | skip | | ||
| tst.go:22:2:22:2 | assignment to r | tst.go:23:9:23:12 | skip | | ||
| tst.go:22:2:22:2 | skip | tst.go:22:7:22:13 | getData | | ||
| tst.go:22:7:22:13 | getData | tst.go:22:15:22:20 | source | | ||
| tst.go:22:7:22:21 | call to getData | tst.go:22:2:22:2 | assignment to r | | ||
| tst.go:22:7:22:21 | call to getData | tst.go:28:1:28:1 | exit | | ||
| tst.go:22:15:22:20 | source | tst.go:22:7:22:21 | call to getData | | ||
| tst.go:23:9:23:12 | assignment to data | tst.go:24:7:24:10 | case star expression | | ||
| tst.go:23:9:23:12 | assignment to data | tst.go:27:9:27:10 | "" | | ||
| tst.go:23:9:23:12 | skip | tst.go:23:17:23:17 | r | | ||
| tst.go:23:17:23:17 | r | tst.go:23:17:23:24 | type assertion | | ||
| tst.go:23:17:23:24 | type assertion | tst.go:23:9:23:12 | assignment to data | | ||
| tst.go:24:7:24:10 | case star expression | tst.go:25:10:25:13 | data | | ||
| tst.go:24:7:24:10 | case star expression | tst.go:27:9:27:10 | "" | | ||
| tst.go:25:3:25:22 | return statement | tst.go:28:1:28:1 | exit | | ||
| tst.go:25:10:25:13 | data | tst.go:25:10:25:20 | selection of String | | ||
| tst.go:25:10:25:20 | selection of String | tst.go:25:10:25:22 | call to String | | ||
| tst.go:25:10:25:22 | call to String | tst.go:25:3:25:22 | return statement | | ||
| tst.go:25:10:25:22 | call to String | tst.go:28:1:28:1 | exit | | ||
| tst.go:27:2:27:10 | return statement | tst.go:28:1:28:1 | exit | | ||
| tst.go:27:9:27:10 | "" | tst.go:27:2:27:10 | return statement | | ||
| tst.go:30:1:30:1 | entry | tst.go:31:2:31:10 | skip | | ||
| tst.go:30:1:34:1 | function declaration | tst.go:0:0:0:0 | exit | | ||
| tst.go:30:6:30:9 | skip | tst.go:30:1:34:1 | function declaration | | ||
| tst.go:31:2:31:10 | assignment to sourceStr | tst.go:32:2:32:8 | skip | | ||
| tst.go:31:2:31:10 | skip | tst.go:31:15:31:28 | "Hellow rold!" | | ||
| tst.go:31:15:31:28 | "Hellow rold!" | tst.go:31:2:31:10 | assignment to sourceStr | | ||
| tst.go:32:2:32:8 | assignment to sinkStr | tst.go:33:2:33:12 | selection of Println | | ||
| tst.go:32:2:32:8 | skip | tst.go:32:13:32:19 | process | | ||
| tst.go:32:13:32:19 | process | tst.go:32:21:32:29 | sourceStr | | ||
| tst.go:32:13:32:30 | call to process | tst.go:32:2:32:8 | assignment to sinkStr | | ||
| tst.go:32:13:32:30 | call to process | tst.go:34:1:34:1 | exit | | ||
| tst.go:32:21:32:29 | sourceStr | tst.go:32:13:32:30 | call to process | | ||
| tst.go:33:2:33:12 | selection of Println | tst.go:33:14:33:20 | sinkStr | | ||
| tst.go:33:2:33:21 | call to Println | tst.go:34:1:34:1 | exit | | ||
| tst.go:33:14:33:20 | sinkStr | tst.go:33:2:33:21 | call to Println | | ||
#select | ||
| | |
9 changes: 9 additions & 0 deletions
9
go/ql/test/library-tests/semmle/go/controlflow/ControlFlowGraph2/CFG.ql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import go | ||
Check failure on line 1 in go/ql/test/library-tests/semmle/go/controlflow/ControlFlowGraph2/CFG.ql GitHub Actions / Test Linux (Ubuntu)
|
||
|
||
query predicate edges(ControlFlow::Node pred, ControlFlow::Node succ) { | ||
not succ.getFile().hasBuildConstraints() and | ||
not pred.getFile().hasBuildConstraints() and | ||
succ = pred.getASuccessor() | ||
} | ||
|
||
select "" |
64 changes: 64 additions & 0 deletions
64
...rary-tests/semmle/go/controlflow/ControlFlowGraph2/ControlFlowNode_getASuccessor.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
| tst.go:0:0:0:0 | entry | tst.go:3:1:3:12 | skip | | ||
| tst.go:3:1:3:12 | skip | tst.go:5:1:7:1 | skip | | ||
| tst.go:5:1:7:1 | skip | tst.go:9:1:11:1 | skip | | ||
| tst.go:9:1:11:1 | skip | tst.go:13:15:13:20 | skip | | ||
| tst.go:13:1:13:1 | entry | tst.go:13:7:13:7 | argument corresponding to r | | ||
| tst.go:13:1:15:1 | function declaration | tst.go:17:6:17:12 | skip | | ||
| tst.go:13:7:13:7 | argument corresponding to r | tst.go:13:7:13:7 | initialization of r | | ||
| tst.go:13:7:13:7 | initialization of r | tst.go:14:9:14:9 | r | | ||
| tst.go:13:15:13:20 | skip | tst.go:13:1:15:1 | function declaration | | ||
| tst.go:14:2:14:14 | return statement | tst.go:15:1:15:1 | exit | | ||
| tst.go:14:9:14:9 | implicit dereference | tst.go:14:9:14:14 | selection of data | | ||
| tst.go:14:9:14:9 | implicit dereference | tst.go:15:1:15:1 | exit | | ||
| tst.go:14:9:14:9 | r | tst.go:14:9:14:9 | implicit dereference | | ||
| tst.go:14:9:14:14 | selection of data | tst.go:14:2:14:14 | return statement | | ||
| tst.go:17:1:17:1 | entry | tst.go:17:14:17:19 | argument corresponding to source | | ||
| tst.go:17:1:19:1 | function declaration | tst.go:21:6:21:12 | skip | | ||
| tst.go:17:6:17:12 | skip | tst.go:17:1:19:1 | function declaration | | ||
| tst.go:17:14:17:19 | argument corresponding to source | tst.go:17:14:17:19 | initialization of source | | ||
| tst.go:17:14:17:19 | initialization of source | tst.go:18:10:18:26 | struct literal | | ||
| tst.go:18:2:18:26 | return statement | tst.go:19:1:19:1 | exit | | ||
| tst.go:18:9:18:26 | &... | tst.go:18:2:18:26 | return statement | | ||
| tst.go:18:10:18:26 | struct literal | tst.go:18:20:18:25 | source | | ||
| tst.go:18:14:18:25 | init of key-value pair | tst.go:18:9:18:26 | &... | | ||
| tst.go:18:20:18:25 | source | tst.go:18:14:18:25 | init of key-value pair | | ||
| tst.go:21:1:21:1 | entry | tst.go:21:14:21:19 | argument corresponding to source | | ||
| tst.go:21:1:28:1 | function declaration | tst.go:30:6:30:9 | skip | | ||
| tst.go:21:6:21:12 | skip | tst.go:21:1:28:1 | function declaration | | ||
| tst.go:21:14:21:19 | argument corresponding to source | tst.go:21:14:21:19 | initialization of source | | ||
| tst.go:21:14:21:19 | initialization of source | tst.go:22:2:22:2 | skip | | ||
| tst.go:22:2:22:2 | assignment to r | tst.go:23:9:23:12 | skip | | ||
| tst.go:22:2:22:2 | skip | tst.go:22:7:22:13 | getData | | ||
| tst.go:22:7:22:13 | getData | tst.go:22:15:22:20 | source | | ||
| tst.go:22:7:22:21 | call to getData | tst.go:22:2:22:2 | assignment to r | | ||
| tst.go:22:7:22:21 | call to getData | tst.go:28:1:28:1 | exit | | ||
| tst.go:22:15:22:20 | source | tst.go:22:7:22:21 | call to getData | | ||
| tst.go:23:9:23:12 | assignment to data | tst.go:24:7:24:10 | case star expression | | ||
| tst.go:23:9:23:12 | assignment to data | tst.go:27:9:27:10 | "" | | ||
| tst.go:23:9:23:12 | skip | tst.go:23:17:23:17 | r | | ||
| tst.go:23:17:23:17 | r | tst.go:23:17:23:24 | type assertion | | ||
| tst.go:23:17:23:24 | type assertion | tst.go:23:9:23:12 | assignment to data | | ||
| tst.go:24:7:24:10 | case star expression | tst.go:25:10:25:13 | data | | ||
| tst.go:24:7:24:10 | case star expression | tst.go:27:9:27:10 | "" | | ||
| tst.go:25:3:25:22 | return statement | tst.go:28:1:28:1 | exit | | ||
| tst.go:25:10:25:13 | data | tst.go:25:10:25:20 | selection of String | | ||
| tst.go:25:10:25:20 | selection of String | tst.go:25:10:25:22 | call to String | | ||
| tst.go:25:10:25:22 | call to String | tst.go:25:3:25:22 | return statement | | ||
| tst.go:25:10:25:22 | call to String | tst.go:28:1:28:1 | exit | | ||
| tst.go:27:2:27:10 | return statement | tst.go:28:1:28:1 | exit | | ||
| tst.go:27:9:27:10 | "" | tst.go:27:2:27:10 | return statement | | ||
| tst.go:30:1:30:1 | entry | tst.go:31:2:31:10 | skip | | ||
| tst.go:30:1:34:1 | function declaration | tst.go:0:0:0:0 | exit | | ||
| tst.go:30:6:30:9 | skip | tst.go:30:1:34:1 | function declaration | | ||
| tst.go:31:2:31:10 | assignment to sourceStr | tst.go:32:2:32:8 | skip | | ||
| tst.go:31:2:31:10 | skip | tst.go:31:15:31:28 | "Hellow rold!" | | ||
| tst.go:31:15:31:28 | "Hellow rold!" | tst.go:31:2:31:10 | assignment to sourceStr | | ||
| tst.go:32:2:32:8 | assignment to sinkStr | tst.go:33:2:33:12 | selection of Println | | ||
| tst.go:32:2:32:8 | skip | tst.go:32:13:32:19 | process | | ||
| tst.go:32:13:32:19 | process | tst.go:32:21:32:29 | sourceStr | | ||
| tst.go:32:13:32:30 | call to process | tst.go:32:2:32:8 | assignment to sinkStr | | ||
| tst.go:32:13:32:30 | call to process | tst.go:34:1:34:1 | exit | | ||
| tst.go:32:21:32:29 | sourceStr | tst.go:32:13:32:30 | call to process | | ||
| tst.go:33:2:33:12 | selection of Println | tst.go:33:14:33:20 | sinkStr | | ||
| tst.go:33:2:33:21 | call to Println | tst.go:34:1:34:1 | exit | | ||
| tst.go:33:14:33:20 | sinkStr | tst.go:33:2:33:21 | call to Println | |
7 changes: 7 additions & 0 deletions
7
...st/library-tests/semmle/go/controlflow/ControlFlowGraph2/ControlFlowNode_getASuccessor.ql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import go | ||
Check failure on line 1 in go/ql/test/library-tests/semmle/go/controlflow/ControlFlowGraph2/ControlFlowNode_getASuccessor.ql GitHub Actions / Test Linux (Ubuntu)
|
||
|
||
from ControlFlow::Node nd | ||
where | ||
// exclude code with build constraints to ensure platform-independent results | ||
not nd.getFile().hasBuildConstraints() | ||
select nd, nd.getASuccessor() |
33 changes: 33 additions & 0 deletions
33
go/ql/test/library-tests/semmle/go/controlflow/ControlFlowGraph2/tst.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package main | ||
|
||
type Data interface { | ||
String() string | ||
} | ||
|
||
type Req struct { | ||
data string | ||
} | ||
|
||
func (r *Req) String() string { | ||
return r.data | ||
} | ||
|
||
func getData(source string) Data { | ||
return &Req{data: source} | ||
} | ||
|
||
func process(source string) string { | ||
r := getData(source) | ||
switch data := r.(type) { | ||
case *Req: | ||
return data.String() | ||
} | ||
return "" | ||
} | ||
|
||
func source() string { return "source" } | ||
func sink(s string) {} | ||
|
||
func main() { | ||
sink(process(source())) | ||
} |
Empty file.
3 changes: 3 additions & 0 deletions
3
go/ql/test/library-tests/semmle/go/dataflow/Switch/DataFlow.ql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import go | ||
import TestUtilities.InlineFlowTest | ||
import DefaultFlowTest |
24 changes: 24 additions & 0 deletions
24
go/ql/test/library-tests/semmle/go/dataflow/Switch/LocalFlowStep.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
| file://:0:0:0:0 | function String | tst.go:9:13:9:29 | selection of String | | ||
| tst.go:5:6:5:6 | function f | tst.go:18:19:18:19 | f | | ||
| tst.go:5:8:5:13 | argument corresponding to input1 | tst.go:5:8:5:13 | definition of input1 | | ||
| tst.go:5:8:5:13 | definition of input1 | tst.go:7:23:7:28 | input1 | | ||
| tst.go:6:2:6:8 | definition of output1 | tst.go:13:9:13:9 | output1 = phi(def@11:3, def@6:2, def@9:3) | | ||
| tst.go:6:13:6:14 | "" | tst.go:6:2:6:8 | definition of output1 | | ||
| tst.go:7:9:7:18 | definition of input1Type | tst.go:9:13:9:22 | input1Type | | ||
| tst.go:7:23:7:28 | input1 | tst.go:7:23:7:35 | type assertion | | ||
| tst.go:7:23:7:35 | type assertion | tst.go:7:9:7:18 | definition of input1Type | | ||
| tst.go:9:3:9:9 | definition of output1 | tst.go:13:9:13:9 | output1 = phi(def@11:3, def@6:2, def@9:3) | | ||
| tst.go:9:13:9:31 | call to String | tst.go:9:3:9:9 | definition of output1 | | ||
| tst.go:11:3:11:9 | definition of output1 | tst.go:13:9:13:9 | output1 = phi(def@11:3, def@6:2, def@9:3) | | ||
| tst.go:11:13:11:23 | "Formatter" | tst.go:11:3:11:9 | definition of output1 | | ||
| tst.go:13:9:13:9 | output1 = phi(def@11:3, def@6:2, def@9:3) | tst.go:13:9:13:15 | output1 | | ||
| tst.go:17:2:17:8 | definition of output2 | tst.go:24:9:24:9 | output2 = phi(def@17:2, def@20:3, def@22:3) | | ||
| tst.go:17:13:17:14 | "" | tst.go:17:2:17:8 | definition of output2 | | ||
| tst.go:18:9:18:14 | definition of input2 | tst.go:18:27:18:32 | input2 | | ||
| tst.go:18:9:18:14 | definition of input2 | tst.go:20:13:20:18 | input2 | | ||
| tst.go:18:19:18:24 | call to f | tst.go:18:9:18:14 | definition of input2 | | ||
| tst.go:20:3:20:9 | definition of output2 | tst.go:24:9:24:9 | output2 = phi(def@17:2, def@20:3, def@22:3) | | ||
| tst.go:20:13:20:18 | input2 | tst.go:20:3:20:9 | definition of output2 | | ||
| tst.go:22:3:22:9 | definition of output2 | tst.go:24:9:24:9 | output2 = phi(def@17:2, def@20:3, def@22:3) | | ||
| tst.go:22:13:22:15 | "c" | tst.go:22:3:22:9 | definition of output2 | | ||
| tst.go:24:9:24:9 | output2 = phi(def@17:2, def@20:3, def@22:3) | tst.go:24:9:24:15 | output2 | |
5 changes: 5 additions & 0 deletions
5
go/ql/test/library-tests/semmle/go/dataflow/Switch/LocalFlowStep.ql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import go | ||
Check failure on line 1 in go/ql/test/library-tests/semmle/go/dataflow/Switch/LocalFlowStep.ql GitHub Actions / Test Linux (Ubuntu)
|
||
|
||
from DataFlow::Node nd, DataFlow::Node succ | ||
where DataFlow::localFlowStep(nd, succ) | ||
select nd, succ |
Oops, something went wrong.