Skip to content

Commit

Permalink
Ruby: Fix another bug in isCapturedAccess
Browse files Browse the repository at this point in the history
  • Loading branch information
hvitved committed Aug 10, 2023
1 parent f377d25 commit f19232f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 36 deletions.
16 changes: 2 additions & 14 deletions ruby/ql/lib/codeql/ruby/ast/internal/Variable.qll
Original file line number Diff line number Diff line change
Expand Up @@ -368,20 +368,8 @@ private module Cached {
exists(Scope scope1, CfgScope scope2 |
scope1 = access.getVariable().getDeclaringScope() and
scope2 = access.getCfgScope() and
scope1 != scope2
|
if access instanceof SelfVariableAccess
then
// ```
// class C
// def self.m // not a captured access
// end
//
// self.foo // not a captured access
// end
// ```
not scope2 instanceof Toplevel
else any()
scope1 != scope2 and
not scope2 instanceof Toplevel
)
}

Expand Down
4 changes: 0 additions & 4 deletions ruby/ql/test/library-tests/variables/ssa.expected
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,9 @@ definition
| scopes.rb:26:1:26:12 | self (A) | scopes.rb:26:1:26:12 | self |
| scopes.rb:27:1:27:1 | x | scopes.rb:27:1:27:1 | x |
| scopes.rb:28:1:30:3 | self (B) | scopes.rb:28:1:30:3 | self |
| scopes.rb:29:3:29:3 | x | scopes.rb:29:3:29:3 | x |
| scopes.rb:32:3:32:3 | x | scopes.rb:32:3:32:3 | x |
| scopes.rb:34:1:36:3 | self (C) | scopes.rb:34:1:36:3 | self |
| scopes.rb:35:3:35:3 | x | scopes.rb:35:3:35:3 | x |
| scopes.rb:41:1:49:3 | self (M) | scopes.rb:41:1:49:3 | self |
| scopes.rb:42:2:42:4 | var | scopes.rb:42:2:42:4 | var |
| scopes.rb:43:2:43:4 | foo | scopes.rb:43:2:43:4 | foo |
| scopes.rb:46:5:46:8 | var2 | scopes.rb:46:5:46:8 | var2 |
| ssa.rb:1:1:16:3 | self (m) | ssa.rb:1:1:16:3 | self |
| ssa.rb:1:7:1:7 | b | ssa.rb:1:7:1:7 | b |
Expand Down
18 changes: 0 additions & 18 deletions ruby/ql/test/library-tests/variables/varaccess.expected
Original file line number Diff line number Diff line change
Expand Up @@ -619,18 +619,8 @@ readAccess
captureAccess
| instance_variables.rb:28:3:28:4 | self |
| instance_variables.rb:32:12:32:13 | self |
| nested_scopes.rb:5:3:5:3 | a |
| nested_scopes.rb:7:5:7:5 | a |
| nested_scopes.rb:9:7:9:7 | a |
| nested_scopes.rb:11:9:11:9 | a |
| nested_scopes.rb:18:29:18:34 | self |
| nested_scopes.rb:18:34:18:34 | a |
| nested_scopes.rb:25:14:25:14 | a |
| nested_scopes.rb:31:11:31:11 | a |
| nested_scopes.rb:32:16:32:16 | a |
| nested_scopes.rb:34:12:34:12 | a |
| nested_scopes.rb:36:10:36:10 | a |
| nested_scopes.rb:38:8:38:8 | a |
| parameters.rb:3:4:3:9 | self |
| parameters.rb:4:4:4:9 | self |
| parameters.rb:17:5:17:28 | self |
Expand All @@ -653,14 +643,6 @@ captureAccess
| scopes.rb:15:4:15:9 | self |
| scopes.rb:16:4:16:9 | self |
| scopes.rb:17:4:17:9 | self |
| scopes.rb:29:3:29:3 | x |
| scopes.rb:32:3:32:3 | x |
| scopes.rb:35:3:35:3 | x |
| scopes.rb:42:2:42:4 | var |
| scopes.rb:43:2:43:4 | foo |
| scopes.rb:44:5:44:7 | var |
| scopes.rb:46:5:46:8 | var2 |
| scopes.rb:47:5:47:8 | var2 |
| ssa.rb:26:7:26:10 | elem |
| ssa.rb:27:5:27:13 | self |
| ssa.rb:27:10:27:13 | elem |
Expand Down

0 comments on commit f19232f

Please sign in to comment.