Can anyone tell me why this is or is not legal from a legal point of view
Because you're an employee subject to terms of employment. Terms of employment state no weapons allowed. Perfectly legal.
Find your employee handbook or manual or whatever HR offers that spells out the rules for employees.
Don't like it, quit.

