Skip to content

Commit 6abf77d

Browse files
committed
Factor comparison into compatibleContents
1 parent 85d0c63 commit 6abf77d

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

ruby/ql/lib/codeql/ruby/typetracking/TypeTracker.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private module Cached {
4141
exists(TypeTrackerContentSet loadContents |
4242
step = LoadStep(pragma[only_bind_into](loadContents)) and
4343
tt = MkTypeTracker(hasCall, storeContents) and
44-
storeContents.getAStoreContent() = loadContents.getAReadContent() and
44+
compatibleContents(storeContents, loadContents) and
4545
result = noContentTypeTracker(hasCall)
4646
)
4747
or
@@ -76,7 +76,7 @@ private module Cached {
7676
exists(TypeTrackerContentSet storeContents |
7777
step = StoreStep(pragma[only_bind_into](storeContents)) and
7878
tbt = MkTypeBackTracker(hasReturn, loadContents) and
79-
storeContents.getAStoreContent() = loadContents.getAReadContent() and
79+
compatibleContents(storeContents, loadContents) and
8080
result = noContentTypeBackTracker(hasReturn)
8181
)
8282
or

ruby/ql/lib/codeql/ruby/typetracking/TypeTrackerSpecific.qll

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@ class Node = DataFlowPublic::Node;
1515

1616
class TypeTrackingNode = DataFlowPublic::LocalSourceNode;
1717

18-
private newtype TOptionalTypeTrackerContent =
19-
MkAttribute(string name) { name = any(Ast::SetterMethodCall c).getTargetName() } or
20-
MkContent(DataFlowPublic::Content content) or
21-
MkNoContent()
22-
23-
class TypeTrackerContent = DataFlowPublic::Content;
24-
2518
class TypeTrackerContentSet = DataFlowPublic::ContentSet;
2619

2720
class OptionalTypeTrackerContentSet = DataFlowPublic::OptionalContentSet;
2821

22+
/**
23+
* Holds if a value stored with `storeContents` can be read back with `loadContents`.
24+
*/
25+
pragma[inline]
26+
predicate compatibleContents(TypeTrackerContentSet storeContents, TypeTrackerContentSet loadContents) {
27+
storeContents.getAStoreContent() = loadContents.getAReadContent()
28+
}
29+
2930
/** Gets the "no content set" value to use for a type tracker not inside any content. */
3031
OptionalTypeTrackerContentSet noContentSet() { result.isNoContentSet() }
3132

0 commit comments

Comments
 (0)