It’s not nearly that hard of a problem. There are n gun files on internet, so validate the hash of those n files (g code whatever). These people aren’t cadding their own designs.
Guns can be made out of simple geometric shapes like tubes, blocks, and simple machines like levers and springs. There is mathematically no way to distinguish a gun part from a part used in home plumbing - in fact you can go to the plumbing section of your local hardware store and buy everything you need to build a fully functional shotgun.
The g-code is not being distributed, because it's specific to each printer, filament, etc. G-code is not the same thing as a STP or STL file.
Seems trivial to create an infinite number of inconsequentially (but hash defeating) different variants.
In 3D modeling, there are parametric files where the end user is expected to modify the input parameters to fit their needs. So for example, if you have multiple parts that need to fit together, you may need to adjust the tolerances for that fit, because the physical shape will vary depending on your printer settings and material.
Making tiny modifications isn't just a method of circumvention, it's like part of the main workflow of using a 3d model.
One big part of this is that gcode isnt really a 3d model its a set of instructions on how to move the printhead around. You don't download the gcode directly, because that varies by printer. You download a model, and then a slicing program turns that into a set of printer-specific gcode. Any subtle settings changes would change the hash of this gcode.
And the printer doesn't really know what the model is. It would have to reverse the gcode instructions back into a model somehow. The printer isn't really the place to detect and prevent this sort of thing imo. Especially with how cheap some 3d printers are getting, they often don't really have much compute power in them. They just move things around as instructed by the g-code. If the g-code is malformed it can even break the printer in some instances, or at least really screw up your print.
There are even scripts that modify the gcode to do weird things the printer really isn't designed for, like print something and then have the printer move in such a way to crash into and push the printed object off the plate, and then start over and print another print. The printer will just follow these instructions blindly.