Skip to content

Commit

Permalink
fix(security): allow more strict CSP for SVG assets (#9209)
Browse files Browse the repository at this point in the history
Refs #7540
  • Loading branch information
char0n committed Sep 14, 2023
1 parent efe6133 commit b7f5331
Show file tree
Hide file tree
Showing 8 changed files with 605 additions and 62 deletions.
1 change: 1 addition & 0 deletions dev-helpers/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Security-Policy" content="img-src 'self'" />
<title>Swagger UI</title>
<link rel="stylesheet" type="text/css" href="style.css">
<style>
Expand Down
642 changes: 586 additions & 56 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"@jest/globals": "=29.6.4",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
"@release-it/conventional-changelog": "=5.1.0",
"@svgr/webpack": "=8.1.0",
"@wojtekmaj/enzyme-adapter-react-17": "=0.8.0",
"autoprefixer": "^10.4.15",
"babel-loader": "^9.1.3",
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/model.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default class Model extends ImmutablePureComponent {
if(!schema) {
return <span className="model model-title">
<span className="model-title__text">{ displayName || name }</span>
<img src={RollingLoadSVG} height={"20px"} width={"20px"} />
<RollingLoadSVG height="20px" width="20px" />
</span>
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/components/operation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default class Operation extends PureComponent {
<Collapse isOpened={isShown}>
<div className="opblock-body">
{ (operation && operation.size) || operation === null ? null :
<img height={"32px"} width={"32px"} src={RollingLoadSVG} className="opblock-loading-animation" />
<RollingLoadSVG height="32px" width="32px" className="opblock-loading-animation" />
}
{ deprecated && <h4 className="opblock-title_normal"> Warning: Deprecated</h4>}
{ description &&
Expand Down
2 changes: 1 addition & 1 deletion src/standalone/plugins/top-bar/components/Logo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
import React from "react"
import SwaggerUILogo from "../assets/logo_small.svg"

const Logo = () => <img height="40" src={SwaggerUILogo} alt="Swagger UI" />
const Logo = () => <SwaggerUILogo height="40" />

export default Logo
11 changes: 9 additions & 2 deletions webpack/_config-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,16 @@ const baseRules = [
cacheDirectory: true,
},
},
{ test: /\.(txt|yaml)$/, type: "asset/source" },
{
test: /\.(png|jpg|jpeg|gif|svg)$/,
test: /\.(txt|yaml)$/,
type: "asset/source",
},
{
test: /\.svg$/,
use: ["@svgr/webpack"],
},
{
test: /\.(png|jpg|jpeg|gif)$/,
type: "asset/inline",
},
]
Expand Down
6 changes: 5 additions & 1 deletion webpack/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ const devConfig = configBuilder(
type: "asset/source",
},
{
test: /\.(png|jpg|jpeg|gif|svg)$/,
test: /\.svg$/,
use: ["@svgr/webpack"],
},
{
test: /\.(png|jpg|jpeg|gif)$/,
type: "asset/inline",
},
],
Expand Down

0 comments on commit b7f5331

Please sign in to comment.