Search in sources :

Example 1 with ThreatDatabase

use of com.ge.research.osate.verdict.dsl.verdict.ThreatDatabase in project VERDICT by ge-high-assurance.

the class VerdictJavaValidator method checkThreatDatabase.

/**
 * Check that threat database IDs are non-empty and unique.
 *
 * @param database
 */
@Check(CheckType.FAST)
public void checkThreatDatabase(ThreatDatabase database) {
    List<String> otherDatabases = new ArrayList<>();
    AadlPackage top = ThreatModelUtil.getAadlPackage(database);
    if (database.getId().length() == 0) {
        error("Threat database must specify an ID", VerdictPackage.Literals.THREAT_DATABASE__ID);
    } else {
        for (AnnexLibrary library : top.getOwnedPublicSection().getOwnedAnnexLibraries()) {
            if ("verdict".equals(library.getName())) {
                VerdictThreatModels threats = ThreatModelUtil.getVerdictThreatModels(library);
                for (ThreatStatement statement : threats.getStatements()) {
                    if (statement instanceof ThreatDatabase && statement != database) {
                        otherDatabases.add(((ThreatDatabase) statement).getId());
                    }
                }
            }
        }
        if (otherDatabases.contains(database.getId())) {
            error("Duplicate ID: " + database.getId(), VerdictPackage.Literals.THREAT_DATABASE__ID);
        }
    }
}
Also used : AadlPackage(org.osate.aadl2.AadlPackage) VerdictThreatModels(com.ge.research.osate.verdict.dsl.verdict.VerdictThreatModels) ThreatStatement(com.ge.research.osate.verdict.dsl.verdict.ThreatStatement) ThreatDatabase(com.ge.research.osate.verdict.dsl.verdict.ThreatDatabase) ArrayList(java.util.ArrayList) AnnexLibrary(org.osate.aadl2.AnnexLibrary) Check(org.eclipse.xtext.validation.Check)

Aggregations

ThreatDatabase (com.ge.research.osate.verdict.dsl.verdict.ThreatDatabase)1 ThreatStatement (com.ge.research.osate.verdict.dsl.verdict.ThreatStatement)1 VerdictThreatModels (com.ge.research.osate.verdict.dsl.verdict.VerdictThreatModels)1 ArrayList (java.util.ArrayList)1 Check (org.eclipse.xtext.validation.Check)1 AadlPackage (org.osate.aadl2.AadlPackage)1 AnnexLibrary (org.osate.aadl2.AnnexLibrary)1