It may be legal for them to print classified information, but it should be 100% illegal for them to conceal their sources. We need a law to that effect.
That way, the media could still warn the American public in the event that a real whistleblower showed up with evidence of real crimes, but it would be a huge deterrant to partisan hacks who damage national security just to hurt people who's politics they don't like.
Actually, it's not legal for them to print classified information, at least in some cases. Section 798 of Title 18 of the U.S. Code is the relevant law.