javascript-obfuscator icon indicating copy to clipboard operation
javascript-obfuscator copied to clipboard

Obfuscation on AngularJS 1.5.10 is causing $injector:modulerr

Open MatthewMollentze opened this issue 5 years ago • 2 comments

Current Behavior

Obfuscating via a grunt task or manually, the Error: $injector:modulerr Module Error is given, without any more context

Steps to Reproduce

  1. Run obfuscator before or after concatenation. Run it manually or via task.
  2. Run with or without babel-plugin-angularjs-annotate.
  3. Lift app and load page...
  4. Output of Error: $injector:modulerr Module Error is reported.

Environment

  • Obfuscator version used: v1.17.3
  • Node version used: v12.22.5
  • AngularJS: v1.5.10
  • SailsJS: v1.4.3

Task Config

module.exports = function (grunt) {
  grunt.config.set('javascript_obfuscator', {

    options: {
      compact: true,
      controlFlowFlattening: false,
      deadCodeInjection: false,
      debugProtection: false,
      debugProtectionInterval: false,
      disableConsoleOutput: false,
      identifierNamesGenerator: 'hexadecimal',
      log: false,
      numbersToExpressions: false,
      renameGlobals: false,
      rotateStringArray: true,
      selfDefending: true,
      shuffleStringArray: true,
      simplify: true,
      splitStrings: false,
      stringArray: true,
      stringArrayEncoding: [],
      stringArrayIndexShift: true,
      stringArrayWrappersCount: 1,
      stringArrayWrappersChainedCalls: true,
      stringArrayWrappersParametersMaxCount: 2,
      stringArrayWrappersType: 'variable',
      stringArrayThreshold: 0.75,
      unicodeEscapeSequence: false,
    },

    dist: {
      src: ['.tmp/public/concat/production.js'],
      dest: '.tmp/public/min/production.min.js',
    },
  })

  grunt.loadNpmTasks('grunt-javascript-obfuscator')
}

MatthewMollentze avatar Aug 25 '21 11:08 MatthewMollentze

Because AngularJS 1.* dependency injection depends on identifier names. If you minify your code, the same error should happen.

sanex3339 avatar Aug 25 '21 11:08 sanex3339

Thank you @sanex3339, however, even with using babel-plugin-angularjs-annotate resolving the implicit annotation issue, the same $injector:modulerr occurs.

MatthewMollentze avatar Aug 25 '21 11:08 MatthewMollentze