**The typical answer has been to liberally coat the firearm in some sort of viscous grease (last generally sold in the Korean War era)***
Vaseline Petroleum Jelly, or equivalent will work just fine.
True - now, get it all off, including your optics/sights.
Vaseline is horrible about ‘attracting’ and holding dust and grit.
Just sayin’
Having said that, Vaseline is a byproduct of extracting oil from the ground, and is essentially just grease with no additives.