I had a rule that any candy collected could not be eaten until I looked at it. Easier said than done when I walked with them when they were smaller. I showed them how to determine safe candy (air in the chocolate packing) so if they opted to ignore my rule they would know what to look for.
When I was small there was the razor blades in apple thing and drug laced candy, most of which was debunked just like the kiddie tattoos that had drugs laced into them. My folks nor I ever let the kids have anything that was homemade or not commercially packaged.
I sorted their candy by what I could identify as commercial wrapping not being compromised. Anything with the tiniest tear tossed. Then I let them pick out what they would not eat and either took it to work or DH took it to work. To pass out candy I only buy stuff that we will eat the left overs.