From 8759b0bf14142bfc960df7d4479ceba0431fcc5c Mon Sep 17 00:00:00 2001 From: KuechA <31155350+KuechA@users.noreply.github.com> Date: Thu, 23 Nov 2023 21:24:01 +0100 Subject: [PATCH] Add some properties for specifying DFG edges more precisely (#1370) --- .../aisec/cpg/graph/edge/Properties.kt | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/edge/Properties.kt b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/edge/Properties.kt index 340eb2b866..1f4d9cfb29 100644 --- a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/edge/Properties.kt +++ b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/edge/Properties.kt @@ -25,6 +25,8 @@ */ package de.fraunhofer.aisec.cpg.graph.edge +import java.util.* + /** * INDEX: (int) Indicates the position in a list of edges * @@ -50,7 +52,10 @@ enum class Properties { UNREACHABLE, ACCESS, DEPENDENCE, - DYNAMIC_INVOKE + DYNAMIC_INVOKE, + SENSITIVITY, + CALLING_CONTEXT_IN, + CALLING_CONTEXT_OUT } /** The types of dependencies that might be represented in the CPG */ @@ -58,3 +63,18 @@ enum class DependenceType { CONTROL, DATA } + +/** Sensitivity options (of DFG edges). */ +enum class SensitivitySpecifier { + FIELD, + CONTEXT; + + infix fun and(other: SensitivitySpecifier) = Sensitivities.of(this, other) +} + +typealias Sensitivities = EnumSet + +infix fun Sensitivities.allOf(other: Sensitivities) = this.containsAll(other) + +infix fun Sensitivities.and(other: SensitivitySpecifier) = + Sensitivities.of(other, *this.toTypedArray())