-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dependabot/npm_and_yarn/next-14.2.12
- Loading branch information
Showing
7 changed files
with
135 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
repos: | ||
- repo: https://github.com/semgrep/semgrep | ||
rev: "v1.86.0" | ||
rev: '768d0f4c3ccb4b1740eef22bbbd57fc936450df2' # frozen: v1.84.1 | ||
hooks: | ||
- id: semgrep | ||
args: | ||
[ | ||
"--config", | ||
"p/ci", | ||
"--error", | ||
"--skip-unknown-extensions", | ||
"--metrics", | ||
"off", | ||
] | ||
stages: [pre-push] | ||
- --config | ||
- rules/ | ||
- --error | ||
- --skip-unknown-extensions | ||
- --metrics | ||
- 'off' | ||
stages: | ||
- pre-push | ||
- repo: https://github.com/Yelp/detect-secrets | ||
rev: v1.5.0 | ||
rev: '68e8b45440415753fff70a312ece8da92ba85b4a' # frozen: v1.5.0 | ||
hooks: | ||
- id: detect-secrets | ||
stages: [pre-commit] | ||
args: ["--baseline", ".secrets.baseline"] | ||
exclude: yarn.lock | ||
args: | ||
- --baseline | ||
- .secrets.baseline | ||
stages: | ||
- pre-commit | ||
exclude: package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// pages/comments.js | ||
|
||
import { useState, useEffect } from 'react'; | ||
|
||
export default function Comments() { | ||
const [comments, setComments] = useState([]); | ||
const [newComment, setNewComment] = useState(''); | ||
|
||
useEffect(() => { | ||
// Load comments from local storage when the component mounts | ||
const savedComments = JSON.parse(localStorage.getItem('comments')) || []; | ||
setComments(savedComments); | ||
}, []); | ||
|
||
const handleAddComment = () => { | ||
if (newComment.trim() === '') return; | ||
|
||
const updatedComments = [...comments, newComment]; | ||
setComments(updatedComments); | ||
setNewComment(''); | ||
localStorage.setItem('comments', JSON.stringify(updatedComments)); | ||
}; | ||
|
||
const handleRemoveComment = (index) => { | ||
const updatedComments = comments.filter((_, i) => i !== index); | ||
setComments(updatedComments); | ||
localStorage.setItem('comments', JSON.stringify(updatedComments)); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<h1>Comments</h1> | ||
<div> | ||
<input | ||
type="text" | ||
value={newComment} | ||
onChange={(e) => setNewComment(e.target.value)} | ||
placeholder="Add a comment" | ||
/> | ||
<button onClick={handleAddComment}>Submit</button> | ||
</div> | ||
<ul> | ||
{comments.map((comment, index) => ( | ||
<li key={index}> | ||
{comment} | ||
<button onClick={() => handleRemoveComment(index)}>Remove</button> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
rules: | ||
- id: detect-dangerous-innerhtml | ||
pattern: | | ||
<$_ dangerouslySetInnerHTML={ { __html: $VAL } } /> | ||
message: "Usage of 'dangerouslySetInnerHTML' can lead to XSS vulnerabilities. Avoid using it unless absolutely necessary." | ||
severity: ERROR | ||
languages: [javascript, typescript] | ||
metadata: | ||
category: security | ||
technology: react |