This commit is contained in:
2026-03-03 15:23:00 +00:00
parent 5e3726de39
commit 8e223bfbec
3689 changed files with 955330 additions and 1011 deletions

10
node_modules/@hapi/bourne/LICENSE.md generated vendored Executable file
View File

@@ -0,0 +1,10 @@
Copyright (c) 2019-2022, Project contributors
Copyright (c) 2019-2020, Sideway Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* The names of any contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS OFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

17
node_modules/@hapi/bourne/README.md generated vendored Executable file
View File

@@ -0,0 +1,17 @@
<a href="https://hapi.dev"><img src="https://raw.githubusercontent.com/hapijs/assets/master/images/family.png" width="180px" align="right" /></a>
# @hapi/bourne
#### JSON.parse() drop-in replacement with prototype poisoning protection.
**bourne** is part of the **hapi** ecosystem and was designed to work seamlessly with the [hapi web framework](https://hapi.dev) and its other components (but works great on its own or with other frameworks). If you are using a different web framework and find this module useful, check out [hapi](https://hapi.dev) they work even better together.
### Visit the [hapi.dev](https://hapi.dev) Developer Portal for tutorials, documentation, and support
## Useful resources
- [Documentation and API](https://hapi.dev/family/bourne/)
- [Version status](https://hapi.dev/resources/status/#bourne) (builds, dependencies, node versions, licenses, eol)
- [Changelog](https://hapi.dev/family/bourne/changelog/)
- [Project policies](https://hapi.dev/policies/)
- [Free and commercial support options](https://hapi.dev/support/)

62
node_modules/@hapi/bourne/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,62 @@
interface Reviver {
(this: any, key: string, value: any): any;
}
interface ParseOptions {
/**
* - `'error'` - throw a `SyntaxError` when a `__proto__` key is found. This is the default value.
* - `'remove'` - deletes any `__proto__` keys from the result object.
* - `'ignore'` - skips all validation (same as calling `JSON.parse()` directly).
*/
protoAction?: 'error' | 'remove' | 'ignore';
}
/**
* Parses a given JSON-formatted text into an object.
* @param text the JSON text string.
*/
export function parse(text: string): any;
/**
* Parses a given JSON-formatted text into an object.
* @param text the JSON text string.
* @param reviver the `JSON.parse()` optional `reviver` argument.
*/
export function parse(text: string, reviver: Reviver): any;
/**
* Parses a given JSON-formatted text into an object.
* @param text the JSON text string.
* @param options optional configuration object.
*/
export function parse(text: string, options: ParseOptions): any;
/**
* Parses a given JSON-formatted text into an object.
* @param text the JSON text string.
* @param reviver the `JSON.parse()` optional `reviver` argument.
* @param options optional configuration object.
*/
export function parse(text: string, reviver: Reviver, options: ParseOptions): any;
interface ScanOptions {
/**
* - `'error'` - throw a `SyntaxError` when a `__proto__` key is found. This is the default value.
* - `'remove'` - deletes any `__proto__` keys from the input `obj`.
*/
protoAction?: 'error' | 'remove';
}
/**
* Scans a given object for prototype properties.
* @param obj the object being scanned.
* @param options optional configuration object.
*/
export function scan(obj: any, options?: ScanOptions): void;
/**
* Parses a given JSON-formatted text into an object or `null` if an error is found.
* @param text the JSON text string.
* @param reviver the `JSON.parse()` optional `reviver` argument.
*/
export function safeParse(text: string, reviver?: Reviver) : any | null;

87
node_modules/@hapi/bourne/lib/index.js generated vendored Executable file
View File

@@ -0,0 +1,87 @@
'use strict';
const internals = {
suspectRx: /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*\:/
};
exports.parse = function (text, ...args) {
// Normalize arguments
const firstOptions = typeof args[0] === 'object' && args[0];
const reviver = args.length > 1 || !firstOptions ? args[0] : undefined;
const options = (args.length > 1 && args[1]) || firstOptions || {};
// Parse normally, allowing exceptions
const obj = JSON.parse(text, reviver);
// options.protoAction: 'error' (default) / 'remove' / 'ignore'
if (options.protoAction === 'ignore') {
return obj;
}
// Ignore null and non-objects
if (!obj ||
typeof obj !== 'object') {
return obj;
}
// Check original string for potential exploit
if (!text.match(internals.suspectRx)) {
return obj;
}
// Scan result for proto keys
exports.scan(obj, options);
return obj;
};
exports.scan = function (obj, options = {}) {
let next = [obj];
while (next.length) {
const nodes = next;
next = [];
for (const node of nodes) {
if (Object.prototype.hasOwnProperty.call(node, '__proto__')) { // Avoid calling node.hasOwnProperty directly
if (options.protoAction !== 'remove') {
throw new SyntaxError('Object contains forbidden prototype property');
}
delete node.__proto__;
}
for (const key in node) {
const value = node[key];
if (value &&
typeof value === 'object') {
next.push(node[key]);
}
}
}
}
};
exports.safeParse = function (text, reviver) {
try {
return exports.parse(text, reviver);
}
catch (ignoreError) {
return null;
}
};

35
node_modules/@hapi/bourne/package.json generated vendored Normal file
View File

@@ -0,0 +1,35 @@
{
"name": "@hapi/bourne",
"description": "JSON parse with prototype poisoning protection",
"version": "3.0.0",
"repository": "git://github.com/hapijs/bourne",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
"lib"
],
"keywords": [
"JSON",
"parse",
"safe",
"prototype"
],
"eslintConfig": {
"extends": [
"plugin:@hapi/module"
]
},
"devDependencies": {
"@hapi/code": "^9.0.0",
"@hapi/eslint-plugin": "*",
"@hapi/lab": "25.0.0-beta.1",
"@types/node": "^17.0.31",
"benchmark": "2.x.x",
"typescript": "^4.6.3"
},
"scripts": {
"test": "lab -a @hapi/code -t 100 -L -Y",
"test-cov-html": "lab -a @hapi/code -r html -o coverage.html"
},
"license": "BSD-3-Clause"
}