Expand description
The query engine and framework for defining paralegal policies.
It provides a state machine for programmatically extracting and parsing a Semantic Program Dependence Graph (SPDG) and provides combinators and queries on this graph for you to compose into policies.
Next we show you the most common workflow, then explain the steps and show you how to customize them to your needs.
SPDGGenCommand::global()
.run("project/dir/to/analyze")?
.with_context(|ctx| my_property(ctx))
-
SPDGGenCommand
lets you programmatically invoke the SDPG extractor. The::global()
method usescargo paralegal-flow
for this purpose, e.g. a global installation ofcargo-paralegal-flow
that was performed withcargo install
.::custom()
lets you instead pick a different binary to run, for instance from a local installation..get_command()
lets you customize the command, for instance by passing additional arguments such as--debug
or--dump
.
-
.run(dir)
invokes the extractor indir
, returning the path (as aGraphLocation
) where the SPDG was written to.Re-running this command often is cheap, because rustc skips the execution if there are no changes.
You may generate the graph manually and skip steps 1 and 2. In this case you can specify the
GraphLocation
with::std()
, which uses the default graph file name or::custom()
to use a custom file name. -
.with_context()
reads and parses the graph file, then invokes the provided closure with aContext
. After the closure returns it automatically invokesRootContext::emit_diagnostics
.
For information about how to specify policies see the Context
struct.
Note: This crate defines both the interface to the property checkers (via
Context
) and the implementation of the engine (via
GraphLocation::build_context
). A future version of this crate should
ideally separate those out so property checkers do not need to depend on the
checker implementation.
Re-exports§
pub use self::algo::flows_to::CtrlFlowsTo;
pub use self::algo::flows_to::DataAndControlInfluencees;
pub use self::diagnostics::CombinatorContext;
pub use self::diagnostics::Diagnostics;
pub use self::diagnostics::PolicyContext;
pub use paralegal_spdg;
Modules§
- Algorithms for querying the graph
- context 🔒
- Emit messages to the user running a policy.
Macros§
- Check the condition and emit a
Diagnostics::error
if it fails. - Check the condition and emit a
Diagnostics::warning
if it fails. - A convenience macro that uses
file!
,line!
andcolumn!
to return the string"file:line:column"
. This can be used to mention policy source locations in policies.
Structs§
- Configuration for the framework
- Provide display trait for DefId in a Context.
- A globally identified node in an SPDG
- A path to a
ProgramDescription
file from which aContext
can be created. - Collection of entities a particular marker has been applied to
- Result of running a policy
- The annotated program dependence graph.
- Interface for defining policies.
- Configuration of the
cargo paralegal-flow
command. - Statistics about the runtime of the various parts of a policy.
Enums§
- Which type of edges should be considered for a given traversal
Traits§
- Actions that behave differently depending on the context
- This lets us be agnostic whether a primitive (such as
flows_to
) is called with aGlobalNode
or&NodeCluster
. - Extension trait with queries for single nodes
- Context queries conveniently accessible on nodes
Type Aliases§
- The type identifying a function that is used in call sites.
- Identifier for a graph element that allows attaching a marker.
- User-defined PDG markers.