8000 Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/… · sec-js/javascript-obfuscator@75c2a7b · GitHub
[go: up one dir, main page]

Skip to content

Commit 75c2a7b

Browse files
author
sanex3339
committed
1 parent 8ab502e commit 75c2a7b

File tree

9 files changed

+63
-39
lines changed

9 files changed

+63
-39
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Change Log
22

3+
v0.27.4
4+
---
5+
* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/590
6+
37
v0.27.3
48
---
59
* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/593

dist/index.browser.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.cli.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "javascript-obfuscator",
3-
"version": "0.27.3",
3+
"version": "0.27.4",
44
"description": "JavaScript obfuscator",
5< 10000 code>5
"keywords": [
66
"obfuscator",
@@ -51,7 +51,7 @@
5151
"@types/eslint-scope": "3.7.0",
5252
"@types/estraverse": "0.0.6",
5353
"@types/estree": "0.0.44",
54-
"@types/md5": "2.1.33",
54+
"@types/md5": "2.2.0",
5555
"@types/mkdirp": "1.0.0",
5656
"@types/mocha": "7.0.2",
5757
"@types/multimatch": "4.0.0",
@@ -66,7 +66,7 @@
6666
"coveralls": "3.0.11",
6767
"eslint": "6.8.0",
6868
"eslint-plugin-import": "2.20.2",
69-
"eslint-plugin-jsdoc": "22.1.0",
69+
"eslint-plugin-jsdoc": "23.0.0",
7070
"eslint-plugin-no-null": "1.0.2",
7171
"eslint-plugin-prefer-arrow": "1.2.0",
7272
"eslint-plugin-unicorn": "18.0.1",

src/JavaScriptObfuscator.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ export class JavaScriptObfuscator implements IJavaScriptObfuscator {
142142
* @returns {IObfuscatedCode}
143143
*/
144144
public obfuscate (sourceCode: string): IObfuscatedCode {
145+
if (typeof sourceCode !== 'string') {
146+
sourceCode = '';
147+
}
148+
145149
const timeStart: number = Date.now();
146150
this.logger.info(LoggingMessage.Version, Utils.buildVersionMessage(process.env.VERSION, process.env.BUILD_TIMESTAMP));
147151
this.logger.info(LoggingMessage.ObfuscationStarted);

test/fixtures/directory-obfuscation-error/foo-obfuscated.js

Whitespace-only changes.

test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,39 +47,55 @@ describe('JavaScriptObfuscator', () => {
4747
});
4848
});
4949

50-
describe('empty source code', () => {
51-
let obfuscatedCode: string;
50+
describe('Empty or invalid source code', () => {
51+
describe('empty source code', () => {
52+
let obfuscatedCode: string;
5253

53-
beforeEach(() => {
54-
const code: string = readFileAsString(__dirname + '/fixtures/empty-input.js');
54+
beforeEach(() => {
55+
const code: string = readFileAsString(__dirname + '/fixtures/empty-input.js');
5556

56-
obfuscatedCode = JavaScriptObfuscator.obfuscate(
57-
code,
58-
).getObfuscatedCode();
59-
});
57+
obfuscatedCode = JavaScriptObfuscator.obfuscate(
58+
code,
59+
).getObfuscatedCode();
60+
});
6061

61-
it('should return an empty obfuscated code', () => {
62-
assert.isNotOk(obfuscatedCode);
62+
it('should return an empty obfuscated code', () => {
63+
assert.isNotOk(obfuscatedCode);
64+
});
6365
});
64-
});
6566

66-
describe('empty source code with comments', () => {
67-
let obfuscatedCode: string;
67+
describe('empty source code with comments', () => {
68+
let obfuscatedCode: string;
6869

69-
beforeEach(() => {
70-
const code: string = readFileAsString(__dirname + '/fixtures/comments-only.js');
70+
beforeEach(() => {
71+
const code: string = readFileAsString(__dirname + '/fixtures/comments-only.js');
7172

72-
obfuscatedCode = JavaScriptObfuscator.obfuscate(
73-
code,
74-
{
75-
controlFlowFlattening: true,
76-
deadCodeInjection: true
77-
}
78-
).getObfuscatedCode();
73+
obfuscatedCode = JavaScriptObfuscator.obfuscate(
74+
code,
75+
{
76+
controlFlowFlattening: true,
77+
deadCodeInjection: true
78+
}
79+
).getObfuscatedCode();
80+
});
81+
82+
it('should return an empty obfuscated code', () => {
83+
assert.isNotOk(obfuscatedCode);
84+
});
7985
});
8086

81-
it('should return an empty obfuscated code', () => {
82-
assert.isNotOk(obfuscatedCode);
87+
describe('invalid source code type', () => {
88+
let obfuscatedCode: string;
89+
90+
beforeEach(() => {
91+
obfuscatedCode = JavaScriptObfuscator.obfuscate(
92+
1 as unknown as string
93+
).getObfuscatedCode();
94+
});
95+
96+
it('should return an empty obfuscated code', () => {
97+
assert.isNotOk(obfuscatedCode);
98+
});
8399
});
84100
});
85101

yarn.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,10 @@
328328
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.4.tgz#38fd73ddfd9b55abb1e1b2ed578cb55bd7b7d339"
329329
integrity sha512-8+KAKzEvSUdeo+kmqnKrqgeE+LcA0tjYWFY7RPProVYwnqDjukzO+3b6dLD56rYX5TdWejnEOLJYOIeh4CXKuA==
330330

331-
"@types/md5@2.1.33":
332-
version "2.1.33"
333-
resolved "https://registry.yarnpkg.com/@types/md5/-/md5-2.1.33.tgz#8c8dba30df4ad0e92296424f08c4898dd808e8df"
334-
integrity sha512-8+X960EtKLoSblhauxLKy3zzotagjoj3Jt1Tx9oaxUdZEPIBl+mkrUz6PNKpzJgkrKSN9YgkWTA29c0KnLshmA==
331+
"@types/md5@2.2.0":
332+
version "2.2.0"
333+
resolved "https://registry.yarnpkg.com/@types/md5/-/md5-2.2.0.tgz#cd82e16b95973f94bb03dee40c5b6be4a7fb7fb4"
334+
integrity sha512-JN8OVL/wiDlCWTPzplsgMPu0uE9Q6blwp68rYsfk2G8aokRUQ8XD9MEhZwihfAiQvoyE+m31m6i3GFXwYWomKQ==
335335
dependencies:
336336
"@types/node" "*"
337337

@@ -1866,10 +1866,10 @@ eslint-plugin-import@2.20.2:
18661866
read-pkg-up "^2.0.0"
18671867
resolve "^1.12.0"
18681868

1869-
eslint-plugin-jsdoc@22.1.0:
1870-
version "22.1.0"
1871-
resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-22.1.0.tgz#dadfa62653fc0d87f900d810307f5ed07ef6ecd5"
1872-
integrity sha512-54NdbICM7KrxsGUqQsev9aIMqPXyvyBx2218Qcm0TQ16P9CtBI+YY4hayJR6adrxlq4Ej0JLpgfUXWaQVFqmQg==
1869+
eslint-plugin-jsdoc@23.0.0:
1870+
version "23.0.0"
1871+
resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-23.0.0.tgz#f80dca482fc9d93a9e30b3ead70b88dee261caa3"
1872+
integrity sha512-zj5ZephjKkFU/J9hEw3RcjwpuywChvwNMgHs2DTgOuKarpJ65SJU3JGgx/K4y9l8iFw0ysrk6NlAKDX88ZwZdw==
18731873
dependencies:
18741874
comment-parser "^0.7.2"
18751875
debug "^4.1.1"

0 commit comments

Comments
 (0)
0