Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed
alexcoderabbitai wants to merge 6 commits into main from preview/oxlint
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .oxlintrc.json
View file Open in desktop
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"
}
}
]
}
6 changes: 6 additions & 0 deletions coderabbit.yml
View file Open in desktop
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
11 changes: 11 additions & 0 deletions sampleReact.jsx
View file Open in desktop
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
Copy link

@coderabbitai coderabbitai bot Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove dangerouslySetInnerHTML to prevent XSS attacks.

This component exposes users to cross-site scripting (XSS) attacks by using dangerouslySetInnerHTML. The static analysis tool correctly flagged this security vulnerability. You should sanitize content or use safer React patterns instead.

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}} />;
 }

Committable suggestion skipped: line range outside the PR's diff.

🧰 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
In sampleReact.jsx lines 1 to 4, the use of dangerouslySetInnerHTML poses an XSS
security risk. To fix this, remove dangerouslySetInnerHTML and instead render
content using safe React methods like JSX elements or text nodes. If rendering
HTML is necessary, sanitize the HTML content thoroughly before injecting it to
prevent XSS vulnerabilities.


function OkComponent() {
// OK
const discordClientKey = '8dyfuiRyq=vVc3RRr_edRk-fK__JItpZ';
return {__html: 'Первый &middot; Второй'};
}
Comment on lines +6 to +10
Copy link

@coderabbitai coderabbitai bot Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Move the Discord client secret to environment variables and fix the component structure.

This component has two critical issues:

  1. Security: You hardcode a Discord client secret directly in the source code, which creates a serious security risk
  2. Functionality: This function doesn't return valid JSX, making it an invalid React component

Apply this fix to address both issues:

 function OkComponent() {
- // OK
- const discordClientKey = '8dyfuiRyq=vVc3RRr_edRk-fK__JItpZ';
- return {__html: 'Первый &middot; Второй'};
+ const discordClientKey = process.env.REACT_APP_DISCORD_CLIENT_KEY;
+ return <div>Первый &middot; Второй</div>;
 }

Then add the secret to your environment variables:

# .env.local
REACT_APP_DISCORD_CLIENT_KEY=8dyfuiRyq=vVc3RRr_edRk-fK__JItpZ

Remember to add .env.local to your .gitignore file to prevent committing secrets.

🧰 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
In sampleReact.jsx around lines 6 to 10, the Discord client secret is hardcoded,
posing a security risk, and the function returns an invalid React component
structure. To fix this, remove the hardcoded secret and instead access it via
process.env.REACT_APP_DISCORD_CLIENT_KEY, ensuring the secret is stored in an
environment variable. Also, update the function to return valid JSX rather than
an object, for example by returning a React element with the desired HTML
content safely rendered. Finally, add the secret to a .env.local file and ensure
this file is included in .gitignore to avoid committing secrets.


AltStyle によって変換されたページ (->オリジナル) /