Skip to content

prettier: initial integration#15502

Open
rootvector2 wants to merge 1 commit into
google:masterfrom
rootvector2:prettier--initial-integration
Open

prettier: initial integration#15502
rootvector2 wants to merge 1 commit into
google:masterfrom
rootvector2:prettier--initial-integration

Conversation

@rootvector2
Copy link
Copy Markdown
Contributor

Adds an initial OSS-Fuzz integration for Prettier, the opinionated code formatter used across a huge slice of the JS/TS/CSS/Markdown/JSON/YAML ecosystem.

The setup follows the Jazzer.js pattern used by the existing JavaScript projects in this repo (typescript, js-yaml, fast-xml-parser, etc.).

Fuzz targets

Five targets, each one wrapped around prettier.format() for a parser family, with formatting options pulled from FuzzedDataProvider:

  • fuzz_format_jsbabel, babel-flow, acorn, espree, meriyah, flow
  • fuzz_format_tstypescript, babel-ts
  • fuzz_format_csscss, scss, less
  • fuzz_format_jsonjson, json5, jsonc, json-stringify
  • fuzz_format_mdmarkdown, mdx, remark

Expected parse failures (SyntaxError, "Unexpected token", "Unterminated …", etc.) are filtered out so the fuzzers only surface unexpected exceptions and crashes.

A couple of things worth flagging

  • The fuzz targets live in a fuzz_targets/ subdirectory with its own tiny package.json declaring "type": "commonjs". Prettier's own package.json sets "type": "module", which would otherwise make Node load every .js file in the repo as ESM and break the CommonJS require() calls in the fuzzers.
  • @jazzer.js/core is pinned to 2.1.0. The freshly released 4.0.0 ships a prebuilt native addon that needs GLIBC_2.32, which isn't available yet in base-builder-javascript (Ubuntu 20.04, glibc 2.31). Once the base image is bumped this pin can go away.
  • Since Prettier v3 format() is async, the targets are written as async function and --sync is not passed to compile_javascript_fuzzer.

Test plan

  • docker build of the project image succeeds
  • All five fuzzers compile under base-builder-javascript
  • Each fuzzer starts and runs cleanly; fuzz_format_js and fuzz_format_json produce non-trivial coverage in a short local run

@github-actions
Copy link
Copy Markdown

rootvector2 is integrating a new project:
- Main repo: https://github.com/prettier/prettier
- Criticality score: 0.67392

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant