I think there is a problem with the idea that somebody in a remote location can enforce a law or policy on an isolated group of people. I am somewhat amazed that a Russian cosmonaut would sexually attack a Canadian cosmonaut on a simulated space mission that was actually siting on Earth's surface, where supposedly police could intervene quickly. I note that happened on New Year's Eve and I suspect it probably involved vodka. But, I realize the exact same situation could play out on the Moon or Mars much more easily than in such cramped quarters as a Mir space station with other crew members present and no privacy.
Exactly how much of a problem this really is will be hard to determine, considering the politicization of "sexual harassment" issues these days. We see a lot of allegations that seem to be more connected with political character assassination or monetary greed than with actual justice, and that is hard to analytically separate from the actual harassment and assaults. We also have the problem that, in "Western" cultures, women are sexualized for advertising purposes and some individual women choose to flirt with men as a means of getting ahead in their non-sexual endeavors, leading to misunderstandings that can then be alleged to be harassment or assault.
So, at this point, I am thinking it is a real issue with perhaps some embellishment of its severity by those who wish to be employed to study it.
I would hope that missions that are of fixed duration, even long-term ones like trips to Mars, could have crew selected to avoid this type of behavior. But, that could be a challenge if the crew comes from the ranks of fighter aircraft pilots or other macho image career paths.
And, we have to remember that it is not only men who make unwanted and sometime dangerous attempts to initiate sexual activities. Women have attacked women, and women have attacked men. And, men have attacked me, too. So, in this age of accepting 2SLGBTQIA people and working to ensure that they are able to participate in all activities, there will be a lot of competing pressures to include some people whom other people may not be comfortable with.
For long-term missions, I would suggest that the selected crew have at least a 6-month stint of simulated mission isolation on a simulator on Earth, with some serious surveillance by professional psychologists, before launching them.
But, for "colonies" on even the Moon, and certainly Mars, it is really going to be up to those colonists themselves to deal with whatever misconduct occurs. And, that might well include all of the social aspects of initiating pregnancies, child birthing, and raising children to adulthood in a place where no control can be exercised from societies on Earth. We could send them off with a pre-written constitution and laws, but actual enforcement will necessarily be up to the individuals who are actually there. And, after a generation or 2, any colony could well decide to become "independent" if they are, in fact, able to subsist without constant support from Earth. I doubt that could happen on the Moon, but several groups are planning for it on Mars.