This is not something to be worried about, certainly with the newer ships. Most ships actually have a high pitched speaker, which when pointed at any oncoming threat would burst their ear-drums. There is also very good protection with onboard security - fully trained for such emergencies - and coastguards. This was certainly the case with Princess cruises.
A Seabourn vessel was attacked off Somalia a while back but frankly if you choose a mainstream cruise company on a standard Med/Baltic/Caribbean route you are at more risk of being attacked by a pilates class.
These large vessels are worth $500m+ so you can safely assume the cruise companies and their insurers ensure adequate protection is in place.
Every cruise passenger is attacked by pirates. You usually find them at the Tours Desk, trying to spin a yarn about their shore excursions at exhorbitant prices when most can be done independently for a fraction of the cost.