codyze-evaluator

Basics of Program Analysis and its Application in the Query API.

To write meaningful queries, it is useful to get familiar with some terminology used in program analysis since this is used to configure the functions used during the analysis.

Several functions share the following configuration options:

AnalysisType

In general, it is possible to differentiate between a Must and May analysis:

The functions dataFlow, alwaysFlowsTo and executionPath receive this configuration via the argument type. The two objects Must and May allow this configuration.

AnalysisScope

We provide several options to configure the scope of the analysis. Most importantly, it is necessary to understand the difference between interprocedural and intraprocedural analysis.

In addition, InterproceduralWithDfgTermination can be used by alwaysFlowsTo to terminate following the evaluation order if the predicate can no longer be fulfilled on a path leaving a function. E.g. if not a single target of the start node’s dataflows is in the scope of the function containing the call-site, it is not promising to keep iterating the EOG from this call-site.

AnalysisDirection

Depending on the use-case, it can be required to follow edges in the direction of the control flow or against it. We account for this difference by providing a configuration option for the direction of the analysis:

All of these options can be configured with the graph that should be followed. Currently, the options EOG and DFG are available.

!!! note “Note: Implicit dataflows”

If configured with the AnalysisScope `Implicit`, the `DFG` will actually iterate through the program dependence graph (PDG) which includes the control dependence graph (CDG) as well.

Sensitivities

In program analysis, we can distinguish between different types of sensitivities. These represent different challenges when following the flow of program execution or data through the program. Some classes which are also considered in our tooling are:

!!! note

It is not possible to compute an efficient solution for a combination of all possible sensitivities in program analysis.

We use the term “sensitivity” to configure other aspects of the analysis as well, i.e., the user can configure:

The sensitivities can be configured by passing the argument sensitivity. It accepts a variable length of arguments (vararg) which is equivalent to an array. To simplify constructing the respective typed array, we provide utility functions by overriding the + operator. Hence, you can configure the functions dataFlow, alwaysFlowsTo and executionPath, you can simply call them with the (named) argument sensitivities = ContextSensitive + FieldSensitive as an example.