verdaccio-security-filter 1.4.2 → 1.4.4

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
@@ -433,7 +433,7 @@ Recommended before turning on `cveCheck.autoBlock`, a license policy or the auth
433
433
  |--------|------|---------|-------------|
434
434
  | `cveCheck.enabled` | `boolean` | `false` | Enable CVE scanning |
435
435
  | `cveCheck.databases` | `string[]` | `['osv']` | Vulnerability databases. Only `osv` is implemented; it already includes GitHub Security Advisories |
436
- | `cveCheck.severity` | `string[]` | `['high', 'critical']` | Severity levels to check |
436
+ | `cveCheck.severity` | `string[]` | `['high', 'critical']` | Severity levels to act on. See [how severity is determined](#how-severity-is-determined) |
437
437
  | `cveCheck.autoBlock` | `boolean` | `false` | Remove vulnerable versions from metadata (whole package blocked if every version is vulnerable) |
438
438
  | `cveCheck.updateInterval` | `number` | `24` | How long a package's vulnerability data is cached (hours) |
439
439
  | `cveCheck.cacheDir` | `string` | `./.security-cache` | Cache directory path |
@@ -442,6 +442,18 @@ Recommended before turning on `cveCheck.autoBlock`, a license policy or the auth
442
442
 
443
443
  > **When OSV is unreachable:** a lookup gets one retry with a 5 second timeout each. After a failure the same package is not looked up again for 60 seconds. Previously cached data, even if older than `updateInterval`, keeps being used. With no cached data, `errorHandling.onCveCheckError` decides: `fail-open` serves the package unchecked, `fail-closed` blocks it.
444
444
 
445
+ ### How severity is determined
446
+
447
+ For each OSV record, in this order:
448
+
449
+ 1. Malicious-package reports (ids starting with `MAL-`) are `critical`. They carry no severity information in OSV.
450
+ 2. The rating of the source database (GitHub Security Advisories: `LOW`, `MODERATE`, `HIGH`, `CRITICAL`).
451
+ 3. The CVSS v3.0 / v3.1 base score computed from the vector.
452
+ 4. A record with only a CVSS v4 vector is treated as `high`: v4 vectors are not scored.
453
+ 5. A record with no severity information at all is `medium`.
454
+
455
+ Cached results keep the severity they were stored with until they are refreshed (`cveCheck.updateInterval`).
456
+
445
457
  ### License Options
446
458
 
447
459
  | Option | Type | Default | Description |
@@ -589,23 +601,30 @@ npm run build -- --watch
589
601
 
590
602
  ## 📊 Metrics & Monitoring
591
603
 
592
- When metrics are enabled, the plugin tracks:
604
+ When metrics are enabled, the plugin writes one JSON object per event, flushed every 10 seconds or every 100 events.
605
+
606
+ - `block` - a package, a tarball or some versions were blocked; `reason` says why
607
+ - `author_blocked` - the same, decided by the author filter
608
+
609
+ What `version` holds:
610
+
611
+ | Situation | Fields |
612
+ |---|---|
613
+ | A tarball download was refused | `version`: the requested version |
614
+ | A package was blocked as a whole | `version`: `"*"` |
615
+ | Versions were removed from metadata | no `version`; `metadata.versions` lists them |
616
+
617
+ Refused requests are recorded every time, because each one is an attempt. Removed versions are recorded once per package and reason, and again only after 10 minutes: metadata is filtered on every request, so the same removal would otherwise be repeated for each of them.
593
618
 
594
- - `block` - Packages or versions blocked by rules, CVE, license or age checks; the `reason` field says which
595
- - `author_blocked` - Packages blocked due to author/region filtering
619
+ In [dry-run mode](#dry-run-mode) every event carries `"dryRun": true`.
596
620
 
597
- Example metrics output:
598
621
  ```json
599
622
  {
600
- "timestamp": "2025-01-15T10:30:00.000Z",
601
- "event": "cve_detected",
623
+ "timestamp": "2026-01-15T10:30:00.000Z",
624
+ "event": "block",
602
625
  "packageName": "lodash",
603
- "version": "4.17.20",
604
- "reason": "CVE-2021-23337 (high)",
605
- "metadata": {
606
- "cveId": "CVE-2021-23337",
607
- "severity": "high"
608
- }
626
+ "reason": "Package has 2 vulnerable version(s)",
627
+ "metadata": { "versions": ["4.17.19", "4.17.20"] }
609
628
  }
610
629
  ```
611
630
 
package/build/index.js CHANGED
@@ -72,9 +72,9 @@ class SecurityFilterPlugin {
72
72
  };
73
73
  }
74
74
  this.logger = new logger_1.SecurityLogger(options.logger, this.config.logger, !!this.config.dryRun);
75
- this.metrics = new metrics_1.MetricsCollector(this.config.metrics, !!this.config.dryRun);
76
- this.whitelistChecker = new whitelist_checker_1.WhitelistChecker(this.config.whitelist);
77
- this.cveChecker = new cve_checker_1.CVEChecker(this.config.cveCheck);
75
+ this.metrics = new metrics_1.MetricsCollector(this.config.metrics, !!this.config.dryRun, this.logger);
76
+ this.whitelistChecker = new whitelist_checker_1.WhitelistChecker(this.config.whitelist, this.logger);
77
+ this.cveChecker = new cve_checker_1.CVEChecker(this.config.cveCheck, this.logger);
78
78
  this.licenseChecker = new license_checker_1.LicenseChecker(this.config.licenses);
79
79
  this.packageAgeChecker = new package_age_checker_1.PackageAgeChecker(this.config.packageAge);
80
80
  this.authorChecker = new author_checker_1.AuthorChecker(this.config.authorFilter);
@@ -368,6 +368,7 @@ class SecurityFilterPlugin {
368
368
  (whitelistMode && !this.whitelistChecker.isWhitelisted(packageName, version).allowed));
369
369
  if (ruleBlocked.length > 0) {
370
370
  this.logger.warn(`[filter_metadata] RULE FILTERED: ${packageName}: ${ruleBlocked.join(', ')}`);
371
+ this.metrics.recordFiltered(packageName, ruleBlocked, 'Version blocked by rules');
371
372
  pkg = this._removeVersions(pkg, ruleBlocked);
372
373
  }
373
374
  }
@@ -397,9 +398,7 @@ class SecurityFilterPlugin {
397
398
  return this._blockedPackage(pkg, reason, { vulnerableVersions });
398
399
  }
399
400
  this.logger.warn(`[filter_metadata] CVE FILTERED: ${packageName} - ${reason}: ${vulnerableVersions.join(', ')}`);
400
- for (const version of vulnerableVersions) {
401
- this.metrics.recordBlock(packageName, version, reason);
402
- }
401
+ this.metrics.recordFiltered(packageName, vulnerableVersions, reason);
403
402
  pkg = this._removeVersions(pkg, vulnerableVersions);
404
403
  }
405
404
  }
@@ -413,9 +412,7 @@ class SecurityFilterPlugin {
413
412
  }
414
413
  if (rejected.versions.length > 0) {
415
414
  this.logger.warn(`[filter_metadata] LICENSE FILTERED: ${packageName}: ${rejected.versions.join(', ')}`);
416
- for (const [version, result] of rejected.results) {
417
- this.metrics.recordBlock(packageName, version, result.reason || 'License not allowed');
418
- }
415
+ this.metrics.recordFiltered(packageName, rejected.versions, 'License not allowed');
419
416
  pkg = this._removeVersions(pkg, rejected.versions);
420
417
  }
421
418
  }
@@ -435,15 +432,17 @@ class SecurityFilterPlugin {
435
432
  for (const version of Object.keys(pkg.versions || {})) {
436
433
  const versionAgeResult = this.packageAgeChecker.checkVersionAge(pkg, version);
437
434
  if (!versionAgeResult.allowed && !versionAgeResult.warnOnly) {
438
- this.logger.warn(`[filter_metadata] VERSION AGE FILTERED: ${packageName}@${version} - ${versionAgeResult.reason}`);
439
- this.metrics.recordBlock(packageName, version, versionAgeResult.reason || 'Version too new');
440
435
  removedVersions.push(version);
441
436
  }
442
437
  else if (!versionAgeResult.allowed && versionAgeResult.warnOnly) {
443
438
  this.logger.warn(`[filter_metadata] VERSION AGE WARNING: ${packageName}@${version} - ${versionAgeResult.reason} (warn-only mode)`);
444
439
  }
445
440
  }
446
- pkg = this._removeVersions(pkg, removedVersions);
441
+ if (removedVersions.length > 0) {
442
+ this.logger.warn(`[filter_metadata] VERSION AGE FILTERED: ${packageName}: ${removedVersions.join(', ')}`);
443
+ this.metrics.recordFiltered(packageName, removedVersions, 'Version too new');
444
+ pkg = this._removeVersions(pkg, removedVersions);
445
+ }
447
446
  }
448
447
  }
449
448
  if ((_d = this.config.authorFilter) === null || _d === void 0 ? void 0 : _d.enabled) {
@@ -452,31 +451,22 @@ class SecurityFilterPlugin {
452
451
  this.logger.warn(`[filter_metadata] AUTHOR WARNING: ${packageName}: ${rejected.versions.join(', ')} - ${rejected.first.reason} (warn-only mode)`);
453
452
  }
454
453
  else if (rejected.versions.length > 0) {
455
- for (const [version, result] of rejected.results) {
454
+ const reason = rejected.first.reason || 'Author not allowed';
455
+ const details = { blockedBy: rejected.first.blockedBy, authorInfo: rejected.first.authorInfo };
456
+ if (rejected.all) {
457
+ this.logger.warn(`[filter_metadata] AUTHOR BLOCKED: ${packageName} - ${reason}`);
456
458
  this.metrics.record({
457
459
  timestamp: new Date().toISOString(),
458
460
  event: 'author_blocked',
459
461
  packageName,
460
- version: rejected.all ? '*' : version,
461
- reason: result.reason || 'Author not allowed',
462
- metadata: {
463
- blockedBy: result.blockedBy,
464
- authorInfo: result.authorInfo,
465
- },
466
- });
467
- if (rejected.all) {
468
- break;
469
- }
470
- }
471
- if (rejected.all) {
472
- const reason = rejected.first.reason || 'Author not allowed';
473
- this.logger.warn(`[filter_metadata] AUTHOR BLOCKED: ${packageName} - ${reason}`);
474
- return this._blockedPackage(pkg, reason, {
475
- blockedBy: rejected.first.blockedBy,
476
- authorInfo: rejected.first.authorInfo,
462
+ version: '*',
463
+ reason,
464
+ metadata: details,
477
465
  });
466
+ return this._blockedPackage(pkg, reason, details);
478
467
  }
479
468
  this.logger.warn(`[filter_metadata] AUTHOR FILTERED: ${packageName}: ${rejected.versions.join(', ')}`);
469
+ this.metrics.recordFiltered(packageName, rejected.versions, reason, 'author_blocked', details);
480
470
  pkg = this._removeVersions(pkg, rejected.versions);
481
471
  }
482
472
  }
@@ -1,5 +1,7 @@
1
1
  import { CVECheckConfig, CVECheckResult } from '../types';
2
+ import { CheckerLog } from './logger';
2
3
  export declare class CVEChecker {
4
+ private readonly log;
3
5
  private config;
4
6
  private cache;
5
7
  private failedUntil;
@@ -9,7 +11,7 @@ export declare class CVEChecker {
9
11
  private saveTimer;
10
12
  private readonly SAVE_DEBOUNCE_MS;
11
13
  private dirty;
12
- constructor(config?: CVECheckConfig);
14
+ constructor(config?: CVECheckConfig, log?: CheckerLog);
13
15
  checkPackage(packageName: string, version: string): Promise<CVECheckResult>;
14
16
  checkVersions(packageName: string, versions: string[]): Promise<CVECheckResult[]>;
15
17
  private getPackageEntry;
@@ -105,7 +105,8 @@ function isAffected(vuln, version, parsed) {
105
105
  });
106
106
  }
107
107
  class CVEChecker {
108
- constructor(config) {
108
+ constructor(config, log = console) {
109
+ this.log = log;
109
110
  this.inFlight = new Map();
110
111
  this.matches = new WeakMap();
111
112
  this.MAX_CACHE_SIZE = 1000;
@@ -202,7 +203,7 @@ class CVEChecker {
202
203
  }
203
204
  if (stale) {
204
205
  const message = failure instanceof Error ? failure.message : String(failure);
205
- console.warn(`[CVE Checker] Using stale data for ${packageName}: ${message}`);
206
+ this.log.warn(`[CVE Checker] Using stale data for ${packageName}: ${message}`);
206
207
  return stale;
207
208
  }
208
209
  throw failure;
@@ -273,18 +274,22 @@ class CVEChecker {
273
274
  };
274
275
  }
275
276
  mapOSVSeverity(vuln) {
276
- var _a, _b, _c, _d;
277
- const databaseSeverity = this.mapDatabaseSpecificSeverity((_a = vuln === null || vuln === void 0 ? void 0 : vuln.database_specific) === null || _a === void 0 ? void 0 : _a.severity);
277
+ var _a, _b, _c, _d, _e;
278
+ if ((_a = vuln === null || vuln === void 0 ? void 0 : vuln.id) === null || _a === void 0 ? void 0 : _a.startsWith('MAL-')) {
279
+ return 'critical';
280
+ }
281
+ const databaseSeverity = this.mapDatabaseSpecificSeverity((_b = vuln === null || vuln === void 0 ? void 0 : vuln.database_specific) === null || _b === void 0 ? void 0 : _b.severity);
278
282
  if (databaseSeverity) {
279
283
  return databaseSeverity;
280
284
  }
281
- const cvssV3 = (_b = vuln === null || vuln === void 0 ? void 0 : vuln.severity) === null || _b === void 0 ? void 0 : _b.find(entry => entry.type === 'CVSS_V3');
285
+ const cvssV3 = (_c = vuln === null || vuln === void 0 ? void 0 : vuln.severity) === null || _c === void 0 ? void 0 : _c.find(entry => entry.type === 'CVSS_V3');
282
286
  const score = cvssV3 ? this.computeCVSSv3BaseScore(cvssV3.score) : null;
283
287
  if (score !== null) {
284
288
  return this.scoreToSeverity(score);
285
289
  }
286
- if ((_c = vuln === null || vuln === void 0 ? void 0 : vuln.severity) === null || _c === void 0 ? void 0 : _c.some(entry => entry.type === 'CVSS_V4')) {
287
- console.debug(`[CVE Checker] ${(_d = vuln.id) !== null && _d !== void 0 ? _d : 'unknown vulnerability'} only has a CVSS_V4 vector, which is not scored yet - defaulting severity to medium`);
290
+ if ((_d = vuln === null || vuln === void 0 ? void 0 : vuln.severity) === null || _d === void 0 ? void 0 : _d.some(entry => entry.type === 'CVSS_V4')) {
291
+ this.log.debug(`[CVE Checker] ${(_e = vuln.id) !== null && _e !== void 0 ? _e : 'unknown vulnerability'} only has a CVSS_V4 vector, which is not scored - treating it as high`);
292
+ return 'high';
288
293
  }
289
294
  return 'medium';
290
295
  }
@@ -368,7 +373,7 @@ class CVEChecker {
368
373
  }
369
374
  catch (error) {
370
375
  const message = error instanceof Error ? error.message : String(error);
371
- console.error('[CVE Checker] Failed to load cache:', message);
376
+ this.log.error(`[CVE Checker] Failed to load cache: ${message}`);
372
377
  }
373
378
  }
374
379
  debouncedSaveCache() {
@@ -396,7 +401,7 @@ class CVEChecker {
396
401
  }
397
402
  catch (error) {
398
403
  const message = error instanceof Error ? error.message : String(error);
399
- console.error('[CVE Checker] Failed to save cache:', message);
404
+ this.log.error(`[CVE Checker] Failed to save cache: ${message}`);
400
405
  }
401
406
  });
402
407
  }
@@ -417,7 +422,7 @@ class CVEChecker {
417
422
  }
418
423
  catch (error) {
419
424
  const message = error instanceof Error ? error.message : String(error);
420
- console.error('[CVE Checker] Failed to save cache:', message);
425
+ this.log.error(`[CVE Checker] Failed to save cache: ${message}`);
421
426
  }
422
427
  }
423
428
  this.cache.clear();
@@ -1,5 +1,6 @@
1
1
  import { Logger } from '@verdaccio/types';
2
2
  import { LoggerConfig } from '../types';
3
+ export type CheckerLog = Pick<SecurityLogger, 'debug' | 'warn' | 'error'>;
3
4
  export declare class SecurityLogger {
4
5
  private verdaccioLogger;
5
6
  private config;
@@ -12,10 +13,5 @@ export declare class SecurityLogger {
12
13
  info(message: string, ...args: any[]): void;
13
14
  warn(message: string, ...args: any[]): void;
14
15
  error(message: string, ...args: any[]): void;
15
- logBlock(packageName: string, version: string, reason: string): void;
16
- logFallback(packageName: string, fromVersion: string, toVersion: string, reason?: string): void;
17
- logCVE(packageName: string, version: string, cveId: string, severity: string): void;
18
- logLicense(packageName: string, version: string, license: string, reason: string): void;
19
- logPublishRejected(packageName: string, version: string, reason: string): void;
20
16
  logInit(features: string[]): void;
21
17
  }
@@ -51,22 +51,6 @@ class SecurityLogger {
51
51
  this.verdaccioLogger.error(this.formatMessage(message), ...args);
52
52
  }
53
53
  }
54
- logBlock(packageName, version, reason) {
55
- this.warn(`Blocked ${packageName}@${version} - ${reason}`);
56
- }
57
- logFallback(packageName, fromVersion, toVersion, reason) {
58
- const reasonText = reason ? ` (${reason})` : '';
59
- this.info(`Fallback applied: ${packageName}@${fromVersion} -> ${toVersion}${reasonText}`);
60
- }
61
- logCVE(packageName, version, cveId, severity) {
62
- this.warn(`CVE detected: ${cveId} [${severity}] in ${packageName}@${version}`);
63
- }
64
- logLicense(packageName, version, license, reason) {
65
- this.warn(`License violation: ${packageName}@${version} has ${license} - ${reason}`);
66
- }
67
- logPublishRejected(packageName, version, reason) {
68
- this.warn(`Publish rejected: ${packageName}@${version} - ${reason}`);
69
- }
70
54
  logInit(features) {
71
55
  this.info(`Plugin initialized with features: ${features.join(', ')}`);
72
56
  }
@@ -1,18 +1,21 @@
1
1
  import { MetricsConfig, MetricsData } from '../types';
2
+ import { CheckerLog } from './logger';
2
3
  export declare class MetricsCollector {
3
4
  private readonly dryRun;
5
+ private readonly log;
4
6
  private config;
5
7
  private metricsBuffer;
6
8
  private readonly bufferSize;
7
9
  private readonly maxBufferSize;
8
10
  private readonly flushIntervalMs;
9
11
  private flushTimer;
10
- constructor(config?: MetricsConfig, dryRun?: boolean);
12
+ private readonly filteredRepeatMs;
13
+ private recentlyFiltered;
14
+ private counts;
15
+ constructor(config?: MetricsConfig, dryRun?: boolean, log?: CheckerLog);
11
16
  record(event: MetricsData): void;
12
17
  recordBlock(packageName: string, version: string, reason: string, metadata?: Record<string, any>): void;
13
- recordPublishRejected(packageName: string, version: string, reason: string): void;
14
- recordLicenseBlock(packageName: string, version: string, license: string, reason: string): void;
15
- recordPackageTooNew(packageName: string, version: string, reason: string, metadata?: Record<string, any>): void;
18
+ recordFiltered(packageName: string, versions: string[], reason: string, event?: MetricsData['event'], metadata?: Record<string, any>): void;
16
19
  flush(): void;
17
20
  private writeToFile;
18
21
  getSummary(): Record<string, number>;
@@ -36,14 +36,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.MetricsCollector = void 0;
37
37
  const fs = __importStar(require("fs"));
38
38
  const path = __importStar(require("path"));
39
+ const lru_cache_1 = require("./lru-cache");
39
40
  class MetricsCollector {
40
- constructor(config, dryRun = false) {
41
+ constructor(config, dryRun = false, log = console) {
41
42
  this.dryRun = dryRun;
43
+ this.log = log;
42
44
  this.metricsBuffer = [];
43
45
  this.bufferSize = 100;
44
46
  this.maxBufferSize = 500;
45
47
  this.flushIntervalMs = 10000;
46
48
  this.flushTimer = null;
49
+ this.filteredRepeatMs = 10 * 60 * 1000;
50
+ this.recentlyFiltered = new lru_cache_1.LRUCache(5000);
51
+ this.counts = { block: 0, author_blocked: 0 };
47
52
  this.config = {
48
53
  enabled: (config === null || config === void 0 ? void 0 : config.enabled) || false,
49
54
  output: (config === null || config === void 0 ? void 0 : config.output) || 'stdout',
@@ -61,6 +66,7 @@ class MetricsCollector {
61
66
  if (this.metricsBuffer.length >= this.maxBufferSize) {
62
67
  this.flush();
63
68
  }
69
+ this.counts[event.event] = (this.counts[event.event] || 0) + 1;
64
70
  this.metricsBuffer.push(this.dryRun ? Object.assign(Object.assign({}, event), { dryRun: true }) : event);
65
71
  if (this.metricsBuffer.length >= this.bufferSize) {
66
72
  this.flush();
@@ -76,33 +82,23 @@ class MetricsCollector {
76
82
  metadata,
77
83
  });
78
84
  }
79
- recordPublishRejected(packageName, version, reason) {
80
- this.record({
81
- timestamp: new Date().toISOString(),
82
- event: 'publish_rejected',
83
- packageName,
84
- version,
85
- reason,
86
- });
87
- }
88
- recordLicenseBlock(packageName, version, license, reason) {
89
- this.record({
90
- timestamp: new Date().toISOString(),
91
- event: 'license_blocked',
92
- packageName,
93
- version,
94
- reason,
95
- metadata: { license },
96
- });
97
- }
98
- recordPackageTooNew(packageName, version, reason, metadata) {
85
+ recordFiltered(packageName, versions, reason, event = 'block', metadata = {}) {
86
+ var _a;
87
+ if (!this.config.enabled || versions.length === 0) {
88
+ return;
89
+ }
90
+ const key = `${event}|${packageName}|${reason}|${versions.join(',')}`;
91
+ const now = Date.now();
92
+ if (now - ((_a = this.recentlyFiltered.get(key)) !== null && _a !== void 0 ? _a : -Infinity) < this.filteredRepeatMs) {
93
+ return;
94
+ }
95
+ this.recentlyFiltered.set(key, now);
99
96
  this.record({
100
97
  timestamp: new Date().toISOString(),
101
- event: 'package_too_new',
98
+ event,
102
99
  packageName,
103
- version,
104
100
  reason,
105
- metadata,
101
+ metadata: Object.assign(Object.assign({}, metadata), { versions }),
106
102
  });
107
103
  }
108
104
  flush() {
@@ -131,23 +127,11 @@ class MetricsCollector {
131
127
  }
132
128
  catch (error) {
133
129
  const message = error instanceof Error ? error.message : String(error);
134
- console.error('[Security Filter] Failed to write metrics:', message);
130
+ this.log.error(`Failed to write metrics: ${message}`);
135
131
  }
136
132
  }
137
133
  getSummary() {
138
- const summary = {
139
- block: 0,
140
- fallback: 0,
141
- publish_rejected: 0,
142
- cve_detected: 0,
143
- license_blocked: 0,
144
- package_too_new: 0,
145
- author_blocked: 0,
146
- };
147
- this.metricsBuffer.forEach(metric => {
148
- summary[metric.event] = (summary[metric.event] || 0) + 1;
149
- });
150
- return summary;
134
+ return Object.assign({}, this.counts);
151
135
  }
152
136
  cleanup() {
153
137
  if (this.flushTimer) {
@@ -1,8 +1,10 @@
1
1
  import { WhitelistConfig } from '../types';
2
+ import { CheckerLog } from './logger';
2
3
  export declare class WhitelistChecker {
4
+ private readonly log;
3
5
  private config;
4
6
  private regexes;
5
- constructor(config?: WhitelistConfig);
7
+ constructor(config?: WhitelistConfig, log?: CheckerLog);
6
8
  isWhitelisted(packageName: string, version?: string): {
7
9
  allowed: boolean;
8
10
  reason?: string;
@@ -36,7 +36,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.WhitelistChecker = void 0;
37
37
  const semver = __importStar(require("semver"));
38
38
  class WhitelistChecker {
39
- constructor(config) {
39
+ constructor(config, log = console) {
40
+ this.log = log;
40
41
  this.regexes = new Map();
41
42
  this.config = {
42
43
  packages: (config === null || config === void 0 ? void 0 : config.packages) || [],
@@ -75,7 +76,7 @@ class WhitelistChecker {
75
76
  regex = new RegExp(pattern);
76
77
  }
77
78
  catch (_a) {
78
- console.error(`[Whitelist] Invalid pattern: ${pattern}`);
79
+ this.log.error(`[Whitelist] Invalid pattern: ${pattern}`);
79
80
  regex = null;
80
81
  }
81
82
  this.regexes.set(pattern, regex);
package/build/types.d.ts CHANGED
@@ -96,7 +96,7 @@ export interface CVECheckResult {
96
96
  }
97
97
  export interface MetricsData {
98
98
  timestamp: string;
99
- event: 'block' | 'fallback' | 'publish_rejected' | 'cve_detected' | 'license_blocked' | 'package_too_new' | 'author_blocked';
99
+ event: 'block' | 'author_blocked';
100
100
  packageName: string;
101
101
  version?: string;
102
102
  reason: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "verdaccio-security-filter",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "Advanced security filter plugin for Verdaccio with version range blocking and fallback strategies",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -55,8 +55,8 @@
55
55
  "typescript-eslint": "^8.0.0"
56
56
  },
57
57
  "overrides": {
58
- "qs": "6.16.0",
59
- "@cypress/request": "3.0.10"
58
+ "qs": "6.17.1",
59
+ "@cypress/request": "4.0.1"
60
60
  },
61
61
  "author": {
62
62
  "name": "Vitaliy Ponomarenko",