Skip to content

Commit cf18035

Browse files
authored
Merge pull request #95 from Team-INSERT/hotfix/xxs
XSS 보안
2 parents 8ad2460 + 4353750 commit cf18035

File tree

4 files changed

+61
-2
lines changed

4 files changed

+61
-2
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@typescript-eslint/eslint-plugin": "^5.43.0",
2626
"@uiw/react-markdown-preview": "^4.1.16",
2727
"@uiw/react-md-editor": "3.6.0",
28+
"apollo-link-token-refresh": "^0.6.0",
2829
"axios": "^1.4.0",
2930
"babel-loader": "^9.1.3",
3031
"babel-plugin-styled-components": "^2.1.4",
@@ -37,6 +38,7 @@
3738
"eslint-plugin-prettier": "^4.2.1",
3839
"graphql": "^16.8.0",
3940
"jest": "^29.3.1",
41+
"jwt-decode": "^3.1.2",
4042
"msw": "^1.2.3",
4143
"next": "13.5.2",
4244
"next-remove-imports": "^1.0.12",
@@ -53,6 +55,7 @@
5355
"react-spinners": "^0.13.8",
5456
"react-toastify": "^9.1.3",
5557
"recoil": "^0.7.7",
58+
"rehype-sanitize": "^6.0.0",
5659
"slick-carousel": "^1.8.1",
5760
"styled-components": "^6.0.8",
5861
"sweetalert2": "^11.7.28",

src/components/atoms/CustomEditor.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import MDEditor, {
88
MDEditorProps,
99
getCommands,
1010
} from "@uiw/react-md-editor";
11+
import rehypeSanitize from "rehype-sanitize";
1112
import { UploadIcon } from "@/assets/icons";
1213
import { getImageUrl } from "@/helpers";
1314
import useModal from "@/hooks/useModal";
@@ -53,6 +54,9 @@ const CustomEditor = ({ ...props }: ICustomEditorProps) => {
5354
{...props}
5455
preview="edit"
5556
commands={[...getCommands(), imageUploader]}
57+
previewOptions={{
58+
rehypePlugins: [[rehypeSanitize]],
59+
}}
5660
/>
5761
);
5862
};

src/components/atoms/CustomViewer.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
22
import MDViewer from "@uiw/react-markdown-preview";
3-
import { getXSSContent } from "@/helpers";
3+
import rehypeSanitize from "rehype-sanitize";
44

55
interface MDViewerPropsType {
66
content?: string;
@@ -9,10 +9,11 @@ interface MDViewerPropsType {
99
const CustomViewer = ({ content }: MDViewerPropsType) => {
1010
return (
1111
<MDViewer
12-
source={getXSSContent(content)}
12+
source={content}
1313
wrapperElement={{
1414
"data-color-mode": "light",
1515
}}
16+
rehypePlugins={[rehypeSanitize]}
1617
/>
1718
);
1819
};

yarn.lock

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2469,6 +2469,13 @@
24692469
dependencies:
24702470
"@types/unist" "^2"
24712471

2472+
"@types/hast@^3.0.0":
2473+
version "3.0.1"
2474+
resolved "https://registry.yarnpkg.com/@types/hast/-/hast-3.0.1.tgz#e1705ec9258ac4885659c2d50bac06b4fcd16466"
2475+
integrity sha512-hs/iBJx2aydugBQx5ETV3ZgeSS0oIreQrFJ4bjBl0XvM4wAmDjFEALY7p0rTSLt2eL+ibjRAAs9dTPiCLtmbqQ==
2476+
dependencies:
2477+
"@types/unist" "*"
2478+
24722479
"@types/hoist-non-react-statics@*":
24732480
version "3.3.2"
24742481
resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#dc1e9ded53375d37603c479cc12c693b0878aa2a"
@@ -2698,6 +2705,11 @@
26982705
resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-4.0.3.tgz#3d06b6769518450871fbc40770b7586334bdfd90"
26992706
integrity sha512-THo502dA5PzG/sfQH+42Lw3fvmYkceefOspdCwpHRul8ik2Jv1K8I5OZz1AT3/rs46kwgMCe9bSBmDLYkkOMGg==
27002707

2708+
"@types/unist@*", "@types/unist@^3.0.0":
2709+
version "3.0.0"
2710+
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-3.0.0.tgz#988ae8af1e5239e89f9fbb1ade4c935f4eeedf9a"
2711+
integrity sha512-MFETx3tbTjE7Uk6vvnWINA/1iJ7LuMdO4fcq8UfF0pRbj01aGLduVvQcRyswuACJdpnHgg8E3rQLhaRdNEJS0w==
2712+
27012713
"@types/unist@^2", "@types/unist@^2.0.0", "@types/unist@^2.0.2", "@types/unist@^2.0.3":
27022714
version "2.0.8"
27032715
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.8.tgz#bb197b9639aa1a04cf464a617fe800cccd92ad5c"
@@ -2845,6 +2857,11 @@
28452857
"@uiw/react-markdown-preview" "3.3.0"
28462858
rehype "12.0.0"
28472859

2860+
"@ungap/structured-clone@^1.2.0":
2861+
version "1.2.0"
2862+
resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.2.0.tgz#756641adb587851b5ccb3e095daf27ae581c8406"
2863+
integrity sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==
2864+
28482865
"@wry/context@^0.7.0", "@wry/context@^0.7.3":
28492866
version "0.7.3"
28502867
resolved "https://registry.yarnpkg.com/@wry/context/-/context-0.7.3.tgz#240f6dfd4db5ef54f81f6597f6714e58d4f476a1"
@@ -3037,6 +3054,11 @@ anymatch@^3.0.3, anymatch@~3.1.2:
30373054
normalize-path "^3.0.0"
30383055
picomatch "^2.0.4"
30393056

3057+
apollo-link-token-refresh@^0.6.0:
3058+
version "0.6.0"
3059+
resolved "https://registry.yarnpkg.com/apollo-link-token-refresh/-/apollo-link-token-refresh-0.6.0.tgz#5bea13bd672ce5118685610554d7c76ff953de26"
3060+
integrity sha512-WT1Z1cpuB74PFRA/xRU3LR2c9lz4Rc3BlsFRe3xa7yKIJQLSlkT+oecb0iYUPPU/9rJuxNKNLcFBKvXdLTvmug==
3061+
30403062
"aproba@^1.0.3 || ^2.0.0", aproba@^2.0.0:
30413063
version "2.0.0"
30423064
resolved "https://registry.yarnpkg.com/aproba/-/aproba-2.0.0.tgz#52520b8ae5b569215b354efc0caa3fe1e45a8adc"
@@ -5812,6 +5834,15 @@ hast-util-raw@^7.0.0, hast-util-raw@^7.2.0:
58125834
web-namespaces "^2.0.0"
58135835
zwitch "^2.0.0"
58145836

5837+
hast-util-sanitize@^5.0.0:
5838+
version "5.0.0"
5839+
resolved "https://registry.yarnpkg.com/hast-util-sanitize/-/hast-util-sanitize-5.0.0.tgz#041ef2247fe8f34b5f2bb4398c545e465e5a8c0e"
5840+
integrity sha512-L0g/qhOA82zG2hA3O29hnlv4mLU7YVVT1if5JZSr2tKO1ywkQbuMDcN05btgX0HtpqDXQniAM0ar0K+Lv4MDBQ==
5841+
dependencies:
5842+
"@types/hast" "^3.0.0"
5843+
"@ungap/structured-clone" "^1.2.0"
5844+
unist-util-position "^5.0.0"
5845+
58155846
hast-util-select@^5.0.5, hast-util-select@~5.0.1:
58165847
version "5.0.5"
58175848
resolved "https://registry.yarnpkg.com/hast-util-select/-/hast-util-select-5.0.5.tgz#be9ccb71d2278681ca024727f12abd4f93b3e9bc"
@@ -7140,6 +7171,11 @@ just-diff@^5.0.1:
71407171
resolved "https://registry.yarnpkg.com/just-diff/-/just-diff-5.2.0.tgz#60dca55891cf24cd4a094e33504660692348a241"
71417172
integrity sha512-6ufhP9SHjb7jibNFrNxyFZ6od3g+An6Ai9mhGRvcYe8UJlH0prseN64M+6ZBBUoKYHZsitDP42gAJ8+eVWr3lw==
71427173

7174+
jwt-decode@^3.1.2:
7175+
version "3.1.2"
7176+
resolved "https://registry.yarnpkg.com/jwt-decode/-/jwt-decode-3.1.2.tgz#3fb319f3675a2df0c2895c8f5e9fa4b67b04ed59"
7177+
integrity sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A==
7178+
71437179
keyv@^4.5.3:
71447180
version "4.5.3"
71457181
resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.3.tgz#00873d2b046df737963157bd04f294ca818c9c25"
@@ -9678,6 +9714,14 @@ rehype-rewrite@~3.0.6:
96789714
unified "~10.1.1"
96799715
unist-util-visit "~4.1.0"
96809716

9717+
rehype-sanitize@^6.0.0:
9718+
version "6.0.0"
9719+
resolved "https://registry.yarnpkg.com/rehype-sanitize/-/rehype-sanitize-6.0.0.tgz#16e95f4a67a69cbf0f79e113c8e0df48203db73c"
9720+
integrity sha512-CsnhKNsyI8Tub6L4sm5ZFsme4puGfc6pYylvXo1AeqaGbjOYyzNv3qZPwvs0oMJ39eryyeOdmxwUIo94IpEhqg==
9721+
dependencies:
9722+
"@types/hast" "^3.0.0"
9723+
hast-util-sanitize "^5.0.0"
9724+
96819725
96829726
version "5.0.0"
96839727
resolved "https://registry.yarnpkg.com/rehype-slug/-/rehype-slug-5.0.0.tgz#dfafa1d11577e206970f2d0de023f8490a99dc31"
@@ -10934,6 +10978,13 @@ unist-util-position@^4.0.0:
1093410978
dependencies:
1093510979
"@types/unist" "^2.0.0"
1093610980

10981+
unist-util-position@^5.0.0:
10982+
version "5.0.0"
10983+
resolved "https://registry.yarnpkg.com/unist-util-position/-/unist-util-position-5.0.0.tgz#678f20ab5ca1207a97d7ea8a388373c9cf896be4"
10984+
integrity sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==
10985+
dependencies:
10986+
"@types/unist" "^3.0.0"
10987+
1093710988
unist-util-stringify-position@^2.0.0:
1093810989
version "2.0.3"
1093910990
resolved "https://registry.yarnpkg.com/unist-util-stringify-position/-/unist-util-stringify-position-2.0.3.tgz#cce3bfa1cdf85ba7375d1d5b17bdc4cada9bd9da"

0 commit comments

Comments
 (0)