The NSA database included both "upstream" and "downstream" (better known as PRISM) surveillance of electronic communications collected without a warrant under Section 702 of the Foreign Intelligence Surveillance Act (FISA). In some cases, the database swept up info about American citizens. The FISA court, under U.S. District Judge James Boasberg, found tens of thousands of improper searches by the FBI in 2017 and 2018. For instance, one FBI contractor ran a query to look for information on himself, other FBI personnel and his relatives. The improper searches violated the requirements of the Fourth Amendment.
As The Wall Street Journal points out, US spying activities have "generally withstood legal challenge or review." In 2017, US intelligence agencies pushed to permanently extend Section 702 of the Foreign Intelligence Surveillance Act (FISA) -- the act that allows the federal government to monitor the communications of non-US citizens on foreign soil who are communicating with Americans in the US on matters of national security. In 2018, President Trump authorized another six years of data collection, and according to a NSA transparency report, warrantless searches of Americans' data spiked 28 percent in 2018. According to FISC, the FBI has amended its querying practices, and FISC has deemed them sufficient.