Search in sources :

Example 11 with Defense

use of com.ge.verdict.attackdefensecollector.adtree.Defense in project VERDICT by ge-high-assurance.

the class SystemModel method concretize.

/**
 * Build all of the maps used by trace(). This is performed once for significant time complexity
 * improvements.
 */
public void concretize() {
    outputConcernToCyberRel = new LinkedHashMap<>();
    destPortToOutgoingInternalConnection = new LinkedHashMap<>();
    sourcePortToIncomingInternalConnection = new LinkedHashMap<>();
    inputPortToIncomingConnection = new LinkedHashMap<>();
    attackToDefense = new LinkedHashMap<>();
    for (CyberRel cyberRel : cyberRels) {
        Util.putListMap(outputConcernToCyberRel, cyberRel.getOutput(), cyberRel);
    }
    for (ConnectionModel connection : getInternalOutgoingConnections()) {
        Util.putListMap(destPortToOutgoingInternalConnection, connection.getDestinationPortName(), connection);
    }
    for (ConnectionModel connection : getInternalIncomingConnections()) {
        Util.putListMap(sourcePortToIncomingInternalConnection, connection.getSourcePortName(), connection);
    }
    for (ConnectionModel connection : getIncomingConnections()) {
        Util.putListMap(inputPortToIncomingConnection, connection.getDestinationPortName(), connection);
    }
    Set<Attack> declaredAttacks = new HashSet<>();
    for (Attack attack : attackable.getAttacks()) {
        declaredAttacks.add(attack);
    }
    for (Defense defense : attackable.getDefenses()) {
        // Check that referenced attacks are added to this system
        if (!declaredAttacks.contains(defense.getAttack())) {
            throw new RuntimeException("Defense in system " + getName() + " refers to non-existant attack " + defense.getAttack().getName());
        }
        attackToDefense.put(defense.getAttack(), defense);
    }
}
Also used : Attack(com.ge.verdict.attackdefensecollector.adtree.Attack) Defense(com.ge.verdict.attackdefensecollector.adtree.Defense) HashSet(java.util.HashSet)

Example 12 with Defense

use of com.ge.verdict.attackdefensecollector.adtree.Defense in project VERDICT by ge-high-assurance.

the class VerdictSynthesisTest method biggerMeritAssignmentTest.

@Test
public void biggerMeritAssignmentTest() {
    CostModel costModel = new CostModel(new File(getClass().getResource("meritCosts.xml").getPath()));
    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)))));
    Attack attack2 = new Attack(system.getAttackable(), "A2", "An attack", Prob.certain(), CIA.I);
    Defense defense2 = new Defense(attack2);
    defense2.addDefenseClause(Collections.singletonList(new Defense.DefenseLeaf("D2", Optional.of(new com.ge.verdict.attackdefensecollector.Pair<>("D2", 1)))));
    ADTree adtree = new ADAnd(new ADOr(new ADAnd(new ADNot(defense1), attack1)), new ADOr(new ADAnd(new ADNot(defense2), attack2)));
    DLeaf.Factory factory = new DLeaf.Factory();
    List<AttackDefenseCollector.Result> results = Arrays.asList(new AttackDefenseCollector.Result(system, new CyberReq("req1", "mission1", 1, "port1", CIA.I), adtree, Prob.certain()));
    Optional<ResultsInstance> result = VerdictSynthesis.performSynthesisMultiple(DTreeConstructor.construct(results, costModel, true, true, factory), factory, costModel, true, true, true, false);
    Assertions.assertThat(result.isPresent());
    Assertions.assertThat(result.get().items.size()).isEqualTo(2);
    Assertions.assertThat(result.get().outputCost).isEqualTo(new Fraction(1));
}
Also used : DLeaf(com.ge.verdict.synthesis.dtree.DLeaf) ADNot(com.ge.verdict.attackdefensecollector.adtree.ADNot) CyberReq(com.ge.verdict.attackdefensecollector.model.CyberReq) ADAnd(com.ge.verdict.attackdefensecollector.adtree.ADAnd) AttackDefenseCollector(com.ge.verdict.attackdefensecollector.AttackDefenseCollector) Fraction(org.apache.commons.math3.fraction.Fraction) Attack(com.ge.verdict.attackdefensecollector.adtree.Attack) ResultsInstance(com.ge.verdict.vdm.synthesis.ResultsInstance) 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) ADOr(com.ge.verdict.attackdefensecollector.adtree.ADOr) File(java.io.File) Pair(com.ge.verdict.synthesis.util.Pair) Test(org.junit.Test)

Aggregations

Defense (com.ge.verdict.attackdefensecollector.adtree.Defense)12 Attack (com.ge.verdict.attackdefensecollector.adtree.Attack)11 ADOr (com.ge.verdict.attackdefensecollector.adtree.ADOr)10 ADTree (com.ge.verdict.attackdefensecollector.adtree.ADTree)10 ADAnd (com.ge.verdict.attackdefensecollector.adtree.ADAnd)8 ADNot (com.ge.verdict.attackdefensecollector.adtree.ADNot)8 DLeaf (com.ge.verdict.synthesis.dtree.DLeaf)8 SystemModel (com.ge.verdict.attackdefensecollector.model.SystemModel)7 File (java.io.File)7 DOr (com.ge.verdict.synthesis.dtree.DOr)6 DTree (com.ge.verdict.synthesis.dtree.DTree)6 Test (org.junit.Test)6 DAnd (com.ge.verdict.synthesis.dtree.DAnd)5 Optional (java.util.Optional)4 Set (java.util.Set)4 Fraction (org.apache.commons.math3.fraction.Fraction)4 AttackDefenseCollector (com.ge.verdict.attackdefensecollector.AttackDefenseCollector)3 CyberReq (com.ge.verdict.attackdefensecollector.model.CyberReq)3 ALeaf (com.ge.verdict.synthesis.dtree.ALeaf)3 ArrayList (java.util.ArrayList)3