loopbackio / loopbackio/loopback.io
Explorer violates content-security-policy: default-src 'self'
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- HTML
- Star
- 276
- Fork
- 382
- Merge trung bình
- 6 giờ 17 phút
- Pull request đã merge (30 ngày)
- 18
Mô tả
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.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu tại trang API Explorer được phục vụ ở /api/explorer/ và kiểm tra HTML để tìm các phần tử inline style và script của trang. Chuyển nội dung đó vào các tệp riêng biệt và xác minh rằng trang tải mà không có lỗi trong console dưới default-src 'self'.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- css, html, javascript
- Lĩnh vực
- frontend, security, web-dev
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100