redhat-developer / redhat-developer/yaml-language-server

Use ajv standalone mode for schema validation

Open
#1,089 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.5k
Forks
352
Avg merge
2d 7h
Merged PRs (30d)
11

Description

Is your enhancement related to a problem? Please describe.

Yaml language server currently uses ajv.compile for schema validation here: https://github.com/redhat-developer/yaml-language-server/blob/main/src/languageservice/services/yamlSchemaService.ts#L41 . This works fine, except for the cases, when unsafe-eval is disabled by CSP. This makes the language server unusable in this context. There are also a few discussions about that for ajv (for example https://github.com/ajv-validator/ajv/issues/406).

Describe the solution you would like

AJV supports standalone mode https://ajv.js.org/standalone.html where a validation function is generated at compile time and doesn't rely on dynamic compilation anymore. I propose to switch the language server to use the standalone mode which would allow the server to work with strict CSP policies.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/languageservice/services/yamlSchemaService.ts:41 and read AJV's standalone mode documentation. Trace how schema validators are compiled and loaded, then verify the language server validates schemas under a CSP that disables unsafe-eval without changing existing validation behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.