Skip to content

Pre-compile HAR schema for validation #270

@captn3m0

Description

@captn3m0

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions