node-fastify 5.8.3
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/.borp.yaml +3 -0
- package/.markdownlint-cli2.yaml +22 -0
- package/.prettierignore +1 -0
- package/GOVERNANCE.md +4 -0
- package/LICENSE +21 -0
- package/PROJECT_CHARTER.md +126 -0
- package/README.md +423 -0
- package/SECURITY.md +220 -0
- package/SPONSORS.md +24 -0
- package/build/build-error-serializer.js +35 -0
- package/build/build-validation.js +169 -0
- package/build/sync-version.js +11 -0
- package/docs/Guides/Benchmarking.md +60 -0
- package/docs/Guides/Database.md +321 -0
- package/docs/Guides/Delay-Accepting-Requests.md +608 -0
- package/docs/Guides/Detecting-When-Clients-Abort.md +172 -0
- package/docs/Guides/Ecosystem.md +726 -0
- package/docs/Guides/Fluent-Schema.md +127 -0
- package/docs/Guides/Getting-Started.md +620 -0
- package/docs/Guides/Index.md +43 -0
- package/docs/Guides/Migration-Guide-V3.md +287 -0
- package/docs/Guides/Migration-Guide-V4.md +267 -0
- package/docs/Guides/Migration-Guide-V5.md +727 -0
- package/docs/Guides/Plugins-Guide.md +520 -0
- package/docs/Guides/Prototype-Poisoning.md +383 -0
- package/docs/Guides/Recommendations.md +378 -0
- package/docs/Guides/Serverless.md +604 -0
- package/docs/Guides/Style-Guide.md +246 -0
- package/docs/Guides/Testing.md +481 -0
- package/docs/Guides/Write-Plugin.md +103 -0
- package/docs/Guides/Write-Type-Provider.md +34 -0
- package/docs/Reference/ContentTypeParser.md +271 -0
- package/docs/Reference/Decorators.md +436 -0
- package/docs/Reference/Encapsulation.md +194 -0
- package/docs/Reference/Errors.md +377 -0
- package/docs/Reference/HTTP2.md +94 -0
- package/docs/Reference/Hooks.md +958 -0
- package/docs/Reference/Index.md +73 -0
- package/docs/Reference/LTS.md +86 -0
- package/docs/Reference/Lifecycle.md +99 -0
- package/docs/Reference/Logging.md +268 -0
- package/docs/Reference/Middleware.md +79 -0
- package/docs/Reference/Plugins.md +245 -0
- package/docs/Reference/Principles.md +73 -0
- package/docs/Reference/Reply.md +1001 -0
- package/docs/Reference/Request.md +295 -0
- package/docs/Reference/Routes.md +802 -0
- package/docs/Reference/Server.md +2389 -0
- package/docs/Reference/Type-Providers.md +256 -0
- package/docs/Reference/TypeScript.md +1729 -0
- package/docs/Reference/Validation-and-Serialization.md +1130 -0
- package/docs/Reference/Warnings.md +58 -0
- package/docs/index.md +24 -0
- package/docs/resources/encapsulation_context.drawio +1 -0
- package/docs/resources/encapsulation_context.svg +3 -0
- package/eslint.config.js +35 -0
- package/examples/asyncawait.js +38 -0
- package/examples/benchmark/body.json +3 -0
- package/examples/benchmark/hooks-benchmark-async-await.js +44 -0
- package/examples/benchmark/hooks-benchmark.js +52 -0
- package/examples/benchmark/parser.js +47 -0
- package/examples/benchmark/simple.js +30 -0
- package/examples/benchmark/webstream.js +27 -0
- package/examples/hooks.js +91 -0
- package/examples/http2.js +39 -0
- package/examples/https.js +38 -0
- package/examples/parser.js +53 -0
- package/examples/plugin.js +12 -0
- package/examples/route-prefix.js +38 -0
- package/examples/shared-schema.js +38 -0
- package/examples/simple-stream.js +20 -0
- package/examples/simple.js +32 -0
- package/examples/simple.mjs +27 -0
- package/examples/typescript-server.ts +79 -0
- package/examples/use-plugin.js +29 -0
- package/fastify.d.ts +253 -0
- package/fastify.js +985 -0
- package/integration/server.js +29 -0
- package/integration/test.sh +23 -0
- package/lib/config-validator.js +1266 -0
- package/lib/content-type-parser.js +413 -0
- package/lib/content-type.js +160 -0
- package/lib/context.js +98 -0
- package/lib/decorate.js +152 -0
- package/lib/error-handler.js +173 -0
- package/lib/error-serializer.js +134 -0
- package/lib/error-status.js +14 -0
- package/lib/errors.js +516 -0
- package/lib/four-oh-four.js +190 -0
- package/lib/handle-request.js +195 -0
- package/lib/head-route.js +45 -0
- package/lib/hooks.js +429 -0
- package/lib/initial-config-validation.js +37 -0
- package/lib/logger-factory.js +136 -0
- package/lib/logger-pino.js +68 -0
- package/lib/noop-set.js +10 -0
- package/lib/plugin-override.js +90 -0
- package/lib/plugin-utils.js +169 -0
- package/lib/promise.js +23 -0
- package/lib/reply.js +1030 -0
- package/lib/req-id-gen-factory.js +52 -0
- package/lib/request.js +391 -0
- package/lib/route.js +686 -0
- package/lib/schema-controller.js +164 -0
- package/lib/schemas.js +207 -0
- package/lib/server.js +441 -0
- package/lib/symbols.js +71 -0
- package/lib/validation.js +280 -0
- package/lib/warnings.js +57 -0
- package/lib/wrap-thenable.js +84 -0
- package/package.json +225 -0
- package/scripts/validate-ecosystem-links.js +179 -0
- package/test/404s.test.js +2035 -0
- package/test/500s.test.js +422 -0
- package/test/allow-unsafe-regex.test.js +92 -0
- package/test/als.test.js +65 -0
- package/test/async-await.test.js +705 -0
- package/test/async-dispose.test.js +20 -0
- package/test/async_hooks.test.js +52 -0
- package/test/body-limit.test.js +224 -0
- package/test/buffer.test.js +74 -0
- package/test/build/error-serializer.test.js +36 -0
- package/test/build/version.test.js +14 -0
- package/test/build-certificate.js +109 -0
- package/test/bundler/README.md +29 -0
- package/test/bundler/esbuild/bundler-test.js +32 -0
- package/test/bundler/esbuild/package.json +10 -0
- package/test/bundler/esbuild/src/fail-plugin-version.js +14 -0
- package/test/bundler/esbuild/src/index.js +9 -0
- package/test/bundler/webpack/bundler-test.js +32 -0
- package/test/bundler/webpack/package.json +11 -0
- package/test/bundler/webpack/src/fail-plugin-version.js +14 -0
- package/test/bundler/webpack/src/index.js +9 -0
- package/test/bundler/webpack/webpack.config.js +15 -0
- package/test/case-insensitive.test.js +102 -0
- package/test/chainable.test.js +40 -0
- package/test/child-logger-factory.test.js +128 -0
- package/test/client-timeout.test.js +38 -0
- package/test/close-pipelining.test.js +78 -0
- package/test/close.test.js +706 -0
- package/test/conditional-pino.test.js +47 -0
- package/test/connection-timeout.test.js +42 -0
- package/test/constrained-routes.test.js +1138 -0
- package/test/content-length.test.js +174 -0
- package/test/content-parser.test.js +739 -0
- package/test/content-type.test.js +181 -0
- package/test/context-config.test.js +164 -0
- package/test/custom-http-server.test.js +118 -0
- package/test/custom-parser-async.test.js +59 -0
- package/test/custom-parser.0.test.js +701 -0
- package/test/custom-parser.1.test.js +266 -0
- package/test/custom-parser.2.test.js +91 -0
- package/test/custom-parser.3.test.js +208 -0
- package/test/custom-parser.4.test.js +218 -0
- package/test/custom-parser.5.test.js +130 -0
- package/test/custom-querystring-parser.test.js +129 -0
- package/test/decorator.test.js +1330 -0
- package/test/delete.test.js +344 -0
- package/test/diagnostics-channel/404.test.js +49 -0
- package/test/diagnostics-channel/async-delay-request.test.js +65 -0
- package/test/diagnostics-channel/async-request.test.js +64 -0
- package/test/diagnostics-channel/error-before-handler.test.js +35 -0
- package/test/diagnostics-channel/error-request.test.js +53 -0
- package/test/diagnostics-channel/error-status.test.js +123 -0
- package/test/diagnostics-channel/init.test.js +50 -0
- package/test/diagnostics-channel/sync-delay-request.test.js +49 -0
- package/test/diagnostics-channel/sync-request-reply.test.js +51 -0
- package/test/diagnostics-channel/sync-request.test.js +54 -0
- package/test/encapsulated-child-logger-factory.test.js +69 -0
- package/test/encapsulated-error-handler.test.js +237 -0
- package/test/esm/errorCodes.test.mjs +10 -0
- package/test/esm/esm.test.mjs +13 -0
- package/test/esm/index.test.js +8 -0
- package/test/esm/named-exports.mjs +14 -0
- package/test/esm/other.mjs +8 -0
- package/test/esm/plugin.mjs +8 -0
- package/test/fastify-instance.test.js +300 -0
- package/test/find-route.test.js +152 -0
- package/test/fluent-schema.test.js +209 -0
- package/test/genReqId.test.js +426 -0
- package/test/handler-context.test.js +45 -0
- package/test/handler-timeout.test.js +367 -0
- package/test/has-route.test.js +88 -0
- package/test/header-overflow.test.js +55 -0
- package/test/helper.js +496 -0
- package/test/hooks-async.test.js +1099 -0
- package/test/hooks.on-listen.test.js +1162 -0
- package/test/hooks.on-ready.test.js +421 -0
- package/test/hooks.test.js +3578 -0
- package/test/http-methods/copy.test.js +35 -0
- package/test/http-methods/custom-http-methods.test.js +114 -0
- package/test/http-methods/get.test.js +412 -0
- package/test/http-methods/head.test.js +263 -0
- package/test/http-methods/lock.test.js +108 -0
- package/test/http-methods/mkcalendar.test.js +143 -0
- package/test/http-methods/mkcol.test.js +35 -0
- package/test/http-methods/move.test.js +42 -0
- package/test/http-methods/propfind.test.js +136 -0
- package/test/http-methods/proppatch.test.js +105 -0
- package/test/http-methods/report.test.js +142 -0
- package/test/http-methods/search.test.js +233 -0
- package/test/http-methods/trace.test.js +21 -0
- package/test/http-methods/unlock.test.js +38 -0
- package/test/http2/closing.test.js +270 -0
- package/test/http2/constraint.test.js +109 -0
- package/test/http2/head.test.js +34 -0
- package/test/http2/plain.test.js +68 -0
- package/test/http2/secure-with-fallback.test.js +113 -0
- package/test/http2/secure.test.js +67 -0
- package/test/http2/unknown-http-method.test.js +34 -0
- package/test/https/custom-https-server.test.js +58 -0
- package/test/https/https.test.js +136 -0
- package/test/imports.test.js +17 -0
- package/test/inject.test.js +502 -0
- package/test/input-validation.js +335 -0
- package/test/internals/all.test.js +38 -0
- package/test/internals/content-type-parser.test.js +111 -0
- package/test/internals/context.test.js +31 -0
- package/test/internals/decorator.test.js +156 -0
- package/test/internals/errors.test.js +982 -0
- package/test/internals/handle-request.test.js +270 -0
- package/test/internals/hook-runner.test.js +449 -0
- package/test/internals/hooks.test.js +96 -0
- package/test/internals/initial-config.test.js +383 -0
- package/test/internals/logger.test.js +163 -0
- package/test/internals/plugin.test.js +170 -0
- package/test/internals/promise.test.js +63 -0
- package/test/internals/reply-serialize.test.js +714 -0
- package/test/internals/reply.test.js +1920 -0
- package/test/internals/req-id-gen-factory.test.js +133 -0
- package/test/internals/request-validate.test.js +1402 -0
- package/test/internals/request.test.js +506 -0
- package/test/internals/schema-controller-perf.test.js +40 -0
- package/test/internals/server.test.js +91 -0
- package/test/internals/validation.test.js +352 -0
- package/test/issue-4959.test.js +118 -0
- package/test/keep-alive-timeout.test.js +42 -0
- package/test/listen.1.test.js +154 -0
- package/test/listen.2.test.js +113 -0
- package/test/listen.3.test.js +83 -0
- package/test/listen.4.test.js +168 -0
- package/test/listen.5.test.js +122 -0
- package/test/logger/instantiation.test.js +341 -0
- package/test/logger/logger-test-utils.js +47 -0
- package/test/logger/logging.test.js +460 -0
- package/test/logger/options.test.js +579 -0
- package/test/logger/request.test.js +292 -0
- package/test/logger/response.test.js +183 -0
- package/test/logger/tap-parallel-not-ok +0 -0
- package/test/max-requests-per-socket.test.js +113 -0
- package/test/middleware.test.js +37 -0
- package/test/noop-set.test.js +19 -0
- package/test/nullable-validation.test.js +187 -0
- package/test/options.error-handler.test.js +5 -0
- package/test/options.test.js +5 -0
- package/test/output-validation.test.js +140 -0
- package/test/patch.error-handler.test.js +5 -0
- package/test/patch.test.js +5 -0
- package/test/plugin.1.test.js +230 -0
- package/test/plugin.2.test.js +314 -0
- package/test/plugin.3.test.js +287 -0
- package/test/plugin.4.test.js +504 -0
- package/test/plugin.helper.js +8 -0
- package/test/plugin.name.display.js +10 -0
- package/test/post-empty-body.test.js +38 -0
- package/test/pretty-print.test.js +366 -0
- package/test/promises.test.js +125 -0
- package/test/proto-poisoning.test.js +145 -0
- package/test/put.error-handler.test.js +5 -0
- package/test/put.test.js +5 -0
- package/test/register.test.js +184 -0
- package/test/reply-code.test.js +148 -0
- package/test/reply-early-hints.test.js +100 -0
- package/test/reply-error.test.js +815 -0
- package/test/reply-trailers.test.js +445 -0
- package/test/reply-web-stream-locked.test.js +37 -0
- package/test/request-error.test.js +624 -0
- package/test/request-header-host.test.js +339 -0
- package/test/request-id.test.js +118 -0
- package/test/request-timeout.test.js +53 -0
- package/test/route-hooks.test.js +635 -0
- package/test/route-prefix.test.js +904 -0
- package/test/route-shorthand.test.js +48 -0
- package/test/route.1.test.js +259 -0
- package/test/route.2.test.js +100 -0
- package/test/route.3.test.js +213 -0
- package/test/route.4.test.js +127 -0
- package/test/route.5.test.js +211 -0
- package/test/route.6.test.js +306 -0
- package/test/route.7.test.js +406 -0
- package/test/route.8.test.js +225 -0
- package/test/router-options.test.js +1108 -0
- package/test/same-shape.test.js +124 -0
- package/test/schema-examples.test.js +661 -0
- package/test/schema-feature.test.js +2198 -0
- package/test/schema-serialization.test.js +1171 -0
- package/test/schema-special-usage.test.js +1348 -0
- package/test/schema-validation.test.js +1572 -0
- package/test/scripts/validate-ecosystem-links.test.js +339 -0
- package/test/serialize-response.test.js +186 -0
- package/test/server.test.js +347 -0
- package/test/set-error-handler.test.js +69 -0
- package/test/skip-reply-send.test.js +317 -0
- package/test/stream-serializers.test.js +40 -0
- package/test/stream.1.test.js +94 -0
- package/test/stream.2.test.js +129 -0
- package/test/stream.3.test.js +198 -0
- package/test/stream.4.test.js +176 -0
- package/test/stream.5.test.js +188 -0
- package/test/sync-routes.test.js +32 -0
- package/test/throw.test.js +359 -0
- package/test/toolkit.js +63 -0
- package/test/trust-proxy.test.js +162 -0
- package/test/type-provider.test.js +22 -0
- package/test/types/content-type-parser.test-d.ts +72 -0
- package/test/types/decorate-request-reply.test-d.ts +18 -0
- package/test/types/dummy-plugin.ts +9 -0
- package/test/types/errors.test-d.ts +90 -0
- package/test/types/fastify.test-d.ts +352 -0
- package/test/types/hooks.test-d.ts +550 -0
- package/test/types/import.ts +2 -0
- package/test/types/instance.test-d.ts +588 -0
- package/test/types/logger.test-d.ts +277 -0
- package/test/types/plugin.test-d.ts +97 -0
- package/test/types/register.test-d.ts +237 -0
- package/test/types/reply.test-d.ts +254 -0
- package/test/types/request.test-d.ts +188 -0
- package/test/types/route.test-d.ts +553 -0
- package/test/types/schema.test-d.ts +135 -0
- package/test/types/serverFactory.test-d.ts +37 -0
- package/test/types/type-provider.test-d.ts +1213 -0
- package/test/types/using.test-d.ts +17 -0
- package/test/upgrade.test.js +52 -0
- package/test/url-rewriting.test.js +122 -0
- package/test/use-semicolon-delimiter.test.js +168 -0
- package/test/validation-error-handling.test.js +900 -0
- package/test/versioned-routes.test.js +603 -0
- package/test/web-api.test.js +616 -0
- package/test/wrap-thenable.test.js +30 -0
- package/types/content-type-parser.d.ts +75 -0
- package/types/context.d.ts +22 -0
- package/types/errors.d.ts +92 -0
- package/types/hooks.d.ts +875 -0
- package/types/instance.d.ts +609 -0
- package/types/logger.d.ts +107 -0
- package/types/plugin.d.ts +44 -0
- package/types/register.d.ts +42 -0
- package/types/reply.d.ts +81 -0
- package/types/request.d.ts +95 -0
- package/types/route.d.ts +199 -0
- package/types/schema.d.ts +61 -0
- package/types/server-factory.d.ts +19 -0
- package/types/type-provider.d.ts +130 -0
- package/types/utils.d.ts +98 -0
package/SECURITY.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
This document describes the management of vulnerabilities for the Fastify
|
|
4
|
+
project and its official plugins.
|
|
5
|
+
|
|
6
|
+
## Threat Model
|
|
7
|
+
|
|
8
|
+
Fastify's threat model extends the
|
|
9
|
+
[Node.js security policy](https://github.com/nodejs/node/blob/main/SECURITY.md).
|
|
10
|
+
|
|
11
|
+
**Trusted:** Application code (plugins, handlers, hooks, schemas), configuration,
|
|
12
|
+
and the runtime environment.
|
|
13
|
+
|
|
14
|
+
**Untrusted:** All network input (HTTP headers, body, query strings, URL
|
|
15
|
+
parameters).
|
|
16
|
+
|
|
17
|
+
Fastify assumes Node.js is running with `insecureHTTPParser: false` (the
|
|
18
|
+
secure default). Deployments that enable `insecureHTTPParser: true` are
|
|
19
|
+
outside Fastify's threat model.
|
|
20
|
+
|
|
21
|
+
### Examples of Vulnerabilities
|
|
22
|
+
|
|
23
|
+
- Parsing flaws that bypass validation or security controls
|
|
24
|
+
- DoS through malformed input to Fastify's core
|
|
25
|
+
- Bypasses of built-in protections (prototype poisoning, schema validation)
|
|
26
|
+
|
|
27
|
+
### Examples of Non-Vulnerabilities
|
|
28
|
+
|
|
29
|
+
The following are **not** considered vulnerabilities in Fastify:
|
|
30
|
+
|
|
31
|
+
- **Application code vulnerabilities**: XSS, SQL injection, or other flaws in
|
|
32
|
+
user-written route handlers, hooks, or plugins
|
|
33
|
+
- **Malicious application code**: Issues caused by intentionally malicious
|
|
34
|
+
plugins or handlers (application code is trusted)
|
|
35
|
+
- **Validation schema issues**: Weak or incorrect schemas provided by developers
|
|
36
|
+
(schemas are trusted)
|
|
37
|
+
- **ReDoS in user patterns**: Regular expression DoS in user-provided regex
|
|
38
|
+
patterns for routes or validation
|
|
39
|
+
- **Missing security features**: Lack of rate limiting, authentication, or
|
|
40
|
+
authorization (these are application-level concerns)
|
|
41
|
+
- **Configuration mistakes**: Security issues arising from developer
|
|
42
|
+
misconfiguration (configuration is trusted)
|
|
43
|
+
- **Content-type parser/schema mismatches**: When a custom content-type parser
|
|
44
|
+
registered with a regular expression (e.g., `/^application\/.*json$/`) matches
|
|
45
|
+
incoming requests that do not have a corresponding key in the route's
|
|
46
|
+
`schema.body.content` map, validation is skipped for that request. It is the
|
|
47
|
+
application's responsibility to ensure that every content type accepted by a
|
|
48
|
+
parser has a matching validation schema entry. This is a configuration concern,
|
|
49
|
+
not a framework vulnerability (see
|
|
50
|
+
[Validation and Serialization](./docs/Reference/Validation-and-Serialization.md)
|
|
51
|
+
and [Content-Type Parser](./docs/Reference/ContentTypeParser.md))
|
|
52
|
+
- **`insecureHTTPParser: true` deployments**: Reports that rely on enabling
|
|
53
|
+
Node.js `insecureHTTPParser` are out of scope; Fastify assumes this flag is
|
|
54
|
+
`false`
|
|
55
|
+
- **Third-party dependencies**: Vulnerabilities in npm packages used by the
|
|
56
|
+
application (not Fastify core dependencies)
|
|
57
|
+
- **Resource exhaustion from handlers**: DoS caused by expensive operations in
|
|
58
|
+
user route handlers
|
|
59
|
+
- **Information disclosure by design**: Exposing error details or stack traces
|
|
60
|
+
explicitly enabled via configuration options
|
|
61
|
+
|
|
62
|
+
## Reporting vulnerabilities
|
|
63
|
+
|
|
64
|
+
Individuals who find potential vulnerabilities in Fastify are invited to
|
|
65
|
+
complete a vulnerability report via the
|
|
66
|
+
[GitHub Security page](https://github.com/fastify/fastify/security/advisories/new).
|
|
67
|
+
|
|
68
|
+
Do not assign or request a CVE directly.
|
|
69
|
+
CVE assignment is handled by the Fastify Security Team.
|
|
70
|
+
Fastify falls under the [OpenJS CNA](https://cna.openjsf.org/).
|
|
71
|
+
A CVE will be assigned as part of our responsible disclosure process.
|
|
72
|
+
|
|
73
|
+
> ℹ️ Note:
|
|
74
|
+
> Fastify's [HackerOne](https://hackerone.com/fastify) program is now closed.
|
|
75
|
+
|
|
76
|
+
### Strict measures when reporting vulnerabilities
|
|
77
|
+
|
|
78
|
+
It is of the utmost importance that you read carefully and follow these
|
|
79
|
+
guidelines to ensure the ecosystem as a whole isn't disrupted due to improperly
|
|
80
|
+
reported vulnerabilities:
|
|
81
|
+
|
|
82
|
+
* Avoid creating new "informative" reports. Only create new
|
|
83
|
+
reports on a vulnerability if you are absolutely sure this should be
|
|
84
|
+
tagged as an actual vulnerability. Third-party vendors and individuals are
|
|
85
|
+
tracking any new vulnerabilities reported on GitHub and will flag
|
|
86
|
+
them as such for their customers (think about snyk, npm audit, ...).
|
|
87
|
+
* Security reports should never be created and triaged by the same person. If
|
|
88
|
+
you are creating a report for a vulnerability that you found, or on
|
|
89
|
+
behalf of someone else, there should always be a 2nd Security Team member who
|
|
90
|
+
triages it. If in doubt, invite more Fastify Collaborators to help triage the
|
|
91
|
+
validity of the report. In any case, the report should follow the same process
|
|
92
|
+
as outlined below of inviting the maintainers to review and accept the
|
|
93
|
+
vulnerability.
|
|
94
|
+
* ***Do not*** attempt to show CI/CD vulnerabilities by creating new pull
|
|
95
|
+
requests to any of the Fastify organization's repositories. Doing so will
|
|
96
|
+
result in a [content report][cr] to GitHub as an unsolicited exploit.
|
|
97
|
+
The proper way to provide such reports is by creating a new repository,
|
|
98
|
+
configured in the same manner as the repository you would like to submit
|
|
99
|
+
a report about, and with a pull request to your own repository showing
|
|
100
|
+
the proof of concept.
|
|
101
|
+
|
|
102
|
+
[cr]: https://docs.github.com/en/communities/maintaining-your-safety-on-github/reporting-abuse-or-spam#reporting-an-issue-or-pull-request
|
|
103
|
+
|
|
104
|
+
### Vulnerabilities found outside this process
|
|
105
|
+
|
|
106
|
+
⚠ The Fastify project does not support any reporting outside the process mentioned
|
|
107
|
+
in this document.
|
|
108
|
+
|
|
109
|
+
## Handling vulnerability reports
|
|
110
|
+
|
|
111
|
+
When a potential vulnerability is reported, the following actions are taken:
|
|
112
|
+
|
|
113
|
+
### Triage
|
|
114
|
+
|
|
115
|
+
**Delay:** 4 business days
|
|
116
|
+
|
|
117
|
+
Within 4 business days, a member of the security team provides a first answer to
|
|
118
|
+
the individual who submitted the potential vulnerability. The possible responses
|
|
119
|
+
can be:
|
|
120
|
+
|
|
121
|
+
* **Acceptance**: what was reported is considered as a new vulnerability
|
|
122
|
+
* **Rejection**: what was reported is not considered as a new vulnerability
|
|
123
|
+
* **Need more information**: the security team needs more information in order to
|
|
124
|
+
evaluate what was reported.
|
|
125
|
+
|
|
126
|
+
Triaging should include updating issue fields:
|
|
127
|
+
* Asset - set/create the module affected by the report
|
|
128
|
+
* Severity - TBD, currently left empty
|
|
129
|
+
|
|
130
|
+
### Correction follow-up
|
|
131
|
+
|
|
132
|
+
**Delay:** 90 days
|
|
133
|
+
|
|
134
|
+
When a vulnerability is confirmed, a member of the security team volunteers to
|
|
135
|
+
follow up on this report.
|
|
136
|
+
|
|
137
|
+
With the help of the individual who reported the vulnerability, they contact the
|
|
138
|
+
maintainers of the vulnerable package to make them aware of the vulnerability.
|
|
139
|
+
The maintainers can be invited as participants to the reported issue.
|
|
140
|
+
|
|
141
|
+
With the package maintainer, they define a release date for the publication of
|
|
142
|
+
the vulnerability. Ideally, this release date should not happen before the
|
|
143
|
+
package has been patched.
|
|
144
|
+
|
|
145
|
+
The report's vulnerable versions upper limit should be set to:
|
|
146
|
+
* `*` if there is no fixed version available by the time of publishing the
|
|
147
|
+
report.
|
|
148
|
+
* the last vulnerable version. For example: `<=1.2.3` if a fix exists in `1.2.4`
|
|
149
|
+
|
|
150
|
+
### Publication
|
|
151
|
+
|
|
152
|
+
**Delay:** 90 days
|
|
153
|
+
|
|
154
|
+
Within 90 days after the triage date, the vulnerability must be made public.
|
|
155
|
+
|
|
156
|
+
**Severity**: Vulnerability severity is assessed using [CVSS
|
|
157
|
+
v.3](https://www.first.org/cvss/user-guide).
|
|
158
|
+
|
|
159
|
+
If the package maintainer is actively developing a patch, an additional delay
|
|
160
|
+
can be added with the approval of the security team and the individual who
|
|
161
|
+
reported the vulnerability.
|
|
162
|
+
|
|
163
|
+
### Secondary Contact
|
|
164
|
+
|
|
165
|
+
If you do not receive an acknowledgment of your report within 6 business days,
|
|
166
|
+
or if you cannot find a private security contact for the project, you may
|
|
167
|
+
contact the OpenJS Foundation CNA at <https://cna.openjsf.org/> (or
|
|
168
|
+
`security@lists.openjsf.org`) for assistance.
|
|
169
|
+
|
|
170
|
+
The CNA can help ensure your report is properly acknowledged, assist with
|
|
171
|
+
coordinating disclosure timelines, and assign CVEs when necessary. This is a
|
|
172
|
+
support mechanism to ensure security reports are handled appropriately across
|
|
173
|
+
all OpenJS Foundation projects.
|
|
174
|
+
|
|
175
|
+
## The Fastify Security team
|
|
176
|
+
|
|
177
|
+
The core team is responsible for the management of the security program and
|
|
178
|
+
this policy and process.
|
|
179
|
+
|
|
180
|
+
Members of this team are expected to keep all information that they have
|
|
181
|
+
privileged access to by being on the team completely private to the team. This
|
|
182
|
+
includes agreeing to not notify anyone outside the team of issues that have not
|
|
183
|
+
yet been disclosed publicly, including the existence of issues, expectations of
|
|
184
|
+
upcoming releases, and patching of any issues other than in the process of their
|
|
185
|
+
work as a member of the Fastify Core team.
|
|
186
|
+
|
|
187
|
+
### Members
|
|
188
|
+
|
|
189
|
+
* [__Matteo Collina__](https://github.com/mcollina),
|
|
190
|
+
<https://x.com/matteocollina>, <https://www.npmjs.com/~matteo.collina>
|
|
191
|
+
* [__Tomas Della Vedova__](https://github.com/delvedor),
|
|
192
|
+
<https://x.com/delvedor>, <https://www.npmjs.com/~delvedor>
|
|
193
|
+
* [__Vincent Le Goff__](https://github.com/zekth)
|
|
194
|
+
* [__KaKa Ng__](https://github.com/climba03003)
|
|
195
|
+
* [__James Sumners__](https://github.com/jsumners),
|
|
196
|
+
<https://x.com/jsumners79>, <https://www.npmjs.com/~jsumners>
|
|
197
|
+
|
|
198
|
+
## OpenSSF CII Best Practices
|
|
199
|
+
|
|
200
|
+
[](https://www.bestpractices.dev/en/projects/7585/passing)
|
|
201
|
+
|
|
202
|
+
There are three “tiers”: passing, silver, and gold.
|
|
203
|
+
|
|
204
|
+
### Passing
|
|
205
|
+
We meet 100% of the “passing” criteria.
|
|
206
|
+
|
|
207
|
+
### Silver
|
|
208
|
+
We meet 87% of the "silver" criteria. The gaps are as follows:
|
|
209
|
+
- we do not have a DCO or a CLA process for contributions.
|
|
210
|
+
- we do not currently document "the architecture (aka high-level design)"
|
|
211
|
+
for our project.
|
|
212
|
+
|
|
213
|
+
### Gold
|
|
214
|
+
We meet 70% of the “gold” criteria. The gaps are as follows:
|
|
215
|
+
- we do not yet have the “silver” badge; see all the gaps above.
|
|
216
|
+
- We do not include a copyright or license statement in each source file.
|
|
217
|
+
Efforts are underway to change this archaic practice into a
|
|
218
|
+
suggestion instead of a hard requirement.
|
|
219
|
+
- There are a few unanswered questions around cryptography that are
|
|
220
|
+
waiting for clarification.
|
package/SPONSORS.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Sponsors
|
|
2
|
+
|
|
3
|
+
All active sponsors of Fastify are listed here, in order of contribution!
|
|
4
|
+
Our sponsors are the reason why we can work on some issues or features
|
|
5
|
+
that otherwise would be impossible to do.
|
|
6
|
+
|
|
7
|
+
If you want to become a sponsor, please check out our [Open Collective page](https://opencollective.com/fastify)
|
|
8
|
+
or [GitHub Sponsors](https://github.com/sponsors/fastify)!
|
|
9
|
+
|
|
10
|
+
## Tier 4
|
|
11
|
+
|
|
12
|
+
- [SerpApi](https://serpapi.com/?utm_source=fastify)
|
|
13
|
+
|
|
14
|
+
## Tier 3
|
|
15
|
+
|
|
16
|
+
- [Mercedes-Benz Group](https://github.com/mercedes-benz)
|
|
17
|
+
- [Val Town, Inc.](https://opencollective.com/valtown)
|
|
18
|
+
- [Handsontable - JavaScript Data Grid](https://handsontable.com/docs/react-data-grid/?utm_source=Fastify_GH&utm_medium=sponsorship&utm_campaign=library_sponsorship_2024)
|
|
19
|
+
- [Lokalise - A Localization and Translation Software Tool](https://lokalise.com/?utm_source=Fastify_GH&utm_medium=sponsorship)
|
|
20
|
+
- [TestMu AI](https://www.testmu.ai/)
|
|
21
|
+
|
|
22
|
+
## Tier 2
|
|
23
|
+
|
|
24
|
+
_Be the first!_
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* istanbul ignore file */
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
const FJS = require('fast-json-stringify')
|
|
5
|
+
const path = require('node:path')
|
|
6
|
+
const fs = require('node:fs')
|
|
7
|
+
|
|
8
|
+
const code = FJS({
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
statusCode: { type: 'number' },
|
|
12
|
+
code: { type: 'string' },
|
|
13
|
+
error: { type: 'string' },
|
|
14
|
+
message: { type: 'string' }
|
|
15
|
+
}
|
|
16
|
+
}, { mode: 'standalone' })
|
|
17
|
+
|
|
18
|
+
const file = path.join(__dirname, '..', 'lib', 'error-serializer.js')
|
|
19
|
+
|
|
20
|
+
const moduleCode = `// This file is autogenerated by build/build-error-serializer.js, do not edit
|
|
21
|
+
/* c8 ignore start */
|
|
22
|
+
${code}
|
|
23
|
+
/* c8 ignore stop */
|
|
24
|
+
`
|
|
25
|
+
|
|
26
|
+
/* c8 ignore start */
|
|
27
|
+
if (require.main === module) {
|
|
28
|
+
fs.writeFileSync(file, moduleCode)
|
|
29
|
+
console.log(`Saved ${file} file successfully`)
|
|
30
|
+
} else {
|
|
31
|
+
module.exports = {
|
|
32
|
+
code: moduleCode
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/* c8 ignore stop */
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const AjvStandaloneCompiler = require('@fastify/ajv-compiler/standalone')
|
|
4
|
+
const { _ } = require('ajv')
|
|
5
|
+
const fs = require('node:fs')
|
|
6
|
+
const path = require('node:path')
|
|
7
|
+
|
|
8
|
+
const factory = AjvStandaloneCompiler({
|
|
9
|
+
readMode: false,
|
|
10
|
+
storeFunction (routeOpts, schemaValidationCode) {
|
|
11
|
+
const moduleCode = `// This file is autogenerated by build/build-validation.js, do not edit
|
|
12
|
+
/* c8 ignore start */
|
|
13
|
+
${schemaValidationCode}
|
|
14
|
+
|
|
15
|
+
module.exports.defaultInitOptions = ${JSON.stringify(defaultInitOptions)}
|
|
16
|
+
/* c8 ignore stop */
|
|
17
|
+
`
|
|
18
|
+
|
|
19
|
+
const file = path.join(__dirname, '..', 'lib', 'config-validator.js')
|
|
20
|
+
fs.writeFileSync(file, moduleCode)
|
|
21
|
+
console.log(`Saved ${file} file successfully`)
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const defaultInitOptions = {
|
|
26
|
+
connectionTimeout: 0, // 0 sec
|
|
27
|
+
keepAliveTimeout: 72000, // 72 seconds
|
|
28
|
+
forceCloseConnections: undefined, // keep-alive connections
|
|
29
|
+
maxRequestsPerSocket: 0, // no limit
|
|
30
|
+
requestTimeout: 0, // no limit
|
|
31
|
+
handlerTimeout: 0, // no timeout (disabled by default)
|
|
32
|
+
bodyLimit: 1024 * 1024, // 1 MiB
|
|
33
|
+
caseSensitive: true,
|
|
34
|
+
allowUnsafeRegex: false,
|
|
35
|
+
disableRequestLogging: false,
|
|
36
|
+
ignoreTrailingSlash: false,
|
|
37
|
+
ignoreDuplicateSlashes: false,
|
|
38
|
+
maxParamLength: 100,
|
|
39
|
+
onProtoPoisoning: 'error',
|
|
40
|
+
onConstructorPoisoning: 'error',
|
|
41
|
+
pluginTimeout: 10000,
|
|
42
|
+
requestIdHeader: false,
|
|
43
|
+
requestIdLogLabel: 'reqId',
|
|
44
|
+
http2SessionTimeout: 72000, // 72 seconds
|
|
45
|
+
exposeHeadRoutes: true,
|
|
46
|
+
useSemicolonDelimiter: false,
|
|
47
|
+
allowErrorHandlerOverride: true, // TODO: set to false in v6
|
|
48
|
+
routerOptions: {
|
|
49
|
+
ignoreTrailingSlash: false,
|
|
50
|
+
ignoreDuplicateSlashes: false,
|
|
51
|
+
maxParamLength: 100,
|
|
52
|
+
allowUnsafeRegex: false,
|
|
53
|
+
useSemicolonDelimiter: false
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const schema = {
|
|
58
|
+
type: 'object',
|
|
59
|
+
additionalProperties: false,
|
|
60
|
+
properties: {
|
|
61
|
+
connectionTimeout: { type: 'integer', default: defaultInitOptions.connectionTimeout },
|
|
62
|
+
keepAliveTimeout: { type: 'integer', default: defaultInitOptions.keepAliveTimeout },
|
|
63
|
+
forceCloseConnections: {
|
|
64
|
+
oneOf: [
|
|
65
|
+
{
|
|
66
|
+
type: 'string',
|
|
67
|
+
pattern: 'idle'
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
type: 'boolean'
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
maxRequestsPerSocket: { type: 'integer', default: defaultInitOptions.maxRequestsPerSocket, nullable: true },
|
|
75
|
+
requestTimeout: { type: 'integer', default: defaultInitOptions.requestTimeout },
|
|
76
|
+
handlerTimeout: { type: 'integer', default: defaultInitOptions.handlerTimeout },
|
|
77
|
+
bodyLimit: { type: 'integer', default: defaultInitOptions.bodyLimit },
|
|
78
|
+
caseSensitive: { type: 'boolean', default: defaultInitOptions.caseSensitive },
|
|
79
|
+
allowUnsafeRegex: { type: 'boolean', default: defaultInitOptions.allowUnsafeRegex },
|
|
80
|
+
http2: { type: 'boolean' },
|
|
81
|
+
https: {
|
|
82
|
+
if: {
|
|
83
|
+
not: {
|
|
84
|
+
oneOf: [
|
|
85
|
+
{ type: 'boolean' },
|
|
86
|
+
{ type: 'null' },
|
|
87
|
+
{
|
|
88
|
+
type: 'object',
|
|
89
|
+
additionalProperties: false,
|
|
90
|
+
required: ['allowHTTP1'],
|
|
91
|
+
properties: {
|
|
92
|
+
allowHTTP1: { type: 'boolean' }
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
then: { setDefaultValue: true }
|
|
99
|
+
},
|
|
100
|
+
ignoreTrailingSlash: { type: 'boolean', default: defaultInitOptions.ignoreTrailingSlash },
|
|
101
|
+
ignoreDuplicateSlashes: { type: 'boolean', default: defaultInitOptions.ignoreDuplicateSlashes },
|
|
102
|
+
disableRequestLogging: {
|
|
103
|
+
default: false
|
|
104
|
+
},
|
|
105
|
+
maxParamLength: { type: 'integer', default: defaultInitOptions.maxParamLength },
|
|
106
|
+
onProtoPoisoning: { type: 'string', default: defaultInitOptions.onProtoPoisoning },
|
|
107
|
+
onConstructorPoisoning: { type: 'string', default: defaultInitOptions.onConstructorPoisoning },
|
|
108
|
+
pluginTimeout: { type: 'integer', default: defaultInitOptions.pluginTimeout },
|
|
109
|
+
requestIdHeader: { anyOf: [{ type: 'boolean' }, { type: 'string' }], default: defaultInitOptions.requestIdHeader },
|
|
110
|
+
requestIdLogLabel: { type: 'string', default: defaultInitOptions.requestIdLogLabel },
|
|
111
|
+
http2SessionTimeout: { type: 'integer', default: defaultInitOptions.http2SessionTimeout },
|
|
112
|
+
exposeHeadRoutes: { type: 'boolean', default: defaultInitOptions.exposeHeadRoutes },
|
|
113
|
+
useSemicolonDelimiter: { type: 'boolean', default: defaultInitOptions.useSemicolonDelimiter },
|
|
114
|
+
routerOptions: {
|
|
115
|
+
type: 'object',
|
|
116
|
+
additionalProperties: true,
|
|
117
|
+
properties: {
|
|
118
|
+
ignoreTrailingSlash: { type: 'boolean', default: defaultInitOptions.routerOptions.ignoreTrailingSlash },
|
|
119
|
+
ignoreDuplicateSlashes: { type: 'boolean', default: defaultInitOptions.routerOptions.ignoreDuplicateSlashes },
|
|
120
|
+
maxParamLength: { type: 'integer', default: defaultInitOptions.routerOptions.maxParamLength },
|
|
121
|
+
allowUnsafeRegex: { type: 'boolean', default: defaultInitOptions.routerOptions.allowUnsafeRegex },
|
|
122
|
+
useSemicolonDelimiter: { type: 'boolean', default: defaultInitOptions.routerOptions.useSemicolonDelimiter }
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
constraints: {
|
|
126
|
+
type: 'object',
|
|
127
|
+
additionalProperties: {
|
|
128
|
+
type: 'object',
|
|
129
|
+
required: ['name', 'storage', 'validate', 'deriveConstraint'],
|
|
130
|
+
additionalProperties: true,
|
|
131
|
+
properties: {
|
|
132
|
+
name: { type: 'string' },
|
|
133
|
+
storage: {},
|
|
134
|
+
validate: {},
|
|
135
|
+
deriveConstraint: {}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const compiler = factory({}, {
|
|
143
|
+
customOptions: {
|
|
144
|
+
code: {
|
|
145
|
+
source: true,
|
|
146
|
+
lines: true,
|
|
147
|
+
optimize: 3
|
|
148
|
+
},
|
|
149
|
+
removeAdditional: true,
|
|
150
|
+
useDefaults: true,
|
|
151
|
+
coerceTypes: true,
|
|
152
|
+
keywords: [
|
|
153
|
+
{
|
|
154
|
+
keyword: 'setDefaultValue',
|
|
155
|
+
$data: true,
|
|
156
|
+
// error: false,
|
|
157
|
+
modifying: true,
|
|
158
|
+
valid: true,
|
|
159
|
+
code (keywordCxt) {
|
|
160
|
+
const { gen, it, schemaValue } = keywordCxt
|
|
161
|
+
const logicCode = gen.assign(_`${it.parentData}[${it.parentDataProperty}]`, schemaValue)
|
|
162
|
+
return logicCode
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
compiler({ schema })
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs')
|
|
4
|
+
const path = require('node:path')
|
|
5
|
+
|
|
6
|
+
// package.json:version -> fastify.js:VERSION
|
|
7
|
+
const { version } = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json')).toString('utf8'))
|
|
8
|
+
|
|
9
|
+
const fastifyJs = path.join(__dirname, '..', 'fastify.js')
|
|
10
|
+
|
|
11
|
+
fs.writeFileSync(fastifyJs, fs.readFileSync(fastifyJs).toString('utf8').replace(/const\s*VERSION\s*=.*/, `const VERSION = '${version}'`))
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<h1 align="center">Fastify</h1>
|
|
2
|
+
|
|
3
|
+
## Benchmarking
|
|
4
|
+
Benchmarking is important if you want to measure how a change can affect your
|
|
5
|
+
application's performance. We provide a simple way to benchmark your
|
|
6
|
+
application from the point of view of a user and contributor. The setup allows
|
|
7
|
+
you to automate benchmarks in different branches and on different Node.js
|
|
8
|
+
versions.
|
|
9
|
+
|
|
10
|
+
The modules we will use:
|
|
11
|
+
- [Autocannon](https://github.com/mcollina/autocannon): An HTTP/1.1 benchmarking
|
|
12
|
+
tool written in node.
|
|
13
|
+
- [Branch-comparer](https://github.com/StarpTech/branch-comparer): Checkout
|
|
14
|
+
multiple git branches, execute scripts, and log the results.
|
|
15
|
+
- [Concurrently](https://github.com/open-cli-tools/concurrently): Run commands
|
|
16
|
+
concurrently.
|
|
17
|
+
- [Npx](https://github.com/npm/npx): NPM package runner used to run scripts
|
|
18
|
+
against different Node.js Versions and execute local binaries. Shipped with
|
|
19
|
+
npm@5.2.0.
|
|
20
|
+
|
|
21
|
+
## Simple
|
|
22
|
+
|
|
23
|
+
### Run the test in the current branch
|
|
24
|
+
```sh
|
|
25
|
+
npm run benchmark
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Run the test against different Node.js versions ✨
|
|
29
|
+
```sh
|
|
30
|
+
npx -p node@10 -- npm run benchmark
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Advanced
|
|
34
|
+
|
|
35
|
+
### Run the test in different branches
|
|
36
|
+
```sh
|
|
37
|
+
branchcmp --rounds 2 --script "npm run benchmark"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Run the test in different branches against different Node.js versions ✨
|
|
41
|
+
```sh
|
|
42
|
+
branchcmp --rounds 2 --script "npm run benchmark"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Compare current branch with main (Gitflow)
|
|
46
|
+
```sh
|
|
47
|
+
branchcmp --rounds 2 --gitflow --script "npm run benchmark"
|
|
48
|
+
```
|
|
49
|
+
or
|
|
50
|
+
```sh
|
|
51
|
+
npm run bench
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Run different examples
|
|
55
|
+
|
|
56
|
+
<!-- markdownlint-disable -->
|
|
57
|
+
```sh
|
|
58
|
+
branchcmp --rounds 2 -s "node ./node_modules/concurrently -k -s first \"node ./examples/asyncawait.js\" \"node ./node_modules/autocannon -c 100 -d 5 -p 10 localhost:3000/\""
|
|
59
|
+
```
|
|
60
|
+
<!-- markdownlint-enable -->
|