Pills are easy to sneak in so long as you aren't dumb about it and stash them somewhere obvious (i.e. your pocket or your shoes).
Security is privately hired by the promoter and they are paid to do certain things, one of which is not to give someone shit just because they look like they're on drugs. If they see you taking them though, that's another story.
If you're going to a massive, chances are you won't run into any cops inside but as long as you're not dealing or consuming out in the open they should leave you alone too. But, then again cops are cops...they aren't being hired by the promoters so if you come across one who is in a bad mood you might be in for a rough time. But like I said before, at an event with tens of thousands of people, your chances of being harassed are pretty slim. Everyone else will be rolling balls too so it's not like you're going to stand out or anything, heh.
At Monster Massive last year, we were driving into the parking lot outside the stadium and my friend and I saw this kid approach and say something to a uniformed cop while he was obviously rolling balls. The cop shoved the kid and started cursing, yelling at and threatening him with arrest. It was horrible to watch

Then again, he was pretty dumb for thinking it would be smart to start talking to a cop at a rave, let alone while rolling.
Then again, at EDC this past summer I saw a couple of scantily clad kandy-wearing hotties laughing and chatting it up with a couple of cops outside the gate. But they had nice tits and were nearly naked, lol.