Search in sources :

Example 1 with Approach

use of com.ge.verdict.synthesis.VerdictSynthesis.Approach in project VERDICT by ge-high-assurance.

the class VerdictSynthesisTest method partialSolutionTest.

@Test
public void partialSolutionTest() {
    CostModel costModel = new CostModel(new File(getClass().getResource("partialCosts.xml").getPath()));
    int dal = 2;
    SystemModel system = new SystemModel("C1");
    Attack attack1 = new Attack(system.getAttackable(), "A1", "An attack", Prob.certain(), CIA.I);
    Defense defense1 = new Defense(attack1);
    defense1.addDefenseClause(Collections.singletonList(new Defense.DefenseLeaf("D1", Optional.of(new com.ge.verdict.attackdefensecollector.Pair<>("D1", 1)))));
    ADTree adtree = new ADOr(new ADAnd(new ADNot(defense1), attack1));
    for (Approach approach : Approach.values()) {
        {
            DLeaf.Factory factoryPartial = new DLeaf.Factory();
            Optional<Pair<Set<ComponentDefense>, Double>> resultPartial = VerdictSynthesis.performSynthesisSingle(DTreeConstructor.construct(adtree, costModel, dal, true, false, factoryPartial), dal, factoryPartial, approach);
            Assertions.assertThat(resultPartial.isPresent());
            Assertions.assertThat(resultPartial.get().right).isEqualTo(1);
        }
        {
            DLeaf.Factory factoryTotal = new DLeaf.Factory();
            Optional<Pair<Set<ComponentDefense>, Double>> resultTotal = VerdictSynthesis.performSynthesisSingle(DTreeConstructor.construct(adtree, costModel, dal, false, false, factoryTotal), dal, factoryTotal, approach);
            Assertions.assertThat(resultTotal.isPresent());
            Assertions.assertThat(resultTotal.get().right).isEqualTo(2);
        }
    }
}
Also used : DLeaf(com.ge.verdict.synthesis.dtree.DLeaf) Set(java.util.Set) ADNot(com.ge.verdict.attackdefensecollector.adtree.ADNot) Optional(java.util.Optional) ADAnd(com.ge.verdict.attackdefensecollector.adtree.ADAnd) Attack(com.ge.verdict.attackdefensecollector.adtree.Attack) Defense(com.ge.verdict.attackdefensecollector.adtree.Defense) ComponentDefense(com.ge.verdict.synthesis.dtree.DLeaf.ComponentDefense) ADTree(com.ge.verdict.attackdefensecollector.adtree.ADTree) SystemModel(com.ge.verdict.attackdefensecollector.model.SystemModel) Approach(com.ge.verdict.synthesis.VerdictSynthesis.Approach) ADOr(com.ge.verdict.attackdefensecollector.adtree.ADOr) File(java.io.File) Pair(com.ge.verdict.synthesis.util.Pair) Test(org.junit.Test)

Example 2 with Approach

use of com.ge.verdict.synthesis.VerdictSynthesis.Approach in project VERDICT by ge-high-assurance.

the class VerdictSynthesisTest method unmitigatedMixedTest.

@Test
public void unmitigatedMixedTest() {
    DLeaf.Factory factory = new DLeaf.Factory();
    SystemModel system = new SystemModel("S1");
    int targetDal = 1;
    Fraction[] costs = Util.fractionCosts(new double[] { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 });
    DLeaf dleaf = new DLeaf("S1", "D1", "A2", 0, targetDal, costs, factory);
    DTree dtree = new DOr(new ALeaf(new Attack(system.getAttackable(), "A1", "An attack", Prob.certain(), CIA.I)), dleaf);
    for (Approach approach : Approach.values()) {
        Optional<Pair<Set<ComponentDefense>, Double>> result = VerdictSynthesis.performSynthesisSingle(dtree, targetDal, factory, approach);
        Assertions.assertThat(result.isPresent());
        Assertions.assertThat(result.get().left).hasSize(1);
        Assertions.assertThat(result.get().left).contains(dleaf.componentDefense);
        Assertions.assertThat(result.get().right).isEqualTo(5);
    }
}
Also used : DLeaf(com.ge.verdict.synthesis.dtree.DLeaf) DTree(com.ge.verdict.synthesis.dtree.DTree) ADTree(com.ge.verdict.attackdefensecollector.adtree.ADTree) ADOr(com.ge.verdict.attackdefensecollector.adtree.ADOr) DOr(com.ge.verdict.synthesis.dtree.DOr) ALeaf(com.ge.verdict.synthesis.dtree.ALeaf) Fraction(org.apache.commons.math3.fraction.Fraction) Attack(com.ge.verdict.attackdefensecollector.adtree.Attack) SystemModel(com.ge.verdict.attackdefensecollector.model.SystemModel) ComponentDefense(com.ge.verdict.synthesis.dtree.DLeaf.ComponentDefense) Approach(com.ge.verdict.synthesis.VerdictSynthesis.Approach) Pair(com.ge.verdict.synthesis.util.Pair) Test(org.junit.Test)

Example 3 with Approach

use of com.ge.verdict.synthesis.VerdictSynthesis.Approach in project VERDICT by ge-high-assurance.

the class VerdictSynthesisTest method unmitigatedTest.

@Test
public void unmitigatedTest() {
    DLeaf.Factory factory = new DLeaf.Factory();
    SystemModel system = new SystemModel("S1");
    DTree dtree = new ALeaf(new Attack(system.getAttackable(), "A1", "An attack", Prob.certain(), CIA.I));
    for (Approach approach : Approach.values()) {
        Assertions.assertThat(VerdictSynthesis.performSynthesisSingle(dtree, 1, factory, approach)).isEmpty();
    }
}
Also used : DLeaf(com.ge.verdict.synthesis.dtree.DLeaf) SystemModel(com.ge.verdict.attackdefensecollector.model.SystemModel) DTree(com.ge.verdict.synthesis.dtree.DTree) ADTree(com.ge.verdict.attackdefensecollector.adtree.ADTree) ALeaf(com.ge.verdict.synthesis.dtree.ALeaf) Approach(com.ge.verdict.synthesis.VerdictSynthesis.Approach) Attack(com.ge.verdict.attackdefensecollector.adtree.Attack) Test(org.junit.Test)

Example 4 with Approach

use of com.ge.verdict.synthesis.VerdictSynthesis.Approach in project VERDICT by ge-high-assurance.

the class VerdictSynthesisTest method performSynthesisTest.

@Test
public void performSynthesisTest() {
    for (Approach approach : Approach.values()) {
        performSynthesisTestInternal(new int[] { 1, 2, 3 }, new String[] { "C1", "C2" }, approach);
        performSynthesisTestInternal(new int[] { 3, 2, 1 }, new String[] { "C3", "C2" }, approach);
        performSynthesisTestInternal(new int[] { 1, 3, 2 }, new String[] { "C1", "C3" }, approach);
    }
}
Also used : Approach(com.ge.verdict.synthesis.VerdictSynthesis.Approach) Test(org.junit.Test)

Aggregations

Approach (com.ge.verdict.synthesis.VerdictSynthesis.Approach)4 Test (org.junit.Test)4 ADTree (com.ge.verdict.attackdefensecollector.adtree.ADTree)3 Attack (com.ge.verdict.attackdefensecollector.adtree.Attack)3 SystemModel (com.ge.verdict.attackdefensecollector.model.SystemModel)3 DLeaf (com.ge.verdict.synthesis.dtree.DLeaf)3 ADOr (com.ge.verdict.attackdefensecollector.adtree.ADOr)2 ALeaf (com.ge.verdict.synthesis.dtree.ALeaf)2 ComponentDefense (com.ge.verdict.synthesis.dtree.DLeaf.ComponentDefense)2 DTree (com.ge.verdict.synthesis.dtree.DTree)2 Pair (com.ge.verdict.synthesis.util.Pair)2 ADAnd (com.ge.verdict.attackdefensecollector.adtree.ADAnd)1 ADNot (com.ge.verdict.attackdefensecollector.adtree.ADNot)1 Defense (com.ge.verdict.attackdefensecollector.adtree.Defense)1 DOr (com.ge.verdict.synthesis.dtree.DOr)1 File (java.io.File)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Fraction (org.apache.commons.math3.fraction.Fraction)1