This is the part of the game where long range scanners finally pay their due, IMO. I install them on all my spaceports - the range is very big, especially with upgrades, and you can see any pirates trying to build cheeky bases nearby and monitor their ships in the area - and build a series of ships designed to suss out pirate stuff.