verdaccio-security-filter 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -125,7 +125,7 @@ These wait for a concrete request:
125
125
  ### Prerequisites
126
126
 
127
127
  - Node.js >= 22.0.0
128
- - Verdaccio >= 5.0.0
128
+ - Verdaccio >= 5.0.0; 7.x recommended. Verdaccio 6 depends on a `minimatch` version with a known denial-of-service issue ([GHSA-g3hv-75wg-m249](https://github.com/advisories/GHSA-g3hv-75wg-m249)), fixed in Verdaccio 7.
129
129
 
130
130
  ```bash
131
131
  npm install -g verdaccio
package/build/index.d.ts CHANGED
@@ -15,6 +15,7 @@ export default class SecurityFilterPlugin implements IPluginMiddleware<SecurityC
15
15
  private readonly packageAgeChecker;
16
16
  private readonly authorChecker;
17
17
  private readonly typosquatChecker;
18
+ private readonly typosquatWarnedAt;
18
19
  constructor(config: SecurityConfig, options: PluginOptions<SecurityConfig>);
19
20
  private _parseVersionRangeRules;
20
21
  private _logInitialization;
package/build/index.js CHANGED
@@ -61,11 +61,13 @@ const lru_cache_1 = require("./lib/lru-cache");
61
61
  const webhook_1 = require("./lib/webhook");
62
62
  const PLUGIN_VERSION = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '..', 'package.json'), 'utf8')).version;
63
63
  const filterBlocks = new lru_cache_1.LRUCache(1000);
64
+ const TYPOSQUAT_WARN_REPEAT_MS = 10 * 60 * 1000;
64
65
  function forbiddenBody(packageName, reason, extra = {}) {
65
66
  return Object.assign(Object.assign({ error: `Package blocked by security filter: ${reason}`, package: packageName, reason }, extra), { timestamp: new Date().toISOString() });
66
67
  }
67
68
  class SecurityFilterPlugin {
68
69
  constructor(config, options) {
70
+ this.typosquatWarnedAt = new lru_cache_1.LRUCache(5000);
69
71
  this.config = config || {};
70
72
  if (!this.config.errorHandling) {
71
73
  this.config.errorHandling = {
@@ -507,6 +509,7 @@ class SecurityFilterPlugin {
507
509
  }
508
510
  _checkPackageBlock(packageName, version) {
509
511
  return __awaiter(this, void 0, void 0, function* () {
512
+ var _a;
510
513
  const whitelistMode = this.config.mode === 'whitelist';
511
514
  if (whitelistMode) {
512
515
  const whitelistCheck = this.whitelistChecker.isWhitelisted(packageName, version);
@@ -522,7 +525,11 @@ class SecurityFilterPlugin {
522
525
  }
523
526
  const typosquat = whitelistMode ? { allowed: true } : this.typosquatChecker.check(packageName);
524
527
  if (typosquat.warnOnly && typosquat.reason) {
525
- this.logger.warn(`TYPOSQUAT WARNING: ${packageName} - ${typosquat.reason} (warn-only mode)`);
528
+ const now = Date.now();
529
+ if (now - ((_a = this.typosquatWarnedAt.get(packageName)) !== null && _a !== void 0 ? _a : -Infinity) >= TYPOSQUAT_WARN_REPEAT_MS) {
530
+ this.typosquatWarnedAt.set(packageName, now);
531
+ this.logger.warn(`TYPOSQUAT WARNING: ${packageName} - ${typosquat.reason} (warn-only mode)`);
532
+ }
526
533
  }
527
534
  else if (!typosquat.allowed) {
528
535
  return { blocked: true, reason: typosquat.reason };
@@ -554,6 +561,12 @@ class SecurityFilterPlugin {
554
561
  rules.allowedScopes = this.securityRules.allowedScopes;
555
562
  }
556
563
  }
564
+ if (this.config.mode !== 'whitelist') {
565
+ const typosquat = this.typosquatChecker.check(packageName);
566
+ if (!typosquat.allowed && typosquat.target) {
567
+ rules.typosquat = { target: typosquat.target, distance: typosquat.distance };
568
+ }
569
+ }
557
570
  const versionRules = this.securityRules.versionRangeRules.filter(rule => rule.package === packageName);
558
571
  if (versionRules.length > 0) {
559
572
  rules.versionRangeRules = versionRules.map(rule => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "verdaccio-security-filter",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Verdaccio security plugin: block vulnerable (CVE/OSV), malicious and newly published npm packages in your private registry to stop supply chain attacks",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -63,11 +63,13 @@
63
63
  "npm-high-impact": "^1.13.0",
64
64
  "ts-jest": "^29.2.5",
65
65
  "typescript": "^6.0.3",
66
- "typescript-eslint": "^8.0.0"
66
+ "typescript-eslint": "^8.0.0",
67
+ "verdaccio": "^7.1.2"
67
68
  },
68
69
  "overrides": {
69
70
  "qs": "6.17.1",
70
- "@cypress/request": "4.0.1"
71
+ "@cypress/request": "4.0.1",
72
+ "minimatch": "11.0.9"
71
73
  },
72
74
  "author": {
73
75
  "name": "Vitaliy Ponomarenko",