Commit graph

15 commits

Author SHA1 Message Date
DosX
9863826990 Refactor JS heuristic and improve template parsing
Extracted and de-duplicated the main heuristic logic, making detect() only call main() during heuristic scans. The update reorganizes file-suffix handling and enhances JS content analysis: it skips string literals, properly handles template literals and nested ${...} expressions (using skipNestedTemplate), and distinguishes bytecode vs. plain-text scripts. Detection for minified/compiled code was improved by scanning code segments outside strings with updated regex checks.
2026-05-15 13:33:54 +03:00
DosX
8641f9da43 Lower size threshold for JS heuristic
Change the Binary.getSize() check from >3000 to >0x400 (1024) so the MiniJavaScript heuristic will run on smaller binary/text inputs. This makes the detector cover scripts between ~1KB and the previous 3KB cutoff, improving detection for smaller embedded scripts.
2026-05-15 13:31:26 +03:00
DosX
6aa64aeb04 Fix regex char class in MiniJavaScript heuristic
Escape closing brace and parenthesis inside the regex character class used by the minification heuristic. This corrects the token-matching pattern so punctuation like ";", "}" and ")" are recognized reliably and prevents potential regex parsing issues in db/Binary/__MiniJavaScriptHeuristic_By_DosX.7.sg.
2026-05-15 13:26:36 +03:00
DosX
21782fbd78 Add skipNestedTemplate helper for templates
Introduce skipNestedTemplate(s, i) to robustly skip JavaScript template literals, handling nested ${} expressions, inner string literals, escape sequences, and recursion. Replace the previous ad-hoc template-scanning loop in main with a call to this helper when encountering a nested backtick, simplifying the logic and improving correctness when parsing nested templates in scriptContent during heuristic scans.
2026-05-15 13:26:20 +03:00
DosX
3e1fa4cab4 Enhance JS heuristic parsing and regex fixes
Improve the MiniJavaScript heuristic parsing: skip escaped characters, properly skip string literals inside expressions, and handle nested template literals (tracking ${} depth) to avoid false positives when scanning script content. Also tighten regexes by switching to non-capturing groups and refining the whitespace/token check used to detect minified/compiled code.
2026-05-15 13:16:03 +03:00
DosX
5cce7a286d Add jsx/mjs/cjs extensions to JS heuristic
Recognize .jsx, .mjs, and .cjs as JavaScript file types in the MiniJavaScript heuristic. Adds switch cases for JavaScript XML, Module, and CommonJS Module in db/Binary/__MiniJavaScriptHeuristic_By_DosX.7.sg to improve detection of modern JS file extensions.
2026-05-15 13:00:12 +03:00
DosX
3e15fc3ac5 Add 'sg' file suffix to heuristic detection
Updated the MiniJavaScriptHeuristic to recognize files with the 'sg' suffix, improving detection for Detect It Easy modules.
2025-12-22 22:12:21 +03:00
DosX
bf5194d586 Update regex for minified code detection
Modified the regular expression to improve detection of minified or compiled JavaScript code by allowing for more flexible matching of equality and negation operators.
2025-12-15 19:31:07 +03:00
DosX
4aeb4c4225 Remove debug logging from segment processing loop
Eliminated a debug statement that logged segment formatting information within the main function's segment processing loop.
2025-12-15 19:24:06 +03:00
DosX
313e084a0a Improve JavaScript minification detection logic
Refactored the script to more accurately split code outside of string literals, handling escaped quotes and template literal expressions. The detection now processes code segments outside of strings, improving reliability when identifying minified or compiled JavaScript.
2025-12-15 19:23:51 +03:00
DosX
6ae41f5384 Refactor MiniJavaScriptHeuristic detect function
Changed 'detect' from a constant assignment to a function declaration and replaced string initializations with String() for clarity. These changes improve code readability and maintain consistency in variable initialization.
2025-09-18 13:08:37 +03:00
DosX
84c47bc6cc - 2025-03-23 12:41:20 +03:00
DosX
c898979208 Revert "Update file(s): 2024-10-07"
This reverts commit 120ee256d7.
2024-10-07 11:52:02 +03:00
horsicq
120ee256d7 Update file(s): 2024-10-07 2024-10-07 01:30:53 +02:00
DosX
17d2a19975 Database update 2024-10-04 23:26:26 +03:00