Ruby: Add variable capture spurious flow test

This commit is contained in:
Tom Hvitved
2024-03-05 09:38:09 +01:00
parent 2896bfbd9f
commit e793a1e9fe
2 changed files with 25 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
testFailures
| captured_variables.rb:236:14:236:14 | x | Unexpected result: hasValueFlow=19 |
edges
| blocks.rb:14:12:14:20 | call to source | blocks.rb:8:10:8:14 | yield ... | provenance | |
| captured_variables.rb:9:24:9:24 | x | captured_variables.rb:10:10:10:23 | -> { ... } [captured x] | provenance | |
@@ -122,6 +123,10 @@ edges
| captured_variables.rb:222:11:224:5 | -> { ... } [captured x] | captured_variables.rb:222:5:222:7 | fn1 [captured x] | provenance | |
| captured_variables.rb:226:5:226:7 | [post] fn1 [captured y] | captured_variables.rb:227:10:227:10 | y | provenance | |
| captured_variables.rb:226:5:226:7 | fn1 [captured x] | captured_variables.rb:226:5:226:7 | [post] fn1 [captured y] | provenance | |
| captured_variables.rb:233:9:233:17 | call to taint | captured_variables.rb:235:11:237:5 | -> { ... } [captured x] | provenance | |
| captured_variables.rb:235:5:235:7 | fn1 [captured x] | captured_variables.rb:241:5:241:7 | fn1 [captured x] | provenance | |
| captured_variables.rb:235:11:237:5 | -> { ... } [captured x] | captured_variables.rb:235:5:235:7 | fn1 [captured x] | provenance | |
| captured_variables.rb:241:5:241:7 | fn1 [captured x] | captured_variables.rb:236:14:236:14 | x | provenance | |
| instance_variables.rb:10:19:10:19 | x | instance_variables.rb:11:18:11:18 | x | provenance | |
| instance_variables.rb:11:18:11:18 | x | instance_variables.rb:11:9:11:14 | [post] self [@field] | provenance | |
| instance_variables.rb:13:5:15:7 | self in get_field [@field] | instance_variables.rb:14:16:14:21 | self [@field] | provenance | |
@@ -385,6 +390,11 @@ nodes
| captured_variables.rb:226:5:226:7 | [post] fn1 [captured y] | semmle.label | [post] fn1 [captured y] |
| captured_variables.rb:226:5:226:7 | fn1 [captured x] | semmle.label | fn1 [captured x] |
| captured_variables.rb:227:10:227:10 | y | semmle.label | y |
| captured_variables.rb:233:9:233:17 | call to taint | semmle.label | call to taint |
| captured_variables.rb:235:5:235:7 | fn1 [captured x] | semmle.label | fn1 [captured x] |
| captured_variables.rb:235:11:237:5 | -> { ... } [captured x] | semmle.label | -> { ... } [captured x] |
| captured_variables.rb:236:14:236:14 | x | semmle.label | x |
| captured_variables.rb:241:5:241:7 | fn1 [captured x] | semmle.label | fn1 [captured x] |
| instance_variables.rb:10:19:10:19 | x | semmle.label | x |
| instance_variables.rb:11:9:11:14 | [post] self [@field] | semmle.label | [post] self [@field] |
| instance_variables.rb:11:18:11:18 | x | semmle.label | x |
@@ -595,6 +605,7 @@ subpaths
| captured_variables.rb:199:10:199:10 | x | captured_variables.rb:197:9:197:17 | call to taint | captured_variables.rb:199:10:199:10 | x | $@ | captured_variables.rb:197:9:197:17 | call to taint | call to taint |
| captured_variables.rb:208:14:208:14 | x | captured_variables.rb:206:13:206:21 | call to taint | captured_variables.rb:208:14:208:14 | x | $@ | captured_variables.rb:206:13:206:21 | call to taint | call to taint |
| captured_variables.rb:227:10:227:10 | y | captured_variables.rb:219:9:219:17 | call to taint | captured_variables.rb:227:10:227:10 | y | $@ | captured_variables.rb:219:9:219:17 | call to taint | call to taint |
| captured_variables.rb:236:14:236:14 | x | captured_variables.rb:233:9:233:17 | call to taint | captured_variables.rb:236:14:236:14 | x | $@ | captured_variables.rb:233:9:233:17 | call to taint | call to taint |
| instance_variables.rb:20:10:20:13 | @foo | instance_variables.rb:19:12:19:21 | call to taint | instance_variables.rb:20:10:20:13 | @foo | $@ | instance_variables.rb:19:12:19:21 | call to taint | call to taint |
| instance_variables.rb:36:10:36:33 | call to get_field | instance_variables.rb:36:14:36:22 | call to taint | instance_variables.rb:36:10:36:33 | call to get_field | $@ | instance_variables.rb:36:14:36:22 | call to taint | call to taint |
| instance_variables.rb:39:6:39:33 | call to get_field | instance_variables.rb:39:14:39:22 | call to taint | instance_variables.rb:39:6:39:33 | call to get_field | $@ | instance_variables.rb:39:14:39:22 | call to taint | call to taint |

View File

@@ -228,3 +228,17 @@ def multi_capture
end
multi_capture
def m1
x = taint(19)
fn1 = -> {
sink x
}
x = nil
fn1.call()
end
m1