You are 100% correct. Military generals such as General Mattis operate as if the enemy is inside and listening.
General George Washington was no different. In fact, he knew who the spies were and allowed them to operate so that he could feed them false information.
One would hope that they have now identified the leaker by the timing of the attack.