Skip to content

AJV schema validation functions should be pre-compiled to avoid unsafe-eval CSP requirement #423

Closed
@hrobertson

Description

@hrobertson

Describe the Bug
Compiling the AJV schema validation functions at runtime uses new new Function which requires the CSP script-src to include 'unsafe-eval'.

Instead, the schema validation functions should be pre-compiled.

Steps to Reproduce

  1. Use the cloudevents/sdk-javascript library in a site with a CSP with script-src not including 'unsafe-eval'
  2. Use new CloudEvent(...)
  3. Observe CSP error

Expected Behavior
The library should be able to be used successfully without including 'unsafe-eval' in your CSP.

Additional context
See https://github.com/ajv-validator/ajv/blob/master/docs/security.md#content-security-policy

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions