Commit c3993c1a authored by Paff's avatar Paff
Browse files

bug fixing for analysis configuration:

now a change in the analysis file is possible while running
parent bd7155c0
......@@ -12,9 +12,8 @@ D04-Derive-Trustlevel-Component 1
E01-Unencrypted-Connector-In-Path 1
E02-Unencrypted-Connector-Low-Trustlevel 1
E03-Encrypted-Path-Continues-Unencrypted 1
E04-Trustlevel-Unencrypted-Path-In-Low 1
E05-Unencrypted-Path-End-In-Low-Trustlevel 1
E06-Trustlevel-Connector-Higher 1
E04-Unencrypted-Path-End-In-Low-Trustlevel 1
E05-Trustlevel-Connector-Higher 1
I01-Encrypted-Connector 1
I02-Trustlevel-Client-Server 1
I03-Roles-Defined 1
......@@ -22,7 +21,7 @@ F01-Taint-Tracking 1
F02-High-Trustlevel 1
T01-Reason-Trustlevel 1
T02-High-Trustlevel 1
WI01Access-Roles 1
WI01-Access-Roles 1
WI02-Third-Party-Component-Security 1
WI03-Low-Trustlevel 1
WI04-Critical-Ports 1
\ No newline at end of file
......@@ -105,9 +105,9 @@ public final class MontiSecArcAnalysis extends MontiSecArc {
analysisWorkflow.setAnalysis(MontiSecArcAnalysisCreator.createAnalysis(analysisConfPath));
//AnalysisConfiguratin
if(analysisConfPath != null && !analysisConfPath.isEmpty()) {
analysisWorkflow.setAnalysisConfiguration(MontiSecArcAnalysisCreator.createConfig());
} else {
analysisWorkflow.setAnalysisConfiguration(MontiSecArcAnalysisCreator.createConfig(analysisConfPath));
} else {
analysisWorkflow.setAnalysisConfiguration(MontiSecArcAnalysisCreator.createConfig());
}
//AnalysisParaemter
analysisWorkflow.setAnalysisParameter(analysisParameter);
......
......@@ -61,16 +61,18 @@ public class WrapperMontiSecArcAnalysisTool extends MontiSecArcAnalysisTool {
*/
public static void main(String[] arguments) {
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Start analysis...");
System.out.println("Start analysis... \n\n");
String line = "";
try {
while((line = console.readLine()) != null) {
while((line = console.readLine()) != null) {
MCG.initMonticoreGlobals();
MontiSecArcAnalysisTool tool = createTestToolWithoutJava(line.split("\\s"));
tool.init();
tool.run();
System.out.println("\n\nStart analysis... \n\n");
}
} catch (IOException e) {
MCG.getLogger().info(e.getMessage());
......
......@@ -116,7 +116,7 @@ public final class MontiSecArcAnalysisConstants {
public static final String E01 = "E01-Unencrypted-Connector-In-Path";
public static final String E02 = "E2-Unencrypted-Connector-Low-Trustlevel";
public static final String E02 = "E02-Unencrypted-Connector-Low-Trustlevel";
public static final String E03 = "E03-Encrypted-Path-Continues-Unencrypted";
......@@ -138,7 +138,7 @@ public final class MontiSecArcAnalysisConstants {
public static final String T02 = "T02-High-Trustlevel";
public static final String WI01 = "WI01Access-Roles";
public static final String WI01 = "WI01-Access-Roles";
public static final String WI02 = "WI02-Third-Party-Component-Security";
......
......@@ -246,22 +246,6 @@ public final class MontiSecArcAnalysisCreator {
return analysis;
}
/**
* BufferedReader for config file
*
* @param analysisConfFile
* @return BufferedReader
*/
private BufferedReader getCofigFileFromString(String analysisConfFile) {
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(analysisConfFile));
} catch (FileNotFoundException e){
MCG.getLogger().info(e.getMessage());
}
return reader;
}
/**
* Factor for metric
*
......@@ -270,24 +254,34 @@ public final class MontiSecArcAnalysisCreator {
* @return factor Factor of analysis
*/
private int getFactorFromCofigFile(String analysisConfFile, String name) {
FileReader fileReader = null;
BufferedReader bufferedReader = null;
try {
fileReader = new FileReader(analysisConfFile);
bufferedReader = new BufferedReader(fileReader);
} catch (FileNotFoundException e){
MCG.getLogger().info(e.getMessage());
}
String zeile = "";
int value = 1;
BufferedReader reader = getCofigFileFromString(analysisConfFile);
//Can't read file and use default value
if(reader == null) {
if(bufferedReader == null) {
return value;
}
try {
while((zeile = reader.readLine()) != null) {
while((zeile = bufferedReader.readLine()) != null) {
if(zeile.contains(name)) {
if(zeile.contains(" ")) {
String svalue = zeile.split(" ")[1];
reader.close();
String svalue = zeile.split("\\s")[1];
bufferedReader.close();
fileReader.close();
return Integer.parseInt(svalue);
}
}
}
reader.close();
bufferedReader.close();
fileReader.close();
} catch (IOException | NumberFormatException e) {
//Error while reading
MCG.getLogger().info(e.getMessage());
......@@ -303,21 +297,31 @@ public final class MontiSecArcAnalysisCreator {
* @return boolean true if analysis exists
*/
private boolean existsAnalysisInFile(String analysisConfFile, String name) {
FileReader fileReader = null;
BufferedReader bufferedReader = null;
try {
fileReader = new FileReader(analysisConfFile);
bufferedReader = new BufferedReader(fileReader);
} catch (FileNotFoundException e){
MCG.getLogger().info(e.getMessage());
}
String zeile = "";
boolean value = false;
BufferedReader reader = getCofigFileFromString(analysisConfFile);
//Can't read file and use default value
if(reader == null) {
if(bufferedReader == null) {
return value;
}
try {
while((zeile = reader.readLine()) != null) {
while((zeile = bufferedReader.readLine()) != null) {
if(zeile.contains(name)) {
reader.close();
bufferedReader.close();
fileReader.close();
return true;
}
}
reader.close();
bufferedReader.close();
fileReader.close();
} catch (IOException | NumberFormatException e) {
//Error while reading
MCG.getLogger().info(e.getMessage());
......@@ -333,11 +337,12 @@ public final class MontiSecArcAnalysisCreator {
private Map<String,ProblemReport.Type> doCreateConfiguration() {
if(analysisConfiguration == null) {
analysisConfiguration = new HashMap<String, Type>();
analysisConfiguration.put(MontiSecArcAnalysisConstants.ALL_ANALYSES, Type.WARNING);
} else {
analysisConfiguration.clear();
}
analysisConfiguration.put(MontiSecArcAnalysisConstants.ALL_ANALYSES, Type.WARNING);
return analysisConfiguration;
}
......@@ -398,18 +403,20 @@ public final class MontiSecArcAnalysisCreator {
Map<String, String> mapping = createMappingNameConstant();
if(analysisConfiguration == null) {
analysisConfiguration = new HashMap<String, Type>();
//Add analysis from configuration file
for(Entry<String, String> it : mapping.entrySet()) {
if(existsAnalysisInFile(pathConfiguration, it.getKey())) {
analysisConfiguration.put(it.getValue(), Type.WARNING);
}
} else {
analysisConfiguration.clear();
}
//Add analysis from configuration file
for(Entry<String, String> it : mapping.entrySet()) {
if(existsAnalysisInFile(pathConfiguration, it.getKey())) {
analysisConfiguration.put(it.getValue(), Type.WARNING);
}
}
//Add analysis for parameter
analysisConfiguration.put(MontiSecArcAnalysisConstants.ALL_PARAMETER, Type.WARNING);
//Add analysis for parameter
analysisConfiguration.put(MontiSecArcAnalysisConstants.ALL_PARAMETER, Type.WARNING);
}
return analysisConfiguration;
}
......
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