It's legal. It (was) secret. It helps stop people trying to enslave and kill us. Telling them our tactics helps them win.
The NYT knew it was legal and secret and effective against our enemy. They told anyway. Helping your enemy by informing them of your tactics against them aids them and their cause.
This isn't rocket science.
I'm not supporting the Times here; I'm just responding to calls to punish them for something that was legal.