use of com.ge.verdict.attackdefensecollector.AttackDefenseCollector.Result in project VERDICT by ge-high-assurance.
the class Main method main.
@SuppressWarnings("deprecation")
public static void main(String[] args) throws IOException, CSVFile.MalformedInputException {
if (arrayContains(args, "--help")) {
System.out.println("Usage: " + USAGE);
return;
}
long start = System.currentTimeMillis();
// this argument parsing is pretty bad. but we shouldn't be using this anyway.
boolean inference = arrayContains(args, "--inference");
boolean cutSet = arrayContains(args, "--cut-set");
AttackDefenseCollector attackDefenseCollector;
// otherwise, we will load csv files
if (arrayContains(args, "--vdm")) {
attackDefenseCollector = new AttackDefenseCollector(new File(args[1]), new File(args[0]), inference);
} else {
attackDefenseCollector = new AttackDefenseCollector(args[0], inference);
}
List<Result> results = attackDefenseCollector.perform();
for (Result result : results) {
// Convert adtree to cutset only if --cut-set is on.
ADTree adtree = cutSet ? CutSetGenerator.generate(result.adtree) : result.adtree;
Logger.println();
// The default printer includes indentation for clean-ness
Logger.println(adtree);
Logger.println();
Logger.println("CyberReq: " + result.cyberReq.getName());
Logger.println("Mission: " + result.cyberReq.getMission());
Logger.println("Severity: " + result.cyberReq.getSeverity());
Logger.println("Computed: " + result.prob);
Logger.println("Successful: " + (Prob.lte(result.prob, result.cyberReq.getSeverity()) ? "Yes" : "No"));
}
Logger.println("Total time: " + (System.currentTimeMillis() - start) + " milliseconds");
}
use of com.ge.verdict.attackdefensecollector.AttackDefenseCollector.Result in project VERDICT by ge-high-assurance.
the class App method main.
/**
* This is just used for testing purposes. Uses CSV, not VDM (so out of date). See below for
* invocation.
*
* @param args
*/
public static void main(String[] args) {
if (args.length < 2) {
throw new RuntimeException("Must specify STEM output directory and cost model XML!");
}
long startTime = System.currentTimeMillis();
// Usage:
String stemOutDir = args[0];
String costModelXml = args[1];
boolean inference = arrayContains(args, "--inference");
boolean meritAssignment = arrayContains(args, "--merit-assignment");
boolean partialSolution = arrayContains(args, "--partial-solution") || meritAssignment;
boolean dumpSmtLib = arrayContains(args, "--dump-smtlib");
if (dumpSmtLib) {
System.out.println("Will dump SMT-LIB format to verdict-synthesis-dump.smtlib for debugging");
System.out.println("Parent directory: " + System.getProperty("user.dir"));
}
final CostModel costModel = timed("Load cost model", () -> new CostModel(new File(costModelXml)));
AttackDefenseCollector collector = timed("Load CSV", () -> {
try {
return new AttackDefenseCollector(stemOutDir, inference);
} catch (IOException | MalformedInputException e) {
throw new RuntimeException(e);
}
});
List<Result> results = timed("Build attack-defense tree", () -> collector.perform());
// This part is for the single cyber requirement version
// disabled because it doesn't work anymore
// for (Result result : results) {
// System.out.println();
// System.out.println("Result for cyber req: " + result.cyberReq.getName());
// DLeaf.Factory factory = new DLeaf.Factory();
// DTree dtree =
// timed(
// "Construct defense tree",
// () ->
// DTreeConstructor.construct(
// result.adtree,
// costModel,
// result.cyberReq.getSeverityDal(),
// partialSolution,
// false,
// factory));
// Optional<Pair<Set<ComponentDefense>, Double>> selected =
// timed(
// "Perform synthesis",
// () ->
// VerdictSynthesis.performSynthesisSingle(
// dtree,
// result.cyberReq.getSeverityDal(),
// factory,
// VerdictSynthesis.Approach.MAXSMT));
// if (selected.isPresent()) {
// for (ComponentDefense pair : selected.get().left) {
// System.out.println("Selected leaf: " + pair.toString());
// }
// System.out.println("Total cost: " + selected.get().right);
// }
// }
System.out.println("\n\n\n");
{
DLeaf.Factory factory = new DLeaf.Factory();
DTree dtree = timed("Construct defense tree", () -> DTreeConstructor.construct(results, costModel, partialSolution, meritAssignment, factory));
Optional<ResultsInstance> selected = timed("Perform synthesis", () -> VerdictSynthesis.performSynthesisMultiple(dtree, factory, costModel, partialSolution, true, meritAssignment, dumpSmtLib));
if (selected.isPresent()) {
selected.get().toStreamXml(System.out);
} else {
System.out.println("Failure?");
}
}
System.out.println(" == Total time: " + (System.currentTimeMillis() - startTime) + " milliseconds");
}
Aggregations