Add def-use code sample and query

This commit is contained in:
Michael Hohn
2023-11-28 17:04:57 -08:00
committed by =Michael Hohn
parent 60ee4295b2
commit bf9197cb57
7 changed files with 189 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
WARNING: Unused class GR (/Users/hohn/local/codeql-javascript-multiflow/solutions/DefUseSample.ql:53,7-9)
nodes
| sample-utility-0.js:5:6:5:39 | value |
| sample-utility-0.js:5:14:5:39 | this.ge ... value') |
| sample-utility-0.js:5:14:5:39 | this.ge ... value') |
| sample-utility-0.js:17:27:17:31 | value |
| sample-utility-0.js:18:6:18:7 | ua |
| sample-utility-0.js:18:6:18:7 | 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:6:5:39 | value | sample-utility-0.js:17:27:17:31 | value |
| sample-utility-0.js:5:14:5:39 | this.ge ... value') | sample-utility-0.js:5:6:5:39 | value |
| sample-utility-0.js:5:14:5:39 | this.ge ... value') | sample-utility-0.js:5:6:5:39 | value |
| sample-utility-0.js:17:27:17:31 | value | sample-utility-0.js:17:27:17:31 | value |
| sample-utility-0.js:17:27:17:31 | value | sample-utility-0.js:18:6:18:7 | ua |
| sample-utility-0.js:17:27:17:31 | value | sample-utility-0.js:18:6:18:7 | 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:6:18:7 | ua | sample-utility-0.js:5:14:5:39 | this.ge ... value') | sample-utility-0.js:18:6:18:7 | ua | Data flow from $@ to $@. | sample-utility-0.js:5:14:5:39 | this.ge ... value') | this.ge ... value') | sample-utility-0.js:18:6:18:7 | 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 |

View File

@@ -0,0 +1 @@
DefUseSample.ql

View File

@@ -0,0 +1,23 @@
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);
ua.update();
}
},
type: 'SampleUtility'
});

View 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();
}
}