Commit b3f49dfc authored by Paff's avatar Paff
Browse files

bug fixing with running example

parent f62afdc9
/**
* Generated on Thu Sep 18 17:44:55 CEST 2014
*/
config {
Require-Model:
"de.monticore.java.lib-3.1.1-symbols.jar",
"../montiSecArcFE/src/main/grammars"
}
\ No newline at end of file
...@@ -10,6 +10,7 @@ import com.google.inject.Injector; ...@@ -10,6 +10,7 @@ import com.google.inject.Injector;
import interfaces2.language.ETSTool; import interfaces2.language.ETSTool;
import interfaces2.language.LanguageFamily; import interfaces2.language.LanguageFamily;
import mc.ProblemReport.Type; import mc.ProblemReport.Type;
import mc.umlp.arc.MontiArcLanguageFamilyFactory;
import mc.umlp.arcd.InjectorProvider; import mc.umlp.arcd.InjectorProvider;
import secarc.ets.check.MontiSecArcAnalysisCreator; import secarc.ets.check.MontiSecArcAnalysisCreator;
import secarc.ets.check.MontiSecArcContextConditionCreator; import secarc.ets.check.MontiSecArcContextConditionCreator;
...@@ -129,8 +130,7 @@ public class MontiSecArcAnalysisTool extends ETSTool { ...@@ -129,8 +130,7 @@ public class MontiSecArcAnalysisTool extends ETSTool {
Injector injector = Guice.createInjector(new MontiSecArcDefaultModule()); Injector injector = Guice.createInjector(new MontiSecArcDefaultModule());
InjectorProvider.setInjector(injector); InjectorProvider.setInjector(injector);
LanguageFamily languageFamily = new LanguageFamily(); LanguageFamily languageFamily = MontiArcLanguageFamilyFactory.create(MontiSecArcAnalysis.newLanguage(injector.getInstance(MontiSecArcComponent.class), analysisParameter, analysisConfPath));
languageFamily.addLanguage(MontiSecArcAnalysis.newLanguage(injector.getInstance(MontiSecArcComponent.class), analysisParameter, analysisConfPath));
setLanguages(languageFamily); setLanguages(languageFamily);
// set default CoCos // set default CoCos
......
...@@ -205,7 +205,7 @@ public class MontiSecArcAnalysisVisitor extends CheckWorkflowClient { ...@@ -205,7 +205,7 @@ public class MontiSecArcAnalysisVisitor extends CheckWorkflowClient {
try { try {
//root component for architecture graph //root component for architecture graph
componentEntry = (SecComponentEntry) resolver.resolve(node.getType().getName(), ComponentEntry.KIND, getNameSpaceFor(node)); componentEntry = (SecComponentEntry) resolver.resolve(node.getType().printName(), ComponentEntry.KIND, getNameSpaceFor(node));
} catch (AmbigousException | NullPointerException e) { } catch (AmbigousException | NullPointerException e) {
// not checked here // not checked here
MCG.getLogger().info(e.getMessage()); MCG.getLogger().info(e.getMessage());
...@@ -261,7 +261,7 @@ public class MontiSecArcAnalysisVisitor extends CheckWorkflowClient { ...@@ -261,7 +261,7 @@ public class MontiSecArcAnalysisVisitor extends CheckWorkflowClient {
*/ */
public void visit(ASTArcPort node) { public void visit(ASTArcPort node) {
try { try {
SecPortEntry entry = (SecPortEntry) resolver.resolve(node.getName(), PortEntry.KIND, getNameSpaceFor(node)); SecPortEntry entry = (SecPortEntry) resolver.resolve(node.printName(), PortEntry.KIND, getNameSpaceFor(node));
if(entry != null) { if(entry != null) {
for(ISecAnalysisPortChecker cc : analysisPortChecker) { for(ISecAnalysisPortChecker cc : analysisPortChecker) {
metricSum += cc.check(node, entry, graphConnectorEdges, advanced); metricSum += cc.check(node, entry, graphConnectorEdges, advanced);
......
package secarc;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import mc.dsltool.AmbigousException;
import mc.dsltool.CircluarDependencyException;
public class MontiSecArcAnalysisRunningExampleTest extends TestWithSymtabAnalysis<MontiSecArcAnalysisTestTool> {
public MontiSecArcAnalysisRunningExampleTest() {
super(MontiSecArcAnalysisTestTool.class, new String[] { "gen/conv" });
}
/**
* Test for Running Example in MontiSecArc with Analysis
* @throws AmbigousException
* @throws CircluarDependencyException
*/
@Test
public void testSecRunningExample() throws CircluarDependencyException, AmbigousException {
MontiSecArcAnalysisTestTool tool = createTestToolWithAdditionalParameters(new String[] {"src/test/resources/secarc/seccds"}, new String[] {"src/test/resources"});
tool.init();
assertTrue(tool.run());
}
}
...@@ -87,6 +87,61 @@ public class TestWithSymtabAnalysis<T extends ETSTool> extends ...@@ -87,6 +87,61 @@ public class TestWithSymtabAnalysis<T extends ETSTool> extends
} }
/** /**
* Creates a DSL Tool from the type T that is configured to build the symbol
* table for the given files being able to load models and symbols from the
* src folder, the java bootstrap folder and the given additional model
* paths.
*
* @param files files to process
* @param additionalModelPath to expand the model path
* @param additionalParameters add additional parameters here to configure the tool
*
* @return the created dsl tool
*/
@Override
protected T createTestToolWithAdditionalParameters(String[] files, String[] additionalModelPath, String... additionalParameters) {
String[] args = new String[] {
ARG_MODELPATH, "src/main/java",
ARG_CONF, "mc-test.cfg",
ARG_OUT, OUTPUT_TEST_FOLDER,
ARG_SYMTABDIR, SYMTAB_FOLDER,
ARG_ANALYSIS, Parameters.ALL, WF_PARSE,
ARG_ANALYSIS, "javadsl", "setname",
ARG_ANALYSIS, "javadsl", "addImports",
ARG_ANALYSIS, Parameters.ALL, WF_INIT_SYMTAB,
ARG_ANALYSIS, Parameters.ALL, WF_CREATE_SYMTAB,
ARG_SYNTHESIS, Parameters.ALL, WF_INIT_CHECK,
ARG_SYNTHESIS, "secarc", WF_PRE_CHECK_TRAFO,
ARG_SYNTHESIS, Parameters.ALL, WF_RUN_CHECK,
//Uses analysis workflow
ARG_SYNTHESIS, "secarc", MontiSecArcConstants.ANALYSIS_WORKFLOW_BEGINNERS,};
List<String> argsAsList = new LinkedList<String>();
argsAsList.addAll(Arrays.asList(args));
for (String mp : additionalModelPath) {
argsAsList.add(ARG_MODELPATH);
argsAsList.add(mp);
}
for (String file : files) {
argsAsList.add(file);
}
for (String param : additionalParameters) {
argsAsList.add(param);
}
T tool = null;
try {
Constructor<T> constructor = toolClass.getConstructor(String[].class, String.class, String.class);
args = argsAsList.toArray(new String[argsAsList.size()]);
tool = constructor.newInstance((Object) args, (Object) "", (Object) "/home/user/workspace/MA-Paff/03.Implementierung/montiSecArcAnalysis/src/main/conf/Analysis_Conf.txt");
tool.setErrorLevel(Type.WARNING);
}
catch (Exception e) {
e.printStackTrace();
}
return tool;
}
/**
* test with filter turstlevel and parameters * test with filter turstlevel and parameters
* *
* @param files * @param files
......
package secarc.seccds;
// import message types
import secarc.seccds.msg.*;
import java.awt.Image;
// import components
import secarc.seccds.fe.CashDesk;
import secarc.seccds.be.Bank;
import secarc.seccds.fe.Store;
component CashDeskSystem {
trustlevel -1;
autoconnect encrypted port;
autoinstantiate on;
accesscontrol on;
port
in Event newSale,
in Image barcode,
in String identifier,
in Event endSale,
out ProductData;
port
in Event cardPay,
in CardData,
in Integer pin,
out Boolean validation;
port
out Bill;
component CashDesk cashDesk
[encrypted bdOut -> bank.bankData;
saleInformation -> store.saleInformation];
component Bank;
component Store;
connect encrypted bank.paymentAck -> cashDesk.paIn;
connect cashDesk -> store;
connect cashDesk.outProductData -> productData;
connect store.productData -> cashDesk.inProductData;
connect identifier -> cashDesk.inIdentifier;
}
\ No newline at end of file
package secarc.seccds.be;
// import message types
import secarc.seccds.msg.*;
component Bank {
trustlevel +3;
port
critical in BankData,
out PaymentAck;
access customer;
identity weak cashDesk -> bank;
}
\ No newline at end of file
package secarc.seccds.fe;
// import message types
import secarc.seccds.msg.*;
import java.awt.Image;
component CashDesk {
trustlevel +1;
port
in Event newSale,
in Image barcode,
in String inIdentifier,
out String outIdentifier,
in Event endSale,
in ProductData inProductData,
in PaymentAck paymentAck,
out ProductData outProductData;
port
in Event cardPay,
critical in CardData,
critical in Integer pin,
critical out BankData bdOut,
in PaymentAck paIn,
out Boolean validation;
port
out SaleInformation,
out Bill;
}
\ No newline at end of file
package secarc.seccds.fe;
// import message types
import secarc.seccds.msg.*;
component Store {
trustlevel +2;
access stockManager, storeManager, cashier;
autoconnect port;
connect saleInformation -> data.filterInfo;
identity weak cashDesk -> store;
port
in String identifier,
out ProductData,
out PaymentAck;
port
in SaleInformation;
component (filter fString) StoreServer {
configuration confName;
cpe "cpeName";
port
in String identifier,
out Identifier;
}
component Data {
port
out ProductData,
out PaymentAck,
(filter fInformation) in SaleInformation filterInfo;
}
}
\ No newline at end of file
package secarc.seccds.msg;
public class BankData {
}
\ No newline at end of file
package secarc.seccds.msg;
public class Bill {
}
package secarc.seccds.msg;
public class CardData {
}
\ No newline at end of file
package secarc.seccds.msg;
public class Event {
}
\ No newline at end of file
package secarc.seccds.msg;
public class Identifier {
}
package secarc.seccds.msg;
public class PaymentAck {
}
\ No newline at end of file
package secarc.seccds.msg;
public class ProductData {
}
\ No newline at end of file
package secarc.seccds.msg;
public class SaleInformation {
}
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="src" path="src/main/generated-resources"/> <classpathentry kind="src" path="src/main/generated-resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/resources"/> <classpathentry including="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
......
...@@ -3,9 +3,18 @@ package secarc; ...@@ -3,9 +3,18 @@ package secarc;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import secarc._ast.ASTSecArcCPE;
import secarc._ast.ASTSecArcConfiguration;
import secarc._ast.ASTSecArcFilter;
import secarc._ast.ASTSecArcFilterComponent; import secarc._ast.ASTSecArcFilterComponent;
import secarc._ast.ASTSecArcIdentity;
import secarc._ast.ASTSecArcPEP;
import secarc._ast.ASTSecArcPort; import secarc._ast.ASTSecArcPort;
import secarc._ast.ASTSecArcRefRole;
import secarc._ast.ASTSecArcRole; import secarc._ast.ASTSecArcRole;
import secarc._ast.ASTSecArcRoleInterface;
import secarc._ast.ASTSecArcTrustLevel;
import secarc._ast.ASTSecArcTrustlevelRelation;
import mc.ast.ASTCNode; import mc.ast.ASTCNode;
import mc.types._ast.ASTTypeParameters; import mc.types._ast.ASTTypeParameters;
...@@ -111,7 +120,9 @@ public final class MontiSecArcConstants extends Interfaces2Constants { ...@@ -111,7 +120,9 @@ public final class MontiSecArcConstants extends Interfaces2Constants {
* List of MontiSecArc AST nodes that have public visibility in the symbol table. * List of MontiSecArc AST nodes that have public visibility in the symbol table.
*/ */
public static final List<Class<? extends ASTCNode>> MONTI_SEC_ARC_PUBLIC_NODES = ImmutableList.of(ASTArcComponent.class, ASTArcPort.class, public static final List<Class<? extends ASTCNode>> MONTI_SEC_ARC_PUBLIC_NODES = ImmutableList.of(ASTArcComponent.class, ASTArcPort.class,
ASTMCCompilationUnit.class, ASTTypeParameters.class, ASTArcParameter.class, ASTSecArcFilterComponent.class, ASTSecArcPort.class, ASTSecArcRole.class); ASTMCCompilationUnit.class, ASTTypeParameters.class, ASTArcParameter.class, ASTSecArcFilterComponent.class, ASTSecArcPort.class,
ASTSecArcRole.class, ASTSecArcRefRole.class, ASTSecArcRoleInterface.class, ASTSecArcIdentity.class, ASTSecArcFilter.class, ASTSecArcConfiguration.class, ASTSecArcCPE.class,ASTSecArcPEP.class,
ASTSecArcTrustLevel.class, ASTSecArcTrustlevelRelation.class);
/** /**
* Holds abbreviations mapped to AST-node names. * Holds abbreviations mapped to AST-node names.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment