If this policy isn't available and enabled by default in some package containing common policies, do you really expect your average developer to a) even know anything about AppArmor, or b) know how to write an AppArmor policy file without spending a few hours digging through docs, reading examples, and engaging in a bunch of trial and error?
(If your answer is "yes" to either of those questions, I'd suggest you might overestimate what is common knowledge.)
AppArmor has come a long way. It's worth learning about it. They have quite a few builtin profiles that you can take advantage of.
Like, the tone of the comment makes no sense, the hard part isn't on the OP, and OP wasn't saying AppArmor is easy, just the content of their comment is easy (which it is!)
It's like saying flipping a light switch to turn on a light is easy... the having someone fly in complaining that understanding industrial power generation is not easy at all.
It's not, it has subtle gaps in the sandbox which still allow some of the attacks it's supposedly protecting you from.
My point is: how do we know the instructions are actually safe?
If you don't trust it, don't run it... but I don't know how anyone in software development would be unable to function if they've never been able to trust someone else's config file suggestion.
None of this applies to maintaining my development machine. You might want to revisit your gate keeping.
And the little demo script GP wrote seems pretty straight forward to me.
The most common attacks is to mess with thinks you build for release in ways which then allow attacking the consumer.
For example by tweaking package, package lock, or even the source code.
Only the last one is prevented here.
Then there is also the thing that installing (user wide or even global) system utilities with npm is a thing, and wouldn't work with your apparmore profile (all need their own profile)
Similar locally running node programs are an attack vector and your profile allow modifying the `node_modules` of such programs even if they don't use npm...
Also you need root rights for loading profiles which can make having a profile for each project a problem as the dev doesn't necessary has root rights. (E.g. in a company with company managed desktop systems this is the default.)
Don't get me wrong. I'm not saying you shouldn't use apparmore and other sandboxes. I even think it's the future of Linux.
My point is appamore isn't simple and it's one of the most simple solutions out there.
Or in other words we still have quite a way to go.
And it's not just about doing sand-boxing, but also about managing sandboxed programs, e.g. last time I looked the app stores of both snap and flatpack where a horror-house of not-properly maintained packages with security vulnerabilities, as well as doggy potentially malicious "unofficial" packages. Even if you sandbox is perfect you still care about security, e.g. you don't want a openoffic package to send copies of all documents you use somewhere else... and that's if the sandbox if used (... flatpack ... facepalm).
Let me correct it:
It MUST be the future of Linux or Linux will have serious problems.
And you're still giving it plenty of access to any projects under your home dir, or opportunities to modify other npm packages that are being installed, to gain execution outside of sandbox later on.
sudo apparmor_parser -r /etc/apparmor.d/sandbox
edit: For completeness, added step to load the profile.