rstudio / rstudio/bslib

Removal of inline scripts to make it easier to implement strict CSP against XSS attacks

Open
#1,122 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
SCSS
Stars
569
Forks
72
Avg merge
1d 2h
Merged PRs (30d)
5

Description

For example, every bslib::card() will create some inline javascript, calling bslib.Card.initializeAllCards() (see below). Would it be possible to move this function call to an external JS file and calling it with something like <script src=''></script> instead?

Removing as many inline scripts as possible would make it easier to set a strict Content Security Policy when serving a shiny application, and setting such a policy greatly improves security against XSS attacks. I am not sure if this is possible, but I thought it is worth a try to ask.

cat(format(bslib::card()))
<div class="card bslib-card bslib-mb-spacing html-fill-item html-fill-container" data-bslib-card-init data-require-bs-caller="card()" data-require-bs-version="5">
  <script data-bslib-card-init>bslib.Card.initializeAllCards();</script>
</div>

Contributor guide

No contributing guide indexed for this repository

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 with the HTML emitted by bslib::card() and trace the bslib.Card.initializeAllCards() call shown in the issue. Identify the existing JavaScript entry point or asset-loading path, then verify that card initialization works without an inline script under a strict Content Security Policy.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, r
Domain
frontend, security
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.