We could just base it off the accepted standardized morality and ethics guidelines, from the official internationally and intergalactically recognized authorities.
It is somewhat amusing that even Asimov's 80-years-old Three Laws of Robotics would've been enough to avoid this.
When I've first read Asimov 20~ years ago, I couldn't imagine I will see machines that speak and act like its robots and computers so quickly, with all the absurdities involved.
at this point that would be like putting a leash on a chair to stop it running away