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

chore: implement OWASP recommendation for package #163

Merged

Conversation

KeesCBakker
Copy link
Collaborator

Last week I had a security incident in which I uploaded something to NPM that should not have been uploaded. Because we had both a .gitignore AND an .npmingore file, the .gitignore was actually ignored. When reviewing the OWASP guidelines, I saw the recommendation that it is better to work with an explicit whitelist, instead of a blacklist (https://cheatsheetseries.owasp.org/cheatsheets/NPM_Security_Cheat_Sheet.html#1-avoid-publishing-secrets-to-the-npm-registry).

I've removed the .npmignore and added the files to the files property of the package.json. This prevents us from leaking information accidentally.

@KeesCBakker
Copy link
Collaborator Author

Another good practice to adopt is making use of the files property in package.json, which works as a whitelist and specifies the array of files to be included in the package that is to be created and installed (while the ignore file functions as a blacklist). The files property and an ignore file can both be used together to determine which files should explicitly be included, as well as excluded, from the package. When using both, the former the files property in package.json takes precedence over the ignore file.

@KeesCBakker
Copy link
Collaborator Author

So this fixes #159 in a better way.

@KeesCBakker
Copy link
Collaborator Author

KeesCBakker commented Aug 11, 2023

Tree is now:

kz@LP545:/mnt/c/projects/hubot-grafana$ tar tf hubot-grafana-4.1.1.tgz | tree --fromfile .
.
└── package
    ├── CONTRIBUTING.md
    ├── LICENSE
    ├── README.md
    ├── index.js
    ├── package.json
    └── src
        └── grafana.js

2 directories, 6 files
kz@LP545:/mnt/c/projects/hubot-grafana$ 

@KeesCBakker
Copy link
Collaborator Author

@stephenyeargin, how does this work? I just merge it and you take care of the version number?

@stephenyeargin
Copy link
Owner

Yep. I have on my TODO list to automate releases with GitHub Actions. Currently it uses a package called release-it which handles semantic versioning, sending it to NPM and creating the changelog.

@KeesCBakker
Copy link
Collaborator Author

Ah cool, maybe we can use the same thing Joey uses here: hubot-friends/hubot-slack#21 (comment)

@KeesCBakker KeesCBakker merged commit 774a08f into stephenyeargin:main Aug 11, 2023
@KeesCBakker KeesCBakker deleted the owasp-recommendation-for-files branch August 11, 2023 17:38
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

2 participants