Skip to content

Commit

Permalink
Adds tests
Browse files Browse the repository at this point in the history
  • Loading branch information
filipeom committed Mar 12, 2024
1 parent a6db053 commit c29edc0
Show file tree
Hide file tree
Showing 26 changed files with 369 additions and 250 deletions.
7 changes: 5 additions & 2 deletions test/dune
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
(test
(name instrumentation2))
(cram
(deps
%{bin:instrumentation2}
(source_tree toy)
(source_tree unit)))
152 changes: 0 additions & 152 deletions test/examples/54/normalized.js

This file was deleted.

41 changes: 0 additions & 41 deletions test/examples/54/taint_summary-fixed.json

This file was deleted.

32 changes: 0 additions & 32 deletions test/examples/54/taint_summary.json

This file was deleted.

Empty file removed test/instrumentation2.ml
Empty file.
54 changes: 54 additions & 0 deletions test/test_toy.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Test toy examples:
$ instrumentation2 toy/vfunexported.js toy/vfunexported.json -o -
Genrating -
let exec = require('child_process').exec;

moduke.exports = function f(x) {
return exec(x);
};

let esl_symbolic = require("esl_symbolic");
esl_symbolic.sealProperties(Object.prototype);
// Vuln: command-injection
let x = esl_symbolic.string("x");
module.exports(x);
$ instrumentation2 toy/vfunretbyexport.js toy/vfunretbyexport.json -o -
Genrating -
function f1(a) {
return function f2(b) {
if (b > 0) {
eval(a);
}
};
};

let esl_symbolic = require("esl_symbolic");
esl_symbolic.sealProperties(Object.prototype);
// Vuln: code-injection
let a = esl_symbolic.string("a");
var ret_f1 = f1(a);
let b = esl_symbolic.number("b");
ret_f1(b);
$ instrumentation2 toy/vfunpropofexportedobj.js toy/vfunpropofexportedobj.json -o -
Genrating -
let Obj = (function () {
function Obj(source) { this.source = source; }

Obj.prototype.f = function (obj) {
if (obj.cond > 0) {
eval(this.source);
}
}

return Obj;
})();

module.exports.Obj = Obj;

let esl_symbolic = require("esl_symbolic");
esl_symbolic.sealProperties(Object.prototype);
// Vuln: code-injection
let source = esl_symbolic.string("source");
var ret_module_exports_Obj = module.exports.Obj(source);
let obj = { cond: esl_symbolic.number("cond") };
ret_module_exports_Obj.f(obj);
Loading

0 comments on commit c29edc0

Please sign in to comment.