The federal government is defending its secretive eavesdropping agency in a lawsuit filed by a B.C. civil rights group, insisting any collection of Canadians' communication is unintentional.

The B.C. Civil Liberties Association filed a lawsuit last fall, alleging Canadians' communications were being illegally swept up by the Communications Security Establishment Canada, or CSEC.

The group's lawsuit targeted the spy agency's monitoring of foreign communications, as well as the collection of metadata, which reveals technical information but not the content of electronic communication.

But Ottawa has filed a statement of defence that says CSEC follows strict rules that prevent the agency from specifically targeting Canadians and its activities are monitored by an independent commissioner.

The government says it's impossible to know whether a foreign target may be communicating with someone in Canada, which means a "small" number of communications from Canadians has be collected.

As for the collection of metadata, the statement of defence says it plays a vital role in identifying and thwarting cyber threats.