-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add security warning for anchor element (rel attribute)
- Loading branch information
Showing
5 changed files
with
130 additions
and
0 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
8 changes: 8 additions & 0 deletions
8
test/validator/samples/security-anchor-rel-noopener/input.svelte
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,8 @@ | ||
<!-- svelte-ignore security-anchor-rel-noreferrer --> | ||
<a href="https://svelte.dev" target="_blank">svelte website (invalid)</a> | ||
<!-- svelte-ignore security-anchor-rel-noreferrer --> | ||
<a href="https://svelte.dev" target="_blank" rel="">svelte website (invalid)</a> | ||
<a href="https://svelte.dev" target="_blank" rel="noreferrer">svelte website (invalid)</a> | ||
<!-- svelte-ignore security-anchor-rel-noreferrer --> | ||
<a href="https://svelte.dev" target="_blank" rel="noopener">svelte website (valid)</a> | ||
<a href="https://svelte.dev" target="_blank" rel="noreferrer noopener">svelte website (valid)</a> |
47 changes: 47 additions & 0 deletions
47
test/validator/samples/security-anchor-rel-noopener/warnings.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
[ | ||
{ | ||
"code": "security-anchor-rel-noopener", | ||
"message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\"", | ||
"start": { | ||
"line": 2, | ||
"column": 0, | ||
"character": 54 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 73, | ||
"character": 127 | ||
}, | ||
"pos": 54 | ||
}, | ||
{ | ||
"code": "security-anchor-rel-noopener", | ||
"message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\"", | ||
"start": { | ||
"line": 4, | ||
"column": 0, | ||
"character": 182 | ||
}, | ||
"end": { | ||
"line": 4, | ||
"column": 80, | ||
"character": 262 | ||
}, | ||
"pos": 182 | ||
}, | ||
{ | ||
"code": "security-anchor-rel-noopener", | ||
"message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\"", | ||
"start": { | ||
"line": 5, | ||
"column": 0, | ||
"character": 263 | ||
}, | ||
"end": { | ||
"line": 5, | ||
"column": 90, | ||
"character": 353 | ||
}, | ||
"pos": 263 | ||
} | ||
] |
8 changes: 8 additions & 0 deletions
8
test/validator/samples/security-anchor-rel-noreferrer/input.svelte
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,8 @@ | ||
<!-- svelte-ignore security-anchor-rel-noopener --> | ||
<a href="https://svelte.dev" target="_blank">svelte website (invalid)</a> | ||
<!-- svelte-ignore security-anchor-rel-noopener --> | ||
<a href="https://svelte.dev" target="_blank" rel="">svelte website (invalid)</a> | ||
<a href="https://svelte.dev" target="_blank" rel="noopener">svelte website (invalid)</a> | ||
<!-- svelte-ignore security-anchor-rel-noopener --> | ||
<a href="https://svelte.dev" target="_blank" rel="noreferrer">svelte website (valid)</a> | ||
<a href="https://svelte.dev" target="_blank" rel="noreferrer noopener">svelte website (valid)</a> |
47 changes: 47 additions & 0 deletions
47
test/validator/samples/security-anchor-rel-noreferrer/warnings.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
[ | ||
{ | ||
"code": "security-anchor-rel-noreferrer", | ||
"message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", | ||
"start": { | ||
"line": 2, | ||
"column": 0, | ||
"character": 52 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 73, | ||
"character": 125 | ||
}, | ||
"pos": 52 | ||
}, | ||
{ | ||
"code": "security-anchor-rel-noreferrer", | ||
"message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", | ||
"start": { | ||
"line": 4, | ||
"column": 0, | ||
"character": 178 | ||
}, | ||
"end": { | ||
"line": 4, | ||
"column": 80, | ||
"character": 258 | ||
}, | ||
"pos": 178 | ||
}, | ||
{ | ||
"code": "security-anchor-rel-noreferrer", | ||
"message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", | ||
"start": { | ||
"line": 5, | ||
"column": 0, | ||
"character": 259 | ||
}, | ||
"end": { | ||
"line": 5, | ||
"column": 88, | ||
"character": 347 | ||
}, | ||
"pos": 259 | ||
} | ||
] |