Commit 9e30723e authored by Paff's avatar Paff
Browse files

test coverage > 90% for cocos

parent 74aaf16c
...@@ -64,7 +64,7 @@ public final class MontiSecArcConstants extends Interfaces2Constants { ...@@ -64,7 +64,7 @@ public final class MontiSecArcConstants extends Interfaces2Constants {
/** /**
* Argument for Analysis configuration * Argument for Analysis configuration
*/ */
public static final String ARG_ANALYSISCONFPATH = "-analsisconf"; public static final String ARG_ANALYSISCONFPATH = "-analsisconfpath";
/** /**
* name for pep entry * name for pep entry
......
...@@ -11,15 +11,9 @@ import mc.types._ast.ASTQualifiedName; ...@@ -11,15 +11,9 @@ import mc.types._ast.ASTQualifiedName;
import mc.umlp.arc.ets.check.MontiArcCheckCoCoVisitor; import mc.umlp.arc.ets.check.MontiArcCheckCoCoVisitor;
import mc.umlp.arcd._ast.ASTArcComponent; import mc.umlp.arcd._ast.ASTArcComponent;
import mc.umlp.arcd._ast.ASTArcComponentBody; import mc.umlp.arcd._ast.ASTArcComponentBody;
import mc.umlp.arcd._ast.ASTArcConnector;
import mc.umlp.arcd._ast.ASTArcPort; import mc.umlp.arcd._ast.ASTArcPort;
import mc.umlp.arcd._ast.ASTArcSimpleConnector;
import mc.umlp.arcd._ast.ASTArcSubComponent;
import mc.umlp.arcd.ets.check.coco.checker.ISubComponentChecker;
import mc.umlp.arcd.ets.entries.ComponentEntry; import mc.umlp.arcd.ets.entries.ComponentEntry;
import mc.umlp.arcd.ets.entries.ConnectorEntry;
import mc.umlp.arcd.ets.entries.PortEntry; import mc.umlp.arcd.ets.entries.PortEntry;
import mc.umlp.arcd.ets.entries.SubComponentEntry;
import secarc.MontiSecArcConstants; import secarc.MontiSecArcConstants;
import secarc._ast.ASTMCCompilationUnit; import secarc._ast.ASTMCCompilationUnit;
...@@ -29,36 +23,28 @@ import secarc._ast.ASTSecArcIdentity; ...@@ -29,36 +23,28 @@ import secarc._ast.ASTSecArcIdentity;
import secarc._ast.ASTSecArcRefRole; import secarc._ast.ASTSecArcRefRole;
import secarc._ast.ASTSecArcRole; import secarc._ast.ASTSecArcRole;
import secarc._ast.ASTSecArcTrustlevelRelation; import secarc._ast.ASTSecArcTrustlevelRelation;
import secarc._ast.ASTSecArcCPE;
import secarc._ast.ASTSecArcPEP; import secarc._ast.ASTSecArcPEP;
import secarc.ets.cocos.checkers.ISecComponentBodyChecker; import secarc.ets.cocos.checkers.ISecComponentBodyChecker;
import secarc.ets.cocos.checkers.ISecComponentChecker; import secarc.ets.cocos.checkers.ISecComponentChecker;
import secarc.ets.cocos.checkers.ISecConfigurationChecker; import secarc.ets.cocos.checkers.ISecConfigurationChecker;
import secarc.ets.cocos.checkers.ISecConnectorChecker;
import secarc.ets.cocos.checkers.ISecFilterChecker; import secarc.ets.cocos.checkers.ISecFilterChecker;
import secarc.ets.cocos.checkers.ISecIdentityChecker; import secarc.ets.cocos.checkers.ISecIdentityChecker;
import secarc.ets.cocos.checkers.ISecPepChecker; import secarc.ets.cocos.checkers.ISecPepChecker;
import secarc.ets.cocos.checkers.ISecPortChecker; import secarc.ets.cocos.checkers.ISecPortChecker;
import secarc.ets.cocos.checkers.ISecRefRoleChecker; import secarc.ets.cocos.checkers.ISecRefRoleChecker;
import secarc.ets.cocos.checkers.ISecRoleChecker; import secarc.ets.cocos.checkers.ISecRoleChecker;
import secarc.ets.cocos.checkers.ISecSubComponentChecker;
import secarc.ets.cocos.checkers.ISecTrustlevelRelationChecker; import secarc.ets.cocos.checkers.ISecTrustlevelRelationChecker;
import secarc.ets.cocos.checkers.ISecCPEChecker;
import secarc.ets.entries.ConfigurationEntry; import secarc.ets.entries.ConfigurationEntry;
import secarc.ets.entries.FilterEntry; import secarc.ets.entries.FilterEntry;
import secarc.ets.entries.IdentityEntry; import secarc.ets.entries.IdentityEntry;
import secarc.ets.entries.PEPEntry; import secarc.ets.entries.PEPEntry;
import secarc.ets.entries.RoleEntry; import secarc.ets.entries.RoleEntry;
import secarc.ets.entries.SecComponentEntry; import secarc.ets.entries.SecComponentEntry;
import secarc.ets.entries.SecConnectorEntry;
import secarc.ets.entries.SecPortEntry; import secarc.ets.entries.SecPortEntry;
import secarc.ets.entries.SecSubComponentEntry;
import secarc.ets.entries.TrustlevelRelationEntry; import secarc.ets.entries.TrustlevelRelationEntry;
import secarc.ets.entries.CPEEntry;
import secarc.ets.graph.ArchitectureGraph; import secarc.ets.graph.ArchitectureGraph;
import secarc.ets.graph.ArchitectureGraphBuilder; import secarc.ets.graph.ArchitectureGraphBuilder;
import interfaces2.STEntryState;
import interfaces2.coco.ContextCondition; import interfaces2.coco.ContextCondition;
import interfaces2.resolvers.AmbigousException; import interfaces2.resolvers.AmbigousException;
...@@ -76,84 +62,64 @@ import interfaces2.resolvers.AmbigousException; ...@@ -76,84 +62,64 @@ import interfaces2.resolvers.AmbigousException;
*/ */
public class MontiSecArcCheckVisitor extends MontiArcCheckCoCoVisitor { public class MontiSecArcCheckVisitor extends MontiArcCheckCoCoVisitor {
private String packageName = "";
/** /**
* Architecture graph for analysis * Architecture graph for analysis
*/ */
private ArchitectureGraph graph; protected ArchitectureGraph graph;
/**
* Cocos that check connector related conditions
*/
private Set<ISecConnectorChecker> secConnectorChecker;
/** /**
* Cocos that check the component related conditions * Cocos that check the component related conditions
*/ */
private Set<ISecComponentChecker> secComponentChecker; protected Set<ISecComponentChecker> secComponentChecker;
/**
* Cocos that check the subcomponent related conditions
*/
private Set<ISecSubComponentChecker> secSubComponentChecker;
/**
* Cocos that check the version related conditions
*/
private Set<ISecCPEChecker> secVersionChecker;
/** /**
* Cocos that check the body of a component * Cocos that check the body of a component
*/ */
private Set<ISecComponentBodyChecker> secComponentBodyChecker; protected Set<ISecComponentBodyChecker> secComponentBodyChecker;
/** /**
* Cocos that check the identity related conditions * Cocos that check the identity related conditions
*/ */
private Set<ISecIdentityChecker> secIdentityChecker; protected Set<ISecIdentityChecker> secIdentityChecker;
/** /**
* Cocos that check pep related conditions * Cocos that check pep related conditions
*/ */
private Set<ISecPepChecker> secPepChecker; protected Set<ISecPepChecker> secPepChecker;
/** /**
* Cocos that check port roles related conditions * Cocos that check port roles related conditions
*/ */
private Set<ISecRefRoleChecker> secRefRoleChecker; protected Set<ISecRefRoleChecker> secRefRoleChecker;
/** /**
* Cocos that check port related conditions * Cocos that check port related conditions
*/ */
private Set<ISecPortChecker> secPortChecker; protected Set<ISecPortChecker> secPortChecker;
/** /**
* Cocos that check configuration related conditions * Cocos that check configuration related conditions
*/ */
private Set<ISecConfigurationChecker> secConfigurationChecker; protected Set<ISecConfigurationChecker> secConfigurationChecker;
/** /**
* Cocos that check role related conditions * Cocos that check role related conditions
*/ */
private Set<ISecRoleChecker> secRoleChecker; protected Set<ISecRoleChecker> secRoleChecker;
/** /**
* Cocos that check filter related conditions * Cocos that check filter related conditions
*/ */
private Set<ISecFilterChecker> secFilterChecker; protected Set<ISecFilterChecker> secFilterChecker;
/** /**
* Cocos that check trustlevel relation related conditions * Cocos that check trustlevel relation related conditions
*/ */
private Set<ISecTrustlevelRelationChecker> secTrustlevelRelationChecker; protected Set<ISecTrustlevelRelationChecker> secTrustlevelRelationChecker;
public MontiSecArcCheckVisitor() { public MontiSecArcCheckVisitor() {
secConnectorChecker = new HashSet<ISecConnectorChecker>();
secComponentChecker = new HashSet<ISecComponentChecker>(); secComponentChecker = new HashSet<ISecComponentChecker>();
secSubComponentChecker = new HashSet<ISecSubComponentChecker>();
secVersionChecker = new HashSet<ISecCPEChecker>();
secComponentBodyChecker = new HashSet<ISecComponentBodyChecker>(); secComponentBodyChecker = new HashSet<ISecComponentBodyChecker>();
secIdentityChecker = new HashSet<ISecIdentityChecker>(); secIdentityChecker = new HashSet<ISecIdentityChecker>();
secPepChecker = new HashSet<ISecPepChecker>(); secPepChecker = new HashSet<ISecPepChecker>();
...@@ -183,18 +149,9 @@ public class MontiSecArcCheckVisitor extends MontiArcCheckCoCoVisitor { ...@@ -183,18 +149,9 @@ public class MontiSecArcCheckVisitor extends MontiArcCheckCoCoVisitor {
super.createUsefulCollections(); super.createUsefulCollections();
for(ContextCondition coco : getEnabledConditions()) { for(ContextCondition coco : getEnabledConditions()) {
if(coco instanceof ISecConnectorChecker) {
secConnectorChecker.add((ISecConnectorChecker) coco);
}
if(coco instanceof ISecComponentChecker) { if(coco instanceof ISecComponentChecker) {
secComponentChecker.add((ISecComponentChecker) coco); secComponentChecker.add((ISecComponentChecker) coco);
} }
if(coco instanceof ISecSubComponentChecker) {
secSubComponentChecker.add((ISecSubComponentChecker) coco);
}
if(coco instanceof ISecCPEChecker) {
secVersionChecker.add((ISecCPEChecker) coco);
}
if(coco instanceof ISecComponentBodyChecker) { if(coco instanceof ISecComponentBodyChecker) {
secComponentBodyChecker.add((ISecComponentBodyChecker) coco); secComponentBodyChecker.add((ISecComponentBodyChecker) coco);
} }
...@@ -231,10 +188,6 @@ public class MontiSecArcCheckVisitor extends MontiArcCheckCoCoVisitor { ...@@ -231,10 +188,6 @@ public class MontiSecArcCheckVisitor extends MontiArcCheckCoCoVisitor {
* @param node ast node to visit * @param node ast node to visit
*/ */
public void visit(ASTMCCompilationUnit node) { public void visit(ASTMCCompilationUnit node) {
packageName = NameHelper.dotSeparatedStringFromList(node.getPackage());
if (!packageName.isEmpty()) {
packageName += ".";
}
SecComponentEntry componentEntry = null; SecComponentEntry componentEntry = null;
...@@ -307,75 +260,6 @@ public class MontiSecArcCheckVisitor extends MontiArcCheckCoCoVisitor { ...@@ -307,75 +260,6 @@ public class MontiSecArcCheckVisitor extends MontiArcCheckCoCoVisitor {
} }
} }
/**
* Visits version
*
* @param node ast node to visit
*/
public void visit(ASTSecArcCPE node) {
try {
CPEEntry entry = (CPEEntry) resolver.resolve(MontiSecArcConstants.CPE_NAME, CPEEntry.KIND, getNameSpaceFor(node.getMainParent()));
if (entry != null) {
for (ISecCPEChecker cc : secVersionChecker) {
cc.check(node, entry);
}
}
} catch (AmbigousException e) {
// not checked here
MCG.getLogger().info(e.getMessage());
}
}
/**
* Visits connectors
*
* @param node ast node to visit
*/
public void visit(ASTArcConnector node) {
super.visit(node);
for (ASTQualifiedName name : node.getTargets()) {
try {
SecConnectorEntry entry = (SecConnectorEntry) resolver.resolve(NameHelper.dotSeparatedStringFromList(name.getParts()), ConnectorEntry.KIND,
getNameSpaceFor(node.getMainParent()));
if (entry != null) {
for (ISecConnectorChecker cc : secConnectorChecker) {
cc.check(node, entry);
}
}
} catch (AmbigousException e) {
// not handled here
MCG.getLogger().info(e.getMessage());
}
}
}
/**
* Visits simple connectors
*
* @param node ast node to visit
*/
public void visit(ASTArcSimpleConnector node) {
super.visit(node);
for (ASTQualifiedName name : node.getTargets()) {
try {
SecConnectorEntry entry = (SecConnectorEntry) resolver.resolve(NameHelper.dotSeparatedStringFromList(name.getParts()), ConnectorEntry.KIND,
getNameSpaceFor(node.getMainParent()));
if (entry != null) {
for (ISecConnectorChecker cc : secConnectorChecker) {
cc.check(node, entry);
}
}
} catch (AmbigousException e) {
// not handled here
MCG.getLogger().info(e.getMessage());
}
}
}
/** /**
* Visits component body * Visits component body
* *
...@@ -431,31 +315,6 @@ public class MontiSecArcCheckVisitor extends MontiArcCheckCoCoVisitor { ...@@ -431,31 +315,6 @@ public class MontiSecArcCheckVisitor extends MontiArcCheckCoCoVisitor {
} }
} }
/**
* Visits subcomponents
*
* @param node ast node to visit
*/
@Override
public void visit(ASTArcSubComponent node) {
super.visit(node);
if (!node.hasNames()) {
try {
SecSubComponentEntry entry = (SecSubComponentEntry) resolver.resolve(node.printName(), SubComponentEntry.KIND, getNameSpaceFor(node.getMainParent()));
if (entry != null && entry.getComponentType().getEntryState() != STEntryState.UNQUALIFIED) {
for (ISubComponentChecker rc : subcomponentChecker) {
rc.check(node, entry);
}
}
} catch (AmbigousException e) {
// not checked here
MCG.getLogger().info(e.getMessage());
}
}
}
/** /**
* Visits configuration * Visits configuration
* *
...@@ -520,7 +379,13 @@ public class MontiSecArcCheckVisitor extends MontiArcCheckCoCoVisitor { ...@@ -520,7 +379,13 @@ public class MontiSecArcCheckVisitor extends MontiArcCheckCoCoVisitor {
*/ */
public void visit(ASTSecArcTrustlevelRelation node) { public void visit(ASTSecArcTrustlevelRelation node) {
try { try {
TrustlevelRelationEntry entry = (TrustlevelRelationEntry) resolver.resolve(NameHelper.dotSeparatedStringFromList(node.getServer().getParts()), TrustlevelRelationEntry.KIND, getNameSpaceFor(node.getMainParent())); String name = "";
if(node.isGT()) {
name = NameHelper.dotSeparatedStringFromList(node.getClient().getParts());
} else {
name = NameHelper.dotSeparatedStringFromList(node.getServer().getParts());
}
TrustlevelRelationEntry entry = (TrustlevelRelationEntry) resolver.resolve(name, TrustlevelRelationEntry.KIND, getNameSpaceFor(node.getMainParent()));
if (entry != null) { if (entry != null) {
for (ISecTrustlevelRelationChecker cc : secTrustlevelRelationChecker) { for (ISecTrustlevelRelationChecker cc : secTrustlevelRelationChecker) {
cc.check(node, entry); cc.check(node, entry);
......
package secarc.ets.cocos.checkers;
import interfaces2.resolvers.AmbigousException;
import mc.umlp.arcd._ast.ASTArcConnector;
import mc.umlp.arcd._ast.ASTArcSimpleConnector;
import secarc.ets.entries.SecConnectorEntry;
/**
* Context condition checker interface for checking secconnector
* related context conditions
*
* <br>
* <br>
* Copyright (c) 2011 RWTH Aachen. All rights reserved
*
* @author (last commit) $Author$
* @version $Date$<br>
* $Revision$
*
*/
public interface ISecConnectorChecker {
/**
*
* @param node ast node to be checked
* @param entry entry related connector entry to be checked
* @throws AmbigousException
*/
void check(ASTArcConnector node, SecConnectorEntry entry) throws AmbigousException;
/**
*
* @param node ast node to be checked
* @param entry entry related connector entry to be checked
* @throws AmbigousException
*/
void check(ASTArcSimpleConnector node, SecConnectorEntry entry) throws AmbigousException;
}
package secarc.ets.cocos.checkers;
import interfaces2.resolvers.AmbigousException;
import secarc.ets.entries.SecSubComponentEntry;
import mc.umlp.arcd._ast.ASTArcSubComponent;
/**
* Context condition checker interface for checking SecSubComponent
* related context conditions
*
* <br>
* <br>
* Copyright (c) 2011 RWTH Aachen. All rights reserved
*
* @author (last commit) $Author$
* @version $Date$<br>
* $Revision$
*
*/
public interface ISecSubComponentChecker {
/**
*
* @param node ast node to be checked
* @param entry entry related subcomponent entry to be checked
* @throws AmbigousException
*/
void check(ASTArcSubComponent node, SecSubComponentEntry entry) throws AmbigousException;
}
...@@ -116,7 +116,7 @@ public class UniqueDefinitionWithFullQualifiedNames extends ComponentExistence { ...@@ -116,7 +116,7 @@ public class UniqueDefinitionWithFullQualifiedNames extends ComponentExistence {
SubComponentEntry higherTrustlevelSubComoponent = innerCheck(node, node.getMainParent(), refHigherTrustlevelComponent); SubComponentEntry higherTrustlevelSubComoponent = innerCheck(node, node.getMainParent(), refHigherTrustlevelComponent);
//Checked in other coco //Checked in other coco
if(lowerTrustlevelSubComoponent != null | higherTrustlevelSubComoponent != null) { if(lowerTrustlevelSubComoponent == null | higherTrustlevelSubComoponent == null) {
return; return;
} }
...@@ -164,7 +164,7 @@ public class UniqueDefinitionWithFullQualifiedNames extends ComponentExistence { ...@@ -164,7 +164,7 @@ public class UniqueDefinitionWithFullQualifiedNames extends ComponentExistence {
} }
if(count > 1) { if(count > 1) {
addReport("There is more than one identity link of the form: trustlevelrelation " + entry.getComponentWithLowerTrustlevel() + relation + entry.getComponentWithHigherTrustlevel(), node.get_SourcePositionStart()); addReport("There is more than one relation of the form: trustlevelrelation " + entry.getComponentWithLowerTrustlevel() + relation + entry.getComponentWithHigherTrustlevel(), node.get_SourcePositionStart());
} }
} }
...@@ -174,8 +174,8 @@ public class UniqueDefinitionWithFullQualifiedNames extends ComponentExistence { ...@@ -174,8 +174,8 @@ public class UniqueDefinitionWithFullQualifiedNames extends ComponentExistence {
SubComponentEntry higherTrustlevelComoponentCompare = null; SubComponentEntry higherTrustlevelComoponentCompare = null;
for(TrustlevelRelationEntry trustlevelRelationEntrySource : entry.getAllTrustlevelRelation()) { for(TrustlevelRelationEntry trustlevelRelationEntrySource : entry.getAllTrustlevelRelation()) {
lowerTrustlevelComoponentCompare = innerCheck(trustlevelRelationEntrySource.getNode(), ((ASTSecArcIdentity) trustlevelRelationEntrySource.getNode()).getMainParent(), trustlevelRelationEntrySource.getComponentWithLowerTrustlevel()); lowerTrustlevelComoponentCompare = innerCheck(trustlevelRelationEntrySource.getNode(), ((ASTSecArcTrustlevelRelation) trustlevelRelationEntrySource.getNode()).getMainParent(), trustlevelRelationEntrySource.getComponentWithLowerTrustlevel());
higherTrustlevelComoponentCompare = innerCheck(trustlevelRelationEntrySource.getNode(), ((ASTSecArcIdentity) trustlevelRelationEntrySource.getNode()).getMainParent(), trustlevelRelationEntrySource.getComponentWithHigherTrustlevel()); higherTrustlevelComoponentCompare = innerCheck(trustlevelRelationEntrySource.getNode(), ((ASTSecArcTrustlevelRelation) trustlevelRelationEntrySource.getNode()).getMainParent(), trustlevelRelationEntrySource.getComponentWithHigherTrustlevel());
if(lowerTrustlevelComoponent.equals(lowerTrustlevelComoponentCompare) && higherTrustlevelComoponent.equals(higherTrustlevelComoponentCompare)) { if(lowerTrustlevelComoponent.equals(lowerTrustlevelComoponentCompare) && higherTrustlevelComoponent.equals(higherTrustlevelComoponentCompare)) {
count++; count++;
} }
......
...@@ -29,9 +29,9 @@ public class IdentityCycleCheck extends ContextCondition implements ISecIdentity ...@@ -29,9 +29,9 @@ public class IdentityCycleCheck extends ContextCondition implements ISecIdentity
CycleDetector<Vertex<? extends STEntry>, Edge> cycleDetector = new CycleDetector<Vertex<? extends STEntry>, Edge>(graph.getRawGraph()); CycleDetector<Vertex<? extends STEntry>, Edge> cycleDetector = new CycleDetector<Vertex<? extends STEntry>, Edge>(graph.getRawGraph());
Set<Vertex<? extends STEntry>> setCycle = cycleDetector.findCyclesContainingVertex(Vertex.of(entry)); Set<Vertex<? extends STEntry>> setCycle = cycleDetector.findCycles();
if(setCycle != null && !setCycle.isEmpty()) { if(setCycle.contains(Vertex.of(entry))) {
addReport("There is a cycle of identity links starting in " + entry, node.get_SourcePositionStart()); addReport("There is a cycle of identity links starting in " + entry, node.get_SourcePositionStart());
} }
......
...@@ -67,7 +67,7 @@ public class RoleWithIdentity extends ContextCondition implements ...@@ -67,7 +67,7 @@ public class RoleWithIdentity extends ContextCondition implements
//First element is not needed //First element is not needed
if(!(element instanceof IdentityEntry)) { if(!(element instanceof IdentityEntry)) {
addReport("For the component " + NameHelper.getSimpleGenericNameFromComplexname(entry.getName()) + " are roles defined. These roles must be authenticated by an identity link.", node.get_SourcePositionStart()); addReport("For the component " + entry.getName() + " are roles defined. These roles must be authenticated by an identity link.", node.get_SourcePositionStart());
} }
} }
......
...@@ -94,8 +94,8 @@ public class CorrectRelationBetweenTrustlevel extends ComponentExistence { ...@@ -94,8 +94,8 @@ public class CorrectRelationBetweenTrustlevel extends ComponentExistence {
} }
if(entry.isEqual() && higherTrustlevelAsInteger != lowerTrustlevelAsInteger) { if(entry.isEqual() && higherTrustlevelAsInteger != lowerTrustlevelAsInteger) {
addReport("The relation between the components " + refLowerTrustlevelComponent + " (trustlevel " + lowerTrustlevelAsString + ") and " + refHigherTrustlevelComponent + " (trustlevel " + higherTrustlevelAsString + ") is defined ad equals.", node.get_SourcePositionStart()); addReport("The relation between the components " + refLowerTrustlevelComponent + " (trustlevel " + lowerTrustlevelAsString + ") and " + refHigherTrustlevelComponent + " (trustlevel " + higherTrustlevelAsString + ") is defined as equals.", node.get_SourcePositionStart());
} else if (entry.isEqual() && higherTrustlevelAsInteger < lowerTrustlevelAsInteger) { } else if (!entry.isEqual() && higherTrustlevelAsInteger < lowerTrustlevelAsInteger) {
addReport("The trustlevel of the component " + refLowerTrustlevelComponent + " (trustlevel " + lowerTrustlevelAsString + ") must be lower than the trustlevel of component " + refHigherTrustlevelComponent + " (trustlevel " + higherTrustlevelAsString + ") regarding the defined relation.", node.get_SourcePositionStart()); addReport("The trustlevel of the component " + refLowerTrustlevelComponent + " (trustlevel " + lowerTrustlevelAsString + ") must be lower than the trustlevel of component " + refHigherTrustlevelComponent + " (trustlevel " + higherTrustlevelAsString + ") regarding the defined relation.", node.get_SourcePositionStart());
} }
......