diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 95b24b9..0f24ae0 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -4,8 +4,6 @@
-
-
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index d39baa9..e09325a 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -1,6 +1,7 @@
+
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index c6c9827..fd5a3f9 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -41,5 +41,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 3eadea6..121a7e3 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -5,6 +5,9 @@
+
+
+
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 344cdca..1c777bf 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -5,9 +5,6 @@
-
-
-
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 903d972..87abbad 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,4 +1,4 @@
-import org.apache.tools.ant.taskdefs.condition.Os;
+import org.apache.tools.ant.taskdefs.condition.Os
plugins {
id 'java'
@@ -29,18 +29,20 @@ repositories {
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'ca.mcgill.sable', name: 'soot', version: '4.0.0'
- compile group: 'de.fraunhofer.iem', name: 'CryptoAnalysis-Android', version: '2.7.2'
- compile group: 'de.fraunhofer.iem', name: 'CryptoAnalysis', version: '2.7.2'
+ compile group: 'de.fraunhofer.iem', name: 'CryptoAnalysis-Android', version: '2.7.3-SNAPSHOT'
+ compile group: 'de.fraunhofer.iem', name: 'CryptoAnalysis', version: '2.7.3-SNAPSHOT'
compile group: 'de.tud.sse', name: 'soot-infoflow', version: '2.7.1'
compile group: 'de.tud.sse', name: 'soot-infoflow-android', version: '2.7.1'
compile group: 'de.tud.sse', name: 'soot-infoflow-cmd', version: '2.7.1'
compile group: 'org.swinglabs.swingx', name: 'swingx-all', version: '1.6.4'
+ compile group: 'de.darmstadt.tu.crossing', name: 'JavaCryptographicArchitecture', version: '1.5.1',ext: 'zip',classifier: 'ruleset', changing: true
+
}
patchPluginXml {
sinceBuild '191'
- untilBuild '202.*'
+ untilBuild '203.*'
}
// See https://github.com/JetBrains/gradle-intellij-plugin/gradle
diff --git a/src/main/java/de/fraunhofer/iem/icognicrypt/CogniCryptPlugin.java b/src/main/java/de/fraunhofer/iem/icognicrypt/CogniCryptPlugin.java
index 857ac5d..bb666a1 100644
--- a/src/main/java/de/fraunhofer/iem/icognicrypt/CogniCryptPlugin.java
+++ b/src/main/java/de/fraunhofer/iem/icognicrypt/CogniCryptPlugin.java
@@ -5,26 +5,34 @@
import de.fraunhofer.iem.icognicrypt.core.crySL.CrySLExtractor;
import de.fraunhofer.iem.icognicrypt.settings.IPersistableCogniCryptSettings;
-import java.io.Console;
-
-public class CogniCryptPlugin extends BackgroundComponent
-{
+public class CogniCryptPlugin extends BackgroundComponent {
private final CrySLExtractor _extractor;
private final IPersistableCogniCryptSettings _settings;
+ String version;
- private CogniCryptPlugin(CrySLExtractor extractor, IPersistableCogniCryptSettings settings)
- {
+ private CogniCryptPlugin(CrySLExtractor extractor, IPersistableCogniCryptSettings settings) {
_extractor = extractor;
_settings = settings;
}
@Override
- protected void InitializeInBackground(ProgressIndicator indicator)
- {
+ protected void InitializeInBackground(ProgressIndicator indicator) {
_extractor.ExtractIfRequired();
- String path = _extractor.GetDefaultCrySLPath(CrySLExtractor.RulesTarget.JCA);
+ String path = _extractor.GetDefaultCrySLPath(CrySLExtractor.RulesTarget.JavaCryptographicArchitecture);
+// try {
+// version = CrySLUpdateChecker.current_version;
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
if (_settings.getRulesDirectory().equals(Constants.DummyCrySLPath) &&
!path.equals(Constants.DummyCrySLPath))
_settings.setRulesDirectory(path);
+// if (_settings.getCurrentVersion().equals(Constants.CrySL_Version) &&
+// !version.equals(Constants.CrySL_Version))
+// _settings.setCurrentVersion(version);
}
}
+
+
+
+
diff --git a/src/main/java/de/fraunhofer/iem/icognicrypt/Constants.java b/src/main/java/de/fraunhofer/iem/icognicrypt/Constants.java
index 048582b..c28a364 100644
--- a/src/main/java/de/fraunhofer/iem/icognicrypt/Constants.java
+++ b/src/main/java/de/fraunhofer/iem/icognicrypt/Constants.java
@@ -7,12 +7,12 @@ public class Constants {
public final static boolean AUTOMATIC_SCAN_ON_COMPILE = false;
public static final String DummyCrySLPath = "./CrySLRules/JavaCryptographicArchitecture";
-
+ public static final String CrySL_Version = "1.5.1";
// TODO: This constant is not final in CryptoAnalysis
public static final String CRYSL_EXTENSION = CrySLModelReader.cryslFileEnding;
- public static final String CRYSL_RULES_DOWNLOADLINK = "https://soot-build.cs.uni-paderborn.de/nexus/repository/soot-release/de/darmstadt/tu/crossing/JavaCryptographicArchitecture/1.5.1/JavaCryptographicArchitecture-1.5.1-ruleset.zip";
+ public static final String CRYSL_RULES_DOWNLOADLINK = "https://soot-build.cs.uni-paderborn.de/nexus/repository/soot-release/de/darmstadt/tu/crossing/JavaCryptographicArchitecture/1.5.2/JavaCryptographicArchitecture-1.5.2-ruleset.zip";
public static final boolean WARNINGS_IN_SOURCECODECLASSES_ONLY = true;
- public static final String ResourceZipPath = "/CrySLRules/JavaCryptographicArchitecture-1.5.1-ruleset.zip";
+ public static final String ResourceZipPath = "JavaCryptographicArchitecture-1.5.1-ruleset.zip";
public static final String DefaultExtractLocation = "./CrySLRules/";
}
diff --git a/src/main/java/de/fraunhofer/iem/icognicrypt/analysis/CryptoAnalysisWrapper.java b/src/main/java/de/fraunhofer/iem/icognicrypt/analysis/CryptoAnalysisWrapper.java
index 8f5fdd8..5ad6a01 100644
--- a/src/main/java/de/fraunhofer/iem/icognicrypt/analysis/CryptoAnalysisWrapper.java
+++ b/src/main/java/de/fraunhofer/iem/icognicrypt/analysis/CryptoAnalysisWrapper.java
@@ -7,6 +7,7 @@
import com.intellij.openapi.project.Project;
import crypto.analysis.CrySLAnalysisListener;
import crypto.analysis.CryptoScanner;
+import crypto.exceptions.CryptoAnalysisException;
import crypto.rules.CrySLRule;
import crypto.rules.CrySLRuleReader;
import de.fraunhofer.iem.icognicrypt.settings.IPersistableCogniCryptSettings;
@@ -140,14 +141,21 @@ private List getRules()
File rulesDirectory = new File(_rulesDirectory);
return Arrays.stream(rulesDirectory.listFiles()).
- map(x -> CrySLRuleReader.readFromSourceFile(x)).collect(Collectors.toList());
+ map(x -> {
+ try {
+ return CrySLRuleReader.readFromSourceFile(x);
+ } catch (CryptoAnalysisException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }).collect(Collectors.toList());
// TODO:
// return CrySLRuleReader.readFromDirectory(new File(_rulesDirectory));
}
private static List getIncludeList() {
- final List includeList = new LinkedList();
+ final List includeList = new LinkedList<>();
includeList.add("java.lang.AbstractStringBuilder");
includeList.add("java.lang.Boolean");
includeList.add("java.lang.Byte");
@@ -162,7 +170,7 @@ private static List getIncludeList() {
}
private List getExcludeList() {
- final List excludeList = new LinkedList();
+ final List excludeList = new LinkedList<>();
for (final CrySLRule r : getRules()) {
excludeList.add(r.getClassName());
}
diff --git a/src/main/java/de/fraunhofer/iem/icognicrypt/core/BackgroundComponent.java b/src/main/java/de/fraunhofer/iem/icognicrypt/core/BackgroundComponent.java
index 4067020..6a80c5f 100644
--- a/src/main/java/de/fraunhofer/iem/icognicrypt/core/BackgroundComponent.java
+++ b/src/main/java/de/fraunhofer/iem/icognicrypt/core/BackgroundComponent.java
@@ -18,7 +18,7 @@
public class BackgroundComponent implements BaseComponent
{
protected final Logger Logger = com.intellij.openapi.diagnostic.Logger.getInstance(this.getClass());
- protected String Title = "";
+ protected String Title = "Running CogniCrypt";
protected boolean CanCancelInit = true;
diff --git a/src/main/java/de/fraunhofer/iem/icognicrypt/core/Helpers/ResourceExtractor.java b/src/main/java/de/fraunhofer/iem/icognicrypt/core/Helpers/ResourceExtractor.java
index 667f1d8..10f8204 100644
--- a/src/main/java/de/fraunhofer/iem/icognicrypt/core/Helpers/ResourceExtractor.java
+++ b/src/main/java/de/fraunhofer/iem/icognicrypt/core/Helpers/ResourceExtractor.java
@@ -1,9 +1,12 @@
package de.fraunhofer.iem.icognicrypt.core.Helpers;
import com.intellij.openapi.application.PathManager;
+import de.fraunhofer.iem.icognicrypt.Constants;
import de.fraunhofer.iem.icognicrypt.core.crySL.CrySLExtractor;
import java.io.*;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -30,7 +33,10 @@ public final void ExtractIfRequired()
// (c) Christoph Dähne https://gist.github.com/christoph-daehne/e7ecf4abf26da41072b31e0431d841e7#file-ziputils-java
protected final void unzip(String resourcePath, File target) throws IOException
{
- InputStream inputStream = getClass().getResourceAsStream(resourcePath);
+ Path jarPath = Paths.get(ExecutingJarPath);
+ Path pluginsDirectory = jarPath.getParent().toAbsolutePath();
+ resourcePath= Paths.get(pluginsDirectory.toString(), Constants.ResourceZipPath).toFile().getCanonicalPath();
+ InputStream inputStream = new FileInputStream(resourcePath);
final ZipInputStream zipStream = new ZipInputStream(inputStream);
ZipEntry nextEntry;
while ((nextEntry = zipStream.getNextEntry()) != null)
diff --git a/src/main/java/de/fraunhofer/iem/icognicrypt/core/crySL/CrySLExtractor.java b/src/main/java/de/fraunhofer/iem/icognicrypt/core/crySL/CrySLExtractor.java
index e48e562..604eef4 100644
--- a/src/main/java/de/fraunhofer/iem/icognicrypt/core/crySL/CrySLExtractor.java
+++ b/src/main/java/de/fraunhofer/iem/icognicrypt/core/crySL/CrySLExtractor.java
@@ -44,8 +44,8 @@ public String GetDefaultCrySLPath(RulesTarget ruleSet)
switch (ruleSet)
{
- case JCA:
- rulesPath = "JCA";
+ case JavaCryptographicArchitecture:
+ rulesPath = "JavaCryptographicArchitecture";
break;
case BoucyCastle:
rulesPath = "BouncyCastle";
@@ -74,6 +74,7 @@ private String GetExtractPath()
try
{
return Paths.get(pluginsDirectory.toString(), Constants.DefaultExtractLocation).toFile().getCanonicalPath();
+
}
catch (IOException e)
{
@@ -82,7 +83,7 @@ private String GetExtractPath()
}
public enum RulesTarget{
- JCA,
+ JavaCryptographicArchitecture,
BoucyCastle,
Tink
}
diff --git a/src/main/java/de/fraunhofer/iem/icognicrypt/settings/CogniCryptSettings.java b/src/main/java/de/fraunhofer/iem/icognicrypt/settings/CogniCryptSettings.java
index 023d9a2..503a268 100644
--- a/src/main/java/de/fraunhofer/iem/icognicrypt/settings/CogniCryptSettings.java
+++ b/src/main/java/de/fraunhofer/iem/icognicrypt/settings/CogniCryptSettings.java
@@ -11,6 +11,7 @@
abstract class CogniCryptSettings implements ICogniCryptSettings
{
protected String RulesDirectory = Constants.DummyCrySLPath;
+ protected String current_version = Constants.CrySL_Version;
protected boolean FindAutomatically = true;
protected boolean IncludeSigned = false;
protected boolean SignedOnly = false;
@@ -22,9 +23,9 @@ public CogniCryptSettings(){
}
- public CogniCryptSettings(ICogniCryptSettings other)
- {
+ public CogniCryptSettings(ICogniCryptSettings other) {
setRulesDirectory(other.getRulesDirectory());
+ setCurrentVersion(other.getCurrentVersion());
setFindAutomatically(other.getFindAutomatically());
setFinderBuildType(other.getFinderBuildType());
setIncludeSigned(other.getIncludeSigned());
@@ -42,6 +43,16 @@ public void setRulesDirectory(String rulesDirectory)
RulesDirectory = rulesDirectory;
}
+ public String getCurrentVersion() {
+ return current_version;
+ }
+
+ public void setCurrentVersion(String currentVersion)
+ {
+ current_version = currentVersion;
+ }
+
+
@Override
public boolean getFindAutomatically()
{
@@ -126,14 +137,16 @@ public boolean equals(Object obj)
if (!(obj instanceof ICogniCryptSettings))
return false;
ICogniCryptSettings other = (ICogniCryptSettings) obj;
- return equals(other);
+ return equals(other);
}
- public boolean equals(ICogniCryptSettings other){
+ public boolean equals(ICogniCryptSettings other) {
if (other == null)
return false;
if (!RulesDirectory.equals(other.getRulesDirectory()))
return false;
+ if (!current_version.equals(other.getCurrentVersion()))
+ return false;
if (FindAutomatically != other.getFindAutomatically())
return false;
if (FinderBuildType != other.getFinderBuildType())
diff --git a/src/main/java/de/fraunhofer/iem/icognicrypt/settings/CogniCryptSettingsPersistentComponent.java b/src/main/java/de/fraunhofer/iem/icognicrypt/settings/CogniCryptSettingsPersistentComponent.java
index d30eb90..bb8e621 100644
--- a/src/main/java/de/fraunhofer/iem/icognicrypt/settings/CogniCryptSettingsPersistentComponent.java
+++ b/src/main/java/de/fraunhofer/iem/icognicrypt/settings/CogniCryptSettingsPersistentComponent.java
@@ -23,7 +23,7 @@ public CogniCryptSettingsPersistentComponent getState()
@Override
public void loadState(@NotNull CogniCryptSettingsPersistentComponent icognicryptSettings)
{
- XmlSerializerUtil.copyBean(icognicryptSettings, this);
+ XmlSerializerUtil.copyBean(icognicryptSettings, this);
}
@Override
diff --git a/src/main/java/de/fraunhofer/iem/icognicrypt/settings/CogniCryptSettingsView.java b/src/main/java/de/fraunhofer/iem/icognicrypt/settings/CogniCryptSettingsView.java
index b3637d4..32b7916 100644
--- a/src/main/java/de/fraunhofer/iem/icognicrypt/settings/CogniCryptSettingsView.java
+++ b/src/main/java/de/fraunhofer/iem/icognicrypt/settings/CogniCryptSettingsView.java
@@ -118,6 +118,7 @@ public void apply()
{
IPersistableCogniCryptSettings settings = ServiceManager.getService(IPersistableCogniCryptSettings.class);
settings.setRulesDirectory(_currentState.getRulesDirectory());
+ settings.setCurrentVersion(_currentState.getCurrentVersion());
settings.setFindAutomatically(_currentState.getFindAutomatically());
settings.setFinderBuildType(_currentState.getFinderBuildType());
settings.setIncludeSigned(_currentState.getIncludeSigned());
diff --git a/src/main/java/de/fraunhofer/iem/icognicrypt/settings/CrySLUpdateChecker.java b/src/main/java/de/fraunhofer/iem/icognicrypt/settings/CrySLUpdateChecker.java
new file mode 100644
index 0000000..bd8bd83
--- /dev/null
+++ b/src/main/java/de/fraunhofer/iem/icognicrypt/settings/CrySLUpdateChecker.java
@@ -0,0 +1,221 @@
+package de.fraunhofer.iem.icognicrypt.settings;
+
+import de.fraunhofer.iem.icognicrypt.Constants;
+import com.intellij.openapi.application.PathManager;
+import com.intellij.notification.Notification;
+import com.intellij.notification.NotificationType;
+import com.intellij.notification.Notifications;
+import com.intellij.openapi.components.ServiceManager;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.startup.StartupActivity;
+import de.fraunhofer.iem.icognicrypt.ui.NotificationProvider;
+import org.jetbrains.annotations.NotNull;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Parser;
+
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+public class CrySLUpdateChecker extends CogniCryptSettings implements StartupActivity {
+ private static final Logger LOG = Logger.getInstance(CrySLUpdateChecker.class);
+ private static final String GROUP_DISPLAY_ID = "Error";
+ public static String latest_version;
+ public static String current_version;
+
+ private ICogniCryptSettings _currentState;
+
+ @Override
+ public void runActivity(@NotNull Project project) {
+ _currentState = ServiceManager.getService(IPersistableCogniCryptSettings.class);
+ current_version = _currentState.getCurrentVersion();
+ try {
+ latest_version = getLatestVersion();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ if (latest_version_Available()) {
+ Notifications.Bus.notify(
+ new Notification(
+ GROUP_DISPLAY_ID,
+ "CogniCrypt Message: CrySL Rule Update",
+ "A Newer version of CrySL ruleset available."+"\n" +"Update now.",
+ NotificationType.INFORMATION,
+ (notification, hyperlinkEvent) -> {
+ try {
+ update(current_version, latest_version);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }),
+ project);
+ }
+ else{
+ }
+ }
+
+ public boolean latest_version_Available() {
+ String[] l_version = latest_version.split(Pattern.quote("."));
+ String[] c_version = current_version.split(Pattern.quote("."));
+ int i = 0;
+ while (i < l_version.length) {
+ int l_int = Integer.parseInt(l_version[i]);
+ int c_int = Integer.parseInt(c_version[i]);
+ if (l_int > c_int) {
+ return true;
+ } else if (l_int == c_int) {
+ i++;
+ } else {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ public void update(String cur_version, String lat_version) throws IOException {
+ String sourceURL = "https://soot-build.cs.uni-paderborn.de/nexus/repository/soot-release/de/darmstadt/tu/crossing/JavaCryptographicArchitecture/1.5.2/JavaCryptographicArchitecture-1.5.2-ruleset.zip";
+
+ String executingjarpath = PathManager.getJarPathForClass(CrySLUpdateChecker.class);
+ Path jarPath = Paths.get(executingjarpath);
+ Path pluginsDirectory = jarPath.getParent().toAbsolutePath();
+ String resourcePath = Paths.get(pluginsDirectory.toString()).toFile().getCanonicalPath();
+
+ URL url = new URL(sourceURL);
+ String fileName = sourceURL.substring(sourceURL.lastIndexOf('/') + 1, sourceURL.length());
+ Path targetPath = new File(resourcePath + File.separator + fileName).toPath();
+ Files.copy(url.openStream(), targetPath, StandardCopyOption.REPLACE_EXISTING);
+ deleteOldCrySL(resourcePath);
+ current_version = latest_version;
+ _currentState.setCurrentVersion(latest_version);
+ NotificationProvider.ShowInfo("Crysl rules updated to " + _currentState.getCurrentVersion());
+ extractDownloadedCrySL(targetPath.toString(), fileName, resourcePath);
+ }
+
+ private void extractDownloadedCrySL(String targetPath, String fileName, String resourcePath) throws IOException {
+ File downloadedFile = new File(targetPath);
+ File target = new File(resourcePath + File.separator + "CrySLRules" + File.separator);
+ if (!downloadedFile.exists()) {
+ throw new IOException(downloadedFile.getAbsolutePath() + " does not exist");
+ } else {
+ InputStream inputStream = new FileInputStream(downloadedFile.getAbsoluteFile());
+ final ZipInputStream zipInputStreamStream = new ZipInputStream(inputStream);
+ ZipEntry nextEntry;
+ while ((nextEntry = zipInputStreamStream.getNextEntry()) != null) {
+ final String name = nextEntry.getName();
+ if (!name.endsWith("/")) {
+ final File nextFile = new File(target, name);
+ final File parent = nextFile.getParentFile();
+ if (parent != null) {
+ parent.mkdirs();
+ }
+ try (OutputStream targetStream = new FileOutputStream(nextFile)) {
+ copy(zipInputStreamStream, targetStream);
+ }
+ }
+ }
+ }
+ }
+
+ public static void copy(final InputStream source, final OutputStream target) throws IOException {
+ final int bufferSize = 4 * 1024;
+ final byte[] buffer = new byte[bufferSize];
+
+ int nextCount;
+ while ((nextCount = source.read(buffer)) >= 0) {
+ target.write(buffer, 0, nextCount);
+ }
+ }
+
+ private void deleteOldCrySL(String resourcePath) {
+ String oldCrySLPath = resourcePath + File.separator + "CrySLRules" + File.separator + "JavaCryptographicArchitecture" + File.separator;
+ File index = new File(oldCrySLPath);
+ String[] entries = index.list();
+ for (String s : entries) {
+ File currentFile = new File(index.getPath(), s);
+ currentFile.delete();
+ }
+ index.delete();
+ }
+
+
+ public String getLatestVersion() throws IOException {
+ URL obj = new URL("https://soot-build.cs.uni-paderborn.de/nexus/repository/soot-release/de/darmstadt/tu/crossing/JavaCryptographicArchitecture/maven-metadata.xml");
+ HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+ con.setRequestMethod("GET");
+ con.setRequestProperty("User-Agent", "Mozilla/5.0");
+ int responseCode = con.getResponseCode();
+ System.out.println("GET Response Code :: " + responseCode);
+ if (responseCode == HttpURLConnection.HTTP_OK) { // success
+ BufferedReader in = new BufferedReader(new InputStreamReader(
+ con.getInputStream()));
+ String inputLine;
+ StringBuffer response = new StringBuffer();
+
+ while ((inputLine = in.readLine()) != null) {
+ response.append(inputLine);
+ }
+ in.close();
+
+ Document doc = (Document) Jsoup.parse(response.toString(), "", Parser.xmlParser());
+ Element e = doc.getElementsByTag("latest").first();
+ latest_version = e.text();
+ }
+ return latest_version;
+ }
+
+
+ public String getCurrentVersions() throws IOException {
+
+ String executingjarpath = PathManager.getJarPathForClass(CrySLUpdateChecker.class);
+ Path jarPath = Paths.get(executingjarpath);
+ Path pluginsDirectory = jarPath.getParent().toAbsolutePath();
+ String resourcePath = Paths.get(pluginsDirectory.toString()).toFile().getCanonicalPath();
+
+ File dir = new File(resourcePath);
+ List allZipCrySLRules = searchForFileNameContainingSubstring(dir, "JavaCryptographicArchitecture");
+ String cVersion = CompareVersion(allZipCrySLRules);
+ _currentState.setCurrentVersion(cVersion);
+ try {
+ return cVersion;
+ } catch (Exception e) {
+ return Constants.CrySL_Version;
+ }
+
+ }
+
+ private String CompareVersion(List allZipCrySLRules) {
+ for (String fileName : allZipCrySLRules) {
+ fileName = fileName.replaceAll("[^\\d.]", "");
+ return fileName;
+ }
+ return null;
+ }
+
+ private List searchForFileNameContainingSubstring(File file, String substring) {
+
+ List filesContainingSubstring = new ArrayList();
+
+ if (file.exists() && file.isDirectory()) {
+ String[] files = file.list(); //get the files in String format.
+ for (String fileName : files) {
+ if (fileName.contains(substring))
+ filesContainingSubstring.add(fileName);
+ }
+ }
+ return filesContainingSubstring;
+ }
+
+}
diff --git a/src/main/java/de/fraunhofer/iem/icognicrypt/settings/ICogniCryptSettings.java b/src/main/java/de/fraunhofer/iem/icognicrypt/settings/ICogniCryptSettings.java
index aacb677..f850320 100644
--- a/src/main/java/de/fraunhofer/iem/icognicrypt/settings/ICogniCryptSettings.java
+++ b/src/main/java/de/fraunhofer/iem/icognicrypt/settings/ICogniCryptSettings.java
@@ -11,6 +11,10 @@ interface ICogniCryptSettings
void setRulesDirectory(String rulesDirectory);
+ String getCurrentVersion();
+
+ void setCurrentVersion(String current_version);
+
boolean getFindAutomatically();
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index f0d17ad..95293a2 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -60,6 +60,7 @@
+
@@ -97,7 +98,6 @@
-
de.fraunhofer.iem.icognicrypt.CogniCryptPlugin