Whether or not the student is allowed to obtain external help to improve their solution to a homework problem (it must already be a solution, otherwise it is probably off-topic here) cannot be judged by us. It will vary from university to university and each will have a different way how help must be acknowledged.
Probably in most universities it would be against some regulation to submit that code as their own work afterwards, but we also don't have any control over how the student acknowledges the help (although, legally they would have to do so, abiding by the CC-BY-SA 3.0 license).
And, as mentioned, students can always submit their question in a way that it is not obvious that it is a homework problem. Requiring all homework problems to be tagged as such does not magically make it so.
I think it boils down to the question:
Should we review code that can be used in an unethical/immoral/illegal way?
So the answer is IMO the same as to the question of whether or not we should review code that can be used for nefarious purposes, like password crackers or code the use of which maybe illegal/unethical, like website crawlers. We should assume best faith. In the end it is the OP which either commits or does not commit an unlawful/unethical act with it and unless this is obvious from the question we cannot (as a community) assume that this will be the use case. As an individual you can always refrain from answering if this is against your personal ethical code.
The answer to this question in the most broad sense is up to debate, currently, in issues such as who is responsible for how a robot/driving car/drone acts and should programmers write that code or not? I don't think there is an agreed upon answer. I doubt we can come up with an answer to that question here.