Would that hold up in court if the person were willing to challenge it? That seems a clear cut violation of that person's speech, but I guess anything for "national security".
Think that's an unfair restrictions on speech? Just wait until you hear about this: https://en.wikipedia.org/wiki/Born_secret