
salut! Dans le dernier article, nous avons commencé à examiner l'importante question de la sécurité dans npm et à discuter des mesures que l'entreprise elle-même utilise pour identifier et prévenir les menaces. Cette fois, je veux parler des outils et des approches qui sont à votre disposition personnellement, et que je recommande vivement à tous les développeurs de mettre en œuvre dans leur pratique.
npm install (: preinstall, install/postinstall), . , . , , .
, :

: npm install malicious-package, evil.sh, unix-.
, , 2018eslint-scopeeslint-config-eslint, , .
, , , , , .
, npm npm, . , npm registry , , , , npm .
, , , , . , , .
, :
npm install suspicious-package --ignore-scripts
, ( .npmrc):
npm config set ignore-scripts true
, . , .

, , npm, npm install. , Docker-, . , npm root-; , . . : npm, .
: - , . , . npm.

: , . , npm .npmrc , .
npm - (, CI/CD), . , , read-only, . .
npm IP- (CIDR). IP ( IP) . , , (on-demand). , , .
.npmrc, (Git). NPM_TOKEN ( ).
--read-only— , (. . , );--cidr=<CIDR>— , IP. CIDR, IP. :--cidr=192.0.2.0/24.
, npm-, . npm, npm token list.
, npm adduser .npmrc . .
~/.npmrc :
//registry.npmjs.org/:_authToken=00000000-0000-0000-0000-000000000000
npm registry, .
, ~/.npmrc unix-! (, SSH), , . , . . , . SSH, EdDSA . , . : Ed25519 (EdDSA) RSA ( 2048 ) .

, , . . , , npm install packae-name: 404, — .
npm , . , , , copy-and-paste.

, , :
- , . (16 );
- . ;
- ;
- , .
: . KeePass ( ). -, . -, , , . (., Google Drive DropBox), .
, , !
(MFA)

, . . : - , . - SMS- . , . . .
, npm -. : « » « ». « », . . , npm OTP npm adduser, - (, npm publish).
, npm 2FA, . : , QR-, -. , CLI :
npm profile enable-2fa auth-and-writes
— « » ()npm profile enable-2fa auth-only
— « »
CLI npm ( ), QR-. (OTP), , .
npm , , , .
, , 2FA npm profile disable-2fa, . , , npm (, ).

, npm publish, npm .
.gitCVS.svn.hg.lock-wscript.wafpickle-N.*.swp.DS_Store._*npm-debug.log.npmrcnode_modulesconfig.gypi*.origpackage-lock.json
- registry , , , . . npm - , , .
, files package.json. , ( glob), . , - .
, , files:
package.jsonREADMECHANGES,CHANGELOG,HISTORYLICENSE,LICENCENOTICE- ,
main
README, CHANGES, LICENSE NOTICE .
, .
, npm publish, --dry-run npm pack --dry-run. , , . --dry-run , , , .
, , npm-. — .
, , , , . , .
- , , .
.