A Github action to obfuscate javascript code by using the javascript-obfuscator
Obfuscate javascript and node with Github action to secure your code. The Github action uses the javascript-obfuscator.
🏳️ See the inputs section for detailed descriptions.
- name: Create distribution path
run: |
mkdir -p distribution_path
- name: Low obfuscation test
uses: KevinRohn/github-action-javascript-obfuscator@v1
with:
input_path: input_path
output_path: distribution_path
compact: true
control_flow_flattening: false
dead_code_injection: false
debug_protection: false
debug_protection_interval: 0
log: false
disable_console_output: true
rename_globals: false
string_array_rotate: true
self_defending: true
string_array: true
string_array_encoding: 'none'
string_array_threshold: 0.75
unicode_escape_sequence: false
target: nodeNote: For an detailed documentation, please check the full documentation of the javascript-obfuscator
The action supports the following inputs:
-
input_pathInput path of the js file(s)
Can be a single js file or also an directory with js files.
Required: true
-
output_pathOutput path to save the obfuscated file(s).
If you use the same output path as the input path, the postfix
obfuscatedwill be added to the file(s) name. e.g.index-obfuscated.jsRequired: true
-
compactCompact code output on one line.
Type:
booleanDefault:trueRequired: false
-
control_flow_flatteningEnables code control flow flattening. Control flow flattening is a structure transformation of the source code that hinders program comprehension.
Type:
booleanDefault:falseRequired: false
-
control_flow_flattening_thresholdThe probability that the control flow flattening transformation will be applied to the node.
Type:
numberDefault:0.75Min:0Max:1Required: false
-
dead_code_injectionWith this option, random blocks of dead code will be added to the obfuscated code.
Type:
booleanDefault:falseRequired: false
-
dead_code_injection_thresholdAllows to set percentage of nodes that will affected by deadCodeInjection.
Type:
numberDefault:0.4Min:0Max:1Required: false
-
debug_protectionThis option makes it almost impossible to use the debugger function of the Developer Tools (both on WebKit-based and Mozilla Firefox).
Type:
booleanDefault:falseRequired: false
-
debug_protection_intervalIf set, an interval in milliseconds is used to force the debug mode on the Console tab, making it harder to use other features of the Developer Tools. Works if debugProtection is enabled. Recommended value is between
2000and4000milliseconds.Type:
numberDefault:0Required: false
-
disable_console_outputDisables the use of
console.log,console.info,console.error,console.warn,console.debug,console.exceptionandconsole.traceby replacing them with empty functions. This makes the use of the debugger harder.Type:
booleanDefault:falseRequired: false
-
domain_lockAllows to run the obfuscated source code only on specific domains and/or sub-domains. This makes really hard for someone to just copy and paste your source code and run it elsewhere.
Type:
string[]Default:[]Required: false
-
domain_lock_redirect_urlAllows the browser to be redirected to a passed URL if the source code is not run on the domains specified by
domain_lock.Type:
stringDefault:about:blankRequired: false
-
excludeA filename or glob which indicates files to exclude from obfuscation.
Type:
string[]Default:[]Required: false
-
force_transform_stringsEnables force transformation of string literals, which is matched by RegExp patterns (comma separated).
Type:
string[]Default:[]Required: false
-
identifier_names_cache_pathThe existing
.jsonfile that will be used to read and write identifier names cache.If a path to the empty file will be passed - identifier names cache will be written to that file.
Type:
stringDefault: ``Required: false
-
identifier_names_generatorSets identifier names generator.
Type:
stringDefault:hexadecimalAvailable values:
dictionary: identifier names fromidentifiers_dictionarylisthexadecimal: identifier names like_0xabc123mangled: short identifier names likea, b, cmangled-shuffled: same asmangledbut with shuffled alphabet
Required: false
-
identifiers_dictionarySets identifiers dictionary for
identifier_names_generator:dictionaryoption. Each identifier from the dictionary will be used in a few variants with a different casing of each character. Thus, the number of identifiers in the dictionary should depend on the identifiers amount at original source code.Type:
string[]Default:[]Required: false
-
identifiers_prefixSets prefix for all global identifiers.
Type:
stringDefault: ``Required: false
-
ignore_importsPrevents obfuscation of
requireanddynamicimports'.Type:
booleanDefault:falseRequired: false
-
logEnables logging of the information to the console.
Type:
booleanDefault:falseRequired: false
-
numbers_to_expressionsEnables numbers conversion to expressions.
Type:
booleanDefault:falseRequired: false
-
options_presetAllows to set options preset.
Type:
stringDefault:defaultAvailable values:
defaultlow-obfuscationmedium-obfuscationhigh-obfuscation
All addition options will be merged with selected options preset.
Required: false
-
rename_globalsAllows to enable obfuscation of global variable and function names with declaration
Type:
booleanDefault:falseRequired: false
-
rename_properties_modeSpecify
rename_propertiesoption mode.Type:
stringDefault:saveAvailable values:
safeunsafe
Required: false
-
reserved_namesDisables obfuscation and generation of identifiers, which being matched by passed RegExp patterns (comma separated).
Type:
string[]Default:[]Required: false
-
reserved_stringsDisables transformation of string literals, which being matched by passed RegExp patterns.
Type:
string[]Default:[]Required: false
-
seedSets seed for random generator. This is useful for creating repeatable results.
Type:
string|numberDefault:0Required: false
-
self_defendingDisables self-defending for obfuscated code.
Type:
booleanDefault:falseRequired: false
-
simplifyEnables additional code obfuscation through simplification.
Type:
booleanDefault:trueRequired: false
-
source_mapEnables source map generation for obfuscated code.
Type:
booleanDefault:trueSource maps can be useful to help you debug your obfuscated JavaScript source code. If you want or need to debug in production, you can upload the separate source map file to a secret location and then point your browser there.
Required: false
-
source_map_base_urlSets base url to the source map import url when
source_map_mode: separate.Type:
stringDefault: ``Required: false
-
source_map_file_nameSets file name for output source map when
source_map_mode: separate.Type:
stringDefault: ``Required: false
-
source_map_modeSpecify source map output mode.
Type:
stringDefault:separateAvailable values:
inlineseparate
Required: false
-
source_map_sources_modeSpecify source map sources mode.
Type:
stringDefault:sources-contentAvailable values:
sources-contentsources
Required: false
-
split_stringsSplits literal strings into chunks with length of
split_strings_chunk_lengthoption value.Type:
booleanDefault:falseRequired: false
-
split_strings_chunk_lengthSets chunk length of
split_stringsoption.Type:
numberDefault:10Required: false
-
string_arrayEnables gathering of all literal strings into an array and replacing every literal string with an array call.
Type:
booleanDefault:trueRemoves string literals and place them in a special array. For instance, the string
"Hello World"invar m = "Hello World";will be replaced with something likevar m = _0x12c456[0x1];.Required: false
-
string_array_calls_transformEnables the transformation of calls to the
string_array.Type:
booleanDefault:falseAll arguments of these calls may be extracted to a different object depending on
string_array_calls_transform_thresholdvalue. So it makes it even harder to automatically find calls to the string array.Required: false
-
string_array_calls_transform_thresholdThe probability that that calls to the string array will be transformed.
Type:
numberDefault:0.5Required: false
-
string_array_encodingEncodes each string in strings array using
base64orrc4(this option can slow down your code speed).Type:
string[]Default:[]Available values:
nonebase64rc4
Required: false
-
string_array_indexes_typeAllows to control the type of string array call indexes.
Type:
string[]Default:['hexadecimal-number']Each
string_arraycall index will be transformed by the randomly picked type from the passed list. This makes possible to use multiple types.Available values:
hexadecimal-numberhexadecimal-numeric-string
Required: false
-
string_array_index_shiftEnables additional index shift for all string array calls.
Type:
booleanDefault:trueRequired: false
-
string_array_rotateShift the
string_arrayarray by a fixed and random (generated at the code obfuscation) places. This makes it harder to match the order of the removed strings to their original place.Type:
booleanDefault:trueRequired: false
-
string_array_shuffleRandomly shuffles the
string_arrayarray items.Type:
booleanDefault:trueRequired: false
-
string_array_shuffleRandomly shuffles the
string_arrayarray items.Type:
booleanDefault:trueRequired: false
-
string_array_wrappers_countSets the count of wrappers for the
string_arrayinside each root or function scope. The actual count of wrappers inside each scope is limited by a count of literal nodes within this scope.Type:
numberDefault:1Required: false
-
string_array_wrappers_chained_callsEnables the chained calls between
string_arraywrappers.Type:
booleanDefault:trueRequired: false
-
string_array_wrappers_parameters_max_countAllows to control the maximum number of string array wrappers parameters. Default and minimum value is
2. Recommended value between2and5.Type:
numberDefault:2Required: false
-
string_array_wrappers_typeAllows to select a type of the wrappers that are appending by the
string_array_wrappers_countoption.Type:
stringDefault:variableAvailable values:
variablefunction
Required: false
-
string_array_thresholdThe probability that the literal string will be inserted into
string_array.Type:
numberDefault:0.8Min:0Max:1Required: false
-
targetAllows to set target environment for obfuscated code.
Type:
stringDefault:browserAvailable values:
browserbrowser-no-evalnode
Required: false
-
transform_object_keysEnables transformation of object keys.
Type:
booleanDefault:falseRequired: false
-
unicode_escape_sequenceAllows to enable/disable string conversion to unicode escape sequence.
Type:
booleanDefault:falseRequired: false