@@ -4,6 +4,7 @@ import ruby
44import codeql.ruby.DataFlow
55private import internal.FlowSummaryImpl as Impl
66private import internal.DataFlowDispatch
7+ private import internal.DataFlowPrivate
78
89// import all instances below
910private module Summaries {
@@ -22,12 +23,34 @@ module SummaryComponent {
2223
2324 predicate content = SC:: content / 1 ;
2425
25- /** Gets a summary component that represents a qualifier . */
26- SummaryComponent qualifier ( ) { result = argument ( any ( ParameterPosition pos | pos .isSelf ( ) ) ) }
26+ /** Gets a summary component that represents a receiver . */
27+ SummaryComponent receiver ( ) { result = argument ( any ( ParameterPosition pos | pos .isSelf ( ) ) ) }
2728
2829 /** Gets a summary component that represents a block argument. */
2930 SummaryComponent block ( ) { result = argument ( any ( ParameterPosition pos | pos .isBlock ( ) ) ) }
3031
32+ /** Gets a summary component that represents an element in an array at an unknown index. */
33+ SummaryComponent arrayElementUnknown ( ) { result = SC:: content ( TUnknownArrayElementContent ( ) ) }
34+
35+ /** Gets a summary component that represents an element in an array at a known index. */
36+ bindingset [ i]
37+ SummaryComponent arrayElementKnown ( int i ) {
38+ result = SC:: content ( TKnownArrayElementContent ( i ) )
39+ or
40+ // `i` may be out of range
41+ not exists ( TKnownArrayElementContent ( i ) ) and
42+ result = arrayElementUnknown ( )
43+ }
44+
45+ /**
46+ * Gets a summary component that represents an element in an array at either an unknown
47+ * index or known index. This predicate should never be used in the output specification
48+ * of a flow summary; use `arrayElementUnknown()` instead.
49+ */
50+ SummaryComponent arrayElementAny ( ) {
51+ result in [ arrayElementUnknown ( ) , SC:: content ( TKnownArrayElementContent ( _) ) ]
52+ }
53+
3154 /** Gets a summary component that represents the return value of a call. */
3255 SummaryComponent return ( ) { result = SC:: return ( any ( NormalReturnKind rk ) ) }
3356}
@@ -44,8 +67,8 @@ module SummaryComponentStack {
4467
4568 predicate argument = SCS:: argument / 1 ;
4669
47- /** Gets a singleton stack representing a qualifier . */
48- SummaryComponentStack qualifier ( ) { result = singleton ( SummaryComponent:: qualifier ( ) ) }
70+ /** Gets a singleton stack representing a receiver . */
71+ SummaryComponentStack receiver ( ) { result = singleton ( SummaryComponent:: receiver ( ) ) }
4972
5073 /** Gets a singleton stack representing a block argument. */
5174 SummaryComponentStack block ( ) { result = singleton ( SummaryComponent:: block ( ) ) }
@@ -108,6 +131,17 @@ abstract class SummarizedCallable extends LibraryCallable {
108131 predicate clearsContent ( ParameterPosition pos , DataFlow:: Content content ) { none ( ) }
109132}
110133
134+ /**
135+ * A callable with a flow summary, identified by a unique string, where all
136+ * calls to a method with the same name are considered relevant.
137+ */
138+ abstract class SimpleSummarizedCallable extends SummarizedCallable {
139+ bindingset [ this ]
140+ SimpleSummarizedCallable ( ) { any ( ) }
141+
142+ final override MethodCall getACall ( ) { result .getMethodName ( ) = this }
143+ }
144+
111145private class SummarizedCallableAdapter extends Impl:: Public:: SummarizedCallable {
112146 private SummarizedCallable sc ;
113147
0 commit comments