Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add profile for npm #3866

Merged
merged 11 commits into from
Jan 8, 2021
Merged

Add profile for npm #3866

merged 11 commits into from
Jan 8, 2021

Conversation

aidalgol
Copy link
Contributor

@aidalgol aidalgol commented Jan 3, 2021

No description provided.

Copy link
Collaborator

@rusty-snake rusty-snake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work, some nitpicks to go trough. Furthermore, can we add

  • disable-exec.inc (with exception for ${HOME})
  • whitelist-runuser-common.inc
  • whitelist-var-common.inc
    ?

etc/profile-m-z/npm.profile Outdated Show resolved Hide resolved
etc/profile-m-z/npm.profile Outdated Show resolved Hide resolved
etc/profile-m-z/npm.profile Outdated Show resolved Hide resolved
etc/profile-m-z/npm.profile Outdated Show resolved Hide resolved
etc/profile-m-z/npm.profile Outdated Show resolved Hide resolved
etc/inc/disable-programs.inc Show resolved Hide resolved
aidalgol and others added 6 commits January 4, 2021 14:50
* Remove redundant blacklisting of Wayland.
* Remove unnecessary noblacklist lines for nodejs.
* Replace absolute paths to .inc files with filenames.
* Remove unneeded dbus whitelisting.

Co-authored-by: rusty-snake <[email protected]>
To keep consistent with other profiles, remove the blank line after the header comment.

Co-authored-by: rusty-snake <[email protected]>
So that our addition of npm paths to disable-programs.inc dose not break IDEs,
we need to unblacklist these same paths in allow-common-devel.inc.
Include disable-exec.inc, but allowing ${HOME}.
Copy link
Collaborator

@rusty-snake rusty-snake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitelisting in $HOME is likely too much, rest looks fine.

etc/profile-m-z/npm.profile Outdated Show resolved Hide resolved
whitelist-common breaks npm, and since we don't know where the user's npm
projects will be, leave the whitelist-common include in a comment with a note
about how to enable it for their setup.
Copy link
Collaborator

@glitsj16 glitsj16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, added a few nitpicks.

I have been trying to create a profile for npm (npx & yarn) for a while now. I find it rather hard to have it cover several personal npm use-cases. Would it be possible to show a fully working example here? This is not a critique, sandboxing npm is a very welcome profile. I'm just wondering if it's not going to create a lot of confusion for users when things start to break due to the vast amount of varied implementations out there.

Example of a project that builds fine with a firejailed npm:
- https://github.com/mozilla/web-ext.git

Examples of projects that throw all kinds of obstacles in the firejail sandboxing of npm:
- https://github.com/bitwarden/browser.git
- https://github.com/minbrowser/min.git
- https://github.com/openstyles/stylus.git

@@ -0,0 +1,60 @@
# Firejail profile for npm
# Description: The Node.js Package Manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to add quiet here to avoid making npm's already pretty verbose output even noisier.

noblacklist ${HOME}/.npm
noblacklist ${HOME}/.npmrc

noblacklist ${PATH}/bash
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why only allow these from disable-shell.inc? IMHO it would make more sense to drop these individual paths and remove 'include disable-shell.inc' below.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If just /bin/sh is needed?

Copy link
Contributor Author

@aidalgol aidalgol Jan 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my use of this profile, /bin/sh was insufficient, as some packages seemed to use /bin/bash. The other shells do not seem to be used anywhere near as commonly for build scripts, if ever.

include disable-exec.inc
include disable-passwdmgr.inc
include disable-programs.inc
include disable-shell.inc
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See earlier comment.

@rusty-snake
Copy link
Collaborator

I'm just wondering if it's not going to create a lot of confusion for users when things start to break due to the vast amount of varied implementations out there.

It's not in firecfg.config. So it just breaks if you add it and then you know enough to adapt your workflows. IMHO it's good to provide a strict template which can be relaxed from users as they need.

Co-authored-by: rusty-snake <[email protected]>
@glitsj16
Copy link
Collaborator

glitsj16 commented Jan 7, 2021

It's not in firecfg.config. So it just breaks if you add it and then you know enough to adapt your workflows. IMHO it's good to provide a strict template which can be relaxed from users as they need.

@rusty-snake Agreed.

In my use of this profile, /bin/sh was insufficient, as some packages seemed to use /bin/bash. The other shells do not seem to be used anywhere near as commonly for build scripts, if ever.

@aidalgol That's a fair point.

In the mean time I re-did some intensive testing of this profile and it looks fine. Had something in my globals.local that kept breaking npm so scratch my earlier examples. For the record, I could add tracelog too.

For using it as a whitelist profile though I needed to add our 'regular' mkdir/mkfile/whitelist foo routine. Without those my ${HOME}/.npmrc was not getting respected. So here's a suggestion to incorporate into this npm.profile:

# If you want whitelisting, change ${HOME}/Projects below to your npm projects directory
# and uncomment the lines below.
#mkdir ${HOME}/.npm
#mkfile ${HOME}/.npmrc
#whitelist ${HOME}/.npm
#whitelist ${HOME}/.npmrc
#whitelist ${DOWNLOADS}
#whitelist ${HOME}/Projects
#include whitelist-common.inc

@aidalgol
Copy link
Contributor Author

aidalgol commented Jan 7, 2021

I have been trying to create a profile for npm (npx & yarn) for a while now. I find it rather hard to have it cover several personal npm use-cases. Would it be possible to show a fully working example here? This is not a critique, sandboxing npm is a very welcome profile. I'm just wondering if it's not going to create a lot of confusion for users when things start to break due to the vast amount of varied implementations out there.

I can't provide a working example that would be easy for anyone to try out, but I have used my original profile (before the suggested changes were made) for gatsby projects, a web-extension project, and some miscellaneous frontend stuff.

@glitsj16 glitsj16 merged commit 3203dd2 into netblue30:master Jan 8, 2021
@matu3ba matu3ba mentioned this pull request Oct 7, 2021
kmk3 added a commit to kmk3/firejail that referenced this pull request Mar 29, 2024
To make it consistent with the other include profiles.

See etc/templates/profile.template.

Relates to netblue30#3866 netblue30#5881.
kmk3 added a commit that referenced this pull request Mar 30, 2024
To make it consistent with the other include profiles.

See etc/templates/profile.template.

Relates to #3866 #5881.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants