LC-2853 admin 블로그 글 에디터 개선 1#2132
Hidden character warning
Conversation
이미지 클릭 시 나타나는 리사이저 UI에 링크 버튼을 추가하여, 드래그 선택 없이도 이미지에 링크를 삽입/수정/제거할 수 있도록 개선 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary of ChangesHello @hyonun321, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 관리자 블로그 글 에디터의 사용자 경험을 개선하기 위해 이미지에 링크를 추가하고 관리하는 기능을 도입합니다. 또한, 이미지 관련 액션 버튼들의 레이아웃을 개선하고, 에디터 내 단락 간의 시각적 구분을 명확히 하여 전반적인 글쓰기 환경을 향상시키는 데 중점을 둡니다. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This PR implements the functionality to add and edit links to images in the admin blog editor. While this is a good improvement, a high-severity stored Cross-Site Scripting (XSS) vulnerability has been identified. User-supplied URLs for image links are not being sanitized, which allows for the injection of malicious javascript: payloads. Additionally, it is recommended to replace window.prompt with a custom modal for URL input to provide a consistent UI and facilitate better URL validation, which would also help mitigate the XSS vulnerability.
| const url = window.prompt('링크 URL을 입력하세요', currentUrl); | ||
| if (url === null) return; | ||
|
|
||
| editor.update(() => { | ||
| const node = $getNodeByKey(nodeKey); | ||
| if (!node) return; | ||
| const parent = node.getParent(); | ||
| if (!parent) return; | ||
|
|
||
| if (url === '') { | ||
| // 링크 제거: LinkNode를 벗기고 자식을 꺼냄 | ||
| if ($isLinkNode(parent)) { | ||
| const children = parent.getChildren(); | ||
| for (const child of children) { | ||
| parent.insertBefore(child); | ||
| } | ||
| parent.remove(); | ||
| } | ||
| } else if ($isLinkNode(parent)) { | ||
| // 기존 링크 URL 수정 | ||
| parent.setURL(url); | ||
| } else { | ||
| // 새 링크 추가: LinkNode로 이미지를 감쌈 | ||
| const linkNode = $createLinkNode(url); | ||
| node.insertBefore(linkNode); | ||
| linkNode.append(node); | ||
| } |
There was a problem hiding this comment.
A stored Cross-Site Scripting (XSS) vulnerability exists in the handleLinkClick function. The application uses window.prompt to get a URL from the user to add a link to an image. The input from this prompt is not sanitized before being used to create or update a LinkNode. An attacker can input a malicious URL containing a javascript: payload (e.g., javascript:alert('XSS')). This payload is then stored as part of the editor's content, leading to arbitrary code execution when clicked. Beyond the security risk, using window.prompt negatively impacts user experience due to inconsistent UI and lack of styling options. It also makes it difficult to add robust URL validation. It is strongly recommended to replace window.prompt with a custom modal (e.g., using useModal) for a consistent UI/UX and to integrate proper URL validation, similar to validateUrl in LinkPlugin, to prevent such vulnerabilities.
const url = window.prompt('링크 URL을 입력하세요', currentUrl);
if (url === null) return;
// TODO: Import a URL sanitization function
const sanitizedUrl = new URL(url).href.startsWith('javascript:') ? '' : url;
editor.update(() => {
const node = $getNodeByKey(nodeKey);
if (!node) return;
const parent = node.getParent();
if (!parent) return;
if (sanitizedUrl === '') {
// 링크 제거: LinkNode를 벗기고 자식을 꺼냄
if ($isLinkNode(parent)) {
const children = parent.getChildren();
for (const child of children) {
parent.insertBefore(child);
}
parent.remove();
}
} else if ($isLinkNode(parent)) {
// 기존 링크 URL 수정
parent.setURL(sanitizedUrl);
} else {
// 새 링크 추가: LinkNode로 이미지를 감쌈
const linkNode = $createLinkNode(sanitizedUrl);
node.insertBefore(linkNode);
linkNode.append(node);
}
});
연관 작업