Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
git-npm-helpers
Advanced tools
Commit generated files on release but hide them during development
Helper scripts for maintaining private npm modules without a registry.
npm allows you to add dependencies to modules maintained in git repos. This is a great solution for modules you'd like to use private and when you don't have a private npm registry server available.
This solution is a little problematic when you need to compile your code into a readily usable format, e.g. when you maintain your source in Typescript or ES2017. When you use the npm registry, this is not a problem, because you can always gitignore the compiled files and publish them to the registry.
However, when you maintain the module in a git repo, the compiled files need to maintained in the repo itself. This works but it does make code reviews more difficult, because the compiled files cannot be gitignored and therefore show up in pull requests.
git-npm-helpers
allows you to keep your pull requests clean yet maintain compiled files in the repository
git-npm-helpers
provides the following scripts:
git-hide
: This forces git to ignore changes in a given directory.git-unhide
: This reverses the change and makes changes visible again.Typically, you use the scripts for the directory where your files get compiled to. In the following example, our compiled files end up in a directory called dist
.
.gitignore
dist
package.json
to implement your workflowFor example:
{
"name": "my-private-git-module",
"version": "0.1.1",
"scripts": {
// ...
"preversion": "npm run lint && npm test",
"version": "npm run build && git-unhide dist",
"postversion": "git-hide dist && git push && git push --tags"
// ...
}
}
With this in place, you can release new versions of your module by running the standard npm version <version|level>
command. npm tags versions automatically following the schema v<version>
. For instance, in order to release a new minor version of your module, run:
npm version minor
This create a new build, bump the version, commit the changed files, tag the commit with the new version, and push the result back.
{
"name": "my-private-project",
"dependencies": {
"my-private-git-module": "git://git@mygitserver.com:owner/my-private-git-module.git#v0.2.0"
}
}
## Known issues
- Sometimes, git gets unhappy about the changes in the dist directory when changing branches during development. Since these are throwaway files anyway, simply delete the files and rebuild.
- Git dependencies don't work well when being resolved as part of a Docker build. This repo includes a script that works around this issue by first checking out Git dependencies into local directories and then rewriting the respective dependencies in `package.json` to point to the local directories instead. At the moment, this script is Github-specific.
FAQs
Commit generated files on release but hide them during development
The npm package git-npm-helpers receives a total of 1 weekly downloads. As such, git-npm-helpers popularity was classified as not popular.
We found that git-npm-helpers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.