r/programming • u/trustsigRobert • Oct 16 '26
[ Removed by moderator ]
/r/programming/comments/1x7v2i1/removed_by_moderator/[removed] — view removed post
47
u/k3v_d3v Oct 17 '26
slllllllllllllllllllllllllllllllllllllllllllllllllllllloppppppppppppppppppppppppppppppppppppp
30
u/MoTTs_ Oct 17 '26 edited Oct 17 '26
I used prettier and checked a couple of the claimed behavior-changing transformations, and I couldn't repro any of the claims from the article. I briefly debugged into the demo page, and it looks like they "detect" formatted or not by keeping a reference copy of the minified source, and checking if the textarea source matches.EDIT:
After more inspection, I'd like to retract (part) of my comment.
The good:
The changes in behavior are real. For two specific examples, DevTools does change
+ +xto++x, and prettier will format inside a character string if it's a tag function named "css". The textarea source check I mentioned before came up because the debugger stepped into the index page.The bad:
The article and code are written by AI, and I think they both lack clarity. The code could have been human-readable while still triggering formatter behavior changes, but instead it was all minified. And the test functions could have been named, for example, as
testUnaryToIncrementortestCssTagFunction, but instead they're named ast0,t1,t2, ...,t185.The
DBvariable contains long character strings of 0's and 1's that on first glance made me suspect code that was obfuscated as binary text, but this DB variable is the test expected values. It's formatted as a tab-separated character string of 0's and 1's that represent booleans, and if the 23rd character in that string is a "1", for example, then it's expected to trigger on the functiont23. I think that's an obscure relationship, and it's difficult to check which tests correspond to which formatters even when you do know the relationship.22
1
u/ShinzouNingen Oct 17 '26 edited Oct 17 '26
I got mixed results. It worked for me when copying from Firefox's formatter, but I also tried terser and couldn't reproduce the results, even the small example.
I don't think they check by the textarea source, then inserting a comment, changing the "use strict" string to something else, or making a whitespace edit would break immediately break it, and it doesn't.
Edit: it works for me in prettier 3.9.10 too. And it cannot be using the textarea, because I ran it locally in node. Downloaded the script from the page above as foo.js, and tested it like this:
⋊> ~/ ◦ node test.js 09:22:19 This script is clean. ⋊> ~/ ◦ npx prettier test.js | node 09:22:42 You formatted this with Prettier1
u/trustsigRobert Oct 17 '26
Probably a config difference, I did my testing using the repl playground. And setting "module" to false.
Have a go with any other formatter/processor too! As terser is a minfier so it is a bit trickier
1
u/ShinzouNingen Oct 17 '26
I tried with prettier first, but I actually got a JS error on the snake page. If you're curious, the error was
Uncaught SyntaxError: Failed to execute 'append' on 'Element': Invalid or unexpected tokenHowever the example that just output the text (I edited my comment) did work with prettier.
The undeserved downvotes are crazy though. You just got unlucky with the reddit mob mentality coin flip.
1
u/trustsigRobert Oct 17 '26
I'll look into the game demo crash from prettier, thanks.
And for the downvotes, it is reddit after all, nothing out of the ordinary :D I appreciate you helping out though.
2
u/Rustywolf Oct 17 '26
its not even the interesting way to do this; JS literally has behaviour that changes when a newline is added.
-3
u/trustsigRobert Oct 17 '26 edited Oct 17 '26
EDIT: He has since edited his message to correct it, thank you. For the article being "AI" written, that is not true. The code was autogenerated from a library I've built over weeks of the techniques, the minification is very small (and was done to force Chromium DevTools to format always, instead of having just very long comments) and any formatter will undo it (but it will trigger a few divergences). I'll release a follow up in a repo soon with the raw source code to everything.
A) You were not able to repo due to testing a few techniques against the wrong tools. (each technique is more-or-less unique to one tool)
B) There is no source code or reference copy checks, you can run the playground script in node and get the same result.
This script contains every one of the 186 techniques, run it through prettier and the logic does change: https://divergence.trustsig.eu/
(You can paste the script into node or browser console anywhere. It has literally nothing to do with the text area nor does it keep a reference copy. )
You tested a "couple" of the 186 techniques against the wrong tools. A technique for chrome dev tools isn't going to work for prettier, obviously. To test any tool, use the above given playground script.
-2
u/Toireht Oct 17 '26
???? This is literally an insanely novel and unique technique, what makes you think this is slop?
-3
1
u/Mike_Zooka Oct 17 '26
Tried it with every formatter and deobfuscator that I have, surprisingly every single one caused it to print out that it was used. Good writeup and demo!
1
u/Signal_Still6283 Oct 17 '26
will be a fun weekend for all the maintainers to fix all of these bugs lol
•
u/programming-ModTeam Oct 17 '26
This is a demo of a product or project that isn't on-topic for r/programming. r/programming is a technical subreddit and isn't a place to show off your project or to solicit feedback.
If this is an ad for a product, it's simply not welcome here.
If it is a project that you made, the submission must focus on what makes it technically interesting and not simply what the project does or that you are the author. Simply linking to a GitHub repo is not sufficient