Address review comments

This commit is contained in:
Tom Hvitved
2024-12-03 09:28:21 +01:00
parent 3e5f4b7f89
commit 52dc79eb7d
4 changed files with 10 additions and 26 deletions

View File

@@ -2,13 +2,13 @@
private import rust
private import internal.FlowSummaryImpl as Impl
private import internal.DataFlowImpl
private import codeql.rust.elements.internal.CallExprBaseImpl::Impl as CallExprBaseImpl
// import all instances below
private module Summaries {
private import codeql.rust.Frameworks
// TODO: Used models-as-data when it's available
// TODO: Use models-as-data when it's available
private class UnwrapSummary extends SummarizedCallable::Range {
UnwrapSummary() { this = "lang:core::_::<crate::option::Option>::unwrap" }
@@ -30,7 +30,7 @@ module LibraryCallable {
/** Gets a call to this library callable. */
CallExprBase getACall() {
exists(Resolvable r, string crate |
r = getCallResolvable(result) and
r = CallExprBaseImpl::getCallResolvable(result) and
this = crate + r.getResolvedPath()
|
crate = r.getResolvedCrateOrigin() + "::_::"

View File

@@ -173,7 +173,7 @@ module Node {
override Location getLocation() { none() }
}
/** A data-flow node used to model flow summaries. */
/** A data flow node used to model flow summaries. */
class FlowSummaryNode extends Node, TFlowSummaryNode {
FlowSummaryImpl::Private::SummaryNode getSummaryNode() { this = TFlowSummaryNode(result) }
@@ -375,10 +375,6 @@ module Node {
/** Gets the node before the state update. */
abstract Node getPreUpdateNode();
override CfgScope getCfgScope() { result = this.getPreUpdateNode().getCfgScope() }
override Location getLocation() { result = this.getPreUpdateNode().getLocation() }
override string toString() { result = "[post] " + this.getPreUpdateNode().toString() }
}
@@ -388,6 +384,10 @@ module Node {
ExprPostUpdateNode() { this = TExprPostUpdateNode(n) }
override Node getPreUpdateNode() { result = TExprNode(n) }
override CfgScope getCfgScope() { result = n.getScope() }
override Location getLocation() { result = n.getLocation() }
}
final class SummaryPostUpdateNode extends FlowSummaryNode, PostUpdateNode {
@@ -399,10 +399,6 @@ module Node {
override Node getPreUpdateNode() { result = pre }
override CfgScope getCfgScope() { result = PostUpdateNode.super.getCfgScope() }
override EmptyLocation getLocation() { result = PostUpdateNode.super.getLocation() }
final override string toString() { result = PostUpdateNode.super.toString() }
}
@@ -689,13 +685,6 @@ private module Aliases {
class ContentSetAlias = ContentSet;
}
pragma[nomagic]
Resolvable getCallResolvable(CallExprBase call) {
result = call.(MethodCallExpr)
or
result = call.(CallExpr).getFunction().(PathExpr).getPath()
}
module RustDataFlow implements InputSig<Location> {
private import Aliases

View File

@@ -15,12 +15,7 @@ module Input implements InputSig<Location, RustDataFlow> {
ReturnKind getStandardReturnValueKind() { result = TNormalReturnKind() }
string encodeParameterPosition(ParameterPosition pos) {
result = pos.getPosition().toString()
or
pos.isSelf() and
result = "self"
}
string encodeParameterPosition(ParameterPosition pos) { result = pos.toString() }
predicate encodeArgumentPosition = encodeParameterPosition/1;

View File

@@ -17,7 +17,7 @@ module Impl {
private import codeql.rust.elements.internal.PathExprImpl::Impl
pragma[nomagic]
private Resolvable getCallResolvable(CallExprBase call) {
Resolvable getCallResolvable(CallExprBase call) {
result = call.(MethodCallExpr)
or
result = call.(CallExpr).getFunction().(PathExpr).getPath()