Skip to content

Commit

Permalink
Version 1.0.3
Browse files Browse the repository at this point in the history
Fixes code injection vulnerability reported by Synk.io.
No longer uses eval (which is evil anyway).
  • Loading branch information
jhuckaby committed Mar 11, 2020
1 parent cd79906 commit 47677a3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
9 changes: 5 additions & 4 deletions class.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ exports.create = function create(members) {
}
else {
// inherit parent's constructor
var code = members.__parent.toString();
var args = code.substring( code.indexOf("(")+1, code.indexOf(")") );
var inner_code = code.substring( code.indexOf("{")+1, code.lastIndexOf("}") );
eval('constructor = function ('+args+') {'+inner_code+'};');
var parent = members.__parent;
constructor = function() {
var args = Array.prototype.slice.call(arguments);
parent.apply( this, args );
};
}

// inherit rest of parent members
Expand Down
40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"name": "pixl-class",
"version": "1.0.2",
"description": "A simple module for creating classes, with inheritance and mixins.",
"author": "Joseph Huckaby <jhuckaby@gmail.com>",
"homepage": "https://github.com/jhuckaby/pixl-class",
"license": "MIT",
"main": "class.js",
"repository": {
"type": "git",
"url": "https://github.com/jhuckaby/pixl-class"
},
"bugs": {
"url": "https://github.com/jhuckaby/pixl-class/issues"
},
"keywords": [
"oop",
"class"
],
"dependencies": {},
"devDependencies": {}
"name": "pixl-class",
"version": "1.0.3",
"description": "A simple module for creating classes, with inheritance and mixins.",
"author": "Joseph Huckaby <jhuckaby@gmail.com>",
"homepage": "https://github.com/jhuckaby/pixl-class",
"license": "MIT",
"main": "class.js",
"repository": {
"type": "git",
"url": "https://github.com/jhuckaby/pixl-class"
},
"bugs": {
"url": "https://github.com/jhuckaby/pixl-class/issues"
},
"keywords": [
"oop",
"class"
],
"dependencies": {},
"devDependencies": {}
}

0 comments on commit 47677a3

Please sign in to comment.