Spymasters past and present have been busy of late condemning Edward Snowden and the Guardian. The "most catastrophic loss to British intelligence ever" is how Sir David Omand described the whistleblower's leaks of confidential data.

The MI5 chief, Andrew Parker, stopped short of a direct attack on the Guardian for exposing GCHQ's data surveillance programme Tempora, but his speech claimed that publishing such information gives terrorists the ability "to strike at will".

Even some sections of the media have taken the side of the spooks. The Daily Mail said the Guardian had shown a "lethal irresponsibility". Now the police have been asked by Tory MP Julian Smith to investigate the Guardian, while Liam Fox has successfully called on parliament to do the same with the support of the prime minister.

In truth, the Guardian is under attack for carrying out its public duty. It acted courageously, in the public interest, to uncover and reveal a government programme that has gained access to the private communications of millions of individuals. Tempora has been mining our internet communications data, en masse, without public knowledge or any kind of public debate. So the newspaper should be thanked for bringing this to our attention so that we can now have a proper conversation about whether mass surveillance is necessary and proportionate in the fight against terrorism.

Instead of criticising the Guardian, David Cameron should turn his attention to having an open public debate about data surveillance. The first step must be to hold a parliamentary inquiry into Tempora. So it's welcome that the intelligence and security committee has finally agreed to investigate the surveillance programmes of our spy agencies and evaluate whether the existing legal framework for surveillance is fit for purpose.

The public also deserve a proper parliamentary debate. This is why I am calling for one in the House of Commons to assess whether the current legal framework governing surveillance is fit for purpose. The laws we have now were written before this kind of mass internet surveillance was even possible. We need to look seriously at whether they need updating.

The real scandal about operations such as Tempora is that so much remains unknown to parliament and the public. We need to decide whether the law permits mass surveillance of this kind and, if so, then how. We need to know how people living in the UK, including its citizens, are affected. And we need to know whether there is a system of oversight in place to protect against abuse of these sweeping surveillance powers. Sir Malcolm Rifkind, chair of the intelligence and security committee, has rightly said an "informed and proper debate" is needed. And for that we need the facts.

The intelligence and security committee is often accused of being too sympathetic to the security services. Its members are nominated by the prime minister, and much of its work is carried out in secret. Sir Malcolm has announced that in this case the committee will conduct public evidence sessions and accept public submissions. This is a positive sign, but the committee must now stick to its word and prove it is fully capable of strong oversight. The public deserve it.

If you've done nothing wrong, then you've nothing to worry about. Or that's the theory. In practice, surveillance powers are frequently abused. Just ask Doreen Lawrence whose family was perversely spied on after the murder of her son Stephen. And the phone-hacking scandal proved conclusively that, without proper accountability and oversight, people we're supposed to trust will not hesitate to abuse their positions. They even break the law so they can listen in on our conversations.

In the United States, lawmakers are proposing changes that would shut down America's equivalent of Tempora. This may or may not be the right choice, but they are having a public debate. People are being informed. Facts are coming into the open. This is what our lawmakers and media should be doing, not castigating the one newspaper that brought these revelations to light.

Privacy is fundamental. It must be protected. We must always rigorously balance the need to protect national security with our duty to respect privacy. This is a conversation we must have openly, and any measures we ultimately decide to take to tackle terrorism must be clearly in line with the law and subject to proper scrutiny. This is what the Guardian is fighting for, and so should we all.