-
Notifications
You must be signed in to change notification settings - Fork 6
Preview/semgrep #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preview/semgrep #62
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
reviews: | ||
path_filters: ["**/*","*"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
function TestComponent() { | ||
// ruleid:react-dangerouslysetinnerhtml | ||
return <div dangerouslySetInnerHTML={createMarkup()} />; | ||
} | ||
Comment on lines
+1
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing function definition. The +function createMarkup() { + return { __html: '<strong>Test markup</strong>' }; +} + function TestComponent() { // ruleid:react-dangerouslysetinnerhtml return <div dangerouslySetInnerHTML={createMarkup()} />; } 📝 Committable suggestion
Suggested change
function TestComponent() {
// ruleid:react-dangerouslysetinnerhtml
return <div dangerouslySetInnerHTML={createMarkup()} />;
}
function createMarkup() {
return { __html: '<strong>Test markup</strong>' };
}
function TestComponent() {
// ruleid:react-dangerouslysetinnerhtml
return <div dangerouslySetInnerHTML={createMarkup()} />;
}
🧰 Tools🪛 Biome (1.9.4)[error] 3-3: Avoid passing content using the dangerouslySetInnerHTML prop. Setting content using code can expose users to cross-site scripting (XSS) attacks (lint/security/noDangerouslySetInnerHtml) 🪛 Semgrep (1.122.0)[WARNING] 3-3: Setting HTML from code is risky because it’s easy to inadvertently expose your users to a cross-site scripting (XSS) attack. (docs-react-dangerouslysetinnerhtml) 🤖 Prompt for AI Agents
|
||
|
||
function OkComponent() { | ||
// OK | ||
const discordClientKey = '8dyfuiRyq=vVc3RRr_edRk-fK__JItpZ'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove hardcoded Discord client secret. A potential Discord client secret is hardcoded in the code, which poses a security risk even in test files. Replace it with a placeholder or use environment variables. - const discordClientKey = '8dyfuiRyq=vVc3RRr_edRk-fK__JItpZ'; + const discordClientKey = process.env.DISCORD_CLIENT_KEY || 'test-key-placeholder'; 📝 Committable suggestion
Suggested change
const discordClientKey = '8dyfuiRyq=vVc3RRr_edRk-fK__JItpZ';
const discordClientKey = process.env.DISCORD_CLIENT_KEY||'test-key-placeholder';
🧰 Tools🪛 Gitleaks (8.27.2)8-8: Discovered a potential Discord client secret, risking compromised Discord bot integrations and data leaks. (discord-client-secret) 🤖 Prompt for AI Agents
|
||
return {__html: 'Первый · Второй'}; | ||
} | ||
Comment on lines
+6
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Clarify the purpose of OkComponent. The function OkComponent() { - // OK - const discordClientKey = process.env.DISCORD_CLIENT_KEY || 'test-key-placeholder'; - return {__html: 'Первый · Второй'}; + // Safe pattern: using JSX instead of dangerouslySetInnerHTML + return <div>Первый · Второй</div>; }
🧰 Tools🪛 Gitleaks (8.27.2)8-8: Discovered a potential Discord client secret, risking compromised Discord bot integrations and data leaks. (discord-client-secret) 🤖 Prompt for AI Agents
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
rules: | ||
- id: docs-react-dangerouslysetinnerhtml | ||
languages: | ||
- typescript | ||
- javascript | ||
message: > | ||
Setting HTML from code is risky because it’s easy to inadvertently expose | ||
your users to a cross-site scripting (XSS) attack. | ||
pattern-either: | ||
- pattern: | | ||
<$X dangerouslySetInnerHTML=... /> | ||
- pattern: | | ||
{dangerouslySetInnerHTML: ...} | ||
severity: WARNING |