Skip to content

Commit 475d8da

Browse files
committed
Ruby: Include more nodes in {Hash,Array}LiteralCfgNode
1 parent 28a5a1d commit 475d8da

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

ruby/ql/lib/codeql/ruby/controlflow/CfgNodes.qll

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -960,8 +960,7 @@ module ExprNodes {
960960
exists(ConstantReadAccess array |
961961
array = this.getReceiver().getExpr() and
962962
e.(MethodCall).getMethodName() = "[]" and
963-
array.getName() = "Array" and
964-
array.hasGlobalScope()
963+
array.getModule().getQualifiedName() = "Array"
965964
)
966965
}
967966
}
@@ -975,11 +974,10 @@ module ExprNodes {
975974
override string getAPrimaryQlClass() { result = "HashLiteralCfgNode" }
976975

977976
HashLiteralCfgNode() {
978-
exists(ConstantReadAccess array |
979-
array = this.getReceiver().getExpr() and
977+
exists(ConstantReadAccess hash |
978+
hash = this.getReceiver().getExpr() and
980979
e.(MethodCall).getMethodName() = "[]" and
981-
array.getName() = "Hash" and
982-
array.hasGlobalScope()
980+
hash.getModule().getQualifiedName() = "Hash"
983981
)
984982
}
985983

ruby/ql/test/library-tests/dataflow/hash-flow/hash-flow.expected

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ edges
4242
| hash_flow.rb:44:10:44:13 | hash [element 0] | hash_flow.rb:44:10:44:16 | ...[...] |
4343
| hash_flow.rb:46:10:46:13 | hash [element :a] | hash_flow.rb:46:10:46:17 | ...[...] |
4444
| hash_flow.rb:48:10:48:13 | hash [element a] | hash_flow.rb:48:10:48:18 | ...[...] |
45-
| hash_flow.rb:55:5:55:9 | hash1 [hash-splat position :a] | hash_flow.rb:56:10:56:14 | hash1 [hash-splat position :a] |
46-
| hash_flow.rb:55:13:55:37 | ...[...] [hash-splat position :a] | hash_flow.rb:55:5:55:9 | hash1 [hash-splat position :a] |
47-
| hash_flow.rb:55:21:55:30 | call to taint | hash_flow.rb:55:13:55:37 | ...[...] [hash-splat position :a] |
48-
| hash_flow.rb:56:10:56:14 | hash1 [hash-splat position :a] | hash_flow.rb:56:10:56:18 | ...[...] |
45+
| hash_flow.rb:55:5:55:9 | hash1 [element :a] | hash_flow.rb:56:10:56:14 | hash1 [element :a] |
46+
| hash_flow.rb:55:13:55:37 | ...[...] [element :a] | hash_flow.rb:55:5:55:9 | hash1 [element :a] |
47+
| hash_flow.rb:55:21:55:30 | call to taint | hash_flow.rb:55:13:55:37 | ...[...] [element :a] |
48+
| hash_flow.rb:56:10:56:14 | hash1 [element :a] | hash_flow.rb:56:10:56:18 | ...[...] |
4949
| hash_flow.rb:59:5:59:5 | x [element :a] | hash_flow.rb:60:18:60:18 | x [element :a] |
5050
| hash_flow.rb:59:13:59:22 | call to taint | hash_flow.rb:59:5:59:5 | x [element :a] |
5151
| hash_flow.rb:60:5:60:9 | hash2 [element :a] | hash_flow.rb:61:10:61:14 | hash2 [element :a] |
@@ -62,10 +62,10 @@ edges
6262
| hash_flow.rb:68:13:68:39 | ...[...] [element :a] | hash_flow.rb:68:5:68:9 | hash4 [element :a] |
6363
| hash_flow.rb:68:22:68:31 | call to taint | hash_flow.rb:68:13:68:39 | ...[...] [element :a] |
6464
| hash_flow.rb:69:10:69:14 | hash4 [element :a] | hash_flow.rb:69:10:69:18 | ...[...] |
65-
| hash_flow.rb:72:5:72:9 | hash5 [hash-splat position a] | hash_flow.rb:73:10:73:14 | hash5 [hash-splat position a] |
66-
| hash_flow.rb:72:13:72:45 | ...[...] [hash-splat position a] | hash_flow.rb:72:5:72:9 | hash5 [hash-splat position a] |
67-
| hash_flow.rb:72:25:72:34 | call to taint | hash_flow.rb:72:13:72:45 | ...[...] [hash-splat position a] |
68-
| hash_flow.rb:73:10:73:14 | hash5 [hash-splat position a] | hash_flow.rb:73:10:73:19 | ...[...] |
65+
| hash_flow.rb:72:5:72:9 | hash5 [element a] | hash_flow.rb:73:10:73:14 | hash5 [element a] |
66+
| hash_flow.rb:72:13:72:45 | ...[...] [element a] | hash_flow.rb:72:5:72:9 | hash5 [element a] |
67+
| hash_flow.rb:72:25:72:34 | call to taint | hash_flow.rb:72:13:72:45 | ...[...] [element a] |
68+
| hash_flow.rb:73:10:73:14 | hash5 [element a] | hash_flow.rb:73:10:73:19 | ...[...] |
6969
| hash_flow.rb:76:5:76:9 | hash6 [element a] | hash_flow.rb:77:10:77:14 | hash6 [element a] |
7070
| hash_flow.rb:76:13:76:47 | ...[...] [element a] | hash_flow.rb:76:5:76:9 | hash6 [element a] |
7171
| hash_flow.rb:76:26:76:35 | call to taint | hash_flow.rb:76:13:76:47 | ...[...] [element a] |
@@ -1015,10 +1015,10 @@ nodes
10151015
| hash_flow.rb:46:10:46:17 | ...[...] | semmle.label | ...[...] |
10161016
| hash_flow.rb:48:10:48:13 | hash [element a] | semmle.label | hash [element a] |
10171017
| hash_flow.rb:48:10:48:18 | ...[...] | semmle.label | ...[...] |
1018-
| hash_flow.rb:55:5:55:9 | hash1 [hash-splat position :a] | semmle.label | hash1 [hash-splat position :a] |
1019-
| hash_flow.rb:55:13:55:37 | ...[...] [hash-splat position :a] | semmle.label | ...[...] [hash-splat position :a] |
1018+
| hash_flow.rb:55:5:55:9 | hash1 [element :a] | semmle.label | hash1 [element :a] |
1019+
| hash_flow.rb:55:13:55:37 | ...[...] [element :a] | semmle.label | ...[...] [element :a] |
10201020
| hash_flow.rb:55:21:55:30 | call to taint | semmle.label | call to taint |
1021-
| hash_flow.rb:56:10:56:14 | hash1 [hash-splat position :a] | semmle.label | hash1 [hash-splat position :a] |
1021+
| hash_flow.rb:56:10:56:14 | hash1 [element :a] | semmle.label | hash1 [element :a] |
10221022
| hash_flow.rb:56:10:56:18 | ...[...] | semmle.label | ...[...] |
10231023
| hash_flow.rb:59:5:59:5 | x [element :a] | semmle.label | x [element :a] |
10241024
| hash_flow.rb:59:13:59:22 | call to taint | semmle.label | call to taint |
@@ -1039,10 +1039,10 @@ nodes
10391039
| hash_flow.rb:68:22:68:31 | call to taint | semmle.label | call to taint |
10401040
| hash_flow.rb:69:10:69:14 | hash4 [element :a] | semmle.label | hash4 [element :a] |
10411041
| hash_flow.rb:69:10:69:18 | ...[...] | semmle.label | ...[...] |
1042-
| hash_flow.rb:72:5:72:9 | hash5 [hash-splat position a] | semmle.label | hash5 [hash-splat position a] |
1043-
| hash_flow.rb:72:13:72:45 | ...[...] [hash-splat position a] | semmle.label | ...[...] [hash-splat position a] |
1042+
| hash_flow.rb:72:5:72:9 | hash5 [element a] | semmle.label | hash5 [element a] |
1043+
| hash_flow.rb:72:13:72:45 | ...[...] [element a] | semmle.label | ...[...] [element a] |
10441044
| hash_flow.rb:72:25:72:34 | call to taint | semmle.label | call to taint |
1045-
| hash_flow.rb:73:10:73:14 | hash5 [hash-splat position a] | semmle.label | hash5 [hash-splat position a] |
1045+
| hash_flow.rb:73:10:73:14 | hash5 [element a] | semmle.label | hash5 [element a] |
10461046
| hash_flow.rb:73:10:73:19 | ...[...] | semmle.label | ...[...] |
10471047
| hash_flow.rb:76:5:76:9 | hash6 [element a] | semmle.label | hash6 [element a] |
10481048
| hash_flow.rb:76:13:76:47 | ...[...] [element a] | semmle.label | ...[...] [element a] |

0 commit comments

Comments
 (0)