A soldier comes to their own assessment then a court martial decides later on if they agree. Just like every other form of action: do what you believe is within bounds, then find out later if the courts agree
The individual. If your boss orders you to do something illegal, it’s up to you to be sceptical and do your research. That’s the only way it can work without converting a part of the population to drones.