It is immoral from almost any point of view to refuse to defend yourself and others from very grave and terrible threats, even as there are limits to the means that can be used in such defense.
Espionage, for the most part, involves finding a person who knows something or has something that you can induce them secretly to give to you. That almost always involves a betrayal of trust.

