mirror of
https://github.com/hohn/codeql-javascript-multiflow.git
synced 2025-12-16 12:03:03 +01:00
Add GuardedSafeToWrite test
This commit is contained in:
committed by
=Michael Hohn
parent
01524f7432
commit
d4c477a0ed
32
tests/GuardedSafeToWrite/GuardedSafeToWrite.expected
Normal file
32
tests/GuardedSafeToWrite/GuardedSafeToWrite.expected
Normal file
@@ -0,0 +1,32 @@
|
||||
WARNING: Unused predicate foo (/Users/hohn/local/codeql-javascript-multiflow/solutions/GuardedSafeToWrite.ql:75,11-14)
|
||||
WARNING: Unused predicate foo1 (/Users/hohn/local/codeql-javascript-multiflow/solutions/GuardedSafeToWrite.ql:84,11-15)
|
||||
WARNING: Unused predicate foo2 (/Users/hohn/local/codeql-javascript-multiflow/solutions/GuardedSafeToWrite.ql:93,11-15)
|
||||
nodes
|
||||
| sample-utility-0.js:5:13:5:46 | value |
|
||||
| sample-utility-0.js:5:21:5:46 | this.ge ... value') |
|
||||
| sample-utility-0.js:5:21:5:46 | this.ge ... value') |
|
||||
| sample-utility-0.js:17:34:17:38 | value |
|
||||
| sample-utility-0.js:18:13:18:14 | ua |
|
||||
| sample-utility-0.js:18:13:18:14 | ua |
|
||||
| sample-utility-1.js:2:9:2:42 | value |
|
||||
| sample-utility-1.js:2:17:2:42 | this.ge ... value') |
|
||||
| sample-utility-1.js:2:17:2:42 | this.ge ... value') |
|
||||
| sample-utility-1.js:14:23:14:27 | value |
|
||||
| sample-utility-1.js:15:2:15:3 | ua |
|
||||
| sample-utility-1.js:15:2:15:3 | ua |
|
||||
edges
|
||||
| sample-utility-0.js:5:13:5:46 | value | sample-utility-0.js:17:34:17:38 | value |
|
||||
| sample-utility-0.js:5:21:5:46 | this.ge ... value') | sample-utility-0.js:5:13:5:46 | value |
|
||||
| sample-utility-0.js:5:21:5:46 | this.ge ... value') | sample-utility-0.js:5:13:5:46 | value |
|
||||
| sample-utility-0.js:17:34:17:38 | value | sample-utility-0.js:17:34:17:38 | value |
|
||||
| sample-utility-0.js:17:34:17:38 | value | sample-utility-0.js:18:13:18:14 | ua |
|
||||
| sample-utility-0.js:17:34:17:38 | value | sample-utility-0.js:18:13:18:14 | ua |
|
||||
| sample-utility-1.js:2:9:2:42 | value | sample-utility-1.js:14:23:14:27 | value |
|
||||
| sample-utility-1.js:2:17:2:42 | this.ge ... value') | sample-utility-1.js:2:9:2:42 | value |
|
||||
| sample-utility-1.js:2:17:2:42 | this.ge ... value') | sample-utility-1.js:2:9:2:42 | value |
|
||||
| sample-utility-1.js:14:23:14:27 | value | sample-utility-1.js:14:23:14:27 | value |
|
||||
| sample-utility-1.js:14:23:14:27 | value | sample-utility-1.js:15:2:15:3 | ua |
|
||||
| sample-utility-1.js:14:23:14:27 | value | sample-utility-1.js:15:2:15:3 | ua |
|
||||
#select
|
||||
| sample-utility-0.js:18:13:18:14 | ua | sample-utility-0.js:5:21:5:46 | this.ge ... value') | sample-utility-0.js:18:13:18:14 | ua | Data flow from $@ to $@. | sample-utility-0.js:5:21:5:46 | this.ge ... value') | this.ge ... value') | sample-utility-0.js:18:13:18:14 | ua | ua |
|
||||
| sample-utility-1.js:15:2:15:3 | ua | sample-utility-1.js:2:17:2:42 | this.ge ... value') | sample-utility-1.js:15:2:15:3 | ua | Data flow from $@ to $@. | sample-utility-1.js:2:17:2:42 | this.ge ... value') | this.ge ... value') | sample-utility-1.js:15:2:15:3 | ua | ua |
|
||||
1
tests/GuardedSafeToWrite/GuardedSafeToWrite.qlref
Normal file
1
tests/GuardedSafeToWrite/GuardedSafeToWrite.qlref
Normal file
@@ -0,0 +1 @@
|
||||
GuardedSafeToWrite.ql
|
||||
29
tests/GuardedSafeToWrite/sample-utility-0.js
Normal file
29
tests/GuardedSafeToWrite/sample-utility-0.js
Normal file
@@ -0,0 +1,29 @@
|
||||
var SampleUtility = function(){};
|
||||
SampleUtility.prototype = Object.extendsObject(Processor, {
|
||||
|
||||
setUserStatus: function() {
|
||||
var value = this.getParameter('value');
|
||||
|
||||
var ua = new GR('users');
|
||||
ua.query();
|
||||
|
||||
if(!ua.hasNext()){
|
||||
ua.initialize();
|
||||
ua.setValue('status',value);
|
||||
ua.insert();
|
||||
}
|
||||
else {
|
||||
ua.next();
|
||||
ua.setValue('status',value); // unsafe
|
||||
ua.update();
|
||||
}
|
||||
|
||||
if (ua.safeToWrite()) {
|
||||
ua.setValue('status', value); // safe
|
||||
ua.update();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
type: 'SampleUtility'
|
||||
});
|
||||
17
tests/GuardedSafeToWrite/sample-utility-1.js
Normal file
17
tests/GuardedSafeToWrite/sample-utility-1.js
Normal file
@@ -0,0 +1,17 @@
|
||||
var SampleUtility = function() {
|
||||
var value = this.getParameter('value');
|
||||
|
||||
var ua = new GR('users');
|
||||
ua.query();
|
||||
|
||||
if(!ua.hasNext()){
|
||||
ua.initialize();
|
||||
ua.setValue('status',value);
|
||||
ua.insert();
|
||||
}
|
||||
else {
|
||||
ua.next();
|
||||
ua.setValue('status',value);
|
||||
ua.update();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user