-
Notifications
You must be signed in to change notification settings - Fork 241
Description
Ajv is currently used in httpsnippet for validating the HAR schema passed. Using complete Ajv dependency makes httpsnippet require 'unsafe-eval in the CSP policy, which is a security concern. (https://github.com/ajv-validator/ajv/blob/c3e203c2696e42ec107fe6a5a659fca54b2e4993/docs/security.md#content-security-policy).
As a workaround, since the schema for HAR is known (and already included), it can be pre-compiled into a validation function as part of the build. The Ajv Docs have details on the same.
This would move Ajv from a runtime dependency to a optional developer-dependency (as Ajv-cli) - only needed when har-schema is updated. This would bring a lot more benefits, including performance and bundle size improvements.
This request comes via the Stoplight Elements project, which uses httpsnippet internally. Since httpsnippet doesn't offer a way to pre-compile schemas, this ends up breaking Elements in configurations which limit unsafe-eval via CSP.