mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Merge branch 'main' into redsun82/rust-macro
This commit is contained in:
@@ -22,16 +22,21 @@ extensions:
|
||||
- ["actions/stale", "pull-requests: write"]
|
||||
- ["actions/attest-build-provenance", "id-token: write"]
|
||||
- ["actions/attest-build-provenance", "attestations: write"]
|
||||
- ["actions/deploy-pages", "pages: write"]
|
||||
- ["actions/deploy-pages", "id-token: write"]
|
||||
- ["actions/delete-package-versions", "packages: write"]
|
||||
- ["actions/jekyll-build-pages", "contents: read"]
|
||||
- ["actions/jekyll-build-pages", "pages: write"]
|
||||
- ["actions/jekyll-build-pages", "id-token: write"]
|
||||
- ["actions/publish-action", "contents: write"]
|
||||
- ["actions/versions-package-tools", "contents: read"]
|
||||
- ["actions/versions-package-tools", "contents: read"]
|
||||
- ["actions/versions-package-tools", "actions: read"]
|
||||
- ["actions/reusable-workflows", "contents: read"]
|
||||
- ["actions/reusable-workflows", "contents: read"]
|
||||
- ["actions/reusable-workflows", "actions: read"]
|
||||
- ["actions/ai-inference", "contents: read"]
|
||||
- ["actions/ai-inference", "models: read"]
|
||||
# TODO: Add permissions for actions/download-artifact
|
||||
# TODO: Add permissions for actions/upload-artifact
|
||||
# No permissions needed for actions/upload-pages-artifact
|
||||
# TODO: Add permissions for actions/cache
|
||||
|
||||
|
||||
# No permissions needed for actions/configure-pages
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* The query `actions/missing-workflow-permissions` is now aware of the minimal permissions needed for the actions `deploy-pages`, `delete-package-versions`, `ai-inference`. This should lead to better alert messages and better fix suggestions.
|
||||
10
actions/ql/test/query-tests/Security/CWE-275/.github/workflows/perms10.yml
vendored
Normal file
10
actions/ql/test/query-tests/Security/CWE-275/.github/workflows/perms10.yml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
on:
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build and test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/ai-inference
|
||||
10
actions/ql/test/query-tests/Security/CWE-275/.github/workflows/perms8.yml
vendored
Normal file
10
actions/ql/test/query-tests/Security/CWE-275/.github/workflows/perms8.yml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
on:
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build and test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/deploy-pages
|
||||
10
actions/ql/test/query-tests/Security/CWE-275/.github/workflows/perms9.yml
vendored
Normal file
10
actions/ql/test/query-tests/Security/CWE-275/.github/workflows/perms9.yml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
on:
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build and test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/delete-package-versions
|
||||
@@ -3,3 +3,6 @@
|
||||
| .github/workflows/perms5.yml:7:5:10:32 | Job: build | Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read} |
|
||||
| .github/workflows/perms6.yml:7:5:11:39 | Job: build | Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read, id-token: write, pages: write} |
|
||||
| .github/workflows/perms7.yml:7:5:10:38 | Job: build | Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {} |
|
||||
| .github/workflows/perms8.yml:7:5:10:33 | Job: build | Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {id-token: write, pages: write} |
|
||||
| .github/workflows/perms9.yml:7:5:10:44 | Job: build | Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {packages: write} |
|
||||
| .github/workflows/perms10.yml:7:5:10:33 | Job: build | Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read, models: read} |
|
||||
|
||||
@@ -22,7 +22,11 @@ module Input implements InputSig<Location, DataFlowImplSpecific::CppDataFlow> {
|
||||
|
||||
ArgumentPosition callbackSelfParameterPosition() { result = TDirectPosition(-1) }
|
||||
|
||||
ReturnKind getStandardReturnValueKind() { result.(NormalReturnKind).getIndirectionIndex() = 0 }
|
||||
ReturnKind getStandardReturnValueKind() { result = getReturnValueKind("") }
|
||||
|
||||
ReturnKind getReturnValueKind(string arg) {
|
||||
arg = repeatStars(result.(NormalReturnKind).getIndirectionIndex())
|
||||
}
|
||||
|
||||
string encodeParameterPosition(ParameterPosition pos) { result = pos.toString() }
|
||||
|
||||
|
||||
@@ -1903,6 +1903,10 @@ module IteratorFlow {
|
||||
predicate allowFlowIntoUncertainDef(IteratorSsa::UncertainWriteDefinition def) { any() }
|
||||
|
||||
class Guard extends Void {
|
||||
predicate hasBranchEdge(SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, boolean branch) {
|
||||
none()
|
||||
}
|
||||
|
||||
predicate controlsBranchEdge(
|
||||
SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, boolean branch
|
||||
) {
|
||||
|
||||
@@ -991,13 +991,17 @@ private module DataFlowIntegrationInput implements SsaImpl::DataFlowIntegrationI
|
||||
class Guard instanceof IRGuards::IRGuardCondition {
|
||||
string toString() { result = super.toString() }
|
||||
|
||||
predicate controlsBranchEdge(SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, boolean branch) {
|
||||
predicate hasBranchEdge(SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, boolean branch) {
|
||||
exists(EdgeKind kind |
|
||||
super.getBlock() = bb1 and
|
||||
kind = getConditionalEdge(branch) and
|
||||
bb1.getSuccessor(kind) = bb2
|
||||
)
|
||||
}
|
||||
|
||||
predicate controlsBranchEdge(SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, boolean branch) {
|
||||
this.hasBranchEdge(bb1, bb2, branch)
|
||||
}
|
||||
}
|
||||
|
||||
predicate guardDirectlyControlsBlock(Guard guard, SsaInput::BasicBlock bb, boolean branch) {
|
||||
|
||||
@@ -264,10 +264,6 @@ module SemanticExprConfig {
|
||||
|
||||
Guard comparisonGuard(Expr e) { getSemanticExpr(result) = e }
|
||||
|
||||
predicate implies_v2(Guard g1, boolean b1, Guard g2, boolean b2) {
|
||||
none() // TODO
|
||||
}
|
||||
|
||||
/** Gets the expression associated with `instr`. */
|
||||
SemExpr getSemanticExpr(IR::Instruction instr) { result = instr }
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ class SemGuard instanceof Specific::Guard {
|
||||
Specific::equalityGuard(this, e1, e2, polarity)
|
||||
}
|
||||
|
||||
final predicate directlyControls(SemBasicBlock controlled, boolean branch) {
|
||||
final predicate controls(SemBasicBlock controlled, boolean branch) {
|
||||
Specific::guardDirectlyControlsBlock(this, controlled, branch)
|
||||
}
|
||||
|
||||
final predicate hasBranchEdge(SemBasicBlock bb1, SemBasicBlock bb2, boolean branch) {
|
||||
final predicate controlsBranchEdge(SemBasicBlock bb1, SemBasicBlock bb2, boolean branch) {
|
||||
Specific::guardHasBranchEdge(this, bb1, bb2, branch)
|
||||
}
|
||||
|
||||
@@ -31,8 +31,4 @@ class SemGuard instanceof Specific::Guard {
|
||||
final SemExpr asExpr() { result = Specific::getGuardAsExpr(this) }
|
||||
}
|
||||
|
||||
predicate semImplies_v2(SemGuard g1, boolean b1, SemGuard g2, boolean b2) {
|
||||
Specific::implies_v2(g1, b1, g2, b2)
|
||||
}
|
||||
|
||||
SemGuard semGetComparisonGuard(SemRelationalExpr e) { result = Specific::comparisonGuard(e) }
|
||||
|
||||
@@ -77,8 +77,6 @@ module Sem implements Semantic<SemLocation> {
|
||||
|
||||
class Guard = SemGuard;
|
||||
|
||||
predicate implies_v2 = semImplies_v2/4;
|
||||
|
||||
class Type = SemType;
|
||||
|
||||
class IntegerType = SemIntegerType;
|
||||
|
||||
@@ -56,9 +56,9 @@ void test_sources() {
|
||||
sink(v_direct); // $ ir
|
||||
|
||||
sink(remoteMadSourceIndirect());
|
||||
sink(*remoteMadSourceIndirect()); // $ MISSING: ir
|
||||
sink(*remoteMadSourceIndirect()); // $ ir
|
||||
sink(*remoteMadSourceDoubleIndirect());
|
||||
sink(**remoteMadSourceDoubleIndirect()); // $ MISSING: ir
|
||||
sink(**remoteMadSourceDoubleIndirect()); // $ ir
|
||||
|
||||
int a, b, c, d;
|
||||
|
||||
@@ -124,7 +124,7 @@ void test_sinks() {
|
||||
// test sources + sinks together
|
||||
|
||||
madSinkArg0(localMadSource()); // $ ir
|
||||
madSinkIndirectArg0(remoteMadSourceIndirect()); // $ MISSING: ir
|
||||
madSinkIndirectArg0(remoteMadSourceIndirect()); // $ ir
|
||||
madSinkVar = remoteMadSourceVar; // $ ir
|
||||
*madSinkVarIndirect = remoteMadSourceVar; // $ MISSING: ir
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ private predicate valueFlowStepSsa(SsaVariable v, SsaReadPosition pos, Expr e, i
|
||||
exists(Guard guard, boolean testIsTrue |
|
||||
pos.hasReadOfVar(v) and
|
||||
guard = eqFlowCond(v, e, delta, true, testIsTrue) and
|
||||
guardDirectlyControlsSsaRead(guard, pos, testIsTrue)
|
||||
guardControlsSsaRead(guard, pos, testIsTrue)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1044,17 +1044,25 @@ private module DataFlowIntegrationInput implements Impl::DataFlowIntegrationInpu
|
||||
|
||||
class Guard extends Guards::Guard {
|
||||
/**
|
||||
* Holds if the control flow branching from `bb1` is dependent on this guard,
|
||||
* and that the edge from `bb1` to `bb2` corresponds to the evaluation of this
|
||||
* guard to `branch`.
|
||||
* Holds if the evaluation of this guard to `branch` corresponds to the edge
|
||||
* from `bb1` to `bb2`.
|
||||
*/
|
||||
predicate controlsBranchEdge(BasicBlock bb1, BasicBlock bb2, boolean branch) {
|
||||
predicate hasBranchEdge(BasicBlock bb1, BasicBlock bb2, boolean branch) {
|
||||
exists(ControlFlow::SuccessorTypes::ConditionalSuccessor s |
|
||||
this.getAControlFlowNode() = bb1.getLastNode() and
|
||||
bb2 = bb1.getASuccessorByType(s) and
|
||||
s.getValue() = branch
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this guard evaluating to `branch` controls the control-flow
|
||||
* branch edge from `bb1` to `bb2`. That is, following the edge from
|
||||
* `bb1` to `bb2` implies that this guard evaluated to `branch`.
|
||||
*/
|
||||
predicate controlsBranchEdge(BasicBlock bb1, BasicBlock bb2, boolean branch) {
|
||||
this.hasBranchEdge(bb1, bb2, branch)
|
||||
}
|
||||
}
|
||||
|
||||
/** Holds if the guard `guard` controls block `bb` upon evaluating to `branch`. */
|
||||
|
||||
@@ -32,8 +32,6 @@ module Private {
|
||||
|
||||
class LeftShiftExpr = RU::ExprNode::LeftShiftExpr;
|
||||
|
||||
predicate guardDirectlyControlsSsaRead = RU::guardControlsSsaRead/3;
|
||||
|
||||
predicate guardControlsSsaRead = RU::guardControlsSsaRead/3;
|
||||
|
||||
predicate valueFlowStep = RU::valueFlowStep/3;
|
||||
|
||||
@@ -145,7 +145,7 @@ private predicate isNonFallThroughPredecessor(SwitchCase sc, ControlFlowNode pre
|
||||
* Evaluating a switch case to true corresponds to taking that switch case, and
|
||||
* evaluating it to false corresponds to taking some other branch.
|
||||
*/
|
||||
class Guard extends ExprParent {
|
||||
final class Guard extends ExprParent {
|
||||
Guard() {
|
||||
this.(Expr).getType() instanceof BooleanType and not this instanceof BooleanLiteral
|
||||
or
|
||||
@@ -272,6 +272,15 @@ class Guard extends ExprParent {
|
||||
preconditionControls(this, controlled, branch)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this guard evaluating to `branch` controls the control-flow
|
||||
* branch edge from `bb1` to `bb2`. That is, following the edge from
|
||||
* `bb1` to `bb2` implies that this guard evaluated to `branch`.
|
||||
*/
|
||||
predicate controlsBranchEdge(BasicBlock bb1, BasicBlock bb2, boolean branch) {
|
||||
guardControlsBranchEdge_v3(this, bb1, bb2, branch)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this guard evaluating to `branch` directly or indirectly controls
|
||||
* the block `controlled`. That is, the evaluation of `controlled` is
|
||||
@@ -351,6 +360,51 @@ private predicate guardControls_v3(Guard guard, BasicBlock controlled, boolean b
|
||||
)
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
private predicate guardControlsBranchEdge_v2(
|
||||
Guard guard, BasicBlock bb1, BasicBlock bb2, boolean branch
|
||||
) {
|
||||
guard.hasBranchEdge(bb1, bb2, branch)
|
||||
or
|
||||
exists(Guard g, boolean b |
|
||||
guardControlsBranchEdge_v2(g, bb1, bb2, b) and
|
||||
implies_v2(g, b, guard, branch)
|
||||
)
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
private predicate guardControlsBranchEdge_v3(
|
||||
Guard guard, BasicBlock bb1, BasicBlock bb2, boolean branch
|
||||
) {
|
||||
guard.hasBranchEdge(bb1, bb2, branch)
|
||||
or
|
||||
exists(Guard g, boolean b |
|
||||
guardControlsBranchEdge_v3(g, bb1, bb2, b) and
|
||||
implies_v3(g, b, guard, branch)
|
||||
)
|
||||
}
|
||||
|
||||
/** INTERNAL: Use `Guard` instead. */
|
||||
final class Guard_v2 extends Guard {
|
||||
/**
|
||||
* Holds if this guard evaluating to `branch` controls the control-flow
|
||||
* branch edge from `bb1` to `bb2`. That is, following the edge from
|
||||
* `bb1` to `bb2` implies that this guard evaluated to `branch`.
|
||||
*/
|
||||
predicate controlsBranchEdge(BasicBlock bb1, BasicBlock bb2, boolean branch) {
|
||||
guardControlsBranchEdge_v2(this, bb1, bb2, branch)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this guard evaluating to `branch` directly or indirectly controls
|
||||
* the block `controlled`. That is, the evaluation of `controlled` is
|
||||
* dominated by this guard evaluating to `branch`.
|
||||
*/
|
||||
predicate controls(BasicBlock controlled, boolean branch) {
|
||||
guardControls_v2(this, controlled, branch)
|
||||
}
|
||||
}
|
||||
|
||||
private predicate equalityGuard(Guard g, Expr e1, Expr e2, boolean polarity) {
|
||||
exists(EqualityTest eqtest |
|
||||
eqtest = g and
|
||||
|
||||
@@ -17,7 +17,7 @@ private predicate valueFlowStepSsa(SsaVariable v, SsaReadPosition pos, Expr e, i
|
||||
exists(Guard guard, boolean testIsTrue |
|
||||
pos.hasReadOfVar(v) and
|
||||
guard = eqFlowCond(v, e, delta, true, testIsTrue) and
|
||||
guardDirectlyControlsSsaRead(guard, pos, testIsTrue)
|
||||
guardControlsSsaRead(guard, pos, testIsTrue)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -219,16 +219,10 @@ module Sem implements Semantic<Location> {
|
||||
|
||||
int getBlockId1(BasicBlock bb) { idOf(bb, result) }
|
||||
|
||||
final private class FinalGuard = GL::Guard;
|
||||
|
||||
class Guard extends FinalGuard {
|
||||
class Guard extends GL::Guard_v2 {
|
||||
Expr asExpr() { result = this }
|
||||
}
|
||||
|
||||
predicate implies_v2(Guard g1, boolean b1, Guard g2, boolean b2) {
|
||||
GL::implies_v2(g1, b1, g2, b2)
|
||||
}
|
||||
|
||||
class Type = J::Type;
|
||||
|
||||
class IntegerType extends J::IntegralType {
|
||||
|
||||
@@ -19,8 +19,6 @@ predicate ssaUpdateStep = U::ssaUpdateStep/3;
|
||||
|
||||
predicate valueFlowStep = U::valueFlowStep/3;
|
||||
|
||||
predicate guardDirectlyControlsSsaRead = U::guardDirectlyControlsSsaRead/3;
|
||||
|
||||
predicate guardControlsSsaRead = U::guardControlsSsaRead/3;
|
||||
|
||||
predicate eqFlowCond = U::eqFlowCond/5;
|
||||
|
||||
@@ -654,16 +654,7 @@ private module DataFlowIntegrationInput implements Impl::DataFlowIntegrationInpu
|
||||
def instanceof SsaUncertainImplicitUpdate
|
||||
}
|
||||
|
||||
class Guard extends Guards::Guard {
|
||||
/**
|
||||
* Holds if the control flow branching from `bb1` is dependent on this guard,
|
||||
* and that the edge from `bb1` to `bb2` corresponds to the evaluation of this
|
||||
* guard to `branch`.
|
||||
*/
|
||||
predicate controlsBranchEdge(BasicBlock bb1, BasicBlock bb2, boolean branch) {
|
||||
super.hasBranchEdge(bb1, bb2, branch)
|
||||
}
|
||||
}
|
||||
class Guard = Guards::Guard;
|
||||
|
||||
/** Holds if the guard `guard` directly controls block `bb` upon evaluating to `branch`. */
|
||||
predicate guardDirectlyControlsBlock(Guard guard, BasicBlock bb, boolean branch) {
|
||||
|
||||
@@ -4,7 +4,6 @@ module Private {
|
||||
private import semmle.code.java.dataflow.RangeUtils as RU
|
||||
private import semmle.code.java.controlflow.Guards as G
|
||||
private import semmle.code.java.controlflow.BasicBlocks as BB
|
||||
private import semmle.code.java.controlflow.internal.GuardsLogic as GL
|
||||
private import SsaReadPositionCommon
|
||||
|
||||
class BasicBlock = BB::BasicBlock;
|
||||
@@ -15,7 +14,7 @@ module Private {
|
||||
|
||||
class Expr = J::Expr;
|
||||
|
||||
class Guard = G::Guard;
|
||||
class Guard = G::Guard_v2;
|
||||
|
||||
class ConstantIntegerExpr = RU::ConstantIntegerExpr;
|
||||
|
||||
@@ -101,29 +100,17 @@ module Private {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `guard` directly controls the position `controlled` with the
|
||||
* value `testIsTrue`.
|
||||
*/
|
||||
pragma[nomagic]
|
||||
predicate guardDirectlyControlsSsaRead(Guard guard, SsaReadPosition controlled, boolean testIsTrue) {
|
||||
guard.directlyControls(controlled.(SsaReadPositionBlock).getBlock(), testIsTrue)
|
||||
or
|
||||
exists(SsaReadPositionPhiInputEdge controlledEdge | controlledEdge = controlled |
|
||||
guard.directlyControls(controlledEdge.getOrigBlock(), testIsTrue) or
|
||||
guard.hasBranchEdge(controlledEdge.getOrigBlock(), controlledEdge.getPhiBlock(), testIsTrue)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `guard` controls the position `controlled` with the value `testIsTrue`.
|
||||
*/
|
||||
predicate guardControlsSsaRead(Guard guard, SsaReadPosition controlled, boolean testIsTrue) {
|
||||
guardDirectlyControlsSsaRead(guard, controlled, testIsTrue)
|
||||
guard.controls(controlled.(SsaReadPositionBlock).getBlock(), testIsTrue)
|
||||
or
|
||||
exists(Guard guard0, boolean testIsTrue0 |
|
||||
GL::implies_v2(guard0, testIsTrue0, guard, testIsTrue) and
|
||||
guardControlsSsaRead(guard0, controlled, testIsTrue0)
|
||||
exists(SsaReadPositionPhiInputEdge controlledEdge | controlledEdge = controlled |
|
||||
guard.controls(controlledEdge.getOrigBlock(), testIsTrue) or
|
||||
guard
|
||||
.controlsBranchEdge(controlledEdge.getOrigBlock(), controlledEdge.getPhiBlock(),
|
||||
testIsTrue)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -7,13 +7,12 @@ module Private {
|
||||
private import semmle.code.java.dataflow.SSA as Ssa
|
||||
private import semmle.code.java.controlflow.Guards as G
|
||||
private import SsaReadPositionCommon
|
||||
private import semmle.code.java.controlflow.internal.GuardsLogic as GL
|
||||
private import Sign
|
||||
import Impl
|
||||
|
||||
class ConstantIntegerExpr = RU::ConstantIntegerExpr;
|
||||
|
||||
class Guard = G::Guard;
|
||||
class Guard = G::Guard_v2;
|
||||
|
||||
class SsaVariable = Ssa::SsaVariable;
|
||||
|
||||
@@ -170,31 +169,17 @@ module Private {
|
||||
|
||||
predicate ssaRead = RU::ssaRead/2;
|
||||
|
||||
/**
|
||||
* Holds if `guard` directly controls the position `controlled` with the
|
||||
* value `testIsTrue`.
|
||||
*/
|
||||
pragma[nomagic]
|
||||
private predicate guardDirectlyControlsSsaRead(
|
||||
Guard guard, SsaReadPosition controlled, boolean testIsTrue
|
||||
) {
|
||||
guard.directlyControls(controlled.(SsaReadPositionBlock).getBlock(), testIsTrue)
|
||||
or
|
||||
exists(SsaReadPositionPhiInputEdge controlledEdge | controlledEdge = controlled |
|
||||
guard.directlyControls(controlledEdge.getOrigBlock(), testIsTrue) or
|
||||
guard.hasBranchEdge(controlledEdge.getOrigBlock(), controlledEdge.getPhiBlock(), testIsTrue)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `guard` controls the position `controlled` with the value `testIsTrue`.
|
||||
*/
|
||||
predicate guardControlsSsaRead(Guard guard, SsaReadPosition controlled, boolean testIsTrue) {
|
||||
guardDirectlyControlsSsaRead(guard, controlled, testIsTrue)
|
||||
guard.controls(controlled.(SsaReadPositionBlock).getBlock(), testIsTrue)
|
||||
or
|
||||
exists(Guard guard0, boolean testIsTrue0 |
|
||||
GL::implies_v2(guard0, testIsTrue0, guard, testIsTrue) and
|
||||
guardControlsSsaRead(guard0, controlled, testIsTrue0)
|
||||
exists(SsaReadPositionPhiInputEdge controlledEdge | controlledEdge = controlled |
|
||||
guard.controls(controlledEdge.getOrigBlock(), testIsTrue) or
|
||||
guard
|
||||
.controlsBranchEdge(controlledEdge.getOrigBlock(), controlledEdge.getPhiBlock(),
|
||||
testIsTrue)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,11 +75,10 @@ module SsaDataflowInput implements DataFlowIntegrationInputSig {
|
||||
Guard() { this = any(js::ConditionGuardNode g).getTest() }
|
||||
|
||||
/**
|
||||
* Holds if the control flow branching from `bb1` is dependent on this guard,
|
||||
* and that the edge from `bb1` to `bb2` corresponds to the evaluation of this
|
||||
* guard to `branch`.
|
||||
* Holds if the evaluation of this guard to `branch` corresponds to the edge
|
||||
* from `bb1` to `bb2`.
|
||||
*/
|
||||
predicate controlsBranchEdge(js::BasicBlock bb1, js::BasicBlock bb2, boolean branch) {
|
||||
predicate hasBranchEdge(js::BasicBlock bb1, js::BasicBlock bb2, boolean branch) {
|
||||
exists(js::ConditionGuardNode g |
|
||||
g.getTest() = this and
|
||||
bb1 = this.getBasicBlock() and
|
||||
@@ -87,6 +86,15 @@ module SsaDataflowInput implements DataFlowIntegrationInputSig {
|
||||
branch = g.getOutcome()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this guard evaluating to `branch` controls the control-flow
|
||||
* branch edge from `bb1` to `bb2`. That is, following the edge from
|
||||
* `bb1` to `bb2` implies that this guard evaluated to `branch`.
|
||||
*/
|
||||
predicate controlsBranchEdge(js::BasicBlock bb1, js::BasicBlock bb2, boolean branch) {
|
||||
this.hasBranchEdge(bb1, bb2, branch)
|
||||
}
|
||||
}
|
||||
|
||||
pragma[inline]
|
||||
|
||||
@@ -484,17 +484,25 @@ private module DataFlowIntegrationInput implements Impl::DataFlowIntegrationInpu
|
||||
|
||||
class Guard extends Cfg::CfgNodes::AstCfgNode {
|
||||
/**
|
||||
* Holds if the control flow branching from `bb1` is dependent on this guard,
|
||||
* and that the edge from `bb1` to `bb2` corresponds to the evaluation of this
|
||||
* guard to `branch`.
|
||||
* Holds if the evaluation of this guard to `branch` corresponds to the edge
|
||||
* from `bb1` to `bb2`.
|
||||
*/
|
||||
predicate controlsBranchEdge(SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, boolean branch) {
|
||||
predicate hasBranchEdge(SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, boolean branch) {
|
||||
exists(Cfg::SuccessorTypes::ConditionalSuccessor s |
|
||||
this.getBasicBlock() = bb1 and
|
||||
bb2 = bb1.getASuccessor(s) and
|
||||
s.getValue() = branch
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this guard evaluating to `branch` controls the control-flow
|
||||
* branch edge from `bb1` to `bb2`. That is, following the edge from
|
||||
* `bb1` to `bb2` implies that this guard evaluated to `branch`.
|
||||
*/
|
||||
predicate controlsBranchEdge(SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, boolean branch) {
|
||||
this.hasBranchEdge(bb1, bb2, branch)
|
||||
}
|
||||
}
|
||||
|
||||
/** Holds if the guard `guard` controls block `bb` upon evaluating to `branch`. */
|
||||
|
||||
@@ -36,8 +36,9 @@ impl Translator<'_> {
|
||||
|
||||
pub(crate) fn emit_{{snake_case_name}}(&mut self, node: &ast::{{ast_name}}) -> Option<Label<generated::{{name}}>> {
|
||||
pre_emit!({{name}}, self, node);
|
||||
{{#has_attrs}}
|
||||
if self.should_be_excluded(node) { return None; }
|
||||
{{#has_attrs}}
|
||||
if self.should_be_excluded_attrs(node) { return None; }
|
||||
{{/has_attrs}}
|
||||
{{#fields}}
|
||||
{{#predicate}}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
description: Remove 'module' from Crate
|
||||
compatibility: breaking
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,5 @@
|
||||
use crate::config::Config;
|
||||
use crate::translate::SourceKind;
|
||||
use anyhow::Context;
|
||||
use chrono::{DateTime, Utc};
|
||||
use ra_ap_project_model::ProjectManifest;
|
||||
@@ -83,6 +84,8 @@ pub enum ExtractionStepKind {
|
||||
LoadSource,
|
||||
Parse,
|
||||
Extract,
|
||||
ParseLibrary,
|
||||
ExtractLibrary,
|
||||
CrateGraph,
|
||||
}
|
||||
|
||||
@@ -113,18 +116,24 @@ impl ExtractionStep {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn parse(start: Instant, target: &Path) -> Self {
|
||||
pub fn parse(start: Instant, source_kind: SourceKind, target: &Path) -> Self {
|
||||
Self::new(
|
||||
start,
|
||||
ExtractionStepKind::Parse,
|
||||
match source_kind {
|
||||
SourceKind::Source => ExtractionStepKind::Parse,
|
||||
SourceKind::Library => ExtractionStepKind::ParseLibrary,
|
||||
},
|
||||
Some(PathBuf::from(target)),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn extract(start: Instant, target: &Path) -> Self {
|
||||
pub fn extract(start: Instant, source_kind: SourceKind, target: &Path) -> Self {
|
||||
Self::new(
|
||||
start,
|
||||
ExtractionStepKind::Extract,
|
||||
match source_kind {
|
||||
SourceKind::Source => ExtractionStepKind::Extract,
|
||||
SourceKind::Library => ExtractionStepKind::ExtractLibrary,
|
||||
},
|
||||
Some(PathBuf::from(target)),
|
||||
)
|
||||
}
|
||||
|
||||
2
rust/extractor/src/generated/.generated.list
generated
2
rust/extractor/src/generated/.generated.list
generated
@@ -1,2 +1,2 @@
|
||||
mod.rs 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7
|
||||
top.rs 7d0c7b324631207a5f0f89649634431b6fe6f27610a31be118f0dc90c17314f7 7d0c7b324631207a5f0f89649634431b6fe6f27610a31be118f0dc90c17314f7
|
||||
top.rs 7f8a694078bc0cde1ce420544d0cf5b83bb297dd29ee4f9d7bcbb1572f0e815a 7f8a694078bc0cde1ce420544d0cf5b83bb297dd29ee4f9d7bcbb1572f0e815a
|
||||
|
||||
4
rust/extractor/src/generated/top.rs
generated
4
rust/extractor/src/generated/top.rs
generated
@@ -154,7 +154,6 @@ pub struct Crate {
|
||||
pub id: trap::TrapId<Crate>,
|
||||
pub name: Option<String>,
|
||||
pub version: Option<String>,
|
||||
pub module: Option<trap::Label<Module>>,
|
||||
pub cfg_options: Vec<String>,
|
||||
pub named_dependencies: Vec<trap::Label<NamedCrate>>,
|
||||
}
|
||||
@@ -172,9 +171,6 @@ impl trap::TrapEntry for Crate {
|
||||
if let Some(v) = self.version {
|
||||
out.add_tuple("crate_versions", vec![id.into(), v.into()]);
|
||||
}
|
||||
if let Some(v) = self.module {
|
||||
out.add_tuple("crate_modules", vec![id.into(), v.into()]);
|
||||
}
|
||||
for (i, v) in self.cfg_options.into_iter().enumerate() {
|
||||
out.add_tuple("crate_cfg_options", vec![id.into(), i.into(), v.into()]);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
use crate::diagnostics::{ExtractionStep, emit_extraction_diagnostics};
|
||||
use crate::rust_analyzer::path_to_file_id;
|
||||
use crate::translate::ResolvePaths;
|
||||
use crate::translate::{ResolvePaths, SourceKind};
|
||||
use crate::trap::TrapId;
|
||||
use anyhow::Context;
|
||||
use archive::Archiver;
|
||||
use ra_ap_base_db::SourceDatabase;
|
||||
use ra_ap_hir::Semantics;
|
||||
use ra_ap_ide_db::RootDatabase;
|
||||
use ra_ap_ide_db::line_index::{LineCol, LineIndex};
|
||||
@@ -12,6 +13,8 @@ use ra_ap_paths::{AbsPathBuf, Utf8PathBuf};
|
||||
use ra_ap_project_model::{CargoConfig, ProjectManifest};
|
||||
use ra_ap_vfs::Vfs;
|
||||
use rust_analyzer::{ParseResult, RustAnalyzer};
|
||||
use std::collections::HashSet;
|
||||
use std::hash::RandomState;
|
||||
use std::time::Instant;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
@@ -47,9 +50,14 @@ impl<'a> Extractor<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn extract(&mut self, rust_analyzer: &RustAnalyzer, file: &Path, resolve_paths: ResolvePaths) {
|
||||
fn extract(
|
||||
&mut self,
|
||||
rust_analyzer: &RustAnalyzer,
|
||||
file: &Path,
|
||||
resolve_paths: ResolvePaths,
|
||||
source_kind: SourceKind,
|
||||
) {
|
||||
self.archiver.archive(file);
|
||||
|
||||
let before_parse = Instant::now();
|
||||
let ParseResult {
|
||||
ast,
|
||||
@@ -57,7 +65,8 @@ impl<'a> Extractor<'a> {
|
||||
errors,
|
||||
semantics_info,
|
||||
} = rust_analyzer.parse(file);
|
||||
self.steps.push(ExtractionStep::parse(before_parse, file));
|
||||
self.steps
|
||||
.push(ExtractionStep::parse(before_parse, source_kind, file));
|
||||
|
||||
let before_extract = Instant::now();
|
||||
let line_index = LineIndex::new(text.as_ref());
|
||||
@@ -71,6 +80,7 @@ impl<'a> Extractor<'a> {
|
||||
line_index,
|
||||
semantics_info.as_ref().ok(),
|
||||
resolve_paths,
|
||||
source_kind,
|
||||
);
|
||||
|
||||
for err in errors {
|
||||
@@ -101,7 +111,7 @@ impl<'a> Extractor<'a> {
|
||||
)
|
||||
});
|
||||
self.steps
|
||||
.push(ExtractionStep::extract(before_extract, file));
|
||||
.push(ExtractionStep::extract(before_extract, source_kind, file));
|
||||
}
|
||||
|
||||
pub fn extract_with_semantics(
|
||||
@@ -110,15 +120,27 @@ impl<'a> Extractor<'a> {
|
||||
semantics: &Semantics<'_, RootDatabase>,
|
||||
vfs: &Vfs,
|
||||
resolve_paths: ResolvePaths,
|
||||
source_kind: SourceKind,
|
||||
) {
|
||||
self.extract(&RustAnalyzer::new(vfs, semantics), file, resolve_paths);
|
||||
self.extract(
|
||||
&RustAnalyzer::new(vfs, semantics),
|
||||
file,
|
||||
resolve_paths,
|
||||
source_kind,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn extract_without_semantics(&mut self, file: &Path, reason: &str) {
|
||||
pub fn extract_without_semantics(
|
||||
&mut self,
|
||||
file: &Path,
|
||||
source_kind: SourceKind,
|
||||
reason: &str,
|
||||
) {
|
||||
self.extract(
|
||||
&RustAnalyzer::WithoutSemantics { reason },
|
||||
file,
|
||||
ResolvePaths::No,
|
||||
source_kind,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -246,7 +268,7 @@ fn main() -> anyhow::Result<()> {
|
||||
continue 'outer;
|
||||
}
|
||||
}
|
||||
extractor.extract_without_semantics(file, "no manifest found");
|
||||
extractor.extract_without_semantics(file, SourceKind::Source, "no manifest found");
|
||||
}
|
||||
let cwd = cwd()?;
|
||||
let (cargo_config, load_cargo_config) = cfg.to_cargo_config(&cwd);
|
||||
@@ -255,6 +277,8 @@ fn main() -> anyhow::Result<()> {
|
||||
} else {
|
||||
ResolvePaths::Yes
|
||||
};
|
||||
let mut processed_files: HashSet<PathBuf, RandomState> =
|
||||
HashSet::from_iter(files.iter().cloned());
|
||||
for (manifest, files) in map.values().filter(|(_, files)| !files.is_empty()) {
|
||||
if let Some((ref db, ref vfs)) =
|
||||
extractor.load_manifest(manifest, &cargo_config, &load_cargo_config)
|
||||
@@ -267,15 +291,45 @@ fn main() -> anyhow::Result<()> {
|
||||
let semantics = Semantics::new(db);
|
||||
for file in files {
|
||||
match extractor.load_source(file, &semantics, vfs) {
|
||||
Ok(()) => {
|
||||
extractor.extract_with_semantics(file, &semantics, vfs, resolve_paths)
|
||||
Ok(()) => extractor.extract_with_semantics(
|
||||
file,
|
||||
&semantics,
|
||||
vfs,
|
||||
resolve_paths,
|
||||
SourceKind::Source,
|
||||
),
|
||||
Err(reason) => {
|
||||
extractor.extract_without_semantics(file, SourceKind::Source, &reason)
|
||||
}
|
||||
Err(reason) => extractor.extract_without_semantics(file, &reason),
|
||||
};
|
||||
}
|
||||
for (file_id, file) in vfs.iter() {
|
||||
if let Some(file) = file.as_path().map(<_ as AsRef<Path>>::as_ref) {
|
||||
if file.extension().is_some_and(|ext| ext == "rs")
|
||||
&& processed_files.insert(file.to_owned())
|
||||
&& db
|
||||
.source_root(db.file_source_root(file_id).source_root_id(db))
|
||||
.source_root(db)
|
||||
.is_library
|
||||
{
|
||||
extractor.extract_with_semantics(
|
||||
file,
|
||||
&semantics,
|
||||
vfs,
|
||||
ResolvePaths::No,
|
||||
SourceKind::Library,
|
||||
);
|
||||
extractor.archiver.archive(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for file in files {
|
||||
extractor.extract_without_semantics(file, "unable to load manifest");
|
||||
extractor.extract_without_semantics(
|
||||
file,
|
||||
SourceKind::Source,
|
||||
"unable to load manifest",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -286,7 +340,7 @@ fn main() -> anyhow::Result<()> {
|
||||
let entry = entry.context("failed to read builtins directory")?;
|
||||
let path = entry.path();
|
||||
if path.extension().is_some_and(|ext| ext == "rs") {
|
||||
extractor.extract_without_semantics(&path, "");
|
||||
extractor.extract_without_semantics(&path, SourceKind::Library, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,4 +2,4 @@ mod base;
|
||||
mod generated;
|
||||
mod mappings;
|
||||
|
||||
pub use base::{ResolvePaths, Translator};
|
||||
pub use base::{ResolvePaths, SourceKind, Translator};
|
||||
|
||||
@@ -16,7 +16,7 @@ use ra_ap_ide_db::RootDatabase;
|
||||
use ra_ap_ide_db::line_index::{LineCol, LineIndex};
|
||||
use ra_ap_parser::SyntaxKind;
|
||||
use ra_ap_span::TextSize;
|
||||
use ra_ap_syntax::ast::HasName;
|
||||
use ra_ap_syntax::ast::{Const, Fn, HasName, Param, Static};
|
||||
use ra_ap_syntax::{
|
||||
AstNode, NodeOrToken, SyntaxElementChildren, SyntaxError, SyntaxNode, SyntaxToken, TextRange,
|
||||
ast,
|
||||
@@ -101,6 +101,11 @@ pub enum ResolvePaths {
|
||||
Yes,
|
||||
No,
|
||||
}
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
pub enum SourceKind {
|
||||
Source,
|
||||
Library,
|
||||
}
|
||||
|
||||
pub struct Translator<'a> {
|
||||
pub trap: TrapFile,
|
||||
@@ -110,6 +115,7 @@ pub struct Translator<'a> {
|
||||
file_id: Option<EditionedFileId>,
|
||||
pub semantics: Option<&'a Semantics<'a, RootDatabase>>,
|
||||
resolve_paths: bool,
|
||||
source_kind: SourceKind,
|
||||
macro_context_depth: usize,
|
||||
}
|
||||
|
||||
@@ -124,6 +130,7 @@ impl<'a> Translator<'a> {
|
||||
line_index: LineIndex,
|
||||
semantic_info: Option<&FileSemanticInformation<'a>>,
|
||||
resolve_paths: ResolvePaths,
|
||||
source_kind: SourceKind,
|
||||
) -> Translator<'a> {
|
||||
Translator {
|
||||
trap,
|
||||
@@ -133,6 +140,7 @@ impl<'a> Translator<'a> {
|
||||
file_id: semantic_info.map(|i| i.file_id),
|
||||
semantics: semantic_info.map(|i| i.semantics),
|
||||
resolve_paths: resolve_paths == ResolvePaths::Yes,
|
||||
source_kind,
|
||||
macro_context_depth: 0,
|
||||
}
|
||||
}
|
||||
@@ -212,6 +220,14 @@ impl<'a> Translator<'a> {
|
||||
full_message: String,
|
||||
location: (LineCol, LineCol),
|
||||
) {
|
||||
let severity = if self.source_kind == SourceKind::Library {
|
||||
match severity {
|
||||
DiagnosticSeverity::Error => DiagnosticSeverity::Info,
|
||||
_ => DiagnosticSeverity::Debug,
|
||||
}
|
||||
} else {
|
||||
severity
|
||||
};
|
||||
let (start, end) = location;
|
||||
dispatch_to_tracing!(
|
||||
severity,
|
||||
@@ -626,7 +642,7 @@ impl<'a> Translator<'a> {
|
||||
})();
|
||||
}
|
||||
|
||||
pub(crate) fn should_be_excluded(&self, item: &impl ast::HasAttrs) -> bool {
|
||||
pub(crate) fn should_be_excluded_attrs(&self, item: &impl ast::HasAttrs) -> bool {
|
||||
self.semantics.is_some_and(|sema| {
|
||||
item.attrs().any(|attr| {
|
||||
attr.as_simple_call().is_some_and(|(name, tokens)| {
|
||||
@@ -636,6 +652,45 @@ impl<'a> Translator<'a> {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn should_be_excluded(&self, item: &impl ast::AstNode) -> bool {
|
||||
if self.source_kind == SourceKind::Library {
|
||||
let syntax = item.syntax();
|
||||
if syntax
|
||||
.parent()
|
||||
.and_then(Fn::cast)
|
||||
.and_then(|x| x.body())
|
||||
.is_some_and(|body| body.syntax() == syntax)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if syntax
|
||||
.parent()
|
||||
.and_then(Const::cast)
|
||||
.and_then(|x| x.body())
|
||||
.is_some_and(|body| body.syntax() == syntax)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if syntax
|
||||
.parent()
|
||||
.and_then(Static::cast)
|
||||
.and_then(|x| x.body())
|
||||
.is_some_and(|body| body.syntax() == syntax)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if syntax
|
||||
.parent()
|
||||
.and_then(Param::cast)
|
||||
.and_then(|x| x.pat())
|
||||
.is_some_and(|pat| pat.syntax() == syntax)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
pub(crate) fn extract_types_from_path_segment(
|
||||
&mut self,
|
||||
item: &ast::PathSegment,
|
||||
@@ -679,6 +734,10 @@ impl<'a> Translator<'a> {
|
||||
}
|
||||
|
||||
pub(crate) fn emit_item_expansion(&mut self, node: &ast::Item, label: Label<generated::Item>) {
|
||||
// TODO: remove this after fixing exponential expansion on libraries like funty-2.0.0
|
||||
if self.source_kind == SourceKind::Library {
|
||||
return;
|
||||
}
|
||||
(|| {
|
||||
let semantics = self.semantics?;
|
||||
let file = semantics.hir_file_for(node.syntax());
|
||||
|
||||
462
rust/extractor/src/translate/generated.rs
generated
462
rust/extractor/src/translate/generated.rs
generated
File diff suppressed because it is too large
Load Diff
8
rust/ql/.generated.list
generated
8
rust/ql/.generated.list
generated
@@ -43,7 +43,7 @@ lib/codeql/rust/elements/ConstArg.qll f37b34417503bbd2f3ce09b3211d8fa71f6a954970
|
||||
lib/codeql/rust/elements/ConstBlockPat.qll a25f42b84dbeb33e10955735ef53b8bb7e3258522d6d1a9068f19adaf1af89d9 eeb816d2b54db77a1e7bb70e90b68d040a0cd44e9d44455a223311c3615c5e6e
|
||||
lib/codeql/rust/elements/ConstParam.qll 248db1e3abef6943326c42478a15f148f8cdaa25649ef5578064b15924c53351 28babba3aea28a65c3fe3b3db6cb9c86f70d7391e9d6ef9188eb2e4513072f9f
|
||||
lib/codeql/rust/elements/ContinueExpr.qll 9f27c5d5c819ad0ebc5bd10967ba8d33a9dc95b9aae278fcfb1fcf9216bda79c 0dc061445a6b89854fdce92aaf022fdc76b724511a50bb777496ce75c9ecb262
|
||||
lib/codeql/rust/elements/Crate.qll 37e8d0daa7bef38cee51008499ee3fd6c19800c48f23983a82b7b36bae250813 95eb88b896fe01d57627c1766daf0fe859f086aed6ca1184e1e16b10c9cdaf37
|
||||
lib/codeql/rust/elements/Crate.qll 1426960e6f36195e42ea5ea321405c1a72fccd40cd6c0a33673c321c20302d8d 1571a89f89dab43c5291b71386de7aadf52730755ba10f9d696db9ad2f760aff
|
||||
lib/codeql/rust/elements/DynTraitTypeRepr.qll 5953263ec1e77613170c13b5259b22a71c206a7e08841d2fa1a0b373b4014483 d4380c6cc460687dcd8598df27cad954ef4f508f1117a82460d15d295a7b64ab
|
||||
lib/codeql/rust/elements/Element.qll 0b62d139fef54ed2cf2e2334806aa9bfbc036c9c2085d558f15a42cc3fa84c48 24b999b93df79383ef27ede46e38da752868c88a07fe35fcff5d526684ba7294
|
||||
lib/codeql/rust/elements/Enum.qll 2f122b042519d55e221fceac72fce24b30d4caf1947b25e9b68ee4a2095deb11 83a47445145e4fda8c3631db602a42dbb7a431f259eddf5c09dccd86f6abdd0e
|
||||
@@ -503,7 +503,7 @@ lib/codeql/rust/elements/internal/generated/ConstArg.qll e2451cac6ee464f5b64883d
|
||||
lib/codeql/rust/elements/internal/generated/ConstBlockPat.qll 7526d83ee9565d74776f42db58b1a2efff6fb324cfc7137f51f2206fee815d79 0ab3c22908ff790e7092e576a5df3837db33c32a7922a513a0f5e495729c1ac5
|
||||
lib/codeql/rust/elements/internal/generated/ConstParam.qll 310342603959a4d521418caec45b585b97e3a5bf79368769c7150f52596a7266 a5dd92f0b24d7dbdaea2daedba3c8d5f700ec7d3ace81ca368600da2ad610082
|
||||
lib/codeql/rust/elements/internal/generated/ContinueExpr.qll e2010feb14fb6edeb83a991d9357e50edb770172ddfde2e8670b0d3e68169f28 48d09d661e1443002f6d22b8710e22c9c36d9daa9cde09c6366a61e960d717cb
|
||||
lib/codeql/rust/elements/internal/generated/Crate.qll d245f24e9da4f180c526a6d092f554a9577bae7225c81c36a391947c0865eeb3 c95dbb32b2ce4d9664be56c95b19fcd01c2d3244385e55151f9b06b07f04ce9b
|
||||
lib/codeql/rust/elements/internal/generated/Crate.qll 37f3760d7c0c1c3ca809d07daf7215a8eae6053eda05e88ed7db6e07f4db0781 649a3d7cd7ee99f95f8a4d3d3c41ea2fa848ce7d8415ccbac62977dfc9a49d35
|
||||
lib/codeql/rust/elements/internal/generated/DynTraitTypeRepr.qll a9d540717af1f00dbea1c683fd6b846cddfb2968c7f3e021863276f123337787 1972efb9bca7aae9a9708ca6dcf398e5e8c6d2416a07d525dba1649b80fbe4d1
|
||||
lib/codeql/rust/elements/internal/generated/Element.qll d56d22c060fa929464f837b1e16475a4a2a2e42d68235a014f7369bcb48431db 0e48426ca72179f675ac29aa49bbaadb8b1d27b08ad5cbc72ec5a005c291848e
|
||||
lib/codeql/rust/elements/internal/generated/Enum.qll 4f4cbc9cd758c20d476bc767b916c62ba434d1750067d0ffb63e0821bb95ec86 3da735d54022add50cec0217bbf8ec4cf29b47f4851ee327628bcdd6454989d0
|
||||
@@ -578,7 +578,7 @@ lib/codeql/rust/elements/internal/generated/ParamList.qll c808c9d84dd7800573832b
|
||||
lib/codeql/rust/elements/internal/generated/ParenExpr.qll bc0731505bfe88516205ec360582a4222d2681d11342c93e15258590ddee82f2 d4bd6e0c80cf1d63746c88d4bcb3a01d4c75732e5da09e3ebd9437ced227fb60
|
||||
lib/codeql/rust/elements/internal/generated/ParenPat.qll 4f168ef5d5bb87a903251cc31b2e44a759b099ec69c90af31783fbb15778c940 0e34f94a45a13396fd57d94c245dc64d1adde2ab0e22b56946f7e94c04e297fc
|
||||
lib/codeql/rust/elements/internal/generated/ParenTypeRepr.qll 40ab5c592e7699c621787793743e33988de71ff42ca27599f5ab3ddb70e3f7d8 12c0a6eed2202ee3e892f61da3b3ce77ac3190854cdf3097e8d2be98aa3cb91d
|
||||
lib/codeql/rust/elements/internal/generated/ParentChild.qll 2f620064351fc0275ee1c13d1d0681ac927a2af81c13fbb3fae9ef86dd08e585 61cf70eb649f241e2fcd5e0ba34df63f3a14f07032811b9ae151721783a0fd20
|
||||
lib/codeql/rust/elements/internal/generated/ParentChild.qll e2c6aaaa1735113f160c0e178d682bff8e9ebc627632f73c0dd2d1f4f9d692a8 61cf70eb649f241e2fcd5e0ba34df63f3a14f07032811b9ae151721783a0fd20
|
||||
lib/codeql/rust/elements/internal/generated/ParenthesizedArgList.qll c5fa328ea60d3a3333d7c7bb3480969c1873166c7ac8ebb9d0afad7a8099d1a8 2dbbb6200d96f7db7dea4a55bdeab8d67b14d39a43e0bd54ada019f7e466f163
|
||||
lib/codeql/rust/elements/internal/generated/Pat.qll 3605ac062be2f294ee73336e9669027b8b655f4ad55660e1eab35266275154ee 7f9400db2884d336dd1d21df2a8093759c2a110be9bf6482ce8e80ae0fd74ed4
|
||||
lib/codeql/rust/elements/internal/generated/Path.qll 9b12afb46fc5a9ad3a811b05472621bbecccb900c47504feb7f29d96b28421ca bcacbffc36fb3e0c9b26523b5963af0ffa9fd6b19f00a2a31bdb2316071546bd
|
||||
@@ -593,7 +593,7 @@ lib/codeql/rust/elements/internal/generated/PtrTypeRepr.qll 51d1e9e683fc79dddbff
|
||||
lib/codeql/rust/elements/internal/generated/PureSynthConstructors.qll e5b8e69519012bbaae29dcb82d53f7f7ecce368c0358ec27ef6180b228a0057f e5b8e69519012bbaae29dcb82d53f7f7ecce368c0358ec27ef6180b228a0057f
|
||||
lib/codeql/rust/elements/internal/generated/RangeExpr.qll 23cca03bf43535f33b22a38894f70d669787be4e4f5b8fe5c8f7b964d30e9027 18624cef6c6b679eeace2a98737e472432e0ead354cca02192b4d45330f047c9
|
||||
lib/codeql/rust/elements/internal/generated/RangePat.qll 80826a6a6868a803aa2372e31c52a03e1811a3f1f2abdb469f91ca0bfdd9ecb6 34ee1e208c1690cba505dff2c588837c0cd91e185e2a87d1fe673191962276a9
|
||||
lib/codeql/rust/elements/internal/generated/Raw.qll 96e66877688eafb2f901d2790aa3a0d3176d795732fbcd349c3f950016651fdf 855be30b38dd0886938d51219f90e8ce8c4929e23c0f6697f344d5296fbb07cc
|
||||
lib/codeql/rust/elements/internal/generated/Raw.qll de98fe8481864e23e1cd67d926ffd2e8bb8a83ed48901263122068f9c29ab372 3bd67fe283aaf24b94a2e3fd8f6e73ae34f61a097817900925d1cdcd3b745ecc
|
||||
lib/codeql/rust/elements/internal/generated/RefExpr.qll 7d995884e3dc1c25fc719f5d7253179344d63650e217e9ff6530285fe7a57f64 f2c3c12551deea4964b66553fb9b6423ee16fec53bd63db4796191aa60dc6c66
|
||||
lib/codeql/rust/elements/internal/generated/RefPat.qll 456ede39837463ee22a630ec7ab6c8630d3664a8ea206fcc6e4f199e92fa564c 5622062765f32930465ba6b170e986706f159f6070f48adee3c20e24e8df4e05
|
||||
lib/codeql/rust/elements/internal/generated/RefTypeRepr.qll 3d8c0bd296d33b91a81633f697a43269a6538df06d277262d3990d3f6880ef57 13680f39e89bcd8299c218aba396f3deec804597e6f7cb7d4a7e7c748b6faa77
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
|
||||
import codeql.rust.Diagnostics
|
||||
|
||||
query predicate extractionError(ExtractionError ee) { any() }
|
||||
query predicate extractionError(ExtractionError ee) {
|
||||
not exists(ee.getLocation()) or ee.getLocation().fromSource()
|
||||
}
|
||||
|
||||
query predicate extractionWarning(ExtractionWarning ew) { any() }
|
||||
query predicate extractionWarning(ExtractionWarning ew) {
|
||||
not exists(ew.getLocation()) or ew.getLocation().fromSource()
|
||||
}
|
||||
|
||||
@@ -5,4 +5,29 @@
|
||||
* @id rust/diagnostics/path-resolution-consistency
|
||||
*/
|
||||
|
||||
import codeql.rust.internal.PathResolutionConsistency
|
||||
private import rust
|
||||
private import codeql.rust.internal.PathResolution
|
||||
private import codeql.rust.internal.PathResolutionConsistency as PathResolutionConsistency
|
||||
private import codeql.rust.elements.Locatable
|
||||
private import codeql.Locations
|
||||
import PathResolutionConsistency
|
||||
|
||||
class SourceLocatable extends Locatable {
|
||||
Location getLocation() {
|
||||
if super.getLocation().fromSource()
|
||||
then result = super.getLocation()
|
||||
else result instanceof EmptyLocation
|
||||
}
|
||||
}
|
||||
|
||||
query predicate multipleMethodCallTargets(SourceLocatable a, SourceLocatable b) {
|
||||
PathResolutionConsistency::multipleMethodCallTargets(a, b)
|
||||
}
|
||||
|
||||
query predicate multiplePathResolutions(SourceLocatable a, SourceLocatable b) {
|
||||
PathResolutionConsistency::multiplePathResolutions(a, b)
|
||||
}
|
||||
|
||||
query predicate multipleCanonicalPaths(SourceLocatable i, SourceLocatable c, string path) {
|
||||
PathResolutionConsistency::multipleCanonicalPaths(i, c, path)
|
||||
}
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
},
|
||||
"extractLibrary": {
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
},
|
||||
"findManifests": {
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
@@ -25,12 +29,16 @@
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
},
|
||||
"parseLibrary": {
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
},
|
||||
"total": {
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
}
|
||||
},
|
||||
"numberOfFiles": 6,
|
||||
"numberOfFiles": 5,
|
||||
"numberOfManifests": 1
|
||||
},
|
||||
"severity": "note",
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
| Cargo.toml:0:0:0:0 | LoadManifest(Cargo.toml) |
|
||||
| file:///types.rs:0:0:0:0 | Extract(/types.rs) |
|
||||
| file:///types.rs:0:0:0:0 | Parse(/types.rs) |
|
||||
| file://:0:0:0:0 | CrateGraph |
|
||||
| file://:0:0:0:0 | FindManifests |
|
||||
| src/directory_module/mod.rs:0:0:0:0 | Extract(src/directory_module/mod.rs) |
|
||||
|
||||
@@ -1,27 +1,5 @@
|
||||
import codeql.rust.elements.internal.ExtractorStep
|
||||
|
||||
private class Step instanceof ExtractorStep {
|
||||
string toString() {
|
||||
result = super.getAction() + "(" + this.getFilePath() + ")"
|
||||
or
|
||||
not super.hasFile() and result = super.getAction()
|
||||
}
|
||||
|
||||
private string getFilePath() {
|
||||
exists(File file | file = super.getFile() |
|
||||
exists(file.getRelativePath()) and result = file.getAbsolutePath()
|
||||
or
|
||||
not exists(file.getRelativePath()) and result = "/" + file.getBaseName()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasLocationInfo(
|
||||
string filepath, int startline, int startcolumn, int endline, int endcolumn
|
||||
) {
|
||||
super.hasLocationInfo(_, startline, startcolumn, endline, endcolumn) and
|
||||
filepath = this.getFilePath()
|
||||
}
|
||||
}
|
||||
|
||||
from Step step
|
||||
from ExtractorStep step
|
||||
where not step.getAction() = ["ParseLibrary", "ExtractLibrary"]
|
||||
select step
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
| file:///types.rs:0:0:0:0 | Extract(/types.rs) |
|
||||
| file:///types.rs:0:0:0:0 | Parse(/types.rs) |
|
||||
| file://:0:0:0:0 | CrateGraph |
|
||||
| file://:0:0:0:0 | FindManifests |
|
||||
| rust-project.json:0:0:0:0 | LoadManifest(rust-project.json) |
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
| Inconsistencies - Path resolution | 0 |
|
||||
| Inconsistencies - SSA | 0 |
|
||||
| Inconsistencies - data flow | 0 |
|
||||
| Lines of code extracted | 23 |
|
||||
| Lines of code extracted | 6 |
|
||||
| Lines of user code extracted | 6 |
|
||||
| Macro calls - resolved | 2 |
|
||||
| Macro calls - total | 2 |
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
},
|
||||
"extractLibrary": {
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
},
|
||||
"findManifests": {
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
@@ -25,12 +29,16 @@
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
},
|
||||
"parseLibrary": {
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
},
|
||||
"total": {
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
}
|
||||
},
|
||||
"numberOfFiles": 5,
|
||||
"numberOfFiles": 4,
|
||||
"numberOfManifests": 1
|
||||
},
|
||||
"severity": "note",
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
},
|
||||
"extractLibrary": {
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
},
|
||||
"findManifests": {
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
@@ -25,12 +29,16 @@
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
},
|
||||
"parseLibrary": {
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
},
|
||||
"total": {
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
}
|
||||
},
|
||||
"numberOfFiles": 5,
|
||||
"numberOfFiles": 4,
|
||||
"numberOfManifests": 1
|
||||
},
|
||||
"severity": "note",
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
| exe/src/main.rs:0:0:0:0 | Extract(exe/src/main.rs) |
|
||||
| exe/src/main.rs:0:0:0:0 | LoadSource(exe/src/main.rs) |
|
||||
| exe/src/main.rs:0:0:0:0 | Parse(exe/src/main.rs) |
|
||||
| file:///types.rs:0:0:0:0 | Extract(/types.rs) |
|
||||
| file:///types.rs:0:0:0:0 | Parse(/types.rs) |
|
||||
| file://:0:0:0:0 | CrateGraph |
|
||||
| file://:0:0:0:0 | FindManifests |
|
||||
| lib/src/a_module/mod.rs:0:0:0:0 | Extract(lib/src/a_module/mod.rs) |
|
||||
|
||||
@@ -1,27 +1,5 @@
|
||||
import codeql.rust.elements.internal.ExtractorStep
|
||||
|
||||
private class Step instanceof ExtractorStep {
|
||||
string toString() {
|
||||
result = super.getAction() + "(" + this.getFilePath() + ")"
|
||||
or
|
||||
not super.hasFile() and result = super.getAction()
|
||||
}
|
||||
|
||||
private string getFilePath() {
|
||||
exists(File file | file = super.getFile() |
|
||||
exists(file.getRelativePath()) and result = file.getAbsolutePath()
|
||||
or
|
||||
not exists(file.getRelativePath()) and result = "/" + file.getBaseName()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasLocationInfo(
|
||||
string filepath, int startline, int startcolumn, int endline, int endcolumn
|
||||
) {
|
||||
super.hasLocationInfo(_, startline, startcolumn, endline, endcolumn) and
|
||||
filepath = this.getFilePath()
|
||||
}
|
||||
}
|
||||
|
||||
from Step step
|
||||
from ExtractorStep step
|
||||
where not step.getAction() = ["ParseLibrary", "ExtractLibrary"]
|
||||
select step
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
| exe/src/main.rs:0:0:0:0 | Extract(exe/src/main.rs) |
|
||||
| exe/src/main.rs:0:0:0:0 | LoadSource(exe/src/main.rs) |
|
||||
| exe/src/main.rs:0:0:0:0 | Parse(exe/src/main.rs) |
|
||||
| file:///types.rs:0:0:0:0 | Extract(/types.rs) |
|
||||
| file:///types.rs:0:0:0:0 | Parse(/types.rs) |
|
||||
| file://:0:0:0:0 | CrateGraph |
|
||||
| file://:0:0:0:0 | FindManifests |
|
||||
| lib/src/a_module/mod.rs:0:0:0:0 | Extract(lib/src/a_module/mod.rs) |
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
| Inconsistencies - Path resolution | 0 |
|
||||
| Inconsistencies - SSA | 0 |
|
||||
| Inconsistencies - data flow | 0 |
|
||||
| Lines of code extracted | 26 |
|
||||
| Lines of code extracted | 9 |
|
||||
| Lines of user code extracted | 9 |
|
||||
| Macro calls - resolved | 2 |
|
||||
| Macro calls - total | 2 |
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
| Inconsistencies - Path resolution | 0 |
|
||||
| Inconsistencies - SSA | 0 |
|
||||
| Inconsistencies - data flow | 0 |
|
||||
| Lines of code extracted | 26 |
|
||||
| Lines of code extracted | 9 |
|
||||
| Lines of user code extracted | 9 |
|
||||
| Macro calls - resolved | 2 |
|
||||
| Macro calls - total | 2 |
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
},
|
||||
"extractLibrary": {
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
},
|
||||
"findManifests": {
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
@@ -25,12 +29,16 @@
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
},
|
||||
"parseLibrary": {
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
},
|
||||
"total": {
|
||||
"ms": "__REDACTED__",
|
||||
"pretty": "__REDACTED__"
|
||||
}
|
||||
},
|
||||
"numberOfFiles": 3,
|
||||
"numberOfFiles": 2,
|
||||
"numberOfManifests": 1
|
||||
},
|
||||
"severity": "note",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import rust
|
||||
|
||||
from Item i, MacroItems items, int index, Item expanded
|
||||
where i.getAttributeMacroExpansion() = items and items.getItem(index) = expanded
|
||||
where i.fromSource() and i.getAttributeMacroExpansion() = items and items.getItem(index) = expanded
|
||||
select i, index, expanded
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
| Cargo.toml:0:0:0:0 | LoadManifest(Cargo.toml) |
|
||||
| exe/src/main.rs:0:0:0:0 | Extract(exe/src/main.rs) |
|
||||
| exe/src/main.rs:0:0:0:0 | Parse(exe/src/main.rs) |
|
||||
| file:///types.rs:0:0:0:0 | Extract(/types.rs) |
|
||||
| file:///types.rs:0:0:0:0 | Parse(/types.rs) |
|
||||
| file://:0:0:0:0 | CrateGraph |
|
||||
| file://:0:0:0:0 | FindManifests |
|
||||
| lib/src/lib.rs:0:0:0:0 | Extract(lib/src/lib.rs) |
|
||||
|
||||
@@ -1,27 +1,5 @@
|
||||
import codeql.rust.elements.internal.ExtractorStep
|
||||
|
||||
private class Step instanceof ExtractorStep {
|
||||
string toString() {
|
||||
result = super.getAction() + "(" + this.getFilePath() + ")"
|
||||
or
|
||||
not super.hasFile() and result = super.getAction()
|
||||
}
|
||||
|
||||
private string getFilePath() {
|
||||
exists(File file | file = super.getFile() |
|
||||
exists(file.getRelativePath()) and result = file.getAbsolutePath()
|
||||
or
|
||||
not exists(file.getRelativePath()) and result = "/" + file.getBaseName()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasLocationInfo(
|
||||
string filepath, int startline, int startcolumn, int endline, int endcolumn
|
||||
) {
|
||||
super.hasLocationInfo(_, startline, startcolumn, endline, endcolumn) and
|
||||
filepath = this.getFilePath()
|
||||
}
|
||||
}
|
||||
|
||||
from Step step
|
||||
from ExtractorStep step
|
||||
where not step.getAction() = ["ParseLibrary", "ExtractLibrary"]
|
||||
select step
|
||||
|
||||
@@ -523,97 +523,103 @@ module RustDataFlow implements InputSig<Location> {
|
||||
exists(c)
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
additional predicate readContentStep(Node node1, Content c, Node node2) {
|
||||
exists(TupleStructPatCfgNode pat, int pos |
|
||||
pat = node1.asPat() and
|
||||
node2.asPat() = pat.getField(pos) and
|
||||
c = TTupleFieldContent(pat.getTupleStructPat().getTupleField(pos))
|
||||
)
|
||||
or
|
||||
exists(TuplePatCfgNode pat, int pos |
|
||||
pos = c.(TuplePositionContent).getPosition() and
|
||||
node1.asPat() = pat and
|
||||
node2.asPat() = pat.getField(pos)
|
||||
)
|
||||
or
|
||||
exists(StructPatCfgNode pat, string field |
|
||||
pat = node1.asPat() and
|
||||
c = TStructFieldContent(pat.getStructPat().getStructField(field)) and
|
||||
node2.asPat() = pat.getFieldPat(field)
|
||||
)
|
||||
or
|
||||
c instanceof ReferenceContent and
|
||||
node1.asPat().(RefPatCfgNode).getPat() = node2.asPat()
|
||||
or
|
||||
exists(FieldExprCfgNode access |
|
||||
node1.asExpr() = access.getContainer() and
|
||||
node2.asExpr() = access and
|
||||
access = c.(FieldContent).getAnAccess()
|
||||
)
|
||||
or
|
||||
exists(IndexExprCfgNode arr |
|
||||
c instanceof ElementContent and
|
||||
node1.asExpr() = arr.getBase() and
|
||||
node2.asExpr() = arr
|
||||
)
|
||||
or
|
||||
exists(ForExprCfgNode for |
|
||||
c instanceof ElementContent and
|
||||
node1.asExpr() = for.getIterable() and
|
||||
node2.asPat() = for.getPat()
|
||||
)
|
||||
or
|
||||
exists(SlicePatCfgNode pat |
|
||||
c instanceof ElementContent and
|
||||
node1.asPat() = pat and
|
||||
node2.asPat() = pat.getAPat()
|
||||
)
|
||||
or
|
||||
exists(TryExprCfgNode try |
|
||||
node1.asExpr() = try.getExpr() and
|
||||
node2.asExpr() = try and
|
||||
c.(TupleFieldContent)
|
||||
.isVariantField([any(OptionEnum o).getSome(), any(ResultEnum r).getOk()], 0)
|
||||
)
|
||||
or
|
||||
exists(PrefixExprCfgNode deref |
|
||||
c instanceof ReferenceContent and
|
||||
deref.getOperatorName() = "*" and
|
||||
node1.asExpr() = deref.getExpr() and
|
||||
node2.asExpr() = deref
|
||||
)
|
||||
or
|
||||
// Read from function return
|
||||
exists(DataFlowCall call |
|
||||
lambdaCall(call, _, node1) and
|
||||
call = node2.(OutNode).getCall(TNormalReturnKind()) and
|
||||
c instanceof FunctionCallReturnContent
|
||||
)
|
||||
or
|
||||
exists(AwaitExprCfgNode await |
|
||||
c instanceof FutureContent and
|
||||
node1.asExpr() = await.getExpr() and
|
||||
node2.asExpr() = await
|
||||
)
|
||||
or
|
||||
referenceExprToExpr(node2.(PostUpdateNode).getPreUpdateNode(),
|
||||
node1.(PostUpdateNode).getPreUpdateNode(), c)
|
||||
or
|
||||
// Step from receiver expression to receiver node, in case of an implicit
|
||||
// dereference.
|
||||
implicitDerefToReceiver(node1, node2, c)
|
||||
or
|
||||
// A read step dual to the store step for implicit borrows.
|
||||
implicitBorrowToReceiver(node2.(PostUpdateNode).getPreUpdateNode(),
|
||||
node1.(PostUpdateNode).getPreUpdateNode(), c)
|
||||
or
|
||||
VariableCapture::readStep(node1, c, node2)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if data can flow from `node1` to `node2` via a read of `c`. Thus,
|
||||
* `node1` references an object with a content `c.getAReadContent()` whose
|
||||
* value ends up in `node2`.
|
||||
*/
|
||||
predicate readStep(Node node1, ContentSet cs, Node node2) {
|
||||
exists(Content c | c = cs.(SingletonContentSet).getContent() |
|
||||
exists(TupleStructPatCfgNode pat, int pos |
|
||||
pat = node1.asPat() and
|
||||
node2.asPat() = pat.getField(pos) and
|
||||
c = TTupleFieldContent(pat.getTupleStructPat().getTupleField(pos))
|
||||
)
|
||||
or
|
||||
exists(TuplePatCfgNode pat, int pos |
|
||||
pos = c.(TuplePositionContent).getPosition() and
|
||||
node1.asPat() = pat and
|
||||
node2.asPat() = pat.getField(pos)
|
||||
)
|
||||
or
|
||||
exists(StructPatCfgNode pat, string field |
|
||||
pat = node1.asPat() and
|
||||
c = TStructFieldContent(pat.getStructPat().getStructField(field)) and
|
||||
node2.asPat() = pat.getFieldPat(field)
|
||||
)
|
||||
or
|
||||
c instanceof ReferenceContent and
|
||||
node1.asPat().(RefPatCfgNode).getPat() = node2.asPat()
|
||||
or
|
||||
exists(FieldExprCfgNode access |
|
||||
node1.asExpr() = access.getContainer() and
|
||||
node2.asExpr() = access and
|
||||
access = c.(FieldContent).getAnAccess()
|
||||
)
|
||||
or
|
||||
exists(IndexExprCfgNode arr |
|
||||
c instanceof ElementContent and
|
||||
node1.asExpr() = arr.getBase() and
|
||||
node2.asExpr() = arr
|
||||
)
|
||||
or
|
||||
exists(ForExprCfgNode for |
|
||||
c instanceof ElementContent and
|
||||
node1.asExpr() = for.getIterable() and
|
||||
node2.asPat() = for.getPat()
|
||||
)
|
||||
or
|
||||
exists(SlicePatCfgNode pat |
|
||||
c instanceof ElementContent and
|
||||
node1.asPat() = pat and
|
||||
node2.asPat() = pat.getAPat()
|
||||
)
|
||||
or
|
||||
exists(TryExprCfgNode try |
|
||||
node1.asExpr() = try.getExpr() and
|
||||
node2.asExpr() = try and
|
||||
c.(TupleFieldContent)
|
||||
.isVariantField([any(OptionEnum o).getSome(), any(ResultEnum r).getOk()], 0)
|
||||
)
|
||||
or
|
||||
exists(PrefixExprCfgNode deref |
|
||||
c instanceof ReferenceContent and
|
||||
deref.getOperatorName() = "*" and
|
||||
node1.asExpr() = deref.getExpr() and
|
||||
node2.asExpr() = deref
|
||||
)
|
||||
or
|
||||
// Read from function return
|
||||
exists(DataFlowCall call |
|
||||
lambdaCall(call, _, node1) and
|
||||
call = node2.(OutNode).getCall(TNormalReturnKind()) and
|
||||
c instanceof FunctionCallReturnContent
|
||||
)
|
||||
or
|
||||
exists(AwaitExprCfgNode await |
|
||||
c instanceof FutureContent and
|
||||
node1.asExpr() = await.getExpr() and
|
||||
node2.asExpr() = await
|
||||
)
|
||||
or
|
||||
referenceExprToExpr(node2.(PostUpdateNode).getPreUpdateNode(),
|
||||
node1.(PostUpdateNode).getPreUpdateNode(), c)
|
||||
or
|
||||
// Step from receiver expression to receiver node, in case of an implicit
|
||||
// dereference.
|
||||
implicitDerefToReceiver(node1, node2, c)
|
||||
or
|
||||
// A read step dual to the store step for implicit borrows.
|
||||
implicitBorrowToReceiver(node2.(PostUpdateNode).getPreUpdateNode(),
|
||||
node1.(PostUpdateNode).getPreUpdateNode(), c)
|
||||
or
|
||||
VariableCapture::readStep(node1, c, node2)
|
||||
exists(Content c |
|
||||
c = cs.(SingletonContentSet).getContent() and
|
||||
readContentStep(node1, c, node2)
|
||||
)
|
||||
or
|
||||
FlowSummaryImpl::Private::Steps::summaryReadStep(node1.(FlowSummaryNode).getSummaryNode(), cs,
|
||||
@@ -652,7 +658,7 @@ module RustDataFlow implements InputSig<Location> {
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
private predicate storeContentStep(Node node1, Content c, Node node2) {
|
||||
additional predicate storeContentStep(Node node1, Content c, Node node2) {
|
||||
exists(CallExprCfgNode call, int pos |
|
||||
node1.asExpr() = call.getArgument(pragma[only_bind_into](pos)) and
|
||||
node2.asExpr() = call and
|
||||
|
||||
@@ -363,17 +363,25 @@ private module DataFlowIntegrationInput implements Impl::DataFlowIntegrationInpu
|
||||
|
||||
class Guard extends CfgNodes::AstCfgNode {
|
||||
/**
|
||||
* Holds if the control flow branching from `bb1` is dependent on this guard,
|
||||
* and that the edge from `bb1` to `bb2` corresponds to the evaluation of this
|
||||
* guard to `branch`.
|
||||
* Holds if the evaluation of this guard to `branch` corresponds to the edge
|
||||
* from `bb1` to `bb2`.
|
||||
*/
|
||||
predicate controlsBranchEdge(SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, boolean branch) {
|
||||
predicate hasBranchEdge(SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, boolean branch) {
|
||||
exists(Cfg::ConditionalSuccessor s |
|
||||
this = bb1.getANode() and
|
||||
bb2 = bb1.getASuccessor(s) and
|
||||
s.getValue() = branch
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this guard evaluating to `branch` controls the control-flow
|
||||
* branch edge from `bb1` to `bb2`. That is, following the edge from
|
||||
* `bb1` to `bb2` implies that this guard evaluated to `branch`.
|
||||
*/
|
||||
predicate controlsBranchEdge(SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, boolean branch) {
|
||||
this.hasBranchEdge(bb1, bb2, branch)
|
||||
}
|
||||
}
|
||||
|
||||
/** Holds if the guard `guard` controls block `bb` upon evaluating to `branch`. */
|
||||
|
||||
1
rust/ql/lib/codeql/rust/elements/Crate.qll
generated
1
rust/ql/lib/codeql/rust/elements/Crate.qll
generated
@@ -5,7 +5,6 @@
|
||||
|
||||
private import internal.CrateImpl
|
||||
import codeql.rust.elements.Locatable
|
||||
import codeql.rust.elements.Module
|
||||
import codeql.rust.elements.internal.NamedCrate
|
||||
|
||||
final class Crate = Impl::Crate;
|
||||
|
||||
@@ -15,6 +15,7 @@ module Impl {
|
||||
private import rust
|
||||
private import codeql.rust.elements.internal.generated.ParentChild
|
||||
private import codeql.rust.controlflow.ControlFlowGraph
|
||||
private import codeql.rust.elements.internal.MacroCallImpl::Impl as MacroCallImpl
|
||||
|
||||
/**
|
||||
* Gets the immediate parent of a non-`AstNode` element `e`.
|
||||
@@ -59,10 +60,20 @@ module Impl {
|
||||
}
|
||||
|
||||
/** Holds if this node is inside a macro expansion. */
|
||||
predicate isInMacroExpansion() {
|
||||
this = any(MacroCall mc).getMacroCallExpansion()
|
||||
or
|
||||
this.getParentNode().isInMacroExpansion()
|
||||
predicate isInMacroExpansion() { MacroCallImpl::isInMacroExpansion(_, this) }
|
||||
|
||||
/**
|
||||
* Holds if this node exists only as the result of a macro expansion.
|
||||
*
|
||||
* This is the same as `isInMacroExpansion()`, but excludes AST nodes corresponding
|
||||
* to macro arguments.
|
||||
*/
|
||||
pragma[nomagic]
|
||||
predicate isFromMacroExpansion() {
|
||||
exists(MacroCall mc |
|
||||
MacroCallImpl::isInMacroExpansion(mc, this) and
|
||||
not this = mc.getATokenTreeNode()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,13 +60,11 @@ module Impl {
|
||||
Crate getADependency() { result = this.getDependency(_) }
|
||||
|
||||
/** Gets the source file that defines this crate, if any. */
|
||||
SourceFile getSourceFile() { result.getFile() = this.getModule().getFile() }
|
||||
SourceFile getSourceFile() { result.getFile() = this.getLocation().getFile() }
|
||||
|
||||
/**
|
||||
* Gets a source file that belongs to this crate, if any.
|
||||
*/
|
||||
SourceFile getASourceFile() { result = this.(CrateItemNode).getASourceFile() }
|
||||
|
||||
override Location getLocation() { result = this.getModule().getLocation() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ module Impl {
|
||||
File getFile() { result = this.getLocation().getFile() }
|
||||
|
||||
/** Holds if this element is from source code. */
|
||||
predicate fromSource() { exists(this.getFile().getRelativePath()) }
|
||||
predicate fromSource() { this.getFile().fromSource() }
|
||||
}
|
||||
|
||||
private @location_default getDbLocation(Locatable l) {
|
||||
|
||||
@@ -77,13 +77,76 @@ module LocationImpl {
|
||||
)
|
||||
}
|
||||
|
||||
/** Holds if this location starts strictly before the specified location. */
|
||||
/** Holds if this location starts before location `that`. */
|
||||
pragma[inline]
|
||||
predicate strictlyBefore(Location other) {
|
||||
this.getStartLine() < other.getStartLine()
|
||||
or
|
||||
this.getStartLine() = other.getStartLine() and this.getStartColumn() < other.getStartColumn()
|
||||
predicate startsBefore(Location that) {
|
||||
exists(string f, int sl1, int sc1, int sl2, int sc2 |
|
||||
this.hasLocationInfo(f, sl1, sc1, _, _) and
|
||||
that.hasLocationInfo(f, sl2, sc2, _, _)
|
||||
|
|
||||
sl1 < sl2
|
||||
or
|
||||
sl1 = sl2 and sc1 <= sc2
|
||||
)
|
||||
}
|
||||
|
||||
/** Holds if this location starts strictly before location `that`. */
|
||||
pragma[inline]
|
||||
predicate startsStrictlyBefore(Location that) {
|
||||
exists(string f, int sl1, int sc1, int sl2, int sc2 |
|
||||
this.hasLocationInfo(f, sl1, sc1, _, _) and
|
||||
that.hasLocationInfo(f, sl2, sc2, _, _)
|
||||
|
|
||||
sl1 < sl2
|
||||
or
|
||||
sl1 = sl2 and sc1 < sc2
|
||||
)
|
||||
}
|
||||
|
||||
/** Holds if this location ends after location `that`. */
|
||||
pragma[inline]
|
||||
predicate endsAfter(Location that) {
|
||||
exists(string f, int el1, int ec1, int el2, int ec2 |
|
||||
this.hasLocationInfo(f, _, _, el1, ec1) and
|
||||
that.hasLocationInfo(f, _, _, el2, ec2)
|
||||
|
|
||||
el1 > el2
|
||||
or
|
||||
el1 = el2 and ec1 >= ec2
|
||||
)
|
||||
}
|
||||
|
||||
/** Holds if this location ends strictly after location `that`. */
|
||||
pragma[inline]
|
||||
predicate endsStrictlyAfter(Location that) {
|
||||
exists(string f, int el1, int ec1, int el2, int ec2 |
|
||||
this.hasLocationInfo(f, _, _, el1, ec1) and
|
||||
that.hasLocationInfo(f, _, _, el2, ec2)
|
||||
|
|
||||
el1 > el2
|
||||
or
|
||||
el1 = el2 and ec1 > ec2
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this location contains location `that`, meaning that it starts
|
||||
* before and ends after it.
|
||||
*/
|
||||
pragma[inline]
|
||||
predicate contains(Location that) { this.startsBefore(that) and this.endsAfter(that) }
|
||||
|
||||
/**
|
||||
* Holds if this location strictlycontains location `that`, meaning that it starts
|
||||
* strictly before and ends strictly after it.
|
||||
*/
|
||||
pragma[inline]
|
||||
predicate strictlyContains(Location that) {
|
||||
this.startsStrictlyBefore(that) and this.endsStrictlyAfter(that)
|
||||
}
|
||||
|
||||
/** Holds if this location is from source code. */
|
||||
predicate fromSource() { this.getFile().fromSource() }
|
||||
}
|
||||
|
||||
class LocationDefault extends Location, TLocationDefault {
|
||||
|
||||
@@ -11,6 +11,15 @@ private import codeql.rust.elements.internal.generated.MacroCall
|
||||
* be referenced directly.
|
||||
*/
|
||||
module Impl {
|
||||
private import rust
|
||||
|
||||
pragma[nomagic]
|
||||
predicate isInMacroExpansion(MacroCall mc, AstNode n) {
|
||||
n = mc.getMacroCallExpansion()
|
||||
or
|
||||
isInMacroExpansion(mc, n.getParentNode())
|
||||
}
|
||||
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
* A MacroCall. For example:
|
||||
@@ -20,5 +29,12 @@ module Impl {
|
||||
*/
|
||||
class MacroCall extends Generated::MacroCall {
|
||||
override string toStringImpl() { result = this.getPath().toAbbreviatedString() + "!..." }
|
||||
|
||||
/** Gets an AST node whose location is inside the token tree belonging to this macro call. */
|
||||
pragma[nomagic]
|
||||
AstNode getATokenTreeNode() {
|
||||
isInMacroExpansion(this, result) and
|
||||
this.getTokenTree().getLocation().contains(result.getLocation())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
private import codeql.rust.elements.internal.generated.Synth
|
||||
private import codeql.rust.elements.internal.generated.Raw
|
||||
import codeql.rust.elements.internal.LocatableImpl::Impl as LocatableImpl
|
||||
import codeql.rust.elements.Module
|
||||
import codeql.rust.elements.internal.NamedCrate
|
||||
|
||||
/**
|
||||
@@ -42,18 +41,6 @@ module Generated {
|
||||
*/
|
||||
final predicate hasVersion() { exists(this.getVersion()) }
|
||||
|
||||
/**
|
||||
* Gets the module of this crate, if it exists.
|
||||
*/
|
||||
Module getModule() {
|
||||
result = Synth::convertModuleFromRaw(Synth::convertCrateToRaw(this).(Raw::Crate).getModule())
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `getModule()` exists.
|
||||
*/
|
||||
final predicate hasModule() { exists(this.getModule()) }
|
||||
|
||||
/**
|
||||
* Gets the `index`th cfg option of this crate (0-based).
|
||||
*/
|
||||
|
||||
@@ -86,11 +86,6 @@ module Raw {
|
||||
*/
|
||||
string getVersion() { crate_versions(this, result) }
|
||||
|
||||
/**
|
||||
* Gets the module of this crate, if it exists.
|
||||
*/
|
||||
Module getModule() { crate_modules(this, result) }
|
||||
|
||||
/**
|
||||
* Gets the `index`th cfg option of this crate (0-based).
|
||||
*/
|
||||
|
||||
@@ -7,6 +7,7 @@ private import codeql.rust.Concepts
|
||||
private import codeql.rust.controlflow.ControlFlowGraph as Cfg
|
||||
private import codeql.rust.controlflow.CfgNodes as CfgNodes
|
||||
private import codeql.rust.dataflow.DataFlow
|
||||
private import codeql.rust.internal.PathResolution
|
||||
|
||||
/**
|
||||
* A call to the `starts_with` method on a `Path`.
|
||||
|
||||
@@ -24,10 +24,7 @@ query predicate multipleLocations(Locatable e) { strictcount(e.getLocation()) >
|
||||
/**
|
||||
* Holds if `e` does not have a `Location`.
|
||||
*/
|
||||
query predicate noLocation(Locatable e) {
|
||||
not exists(e.getLocation()) and
|
||||
not e.(AstNode).getParentNode*() = any(Crate c).getModule()
|
||||
}
|
||||
query predicate noLocation(Locatable e) { not exists(e.getLocation()) }
|
||||
|
||||
private predicate multiplePrimaryQlClasses(Element e) {
|
||||
strictcount(string cls | cls = e.getAPrimaryQlClass() and cls != "VariableAccess") > 1
|
||||
|
||||
@@ -180,7 +180,8 @@ abstract class ItemNode extends Locatable {
|
||||
or
|
||||
preludeEdge(this, name, result) and not declares(this, _, name)
|
||||
or
|
||||
builtinEdge(this, name, result)
|
||||
this instanceof SourceFile and
|
||||
builtin(name, result)
|
||||
or
|
||||
name = "super" and
|
||||
if this instanceof Module or this instanceof SourceFile
|
||||
@@ -196,11 +197,11 @@ abstract class ItemNode extends Locatable {
|
||||
this = result.(ImplOrTraitItemNode).getAnItemInSelfScope()
|
||||
or
|
||||
name = "crate" and
|
||||
this = result.(CrateItemNode).getARootModuleNode()
|
||||
this = result.(CrateItemNode).getASourceFile()
|
||||
or
|
||||
// todo: implement properly
|
||||
name = "$crate" and
|
||||
result = any(CrateItemNode crate | this = crate.getARootModuleNode()).(Crate).getADependency*() and
|
||||
result = any(CrateItemNode crate | this = crate.getASourceFile()).(Crate).getADependency*() and
|
||||
result.(CrateItemNode).isPotentialDollarCrateTarget()
|
||||
}
|
||||
|
||||
@@ -281,16 +282,6 @@ abstract private class ModuleLikeNode extends ItemNode {
|
||||
not mid instanceof ModuleLikeNode
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this is a root module, meaning either a source file or
|
||||
* the entry module of a crate.
|
||||
*/
|
||||
predicate isRoot() {
|
||||
this instanceof SourceFileItemNode
|
||||
or
|
||||
this = any(Crate c).getModule()
|
||||
}
|
||||
}
|
||||
|
||||
private class SourceFileItemNode extends ModuleLikeNode, SourceFile {
|
||||
@@ -316,21 +307,13 @@ private class SourceFileItemNode extends ModuleLikeNode, SourceFile {
|
||||
|
||||
class CrateItemNode extends ItemNode instanceof Crate {
|
||||
/**
|
||||
* Gets the module node that defines this crate.
|
||||
*
|
||||
* This is either a source file, when the crate is defined in source code,
|
||||
* or a module, when the crate is defined in a dependency.
|
||||
* Gets the source file that defines this crate.
|
||||
*/
|
||||
pragma[nomagic]
|
||||
ModuleLikeNode getModuleNode() {
|
||||
result = super.getSourceFile()
|
||||
or
|
||||
not exists(super.getSourceFile()) and
|
||||
result = super.getModule()
|
||||
}
|
||||
SourceFileItemNode getSourceFile() { result = super.getSourceFile() }
|
||||
|
||||
/**
|
||||
* Gets a source file that belongs to this crate, if any.
|
||||
* Gets a source file that belongs to this crate.
|
||||
*
|
||||
* This is calculated as those source files that can be reached from the entry
|
||||
* file of this crate using zero or more `mod` imports, without going through
|
||||
@@ -348,15 +331,6 @@ class CrateItemNode extends ItemNode instanceof Crate {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a root module node belonging to this crate.
|
||||
*/
|
||||
ModuleLikeNode getARootModuleNode() {
|
||||
result = this.getASourceFile()
|
||||
or
|
||||
result = super.getModule()
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
predicate isPotentialDollarCrateTarget() {
|
||||
exists(string name, RelevantPath p |
|
||||
@@ -381,10 +355,7 @@ class CrateItemNode extends ItemNode instanceof Crate {
|
||||
this.hasCanonicalPath(c) and
|
||||
exists(ModuleLikeNode m |
|
||||
child.getImmediateParent() = m and
|
||||
not m = child.(SourceFileItemNode).getSuper()
|
||||
|
|
||||
m = super.getModule() // the special `crate` root module inserted by the extractor
|
||||
or
|
||||
not m = child.(SourceFileItemNode).getSuper() and
|
||||
m = super.getSourceFile()
|
||||
)
|
||||
}
|
||||
@@ -998,7 +969,7 @@ private predicate modImport0(Module m, string name, Folder lookup) {
|
||||
// sibling import
|
||||
lookup = parent and
|
||||
(
|
||||
m.getFile() = any(CrateItemNode c).getModuleNode().(SourceFileItemNode).getFile()
|
||||
m.getFile() = any(CrateItemNode c).getSourceFile().getFile()
|
||||
or
|
||||
m.getFile().getBaseName() = "mod.rs"
|
||||
)
|
||||
@@ -1086,7 +1057,7 @@ private predicate fileImportEdge(Module mod, string name, ItemNode item) {
|
||||
*/
|
||||
pragma[nomagic]
|
||||
private predicate crateDefEdge(CrateItemNode c, string name, ItemNode i) {
|
||||
i = c.getModuleNode().getASuccessorRec(name) and
|
||||
i = c.getSourceFile().getASuccessorRec(name) and
|
||||
not i instanceof Crate
|
||||
}
|
||||
|
||||
@@ -1094,17 +1065,10 @@ private predicate crateDefEdge(CrateItemNode c, string name, ItemNode i) {
|
||||
* Holds if `m` depends on crate `dep` named `name`.
|
||||
*/
|
||||
private predicate crateDependencyEdge(ModuleLikeNode m, string name, CrateItemNode dep) {
|
||||
exists(CrateItemNode c | dep = c.(Crate).getDependency(name) |
|
||||
// entry module/entry source file
|
||||
m = c.getModuleNode()
|
||||
or
|
||||
// entry/transitive source file
|
||||
exists(CrateItemNode c |
|
||||
dep = c.(Crate).getDependency(name) and
|
||||
m = c.getASourceFile()
|
||||
)
|
||||
or
|
||||
// paths inside the crate graph use the name of the crate itself as prefix,
|
||||
// although that is not valid in Rust
|
||||
dep = any(Crate c | name = c.getName() and m = c.getModule())
|
||||
}
|
||||
|
||||
private predicate useTreeDeclares(UseTree tree, string name) {
|
||||
@@ -1172,9 +1136,9 @@ class RelevantPath extends Path {
|
||||
|
||||
private predicate isModule(ItemNode m) { m instanceof Module }
|
||||
|
||||
/** Holds if root module `root` contains the module `m`. */
|
||||
private predicate rootHasModule(ItemNode root, ItemNode m) =
|
||||
doublyBoundedFastTC(hasChild/2, isRoot/1, isModule/1)(root, m)
|
||||
/** Holds if source file `source` contains the module `m`. */
|
||||
private predicate rootHasModule(SourceFileItemNode source, ItemNode m) =
|
||||
doublyBoundedFastTC(hasChild/2, isSourceFile/1, isModule/1)(source, m)
|
||||
|
||||
pragma[nomagic]
|
||||
private ItemNode getOuterScope(ItemNode i) {
|
||||
@@ -1227,14 +1191,14 @@ private ItemNode getASuccessorFull(ItemNode pred, string name, Namespace ns) {
|
||||
ns = result.getNamespace()
|
||||
}
|
||||
|
||||
private predicate isRoot(ItemNode root) { root.(ModuleLikeNode).isRoot() }
|
||||
private predicate isSourceFile(ItemNode source) { source instanceof SourceFileItemNode }
|
||||
|
||||
private predicate hasCratePath(ItemNode i) { any(RelevantPath path).isCratePath(_, i) }
|
||||
|
||||
private predicate hasChild(ItemNode parent, ItemNode child) { child.getImmediateParent() = parent }
|
||||
|
||||
private predicate rootHasCratePathTc(ItemNode i1, ItemNode i2) =
|
||||
doublyBoundedFastTC(hasChild/2, isRoot/1, hasCratePath/1)(i1, i2)
|
||||
private predicate sourceFileHasCratePathTc(ItemNode i1, ItemNode i2) =
|
||||
doublyBoundedFastTC(hasChild/2, isSourceFile/1, hasCratePath/1)(i1, i2)
|
||||
|
||||
/**
|
||||
* Holds if the unqualified path `p` references a keyword item named `name`, and
|
||||
@@ -1244,10 +1208,10 @@ pragma[nomagic]
|
||||
private predicate keywordLookup(ItemNode encl, string name, Namespace ns, RelevantPath p) {
|
||||
// For `($)crate`, jump directly to the root module
|
||||
exists(ItemNode i | p.isCratePath(name, i) |
|
||||
encl.(ModuleLikeNode).isRoot() and
|
||||
encl instanceof SourceFile and
|
||||
encl = i
|
||||
or
|
||||
rootHasCratePathTc(encl, i)
|
||||
sourceFileHasCratePathTc(encl, i)
|
||||
)
|
||||
or
|
||||
name = ["super", "self"] and
|
||||
@@ -1448,10 +1412,10 @@ private predicate useImportEdge(Use use, string name, ItemNode item) {
|
||||
* [1]: https://doc.rust-lang.org/core/prelude/index.html
|
||||
*/
|
||||
private predicate preludeEdge(SourceFile f, string name, ItemNode i) {
|
||||
exists(Crate core, ModuleItemNode mod, ModuleItemNode prelude, ModuleItemNode rust |
|
||||
exists(Crate core, ModuleLikeNode mod, ModuleItemNode prelude, ModuleItemNode rust |
|
||||
f = any(Crate c0 | core = c0.getDependency(_)).getASourceFile() and
|
||||
core.getName() = "core" and
|
||||
mod = core.getModule() and
|
||||
mod = core.getSourceFile() and
|
||||
prelude = mod.getASuccessorRec("prelude") and
|
||||
rust = prelude.getASuccessorRec(["rust_2015", "rust_2018", "rust_2021", "rust_2024"]) and
|
||||
i = rust.getASuccessorRec(name) and
|
||||
@@ -1462,12 +1426,7 @@ private predicate preludeEdge(SourceFile f, string name, ItemNode i) {
|
||||
private import codeql.rust.frameworks.stdlib.Bultins as Builtins
|
||||
|
||||
pragma[nomagic]
|
||||
private predicate builtinEdge(ModuleLikeNode m, string name, ItemNode i) {
|
||||
(
|
||||
m instanceof SourceFile
|
||||
or
|
||||
m = any(CrateItemNode c).getModuleNode()
|
||||
) and
|
||||
private predicate builtin(string name, ItemNode i) {
|
||||
exists(SourceFileItemNode builtins |
|
||||
builtins.getFile().getParentContainer() instanceof Builtins::BuiltinsFolder and
|
||||
i = builtins.getASuccessorRec(name)
|
||||
|
||||
@@ -1232,7 +1232,7 @@ private module Debug {
|
||||
exists(string filepath, int startline, int startcolumn, int endline, int endcolumn |
|
||||
result.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) and
|
||||
filepath.matches("%/main.rs") and
|
||||
startline = 28
|
||||
startline = 948
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -238,12 +238,6 @@ crate_versions(
|
||||
string version: string ref
|
||||
);
|
||||
|
||||
#keyset[id]
|
||||
crate_modules(
|
||||
int id: @crate ref,
|
||||
int module: @module ref
|
||||
);
|
||||
|
||||
#keyset[id, index]
|
||||
crate_cfg_options(
|
||||
int id: @crate ref,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,4 @@
|
||||
description: Remove 'module' from Crate
|
||||
compatibility: partial
|
||||
|
||||
crate_modules.rel: delete
|
||||
@@ -18,7 +18,8 @@ private module ResolveTest implements TestSig {
|
||||
private predicate commmentAt(string text, string filepath, int line) {
|
||||
exists(Comment c |
|
||||
c.getLocation().hasLocationInfo(filepath, line, _, _, _) and
|
||||
c.getCommentText().trim() = text
|
||||
c.getCommentText().trim() = text and
|
||||
c.fromSource()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -35,6 +36,8 @@ private module ResolveTest implements TestSig {
|
||||
exists(AstNode n |
|
||||
not n = any(Path parent).getQualifier() and
|
||||
location = n.getLocation() and
|
||||
n.fromSource() and
|
||||
not n.isFromMacroExpansion() and
|
||||
element = n.toString() and
|
||||
tag = "item"
|
||||
|
|
||||
|
||||
@@ -8,5 +8,5 @@
|
||||
import rust
|
||||
|
||||
from MacroCall mc
|
||||
where not mc.hasMacroCallExpansion()
|
||||
where mc.fromSource() and not mc.hasMacroCallExpansion()
|
||||
select mc, "Macro call was not resolved to a target."
|
||||
|
||||
@@ -28,7 +28,7 @@ private import codeql.rust.security.WeakSensitiveDataHashingExtensions
|
||||
/**
|
||||
* Gets a count of the total number of lines of code in the database.
|
||||
*/
|
||||
int getLinesOfCode() { result = sum(File f | | f.getNumberOfLinesOfCode()) }
|
||||
int getLinesOfCode() { result = sum(File f | f.fromSource() | f.getNumberOfLinesOfCode()) }
|
||||
|
||||
/**
|
||||
* Gets a count of the total number of lines of code from the source code directory in the database.
|
||||
@@ -91,8 +91,7 @@ int getQuerySinksCount() { result = count(QuerySink s) }
|
||||
class CrateElement extends Element {
|
||||
CrateElement() {
|
||||
this instanceof Crate or
|
||||
this instanceof NamedCrate or
|
||||
this.(AstNode).getParentNode*() = any(Crate c).getModule()
|
||||
this instanceof NamedCrate
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,9 +109,11 @@ predicate elementStats(string key, int value) {
|
||||
* Gets summary statistics about extraction.
|
||||
*/
|
||||
predicate extractionStats(string key, int value) {
|
||||
key = "Extraction errors" and value = count(ExtractionError e)
|
||||
key = "Extraction errors" and
|
||||
value = count(ExtractionError e | not exists(e.getLocation()) or e.getLocation().fromSource())
|
||||
or
|
||||
key = "Extraction warnings" and value = count(ExtractionWarning w)
|
||||
key = "Extraction warnings" and
|
||||
value = count(ExtractionWarning w | not exists(w.getLocation()) or w.getLocation().fromSource())
|
||||
or
|
||||
key = "Files extracted - total" and value = count(ExtractedFile f | exists(f.getRelativePath()))
|
||||
or
|
||||
@@ -134,11 +135,13 @@ predicate extractionStats(string key, int value) {
|
||||
or
|
||||
key = "Lines of user code extracted" and value = getLinesOfUserCode()
|
||||
or
|
||||
key = "Macro calls - total" and value = count(MacroCall mc)
|
||||
key = "Macro calls - total" and value = count(MacroCall mc | mc.fromSource())
|
||||
or
|
||||
key = "Macro calls - resolved" and value = count(MacroCall mc | mc.hasMacroCallExpansion())
|
||||
key = "Macro calls - resolved" and
|
||||
value = count(MacroCall mc | mc.fromSource() and mc.hasMacroCallExpansion())
|
||||
or
|
||||
key = "Macro calls - unresolved" and value = count(MacroCall mc | not mc.hasMacroCallExpansion())
|
||||
key = "Macro calls - unresolved" and
|
||||
value = count(MacroCall mc | mc.fromSource() and not mc.hasMacroCallExpansion())
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
private import rust
|
||||
|
||||
predicate toBeTested(Element e) { not e instanceof CrateElement and not e instanceof Builtin }
|
||||
predicate toBeTested(Element e) {
|
||||
not e instanceof CrateElement and
|
||||
not e instanceof Builtin and
|
||||
(
|
||||
not e instanceof Locatable
|
||||
or
|
||||
e.(Locatable).fromSource()
|
||||
)
|
||||
}
|
||||
|
||||
class CrateElement extends Element {
|
||||
CrateElement() {
|
||||
this instanceof Crate or
|
||||
this instanceof NamedCrate or
|
||||
any(Crate c).getModule() = this.(AstNode).getParentNode*()
|
||||
this instanceof NamedCrate
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
multipleCanonicalPaths
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Equal as core::cmp::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Equal as typenum::marker_traits::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Greater as core::cmp::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Greater as typenum::marker_traits::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Less as core::cmp::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Less as typenum::marker_traits::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | impl Ord for Equal { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Equal as core::cmp::Ord> |
|
||||
| file://:0:0:0:0 | impl Ord for Equal { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Equal as typenum::marker_traits::Ord> |
|
||||
| file://:0:0:0:0 | impl Ord for Greater { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Greater as core::cmp::Ord> |
|
||||
| file://:0:0:0:0 | impl Ord for Greater { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Greater as typenum::marker_traits::Ord> |
|
||||
| file://:0:0:0:0 | impl Ord for Less { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Less as core::cmp::Ord> |
|
||||
| file://:0:0:0:0 | impl Ord for Less { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Less as typenum::marker_traits::Ord> |
|
||||
@@ -1,140 +0,0 @@
|
||||
#-----| Const
|
||||
|
||||
#-----| Static
|
||||
|
||||
#-----| enum X
|
||||
|
||||
#-----| fn as_string
|
||||
|
||||
#-----| fn as_string
|
||||
|
||||
#-----| fn fmt
|
||||
|
||||
#-----| fn from
|
||||
|
||||
#-----| fn length
|
||||
|
||||
#-----| impl ...::AsString for ...::X { ... }
|
||||
#-----| -> fn as_string
|
||||
|
||||
#-----| impl ...::Display for ...::X { ... }
|
||||
#-----| -> fn fmt
|
||||
|
||||
#-----| impl ...::From::<...> for ...::Thing::<...> { ... }
|
||||
#-----| -> fn from
|
||||
|
||||
lib.rs:
|
||||
# 0| mod crate
|
||||
#-----| -> mod module
|
||||
|
||||
#-----| mod module
|
||||
#-----| -> Const
|
||||
#-----| -> Static
|
||||
#-----| -> enum X
|
||||
#-----| -> fn length
|
||||
#-----| -> impl ...::AsString for ...::X { ... }
|
||||
#-----| -> impl ...::Display for ...::X { ... }
|
||||
#-----| -> impl ...::From::<...> for ...::Thing::<...> { ... }
|
||||
#-----| -> struct LocalKey<T>
|
||||
#-----| -> struct Thing<T>
|
||||
#-----| -> struct X_List
|
||||
#-----| -> trait AsString
|
||||
#-----| -> use ...::DirBuilder
|
||||
#-----| -> use ...::DirEntry
|
||||
#-----| -> use ...::File
|
||||
#-----| -> use ...::FileTimes
|
||||
#-----| -> use ...::FileType
|
||||
#-----| -> use ...::Metadata
|
||||
#-----| -> use ...::OpenOptions
|
||||
#-----| -> use ...::PathBuf
|
||||
#-----| -> use ...::Permissions
|
||||
#-----| -> use ...::ReadDir
|
||||
#-----| -> use ...::canonicalize
|
||||
#-----| -> use ...::copy
|
||||
#-----| -> use ...::create_dir
|
||||
#-----| -> use ...::create_dir as mkdir
|
||||
#-----| -> use ...::create_dir_all
|
||||
#-----| -> use ...::exists
|
||||
#-----| -> use ...::hard_link
|
||||
#-----| -> use ...::metadata
|
||||
#-----| -> use ...::read
|
||||
#-----| -> use ...::read_dir
|
||||
#-----| -> use ...::read_link
|
||||
#-----| -> use ...::read_to_string
|
||||
#-----| -> use ...::remove_dir
|
||||
#-----| -> use ...::remove_dir_all
|
||||
#-----| -> use ...::remove_file
|
||||
#-----| -> use ...::rename
|
||||
#-----| -> use ...::set_permissions
|
||||
#-----| -> use ...::soft_link
|
||||
#-----| -> use ...::symlink_metadata
|
||||
#-----| -> use ...::write
|
||||
|
||||
#-----| struct LocalKey<T>
|
||||
|
||||
#-----| struct Thing<T>
|
||||
|
||||
#-----| struct X_List
|
||||
|
||||
#-----| trait AsString
|
||||
#-----| -> fn as_string
|
||||
|
||||
#-----| use ...::DirBuilder
|
||||
|
||||
#-----| use ...::DirEntry
|
||||
|
||||
#-----| use ...::File
|
||||
|
||||
#-----| use ...::FileTimes
|
||||
|
||||
#-----| use ...::FileType
|
||||
|
||||
#-----| use ...::Metadata
|
||||
|
||||
#-----| use ...::OpenOptions
|
||||
|
||||
#-----| use ...::PathBuf
|
||||
|
||||
#-----| use ...::Permissions
|
||||
|
||||
#-----| use ...::ReadDir
|
||||
|
||||
#-----| use ...::canonicalize
|
||||
|
||||
#-----| use ...::copy
|
||||
|
||||
#-----| use ...::create_dir
|
||||
|
||||
#-----| use ...::create_dir as mkdir
|
||||
|
||||
#-----| use ...::create_dir_all
|
||||
|
||||
#-----| use ...::exists
|
||||
|
||||
#-----| use ...::hard_link
|
||||
|
||||
#-----| use ...::metadata
|
||||
|
||||
#-----| use ...::read
|
||||
|
||||
#-----| use ...::read_dir
|
||||
|
||||
#-----| use ...::read_link
|
||||
|
||||
#-----| use ...::read_to_string
|
||||
|
||||
#-----| use ...::remove_dir
|
||||
|
||||
#-----| use ...::remove_dir_all
|
||||
|
||||
#-----| use ...::remove_file
|
||||
|
||||
#-----| use ...::rename
|
||||
|
||||
#-----| use ...::set_permissions
|
||||
|
||||
#-----| use ...::soft_link
|
||||
|
||||
#-----| use ...::symlink_metadata
|
||||
|
||||
#-----| use ...::write
|
||||
@@ -1,72 +0,0 @@
|
||||
/**
|
||||
* @id module-graph
|
||||
* @name Module and Item Graph
|
||||
* @kind graph
|
||||
*/
|
||||
|
||||
import rust
|
||||
|
||||
predicate nodes(Item i) { i instanceof RelevantNode }
|
||||
|
||||
class RelevantNode extends Item {
|
||||
RelevantNode() {
|
||||
this.getParentNode*() =
|
||||
any(Crate m | m.getName() = "test" and m.getVersion() = "0.0.1").getModule()
|
||||
}
|
||||
|
||||
string label() { result = this.toString() }
|
||||
}
|
||||
|
||||
class HasGenericParams extends RelevantNode {
|
||||
private GenericParamList params;
|
||||
|
||||
HasGenericParams() {
|
||||
params = this.(Function).getGenericParamList() or
|
||||
params = this.(Enum).getGenericParamList() or
|
||||
params = this.(Struct).getGenericParamList() or
|
||||
params = this.(Union).getGenericParamList() or
|
||||
params = this.(Impl).getGenericParamList() or
|
||||
params = this.(Enum).getGenericParamList() or
|
||||
params = this.(Trait).getGenericParamList() or
|
||||
params = this.(TraitAlias).getGenericParamList()
|
||||
}
|
||||
|
||||
override string label() {
|
||||
result =
|
||||
super.toString() + "<" +
|
||||
strictconcat(string part, int index |
|
||||
part = params.getGenericParam(index).toString()
|
||||
|
|
||||
part, ", " order by index
|
||||
) + ">"
|
||||
}
|
||||
}
|
||||
|
||||
predicate edges(RelevantNode container, RelevantNode element) {
|
||||
element = container.(Module).getItemList().getAnItem() or
|
||||
element = container.(Impl).getAssocItemList().getAnAssocItem() or
|
||||
element = container.(Trait).getAssocItemList().getAnAssocItem()
|
||||
}
|
||||
|
||||
query predicate nodes(RelevantNode node, string attr, string val) {
|
||||
nodes(node) and
|
||||
(
|
||||
attr = "semmle.label" and
|
||||
val = node.label()
|
||||
or
|
||||
attr = "semmle.order" and
|
||||
val =
|
||||
any(int i | node = rank[i](RelevantNode n | nodes(n) | n order by n.toString())).toString()
|
||||
)
|
||||
}
|
||||
|
||||
query predicate edges(RelevantNode pred, RelevantNode succ, string attr, string val) {
|
||||
edges(pred, succ) and
|
||||
(
|
||||
attr = "semmle.label" and
|
||||
val = ""
|
||||
or
|
||||
attr = "semmle.order" and
|
||||
val = any(int i | succ = rank[i](Item s | edges(pred, s) | s order by s.toString())).toString()
|
||||
)
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
import rust
|
||||
import TestUtils
|
||||
|
||||
query predicate charLiteral(CharLiteralExpr e) { any() }
|
||||
query predicate charLiteral(CharLiteralExpr e) { toBeTested(e) }
|
||||
|
||||
query predicate stringLiteral(StringLiteralExpr e) { any() }
|
||||
query predicate stringLiteral(StringLiteralExpr e) { toBeTested(e) }
|
||||
|
||||
query predicate integerLiteral(IntegerLiteralExpr e, string suffix) {
|
||||
suffix = concat(e.getSuffix())
|
||||
toBeTested(e) and suffix = concat(e.getSuffix())
|
||||
}
|
||||
|
||||
query predicate floatLiteral(FloatLiteralExpr e, string suffix) { suffix = concat(e.getSuffix()) }
|
||||
query predicate floatLiteral(FloatLiteralExpr e, string suffix) {
|
||||
toBeTested(e) and suffix = concat(e.getSuffix())
|
||||
}
|
||||
|
||||
query predicate booleanLiteral(BooleanLiteralExpr e) { any() }
|
||||
query predicate booleanLiteral(BooleanLiteralExpr e) { toBeTested(e) }
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
import rust
|
||||
import codeql.rust.controlflow.ControlFlowGraph
|
||||
import codeql.rust.controlflow.BasicBlocks
|
||||
import TestUtils
|
||||
|
||||
query predicate dominates(BasicBlock bb1, BasicBlock bb2) { bb1.dominates(bb2) }
|
||||
query predicate dominates(BasicBlock bb1, BasicBlock bb2) {
|
||||
toBeTested(bb1.getScope()) and bb1.dominates(bb2)
|
||||
}
|
||||
|
||||
query predicate postDominance(BasicBlock bb1, BasicBlock bb2) { bb1.postDominates(bb2) }
|
||||
query predicate postDominance(BasicBlock bb1, BasicBlock bb2) {
|
||||
toBeTested(bb1.getScope()) and bb1.postDominates(bb2)
|
||||
}
|
||||
|
||||
query predicate immediateDominator(BasicBlock bb1, BasicBlock bb2) {
|
||||
bb1.getImmediateDominator() = bb2
|
||||
toBeTested(bb1.getScope()) and bb1.getImmediateDominator() = bb2
|
||||
}
|
||||
|
||||
query predicate controls(ConditionBasicBlock bb1, BasicBlock bb2, SuccessorType t) {
|
||||
bb1.edgeDominates(bb2, t)
|
||||
toBeTested(bb1.getScope()) and bb1.edgeDominates(bb2, t)
|
||||
}
|
||||
|
||||
query predicate successor(ConditionBasicBlock bb1, BasicBlock bb2, SuccessorType t) {
|
||||
bb1.getASuccessor(t) = bb2
|
||||
toBeTested(bb1.getScope()) and bb1.getASuccessor(t) = bb2
|
||||
}
|
||||
|
||||
query predicate joinBlockPredecessor(JoinBasicBlock bb1, BasicBlock bb2, int i) {
|
||||
bb1.getJoinBlockPredecessor(i) = bb2
|
||||
toBeTested(bb1.getScope()) and bb1.getJoinBlockPredecessor(i) = bb2
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
||||
import codeql.rust.dataflow.DataFlow
|
||||
import codeql.rust.dataflow.internal.DataFlowImpl
|
||||
import codeql.rust.dataflow.internal.Node
|
||||
import utils.test.TranslateModels
|
||||
|
||||
query predicate localStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
|
||||
@@ -7,6 +8,27 @@ query predicate localStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
|
||||
RustDataFlow::simpleLocalFlowStep(nodeFrom, nodeTo, "")
|
||||
}
|
||||
|
||||
query predicate storeStep = RustDataFlow::storeStep/3;
|
||||
class Content extends DataFlow::Content {
|
||||
predicate hasLocationInfo(
|
||||
string filepath, int startline, int startcolumn, int endline, int endcolumn
|
||||
) {
|
||||
exists(string file |
|
||||
this.getLocation().hasLocationInfo(file, startline, startcolumn, endline, endcolumn) and
|
||||
filepath =
|
||||
file.regexpReplaceAll("^/.*/tools/builtins/", "/BUILTINS/")
|
||||
.regexpReplaceAll("^/.*/.rustup/toolchains/[^/]+/", "/RUSTUP_HOME/toolchain/")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
query predicate readStep = RustDataFlow::readStep/3;
|
||||
class Node extends DataFlow::Node {
|
||||
Node() { not this instanceof FlowSummaryNode }
|
||||
}
|
||||
|
||||
query predicate storeStep(Node node1, Content c, Node node2) {
|
||||
RustDataFlow::storeContentStep(node1, c, node2)
|
||||
}
|
||||
|
||||
query predicate readStep(Node node1, Content c, Node node2) {
|
||||
RustDataFlow::readContentStep(node1, c, node2)
|
||||
}
|
||||
|
||||
@@ -29,32 +29,38 @@ edges
|
||||
| main.rs:28:13:28:13 | a | main.rs:28:13:28:21 | a.clone() | provenance | MaD:5 |
|
||||
| main.rs:28:13:28:13 | a | main.rs:28:13:28:21 | a.clone() | provenance | generated |
|
||||
| main.rs:28:13:28:21 | a.clone() | main.rs:28:9:28:9 | b | provenance | |
|
||||
| main.rs:41:13:41:13 | w [Wrapper] | main.rs:42:15:42:15 | w [Wrapper] | provenance | |
|
||||
| main.rs:41:17:41:41 | Wrapper {...} [Wrapper] | main.rs:41:13:41:13 | w [Wrapper] | provenance | |
|
||||
| main.rs:41:30:41:39 | source(...) | main.rs:41:17:41:41 | Wrapper {...} [Wrapper] | provenance | |
|
||||
| main.rs:42:15:42:15 | w [Wrapper] | main.rs:43:13:43:28 | Wrapper {...} [Wrapper] | provenance | |
|
||||
| main.rs:42:15:42:15 | w [Wrapper] | main.rs:45:17:45:17 | w [Wrapper] | provenance | |
|
||||
| main.rs:43:13:43:28 | Wrapper {...} [Wrapper] | main.rs:43:26:43:26 | n | provenance | |
|
||||
| main.rs:43:26:43:26 | n | main.rs:43:38:43:38 | n | provenance | |
|
||||
| main.rs:45:13:45:13 | u [Wrapper] | main.rs:46:15:46:15 | u [Wrapper] | provenance | |
|
||||
| main.rs:45:17:45:17 | w [Wrapper] | main.rs:45:17:45:25 | w.clone() [Wrapper] | provenance | generated |
|
||||
| main.rs:45:17:45:25 | w.clone() [Wrapper] | main.rs:45:13:45:13 | u [Wrapper] | provenance | |
|
||||
| main.rs:46:15:46:15 | u [Wrapper] | main.rs:47:13:47:28 | Wrapper {...} [Wrapper] | provenance | |
|
||||
| main.rs:47:13:47:28 | Wrapper {...} [Wrapper] | main.rs:47:26:47:26 | n | provenance | |
|
||||
| main.rs:47:26:47:26 | n | main.rs:47:38:47:38 | n | provenance | |
|
||||
| main.rs:58:13:58:13 | b [Some] | main.rs:59:23:59:23 | b [Some] | provenance | |
|
||||
| main.rs:58:17:58:32 | Some(...) [Some] | main.rs:58:13:58:13 | b [Some] | provenance | |
|
||||
| main.rs:58:22:58:31 | source(...) | main.rs:58:17:58:32 | Some(...) [Some] | provenance | |
|
||||
| main.rs:59:13:59:13 | z [Some, tuple.1] | main.rs:60:15:60:15 | z [Some, tuple.1] | provenance | |
|
||||
| main.rs:59:17:59:24 | a.zip(...) [Some, tuple.1] | main.rs:59:13:59:13 | z [Some, tuple.1] | provenance | |
|
||||
| main.rs:59:23:59:23 | b [Some] | main.rs:59:17:59:24 | a.zip(...) [Some, tuple.1] | provenance | MaD:3 |
|
||||
| main.rs:60:15:60:15 | z [Some, tuple.1] | main.rs:61:13:61:24 | Some(...) [Some, tuple.1] | provenance | |
|
||||
| main.rs:61:13:61:24 | Some(...) [Some, tuple.1] | main.rs:61:18:61:23 | TuplePat [tuple.1] | provenance | |
|
||||
| main.rs:61:18:61:23 | TuplePat [tuple.1] | main.rs:61:22:61:22 | m | provenance | |
|
||||
| main.rs:61:22:61:22 | m | main.rs:63:22:63:22 | m | provenance | |
|
||||
| main.rs:84:29:84:29 | [post] y [&ref] | main.rs:85:33:85:33 | y [&ref] | provenance | |
|
||||
| main.rs:84:32:84:41 | source(...) | main.rs:84:29:84:29 | [post] y [&ref] | provenance | MaD:7 |
|
||||
| main.rs:85:33:85:33 | y [&ref] | main.rs:85:18:85:34 | ...::read(...) | provenance | MaD:6 |
|
||||
| main.rs:43:18:43:22 | SelfParam [Wrapper] | main.rs:44:26:44:29 | self [Wrapper] | provenance | |
|
||||
| main.rs:44:13:44:33 | Wrapper {...} [Wrapper] | main.rs:43:33:45:9 | { ... } [Wrapper] | provenance | |
|
||||
| main.rs:44:26:44:29 | self [Wrapper] | main.rs:44:26:44:31 | self.n | provenance | |
|
||||
| main.rs:44:26:44:31 | self.n | main.rs:44:13:44:33 | Wrapper {...} [Wrapper] | provenance | |
|
||||
| main.rs:49:13:49:13 | w [Wrapper] | main.rs:50:15:50:15 | w [Wrapper] | provenance | |
|
||||
| main.rs:49:17:49:41 | Wrapper {...} [Wrapper] | main.rs:49:13:49:13 | w [Wrapper] | provenance | |
|
||||
| main.rs:49:30:49:39 | source(...) | main.rs:49:17:49:41 | Wrapper {...} [Wrapper] | provenance | |
|
||||
| main.rs:50:15:50:15 | w [Wrapper] | main.rs:43:18:43:22 | SelfParam [Wrapper] | provenance | |
|
||||
| main.rs:50:15:50:15 | w [Wrapper] | main.rs:51:13:51:28 | Wrapper {...} [Wrapper] | provenance | |
|
||||
| main.rs:50:15:50:15 | w [Wrapper] | main.rs:53:17:53:17 | w [Wrapper] | provenance | |
|
||||
| main.rs:50:15:50:15 | w [Wrapper] | main.rs:53:17:53:25 | w.clone() [Wrapper] | provenance | |
|
||||
| main.rs:51:13:51:28 | Wrapper {...} [Wrapper] | main.rs:51:26:51:26 | n | provenance | |
|
||||
| main.rs:51:26:51:26 | n | main.rs:51:38:51:38 | n | provenance | |
|
||||
| main.rs:53:13:53:13 | u [Wrapper] | main.rs:54:15:54:15 | u [Wrapper] | provenance | |
|
||||
| main.rs:53:17:53:17 | w [Wrapper] | main.rs:53:17:53:25 | w.clone() [Wrapper] | provenance | generated |
|
||||
| main.rs:53:17:53:25 | w.clone() [Wrapper] | main.rs:53:13:53:13 | u [Wrapper] | provenance | |
|
||||
| main.rs:54:15:54:15 | u [Wrapper] | main.rs:55:13:55:28 | Wrapper {...} [Wrapper] | provenance | |
|
||||
| main.rs:55:13:55:28 | Wrapper {...} [Wrapper] | main.rs:55:26:55:26 | n | provenance | |
|
||||
| main.rs:55:26:55:26 | n | main.rs:55:38:55:38 | n | provenance | |
|
||||
| main.rs:66:13:66:13 | b [Some] | main.rs:67:23:67:23 | b [Some] | provenance | |
|
||||
| main.rs:66:17:66:32 | Some(...) [Some] | main.rs:66:13:66:13 | b [Some] | provenance | |
|
||||
| main.rs:66:22:66:31 | source(...) | main.rs:66:17:66:32 | Some(...) [Some] | provenance | |
|
||||
| main.rs:67:13:67:13 | z [Some, tuple.1] | main.rs:68:15:68:15 | z [Some, tuple.1] | provenance | |
|
||||
| main.rs:67:17:67:24 | a.zip(...) [Some, tuple.1] | main.rs:67:13:67:13 | z [Some, tuple.1] | provenance | |
|
||||
| main.rs:67:23:67:23 | b [Some] | main.rs:67:17:67:24 | a.zip(...) [Some, tuple.1] | provenance | MaD:3 |
|
||||
| main.rs:68:15:68:15 | z [Some, tuple.1] | main.rs:69:13:69:24 | Some(...) [Some, tuple.1] | provenance | |
|
||||
| main.rs:69:13:69:24 | Some(...) [Some, tuple.1] | main.rs:69:18:69:23 | TuplePat [tuple.1] | provenance | |
|
||||
| main.rs:69:18:69:23 | TuplePat [tuple.1] | main.rs:69:22:69:22 | m | provenance | |
|
||||
| main.rs:69:22:69:22 | m | main.rs:71:22:71:22 | m | provenance | |
|
||||
| main.rs:92:29:92:29 | [post] y [&ref] | main.rs:93:33:93:33 | y [&ref] | provenance | |
|
||||
| main.rs:92:32:92:41 | source(...) | main.rs:92:29:92:29 | [post] y [&ref] | provenance | MaD:7 |
|
||||
| main.rs:93:33:93:33 | y [&ref] | main.rs:93:18:93:34 | ...::read(...) | provenance | MaD:6 |
|
||||
nodes
|
||||
| main.rs:12:9:12:9 | a [Some] | semmle.label | a [Some] |
|
||||
| main.rs:12:13:12:28 | Some(...) [Some] | semmle.label | Some(...) [Some] |
|
||||
@@ -79,36 +85,42 @@ nodes
|
||||
| main.rs:28:13:28:13 | a | semmle.label | a |
|
||||
| main.rs:28:13:28:21 | a.clone() | semmle.label | a.clone() |
|
||||
| main.rs:29:10:29:10 | b | semmle.label | b |
|
||||
| main.rs:41:13:41:13 | w [Wrapper] | semmle.label | w [Wrapper] |
|
||||
| main.rs:41:17:41:41 | Wrapper {...} [Wrapper] | semmle.label | Wrapper {...} [Wrapper] |
|
||||
| main.rs:41:30:41:39 | source(...) | semmle.label | source(...) |
|
||||
| main.rs:42:15:42:15 | w [Wrapper] | semmle.label | w [Wrapper] |
|
||||
| main.rs:43:13:43:28 | Wrapper {...} [Wrapper] | semmle.label | Wrapper {...} [Wrapper] |
|
||||
| main.rs:43:26:43:26 | n | semmle.label | n |
|
||||
| main.rs:43:38:43:38 | n | semmle.label | n |
|
||||
| main.rs:45:13:45:13 | u [Wrapper] | semmle.label | u [Wrapper] |
|
||||
| main.rs:45:17:45:17 | w [Wrapper] | semmle.label | w [Wrapper] |
|
||||
| main.rs:45:17:45:25 | w.clone() [Wrapper] | semmle.label | w.clone() [Wrapper] |
|
||||
| main.rs:46:15:46:15 | u [Wrapper] | semmle.label | u [Wrapper] |
|
||||
| main.rs:47:13:47:28 | Wrapper {...} [Wrapper] | semmle.label | Wrapper {...} [Wrapper] |
|
||||
| main.rs:47:26:47:26 | n | semmle.label | n |
|
||||
| main.rs:47:38:47:38 | n | semmle.label | n |
|
||||
| main.rs:58:13:58:13 | b [Some] | semmle.label | b [Some] |
|
||||
| main.rs:58:17:58:32 | Some(...) [Some] | semmle.label | Some(...) [Some] |
|
||||
| main.rs:58:22:58:31 | source(...) | semmle.label | source(...) |
|
||||
| main.rs:59:13:59:13 | z [Some, tuple.1] | semmle.label | z [Some, tuple.1] |
|
||||
| main.rs:59:17:59:24 | a.zip(...) [Some, tuple.1] | semmle.label | a.zip(...) [Some, tuple.1] |
|
||||
| main.rs:59:23:59:23 | b [Some] | semmle.label | b [Some] |
|
||||
| main.rs:60:15:60:15 | z [Some, tuple.1] | semmle.label | z [Some, tuple.1] |
|
||||
| main.rs:61:13:61:24 | Some(...) [Some, tuple.1] | semmle.label | Some(...) [Some, tuple.1] |
|
||||
| main.rs:61:18:61:23 | TuplePat [tuple.1] | semmle.label | TuplePat [tuple.1] |
|
||||
| main.rs:61:22:61:22 | m | semmle.label | m |
|
||||
| main.rs:63:22:63:22 | m | semmle.label | m |
|
||||
| main.rs:84:29:84:29 | [post] y [&ref] | semmle.label | [post] y [&ref] |
|
||||
| main.rs:84:32:84:41 | source(...) | semmle.label | source(...) |
|
||||
| main.rs:85:18:85:34 | ...::read(...) | semmle.label | ...::read(...) |
|
||||
| main.rs:85:33:85:33 | y [&ref] | semmle.label | y [&ref] |
|
||||
| main.rs:43:18:43:22 | SelfParam [Wrapper] | semmle.label | SelfParam [Wrapper] |
|
||||
| main.rs:43:33:45:9 | { ... } [Wrapper] | semmle.label | { ... } [Wrapper] |
|
||||
| main.rs:44:13:44:33 | Wrapper {...} [Wrapper] | semmle.label | Wrapper {...} [Wrapper] |
|
||||
| main.rs:44:26:44:29 | self [Wrapper] | semmle.label | self [Wrapper] |
|
||||
| main.rs:44:26:44:31 | self.n | semmle.label | self.n |
|
||||
| main.rs:49:13:49:13 | w [Wrapper] | semmle.label | w [Wrapper] |
|
||||
| main.rs:49:17:49:41 | Wrapper {...} [Wrapper] | semmle.label | Wrapper {...} [Wrapper] |
|
||||
| main.rs:49:30:49:39 | source(...) | semmle.label | source(...) |
|
||||
| main.rs:50:15:50:15 | w [Wrapper] | semmle.label | w [Wrapper] |
|
||||
| main.rs:51:13:51:28 | Wrapper {...} [Wrapper] | semmle.label | Wrapper {...} [Wrapper] |
|
||||
| main.rs:51:26:51:26 | n | semmle.label | n |
|
||||
| main.rs:51:38:51:38 | n | semmle.label | n |
|
||||
| main.rs:53:13:53:13 | u [Wrapper] | semmle.label | u [Wrapper] |
|
||||
| main.rs:53:17:53:17 | w [Wrapper] | semmle.label | w [Wrapper] |
|
||||
| main.rs:53:17:53:25 | w.clone() [Wrapper] | semmle.label | w.clone() [Wrapper] |
|
||||
| main.rs:54:15:54:15 | u [Wrapper] | semmle.label | u [Wrapper] |
|
||||
| main.rs:55:13:55:28 | Wrapper {...} [Wrapper] | semmle.label | Wrapper {...} [Wrapper] |
|
||||
| main.rs:55:26:55:26 | n | semmle.label | n |
|
||||
| main.rs:55:38:55:38 | n | semmle.label | n |
|
||||
| main.rs:66:13:66:13 | b [Some] | semmle.label | b [Some] |
|
||||
| main.rs:66:17:66:32 | Some(...) [Some] | semmle.label | Some(...) [Some] |
|
||||
| main.rs:66:22:66:31 | source(...) | semmle.label | source(...) |
|
||||
| main.rs:67:13:67:13 | z [Some, tuple.1] | semmle.label | z [Some, tuple.1] |
|
||||
| main.rs:67:17:67:24 | a.zip(...) [Some, tuple.1] | semmle.label | a.zip(...) [Some, tuple.1] |
|
||||
| main.rs:67:23:67:23 | b [Some] | semmle.label | b [Some] |
|
||||
| main.rs:68:15:68:15 | z [Some, tuple.1] | semmle.label | z [Some, tuple.1] |
|
||||
| main.rs:69:13:69:24 | Some(...) [Some, tuple.1] | semmle.label | Some(...) [Some, tuple.1] |
|
||||
| main.rs:69:18:69:23 | TuplePat [tuple.1] | semmle.label | TuplePat [tuple.1] |
|
||||
| main.rs:69:22:69:22 | m | semmle.label | m |
|
||||
| main.rs:71:22:71:22 | m | semmle.label | m |
|
||||
| main.rs:92:29:92:29 | [post] y [&ref] | semmle.label | [post] y [&ref] |
|
||||
| main.rs:92:32:92:41 | source(...) | semmle.label | source(...) |
|
||||
| main.rs:93:18:93:34 | ...::read(...) | semmle.label | ...::read(...) |
|
||||
| main.rs:93:33:93:33 | y [&ref] | semmle.label | y [&ref] |
|
||||
subpaths
|
||||
| main.rs:50:15:50:15 | w [Wrapper] | main.rs:43:18:43:22 | SelfParam [Wrapper] | main.rs:43:33:45:9 | { ... } [Wrapper] | main.rs:53:17:53:25 | w.clone() [Wrapper] |
|
||||
testFailures
|
||||
#select
|
||||
| main.rs:13:10:13:19 | a.unwrap() | main.rs:12:18:12:27 | source(...) | main.rs:13:10:13:19 | a.unwrap() | $@ | main.rs:12:18:12:27 | source(...) | source(...) |
|
||||
@@ -117,7 +129,7 @@ testFailures
|
||||
| main.rs:22:10:22:19 | b.unwrap() | main.rs:19:34:19:43 | source(...) | main.rs:22:10:22:19 | b.unwrap() | $@ | main.rs:19:34:19:43 | source(...) | source(...) |
|
||||
| main.rs:27:10:27:10 | a | main.rs:26:13:26:22 | source(...) | main.rs:27:10:27:10 | a | $@ | main.rs:26:13:26:22 | source(...) | source(...) |
|
||||
| main.rs:29:10:29:10 | b | main.rs:26:13:26:22 | source(...) | main.rs:29:10:29:10 | b | $@ | main.rs:26:13:26:22 | source(...) | source(...) |
|
||||
| main.rs:43:38:43:38 | n | main.rs:41:30:41:39 | source(...) | main.rs:43:38:43:38 | n | $@ | main.rs:41:30:41:39 | source(...) | source(...) |
|
||||
| main.rs:47:38:47:38 | n | main.rs:41:30:41:39 | source(...) | main.rs:47:38:47:38 | n | $@ | main.rs:41:30:41:39 | source(...) | source(...) |
|
||||
| main.rs:63:22:63:22 | m | main.rs:58:22:58:31 | source(...) | main.rs:63:22:63:22 | m | $@ | main.rs:58:22:58:31 | source(...) | source(...) |
|
||||
| main.rs:85:18:85:34 | ...::read(...) | main.rs:84:32:84:41 | source(...) | main.rs:85:18:85:34 | ...::read(...) | $@ | main.rs:84:32:84:41 | source(...) | source(...) |
|
||||
| main.rs:51:38:51:38 | n | main.rs:49:30:49:39 | source(...) | main.rs:51:38:51:38 | n | $@ | main.rs:49:30:49:39 | source(...) | source(...) |
|
||||
| main.rs:55:38:55:38 | n | main.rs:49:30:49:39 | source(...) | main.rs:55:38:55:38 | n | $@ | main.rs:49:30:49:39 | source(...) | source(...) |
|
||||
| main.rs:71:22:71:22 | m | main.rs:66:22:66:31 | source(...) | main.rs:71:22:71:22 | m | $@ | main.rs:66:22:66:31 | source(...) | source(...) |
|
||||
| main.rs:93:18:93:34 | ...::read(...) | main.rs:92:32:92:41 | source(...) | main.rs:93:18:93:34 | ...::read(...) | $@ | main.rs:92:32:92:41 | source(...) | source(...) |
|
||||
|
||||
@@ -32,11 +32,19 @@ fn i64_clone() {
|
||||
mod my_clone {
|
||||
use super::{sink, source};
|
||||
|
||||
#[derive(Clone)]
|
||||
// TODO: Replace manual implementation below with `#[derive(Clone)]`,
|
||||
// once the extractor expands the `#[derive]` attributes.
|
||||
// #[derive(Clone)]
|
||||
struct Wrapper {
|
||||
n: i64,
|
||||
}
|
||||
|
||||
impl Clone for Wrapper {
|
||||
fn clone(&self) -> Self {
|
||||
Wrapper { n: self.n }
|
||||
}
|
||||
}
|
||||
|
||||
pub fn wrapper_clone() {
|
||||
let w = Wrapper { n: source(73) };
|
||||
match w {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
multipleCanonicalPaths
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Equal as core::cmp::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Equal as typenum::marker_traits::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Greater as core::cmp::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Greater as typenum::marker_traits::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Less as core::cmp::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Less as typenum::marker_traits::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | impl Ord for Equal { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Equal as core::cmp::Ord> |
|
||||
| file://:0:0:0:0 | impl Ord for Equal { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Equal as typenum::marker_traits::Ord> |
|
||||
| file://:0:0:0:0 | impl Ord for Greater { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Greater as core::cmp::Ord> |
|
||||
| file://:0:0:0:0 | impl Ord for Greater { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Greater as typenum::marker_traits::Ord> |
|
||||
| file://:0:0:0:0 | impl Ord for Less { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Less as core::cmp::Ord> |
|
||||
| file://:0:0:0:0 | impl Ord for Less { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Less as typenum::marker_traits::Ord> |
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
multipleCanonicalPaths
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Equal as core::cmp::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Equal as typenum::marker_traits::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Greater as core::cmp::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Greater as typenum::marker_traits::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Less as core::cmp::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Less as typenum::marker_traits::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | impl Ord for Equal { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Equal as core::cmp::Ord> |
|
||||
| file://:0:0:0:0 | impl Ord for Equal { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Equal as typenum::marker_traits::Ord> |
|
||||
| file://:0:0:0:0 | impl Ord for Greater { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Greater as core::cmp::Ord> |
|
||||
| file://:0:0:0:0 | impl Ord for Greater { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Greater as typenum::marker_traits::Ord> |
|
||||
| file://:0:0:0:0 | impl Ord for Less { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Less as core::cmp::Ord> |
|
||||
| file://:0:0:0:0 | impl Ord for Less { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Less as typenum::marker_traits::Ord> |
|
||||
@@ -1,5 +1,6 @@
|
||||
import rust
|
||||
import utils.test.InlineExpectationsTest
|
||||
import TestUtils
|
||||
|
||||
string describe(Expr op) {
|
||||
op instanceof Operation and result = "Operation"
|
||||
@@ -40,6 +41,7 @@ module OperationsTest implements TestSig {
|
||||
|
||||
predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
exists(Expr op |
|
||||
toBeTested(op) and
|
||||
location = op.getLocation() and
|
||||
location.getFile().getBaseName() != "" and
|
||||
element = op.toString() and
|
||||
|
||||
@@ -16,13 +16,13 @@ mod my4 {
|
||||
}
|
||||
|
||||
pub use my4::my5::f as nested_f; // $ item=I201
|
||||
|
||||
#[rustfmt::skip]
|
||||
type Result<
|
||||
T, // T
|
||||
> = ::std::result::Result<
|
||||
T, // $ item=T
|
||||
String,
|
||||
>; // my::Result
|
||||
String,> // $ item=Result
|
||||
; // my::Result
|
||||
|
||||
fn int_div(
|
||||
x: i32, // $ item=i32
|
||||
@@ -30,7 +30,7 @@ fn int_div(
|
||||
) -> Result<i32> // $ item=my::Result $ item=i32
|
||||
{
|
||||
if y == 0 {
|
||||
return Err("Div by zero".to_string());
|
||||
return Err("Div by zero".to_string()); // $ item=Err
|
||||
}
|
||||
Ok(x / y)
|
||||
Ok(x / y) // $ item=Ok
|
||||
}
|
||||
|
||||
@@ -352,15 +352,15 @@ resolvePath
|
||||
| my.rs:18:9:18:16 | ...::my5 | my.rs:15:5:15:16 | mod my5 |
|
||||
| my.rs:18:9:18:19 | ...::f | my/my4/my5/mod.rs:1:1:3:1 | fn f |
|
||||
| my.rs:22:5:22:9 | std | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/std/src/lib.rs:0:0:0:0 | Crate(std@0.0.0) |
|
||||
| my.rs:22:5:22:17 | ...::result | file://:0:0:0:0 | mod result |
|
||||
| my.rs:22:5:25:1 | ...::Result::<...> | file://:0:0:0:0 | enum Result |
|
||||
| my.rs:22:5:22:17 | ...::result | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/lib.rs:356:1:356:15 | mod result |
|
||||
| my.rs:22:5:24:12 | ...::Result::<...> | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | enum Result |
|
||||
| my.rs:23:5:23:5 | T | my.rs:21:5:21:5 | T |
|
||||
| my.rs:28:8:28:10 | i32 | file:///BUILTINS/types.rs:12:1:12:15 | struct i32 |
|
||||
| my.rs:29:8:29:10 | i32 | file:///BUILTINS/types.rs:12:1:12:15 | struct i32 |
|
||||
| my.rs:30:6:30:16 | Result::<...> | my.rs:20:1:25:2 | type Result<...> |
|
||||
| my.rs:30:6:30:16 | Result::<...> | my.rs:18:34:25:1 | type Result<...> |
|
||||
| my.rs:30:13:30:15 | i32 | file:///BUILTINS/types.rs:12:1:12:15 | struct i32 |
|
||||
| my.rs:33:16:33:18 | Err | file://:0:0:0:0 | Err |
|
||||
| my.rs:35:5:35:6 | Ok | file://:0:0:0:0 | Ok |
|
||||
| my.rs:33:16:33:18 | Err | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:534:5:537:56 | Err |
|
||||
| my.rs:35:5:35:6 | Ok | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:529:5:532:55 | Ok |
|
||||
| my/nested.rs:9:13:9:13 | f | my/nested.rs:3:9:5:9 | fn f |
|
||||
| my/nested.rs:15:9:15:15 | nested2 | my/nested.rs:2:5:11:5 | mod nested2 |
|
||||
| my/nested.rs:15:9:15:18 | ...::f | my/nested.rs:3:9:5:9 | fn f |
|
||||
|
||||
@@ -21,5 +21,7 @@ class ItemNodeLoc extends ItemNodeFinal {
|
||||
}
|
||||
|
||||
query predicate resolvePath(Path p, ItemNodeLoc i) {
|
||||
toBeTested(p) and not p.isInMacroExpansion() and i = resolvePath(p)
|
||||
toBeTested(p) and
|
||||
not p.isFromMacroExpansion() and
|
||||
i = resolvePath(p)
|
||||
}
|
||||
|
||||
@@ -1468,96 +1468,96 @@ inferType
|
||||
| main.rs:1150:15:1150:16 | &x | | file://:0:0:0:0 | & |
|
||||
| main.rs:1150:15:1150:16 | &x | &T | main.rs:1126:5:1126:13 | S |
|
||||
| main.rs:1150:16:1150:16 | x | | main.rs:1126:5:1126:13 | S |
|
||||
| main.rs:1164:43:1167:5 | { ... } | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1164:43:1167:5 | { ... } | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1164:43:1167:5 | { ... } | E | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1164:43:1167:5 | { ... } | T | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1165:13:1165:13 | x | | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1165:17:1165:30 | ...::Ok(...) | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1165:17:1165:30 | ...::Ok(...) | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1165:17:1165:30 | ...::Ok(...) | T | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1165:17:1165:31 | TryExpr | | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1165:28:1165:29 | S1 | | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1166:9:1166:22 | ...::Ok(...) | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1166:9:1166:22 | ...::Ok(...) | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1166:9:1166:22 | ...::Ok(...) | E | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1166:9:1166:22 | ...::Ok(...) | T | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1166:20:1166:21 | S1 | | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1170:46:1174:5 | { ... } | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1170:46:1174:5 | { ... } | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1170:46:1174:5 | { ... } | E | main.rs:1160:5:1161:14 | S2 |
|
||||
| main.rs:1170:46:1174:5 | { ... } | T | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1171:13:1171:13 | x | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1171:13:1171:13 | x | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1171:13:1171:13 | x | T | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1171:17:1171:30 | ...::Ok(...) | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1171:17:1171:30 | ...::Ok(...) | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1171:17:1171:30 | ...::Ok(...) | T | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1171:28:1171:29 | S1 | | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1172:13:1172:13 | y | | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1172:17:1172:17 | x | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1172:17:1172:17 | x | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1172:17:1172:17 | x | T | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1172:17:1172:18 | TryExpr | | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1173:9:1173:22 | ...::Ok(...) | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1173:9:1173:22 | ...::Ok(...) | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1173:9:1173:22 | ...::Ok(...) | E | main.rs:1160:5:1161:14 | S2 |
|
||||
| main.rs:1173:9:1173:22 | ...::Ok(...) | T | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1173:20:1173:21 | S1 | | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1177:40:1182:5 | { ... } | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1177:40:1182:5 | { ... } | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1177:40:1182:5 | { ... } | E | main.rs:1160:5:1161:14 | S2 |
|
||||
| main.rs:1177:40:1182:5 | { ... } | T | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1178:13:1178:13 | x | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1178:13:1178:13 | x | T | file://:0:0:0:0 | Result |
|
||||
| main.rs:1178:13:1178:13 | x | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1178:13:1178:13 | x | T | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1178:13:1178:13 | x | T.T | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1178:17:1178:42 | ...::Ok(...) | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1178:17:1178:42 | ...::Ok(...) | T | file://:0:0:0:0 | Result |
|
||||
| main.rs:1178:17:1178:42 | ...::Ok(...) | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1178:17:1178:42 | ...::Ok(...) | T | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1178:17:1178:42 | ...::Ok(...) | T.T | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1178:28:1178:41 | ...::Ok(...) | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1178:28:1178:41 | ...::Ok(...) | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1178:28:1178:41 | ...::Ok(...) | T | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1178:39:1178:40 | S1 | | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1180:17:1180:17 | x | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1180:17:1180:17 | x | T | file://:0:0:0:0 | Result |
|
||||
| main.rs:1180:17:1180:17 | x | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1180:17:1180:17 | x | T | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1180:17:1180:17 | x | T.T | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1180:17:1180:18 | TryExpr | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1180:17:1180:18 | TryExpr | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1180:17:1180:18 | TryExpr | T | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1180:17:1180:29 | ... .map(...) | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1181:9:1181:22 | ...::Ok(...) | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1180:17:1180:29 | ... .map(...) | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1181:9:1181:22 | ...::Ok(...) | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1181:9:1181:22 | ...::Ok(...) | E | main.rs:1160:5:1161:14 | S2 |
|
||||
| main.rs:1181:9:1181:22 | ...::Ok(...) | T | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1181:20:1181:21 | S1 | | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1185:30:1185:34 | input | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1185:30:1185:34 | input | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1185:30:1185:34 | input | E | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1185:30:1185:34 | input | T | main.rs:1185:20:1185:27 | T |
|
||||
| main.rs:1185:69:1192:5 | { ... } | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1185:69:1192:5 | { ... } | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1185:69:1192:5 | { ... } | E | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1185:69:1192:5 | { ... } | T | main.rs:1185:20:1185:27 | T |
|
||||
| main.rs:1186:13:1186:17 | value | | main.rs:1185:20:1185:27 | T |
|
||||
| main.rs:1186:21:1186:25 | input | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1186:21:1186:25 | input | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1186:21:1186:25 | input | E | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1186:21:1186:25 | input | T | main.rs:1185:20:1185:27 | T |
|
||||
| main.rs:1186:21:1186:26 | TryExpr | | main.rs:1185:20:1185:27 | T |
|
||||
| main.rs:1187:22:1187:38 | ...::Ok(...) | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1187:22:1187:38 | ...::Ok(...) | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1187:22:1187:38 | ...::Ok(...) | T | main.rs:1185:20:1185:27 | T |
|
||||
| main.rs:1187:22:1190:10 | ... .and_then(...) | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1187:22:1190:10 | ... .and_then(...) | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1187:33:1187:37 | value | | main.rs:1185:20:1185:27 | T |
|
||||
| main.rs:1187:53:1190:9 | { ... } | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1187:53:1190:9 | { ... } | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1187:53:1190:9 | { ... } | E | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1188:22:1188:27 | "{:?}\\n" | | file:///BUILTINS/types.rs:8:1:8:15 | str |
|
||||
| main.rs:1189:13:1189:34 | ...::Ok::<...>(...) | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1189:13:1189:34 | ...::Ok::<...>(...) | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1189:13:1189:34 | ...::Ok::<...>(...) | E | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1191:9:1191:23 | ...::Err(...) | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1191:9:1191:23 | ...::Err(...) | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1191:9:1191:23 | ...::Err(...) | E | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1191:9:1191:23 | ...::Err(...) | T | main.rs:1185:20:1185:27 | T |
|
||||
| main.rs:1191:21:1191:22 | S1 | | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1195:37:1195:52 | try_same_error(...) | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1195:37:1195:52 | try_same_error(...) | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1195:37:1195:52 | try_same_error(...) | E | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1195:37:1195:52 | try_same_error(...) | T | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1196:22:1196:27 | "{:?}\\n" | | file:///BUILTINS/types.rs:8:1:8:15 | str |
|
||||
| main.rs:1199:37:1199:55 | try_convert_error(...) | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1199:37:1199:55 | try_convert_error(...) | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1199:37:1199:55 | try_convert_error(...) | E | main.rs:1160:5:1161:14 | S2 |
|
||||
| main.rs:1199:37:1199:55 | try_convert_error(...) | T | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1200:22:1200:27 | "{:?}\\n" | | file:///BUILTINS/types.rs:8:1:8:15 | str |
|
||||
| main.rs:1203:37:1203:49 | try_chained(...) | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1203:37:1203:49 | try_chained(...) | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1203:37:1203:49 | try_chained(...) | E | main.rs:1160:5:1161:14 | S2 |
|
||||
| main.rs:1203:37:1203:49 | try_chained(...) | T | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1204:22:1204:27 | "{:?}\\n" | | file:///BUILTINS/types.rs:8:1:8:15 | str |
|
||||
| main.rs:1207:37:1207:63 | try_complex(...) | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1207:37:1207:63 | try_complex(...) | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1207:37:1207:63 | try_complex(...) | E | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1207:37:1207:63 | try_complex(...) | T | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1207:49:1207:62 | ...::Ok(...) | | file://:0:0:0:0 | Result |
|
||||
| main.rs:1207:49:1207:62 | ...::Ok(...) | | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/core/src/result.rs:520:1:538:1 | Result |
|
||||
| main.rs:1207:49:1207:62 | ...::Ok(...) | E | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1207:49:1207:62 | ...::Ok(...) | T | main.rs:1157:5:1158:14 | S1 |
|
||||
| main.rs:1207:60:1207:61 | S1 | | main.rs:1157:5:1158:14 | S1 |
|
||||
|
||||
@@ -11,23 +11,27 @@ class TypeLoc extends TypeFinal {
|
||||
) {
|
||||
exists(string file |
|
||||
this.getLocation().hasLocationInfo(file, startline, startcolumn, endline, endcolumn) and
|
||||
filepath = file.regexpReplaceAll("^/.*/tools/builtins/", "/BUILTINS/")
|
||||
filepath =
|
||||
file.regexpReplaceAll("^/.*/tools/builtins/", "/BUILTINS/")
|
||||
.regexpReplaceAll("^/.*/.rustup/toolchains/[^/]+/", "/RUSTUP_HOME/toolchain/")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
query predicate inferType(AstNode n, TypePath path, TypeLoc t) {
|
||||
t = TypeInference::inferType(n, path) and
|
||||
n.fromSource()
|
||||
n.fromSource() and
|
||||
not n.isFromMacroExpansion()
|
||||
}
|
||||
|
||||
module ResolveTest implements TestSig {
|
||||
string getARelevantTag() { result = ["method", "fieldof"] }
|
||||
|
||||
private predicate functionHasValue(Function f, string value) {
|
||||
f.getAPrecedingComment().getCommentText() = value
|
||||
f.getAPrecedingComment().getCommentText() = value and
|
||||
f.fromSource()
|
||||
or
|
||||
not exists(f.getAPrecedingComment()) and
|
||||
not any(f.getAPrecedingComment()).fromSource() and
|
||||
// TODO: Default to canonical path once that is available
|
||||
value = f.getName().getText()
|
||||
}
|
||||
@@ -35,7 +39,9 @@ module ResolveTest implements TestSig {
|
||||
predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
exists(AstNode source, AstNode target |
|
||||
location = source.getLocation() and
|
||||
element = source.toString()
|
||||
element = source.toString() and
|
||||
source.fromSource() and
|
||||
not source.isFromMacroExpansion()
|
||||
|
|
||||
target = source.(MethodCallExpr).getStaticTarget() and
|
||||
functionHasValue(target, value) and
|
||||
|
||||
@@ -4,31 +4,38 @@ import codeql.rust.controlflow.ControlFlowGraph
|
||||
import codeql.rust.dataflow.Ssa
|
||||
import codeql.rust.dataflow.internal.SsaImpl
|
||||
import Impl::TestAdjacentRefs as RefTest
|
||||
import TestUtils
|
||||
|
||||
query predicate definition(Ssa::Definition def, Variable v) { def.getSourceVariable() = v }
|
||||
query predicate definition(Ssa::Definition def, Variable v) {
|
||||
toBeTested(v.getEnclosingCfgScope()) and def.getSourceVariable() = v
|
||||
}
|
||||
|
||||
query predicate read(Ssa::Definition def, Variable v, CfgNode read) {
|
||||
def.getSourceVariable() = v and read = def.getARead()
|
||||
toBeTested(v.getEnclosingCfgScope()) and def.getSourceVariable() = v and read = def.getARead()
|
||||
}
|
||||
|
||||
query predicate firstRead(Ssa::Definition def, Variable v, CfgNode read) {
|
||||
def.getSourceVariable() = v and read = def.getAFirstRead()
|
||||
toBeTested(v.getEnclosingCfgScope()) and
|
||||
def.getSourceVariable() = v and
|
||||
read = def.getAFirstRead()
|
||||
}
|
||||
|
||||
query predicate adjacentReads(Ssa::Definition def, Variable v, CfgNode read1, CfgNode read2) {
|
||||
toBeTested(v.getEnclosingCfgScope()) and
|
||||
def.getSourceVariable() = v and
|
||||
def.hasAdjacentReads(read1, read2)
|
||||
}
|
||||
|
||||
query predicate phi(Ssa::PhiDefinition phi, Variable v, Ssa::Definition input) {
|
||||
phi.getSourceVariable() = v and input = phi.getAnInput()
|
||||
toBeTested(v.getEnclosingCfgScope()) and phi.getSourceVariable() = v and input = phi.getAnInput()
|
||||
}
|
||||
|
||||
query predicate phiReadNode(RefTest::Ref phi, Variable v) {
|
||||
phi.isPhiRead() and phi.getSourceVariable() = v
|
||||
toBeTested(v.getEnclosingCfgScope()) and phi.isPhiRead() and phi.getSourceVariable() = v
|
||||
}
|
||||
|
||||
query predicate phiReadNodeFirstRead(RefTest::Ref phi, Variable v, CfgNode read) {
|
||||
toBeTested(v.getEnclosingCfgScope()) and
|
||||
exists(RefTest::Ref r, BasicBlock bb, int i |
|
||||
phi.isPhiRead() and
|
||||
RefTest::adjacentRefRead(phi, r) and
|
||||
|
||||
@@ -1,29 +1,39 @@
|
||||
import rust
|
||||
import utils.test.InlineExpectationsTest
|
||||
import codeql.rust.elements.internal.VariableImpl::Impl as VariableImpl
|
||||
import TestUtils
|
||||
|
||||
query predicate variable(Variable v) { any() }
|
||||
query predicate variable(Variable v) { toBeTested(v.getEnclosingCfgScope()) }
|
||||
|
||||
query predicate variableAccess(VariableAccess va, Variable v) { v = va.getVariable() }
|
||||
query predicate variableAccess(VariableAccess va, Variable v) {
|
||||
variable(v) and toBeTested(va) and v = va.getVariable()
|
||||
}
|
||||
|
||||
query predicate variableWriteAccess(VariableWriteAccess va, Variable v) { v = va.getVariable() }
|
||||
query predicate variableWriteAccess(VariableWriteAccess va, Variable v) {
|
||||
variable(v) and toBeTested(va) and v = va.getVariable()
|
||||
}
|
||||
|
||||
query predicate variableReadAccess(VariableReadAccess va, Variable v) { v = va.getVariable() }
|
||||
query predicate variableReadAccess(VariableReadAccess va, Variable v) {
|
||||
variable(v) and toBeTested(va) and v = va.getVariable()
|
||||
}
|
||||
|
||||
query predicate variableInitializer(Variable v, Expr e) { e = v.getInitializer() }
|
||||
query predicate variableInitializer(Variable v, Expr e) {
|
||||
variable(v) and toBeTested(e) and e = v.getInitializer()
|
||||
}
|
||||
|
||||
query predicate capturedVariable(Variable v) { v.isCaptured() }
|
||||
query predicate capturedVariable(Variable v) { variable(v) and v.isCaptured() }
|
||||
|
||||
query predicate capturedAccess(VariableAccess va) { va.isCapture() }
|
||||
query predicate capturedAccess(VariableAccess va) { toBeTested(va) and va.isCapture() }
|
||||
|
||||
query predicate nestedFunctionAccess(VariableImpl::NestedFunctionAccess nfa, Function f) {
|
||||
f = nfa.getFunction()
|
||||
toBeTested(f) and f = nfa.getFunction()
|
||||
}
|
||||
|
||||
module VariableAccessTest implements TestSig {
|
||||
string getARelevantTag() { result = ["", "write_", "read_"] + "access" }
|
||||
|
||||
private predicate declAt(Variable v, string filepath, int line, boolean inMacro) {
|
||||
variable(v) and
|
||||
v.getLocation().hasLocationInfo(filepath, _, _, line, _) and
|
||||
if v.getPat().isInMacroExpansion() then inMacro = true else inMacro = false
|
||||
}
|
||||
@@ -46,6 +56,7 @@ module VariableAccessTest implements TestSig {
|
||||
|
||||
predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
exists(VariableAccess va |
|
||||
toBeTested(va) and
|
||||
location = va.getLocation() and
|
||||
element = va.toString() and
|
||||
decl(va.getVariable(), value)
|
||||
|
||||
@@ -1 +1 @@
|
||||
| 77 |
|
||||
| 60 |
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
| Inconsistencies - Path resolution | 0 |
|
||||
| Inconsistencies - SSA | 0 |
|
||||
| Inconsistencies - data flow | 0 |
|
||||
| Lines of code extracted | 77 |
|
||||
| Lines of code extracted | 60 |
|
||||
| Lines of user code extracted | 60 |
|
||||
| Macro calls - resolved | 8 |
|
||||
| Macro calls - total | 9 |
|
||||
|
||||
@@ -39,3 +39,16 @@ multiplePathResolutions
|
||||
| src/main.rs:53:38:53:50 | ...::from | file://:0:0:0:0 | fn from |
|
||||
| src/main.rs:53:38:53:50 | ...::from | file://:0:0:0:0 | fn from |
|
||||
| src/main.rs:53:38:53:50 | ...::from | file://:0:0:0:0 | fn from |
|
||||
multipleCanonicalPaths
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Equal as core::cmp::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Equal as typenum::marker_traits::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Greater as core::cmp::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Greater as typenum::marker_traits::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Less as core::cmp::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Less as typenum::marker_traits::Ord>::to_ordering |
|
||||
| file://:0:0:0:0 | impl Ord for Equal { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Equal as core::cmp::Ord> |
|
||||
| file://:0:0:0:0 | impl Ord for Equal { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Equal as typenum::marker_traits::Ord> |
|
||||
| file://:0:0:0:0 | impl Ord for Greater { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Greater as core::cmp::Ord> |
|
||||
| file://:0:0:0:0 | impl Ord for Greater { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Greater as typenum::marker_traits::Ord> |
|
||||
| file://:0:0:0:0 | impl Ord for Less { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Less as core::cmp::Ord> |
|
||||
| file://:0:0:0:0 | impl Ord for Less { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Less as typenum::marker_traits::Ord> |
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user