-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Ruby: Adopt shared type tracking library #14709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import codeql.ruby.DataFlow | ||
import codeql.ruby.typetracking.internal.TypeTrackingImpl | ||
|
||
private module ConsistencyChecksInput implements ConsistencyChecksInputSig { | ||
predicate unreachableNodeExclude(DataFlow::Node n) { n instanceof DataFlow::PostUpdateNode } | ||
} | ||
|
||
import ConsistencyChecks<ConsistencyChecksInput> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
category: minorAnalysis | ||
--- | ||
* Ruby now makes use of the shared type tracking library, exposed as `codeql.ruby.typetracking.TypeTracking`. The existing type tracking library, `codeql.ruby.typetracking.TypeTracker`, has consequently been deprecated. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ private import codeql.ruby.AST as Ast | |
private import codeql.ruby.CFG | ||
private import codeql.ruby.DataFlow | ||
private import codeql.ruby.controlflow.CfgNodes | ||
private import codeql.ruby.typetracking.TypeTracker | ||
private import codeql.ruby.typetracking.internal.TypeTrackingImpl | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this really need to import the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does, because the code refers to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I guess we cannot avoid that, can we? Or should StepSummary perhaps be part of the public interface? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer to keep it internal, at least for now. It is not something I expect we need to use very often. |
||
private import codeql.ruby.ApiGraphs | ||
private import codeql.ruby.Concepts | ||
private import codeql.ruby.dataflow.internal.DataFlowPrivate as DataFlowPrivate | ||
|
@@ -67,7 +67,7 @@ private signature module TypeTrackInputSig { | |
* Provides a version of type tracking where we first prune for reachable nodes, | ||
* before doing the type tracking computation. | ||
*/ | ||
private module TypeTrack<TypeTrackInputSig Input> { | ||
private module PrunedTypeTrack<TypeTrackInputSig Input> { | ||
private predicate additionalStep( | ||
DataFlow::LocalSourceNode nodeFrom, DataFlow::LocalSourceNode nodeTo | ||
) { | ||
|
@@ -130,10 +130,10 @@ private module TypeTrack<TypeTrackInputSig Input> { | |
TypeTracker t, DataFlow::LocalSourceNode nodeFrom, DataFlow::LocalSourceNode nodeTo | ||
) { | ||
exists(StepSummary summary | | ||
StepSummary::step(nodeFrom, nodeTo, summary) and | ||
step(nodeFrom, nodeTo, summary) and | ||
reached(nodeFrom, t) and | ||
reached(nodeTo, result) and | ||
result = t.append(summary) | ||
result = append(t, summary) | ||
) | ||
or | ||
additionalStep(nodeFrom, nodeTo) and | ||
|
@@ -195,7 +195,7 @@ private module StringTypeTrackInput implements TypeTrackInputSig { | |
* This is used to figure out where `start` is evaluated as a regular expression against an input string, | ||
* or where `start` is compiled into a regular expression. | ||
*/ | ||
private predicate trackStrings = TypeTrack<StringTypeTrackInput>::track/2; | ||
private predicate trackStrings = PrunedTypeTrack<StringTypeTrackInput>::track/2; | ||
|
||
/** Holds if `strConst` flows to a regex compilation (tracked by `t`), where the resulting regular expression is stored in `reg`. */ | ||
pragma[nomagic] | ||
|
@@ -222,7 +222,7 @@ private module RegTypeTrackInput implements TypeTrackInputSig { | |
* Gets a node that has been tracked from the regular expression `start` to some node. | ||
* This is used to figure out where `start` is executed against an input string. | ||
*/ | ||
private predicate trackRegs = TypeTrack<RegTypeTrackInput>::track/2; | ||
private predicate trackRegs = PrunedTypeTrack<RegTypeTrackInput>::track/2; | ||
|
||
/** Gets a node that references a regular expression. */ | ||
private DataFlow::LocalSourceNode trackRegexpType(TypeTracker t) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change correct? Were the parameters of
backtrack
swapped? We might want to check that all the places where we usebacktrack
are still correct.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is because the shared library (which defines
step
) has the arguments reversed. I decided to keep the order as-is inbacktrack
.