Skip to content

Running the Analysis Locally using our Java API ​

Initializing the Analysis ​

To use the analysis one needs to use the corresponding Analysis Builder required to run the analysis: In the instance of DFD Models one should use the DFDDataFlowAnalysisBuilder class and for PCM Models the PCMDataFlowConfidentialityAnalysisBuilder.

Then, one needs to define paths to the corresponding models within a eclipse modeling project. An example for a eclipse modeling project is the example models bundle at bundles/org.dataflowanalysis.analysis.examplemodels

java
final Path usageModelPath = Paths.get("scenarios", "pcm", "InternationalOnlineShop", "default.usagemodel");
final Path allocationPath = Paths.get("scenarios", "pcm", "InternationalOnlineShop", "default.allocation");
final Path nodeCharacteristicsPath = Paths.get("scenarios", "pcm", "InternationalOnlineShop", "default.nodecharacteristics");

pcmAnalysis = new PCMDataFlowConfidentialityAnalysisBuilder().standalone()
        .modelProjectName(TEST_MODEL_PROJECT_NAME)
        .usePluginActivator(Activator.class)
        .useUsageModel(usageModelPath.toString())
        .useAllocationModel(allocationPath.toString())
        .useNodeCharacteristicsModel(nodeCharacteristicsPath.toString())
        .build();
pcmAnalysis.initializeAnalysis();

Currently, running the analysis is only possible in standalone mode and is set by calling standalone(). The Activator class is provided to usePluginAcivator(Class<? extends Plugin>), while the models are passed to their corresponding use methods. Finally, a constructed analysis is built from the builder by calling build(). This steps also runs some precursory validation on the provided setup.

java
final Path usageModelPath = Paths.get("scenarios", "pcm", "InternationalOnlineShop", "default.usagemodel");
final Path allocationPath = Paths.get("scenarios", "pcm", "InternationalOnlineShop", "default.allocation");
final Path nodeCharacteristicsPath = Paths.get("scenarios", "pcm", "InternationalOnlineShop", "default.nodecharacteristics");

pcmAnalysis = new PCMDataFlowConfidentialityAnalysisBuilder().standalone()
        .modelProjectName(TEST_MODEL_PROJECT_NAME)
        .usePluginActivator(Activator.class)
        .useUsageModel(usageModelPath.toString())
        .useAllocationModel(allocationPath.toString())
        .useNodeCharacteristicsModel(nodeCharacteristicsPath.toString())
        .build();
pcmAnalysis.initializeAnalysis();

The analysis is fully initalized by calling initializeAnalysis() on the created analysis object. If any errors during model loading occur, they will be logged on the command line logger.

java
final Path usageModelPath = Paths.get("scenarios", "pcm", "InternationalOnlineShop", "default.usagemodel");
final Path allocationPath = Paths.get("scenarios", "pcm", "InternationalOnlineShop", "default.allocation");
final Path nodeCharacteristicsPath = Paths.get("scenarios", "pcm", "InternationalOnlineShop", "default.nodecharacteristics");

pcmAnalysis = new PCMDataFlowConfidentialityAnalysisBuilder().standalone()
        .modelProjectName(TEST_MODEL_PROJECT_NAME)
        .usePluginActivator(Activator.class)
        .useUsageModel(usageModelPath.toString())
        .useAllocationModel(allocationPath.toString())
        .useNodeCharacteristicsModel(nodeCharacteristicsPath.toString())
        .build();
pcmAnalysis.initializeAnalysis();

Writing contstraints and finding violations ​

java
PCMFlowGraphCollection flowGraphs = pcmAnalysis.findFlowGraphs();
flowGraphs.evaluate();

AnalysisConstraint constraint = new ConstraintDSL().ofData()
        .withLabel("DataSensitivity", List.of("Personal"))
        .fromNode()
        .neverFlows()
        .toVertex()
        .withCharacteristic("ServerLocation", "nonEU")
        .create();

logger.info("Evaluating DSL constraint: \"%s\"".formatted(constraint.toString()));

List<DSLResult> result = constraint.findViolations(flowGraphs);

if (result.size() > 0) {
    logger.info("Confidentiality violations found: %s".formatted(result.toString()));
} else {
    logger.info("No confidentiality violations found.");
}

xDECAF – An extensible data flow diagram constraint analysis framework for information security. Imprint, Legals, Privacy Policy.