Skip to content

Commit 1fd7643

Browse files
committed
Adding example slicing queries.
1 parent 7b7ed61 commit 1fd7643

11 files changed

+141
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @name Detects known asymmetric algorithms
3+
* @id java/crypto_inventory_slices/known_asymmetric_algorithm
4+
* @kind problem
5+
*/
6+
7+
import java
8+
import experimental.Quantum.Language
9+
10+
from Crypto::AlgorithmNode a
11+
where Crypto::isKnownAsymmetricAlgorithm(a)
12+
select a, "Instance of asymmetric algorithm " + a.getAlgorithmName()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @name Detects operations where the algorithm applied is a known asymmetric algorithms
3+
* @id java/crypto_inventory_slices/known_asymmetric_operation_algorithm
4+
* @kind problem
5+
*/
6+
7+
import java
8+
import experimental.Quantum.Language
9+
10+
from Crypto::OperationNode op, Crypto::AlgorithmNode a
11+
where a = op.getAKnownAlgorithm() and Crypto::isKnownAsymmetricAlgorithm(a)
12+
select op, "Operation using asymmetric algorithm $@", a, a.getAlgorithmName()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @name Detects known elliptic curve algorithms
3+
* @id java/crypto_inventory_slices/known_elliptic_curvee_algorithm
4+
* @kind problem
5+
*/
6+
7+
import java
8+
import experimental.Quantum.Language
9+
10+
from Crypto::EllipticCurveNode a
11+
select a, "Instance of elliptic curve algorithm " + a.getAlgorithmName()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @name Detects algorithms that are known hashing algorithms
3+
* @id java/crypto_inventory_slices/known_hashing_algorithm
4+
* @kind problem
5+
*/
6+
7+
import java
8+
import experimental.Quantum.Language
9+
10+
from Crypto::HashAlgorithmNode a
11+
select a, "Instance of hashing algorithm " + a.getAlgorithmName()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @name Detects uses of hashing operations (operations exlicitly for hashing only, irrespective of the algorithm used)
3+
* @id java/crypto_inventory_slices/known_hashing_operation
4+
* @kind problem
5+
*/
6+
7+
import java
8+
import experimental.Quantum.Language
9+
10+
from Crypto::HashOperationNode op
11+
select op, "Known hashing operation"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @name Detects operations where the algorithm applied is a known hashing algorithm
3+
* @id java/crypto_inventory_slices/operation_with_known_hashing_algorithm
4+
* @kind problem
5+
*/
6+
7+
import java
8+
import experimental.Quantum.Language
9+
10+
from Crypto::OperationNode op, Crypto::HashAlgorithmNode a
11+
where a = op.getAKnownAlgorithm()
12+
select op, "Operation using hashing algorithm $@", a, a.getAlgorithmName()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @name Detects known key derivation algorithms
3+
* @id java/crypto_inventory_slices/known_key_derivation_algorithm
4+
* @kind problem
5+
*/
6+
7+
import java
8+
import experimental.Quantum.Language
9+
10+
from Crypto::KeyDerivationAlgorithmNode alg
11+
select alg, "Known key derivation algorithm " + alg.getAlgorithmName()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @name Detects uses of key derivation operations (operations exlicitly for key derivation only, irrespective of the algorithm used)
3+
* @id java/crypto_inventory_slices/known_key_derivation_operation
4+
* @kind problem
5+
*/
6+
7+
import java
8+
import experimental.Quantum.Language
9+
10+
from Crypto::KeyDerivationOperationNode op
11+
select op, "Known key derivation operation"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @name Detects operations where the algorithm applied is a known key derivation algorithm
3+
* @id java/crypto_inventory_slices/operation_with_known_key_derivation_algorithm
4+
* @kind problem
5+
*/
6+
7+
import java
8+
import experimental.Quantum.Language
9+
10+
from Crypto::OperationNode op, Crypto::KeyDerivationAlgorithmNode a
11+
where a = op.getAKnownAlgorithm()
12+
select op, "Operation using key derivation algorithm $@", a, a.getAlgorithmName()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @name Detects functions that take in crypto configuration parameters but calls are not detected in source.
3+
* @id java/crypto_inventory_slices/likely_crypto_api_function
4+
* @kind problem
5+
*/
6+
7+
import java
8+
import experimental.Quantum.Language
9+
10+
from Callable f, Parameter p, Crypto::OperationNode op
11+
where
12+
op.asElement().(Expr).getEnclosingCallable() = f and
13+
op.getAnAlgorithmOrGenericSource().asElement() = p
14+
select f,
15+
"Likely crypto API function: Operation $@ configured by parameter $@ with no known configuring call",
16+
op, op.toString(), p, p.toString()

0 commit comments

Comments
 (0)