File tree Expand file tree Collapse file tree 2 files changed +28
-28
lines changed
Expand file tree Collapse file tree 2 files changed +28
-28
lines changed Original file line number Diff line number Diff line change 55private import rust
66private import codeql.rust.Concepts
77private import codeql.rust.dataflow.DataFlow
8- private import codeql.rust.dataflow.FlowSource
9- private import codeql.rust.dataflow.FlowSink
10- private import codeql.rust.dataflow.internal.DataFlowImpl
118
129bindingset [ algorithmName]
1310private string simplifyAlgorithmName ( string algorithmName ) {
@@ -58,28 +55,3 @@ class StreamCipherInit extends Cryptography::CryptographicOperation::Range {
5855
5956 override Cryptography:: BlockMode getBlockMode ( ) { result = "" }
6057}
61-
62- /**
63- * An externally modelled operation that hashes data, for example a call to `md5::Md5::digest(data)`.
64- */
65- class ModelledHashOperation extends Cryptography:: CryptographicOperation:: Range {
66- DataFlow:: Node input ;
67- CallExpr call ;
68- string algorithmName ;
69-
70- ModelledHashOperation ( ) {
71- sinkNode ( input , "hasher-input" ) and
72- call = input .( Node:: FlowSummaryNode ) .getSinkElement ( ) .getCall ( ) and
73- call = this .asExpr ( ) .getExpr ( ) and
74- algorithmName =
75- call .getFunction ( ) .( PathExpr ) .getPath ( ) .getQualifier ( ) .getPart ( ) .getNameRef ( ) .getText ( )
76- }
77-
78- override DataFlow:: Node getInitialization ( ) { result = this }
79-
80- override Cryptography:: CryptographicAlgorithm getAlgorithm ( ) { result .matchesName ( algorithmName ) }
81-
82- override DataFlow:: Node getAnInput ( ) { result = input }
83-
84- override Cryptography:: BlockMode getBlockMode ( ) { none ( ) } // (does not apply for hashing)
85- }
Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ import rust
1212private import codeql.rust.Concepts
1313private import codeql.rust.security.SensitiveData
1414private import codeql.rust.dataflow.DataFlow
15+ private import codeql.rust.dataflow.FlowSource
16+ private import codeql.rust.dataflow.FlowSink
17+ private import codeql.rust.dataflow.internal.DataFlowImpl
1518
1619/**
1720 * Provides default sources, sinks and sanitizers for detecting "use of a broken or weak
@@ -169,3 +172,28 @@ module ComputationallyExpensiveHashFunction {
169172 }
170173 }
171174}
175+
176+ /**
177+ * An externally modelled operation that hashes data, for example a call to `md5::Md5::digest(data)`.
178+ */
179+ class ModelledHashOperation extends Cryptography:: CryptographicOperation:: Range {
180+ DataFlow:: Node input ;
181+ CallExpr call ;
182+ string algorithmName ;
183+
184+ ModelledHashOperation ( ) {
185+ sinkNode ( input , "hasher-input" ) and
186+ call = input .( Node:: FlowSummaryNode ) .getSinkElement ( ) .getCall ( ) and
187+ call = this .asExpr ( ) .getExpr ( ) and
188+ algorithmName =
189+ call .getFunction ( ) .( PathExpr ) .getPath ( ) .getQualifier ( ) .getPart ( ) .getNameRef ( ) .getText ( )
190+ }
191+
192+ override DataFlow:: Node getInitialization ( ) { result = this }
193+
194+ override Cryptography:: CryptographicAlgorithm getAlgorithm ( ) { result .matchesName ( algorithmName ) }
195+
196+ override DataFlow:: Node getAnInput ( ) { result = input }
197+
198+ override Cryptography:: BlockMode getBlockMode ( ) { none ( ) } // (does not apply for hashing)
199+ }
You can’t perform that action at this time.
0 commit comments