-
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
4 changed files
with
177 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
ruby/ql/test/library-tests/dataflow/barrier-guards/barrier-flow.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,47 @@ | ||
testFailures | ||
edges | ||
| barrier_flow.rb:2:5:2:5 | x | barrier_flow.rb:4:10:4:10 | x | provenance | | | ||
| barrier_flow.rb:2:9:2:17 | call to source | barrier_flow.rb:2:5:2:5 | x | provenance | | | ||
| barrier_flow.rb:8:5:8:5 | x | barrier_flow.rb:11:14:11:14 | x | provenance | | | ||
| barrier_flow.rb:8:9:8:17 | call to source | barrier_flow.rb:8:5:8:5 | x | provenance | | | ||
| barrier_flow.rb:24:5:24:5 | x | barrier_flow.rb:26:10:26:10 | x | provenance | | | ||
| barrier_flow.rb:24:9:24:17 | call to source | barrier_flow.rb:24:5:24:5 | x | provenance | | | ||
| barrier_flow.rb:36:5:36:5 | x | barrier_flow.rb:42:10:42:10 | x | provenance | | | ||
| barrier_flow.rb:36:9:36:17 | call to source | barrier_flow.rb:36:5:36:5 | x | provenance | | | ||
| barrier_flow.rb:46:5:46:5 | x | barrier_flow.rb:50:10:50:10 | x | provenance | | | ||
| barrier_flow.rb:46:9:46:17 | call to source | barrier_flow.rb:46:5:46:5 | x | provenance | | | ||
| barrier_flow.rb:54:5:54:5 | x | barrier_flow.rb:62:10:62:10 | x | provenance | | | ||
| barrier_flow.rb:54:9:54:17 | call to source | barrier_flow.rb:54:5:54:5 | x | provenance | | | ||
| barrier_flow.rb:66:5:66:5 | x | barrier_flow.rb:78:10:78:10 | x | provenance | | | ||
| barrier_flow.rb:66:9:66:17 | call to source | barrier_flow.rb:66:5:66:5 | x | provenance | | | ||
nodes | ||
| barrier_flow.rb:2:5:2:5 | x | semmle.label | x | | ||
| barrier_flow.rb:2:9:2:17 | call to source | semmle.label | call to source | | ||
| barrier_flow.rb:4:10:4:10 | x | semmle.label | x | | ||
| barrier_flow.rb:8:5:8:5 | x | semmle.label | x | | ||
| barrier_flow.rb:8:9:8:17 | call to source | semmle.label | call to source | | ||
| barrier_flow.rb:11:14:11:14 | x | semmle.label | x | | ||
| barrier_flow.rb:24:5:24:5 | x | semmle.label | x | | ||
| barrier_flow.rb:24:9:24:17 | call to source | semmle.label | call to source | | ||
| barrier_flow.rb:26:10:26:10 | x | semmle.label | x | | ||
| barrier_flow.rb:36:5:36:5 | x | semmle.label | x | | ||
| barrier_flow.rb:36:9:36:17 | call to source | semmle.label | call to source | | ||
| barrier_flow.rb:42:10:42:10 | x | semmle.label | x | | ||
| barrier_flow.rb:46:5:46:5 | x | semmle.label | x | | ||
| barrier_flow.rb:46:9:46:17 | call to source | semmle.label | call to source | | ||
| barrier_flow.rb:50:10:50:10 | x | semmle.label | x | | ||
| barrier_flow.rb:54:5:54:5 | x | semmle.label | x | | ||
| barrier_flow.rb:54:9:54:17 | call to source | semmle.label | call to source | | ||
| barrier_flow.rb:62:10:62:10 | x | semmle.label | x | | ||
| barrier_flow.rb:66:5:66:5 | x | semmle.label | x | | ||
| barrier_flow.rb:66:9:66:17 | call to source | semmle.label | call to source | | ||
| barrier_flow.rb:78:10:78:10 | x | semmle.label | x | | ||
subpaths | ||
#select | ||
| barrier_flow.rb:4:10:4:10 | x | barrier_flow.rb:2:9:2:17 | call to source | barrier_flow.rb:4:10:4:10 | x | $@ | barrier_flow.rb:2:9:2:17 | call to source | call to source | | ||
| barrier_flow.rb:11:14:11:14 | x | barrier_flow.rb:8:9:8:17 | call to source | barrier_flow.rb:11:14:11:14 | x | $@ | barrier_flow.rb:8:9:8:17 | call to source | call to source | | ||
| barrier_flow.rb:26:10:26:10 | x | barrier_flow.rb:24:9:24:17 | call to source | barrier_flow.rb:26:10:26:10 | x | $@ | barrier_flow.rb:24:9:24:17 | call to source | call to source | | ||
| barrier_flow.rb:42:10:42:10 | x | barrier_flow.rb:36:9:36:17 | call to source | barrier_flow.rb:42:10:42:10 | x | $@ | barrier_flow.rb:36:9:36:17 | call to source | call to source | | ||
| barrier_flow.rb:50:10:50:10 | x | barrier_flow.rb:46:9:46:17 | call to source | barrier_flow.rb:50:10:50:10 | x | $@ | barrier_flow.rb:46:9:46:17 | call to source | call to source | | ||
| barrier_flow.rb:62:10:62:10 | x | barrier_flow.rb:54:9:54:17 | call to source | barrier_flow.rb:62:10:62:10 | x | $@ | barrier_flow.rb:54:9:54:17 | call to source | call to source | | ||
| barrier_flow.rb:78:10:78:10 | x | barrier_flow.rb:66:9:66:17 | call to source | barrier_flow.rb:78:10:78:10 | x | $@ | barrier_flow.rb:66:9:66:17 | call to source | call to source | |
23 changes: 23 additions & 0 deletions
23
ruby/ql/test/library-tests/dataflow/barrier-guards/barrier-flow.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,23 @@ | ||
/** | ||
* @kind path-problem | ||
*/ | ||
|
||
import codeql.ruby.AST | ||
import codeql.ruby.CFG | ||
import TestUtilities.InlineFlowTest | ||
import codeql.ruby.dataflow.BarrierGuards | ||
import PathGraph | ||
|
||
module FlowConfig implements DataFlow::ConfigSig { | ||
predicate isSource = DefaultFlowConfig::isSource/1; | ||
|
||
predicate isSink = DefaultFlowConfig::isSink/1; | ||
|
||
predicate isBarrier(DataFlow::Node n) { n instanceof StringConstCompareBarrier } | ||
} | ||
|
||
import ValueFlowTest<FlowConfig> | ||
|
||
from PathNode source, PathNode sink | ||
where flowPath(source, sink) | ||
select sink, source, sink, "$@", source, source.toString() |
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
79 changes: 79 additions & 0 deletions
79
ruby/ql/test/library-tests/dataflow/barrier-guards/barrier_flow.rb
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,79 @@ | ||
def m1 | ||
x = source(1) | ||
|
||
sink x # $ hasValueFlow=1 | ||
end | ||
|
||
def m2 | ||
x = source(2) | ||
|
||
if x != "safe" then | ||
sink x # $ hasValueFlow=2 | ||
end | ||
end | ||
|
||
def m3 | ||
x = source(3) | ||
|
||
if x == "safe" then | ||
sink x # $ guarded | ||
end | ||
end | ||
|
||
def m4 | ||
x = source(4) | ||
|
||
sink x unless x == "safe" # $ hasValueFlow=4 | ||
end | ||
|
||
def m5 | ||
x = source(5) | ||
|
||
sink x unless x != "safe" # $ guarded | ||
end | ||
|
||
def m6 | ||
x = source(6) | ||
|
||
if x != "safe" then | ||
x = "safe" | ||
end | ||
|
||
sink x # $ SPURIOUS hasValueFlow=6 | ||
end | ||
|
||
def m7 | ||
x = source(7) | ||
|
||
x = "safe" unless x == "safe" | ||
|
||
sink x # $ SPURIOUS hasValueFlow=7 | ||
end | ||
|
||
def m8(b) | ||
x = source(8) | ||
|
||
if b then | ||
return unless x == "safe1" | ||
else | ||
return unless x == "safe2" | ||
end | ||
|
||
sink x # $ SPURIOUS hasValueFlow=8 | ||
end | ||
|
||
def m9(b) | ||
x = source(9) | ||
|
||
if b then | ||
if x != "safe1" then | ||
return | ||
end | ||
else | ||
if x != "safe2" then | ||
return | ||
end | ||
end | ||
|
||
sink x # $ SPURIOUS hasValueFlow=9 | ||
end |