Committing an act of journalism could soon become an imprisonable offence.

New York Times reporter James Risen has been ordered to testify in the criminal trial of former Central Intelligence Agency official Jeffrey Sterling, who has been indicted under the Espionage Act of 1917 – for leaking classified information to Risen for publication in his book, State of War. Last month, the US court of appeals for the fourth circuit in Richmond, Virginia, ruled that Risen could not claim a reporter's privilege under the first amendment to win exemption from being compelled to testify.

In effect, the court has ruled that the journalist must reveal his source. That sets a dangerous precedent now applicable in Maryland and Virginia, home to the NSA and CIA – the very states in which national security journalism matters most. If a reporter cannot guarantee confidentiality to an important source willing to provide information that may be of vital public interest, the job of journalism itself has been criminalised. If a reporter like Risen refuses to co-operate and name names, he himself may face time behind bars.

Indeed, like a dedicated few before him, Risen has vowed to go to prison rather than break his vow of confidentiality in the courtroom. Although there will almost certainly be an appeal, the court's ruling is a potentially devastating blow to investigative journalism. Given its significance, it is shocking how little publicity the Risen/Sterling case has yet received from major media outlets with a direct interest in its outcome.

The Obama administration's war on whistleblowers coupled with the court's ruling against watchdog reporters highlight the federal government's efforts to curb the flow of information from both ends. No one disputes that at times journalists have a duty of care when entrusted with secret information with possible national security implications, but Risen is critical of how government officials will use this argument cynically to delay or suppress a story. He said recently:

I've been an investigative reporter for a long time, and almost always, the government says that ['you can't publish that because of the national security risk'] when you write a story. And then they can never back it up. They say that about everything. And it's like the boy who cried wolf. It's getting old.

Stephen Engelberg, editor-in-chief of the investigative nonprofit news organisation ProPublica, said the fourth circuit's ruling was "extremely unfortunate – given the criminalisation under this government of officials talking to reporters". He stressed the need for a federal version of the "shield law" that already exists in many states and safeguards journalists' right to protect sources.

Even Obama's own chief law officer, Attorney General Eric Holder, recently affirmed that right when he announced new Justice Department guidelines for investigations involving journalists. But Holder himself conceded that his own guidelines would still fall short, and that press freedom needs guarantees from Congress. New York Senator Chuck Schumer and South Carolina Senator Lindsey Graham have introduced a media shield law, but their bill does not provide absolute privilege.

One problem is that it's often hard to mobilize widespread public support for civil liberties issues. In a survey released last month by the First Amendment Center, 80% of those polled agreed that it's important for a democracy to have watchdog reporters, but only 14% named freedom of the press as a key right.

We take too much in our democracy for granted – for journalists cannot successfully hold government accountable in a society that does not recognise a reporter's right to exercise discretion with his sources and the information they provide. This administration has an atrocious record for prosecuting whistleblowers. Can it really get away with jailing the reporters who talk to them, too?