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

Skip to content

Commit 40d68cb

Browse files
committed
JS: Port CleartextStorage
1 parent b8a6f81 commit 40d68cb

3 files changed

Lines changed: 34 additions & 52 deletions

File tree

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,20 @@ import CleartextStorageCustomizations::CleartextStorage
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 ClearTextStorageConfig 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+
module ClearTextStorageFlow = TaintTracking::Global<ClearTextStorageConfig>;
31+
32+
/**
33+
* DEPRECATED. Use the `ClearTextStorageFlow` module instead.
34+
*/
35+
deprecated class Configuration extends TaintTracking::Configuration {
2336
Configuration() { this = "ClearTextStorage" }
2437

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

javascript/ql/src/Security/CWE-312/CleartextStorage.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
import javascript
1717
import semmle.javascript.security.dataflow.CleartextStorageQuery
18-
import DataFlow::PathGraph
18+
import ClearTextStorageFlow::PathGraph
1919

20-
from Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink
21-
where cfg.hasFlowPath(source, sink)
20+
from ClearTextStorageFlow::PathNode source, ClearTextStorageFlow::PathNode sink
21+
where ClearTextStorageFlow::flowPath(source, sink)
2222
select sink.getNode(), source, sink, "This stores sensitive data returned by $@ as clear text.",
2323
source.getNode(), source.getNode().(Source).describe()

javascript/ql/test/query-tests/Security/CWE-312/CleartextStorage.expected

Lines changed: 17 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,26 @@
1-
nodes
2-
| CleartextStorage2.js:5:7:5:58 | pw |
3-
| CleartextStorage2.js:5:12:5:58 | url.par ... assword |
4-
| CleartextStorage2.js:5:12:5:58 | url.par ... assword |
5-
| CleartextStorage2.js:7:19:7:34 | 'password=' + pw |
6-
| CleartextStorage2.js:7:19:7:34 | 'password=' + pw |
7-
| CleartextStorage2.js:7:33:7:34 | pw |
8-
| CleartextStorage.js:5:7:5:40 | pw |
9-
| CleartextStorage.js:5:12:5:40 | req.par ... sword") |
10-
| CleartextStorage.js:5:12:5:40 | req.par ... sword") |
11-
| CleartextStorage.js:7:26:7:27 | pw |
12-
| CleartextStorage.js:7:26:7:27 | pw |
13-
| tst-angularjs.js:3:32:3:45 | data1.password |
14-
| tst-angularjs.js:3:32:3:45 | data1.password |
15-
| tst-angularjs.js:3:32:3:45 | data1.password |
16-
| tst-angularjs.js:4:33:4:46 | data2.password |
17-
| tst-angularjs.js:4:33:4:46 | data2.password |
18-
| tst-angularjs.js:4:33:4:46 | data2.password |
19-
| tst-angularjs.js:5:27:5:40 | data3.password |
20-
| tst-angularjs.js:5:27:5:40 | data3.password |
21-
| tst-angularjs.js:5:27:5:40 | data3.password |
22-
| tst-angularjs.js:6:33:6:46 | data4.password |
23-
| tst-angularjs.js:6:33:6:46 | data4.password |
24-
| tst-angularjs.js:6:33:6:46 | data4.password |
25-
| tst-webstorage.js:1:18:1:30 | data.password |
26-
| tst-webstorage.js:1:18:1:30 | data.password |
27-
| tst-webstorage.js:1:18:1:30 | data.password |
28-
| tst-webstorage.js:2:27:2:39 | data.password |
29-
| tst-webstorage.js:2:27:2:39 | data.password |
30-
| tst-webstorage.js:2:27:2:39 | data.password |
31-
| tst-webstorage.js:3:20:3:32 | data.password |
32-
| tst-webstorage.js:3:20:3:32 | data.password |
33-
| tst-webstorage.js:3:20:3:32 | data.password |
34-
| tst-webstorage.js:4:29:4:41 | data.password |
35-
| tst-webstorage.js:4:29:4:41 | data.password |
36-
| tst-webstorage.js:4:29:4:41 | data.password |
371
edges
382
| CleartextStorage2.js:5:7:5:58 | pw | CleartextStorage2.js:7:33:7:34 | pw |
393
| CleartextStorage2.js:5:12:5:58 | url.par ... assword | CleartextStorage2.js:5:7:5:58 | pw |
40-
| CleartextStorage2.js:5:12:5:58 | url.par ... assword | CleartextStorage2.js:5:7:5:58 | pw |
41-
| CleartextStorage2.js:7:33:7:34 | pw | CleartextStorage2.js:7:19:7:34 | 'password=' + pw |
424
| CleartextStorage2.js:7:33:7:34 | pw | CleartextStorage2.js:7:19:7:34 | 'password=' + pw |
435
| CleartextStorage.js:5:7:5:40 | pw | CleartextStorage.js:7:26:7:27 | pw |
44-
| CleartextStorage.js:5:7:5:40 | pw | CleartextStorage.js:7:26:7:27 | pw |
45-
| CleartextStorage.js:5:12:5:40 | req.par ... sword") | CleartextStorage.js:5:7:5:40 | pw |
466
| CleartextStorage.js:5:12:5:40 | req.par ... sword") | CleartextStorage.js:5:7:5:40 | pw |
47-
| tst-angularjs.js:3:32:3:45 | data1.password | tst-angularjs.js:3:32:3:45 | data1.password |
48-
| tst-angularjs.js:4:33:4:46 | data2.password | tst-angularjs.js:4:33:4:46 | data2.password |
49-
| tst-angularjs.js:5:27:5:40 | data3.password | tst-angularjs.js:5:27:5:40 | data3.password |
50-
| tst-angularjs.js:6:33:6:46 | data4.password | tst-angularjs.js:6:33:6:46 | data4.password |
51-
| tst-webstorage.js:1:18:1:30 | data.password | tst-webstorage.js:1:18:1:30 | data.password |
52-
| tst-webstorage.js:2:27:2:39 | data.password | tst-webstorage.js:2:27:2:39 | data.password |
53-
| tst-webstorage.js:3:20:3:32 | data.password | tst-webstorage.js:3:20:3:32 | data.password |
54-
| tst-webstorage.js:4:29:4:41 | data.password | tst-webstorage.js:4:29:4:41 | data.password |
7+
nodes
8+
| CleartextStorage2.js:5:7:5:58 | pw | semmle.label | pw |
9+
| CleartextStorage2.js:5:12:5:58 | url.par ... assword | semmle.label | url.par ... assword |
10+
| CleartextStorage2.js:7:19:7:34 | 'password=' + pw | semmle.label | 'password=' + pw |
11+
| CleartextStorage2.js:7:33:7:34 | pw | semmle.label | pw |
12+
| CleartextStorage.js:5:7:5:40 | pw | semmle.label | pw |
13+
| CleartextStorage.js:5:12:5:40 | req.par ... sword") | semmle.label | req.par ... sword") |
14+
| CleartextStorage.js:7:26:7:27 | pw | semmle.label | pw |
15+
| tst-angularjs.js:3:32:3:45 | data1.password | semmle.label | data1.password |
16+
| tst-angularjs.js:4:33:4:46 | data2.password | semmle.label | data2.password |
17+
| tst-angularjs.js:5:27:5:40 | data3.password | semmle.label | data3.password |
18+
| tst-angularjs.js:6:33:6:46 | data4.password | semmle.label | data4.password |
19+
| tst-webstorage.js:1:18:1:30 | data.password | semmle.label | data.password |
20+
| tst-webstorage.js:2:27:2:39 | data.password | semmle.label | data.password |
21+
| tst-webstorage.js:3:20:3:32 | data.password | semmle.label | data.password |
22+
| tst-webstorage.js:4:29:4:41 | data.password | semmle.label | data.password |
23+
subpaths
5524
#select
5625
| CleartextStorage2.js:7:19:7:34 | 'password=' + pw | CleartextStorage2.js:5:12:5:58 | url.par ... assword | CleartextStorage2.js:7:19:7:34 | 'password=' + pw | This stores sensitive data returned by $@ as clear text. | CleartextStorage2.js:5:12:5:58 | url.par ... assword | an access to current_password |
5726
| CleartextStorage.js:7:26:7:27 | pw | CleartextStorage.js:5:12:5:40 | req.par ... sword") | CleartextStorage.js:7:26:7:27 | pw | This stores sensitive data returned by $@ as clear text. | CleartextStorage.js:5:12:5:40 | req.par ... sword") | a call to param |

0 commit comments

Comments
 (0)