Skip to content

Commit

Permalink
Modify rule S5148: Adjust code example format (#3454)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-teuchert-sonarsource authored Nov 21, 2023
1 parent cc2ec5b commit 6febd22
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions rules/S5148/html/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ include::../recommended.adoc[]

== Sensitive Code Example

[source,html]
----
<a href="http://example.com/dangerous" target="_blank"> <!-- Sensitive -->
Expand All @@ -18,15 +19,16 @@ To prevent pages from abusing ``++window.opener++``, use ``++rel=noopener++`` on

[source,html]
----
<a href="http://petssocialnetwork.io" target="_blank" rel="noopener"> <!-- Compliant -->
<a href="http://petssocialnetwork.io" target="_blank" rel="noopener">
----

== Exceptions

No Issue will be raised when ``++href++`` contains a hardcoded relative url as there it has less chances of being vulnerable. An url is considered hardcoded and relative if it doesn't start with ``++http://++`` or ``++https://++``, and if it does not contain any of the characters {}$()[]

[source,html]
----
<a href="internal.html" target="_blank" > <!-- Compliant -->
<a href="internal.html" target="_blank" >
----

include::../see.adoc[]
Expand Down
3 changes: 2 additions & 1 deletion rules/S5148/javascript/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ include::../recommended.adoc[]

== Sensitive Code Example

[source,javascript]
----
window.open("https://example.com/dangerous");
window.open("https://example.com/dangerous"); // Sensitive
----

== Compliant Solution
Expand Down

0 comments on commit 6febd22

Please sign in to comment.