Live data from Hacker News

Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

gkoberger.github.io

11–20 of 86 posts

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#11
post #8
post #7

Earlier quoted context omitted.

That’s more or less what all iframed ads are. Plus most popular web sites load libraries for services where the site owners can’t easily see what’s happening under the covers. Google analytics would be an example of this, but there are many , and lots of sites use multiple such services.

I see what you're saying and I agree for the most part, but all that code is written by someone, reviewed (maybe), and put to some form of a production environment. The code in StackOverflow is usually just typed right into the answer box and submitted. I know I've edited answers where there were compilation errors in the accepted solutions! Not strictly relevant to JS of course.

That's how it should work with ad networks, but you really never know what code you're going to end up serving.

https://www.trendmicro.com/vinfo/vn/security/news/cybercrime...

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#13
post #3

Hilariously awesome. I'm curious whether the multiple warnings about running untrusted code in the browser are necessary. I feel like all websites are already untrusted code, and the browser is quite well sandboxed and protected from anything too bad happening. What is the worst case scenario here for the user within the JS ecosystem, under known avenues of attack, not counting an unknown zero day browser exploit?

I'm sure at the very least some of the sorts are incorrect and will brick your browser tab from an infinite loop or something.

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#15
post #5

It only checks that the output is sorted, not that it's a sorted version of the original string. The first answer that apparently works has a comment stating that it fails with more than 2 duplicates; indeed I tried a list with three 3s and the resulting passing answer only had one of those threes.

So a function that always returns an empty list passes the test?

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#16
post #13
post #3

Hilariously awesome. I'm curious whether the multiple warnings about running untrusted code in the browser are necessary. I feel like all websites are already untrusted code, and the browser is quite well sandboxed and protected from anything too bad happening. What is the worst case scenario here for the user within the JS ecosystem, under known avenues of attack, not counting an unknown zero day browser exploit?

I'm sure at the very least some of the sorts are incorrect and will brick your browser tab from an infinite loop or something.

Thats crazy talk everything on Stack Overflow is correct because it has the most upvotes.

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#17
post #10

Is it just me, or do none of them sort this array correctly? ["zebra","apple","banana","5","bapple","banana","banana"] Correction, the page finally found this algorithm that sorts my array[1]. So I am disappointed with the verifier function on this web page and may need to submit a PR 1 - http://stackoverflow.com/questions/3730510/#3730579

the website doesn't verify the accuracy of sort output. it just gives you the first SO answer that a) has a code snippet b) which is error-free c) and has a function that can be extracted and run ...for your input format, and returns the output of passing your input code into it.

It's true to the xkcd mission, which is just to find SO answers until it returns something, not to actually confirm it was sorted correctly.

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#19
post #16
post #13

Earlier quoted context omitted.

I'm sure at the very least some of the sorts are incorrect and will brick your browser tab from an infinite loop or something.

Thats crazy talk everything on Stack Overflow is correct because it has the most upvotes.

To be fair, I'd imagine the code in SO answers is less likely to be malicious than the code in adverts on most news websites...

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#20
post #10

Is it just me, or do none of them sort this array correctly? ["zebra","apple","banana","5","bapple","banana","banana"] Correction, the page finally found this algorithm that sorts my array[1]. So I am disappointed with the verifier function on this web page and may need to submit a PR 1 - http://stackoverflow.com/questions/3730510/#3730579

That conversation about for..in - any JS experts that can say whether modules or other new advances will help with this? Not being able to use the standard functions on primitives because random other code messes with them sounds like pogo sticking in a minefield.
Post reply on HN