Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress errors related to legacy client in code generator #381

Closed
Closed
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
110c28e
save wizard options to file, incomplete
shahrzadav Oct 22, 2019
7adb97e
Saved Q&A hashmap in xml file
shahrzadav Oct 24, 2019
de1ab7d
Merge branch 'develop2' into iss193-FilterResult
shahrzadav Jan 20, 2020
535fed9
Merge branch 'develop' into iss193-FilterResult
shahrzadav Jan 24, 2020
803ced0
Solved issue 193- first draft
shahrzadav Feb 6, 2020
8d97216
cleaned up
shahrzadav Feb 11, 2020
2a5ad9a
minor fix try-catch statement
shahrzadav Feb 11, 2020
15059a4
all changes related to add json-simple library
shahrzadav Feb 16, 2020
13acdc8
Merge branch 'develop2' into iss193-FilterResult
shahrzadav Feb 17, 2020
57d4a60
created a checkbox in pref page.
shahrzadav Feb 17, 2020
6a54670
added note in codeGen, new button in prefpage works
shahrzadav Feb 25, 2020
84dd29b
fixed question due to changes in dev
shahrzadav Feb 28, 2020
293345e
set dafault to true, changed msgs
shahrzadav Mar 4, 2020
f188ab4
Merge branch 'develop2' into iss193-FilterResult
shahrzadav Mar 4, 2020
c11be1d
Merge branch 'develop' into iss193-FilterResult
kruegers Mar 6, 2020
78dad2b
Merge branch 'develop2' into iss193-FilterResult
shahrzadav Mar 9, 2020
ca94d0a
Merge branch 'iss193-FilterResult' of https://github.com/shahrzadav/C…
shahrzadav Mar 9, 2020
dbc87ff
Merge branch 'develop2' into iss193-FilterResult
shahrzadav Mar 27, 2020
8efd959
Merge branch 'develop2' into iss193-FilterResult
shahrzadav Apr 2, 2020
07de860
removed unused import
shahrzadav Apr 2, 2020
e93fb22
Merge branch 'iss193-FilterResult' of https://github.com/shahrzadav/C…
shahrzadav Apr 2, 2020
803eb6b
Merge branch 'develop' into iss193-FilterResult
shahrzadav Apr 2, 2020
5b4c45c
Merge branch 'develop' into iss193-FilterResult
kruegers Apr 28, 2020
b014f19
change a constant temporarily, remove xtra line, correct questiontext
shahrzadav May 14, 2020
71b6ce5
Merge branch 'iss193-FilterResult' of https://github.com/shahrzadav/C…
shahrzadav May 14, 2020
b4f2edb
Merge branch 'develop2' into iss193-FilterResult
shahrzadav May 14, 2020
16c5eff
Rename a constant
shahrzadav May 21, 2020
a8cc723
added unmerged files
shahrzadav May 21, 2020
536bbe9
Merge branch 'develop2' into iss193-FilterResult
shahrzadav May 29, 2020
321611b
removed extra JRE in classpath
shahrzadav May 29, 2020
a47d0e2
changed to activators log error
shahrzadav Jun 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions plugins/de.cognicrypt.codegenerator/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,11 @@
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/claferchocoig.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
shahrzadav marked this conversation as resolved.
Show resolved Hide resolved
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/json-simple.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
3 changes: 2 additions & 1 deletion plugins/de.cognicrypt.codegenerator/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ Bundle-ClassPath: lib/claferchocoig.jar,
src/main/resources/,
src/main/java/,
lib/dom4j-2.0.0.jar,
lib/saxon9he.jar
lib/saxon9he.jar,
lib/json-simple.jar
Automatic-Module-Name: de.cognicrypt.codegenerator
Bundle-Vendor: TU Darmstadt, Paderborn University
Export-Package: de.cognicrypt.codegenerator,
Expand Down
4 changes: 3 additions & 1 deletion plugins/de.cognicrypt.codegenerator/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ bin.includes = plugin.xml,\
src/main/java/,\
target/classes/Tasks/tasks.json,\
lib/dom4j-2.0.0.jar,\
lib/saxon9he.jar
lib/saxon9he.jar,\
lib/json-simple.jar

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public boolean performFinish() {
codeGenerator.getDeveloperProject().refresh();

resetAnswers();
chosenConfig = new CrySLConfiguration(resFileOSPath, ((CrySLBasedCodeGenerator) codeGenerator).setUpTemplateClass(pathToTemplateFile));
chosenConfig = new CrySLConfiguration(resFileOSPath, ((CrySLBasedCodeGenerator) codeGenerator).setUpTemplateClass(pathToTemplateFile), selectedTask.getName());
break;
case XSL:
this.constraints = (this.constraints != null) ? this.constraints : new HashMap<>();
Expand All @@ -274,7 +274,7 @@ public boolean performFinish() {
// Initialize Code Generation
codeGenerator = new XSLBasedGenerator(targetFile, selectedTask.getCodeTemplate());
chosenConfig = new XSLConfiguration(instanceGenerator.getInstances().values().iterator()
.next(), this.constraints, codeGenerator.getDeveloperProject().getProjectPath() + Constants.innerFileSeparator + Constants.pathToClaferInstanceFile);
.next(), this.constraints, codeGenerator.getDeveloperProject().getProjectPath() + Constants.innerFileSeparator + Constants.pathToClaferInstanceFile, selectedTask.getName());
break;
default:
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@
package de.cognicrypt.codegenerator.wizard;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import java.util.Map;

import org.dom4j.io.XMLWriter;

import de.cognicrypt.codegenerator.question.Answer;
import de.cognicrypt.codegenerator.question.Question;
import de.cognicrypt.utils.FileUtils;
import de.cognicrypt.codegenerator.question.Question;
import de.cognicrypt.core.Constants;
import de.cognicrypt.utils.Utils;
import de.cognicrypt.utils.FileUtils;

import org.json.simple.JSONObject;
/**
* This class is a storage for the configuration chosen by the user.
*
Expand All @@ -32,11 +36,27 @@ public abstract class Configuration {

final protected Map<Question, Answer> options;
final protected String pathOnDisk;
protected Answer answr;
final protected String taskName;

@SuppressWarnings("unchecked")
public Configuration(Map<?, ?> constraints, String pathOnDisk) {
@SuppressWarnings("unchecked")
public Configuration(Map<?, ?> constraints, String pathOnDisk, String taskName) throws IOException {

this.answr = new Answer();
this.pathOnDisk = pathOnDisk;
this.options = (Map<Question, Answer>) constraints;
this.taskName = taskName;

JSONObject obj = new JSONObject();
this.options.forEach((question,answer) ->obj.put(question.getQuestionText(), answer.getValue()));
String jsonPath = Utils.getCurrentProject().getLocation().toOSString() + Constants.innerFileSeparator + taskName + Constants.JSON_EXTENSION;

File file = new File(jsonPath);
file.createNewFile();
shahrzadav marked this conversation as resolved.
Show resolved Hide resolved
FileWriter fileWriter = new FileWriter(file);
fileWriter.write(obj.toJSONString());
fileWriter.flush();
fileWriter.close();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public class CrySLConfiguration extends Configuration {

private final GeneratorClass template;

public CrySLConfiguration(String pathOnDisk, GeneratorClass templateClass) {
super(new HashMap<>(), pathOnDisk);
public CrySLConfiguration(String pathOnDisk, GeneratorClass templateClass, String selectedTask) throws IOException {
super(new HashMap<>(), pathOnDisk, selectedTask);
this.template = templateClass;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class XSLConfiguration extends Configuration {

final private InstanceClafer instance;

public XSLConfiguration(InstanceClafer instance, Map<Question, Answer> constraints, String pathOnDisk) {
super(constraints, pathOnDisk);
public XSLConfiguration(InstanceClafer instance, Map<Question, Answer> constraints, String pathOnDisk, String taskName) throws IOException {
super(constraints, pathOnDisk, taskName);
this.instance = instance;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.fieldassist.FieldDecoration;
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.IStructuredSelection;
Expand Down Expand Up @@ -706,6 +707,7 @@ public void widgetSelected(final SelectionEvent e) {
}

private Group createNote(final Composite parent, final Question question, boolean visible) {
IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
final Group notePanel = new Group(parent, SWT.NONE);
notePanel.setText("Note:");
final GridLayout gridLayout = new GridLayout();
Expand All @@ -722,7 +724,12 @@ private Group createNote(final Composite parent, final Question question, boolea
note.setLayoutData(new GridData(GridData.FILL_BOTH));
String noteText = question.getNote();
if (noteText.contains("$$$")) {
noteText = noteText.split("\\$\\$\\$")[1];

String[] noteText1 = noteText.split("\\$\\$\\$");
noteText = noteText1[1];
if (!prefStore.getBoolean(Constants.SUPPRESS_LEGACYCLIENT_ERRORS)) {
noteText = noteText + noteText1[2];
}
}
note.setText(noteText);
note.pack();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
{
"id": "0",
"element": "radio",
"note": "1$$$It is highly discouraged to enable support for legacy clients. This may have grave security implications.",
"note": "1$$$It is highly discouraged to enable support for legacy clients. This may have grave security implications.$$$\nCogniCrypt's analysis raises warnings when this option is selected. You can however disable such warnings for legacy configurations in the CogniCrypt preferences.",
shahrzadav marked this conversation as resolved.
Show resolved Hide resolved
"questionText": "Which clients should the server at least support?",
"answers": [
{
Expand Down
1 change: 1 addition & 0 deletions plugins/de.cognicrypt.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ Export-Package: boomerang;
org.eclipse.egit.github.core.service,
org.ini4j;uses:="org.ini4j.spi,new org.ini4j",
org.ini4j.spi,
org.json.simple,
soot;
uses:="soot.jimple.toolkits.scalar,
soot.toolkits.graph,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ public String toString() {
public static final String SHOW_SECURE_OBJECTS = "de.cognicrypt.staticanalyzer.secureObjects";
public static final String CALL_GRAPH_SELECTION = "de.cognicrypt.staticanalyzer.callgraphSelection";
public static final String SELECT_CUSTOM_RULES = "de.cognicrypt.staticanalyzer.selectCustomRules";
public static final String SUPPRESS_LEGACYCLIENT_ERRORS = "de.cognicrypt.staticanalyzer.suppressConstraintErrors";

public static final String ANALYSE_DEPENDENCIES = "de.cognicrypt.staticanalyzer.dependencyAnalysis";

Expand Down Expand Up @@ -622,4 +623,7 @@ public String toString() {
public static final String codeTemplateFolder =
"src" + Constants.innerFileSeparator + "main" + Constants.innerFileSeparator + "java" + Constants.innerFileSeparator + "de" + Constants.innerFileSeparator + "cognicrypt"
+ Constants.innerFileSeparator + "codegenerator" + Constants.innerFileSeparator + "crysl" + Constants.innerFileSeparator + "templates" + Constants.innerFileSeparator;

//name of tasks
public final static String SECURE_COMMUNICATION = "SecureCommunication";
}
8 changes: 6 additions & 2 deletions plugins/de.cognicrypt.staticanalyzer/.classpath
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this, should I add or not?

</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="experimental"/>
<classpathentry kind="lib" path="resources/json-simple.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
5 changes: 3 additions & 2 deletions plugins/de.cognicrypt.staticanalyzer/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Require-Bundle: org.eclipse.ui,
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .,
resources/
resources/json-simple.jar
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did not add this either

Automatic-Module-Name: de.cognicrypt.staticanalyzer
Import-Package: org.eclipse.ui.texteditor
Import-Package: org.eclipse.ui.texteditor,
org.json.simple
5 changes: 3 additions & 2 deletions plugins/de.cognicrypt.staticanalyzer/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ source.. = src/
bin.includes = plugin.xml,\
META-INF/,\
.,\
src/,\
experimental/
experimental/,\
resources/json-simple.jar
src.includes = resources/json-simple.jar
Binary file not shown.
Loading