verdaccio-security-filter 1.4.1 → 1.4.2

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
@@ -448,9 +448,9 @@ Recommended before turning on `cveCheck.autoBlock`, a license policy or the auth
448
448
  |--------|------|---------|-------------|
449
449
  | `licenses.allowed` | `string[]` | `[]` | Allowed license list |
450
450
  | `licenses.blocked` | `string[]` | `[]` | Blocked license list |
451
- | `licenses.requireLicense` | `boolean` | `true` | Reject versions without a license field |
451
+ | `licenses.requireLicense` | `boolean` | `true` with `allowed`, otherwise `false` | Reject versions without a license field |
452
452
 
453
- The license check runs when `licenses.allowed` is not empty. Every version is checked: versions with a rejected license are removed from the metadata, and the package is blocked as a whole only when no version is left.
453
+ The license check runs when `licenses.allowed` or `licenses.blocked` is not empty, or `licenses.requireLicense` is `true`. Every version is checked: versions with a rejected license are removed from the metadata, and the package is blocked as a whole only when no version is left.
454
454
 
455
455
  ### Whitelist Options
456
456
 
package/build/index.js CHANGED
@@ -146,7 +146,7 @@ class SecurityFilterPlugin {
146
146
  }
147
147
  }
148
148
  _getEnabledFeatures() {
149
- var _a, _b, _c, _d, _e;
149
+ var _a, _b, _c, _d;
150
150
  const features = [];
151
151
  if (this.config.dryRun)
152
152
  features.push('dry-run');
@@ -156,11 +156,11 @@ class SecurityFilterPlugin {
156
156
  features.push('metrics');
157
157
  if ((_b = this.config.cveCheck) === null || _b === void 0 ? void 0 : _b.enabled)
158
158
  features.push('cve-checking');
159
- if (((_c = this.config.licenses) === null || _c === void 0 ? void 0 : _c.allowed) && this.config.licenses.allowed.length > 0)
159
+ if (this.licenseChecker.enabled)
160
160
  features.push('license-filtering');
161
- if ((_d = this.config.packageAge) === null || _d === void 0 ? void 0 : _d.enabled)
161
+ if ((_c = this.config.packageAge) === null || _c === void 0 ? void 0 : _c.enabled)
162
162
  features.push('package-age-verification');
163
- if ((_e = this.config.authorFilter) === null || _e === void 0 ? void 0 : _e.enabled)
163
+ if ((_d = this.config.authorFilter) === null || _d === void 0 ? void 0 : _d.enabled)
164
164
  features.push('author-filtering');
165
165
  if (this.securityRules.versionRangeRules.length > 0)
166
166
  features.push('version-range-rules');
@@ -403,7 +403,7 @@ class SecurityFilterPlugin {
403
403
  pkg = this._removeVersions(pkg, vulnerableVersions);
404
404
  }
405
405
  }
406
- if (this.config.licenses && this.config.licenses.allowed && this.config.licenses.allowed.length > 0) {
406
+ if (this.licenseChecker.enabled) {
407
407
  const rejected = this._rejectedVersions(pkg, data => this.licenseChecker.checkLicense(data));
408
408
  if (rejected.all) {
409
409
  const reason = rejected.first.reason || 'License not allowed';
@@ -3,6 +3,7 @@ import { Version } from '@verdaccio/types';
3
3
  export declare class LicenseChecker {
4
4
  private config;
5
5
  constructor(config?: LicenseConfig);
6
+ get enabled(): boolean;
6
7
  checkLicense(versionData: Version): {
7
8
  allowed: boolean;
8
9
  reason?: string;
@@ -3,12 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LicenseChecker = void 0;
4
4
  class LicenseChecker {
5
5
  constructor(config) {
6
+ var _a;
6
7
  this.config = {
7
8
  allowed: (config === null || config === void 0 ? void 0 : config.allowed) || [],
8
9
  blocked: (config === null || config === void 0 ? void 0 : config.blocked) || [],
9
- requireLicense: (config === null || config === void 0 ? void 0 : config.requireLicense) !== false,
10
+ requireLicense: (_a = config === null || config === void 0 ? void 0 : config.requireLicense) !== null && _a !== void 0 ? _a : ((config === null || config === void 0 ? void 0 : config.allowed) || []).length > 0,
10
11
  };
11
12
  }
13
+ get enabled() {
14
+ return this.config.allowed.length > 0 || this.config.blocked.length > 0 || this.config.requireLicense;
15
+ }
12
16
  checkLicense(versionData) {
13
17
  const license = this.extractLicense(versionData);
14
18
  if (!license || license === 'UNLICENSED' || license === '') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "verdaccio-security-filter",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
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",