10
10
11
11
import rust
12
12
private import codeql.rust.Concepts
13
+ private import codeql.rust.security.SensitiveData
13
14
private import codeql.rust.dataflow.DataFlow
14
15
15
16
/**
@@ -23,7 +24,7 @@ module NormalHashFunction {
23
24
/**
24
25
* A data flow source for "use of a broken or weak cryptographic hashing algorithm on sensitive
25
26
* data" vulnerabilities that does not require computationally expensive hashing. That is, a
26
- * piece of sensitive data.
27
+ * piece of sensitive data that is not a password .
27
28
*/
28
29
abstract class Source extends DataFlow:: Node {
29
30
Source ( ) { not this instanceof ComputationallyExpensiveHashFunction:: Source }
@@ -52,7 +53,19 @@ module NormalHashFunction {
52
53
*/
53
54
abstract class Barrier extends DataFlow:: Node { }
54
55
55
- // TODO: SensitiveDataSourceAsSource
56
+ /**
57
+ * A flow source modelled by the `SensitiveData` library.
58
+ */
59
+ class SensitiveDataAsSource extends Source instanceof SensitiveData {
60
+ SensitiveDataAsSource ( ) {
61
+ not this .( SensitiveData ) .getClassification ( ) = SensitiveDataClassification:: password ( ) and // (covered in ComputationallyExpensiveHashFunction)
62
+ not this .( SensitiveData ) .getClassification ( ) = SensitiveDataClassification:: id ( ) // (not accurate enough)
63
+ }
64
+
65
+ override SensitiveDataClassification getClassification ( ) {
66
+ result = this .( SensitiveData ) .getClassification ( )
67
+ }
68
+ }
56
69
57
70
/**
58
71
* A flow sink modelled by the `Cryptography` module.
@@ -117,7 +130,18 @@ module ComputationallyExpensiveHashFunction {
117
130
*/
118
131
abstract class Barrier extends DataFlow:: Node { }
119
132
120
- // TODO: PasswordSourceAsSource
133
+ /**
134
+ * A flow source modelled by the `SensitiveData` library.
135
+ */
136
+ class PasswordAsSource extends Source instanceof SensitiveData {
137
+ PasswordAsSource ( ) {
138
+ this .( SensitiveData ) .getClassification ( ) = SensitiveDataClassification:: password ( )
139
+ }
140
+
141
+ override SensitiveDataClassification getClassification ( ) {
142
+ result = this .( SensitiveData ) .getClassification ( )
143
+ }
144
+ }
121
145
122
146
/**
123
147
* A flow sink modelled by the `Cryptography` module.
0 commit comments