Search in sources :

Example 1 with CyberExpr

use of verdict.vdm.vdm_model.CyberExpr in project VERDICT by ge-high-assurance.

the class Vdm2Csv method processMissionReqs.

private void processMissionReqs(List<verdict.vdm.vdm_model.Mission> missionReqs, Map<String, verdict.vdm.vdm_model.CyberReq> cyberReqsMap, Map<String, verdict.vdm.vdm_model.SafetyReq> safetyReqsMap, Table missionTable, String scenario, Map<String, List<ConnectionEnd>> connectionDestToSourceMap) {
    for (verdict.vdm.vdm_model.Mission missionReq : missionReqs) {
        // this may include safety requirements
        List<String> cyberReqIds = missionReq.getCyberReqs();
        for (String cyberReqId : cyberReqIds) {
            // get cyberReq Definition
            if (cyberReqsMap.containsKey(cyberReqId)) {
                verdict.vdm.vdm_model.CyberReq cyberReqDef = cyberReqsMap.get(cyberReqId);
                // get the condition of the cyberReq
                CyberExpr cyberReqCondition = cyberReqDef.getCondition();
                // or just single port and CIA
                if (cyberReqCondition.getKind() != null) {
                    // if condition is an OR expression get individual sub-expressions
                    if (cyberReqCondition.getKind().toString().equalsIgnoreCase("Or")) {
                        List<CyberExpr> subCyberCondList = cyberReqCondition.getOr().getExpr();
                        for (CyberExpr subCyberCond : subCyberCondList) {
                            updateCyberMissionsTable(missionTable, scenario, missionReq.getId(), cyberReqId, cyberReqDef.getCia(), cyberReqDef.getSeverity(), subCyberCond, connectionDestToSourceMap);
                        }
                    } else if (cyberReqCondition.getKind().toString().equalsIgnoreCase("And")) {
                        updateAndExprCyberMissionsTable(missionTable, scenario, missionReq.getId(), cyberReqId, cyberReqDef.getCia(), cyberReqDef.getSeverity(), cyberReqCondition, connectionDestToSourceMap);
                    } else {
                        throw new RuntimeException("Expression used as condition in Cyber Requirement is not supported.");
                    }
                } else {
                    // if condition has single port and CIa
                    updateCyberMissionsTable(missionTable, scenario, missionReq.getId(), cyberReqId, cyberReqDef.getCia(), cyberReqDef.getSeverity(), cyberReqCondition, connectionDestToSourceMap);
                }
            } else if (safetyReqsMap.containsKey(cyberReqId)) {
                verdict.vdm.vdm_model.SafetyReq safetyReqDef = safetyReqsMap.get(cyberReqId);
                // get the condition of the cyberReq
                verdict.vdm.vdm_model.SafetyReqExpr safetyReqCondition = safetyReqDef.getCondition();
                // or just single port and IA
                if (safetyReqCondition.getKind() != null) {
                    // if condition is an OR expression get individual sub-expressions
                    if (safetyReqCondition.getKind().toString().equalsIgnoreCase("Or")) {
                        List<verdict.vdm.vdm_model.SafetyReqExpr> subSafetyExprCondList = safetyReqCondition.getOr().getExpr();
                        for (verdict.vdm.vdm_model.SafetyReqExpr subCyberCond : subSafetyExprCondList) {
                            updateSafetyMissionsTable(missionTable, scenario, missionReq.getId(), cyberReqId, safetyReqDef.getTargetProbability(), subCyberCond, connectionDestToSourceMap);
                        }
                    } else if (safetyReqCondition.getKind().toString().equalsIgnoreCase("And")) {
                        updateAndExprSafetyMissionsTable(missionTable, scenario, missionReq.getId(), cyberReqId, safetyReqDef.getTargetProbability(), safetyReqCondition, connectionDestToSourceMap);
                    } else {
                        throw new RuntimeException("Expression used as condition in Safety Requirement is not supported.");
                    }
                } else {
                    // if condition has single port and CIa
                    updateSafetyMissionsTable(missionTable, scenario, missionReq.getId(), cyberReqId, safetyReqDef.getTargetProbability(), safetyReqCondition, connectionDestToSourceMap);
                }
            } else {
                throw new RuntimeException("Undefined cyber or safety requirement used in mission requirement.");
            }
        }
    }
}
Also used : SafetyReqExpr(verdict.vdm.vdm_model.SafetyReqExpr) CyberExpr(verdict.vdm.vdm_model.CyberExpr) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with CyberExpr

use of verdict.vdm.vdm_model.CyberExpr in project VERDICT by ge-high-assurance.

the class Vdm2Csv method updateCompDepTable.

private void updateCompDepTable(Table compDepTable, String qualNameComp, String packageName, String compTypeName, CyberExpr inputCyberExpr, CIAPort outputCIAPort) {
    if (inputCyberExpr.getKind() == null) {
        // expression is not an AND, OR, NOT expression
        compDepTable.addValue(qualNameComp);
        compDepTable.addValue(replaceColonsWithUnderscore(qualNameComp));
        compDepTable.addValue(packageName);
        compDepTable.addValue(compTypeName);
        CIAPort inpCIAPort = inputCyberExpr.getPort();
        compDepTable.addValue(inpCIAPort.getName());
        compDepTable.addValue(formatToSmall(inpCIAPort.getCia().name()));
        compDepTable.addValue(outputCIAPort.getName());
        compDepTable.addValue(formatToSmall(outputCIAPort.getCia().name()));
        compDepTable.capRow();
    } else if (inputCyberExpr.getKind().toString().equalsIgnoreCase("Or")) {
        List<CyberExpr> subInpCyberList = inputCyberExpr.getOr().getExpr();
        for (CyberExpr subInpCyberExpr : subInpCyberList) {
            updateCompDepTable(compDepTable, qualNameComp, packageName, compTypeName, subInpCyberExpr, outputCIAPort);
        }
    } else if (inputCyberExpr.getKind().toString().equalsIgnoreCase("And")) {
        updateCompDepTableWithAndCyberExpr(compDepTable, qualNameComp, packageName, compTypeName, inputCyberExpr, outputCIAPort);
    } else {
        throw new RuntimeException("Expression used as Cyber Relation input is not supported.");
    }
}
Also used : CIAPort(verdict.vdm.vdm_model.CIAPort) CyberExpr(verdict.vdm.vdm_model.CyberExpr) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with CyberExpr

use of verdict.vdm.vdm_model.CyberExpr in project VERDICT by ge-high-assurance.

the class Vdm2Csv method getPortsAndCIAsForMission.

private void getPortsAndCIAsForMission(CyberExpr inputCyberExpr, String[] portsCIAs, Map<String, List<ConnectionEnd>> connectionDestToSourceMap) {
    if (inputCyberExpr.getKind() == null) {
        // get port's linked source instance
        if (connectionDestToSourceMap.containsKey(inputCyberExpr.getPort().getName())) {
            List<ConnectionEnd> linkedSourcePorts = connectionDestToSourceMap.get(inputCyberExpr.getPort().getName());
            if (linkedSourcePorts.size() > 1) {
                throw new RuntimeException("Multiple Linked Source Ports is unexpected for ports in cyber expression.");
            }
            if (linkedSourcePorts.get(0).getSubcomponentPort() != null) {
                CompInstancePort depCompPort = linkedSourcePorts.get(0).getSubcomponentPort();
                if (portsCIAs[0].equalsIgnoreCase("")) {
                    portsCIAs[0] = depCompPort.getSubcomponent().getName();
                    portsCIAs[1] = depCompPort.getPort().getName();
                    portsCIAs[2] = formatToSmall(inputCyberExpr.getPort().getCia().name());
                } else {
                    portsCIAs[0] = portsCIAs[0] + ";" + depCompPort.getSubcomponent().getName();
                    portsCIAs[1] = portsCIAs[1] + ";" + depCompPort.getPort().getName();
                    portsCIAs[2] = portsCIAs[2] + ";" + formatToSmall(inputCyberExpr.getPort().getCia().name());
                }
            } else {
                throw new RuntimeException("Linked Source Port has no instance information");
            }
        } else {
            throw new RuntimeException("Missing component instance dependency. " + inputCyberExpr.getPort().getName() + " is not linked to a source port");
        }
    } else if (inputCyberExpr.getKind().toString().equalsIgnoreCase("And")) {
        List<CyberExpr> subInpCyberList = inputCyberExpr.getAnd().getExpr();
        for (CyberExpr subInpCyberExpr : subInpCyberList) {
            getPortsAndCIAsForMission(subInpCyberExpr, portsCIAs, connectionDestToSourceMap);
        }
    } else {
        throw new RuntimeException("VERDICT only supports DNF in cyber requirements.");
    }
}
Also used : CyberExpr(verdict.vdm.vdm_model.CyberExpr) CompInstancePort(verdict.vdm.vdm_model.CompInstancePort) ConnectionEnd(verdict.vdm.vdm_model.ConnectionEnd) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ArrayList (java.util.ArrayList)3 List (java.util.List)3 CyberExpr (verdict.vdm.vdm_model.CyberExpr)3 CIAPort (verdict.vdm.vdm_model.CIAPort)1 CompInstancePort (verdict.vdm.vdm_model.CompInstancePort)1 ConnectionEnd (verdict.vdm.vdm_model.ConnectionEnd)1 SafetyReqExpr (verdict.vdm.vdm_model.SafetyReqExpr)1