z-schema 12.0.0 → 12.0.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
@@ -4,7 +4,7 @@ Fast, lightweight JSON Schema validator for Node.js and browsers with **full sup
4
4
 
5
5
  [![NPM](https://nodei.co/npm/z-schema.png?downloads=true&downloadRank=true)](https://www.npmjs.com/package/z-schema)
6
6
 
7
- [![Coverage Status](https://coveralls.io/repos/github/zaggino/z-schema/badge.svg?branch=main)](https://coveralls.io/github/zaggino/z-schema?branch=main)
7
+ [![Coverage 91%](https://img.shields.io/badge/coverage-91%25-brightgreen)](docs/test-coverage.md)
8
8
 
9
9
  ## Install
10
10
 
@@ -330,6 +330,13 @@ Big thanks to:
330
330
  <sub><b>Geraint</b></sub>
331
331
  </a>
332
332
  </td>
333
+ <td align="center">
334
+ <a href="https://github.com/lirenhe">
335
+ <img src="https://avatars.githubusercontent.com/u/9100546?v=4" width="100;" alt="lirenhe"/>
336
+ <br />
337
+ <sub><b>Renhe Li</b></sub>
338
+ </a>
339
+ </td>
333
340
  <td align="center">
334
341
  <a href="https://github.com/dgerber">
335
342
  <img src="https://avatars.githubusercontent.com/u/393344?v=4" width="100;" alt="dgerber"/>
@@ -358,6 +365,8 @@ Big thanks to:
358
365
  <sub><b>barrtender</b></sub>
359
366
  </a>
360
367
  </td>
368
+ </tr>
369
+ <tr>
361
370
  <td align="center">
362
371
  <a href="https://github.com/RomanHotsiy">
363
372
  <img src="https://avatars.githubusercontent.com/u/3975738?v=4" width="100;" alt="RomanHotsiy"/>
@@ -365,8 +374,6 @@ Big thanks to:
365
374
  <sub><b>Roman Hotsiy</b></sub>
366
375
  </a>
367
376
  </td>
368
- </tr>
369
- <tr>
370
377
  <td align="center">
371
378
  <a href="https://github.com/sauvainr">
372
379
  <img src="https://avatars.githubusercontent.com/u/1715747?v=4" width="100;" alt="sauvainr"/>
@@ -402,6 +409,8 @@ Big thanks to:
402
409
  <sub><b>José F. Romaniello</b></sub>
403
410
  </a>
404
411
  </td>
412
+ </tr>
413
+ <tr>
405
414
  <td align="center">
406
415
  <a href="https://github.com/KEIII">
407
416
  <img src="https://avatars.githubusercontent.com/u/1167833?v=4" width="100;" alt="KEIII"/>
@@ -409,8 +418,6 @@ Big thanks to:
409
418
  <sub><b>Ivan Kasenkov</b></sub>
410
419
  </a>
411
420
  </td>
412
- </tr>
413
- <tr>
414
421
  <td align="center">
415
422
  <a href="https://github.com/HanOterLin">
416
423
  <img src="https://avatars.githubusercontent.com/u/21137108?v=4" width="100;" alt="HanOterLin"/>
package/bin/z-schema CHANGED
@@ -104,7 +104,34 @@ function validateWithAutomaticDownloads(filePath, data, schema, callback) {
104
104
  var urlString = 'request: ' + url + ' - ';
105
105
 
106
106
  if (url.match(/^https?:/)) {
107
- request(url, function (response) {
107
+ var parsedUrl;
108
+ try {
109
+ parsedUrl = new URL(url);
110
+ } catch (_e) {
111
+ console.error('Invalid URL: ' + url);
112
+ process.exit(1);
113
+ }
114
+ // Guard against SSRF: only allow https and reject private/internal hostnames (CWE-918)
115
+ if (parsedUrl.protocol !== 'https:') {
116
+ console.error('Only HTTPS URLs are allowed for remote references: ' + url);
117
+ process.exit(1);
118
+ }
119
+ var hostname = parsedUrl.hostname;
120
+ if (
121
+ hostname === 'localhost' ||
122
+ hostname === '127.0.0.1' ||
123
+ hostname === '::1' ||
124
+ hostname === '0.0.0.0' ||
125
+ hostname.endsWith('.local') ||
126
+ hostname.startsWith('10.') ||
127
+ hostname.startsWith('192.168.') ||
128
+ /^172\.(1[6-9]|2\d|3[01])\./.test(hostname) ||
129
+ hostname.startsWith('169.254.')
130
+ ) {
131
+ console.error('Requests to private/internal addresses are not allowed: ' + url);
132
+ process.exit(1);
133
+ }
134
+ request(parsedUrl, function (response) {
108
135
  var body = '';
109
136
  response.on('data', function (chunk) {
110
137
  body += chunk;
package/cjs/index.d.ts CHANGED
@@ -231,6 +231,14 @@ declare class ZSchemaBase {
231
231
  validateOptions: ValidateOptions;
232
232
  options: ZSchemaOptions;
233
233
  constructor(options: ZSchemaOptions | undefined, token: symbol);
234
+ /**
235
+ * Internal recursive JSON validation — delegates to the `validate` function
236
+ * in `json-validation.ts`. Exposed as a method so that per-keyword validator
237
+ * modules (array, combinators, object) can call back into the core validator
238
+ * via `this` without importing `json-validation.ts` directly (which would
239
+ * create a circular dependency).
240
+ */
241
+ _jsonValidate(report: Report, schema: boolean | JsonSchemaInternal, json: unknown): boolean;
234
242
  getDefaultSchemaId(): string;
235
243
  _validate(json: unknown, schema: JsonSchema | string, options: ValidateOptions, callback: ValidateCallback): void;
236
244
  _validate(json: unknown, schema: JsonSchema | string, callback: ValidateCallback): void;