(obj: any)
| 1477 | } |
| 1478 | |
| 1479 | function filter(obj: any) { |
| 1480 | let next = [obj] |
| 1481 | |
| 1482 | while (next.length) { |
| 1483 | const nodes = next |
| 1484 | next = [] |
| 1485 | |
| 1486 | for (const node of nodes) { |
| 1487 | if (Object.prototype.hasOwnProperty.call(node, "__proto__")) { |
| 1488 | throw new SyntaxError("Object contains forbidden prototype property") |
| 1489 | } |
| 1490 | |
| 1491 | if ( |
| 1492 | Object.prototype.hasOwnProperty.call(node, "constructor") && |
| 1493 | Object.prototype.hasOwnProperty.call(node.constructor, "prototype") |
| 1494 | ) { |
| 1495 | throw new SyntaxError("Object contains forbidden prototype property") |
| 1496 | } |
| 1497 | |
| 1498 | for (const key in node) { |
| 1499 | const value = node[key] |
| 1500 | if (value && typeof value === "object") { |
| 1501 | next.push(value) |
| 1502 | } |
| 1503 | } |
| 1504 | } |
| 1505 | } |
| 1506 | return obj |
| 1507 | } |
| 1508 | |
| 1509 | /** |
| 1510 | * **Unsafe**: This function will throw an error if an insecure property is |
no outgoing calls
no test coverage detected
searching dependent graphs…