mirror of
https://github.com/hohn/codeql-javascript-multiflow.git
synced 2025-12-16 12:03:03 +01:00
WIP: test structure and ultimate source query
This commit is contained in:
committed by
=Michael Hohn
parent
c175614623
commit
563d0e7334
0
tests/UltimateSource/UltimateSource.expected
Normal file
0
tests/UltimateSource/UltimateSource.expected
Normal file
1
tests/UltimateSource/UltimateSource.qlref
Normal file
1
tests/UltimateSource/UltimateSource.qlref
Normal file
@@ -0,0 +1 @@
|
||||
UltimateSource.ql
|
||||
47
tests/UltimateSource/add-user.js
Normal file
47
tests/UltimateSource/add-user.js
Normal file
@@ -0,0 +1,47 @@
|
||||
function get_user_info() {
|
||||
var fs = require("fs");
|
||||
var stdinBuffer = fs.readFileSync(process.stdin.fd);
|
||||
var line = stdinBuffer.toString();
|
||||
console.log(line);
|
||||
line = line.replace(/(\r\n|\n|\r)/gm, "");
|
||||
return line
|
||||
}
|
||||
|
||||
function get_new_id() {
|
||||
return Math.floor(Math.random() * 12345);
|
||||
}
|
||||
|
||||
function connect_db() {
|
||||
const sqlite3 = require('sqlite3').verbose();
|
||||
const db = new sqlite3.Database(
|
||||
'users.sqlite',
|
||||
sqlite3.OPEN_READWRITE | sqlite3.OPEN_FULLMUTEX,
|
||||
err => {
|
||||
if (err){
|
||||
console.log(err);
|
||||
throw err;
|
||||
} else {
|
||||
console.log('DB opened');
|
||||
}
|
||||
});
|
||||
|
||||
return db;
|
||||
}
|
||||
|
||||
function write_info(db, id, info) {
|
||||
db.serialize();
|
||||
const query = `INSERT INTO users VALUES (${id}, "${info}")`;
|
||||
console.log(query);
|
||||
db.exec(query);
|
||||
db.close();
|
||||
}
|
||||
|
||||
let add_user = () => {
|
||||
console.log("Running add-user");
|
||||
var info = get_user_info();
|
||||
var id = get_new_id();
|
||||
var db = connect_db();
|
||||
write_info(db, id, info);
|
||||
}
|
||||
|
||||
add_user()
|
||||
22
tests/codeql-pack.lock.yml
Normal file
22
tests/codeql-pack.lock.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
lockVersion: 1.0.0
|
||||
dependencies:
|
||||
codeql/javascript-all:
|
||||
version: 0.8.3
|
||||
codeql/javascript-queries:
|
||||
version: 0.8.3
|
||||
codeql/mad:
|
||||
version: 0.2.3
|
||||
codeql/regex:
|
||||
version: 0.2.3
|
||||
codeql/suite-helpers:
|
||||
version: 0.7.3
|
||||
codeql/tutorial:
|
||||
version: 0.2.3
|
||||
codeql/typos:
|
||||
version: 0.2.3
|
||||
codeql/util:
|
||||
version: 0.2.3
|
||||
codeql/yaml:
|
||||
version: 0.2.3
|
||||
compiled: false
|
||||
8
tests/qlpack.yml
Normal file
8
tests/qlpack.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
library: false
|
||||
name: codeql-javascript-multiflow-tests
|
||||
version: 0.0.1
|
||||
dependencies:
|
||||
"codeql-javascript-multiflow-solutions" : "*"
|
||||
extractor: javascript
|
||||
|
||||
Reference in New Issue
Block a user