File tree Expand file tree Collapse file tree
library-tests/frameworks/sinatra
query-tests/experimental/improper-memoization Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,11 +4,35 @@ private import codeql.util.test.InlineExpectationsTest
44module Impl implements InlineExpectationsTestSig {
55 private import codeql.ruby.ast.internal.TreeSitter
66
7+ private newtype TAnyComment =
8+ RubyComment ( Ruby:: Comment comment ) or
9+ ErbComment ( R:: ErbComment comment )
10+
711 /**
8- * A class representing line comments in Ruby .
12+ * A class representing comments that may contain inline expectations (Ruby line comments and ERB comments) .
913 */
10- class ExpectationComment extends Ruby:: Comment {
11- string getContents ( ) { result = this .getValue ( ) .suffix ( 1 ) }
14+ class ExpectationComment extends TAnyComment {
15+ Ruby:: Comment asRubyComment ( ) { this = RubyComment ( result ) }
16+
17+ R:: ErbComment asErbComment ( ) { this = ErbComment ( result ) }
18+
19+ string toString ( ) {
20+ result = this .asRubyComment ( ) .toString ( )
21+ or
22+ result = this .asErbComment ( ) .toString ( )
23+ }
24+
25+ Location getLocation ( ) {
26+ result = this .asRubyComment ( ) .getLocation ( )
27+ or
28+ result = this .asErbComment ( ) .getLocation ( )
29+ }
30+
31+ string getContents ( ) {
32+ result = this .asRubyComment ( ) .getValue ( ) .suffix ( 1 )
33+ or
34+ result = this .asErbComment ( ) .getValue ( ) .suffix ( 1 )
35+ }
1236 }
1337
1438 class Location = R:: Location ;
Original file line number Diff line number Diff line change 2323| views/index.erb:2:10:2:12 | call to foo | semmle.label | call to foo |
2424subpaths
2525testFailures
26- | views/index.erb:2:10:2:12 | call to foo | Unexpected result: hasTaintFlow |
2726#select
2827| app.rb:95:10:95:14 | @user | app.rb:103:13:103:22 | call to source | app.rb:95:10:95:14 | @user | $@ | app.rb:103:13:103:22 | call to source | call to source |
2928| views/index.erb:2:10:2:12 | call to foo | app.rb:75:12:75:17 | call to params | views/index.erb:2:10:2:12 | call to foo | $@ | app.rb:75:12:75:17 | call to params | call to params |
Original file line number Diff line number Diff line change 11<%= @foo %>
2- <%= sink foo %>
2+ <%= sink foo %> <%# $ hasTaintFlow %>
Original file line number Diff line number Diff line change 11testFailures
2- | improper_memoization.rb:100:1:104:3 | m14 | Unexpected result: result=BAD |
32#select
43| improper_memoization.rb:50:1:55:3 | m7 | improper_memoization.rb:50:8:50:10 | arg | improper_memoization.rb:51:3:53:5 | ... \|\|= ... |
54| improper_memoization.rb:58:1:63:3 | m8 | improper_memoization.rb:58:8:58:10 | arg | improper_memoization.rb:59:3:61:5 | ... \|\|= ... |
Original file line number Diff line number Diff line change @@ -101,4 +101,4 @@ def m14(arg)
101101 @m14 ||= { }
102102 key = "foo/#{ arg } "
103103 @m14 [ key ] ||= long_running_method ( arg )
104- end
104+ end # $ SPURIOUS: result=BAD
You can’t perform that action at this time.
0 commit comments