diff --git a/packages/evasive-transform/src/transform-comment.js b/packages/evasive-transform/src/transform-comment.js index 87df3ff237..99764b31ed 100644 --- a/packages/evasive-transform/src/transform-comment.js +++ b/packages/evasive-transform/src/transform-comment.js @@ -35,11 +35,11 @@ export function transformComment(node, unmapLoc) { // ...strip extraneous comment whitespace .replace(/^\s+/gm, ' ') // ...replace HTML comments with a defanged version to pass SES restrictions. - .replace(HTML_COMMENT_START_RE, '') + .replace(HTML_COMMENT_START_RE, '') // ...replace import expressions with a defanged version to pass SES restrictions // (featuring homoglyphs for @kriskowal) - .replace(IMPORT_RE, 'im\u{440}ort$2') + .replace(IMPORT_RE, 'IMPORT$2') // ...replace end-of-comment markers .replace(/\*\//g, '*X/'); if (unmapLoc) { diff --git a/packages/evasive-transform/test/snapshots/test-evade-censor.js.md b/packages/evasive-transform/test/snapshots/test-evade-censor.js.md index 7709d4d60b..94af869fa9 100644 --- a/packages/evasive-transform/test/snapshots/test-evade-censor.js.md +++ b/packages/evasive-transform/test/snapshots/test-evade-censor.js.md @@ -8,19 +8,19 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 - '\'use strict\';var node_fs=require(\'node:fs\');/** * @returns {imрort(\'node:fs\').constants.F_OK} */function bambalam(){return node_fs.constants.F_OK;}/** * */function monkey(){return true;}exports.bambalam=bambalam;exports.monkey=monkey;/*# sourceMappingURL=index.cjs.map*/' + '\'use strict\';var node_fs=require(\'node:fs\');/** * @returns {IMPORT(\'node:fs\').constants.F_OK} */function bambalam(){return node_fs.constants.F_OK;}/** * */function monkey(){return true;}exports.bambalam=bambalam;exports.monkey=monkey;/*# sourceMappingURL=index.cjs.map*/' ## evadeCensor() - successful source transform w/ source map > Snapshot 1 - '\'use strict\';var node_fs=require(\'node:fs\');/** * @returns {imрort(\'node:fs\').constants.F_OK} */function bambalam(){return node_fs.constants.F_OK;}/** * */function monkey(){return true;}exports.bambalam=bambalam;exports.monkey=monkey;/*# sourceMappingURL=index.cjs.map*/' + '\'use strict\';var node_fs=require(\'node:fs\');/** * @returns {IMPORT(\'node:fs\').constants.F_OK} */function bambalam(){return node_fs.constants.F_OK;}/** * */function monkey(){return true;}exports.bambalam=bambalam;exports.monkey=monkey;/*# sourceMappingURL=index.cjs.map*/' ## evadeCensor() - successful source transform w/ source map & source URL > Snapshot 1 - '\'use strict\';var node_fs=require(\'node:fs\');/** * @returns {imрort(\'node:fs\').constants.F_OK} */function bambalam(){return node_fs.constants.F_OK;}/** * */function monkey(){return true;}exports.bambalam=bambalam;exports.monkey=monkey;/*# sourceMappingURL=index.cjs.map*/' + '\'use strict\';var node_fs=require(\'node:fs\');/** * @returns {IMPORT(\'node:fs\').constants.F_OK} */function bambalam(){return node_fs.constants.F_OK;}/** * */function monkey(){return true;}exports.bambalam=bambalam;exports.monkey=monkey;/*# sourceMappingURL=index.cjs.map*/' > Snapshot 2 @@ -45,7 +45,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 - '\'use strict\';var node_fs=require(\'node:fs\');/** * @returns {imрort(\'node:fs\').constants.F_OK} */function bambalam(){return node_fs.constants.F_OK;}/** * */function monkey(){return true;}exports.bambalam=bambalam;exports.monkey=monkey;/*# sourceMappingURL=index.cjs.map*/' + '\'use strict\';var node_fs=require(\'node:fs\');/** * @returns {IMPORT(\'node:fs\').constants.F_OK} */function bambalam(){return node_fs.constants.F_OK;}/** * */function monkey(){return true;}exports.bambalam=bambalam;exports.monkey=monkey;/*# sourceMappingURL=index.cjs.map*/' > Snapshot 2 @@ -70,13 +70,13 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 - '\'use strict\';varnode_fs=require(\'node:fs\');/** * @returns {imрort(\'node:fs\').constants.F_OK} */function bambalam(){return node_fs.constants.F_OK;}/** * */function monkey(){return true;}exports.bambalam=bambalam;exports.monkey=monkey;/*# sourceMappingURL=index.cjs.map*/' + '\'use strict\';varnode_fs=require(\'node:fs\');/** * @returns {IMPORT(\'node:fs\').constants.F_OK} */function bambalam(){return node_fs.constants.F_OK;}/** * */function monkey(){return true;}exports.bambalam=bambalam;exports.monkey=monkey;/*# sourceMappingURL=index.cjs.map*/' ## evadeCensor() - successful source transform w/ source map, source URL & unmapping > Snapshot 1 - '\'use strict\';varnode_fs=require(\'node:fs\');/** * @returns {imрort(\'node:fs\').constants.F_OK} */function bambalam(){return node_fs.constants.F_OK;}/** * */function monkey(){return true;}exports.bambalam=bambalam;exports.monkey=monkey;/*# sourceMappingURL=index.cjs.map*/' + '\'use strict\';varnode_fs=require(\'node:fs\');/** * @returns {IMPORT(\'node:fs\').constants.F_OK} */function bambalam(){return node_fs.constants.F_OK;}/** * */function monkey(){return true;}exports.bambalam=bambalam;exports.monkey=monkey;/*# sourceMappingURL=index.cjs.map*/' > Snapshot 2 diff --git a/packages/evasive-transform/test/snapshots/test-evade-censor.js.snap b/packages/evasive-transform/test/snapshots/test-evade-censor.js.snap index bf397da7ea..391945013c 100644 Binary files a/packages/evasive-transform/test/snapshots/test-evade-censor.js.snap and b/packages/evasive-transform/test/snapshots/test-evade-censor.js.snap differ diff --git a/packages/evasive-transform/test/test-transform-comment.js b/packages/evasive-transform/test/test-transform-comment.js index 0e0318ec5c..6a13033836 100644 --- a/packages/evasive-transform/test/test-transform-comment.js +++ b/packages/evasive-transform/test/test-transform-comment.js @@ -24,7 +24,7 @@ test('transformComment() - defang HTML comment', async t => { value: '', }); transformComment(comment); - t.is(comment.value, ''); + t.is(comment.value, ''); }); test('transformComment() - rewrite suspicious import(...)', async t => { @@ -37,9 +37,7 @@ test('transformComment() - rewrite suspicious import(...)', async t => { transformComment(comment); t.regex( comment.value, - new RegExp( - "\\* @type \\{im\u{440}ort\\('c:\\\\My Documents\\\\user\\.js'\\)", - ), + new RegExp("\\* @type \\{IMPORT\\('c:\\\\My Documents\\\\user\\.js'\\)"), ); });