You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48-46
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,54 @@ The static analysis CogniCrypt<sub>SAST</sub> takes rules written in the specifi
5
5
and performs a static analysis based on the specification of the rules. CrySL is a domain-specific language (DSL) designed to encode usage specifications for cryptographic
6
6
libaries (e.g., the [JCA](https://docs.oracle.com/en/java/javase/14/security/java-cryptography-architecture-jca-reference-guide.html) in particular). More information on CrySL and the static analysis may be found in [this paper](http://drops.dagstuhl.de/opus/volltexte/2018/9215/).
7
7
8
+
## Running CognitCrypt<sub>SAST</sub>
9
+
10
+
Let's assume we have the following program with some violations:
// Constraint Error: Key size of 64 is not allowed
26
+
generator.init(64);
27
+
28
+
// KeyGenerator is not correctly initialized
29
+
// RequiredPredicateEror: Generated key is not secure
30
+
SecretKey key = generator.generateKey(); // r1
31
+
32
+
// Constraint Error: "DES" is not allowed
33
+
Cipher cipher =Cipher.getInstance("DES"); // r2
34
+
35
+
// RequiredPredicateError: "key" is not securely generated
36
+
cipher.init(Cipher.ENCRYPT_MODE, key);
37
+
38
+
// IncompleteOperationError: Cipher object is not used
39
+
}
40
+
}
41
+
```
42
+
43
+
Using the [JCA rules](https://github.com/CROSSINGTUD/Crypto-API-Rules/tree/master/JavaCryptographicArchitecture/src), we execute the following command on a compiled version of this program:
CogniCrypt<sub>SAST</sub> runs the analysis and prints a report to the command line. In total, it reports 3 `ConstraintErrors`, 2 `RequiredPredicateErrors` and 1 `IncompleteOperationError`, and their positions in the original programs. Additionally, since we use `--visualization`, it creates the following image `visualization.png` in the directory `./output/`:
50
+
51
+

52
+
53
+
You can see that two `ConstraintErrors` on the object `r0` (KeyGenerator) cause a `RequiredPredicateError` on the object `r1` (SecretKey) which in turn causes a `RequiredPredicateError` on the object `r2` (Cipher). Additionally, there is another `ConstraintError` and `IncompleteOperationError` on the Cipher object. Note that the variables and statements correspond to the intermediate representation Jimple. You can match the variables to the command line output that lists all analyzed objects.
54
+
55
+
8
56
## Structure
9
57
We provide the implementation of the static analysis of CogniCrypt in:
10
58
*`CryptoAnalysis` contains the components for the actual analysis
@@ -129,49 +177,3 @@ We hare happy for every contribution from the community!
129
177
* [Contributing](CONTRIBUTING.md) for details on issues and merge requests.
130
178
* [Coding Guidles](CODING.md) for this project.
131
179
132
-
## Running CognitCrypt<sub>SAST</sub>
133
-
134
-
Let's assume we have the following program with some violations:
135
-
136
-
```java
137
-
import java.security.GeneralSecurityException;
138
-
import javax.crypto.KeyGenerator;
139
-
import javax.crypto.SecretKey;
140
-
import javax.crypto.spec.SecretKeySpec;
141
-
import javax.crypto.Cipher;
142
-
143
-
public class Example {
144
-
145
-
public static void main(String[] args) throws GeneralSecurityException {
// Constraint Error: Key size of 64 is not allowed
150
-
generator.init(64);
151
-
152
-
// KeyGenerator is not correctly initialized
153
-
// RequiredPredicateEror: Generated key is not secure
154
-
SecretKey key = generator.generateKey(); // r1
155
-
156
-
// Constraint Error: "DES" is not allowed
157
-
Cipher cipher = Cipher.getInstance("DES"); // r2
158
-
159
-
// RequiredPredicateError: "key" is not securely generated
160
-
cipher.init(Cipher.ENCRYPT_MODE, key);
161
-
162
-
// IncompleteOperationError: Cipher object is not used
163
-
}
164
-
}
165
-
```
166
-
167
-
Using the [JCA rules](https://github.com/CROSSINGTUD/Crypto-API-Rules/tree/master/JavaCryptographicArchitecture/src), we execute the following command on a compiled version of this program:
CogniCrypt<sub>SAST</sub> runs the analysis and prints a report to the command line. In total, it reports 3 `ConstraintErrors`, 2 `RequiredPredicateErrors` and 1 `IncompleteOperationError`, and their positions in the original programs. Additionally, since we use `--visualization`, it creates the following image `visualization.png` in the directory `./output/`:
174
-
175
-

176
-
177
-
You can see that two `ConstraintErrors` on the object `r0` (KeyGenerator) cause a `RequiredPredicateError` on the object `r1` (SecretKey) which in turn causes a `RequiredPredicateError` on the object `r2` (Cipher). Additionally, there is another `ConstraintError` and `IncompleteOperationError` on the Cipher object. Note that the variables and statements correspond to the intermediate representation Jimple. You can match the variables to the command line output that lists all analyzed objects.
0 commit comments