> Those companies are breaking the law.
If the position requires a security clearance, they are not breaking the law. Language like this is standard on defense contractor postings that require clearances (this from Lockeed):
> Security Clearance Statement: This position requires a government security clearance, you must be a US Citizen for consideration.
> SpaceX was prosecuted for doing that.
SpaceX was prosecuted for excluding refugees and asylees from export-controlled positions, not cleared positions.