Traps to defend property are very illegal.
Even the popular myth that a fire alarm pull station will stain your hands with ink is based on an actual product. High schools with a string of false alarms will sometimes put a marking compound on the handle that is indelible and changes to a bright color when someone tries to wash it off their hands.
Spraying a thief with fart spray and glitter is not illegal.
The fart spray and glitter bomb, would be interesting to see how it would be interpreted. I wouldn’t want to be the test case for it!