Skip to content

Commit 5163ccf

Browse files
author
Esben Sparre Andreasen
committed
JS: split InsufficientPasswordHash.qll
1 parent 8664908 commit 5163ccf

File tree

2 files changed

+62
-46
lines changed

2 files changed

+62
-46
lines changed
Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
11
/**
2-
* Provides a taint tracking configuration for reasoning about password hashing with insufficient computational effort.
2+
* Provides a taint tracking configuration for reasoning about
3+
* password hashing with insufficient computational effort.
4+
*
5+
* Note, for performance reasons: only import this file if
6+
* `InsufficientPasswordHash::Configuration` is needed, otherwise
7+
* `InsufficientPasswordHashCustomizations` should be imported instead.
38
*/
49

510
import javascript
6-
private import semmle.javascript.security.SensitiveActions
7-
private import semmle.javascript.frameworks.CryptoLibraries
811

912
module InsufficientPasswordHash {
10-
/**
11-
* A data flow source for password hashing with insufficient computational effort.
12-
*/
13-
abstract class Source extends DataFlow::Node {
14-
/** Gets a string that describes the type of this data flow source. */
15-
abstract string describe();
16-
}
17-
18-
/**
19-
* A data flow sink for password hashing with insufficient computational effort.
20-
*/
21-
abstract class Sink extends DataFlow::Node { }
22-
23-
/**
24-
* A sanitizer for password hashing with insufficient computational effort.
25-
*/
26-
abstract class Sanitizer extends DataFlow::Node { }
13+
import InsufficientPasswordHashCustomizations::InsufficientPasswordHash
2714

2815
/**
2916
* A taint tracking configuration for password hashing with insufficient computational effort.
@@ -46,30 +33,4 @@ module InsufficientPasswordHash {
4633
node instanceof Sanitizer
4734
}
4835
}
49-
50-
/**
51-
* A potential clear-text password, considered as a source for password hashing
52-
* with insufficient computational effort.
53-
*/
54-
class CleartextPasswordSource extends Source, DataFlow::ValueNode {
55-
override SensitiveExpr astNode;
56-
57-
CleartextPasswordSource() { astNode.getClassification() = SensitiveExpr::password() }
58-
59-
override string describe() { result = astNode.describe() }
60-
}
61-
62-
/**
63-
* An expression used by a cryptographic algorithm that is not suitable for password hashing.
64-
*/
65-
class InsufficientPasswordHashAlgorithm extends Sink {
66-
InsufficientPasswordHashAlgorithm() {
67-
exists(CryptographicOperation application |
68-
application.getAlgorithm().isWeak() or
69-
not application.getAlgorithm() instanceof PasswordHashingAlgorithm
70-
|
71-
this.asExpr() = application.getInput()
72-
)
73-
}
74-
}
7536
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* Provides default sources, sinks and sanitisers for reasoning about
3+
* password hashing with insufficient computational effort, as well as
4+
* extension points for adding your own.
5+
*/
6+
7+
import javascript
8+
private import semmle.javascript.security.SensitiveActions
9+
private import semmle.javascript.frameworks.CryptoLibraries
10+
11+
module InsufficientPasswordHash {
12+
/**
13+
* A data flow source for password hashing with insufficient computational effort.
14+
*/
15+
abstract class Source extends DataFlow::Node {
16+
/** Gets a string that describes the type of this data flow source. */
17+
abstract string describe();
18+
}
19+
20+
/**
21+
* A data flow sink for password hashing with insufficient computational effort.
22+
*/
23+
abstract class Sink extends DataFlow::Node { }
24+
25+
/**
26+
* A sanitizer for password hashing with insufficient computational effort.
27+
*/
28+
abstract class Sanitizer extends DataFlow::Node { }
29+
30+
/**
31+
* A potential clear-text password, considered as a source for password hashing
32+
* with insufficient computational effort.
33+
*/
34+
class CleartextPasswordSource extends Source, DataFlow::ValueNode {
35+
override SensitiveExpr astNode;
36+
37+
CleartextPasswordSource() { astNode.getClassification() = SensitiveExpr::password() }
38+
39+
override string describe() { result = astNode.describe() }
40+
}
41+
42+
/**
43+
* An expression used by a cryptographic algorithm that is not suitable for password hashing.
44+
*/
45+
class InsufficientPasswordHashAlgorithm extends Sink {
46+
InsufficientPasswordHashAlgorithm() {
47+
exists(CryptographicOperation application |
48+
application.getAlgorithm().isWeak() or
49+
not application.getAlgorithm() instanceof PasswordHashingAlgorithm
50+
|
51+
this.asExpr() = application.getInput()
52+
)
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)