Don't render playground code by default
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 22.2k
- Forks
- 1.9k
- PR merge metrics
- PR metrics pending
Description
Problem
A security and privacy improvement would be that the playground code in theme/book.js is not rendered to book/book.js upon build if not explicitly enabled in book.toml.
It is a security enhancement because it lowers the attack surface for remote code execution. Even if user sets runnable = false under [output.html.playground] the code is still available in rendered book.js, disabling it (if having Rust code) currently only removes <pre class="playground"> as mentioned in #2897 , i.e. it does not matter what type of book it is, if only using markdown that code is still there by default.
It is a privacy benefit because if using playgrounds, the rust code gets sent to a third party server. Having it disabled by default would make it possible to add to documentation that enabling this feature sends the rust code to a third party server, so only those comfortable with this will enable it.
Current workaround is to comment out playground code in themes/book.js as mentioned in #2887 .
Proposed Solution
There should be a value in book.toml which by default is set to false and this makes so no playground code is rendered in book/book.js.
Notes
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the playground code in themes/book.js and the generated book/book.js, then trace how book.toml options under [output.html.playground] are handled during the build. Done means playground code is omitted by default, while an explicit configuration enables its rendering; add or update coverage for both behaviors if the existing project structure provides it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, rust
- Domain
- build-system, security
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100