loopbackio / loopbackio/loopback.io

Explorer violates content-security-policy: default-src 'self'

Offen
#1,783 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
HTML
Sterne
276
Forks
382
Ø Merge
6 Std. 17 Min.
Gemergte PRs (30 T.)
18

Beschreibung

URL of the page

https://localhost:3000/api/explorer/

Nature of the issue

If the API is served by an Ingress that implements this Response Header:
content-security-policy: default-src 'self'
the api explorer fails to load

Expected behavior

No errors when running with restrictive content-security-policy.

Actual behavior

The following errors appear in the console of Goole Chrome:

explorer/:11 Refused to apply inline style because it violates the following Content Security Policy directive: "default-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-R1cfim84YiZ+NisBAfyCbdN3fV7Y7Uys20qAO4OBGJ0='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'style-src' was not explicitly set, so 'default-src' is used as a fallback.

explorer/:36 Refused to execute inline script because it violates the following Content Security Policy directive: "default-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-DLbdWNBhwD1fyzUBjaE5Up3Y/4UCDB1OYv/c61qHL/I='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.

These occur because the HTML contains a <style> and a <script> tag respectively.

Suggested resolution

Move the <style> and <script> contents to separate files.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie auf der API Explorer-Seite unter /api/explorer/ und untersuchen Sie das HTML auf seine inline style- und script-Elemente. Verschieben Sie deren Inhalte in separate Dateien und überprüfen Sie, dass die Seite unter default-src 'self' ohne Konsolenfehler geladen wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
css, html, javascript
Bereich
frontend, security, web-dev
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.