It’s legal because it is NOT shotgun or a rifle, it is just a “firearm”.... per the federal BATFE definition
By definition, to be a shotgun or a rifle, it must be originally designed with a stock, a specific length barrel (smooth or rifled, depending on type). To be a pistol it must have an overall length of less than 26”.
If it never had a “stock” or an appropriate length barrel, then it can’t be a shotgun or a rifle.
If it’s too large (over 26”) to be concealed then it’s not a pistol.
That makes it just a “firearm”.
Some states have more specific definitions of what makes a rifle, shotgun or pistol... California says a shotgun is any firearm chambered to shoot a shotgun shell. That’s above and beyond the federal BATFE definition.