Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 85617c2

Browse files
committed
JS: Port BrokenCryptoAlgorithm
1 parent 395f523 commit 85617c2

3 files changed

Lines changed: 28 additions & 27 deletions

File tree

javascript/ql/lib/semmle/javascript/security/dataflow/BrokenCryptoAlgorithmQuery.qll

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,23 @@ import BrokenCryptoAlgorithmCustomizations::BrokenCryptoAlgorithm
1919
* added either by extending the relevant class, or by subclassing this configuration itself,
2020
* and amending the sources and sinks.
2121
*/
22-
class Configuration extends TaintTracking::Configuration {
22+
module BrokenCryptoAlgorithmConfig implements DataFlow::ConfigSig {
23+
predicate isSource(DataFlow::Node source) { source instanceof Source }
24+
25+
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
26+
27+
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
28+
}
29+
30+
/**
31+
* Taint tracking flow for sensitive information in broken or weak cryptographic algorithms.
32+
*/
33+
module BrokenCryptoAlgorithmFlow = TaintTracking::Global<BrokenCryptoAlgorithmConfig>;
34+
35+
/**
36+
* DEPRECATED. Use the `BrokenCryptoAlgorithmFlow` module instead.
37+
*/
38+
deprecated class Configuration extends TaintTracking::Configuration {
2339
Configuration() { this = "BrokenCryptoAlgorithm" }
2440

2541
override predicate isSource(DataFlow::Node source) { source instanceof Source }

javascript/ql/src/Security/CWE-327/BrokenCryptoAlgorithm.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
import javascript
1515
import semmle.javascript.security.dataflow.BrokenCryptoAlgorithmQuery
1616
import semmle.javascript.security.SensitiveActions
17-
import DataFlow::PathGraph
17+
import BrokenCryptoAlgorithmFlow::PathGraph
1818

19-
from Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink
19+
from BrokenCryptoAlgorithmFlow::PathNode source, BrokenCryptoAlgorithmFlow::PathNode sink
2020
where
21-
cfg.hasFlowPath(source, sink) and
21+
BrokenCryptoAlgorithmFlow::flowPath(source, sink) and
2222
not source.getNode() instanceof CleartextPasswordExpr // flagged by js/insufficient-password-hash
2323
select sink.getNode(), source, sink, "A broken or weak cryptographic algorithm depends on $@.",
2424
source.getNode(), "sensitive data from " + source.getNode().(Source).describe()

javascript/ql/test/query-tests/Security/CWE-327/BrokenCryptoAlgorithm.expected

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,15 @@
1-
nodes
2-
| tst.js:3:5:3:24 | secretText |
3-
| tst.js:3:18:3:24 | trusted |
4-
| tst.js:3:18:3:24 | trusted |
5-
| tst.js:11:17:11:26 | secretText |
6-
| tst.js:11:17:11:26 | secretText |
7-
| tst.js:11:17:11:26 | secretText |
8-
| tst.js:17:17:17:25 | o.trusted |
9-
| tst.js:17:17:17:25 | o.trusted |
10-
| tst.js:17:17:17:25 | o.trusted |
11-
| tst.js:19:17:19:24 | password |
12-
| tst.js:19:17:19:24 | password |
13-
| tst.js:19:17:19:24 | password |
14-
| tst.js:22:21:22:30 | secretText |
15-
| tst.js:22:21:22:30 | secretText |
16-
| tst.js:22:21:22:30 | secretText |
171
edges
182
| tst.js:3:5:3:24 | secretText | tst.js:11:17:11:26 | secretText |
19-
| tst.js:3:5:3:24 | secretText | tst.js:11:17:11:26 | secretText |
20-
| tst.js:3:5:3:24 | secretText | tst.js:22:21:22:30 | secretText |
213
| tst.js:3:5:3:24 | secretText | tst.js:22:21:22:30 | secretText |
224
| tst.js:3:18:3:24 | trusted | tst.js:3:5:3:24 | secretText |
23-
| tst.js:3:18:3:24 | trusted | tst.js:3:5:3:24 | secretText |
24-
| tst.js:11:17:11:26 | secretText | tst.js:11:17:11:26 | secretText |
25-
| tst.js:17:17:17:25 | o.trusted | tst.js:17:17:17:25 | o.trusted |
26-
| tst.js:19:17:19:24 | password | tst.js:19:17:19:24 | password |
27-
| tst.js:22:21:22:30 | secretText | tst.js:22:21:22:30 | secretText |
5+
nodes
6+
| tst.js:3:5:3:24 | secretText | semmle.label | secretText |
7+
| tst.js:3:18:3:24 | trusted | semmle.label | trusted |
8+
| tst.js:11:17:11:26 | secretText | semmle.label | secretText |
9+
| tst.js:17:17:17:25 | o.trusted | semmle.label | o.trusted |
10+
| tst.js:19:17:19:24 | password | semmle.label | password |
11+
| tst.js:22:21:22:30 | secretText | semmle.label | secretText |
12+
subpaths
2813
#select
2914
| tst.js:11:17:11:26 | secretText | tst.js:3:18:3:24 | trusted | tst.js:11:17:11:26 | secretText | A broken or weak cryptographic algorithm depends on $@. | tst.js:3:18:3:24 | trusted | sensitive data from an access to trusted |
3015
| tst.js:11:17:11:26 | secretText | tst.js:11:17:11:26 | secretText | tst.js:11:17:11:26 | secretText | A broken or weak cryptographic algorithm depends on $@. | tst.js:11:17:11:26 | secretText | sensitive data from an access to secretText |

0 commit comments

Comments
 (0)