File tree Expand file tree Collapse file tree 5 files changed +24
-24
lines changed
query-tests/security/cwe-079 Expand file tree Collapse file tree 5 files changed +24
-24
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,23 @@ private class Desugared extends AstNode {
126
126
*/
127
127
int desugarLevel ( AstNode n ) { result = count ( Desugared desugared | n = desugared .getADescendant ( ) ) }
128
128
129
+ /**
130
+ * Holds if `n` appears in a context that is desugared. That is, a
131
+ * transitive, reflexive parent of `n` is a desugared node.
132
+ */
133
+ predicate isInDesugeredContext ( AstNode n ) { n = any ( AstNode sugar ) .getDesugared ( ) .getAChild * ( ) }
134
+
135
+ /**
136
+ * Holds if `n` is a node that only exists as a result of desugaring some
137
+ * other node.
138
+ */
139
+ predicate isDesugarNode ( AstNode n ) {
140
+ n = any ( AstNode sugar ) .getDesugared ( )
141
+ or
142
+ isInDesugeredContext ( n ) and
143
+ forall ( AstNode parent | parent = n .getParent ( ) | parent .isSynthesized ( ) )
144
+ }
145
+
129
146
/**
130
147
* Use this predicate in `Synthesis::child` to generate an assignment of `value` to
131
148
* synthesized variable `v`, where the assignment is a child of `assignParent` at
Original file line number Diff line number Diff line change 1
1
private import ruby
2
+ private import codeql.ruby.ast.internal.Synthesis
2
3
private import codeql.ruby.CFG
3
4
private import codeql.ruby.dataflow.SSA
4
5
private import DataFlowPublic
@@ -279,6 +280,8 @@ predicate nodeIsHidden(Node n) {
279
280
def instanceof Ssa:: PhiNode
280
281
)
281
282
or
283
+ isDesugarNode ( n .( ExprNode ) .getExprNode ( ) .getExpr ( ) )
284
+ or
282
285
n instanceof SummaryNode
283
286
or
284
287
n instanceof SummaryParameterNode
Original file line number Diff line number Diff line change 8
8
9
9
private import AST
10
10
private import codeql.ruby.security.performance.RegExpTreeView as RETV
11
-
12
- /** Holds if `n` appears in the desugaring of some other node. */
13
- predicate isDesugared ( AstNode n ) {
14
- n = any ( AstNode sugar ) .getDesugared ( )
15
- or
16
- isDesugared ( n .getParent ( ) )
17
- }
11
+ private import codeql.ruby.ast.internal.Synthesis
18
12
19
13
/**
20
14
* The query can extend this class to control which nodes are printed.
@@ -25,19 +19,7 @@ class PrintAstConfiguration extends string {
25
19
/**
26
20
* Holds if the given node should be printed.
27
21
*/
28
- predicate shouldPrintNode ( AstNode n ) {
29
- not isDesugared ( n )
30
- or
31
- not n .isSynthesized ( )
32
- or
33
- n .isSynthesized ( ) and
34
- not n = any ( AstNode sugar ) .getDesugared ( ) and
35
- exists ( AstNode parent |
36
- parent = n .getParent ( ) and
37
- not parent .isSynthesized ( ) and
38
- not n = parent .getDesugared ( )
39
- )
40
- }
22
+ predicate shouldPrintNode ( AstNode n ) { not isDesugarNode ( n ) }
41
23
42
24
predicate shouldPrintAstEdge ( AstNode parent , string edgeName , AstNode child ) {
43
25
child = parent .getAChild ( edgeName ) and
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import codeql.ruby.ast.internal.Synthesis
8
8
9
9
class DesugarPrintAstConfiguration extends PrintAstConfiguration {
10
10
override predicate shouldPrintNode ( AstNode n ) {
11
- isDesugared ( n )
11
+ isInDesugeredContext ( n )
12
12
or
13
13
exists ( n .getDesugared ( ) )
14
14
}
Original file line number Diff line number Diff line change 1
1
edges
2
2
| app/controllers/foo/bars_controller.rb:9:12:9:17 | call to params : | app/controllers/foo/bars_controller.rb:9:12:9:29 | ...[...] : |
3
3
| app/controllers/foo/bars_controller.rb:9:12:9:29 | ...[...] : | app/views/foo/bars/show.html.erb:47:5:47:13 | call to user_name |
4
- | app/controllers/foo/bars_controller.rb:13:5:13:37 | ... = ... : | app/views/foo/bars/show.html.erb:51:5:51:18 | call to user_name_memo |
5
- | app/controllers/foo/bars_controller.rb:13:20:13:25 | call to params : | app/controllers/foo/bars_controller.rb:13:5:13:37 | ... = ... : |
4
+ | app/controllers/foo/bars_controller.rb:13:20:13:25 | call to params : | app/views/foo/bars/show.html.erb:51:5:51:18 | call to user_name_memo |
6
5
| app/controllers/foo/bars_controller.rb:17:21:17:26 | call to params : | app/controllers/foo/bars_controller.rb:17:21:17:36 | ...[...] : |
7
6
| app/controllers/foo/bars_controller.rb:17:21:17:36 | ...[...] : | app/views/foo/bars/show.html.erb:2:18:2:30 | @user_website |
8
7
| app/controllers/foo/bars_controller.rb:18:10:18:15 | call to params : | app/controllers/foo/bars_controller.rb:19:22:19:23 | dt : |
21
20
nodes
22
21
| app/controllers/foo/bars_controller.rb:9:12:9:17 | call to params : | semmle.label | call to params : |
23
22
| app/controllers/foo/bars_controller.rb:9:12:9:29 | ...[...] : | semmle.label | ...[...] : |
24
- | app/controllers/foo/bars_controller.rb:13:5:13:37 | ... = ... : | semmle.label | ... = ... : |
25
23
| app/controllers/foo/bars_controller.rb:13:20:13:25 | call to params : | semmle.label | call to params : |
26
24
| app/controllers/foo/bars_controller.rb:17:21:17:26 | call to params : | semmle.label | call to params : |
27
25
| app/controllers/foo/bars_controller.rb:17:21:17:36 | ...[...] : | semmle.label | ...[...] : |
You can’t perform that action at this time.
0 commit comments