-
Notifications
You must be signed in to change notification settings - Fork 6
Preview/oxlint #26
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/oxlint #26
Changes from all commits
14e89ad
6949947
ea98f47
f25aa13
500f9ce
b5e74a0
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,28 @@ | ||
{ | ||
"plugins": ["import", "typescript", "unicorn"], | ||
"env": { | ||
"browser": true | ||
}, | ||
"globals": { | ||
"foo": "readonly" | ||
}, | ||
"settings": {}, | ||
"rules": { | ||
"eqeqeq": "warn", | ||
"import/no-cycle": "error", | ||
"react/self-closing-comp": [ | ||
"error", | ||
{ | ||
"html": false | ||
} | ||
] | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": ["*.test.ts", "*.spec.ts"], | ||
"rules": { | ||
"@typescript-eslint/no-explicit-any": "off" | ||
} | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
reviews: | ||
path_filters: ["**/*.yml"] | ||
tools: | ||
# oxlint does not run if biome is enabled | ||
biome: | ||
enabled: false |
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. Remove dangerouslySetInnerHTML to prevent XSS attacks. This component exposes users to cross-site scripting (XSS) attacks by using Consider these safer alternatives: -function TestComponent() { - // ruleid:react-dangerouslysetinnerhtml - return <div dangerouslySetInnerHTML={createMarkup()} />; -} +function TestComponent() { + // Use text content directly or sanitize with a library like DOMPurify + return <div>{sanitizedContent}</div>; +} Alternatively, if you must render HTML, sanitize it first: +import DOMPurify from 'dompurify'; + function TestComponent() { - // ruleid:react-dangerouslysetinnerhtml - return <div dangerouslySetInnerHTML={createMarkup()} />; + const sanitizedMarkup = DOMPurify.sanitize(createMarkup()); + return <div dangerouslySetInnerHTML={{__html: sanitizedMarkup}} />; }
🧰 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) 🤖 Prompt for AI Agents
|
||
|
||
function OkComponent() { | ||
// OK | ||
const discordClientKey = '8dyfuiRyq=vVc3RRr_edRk-fK__JItpZ'; | ||
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. Move the Discord client secret to environment variables and fix the component structure. This component has two critical issues:
Apply this fix to address both issues: function OkComponent() { - // OK - const discordClientKey = '8dyfuiRyq=vVc3RRr_edRk-fK__JItpZ'; - return {__html: 'Первый · Второй'}; + const discordClientKey = process.env.REACT_APP_DISCORD_CLIENT_KEY; + return <div>Первый · Второй</div>; } Then add the secret to your environment variables: # .env.local
REACT_APP_DISCORD_CLIENT_KEY=8dyfuiRyq=vVc3RRr_edRk-fK__JItpZ Remember to add 🧰 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
|
||
|