Skip to content

Commit

Permalink
allow relative paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Timbals committed Jan 11, 2024
1 parent b3e0312 commit e93fc5d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions CryptoAnalysis/src/main/java/crypto/HeadlessCryptoScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,18 @@ protected List<CrySLRule> getRules() {
switch(settings.getRulesetPathType()) {
case DIR:
try {
rules.addAll(ruleReader.readFromDirectory(new File(settings.getRulesetPathDir())));
rulesetRootPath = settings.getRulesetPathDir().substring(0, settings.getRulesetPathDir().lastIndexOf(File.separator));
File ruleSetDir = new File(settings.getRulesetPathDir());
rules.addAll(ruleReader.readFromDirectory(ruleSetDir));
rulesetRootPath = ruleSetDir.getParent();
} catch (CryptoAnalysisException e) {
LOGGER.error("Error happened when getting the CrySL rules from the specified directory: " + settings.getRulesetPathDir(), e);
}
break;
case ZIP:
try {
rules.addAll(ruleReader.readFromZipFile(new File(settings.getRulesetPathDir())));
rulesetRootPath = settings.getRulesetPathDir().substring(0, settings.getRulesetPathDir().lastIndexOf(File.separator));
File ruleSetZip = new File(settings.getRulesetPathDir());
rules.addAll(ruleReader.readFromZipFile(ruleSetZip));
rulesetRootPath = ruleSetZip.getParent();
} catch (CryptoAnalysisException e) {
LOGGER.error("Error happened when getting the CrySL rules from the specified file: " + settings.getRulesetPathDir(), e);
}
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ A packaged `jar` artifact including all dependency is found in `CryptoAnalysis/
## Usage

CogniCrypt<sub>SAST</sub> can be started in headless mode (i.e., detached from Eclipse) via the class `crypto.HeadlessCryptoScanner`. It requires two arguments:
* The absolute path to the directory of the CrySL (source code format) rule files. The source code for the rules which contain specification for the JCA is found [here](https://github.com/CROSSINGTUD/Crypto-API-Rules).
* The absolute path of the application to be analyzed (.jar file or the root compilation output folder which contains the .class files in subdirectories)
* The path to the directory of the CrySL (source code format) rule files. The source code for the rules which contain specification for the JCA is found [here](https://github.com/CROSSINGTUD/Crypto-API-Rules).
* The path of the application to be analyzed (.jar file or the root compilation output folder which contains the .class files in subdirectories)

```
java -cp <path-to-analysis-jar> crypto.HeadlessCryptoScanner
--rulesDir <absolute-path-to-crysl-source-code-format-rules>
--appPath <absolute-application-path>
--rulesDir <path-to-crysl-source-code-format-rules>
--appPath <application-path>
```

For an easy start we prepared a .jar containing classes with crypto misuses. The source code for these misuses is found [here](https://github.com/CROSSINGTUD/CryptoAnalysis/tree/develop/CryptoAnalysisTargets/CogniCryptDemoExample/src/main/java/example). To run CogniCrypt<sub>SAST</sub> on these classes, simply execute the following command (on a linux based system).
Expand Down

0 comments on commit e93fc5d

Please sign in to comment.