This question encapsulates the dilemma quite nicely, that even when for the greater good and being opposed by an enemy who would do the same or worse to you and to do nothing ensures your suffering, although a noble aim, causing harm through choice always has a karmic liability. This will be sorted out amongst the mitigating factors but the broad lesson of karma in this kind of analysis points to the need to make things much better than when there is a necessity to indulge in violence as a solution. What this scenario points to is an overarching need for great healing to raise up all involved so that no party would see such activities to be thinkable, let alone something that represents a desirable career and a badge of honor to be a part of. The workings of human government and their politics and the cultural pressures and presumptions and prejudices often conspire through corruption to provide many triggers for conflict and acts of war to take place. This has happened over and over during history and always is a great liability for all involved. No matter how it is logged in the history books, as perhaps a great victory and a turning point that allows many to celebrate, there are always other sides to the story that are unseen and these are the karmic consequences.
One aspect of this struggle is any victory will be short-lived because before you know it there will be a series of events to get another war going and in that context, the prior victory begins to lose its meaning because it did not really lead to long-term peace but only was buying time to enable more war to come about, more suffering, and more death. This is not a catalogue of greatness on display, but a kind of depravity that humans are dragged into. It is all orchestrated to happen by the interlopers, but far too many people are vulnerable to the manipulation of corruption and corrupted thinking to see using force, even in a clever fashion that is subtle and applied with pinpoint precision to take out an opposing secret agent, for example, to hamper the enemy’s ability to gather intelligence and therefore win the day, still involves wrongdoing.
So those who take part are in fact putting their souls at risk and there will be consequences for them and the Law of Karma will demand a repayment. Such individuals who are heroes for their clandestine service may well have a lifetime where they die young or are a victim themselves, causing great loss and great suffering, and this they will have set in motion for themselves through their actions. What this illustrates is the sheer folly of the entire enterprise, and this is why such things need to be truly thought through with a coming together of differing factions to discuss their differences and work out a compromise to avoid combat at all costs—that is yet to happen for any length of time and, unfortunately, too few have the wisdom of this knowledge weighing in on their decisions.