>>12499525
https://www.history.navy.mil/research/library/online-reading-room/title-list-alphabetically/p/posse-comitatus-act-and-related-matters-a-sketch.html
The Posse Comitatus Act does not apply where Congress has expressly authorized use of the military to execute the law. Congress has done so in three ways, by giving a branch of the armed forces civilian law enforcement authority, by establishing general rules for certain types of assistance, and by addressing individual cases and circumstances with more narrowly crafted legislation. Thus it has vested the Coast Guard, a branch of the armed forces, with broad law enforcement responsibilities. Second, over the years it has passed a fairly extensive array of particularized statutes, like those permitting the President to call out the armed forces in times of insurrection and domestic violence, 10 U.S.C. ยงยง 331-335. Finally, it has enacted general legislation authorizing the armed forces to share information and equipment with civilian law enforcement agencies, 10 U.S.C. ยงยง 371-382.
The legislation contains both explicit grants of authority and restrictions on the use of that authority for military assistance to the police - federal, state and local - particularly in the form of information and equipment, 10 U.S.C. ยงยง 371-382. Section 371 specifically authorizes the armed forces to share information acquired during military operations and in fact encourages the armed forces to plan their activities with an eye to the production of incidental civilian benefits. The section allows the use of military undercover agents and the collection of intelligence concerning civilian activities only where there is a nexus to an underlying military purpose. Under sections 372 through 374, military equipment and facilities may be made available to civilian authorities; members of the armed forces may train civilian police on the operation and maintenance of equipment and may provide them with expert advice; and military personnel may be employed to maintain and operate the equipment supplied.