Package-level declarations

Types

Link copied to clipboard
class QueryException(val message: String) : Exception
Link copied to clipboard
open class QueryTree<T>(var value: T, val children: MutableList<QueryTree<*>> = mutableListOf(), var stringRepresentation: String = "") : Comparable<QueryTree<T>>

Holds the value to which the statements have been evaluated. The children define previous steps of the evaluation, thus building a tree of all steps of the evaluation recursively until we reach the nodes of the CPG. This is necessary if we want to store all steps which are performed when evaluating a query. It helps to make the reasoning of the query more understandable to the user and gives an analyst the maximum of information available.

Properties

Link copied to clipboard

Calls ValueEvaluator.evaluate for this expression, thus trying to resolve a constant value. The result is interpreted as an integer.

Link copied to clipboard

The maximal integer value of this expression. It uses the default argument for eval of max

Link copied to clipboard

The minimal integer value of this expression. It uses the default argument for eval of min

Link copied to clipboard

The size of this expression. It uses the default argument for eval of size

Link copied to clipboard

Calls ValueEvaluator.evaluate for this expression, thus trying to resolve a constant value.

Functions

Link copied to clipboard
inline fun <T> Node.all(noinline sel: (T) -> Boolean? = null, noinline mustSatisfy: (T) -> Boolean): Pair<Boolean, List<T>>

Evaluates if the conditions specified in mustSatisfy hold for all nodes in the graph. The optional argument sel can be used to filter nodes for which the condition has to be fulfilled.

Link copied to clipboard
inline fun <T> Node.allExtended(noinline sel: (T) -> Boolean? = null, noinline mustSatisfy: (T) -> QueryTree<Boolean>): QueryTree<Boolean>

Evaluates if the conditions specified in mustSatisfy hold for all nodes in the graph.

Link copied to clipboard

Does some magic to identify if the value which is in from also reaches to. To do so, it goes some data flow steps backwards in the graph (ideally to find the last assignment) and then follows this value to the node to.

Link copied to clipboard

Performs a logical and (&&) operation between the values of two QueryTrees.

Link copied to clipboard
fun <T> const(n: T): QueryTree<T>
fun <T : Comparable<T>> const(n: T): QueryTree<T>

This is a small wrapper to create a QueryTree containing a constant value, so that it can be used to in comparison with other QueryTree objects.

Link copied to clipboard
fun dataFlow(from: Node, to: Node, collectFailedPaths: Boolean = true, findAllPossiblePaths: Boolean = true): QueryTree<Boolean>

Checks if a data flow is possible between the nodes from as a source and to as sink.

fun dataFlow(from: Node, predicate: (Node) -> Boolean, collectFailedPaths: Boolean = true, findAllPossiblePaths: Boolean = true): QueryTree<Boolean>

Checks if a data flow is possible between the nodes from as a source and a node fulfilling predicate.

Link copied to clipboard

Checks if a path of execution flow is possible between the nodes from and to.

fun executionPath(from: Node, predicate: (Node) -> Boolean): QueryTree<Boolean>

Checks if a path of execution flow is possible starting at the node from and fulfilling the requirement specified in predicate.

Link copied to clipboard

Checks if a path of execution flow is possible ending at the node to and fulfilling the requirement specified in predicate.

Link copied to clipboard
inline fun <T> Node.exists(noinline sel: (T) -> Boolean? = null, noinline mustSatisfy: (T) -> Boolean): Pair<Boolean, List<T>>

Evaluates if the conditions specified in mustSatisfy hold for at least one node in the graph. The optional argument sel can be used to filter nodes which are considered during the evaluation.

Link copied to clipboard
inline fun <T> Node.existsExtended(noinline sel: (T) -> Boolean? = null, noinline mustSatisfy: (T) -> QueryTree<Boolean>): QueryTree<Boolean>

Evaluates if the conditions specified in mustSatisfy hold for at least one node in the graph.

Link copied to clipboard
infix fun <T : Number, S : Number> QueryTree<T>.ge(other: S): QueryTree<Boolean>

Compares the numeric values of a QueryTree and another number for this being "greater than or equal" (>=) other.

infix fun <T : Number, S : Number> QueryTree<T>.ge(other: QueryTree<S>): QueryTree<Boolean>

Compares the numeric values of two QueryTrees for this being "greater than or equal" (>=) other.

Link copied to clipboard
infix fun <T : Number, S : Number> QueryTree<T>.gt(other: S): QueryTree<Boolean>

Compares the numeric values of a QueryTree and another number for this being "greater than" (>) other.

infix fun <T : Number, S : Number> QueryTree<T>.gt(other: QueryTree<S>): QueryTree<Boolean>

Compares the numeric values of two QueryTrees for this being "greater than" (>) other.

Link copied to clipboard

Evaluates a logical implication (->) operation between the values of two QueryTrees.

Link copied to clipboard
operator fun Expression?.invoke(): QueryTree<Any?>

Calls ValueEvaluator.evaluate for this expression, thus trying to resolve a constant value.

Link copied to clipboard
infix fun <T : Number, S : Number> QueryTree<T>.le(other: S): QueryTree<Boolean>

Compares the numeric values of a QueryTree and another number for this being "less than or equal" (<=) other.

infix fun <T : Number, S : Number> QueryTree<T>.le(other: QueryTree<S>): QueryTree<Boolean>

Compares the numeric values of two QueryTrees for this being "less than or equal" (=) other.

Link copied to clipboard
infix fun <T : Number, S : Number> QueryTree<T>.lt(other: S): QueryTree<Boolean>

Compares the numeric values of a QueryTree and another number for this being "less than" (<) other.

infix fun <T : Number, S : Number> QueryTree<T>.lt(other: QueryTree<S>): QueryTree<Boolean>

Compares the numeric values of two QueryTrees for this being "less than" (<) other.

Link copied to clipboard
fun max(n: Node?, eval: ValueEvaluator = MultiValueEvaluator()): QueryTree<Number>

Retrieves the maximal value of the node.

fun max(n: List<Node>?, eval: ValueEvaluator = MultiValueEvaluator()): QueryTree<Number>

Retrieves the maximal value of the nodes in the list.

Link copied to clipboard

Determines the maximal value. Only works for a couple of types! TODO: This method needs improvement! It only works for Java types!

Link copied to clipboard
fun min(n: Node?, eval: ValueEvaluator = MultiValueEvaluator()): QueryTree<Number>

Retrieves the minimal value of the node.

fun min(n: List<Node>?, eval: ValueEvaluator = MultiValueEvaluator()): QueryTree<Number>

Retrieves the minimal value of the nodes in the list.

Link copied to clipboard

Determines the minimal value. Only works for a couple of types! TODO: This method needs improvement! It only works for Java types!

Link copied to clipboard

Negates the value of arg and returns the resulting QueryTree.

Link copied to clipboard

Performs a logical or (||) operation between the values of two QueryTrees.

Link copied to clipboard
fun sizeof(n: Node?, eval: ValueEvaluator = SizeEvaluator()): QueryTree<Int>

Evaluates the size of a node. The implementation is very, very basic!

Link copied to clipboard

Performs a logical xor operation between the values of two QueryTrees.