Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import org.apache.tools.ant.taskdefs.condition.Os;
import org.apache.tools.ant.taskdefs.condition.Os

plugins {
id 'java'
Expand Down Expand Up @@ -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
Expand Down
26 changes: 17 additions & 9 deletions src/main/java/de/fraunhofer/iem/icognicrypt/CogniCryptPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}




6 changes: 3 additions & 3 deletions src/main/java/de/fraunhofer/iem/icognicrypt/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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/";
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -140,14 +141,21 @@ private List<CrySLRule> 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<String> getIncludeList() {
final List<String> includeList = new LinkedList<String>();
final List<String> includeList = new LinkedList<>();
includeList.add("java.lang.AbstractStringBuilder");
includeList.add("java.lang.Boolean");
includeList.add("java.lang.Byte");
Expand All @@ -162,7 +170,7 @@ private static List<String> getIncludeList() {
}

private List<String> getExcludeList() {
final List<String> excludeList = new LinkedList<String>();
final List<String> excludeList = new LinkedList<>();
for (final CrySLRule r : getRules()) {
excludeList.add(r.getClassName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public String GetDefaultCrySLPath(RulesTarget ruleSet)
switch (ruleSet)
{

case JCA:
rulesPath = "JCA";
case JavaCryptographicArchitecture:
rulesPath = "JavaCryptographicArchitecture";
break;
case BoucyCastle:
rulesPath = "BouncyCastle";
Expand Down Expand Up @@ -74,6 +74,7 @@ private String GetExtractPath()
try
{
return Paths.get(pluginsDirectory.toString(), Constants.DefaultExtractLocation).toFile().getCanonicalPath();

}
catch (IOException e)
{
Expand All @@ -82,7 +83,7 @@ private String GetExtractPath()
}

public enum RulesTarget{
JCA,
JavaCryptographicArchitecture,
BoucyCastle,
Tink
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
Expand All @@ -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()
{
Expand Down Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public CogniCryptSettingsPersistentComponent getState()
@Override
public void loadState(@NotNull CogniCryptSettingsPersistentComponent icognicryptSettings)
{
XmlSerializerUtil.copyBean(icognicryptSettings, this);
XmlSerializerUtil.copyBean(icognicryptSettings, this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Loading