Skip to content

Commit 146b372

Browse files
Add default --prepended-code option, bump version.
1 parent 8e3d90c commit 146b372

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

_run.js

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ const path = require("path");
44
const walk = require("walk-sync");
55
const argv = require("./argv.js").run;
66

7+
// Just printing where to find default boilerplate code?
8+
if (argv["prepended-code"] == "show-default") {
9+
const defaultBP = __dirname + "/boilerplate.js"
10+
console.log(defaultBP);
11+
process.exit(0);
12+
}
13+
714
function list_delete(arr, item) {
815
for( var i = 0; i < arr.length; i++){
916

analyze.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,12 @@ if (argv["prepended-code"]) {
786786
var files = []
787787

788788
// get all the files in the directory and sort them alphebetically
789-
if (fs.lstatSync(argv["prepended-code"]).isDirectory()) {
789+
var isDir = false;
790+
try {
791+
isDir = fs.lstatSync(argv["prepended-code"]).isDirectory();
792+
}
793+
catch (e) {}
794+
if (isDir) {
790795

791796
dir_files = fs.readdirSync(argv["prepended-code"]);
792797
for (var i = 0; i < dir_files.length; i++) {
@@ -796,7 +801,15 @@ if (argv["prepended-code"]) {
796801
// make sure we're adding mock code in the right order
797802
files.sort()
798803
} else {
799-
files.push(argv["prepended-code"])
804+
805+
// Use default boilerplate code?
806+
if (argv["prepended-code"] == "default") {
807+
const defaultBP = __dirname + "/boilerplate.js";
808+
files.push(defaultBP);
809+
}
810+
else {
811+
files.push(argv["prepended-code"]);
812+
}
800813
}
801814

802815
for (var i = 0; i < files.length; i++) {

flags.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
{
6666
"name": "prepended-code",
6767
"type": "String",
68-
"description": "Input file or directory containing code that should be prepended to the JS file(s) we're analyzing. If directory is given, prepends contents of all files in the directory in "
68+
"description": "Input file or directory containing code that should be prepended to the JS file(s) we're analyzing. If directory is given, prepends contents of all files in the directory. If 'default' is given use the default boilerplate.js that comes with box-js. if 'show-default' is given just print path of boilerplate.js and exit (useful if you want to copy and modify default boilerplate code)."
6969
},
7070
{
7171
"name": "fake-script-engine",

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "box-js",
3-
"version": "1.9.25",
3+
"version": "1.9.26",
44
"description": "A tool for studying JavaScript malware.",
55
"dependencies": {
66
"acorn": ">=8.8.0",

0 commit comments

Comments
 (0)