An internal investigation into the actions of the Counter Network Division, part of the Customs and Border Protection federal agency, is under away after it reportedly used government databases to investigate about 20 U.S. journalists during the Trump administration.

Yahoo News first reported on the investigation into the unit and the internal review in December, alleging that under Trump it used databases designed to track terrorists to track the journalists, attempting to discover the source of leaks from within the administration and to vet journalists who could become sources of information for the department.

The review comes at the direction of the Department of Homeland Security's Office of Inspector General "to ensure that the activities in question during the prior administration remain an isolated incident and that proper safeguards are in place to prevent an incident like this from taking place in the future," CBP spokesperson Luis Miranda said Monday.

The Washington Post initially reported on Border Patrol agent Jeffrey Rambo allegedly tracking national security reporter Ali Watkins, with Politico at the time and now with The New York Times. The inspector general found that Rambo and others in the unit used the databases to investigate several other high-profile journalists, including one at The Associated Press.

"This is a flagrant example of a federal agency using its power to examine the contacts of journalists," Associated Press Executive Editor Julie Pace wrote in a December letter. "While the actions detailed in the inspector general's report occurred under a previous administration, the practices were described as routine."

Customs and Border Protection, Investigating Journalists, Trump
The Department of Homeland Security logo is seen at the new ICE Cyber Crimes Center expanded facilities in Fairfax, Virginia on July 22, 2015. A review was launched into a unit under the umbrella of Homeland Security that allegedly used federal databases designed to track terrorists to investigate journalists under former President Donald Trump.Paul J. Richards/AFP via Getty Images

The AP obtained a redacted copy of the inspector general report, which referred possible criminal charges for misusing government databases and lying to investigators to the Justice Department for a Border Patrol agent on temporary assignment with the Counter Network Division and two other Homeland Security employees. Prosecutors declined to prosecute.

It's not publicly known whether Rambo or the other employees were subjected to any internal discipline. Customs did not provide details on the investigation, characterizing it as part of a broader effort by Homeland Security Secretary Alejandro Mayorkas and CBP Commissioner Chris Magnus, who took up the position in December after serving as police chief in Tucson, Arizona, to ensure protection of First Amendment rights.

"We do not condone the investigation of reporters for exercising those rights," Miranda said. "CBP is committed to conducting its law enforcement and national security mission with adherence to the highest standards."

The Customs unit used its vast databases to investigate others as well, including Huffington Post founder Arianna Huffington and AP investigative reporter Martha Mendoza.

Rambo said he conducted CBP record checks on "15 to 20 national security reporters," according to an FBI summary of the questioning that was contained in the inspector general's report.

He said he had investigated Mendoza as part of an effort to "vet" her before trying to establish a relationship with her because of her expertise in writing about forced labor, an area of interest to Customs because it enforces trade laws.

The Associated Press contributed to this report.