Search in sources :

Example 11 with DLeaf

use of com.ge.verdict.synthesis.dtree.DLeaf in project VERDICT by ge-high-assurance.

the class DTreeConstructorTest method testUnmitigatedMixed.

@Test
public void testUnmitigatedMixed() {
    DLeaf.Factory factory = new DLeaf.Factory();
    CostModel dummyCosts = new CostModel(new File(getClass().getResource("dummyCosts.xml").getPath()));
    int dal = 5;
    SystemModel system = new SystemModel("S1");
    Attack attack1 = new Attack(system.getAttackable(), "A1", "An attack", Prob.certain(), CIA.I);
    Attack attack2 = new Attack(system.getAttackable(), "A2", "An attack", Prob.certain(), CIA.I);
    Defense defense1 = new Defense(attack1);
    defense1.addDefenseClause(Collections.singletonList(new Defense.DefenseLeaf("D1", Optional.empty())));
    ADTree adtree = new ADOr(new ADNot(defense1), attack1, attack2);
    Fraction[] costs = Util.fractionCosts(new double[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
    DTree dtree = new DAnd(Arrays.asList(new DOr(Collections.singletonList(new DAnd(Collections.singletonList(new DLeaf("S1", "D1", "A1", 0, dal, costs, factory))))), new ALeaf(attack2)));
    Assertions.assertThat(DTreeConstructor.construct(adtree, dummyCosts, dal, false, false, factory).prettyPrint()).isEqualTo(dtree.prettyPrint());
}
Also used : DLeaf(com.ge.verdict.synthesis.dtree.DLeaf) ADNot(com.ge.verdict.attackdefensecollector.adtree.ADNot) 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) ADAnd(com.ge.verdict.attackdefensecollector.adtree.ADAnd) DAnd(com.ge.verdict.synthesis.dtree.DAnd) Defense(com.ge.verdict.attackdefensecollector.adtree.Defense) ADTree(com.ge.verdict.attackdefensecollector.adtree.ADTree) SystemModel(com.ge.verdict.attackdefensecollector.model.SystemModel) ADOr(com.ge.verdict.attackdefensecollector.adtree.ADOr) File(java.io.File) Test(org.junit.Test)

Example 12 with DLeaf

use of com.ge.verdict.synthesis.dtree.DLeaf in project VERDICT by ge-high-assurance.

the class DTreeConstructorTest method testFlattenNot.

@Test
public void testFlattenNot() {
    // Note: comparing the results of prettyPrint() instead of the trees directly
    // because we have not implemented equals for the DTree classes
    DLeaf.Factory factory = new DLeaf.Factory();
    Fraction[] costs = Util.fractionCosts(new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
    DTree leaf = new DLeaf("A", "A", "A", 0, 1, costs, factory);
    DTree dtree = new DNot(new DNot(leaf));
    Assertions.assertThat(dtree.prepare().get().prettyPrint()).isEqualTo(leaf.prettyPrint());
    DTree dtree2 = new DAnd(Collections.singletonList(new DOr(Collections.singletonList(dtree))));
    DTree dtree3 = new DAnd(Collections.singletonList(new DOr(Collections.singletonList(leaf))));
    Assertions.assertThat(dtree2.prepare().get().prettyPrint()).isEqualTo(dtree3.prettyPrint());
}
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) Fraction(org.apache.commons.math3.fraction.Fraction) ADAnd(com.ge.verdict.attackdefensecollector.adtree.ADAnd) DAnd(com.ge.verdict.synthesis.dtree.DAnd) DNot(com.ge.verdict.synthesis.dtree.DNot) ADNot(com.ge.verdict.attackdefensecollector.adtree.ADNot) Test(org.junit.Test)

Example 13 with DLeaf

use of com.ge.verdict.synthesis.dtree.DLeaf in project VERDICT by ge-high-assurance.

the class DLeafTest method testMultipleRequirements.

@Test
public void testMultipleRequirements() {
    DLeaf.Factory factory = new DLeaf.Factory();
    Fraction[] costs = Util.fractionCosts(new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
    DLeaf leaf1 = new DLeaf("A", "A", "A", 0, 1, costs, factory);
    DLeaf leaf2 = new DLeaf("A", "A", "A", 0, 2, costs, factory);
    Assertions.assertThat(leaf1.targetDal).isEqualTo(1);
    Assertions.assertThat(leaf2.targetDal).isEqualTo(2);
}
Also used : DLeaf(com.ge.verdict.synthesis.dtree.DLeaf) Fraction(org.apache.commons.math3.fraction.Fraction) Test(org.junit.Test)

Example 14 with DLeaf

use of com.ge.verdict.synthesis.dtree.DLeaf in project VERDICT by ge-high-assurance.

the class DTreeConstructorTest method partialSolutionTest.

@Test
public void partialSolutionTest() {
    DLeaf.Factory factory = new DLeaf.Factory();
    CostModel dummyCosts = new CostModel(new File(getClass().getResource("dummyCosts.xml").getPath()));
    int dal = 5;
    SystemModel system = new SystemModel("S1");
    Attack attack1 = new Attack(system.getAttackable(), "A1", "An attack", Prob.certain(), CIA.I);
    Attack attack2 = new Attack(system.getAttackable(), "A2", "An attack", Prob.certain(), CIA.A);
    Defense defense1 = new Defense(attack1);
    defense1.addDefenseClause(Collections.singletonList(new Defense.DefenseLeaf("D1", Optional.of(new Pair<>("D1", 3)))));
    Defense defense2 = new Defense(attack2);
    defense2.addDefenseClause(Collections.singletonList(new Defense.DefenseLeaf("D2", Optional.empty())));
    ADTree adtree = new ADOr(new ADNot(defense1), attack1, new ADNot(defense2), attack2);
    Fraction[] costs = Util.fractionCosts(new double[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
    DTree dtree = new DAnd(new DOr(new DAnd(new DLeaf("S1", "D1", "A1", 3, dal, costs, factory))), new DOr(new DAnd(new DLeaf("S1", "D2", "A2", 0, dal, costs, factory))));
    Assertions.assertThat(DTreeConstructor.construct(adtree, dummyCosts, dal, true, false, factory).prepare().get().prettyPrint()).isEqualTo(dtree.prettyPrint());
}
Also used : DLeaf(com.ge.verdict.synthesis.dtree.DLeaf) ADNot(com.ge.verdict.attackdefensecollector.adtree.ADNot) 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) Fraction(org.apache.commons.math3.fraction.Fraction) Attack(com.ge.verdict.attackdefensecollector.adtree.Attack) ADAnd(com.ge.verdict.attackdefensecollector.adtree.ADAnd) DAnd(com.ge.verdict.synthesis.dtree.DAnd) Defense(com.ge.verdict.attackdefensecollector.adtree.Defense) ADTree(com.ge.verdict.attackdefensecollector.adtree.ADTree) SystemModel(com.ge.verdict.attackdefensecollector.model.SystemModel) ADOr(com.ge.verdict.attackdefensecollector.adtree.ADOr) File(java.io.File) Pair(com.ge.verdict.attackdefensecollector.Pair) Test(org.junit.Test)

Example 15 with DLeaf

use of com.ge.verdict.synthesis.dtree.DLeaf in project VERDICT by ge-high-assurance.

the class DTreeConstructorTest method multipleRequirementsTest.

@Test
public void multipleRequirementsTest() {
    DLeaf.Factory factory = new DLeaf.Factory();
    CostModel dummyCosts = new CostModel(new File(getClass().getResource("dummyCosts.xml").getPath()));
    SystemModel system = new SystemModel("S1");
    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.empty())));
    List<AttackDefenseCollector.Result> results = Arrays.asList(new AttackDefenseCollector.Result(system, new CyberReq("req1", "mission1", 5, "port1", CIA.I), new ADAnd(new ADNot(defense1), attack1), Prob.certain()), new AttackDefenseCollector.Result(system, new CyberReq("req1", "mission1", 7, "port1", CIA.I), new ADAnd(new ADNot(defense1), attack1), Prob.certain()));
    DTree dtree = new DAnd(new DOr(new DOr(new DAnd(new DLeaf("S1", "D1", "A1", 0, 5, dummyCosts, factory, false, false)))), new DOr(new DOr(new DAnd(new DLeaf("S1", "D1", "A1", 0, 7, dummyCosts, factory, false, false)))));
    Assertions.assertThat(DTreeConstructor.construct(results, dummyCosts, false, false, factory).prepare().get().prettyPrint()).isEqualTo(dtree.prettyPrint());
}
Also used : DLeaf(com.ge.verdict.synthesis.dtree.DLeaf) ADNot(com.ge.verdict.attackdefensecollector.adtree.ADNot) DTree(com.ge.verdict.synthesis.dtree.DTree) ADTree(com.ge.verdict.attackdefensecollector.adtree.ADTree) CyberReq(com.ge.verdict.attackdefensecollector.model.CyberReq) ADOr(com.ge.verdict.attackdefensecollector.adtree.ADOr) DOr(com.ge.verdict.synthesis.dtree.DOr) AttackDefenseCollector(com.ge.verdict.attackdefensecollector.AttackDefenseCollector) ADAnd(com.ge.verdict.attackdefensecollector.adtree.ADAnd) Attack(com.ge.verdict.attackdefensecollector.adtree.Attack) ADAnd(com.ge.verdict.attackdefensecollector.adtree.ADAnd) DAnd(com.ge.verdict.synthesis.dtree.DAnd) Defense(com.ge.verdict.attackdefensecollector.adtree.Defense) SystemModel(com.ge.verdict.attackdefensecollector.model.SystemModel) File(java.io.File) Test(org.junit.Test)

Aggregations

DLeaf (com.ge.verdict.synthesis.dtree.DLeaf)16 Fraction (org.apache.commons.math3.fraction.Fraction)14 Test (org.junit.Test)14 ADTree (com.ge.verdict.attackdefensecollector.adtree.ADTree)11 DTree (com.ge.verdict.synthesis.dtree.DTree)11 ADOr (com.ge.verdict.attackdefensecollector.adtree.ADOr)9 DOr (com.ge.verdict.synthesis.dtree.DOr)9 ADAnd (com.ge.verdict.attackdefensecollector.adtree.ADAnd)7 DAnd (com.ge.verdict.synthesis.dtree.DAnd)7 File (java.io.File)6 ADNot (com.ge.verdict.attackdefensecollector.adtree.ADNot)5 Attack (com.ge.verdict.attackdefensecollector.adtree.Attack)5 Defense (com.ge.verdict.attackdefensecollector.adtree.Defense)5 SystemModel (com.ge.verdict.attackdefensecollector.model.SystemModel)5 ALeaf (com.ge.verdict.synthesis.dtree.ALeaf)3 ComponentDefense (com.ge.verdict.synthesis.dtree.DLeaf.ComponentDefense)3 ResultsInstance (com.ge.verdict.vdm.synthesis.ResultsInstance)3 Pair (com.ge.verdict.synthesis.util.Pair)2 AttackDefenseCollector (com.ge.verdict.attackdefensecollector.AttackDefenseCollector)1 Pair (com.ge.verdict.attackdefensecollector.Pair)1