男性感染支原体有什么症状| hrd什么意思| 圆脸适合什么发型女| 81年的鸡是什么命| 01是什么生肖| 视力模糊是什么原因引起的| 始于初见止于终老是什么意思| 综艺是什么意思| 血沉是什么| 心脏呈逆钟向转位什么意思| 为什么眼睛会肿| peni是什么意思| 肚子胀气吃什么食物| 手上长斑点是什么原因| 甲状腺有什么症状| 彩虹是什么形状| 放风筝是什么季节| 姐姐的儿子叫什么| 鸡眼用什么药| 胆汁反流性胃炎吃什么中成药| 保养是什么意思| kingtis手表什么牌的| 早上八点半是什么时辰| 补充免疫力吃什么好| 简历照片用什么底色| 6月19日是什么日子| 肚子疼用什么药好| 低密度脂蛋白低是什么原因| 结账是什么意思| 子宫前位和子宫后位有什么区别| left什么意思| 什么叫心脏早搏| 野生刺猬吃什么食物| 黄水晶五行属什么| 女性什么时候退休| petct是什么| 唇炎用什么药| hpv疫苗什么时候打最好| 大便粘便池是什么原因| 办护照需要什么| 专政是什么意思| 撸铁是什么| 活塞是什么| 医生规培是什么意思| 霸王花是什么花| 党参不能和什么一起吃| 肌酸有什么用| 不丹为什么不跟中国建交| 双鱼座最配什么星座| 肌酐是什么意思| 农历今天属什么| 症瘕痞块是什么意思| 单纯是什么意思| 为什么会得口腔溃疡| 头疗是什么| 什么的杨桃| 洛阳古代叫什么| 28周检查什么项目| 十三幺是什么意思| 什么叫代孕| 尿葡萄糖阴性什么意思| 过敏性紫癜有什么症状| 什么情况啊这是| 精液是什么颜色的| 冬至有什么禁忌| 发量多的女生适合什么发型| 查血脂挂什么科| 天麻不能和什么一起吃| 实名认证是什么意思| 81年属什么| 1109是什么星座| 什么叫四维空间| 五行缺水戴什么| 相手蟹吃什么| 旅游穿什么鞋最舒服| 下过海是什么意思| 早孕试纸什么时候测最准确| 司空见惯是说司空见惯了什么| 情人节送妈妈什么花| 苜蓿是什么| 供奉是什么意思| 角鲨烯有什么作用| 后厨打荷是干什么的| 老放屁是什么情况| 曹操是什么生肖| 藿香正气水什么牌子的好| 两弹一星指什么| 为什么有钱人不去植发| 夜游神是什么意思| 妊娠试验阴性是什么意思| 39岁属什么| 一物降一物指什么生肖| 干咳喝什么止咳糖浆好| 竖中指是什么意思| 元五行属性是什么| 家里蟑螂多是什么原因| 扒皮鱼是什么鱼| 血压高有什么好办法| 葵水是什么| 闪光感是什么感觉| 腮腺炎挂什么科| 2026年是什么生肖年| 庚子是什么时辰| 阑尾炎吃什么| 95属什么生肖| 养肝护肝吃什么药| ABB式的词语有什么| 路由器什么牌子好| 社保跟医保有什么区别| 阴虚阳亢吃什么中成药| 感染幽门螺旋杆菌吃什么药| 脚趾抽筋是什么原因引起的| mon什么意思| 什么样的西瓜甜| 牙齿松动是什么原因引起的| 脸上长闭口是什么原因导致的| 金水宝胶囊有什么作用| 为什么午觉睡醒后头疼| 老是想睡觉是什么原因| 血糖偏低是什么原因引起的| 瘦肉炒什么好吃| hpv病毒是什么| 万能血型是什么血型| 代谢什么意思| 梦见栽花是什么意思| 肚脐周围疼痛是什么原因| magnesium是什么意思| 胃上面是什么器官| 奕字属于五行属什么| 这是什么字| 荷兰的国花是什么花| 皮肤一块白一块白的是什么原因| 处暑是什么季节| 跟腱断裂是什么感觉| 百合是什么| 牛皮糖是什么意思| 三星堆遗址在什么地方| 低血压高什么原因| 隆科多为什么不姓佟| 梦游的人为什么不能叫醒| 什么是耳石症| 荨麻疹可以吃什么水果| 藏红花有什么作用和功效| 中空是什么意思| 斑鱼是什么鱼| 把你的心我的心串一串是什么歌| 小苏打有什么作用| super是什么意思| 人体缺钾是什么症状| 九月二十四号是什么星座| 唐僧成了什么佛| tsh代表什么| 心脏不舒服吃什么药| 站军姿有什么好处| 郭靖属什么生肖| 肝火旺吃什么药好| ed是什么病| 眼角发白是什么原因| rush什么意思| 梦见洗手是什么意思| 脚脖子抽筋是什么原因| 鲱鱼罐头为什么这么臭| 鸡蛋价格为什么这么低| 巨蟹和什么星座最配对| 局灶肠化是什么意思| 排骨汤里放什么食材好| 39属什么| 过敏性鼻炎吃什么食物好| TOYOTA是什么车| 遍体鳞伤是什么意思| 胃胀吃什么药最有效| 胃病吃什么水果好| 文王卦是什么意思| 三问表是什么意思| 感染科主要看什么病| 5月30号是什么星座| 桑蚕丝是什么面料| 骨折和断了有什么区别| 酸儿辣女什么意思| 什么是天干地支| 邓绥和阴丽华什么关系| 发什么发什么| 什么的勇气| 小孩啃指甲是什么原因| 九月四号是什么星座的| 淡竹叶有什么功效| 6月份种什么菜| 新农合是什么| 腱鞘炎吃什么药好| 六月五日是什么日子| 鼻窦炎吃什么药好得快| 腱鞘囊肿是什么原因| 多吃黄瓜有什么好处| 什么茶提神| 孕妇晚上饿了吃什么好| 福利院是干什么的| 凝是什么意思| 血尿是什么原因引起的男性| 串串是什么意思| 冬至为什么吃水饺| 猫咪都需要打什么疫苗| 心动过速吃什么药最好| 血压高有什么危害| 胬肉是什么| 一叶知秋下一句是什么| 杵状指常见于什么病| 甲亢和甲状腺有什么区别| 400年前是什么朝代| 大腿正面是什么经络| 发什么什么大| 血小板低吃什么好补| 金不换是什么| 癸丑五行属什么| 糖尿病吃什么| 手指头抽筋是什么原因| 胃病看什么科室| 什么什么美景| 琼瑶什么意思| mg什么单位| 玉米属于什么类食物| 媾是什么意思| 命好的人都有什么特征| 堪舆是什么意思| 什么小吃最火爆最赚钱| 扁食是什么| 孕酮低跟什么有关系| 12月10号是什么星座| 双字五行属什么| 查怀孕挂什么科| 无下限是什么意思| 月经推迟是什么原因| 口腔医学技术是干什么的| 夏天有什么植物| 胎儿双顶径偏大是什么原因| 79是什么意思| 反流性咽喉炎吃什么药| 疑似是什么意思| 减震器坏了有什么症状| 甲磺酸倍他司汀片治什么病| 爱慕是什么意思| 病原体是什么意思| 桃子又什么又什么填空| 女性下面长什么样| 非萎缩性胃炎是什么意思| 韭菜什么时候种最合适| 未扪及是什么意思| 怀孕两个月出血是什么原因| 什么可以补肾壮阳| 西洋参和花旗参有什么区别| 宫颈炎吃什么药好得快| 黯淡是什么意思| 手上十个簸箕代表什么| ear是什么意思| 作壁上观什么意思| 细菌性阴道炎用什么洗液| 麦子什么时候收割| 85年属什么生肖| 尚可什么意思| 黛力新是什么药| 蜜蜂是什么生肖| 大学什么时候开始收费| 吹空调感冒了吃什么药| 糖尿病是什么症状| 什么草药能治肿瘤| 百度
Skip to content

河北省新闻出版广电局公共服务事项清单(2016版)

百度 但古村落的抢救和保护进度,远赶不上古村落逐渐消失的速度。

In the following npm cheatsheet, we’re going to focus on 10 npm security best practices and productivity tips, useful for JavaScript and Node.js developers.

1) Avoid publishing secrets to the npm registry

Whether you’re making use of API keys, passwords or other secrets, they can very easily end up leaking into source control or even a published package on the public npm registry. You may have secrets in your working directory in designated files such as a .env which should be added to a .gitignore to avoid committing it to a SCM, but what happens when you publish an npm package from the project’s directory?

The npm CLI packs up a project into a tar archive (tarball) in order to push it to the registry. The following criteria determine which files and directories are added to the tarball:

  • If there is either a .gitignore or a .npmignore file, the contents of the file are used as an ignore pattern when preparing the package for publication.
  • If both ignore files exist, everything not located in .npmignore is published to the registry. This condition is a common source of confusion and is a problem that can lead to leaking secrets.

Developers may end up updating the .gitignore file, but forget to update .npmignore as well, which can lead to a potentially sensitive file not being pushed to source control, but still being included in the npm package.

Another good practice to adopt is making use of the files property in package.json, which works as an allowlist 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 denylist). 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.

When a package is published, the npm CLI will verbosely display the archive being created. To be extra careful, add a --dry-run command-line argument to your publish command in order to first review how the tarball is created without actually publishing it to the registry.

In January 2019, npm shared on their blog that they added a mechanism that automatically revokes a token if they detect that one has been published with a package.

2) Enforce the lockfile

We embraced the birth of package lockfiles with open arms, which introduced: deterministic installations across different environments, and enforced dependency expectations across team collaboration. Life is good! Or so I thought… what would have happened had I slipped a change into the project’s package.json file but had forgotten to commit the lockfile alongside of it?

Both Yarn, and npm act the same during dependency installation . When they detect an inconsistency between the project’s package.json and the lockfile, they compensate for such change based on the package.json manifest by installing different versions than those that were recorded in the lockfile.

This kind of situation can be hazardous for build and production environments as they could pull in unintended package versions and render the entire benefit of a lockfile futile.

Luckily, there is a way to tell both Yarn and npm to adhere to a specified set of dependencies and their versions by referencing them from the lockfile. Any inconsistency will abort the installation. The command-line should read as follows:

  • If you’re using Yarn, run yarn install --frozen-lockfile.
  • If you’re using npm run npm ci.

3) Minimize attack surfaces by ignoring run-scripts

The npm CLI works with package run-scripts. If you’ve ever run npm start or npm test then you’ve used package run-scripts too. The npm CLI builds on scripts that a package can declare, and allows packages to define scripts to run at specific entry points during the package’s installation in a project. For example, some of these script hook entries may be postinstall scripts that a package that is being installed will execute in order to perform housekeeping chores.

With this capability, bad actors may create or alter packages to perform malicious acts by running any arbitrary command when their package is installed. A couple of cases where we’ve seen this already happening is the popular eslint-scope incident that harvested npm tokens, and the crossenv incident, along with 36 other packages that abused a typosquatting attack on the npm registry.

Apply these npm security best practices in order to minimize the malicious module attack surface:

  • Always vet and perform due-diligence on third-party modules that you install in order to confirm their health and credibility.
  • Hold-off on upgrading immediately to new versions; allow new package versions some time to circulate before trying them out.
  • Before upgrading, make sure to review changelog and release notes for the upgraded version.
  • When installing packages make sure to add the --ignore-scripts suffix to disable the execution of any scripts by third-party packages.
  • Consider adding ignore-scripts to your .npmrc project file, or to your global npm configuration.

4) Assess npm project health

npm outdated command

Rushing to constantly upgrade dependencies to their latest releases is not necessarily a good practice if it is done without reviewing release notes, the code changes, and generally testing new upgrades in a comprehensive manner. With that said, staying out of date and not upgrading at all, or after a long time, is a source for trouble as well.

The npm CLI can provide information about the freshness of dependencies you use with regards to their semantic versioning offset. By running npm outdated, you can see which packages are out of date. Dependencies in yellow correspond to the semantic versioning as specified in the package.json manifest, and dependencies colored in red mean that there’s an update available. Furthermore, the output also shows the latest version for each dependency.

npm doctor command

Between the variety of Node.js package managers, and different versions of Node.js you may have installed in your path, how do you verify a healthy npm installation and working environment? Whether you’re working with the npm CLI in a development environment or within a CI, it is important to assess that everything is working as expected.

Call the doctor! The npm CLI incorporates a health assessment tool to diagnose your environment for a well-working npm interaction. Run npm doctor to review your npm setup:

  • Check the official npm registry is reachable, and display the currently configured registry.
  • Check that Git is available.
  • Review installed npm and Node.js versions.
  • Run permission checks on the various folders such as the local and global node_modules, and on the folder used for package cache.
  • Check the local npm module cache for checksum correctness.

5) Audit for vulnerabilities in open source dependencies

The npm ecosystem is the single largest repository of application libraries amongst all the other language ecosystems. The registry and the libraries in it are at the core for JavaScript developers as they are able to leverage work that others have already built and incorporate it into their codebase. With that said, the increasing adoption of open source libraries in applications brings with it an increased risk of introducing security vulnerabilities.

Many popular npm packages have been found to be vulnerable and may carry a significant risk without proper security auditing of your project’s dependencies. Some examples are npm request, superagent, mongoose, and even security-related packages like jsonwebtoken, and validator.

Security doesn’t end by just scanning for security vulnerabilities when installing a package but should also be streamlined with developer workflows to be effectively adopted throughout the entire lifecycle of software development, and monitored continuously when code is deployed:

  • Scan for security vulnerabilities in third-party open source projects
  • Monitor snapshots of your project's manifests so you can receive alerts when new CVEs impact them

6) Use a local npm proxy

The npm registry is the biggest collection of packages that is available for all JavaScript developers and is also the home of the most of the Open Source projects for web developers. But sometimes you might have different needs in terms of security, deployments or performance. When this is true, npm allows you to switch to a different registry:

When you run npm install, it automatically starts a communication with the main registry to resolve all your dependencies; if you wish to use a different registry, that too is pretty straightforward:

  • Set npm set registry to set up a default registry.
  • Use the argument --registry for one single registry.

Verdaccio is a simple lightweight zero-config-required private registry and installing it is as simple as follows: $ npm install --global verdaccio.

Hosting your own registry was never so easy! Let’s check the most important features of this tool:

  • It supports the npm registry format including private package features, scope support, package access control and authenticated users in the web interface.
  • It provides capabilities to hook remote registries and the power to route each dependency to different registries and caching tarballs. To reduce duplicate downloads and save bandwidth in your local development and CI servers, you should proxy all dependencies.
  • As an authentication provider by default, it uses an htpasswd security, but also supports Gitlab, Bitbucket, LDAP. You can also use your own.
  • It’s easy to scale using a different storage provider.
  • If your project is based in Docker, using the official image is the best choice.
  • It enables really fast bootstrap for testing environments, and is handy for testing big mono-repos projects.

7) Responsibly disclose security vulnerabilities

When security vulnerabilities are found, they pose a potentially serious threat if they are publicised without prior warning or appropriate remedial action for users who cannot protect themselves.

It is recommended that security researchers follow a responsible disclosure program, which is a set of processes and guidelines that aims to connect the researchers with the vendor or maintainer of the vulnerable asset, in order to convey the vulnerability, it’s impact and applicability. Once the vulnerability is correctly triaged, the vendor and researcher coordinate a fix and a publication date for the vulnerability in an effort to provide an upgrade-path or remediation for affected users before the security issue is made public.

8) Enable 2FA

In October 2017, npm officially announced support for two-factor authentication (2FA) for developers using the npm registry to host their closed and open source packages.

Even though 2FA has been supported on the npm registry for a while now, it seems to be slowly adopted with one example being the eslint-scope incident in mid-2018 when a stolen developer account on the ESLint team lead to a malicious version of eslint-scope being published by bad actors.

Enabling 2FA is an easy and significant win for an npm security best practices. The registry supports two modes for enabling 2FA in a user’s account:

  • Authorization-only—when a user logs in to npm via the website or the CLI, or performs other sets of actions such as changing profile information.
  • Authorization and write-mode—profile and log-in actions, as well as write actions such as managing tokens and packages, and minor support for team and package visibility information.

Equip yourself with an authentication application, such as Google Authentication, which you can install on a mobile device, and you’re ready to get started. One easy way to get started with the 2FA extended protection for your account is through npm’s user interface, which allows enabling it very easily. If you’re a command-line person, it’s also easy to enable 2FA when using a supported npm client version (>=5.5.1):

npm profile enable-2fa auth-and-writes

Follow the command-line instructions to enable 2FA, and to save emergency authentication codes. If you wish to enable 2FA mode for login and profile changes only, you may replace the auth-and-writes with auth-only in the code as it appears above.

9) Use npm author tokens

Every time you log in with the npm CLI, a token is generated for your user and authenticates you to the npm registry. Tokens make it easy to perform npm registry-related actions during CI and automated procedures, such as accessing private modules on the registry or publishing new versions from a build step.

Tokens can be managed through the npm registry website, as well as using the npm command-line client. An example of using the CLI to create a read-only token that is restricted to a specific IPv4 address range is as follows:

npm token create --read-only --cidr=192.0.2.0/24

To verify which tokens are created for your user or to revoke tokens in cases of emergency, you can use npm token list or npm token revoke respectively.

Ensure you are following this npm security best practice by protecting and minimizing the exposure of your npm tokens.

10) Understand module naming conventions and typosquatting attacks

Naming a module is the first thing you might do when creating a package, but before defining a final name, npm defines some rules that a package name must follow:

  • It is limited to 214 characters
  • It cannot start with dot or underscore
  • No uppercase letters in the name
  • No trailing spaces
  • Only lowercase
  • Some special characters are not allowed: “~\’!()*”)’
  • Can’t start with . or _
  • Can’t use node_modules or favicon.ico due are banned
  • Even if you follow these rules, be aware that npm uses a spam detection mechanism when publishing new packages, based on score and whether a package name violates the terms of the service. If conditions are violated, the registry might deny the request.

Typosquatting is an attack that relies on mistakes made by users, such as typos. With typosquatting, bad actors could publish malicious modules to the npm registry with names that look much like existing popular modules.

We have been tracking tens of malicious packages in the npm ecosystem; they have been seen on the PyPi Python registry as well. Perhaps some of the most popular incidents have been for cross-env, event-stream, and eslint-scope.

One of the main targets for typosquatting attacks are the user credentials, since any package has access to environment variables via the global variable process.env. Other examples we’ve seen in the past include the case with event-stream, where the attack targeted developers in the hopes of injecting malicious code into an application’s source code.

Closing our list of ten npm security best practices are the following tips to reduce the risk of such attacks:

  • Be extra-careful when copy-pasting package installation instructions into the terminal. Make sure to verify in the source code repository as well as on the npm registry that this is indeed the package you are intending to install. You might verify the metadata of the package with npm info to fetch more information about contributors and latest versions.
  • Default to having an npm logged-out user in your daily work routines so your credentials won’t be the weak spot that would lead to easily compromising your account.
  • When installing packages, append the --ignore-scripts to reduce the risk of arbitrary command execution. For example: npm install my-malicious-package --ignore-scripts
金字旁的字与什么有关 助听器什么牌子好用 狐假虎威告诉我们什么道理 梦见孩子被蛇咬是什么意思 食蚁兽是什么动物
淋病有什么症状 精明是什么意思 灵五行属性是什么 小孩子包皮挂什么科 掼蛋是什么意思
王维有什么之称 今天什么日子老黄历 女性尿路感染什么原因引起的 小孩睡觉流口水是什么原因 一级甲等医院是什么意思
梦见下大雪是什么意思 噗噗噗是什么意思 频繁打哈欠是什么原因 再生纤维是什么 未时右眼跳是什么预兆
正月二十一是什么星座hcv8jop3ns1r.cn 非洲讲什么语言hcv9jop4ns2r.cn 小水母吃什么hcv8jop4ns8r.cn 惊蛰后是什么节气hcv9jop6ns2r.cn 身体虚弱打什么营养针jiuxinfghf.com
卵巢过度刺激综合症是什么hcv9jop1ns0r.cn 白带增多是什么原因hcv9jop6ns5r.cn 甲减长期服用优甲乐有什么危害hcv8jop1ns5r.cn 24节气是什么hcv9jop1ns1r.cn 什么补蛋白最快的食物hcv7jop4ns5r.cn
维生素a是什么hcv9jop6ns9r.cn 2013年五行属什么hcv9jop4ns7r.cn 超敏crp高是什么原因hcv8jop3ns0r.cn 来月经是黑色的是什么原因hcv8jop0ns4r.cn 膝盖疼痛吃什么药hcv7jop9ns3r.cn
肠胃炎喝什么药hcv9jop2ns3r.cn 什么体质人容易长脚气hcv8jop5ns5r.cn 什么时候说什么话hcv7jop7ns0r.cn 装修属于什么行业hcv7jop5ns5r.cn 散瞳快散和慢散有什么区别hcv8jop8ns8r.cn
百度