The mission description might have said something about the mission possibly being considered illegal in some places....
The scan doesn't always get you wanted, but most of the time. You will usually:
- get a warning that you're entering a restricted area. From this point, a (invisible) timer starts running.
- get a fine for trespassing. Second (shorter) timer starts, you still have time to boost out of the area if you want to avoid further trouble.
- get a bounty for trespassing. Anything in the area with a gun starts shooting at you. Including the 0-3 ships docked or floating around in the area.
In the SRV, this gets a bit hairy. Speed, shields and environment are your allies. I just hope you parked your ship outside the line of fire of the base turrets. So - don't use the SRV. You can scan the datapoints from your ship, if you get close enough. Easy enough to do in a small ship, near impossible in an Anaconda. Just keep in mind (that's what I often forget) that you need to deploy hardpoints in order to get the datalink scanner online.
Getting out is a matter of preference. I like to use a shieldless, heavily armoured and engineered Viper. Pop some chaff while scanning, then boost off at 800 m/s. Usually (if I can avoid hitting the ground), I get away with 2% armour damage. If I can't be bothered to get the Viper transferred to whichever base I'm operating out of this day, I need to use my general purpose Krait. Much slower, no chaff - but tough shields. Tough enough to simply ignore the base defenses until I'm out of range.
Of course you can also pre-emptively shut down (generators) or shoot down the turrets (and, if present, patrolling ships), but that would significantly increase your bounty (and, in the case of ships, burden you with notoriety). I wouldn't recommend it.