Merge pull request #14815 from hvitved/type-tracking/param-consistency-checks

Type tracking: Parameterize consistency checks
This commit is contained in:
Tom Hvitved
2023-11-20 11:05:06 +01:00
committed by GitHub
2 changed files with 14 additions and 2 deletions

View File

@@ -124,7 +124,9 @@ private import internal.TypeTrackingImpl as Impl
module TypeTracking<TypeTrackingInput I> {
private module MkImpl = Impl::TypeTracking<I>;
deprecated module ConsistencyChecks = MkImpl::ConsistencyChecks;
private module ConsistencyChecksInput implements MkImpl::ConsistencyChecksInputSig { }
deprecated module ConsistencyChecks = MkImpl::ConsistencyChecks<ConsistencyChecksInput>;
class TypeTracker = MkImpl::TypeTracker;

View File

@@ -17,8 +17,16 @@ private import codeql.typetracking.TypeTracking
module TypeTracking<TypeTrackingInput I> {
private import I
signature module ConsistencyChecksInputSig {
/** Holds if `n` should be excluded from the consistency test `unreachableNode`. */
default predicate unreachableNodeExclude(Node n) { none() }
/** Holds if `n` should be excluded from the consistency test `nonSourceStoreTarget`. */
default predicate nonSourceStoreTargetExclude(Node n) { none() }
}
/** Provides consistency checks for the type-tracker step relations. */
module ConsistencyChecks {
module ConsistencyChecks<ConsistencyChecksInputSig ConsistencyChecksInput> {
private predicate stepEntry(Node n, string kind) {
simpleLocalSmallStep(n, _) and kind = "simpleLocalSmallStep"
or
@@ -34,6 +42,7 @@ module TypeTracking<TypeTrackingInput I> {
* `LocalSourceNode`.
*/
query predicate unreachableNode(Node n, string msg) {
not ConsistencyChecksInput::unreachableNodeExclude(n) and
exists(string kind |
stepEntry(n, kind) and
not flowsTo(_, n) and
@@ -46,6 +55,7 @@ module TypeTracking<TypeTrackingInput I> {
* backtracking store target feature isn't enabled.
*/
query predicate nonSourceStoreTarget(Node n, string msg) {
not ConsistencyChecksInput::nonSourceStoreTargetExclude(n) and
not hasFeatureBacktrackStoreTarget() and
not n instanceof LocalSourceNode and
(storeStep(_, n, _) or loadStoreStep(_, n, _, _)) and