rspec/rules/S5148/html/rule.adoc

49 lines
1.2 KiB
Plaintext
Raw Normal View History

2021-05-11 01:20:07 +00:00
include::../description.adoc[]
2021-04-28 16:49:39 +02:00
2021-05-11 01:20:07 +00:00
include::../ask-yourself.adoc[]
2021-04-28 16:49:39 +02:00
2021-05-11 01:20:07 +00:00
include::../recommended.adoc[]
2021-04-28 16:49:39 +02:00
== Sensitive Code Example
----
2021-05-11 01:20:07 +00:00
<a href="http://example.com/dangerous" target="_blank"> <!-- Sensitive -->
2021-04-28 16:49:39 +02:00
2021-05-11 01:20:07 +00:00
<a href="{{variable}}" target="_blank"> <!-- Sensitive -->
2021-04-28 16:49:39 +02:00
----
== Compliant Solution
2021-05-11 01:20:07 +00:00
To prevent pages from abusing ``++window.opener++``, use ``++rel=noopener++`` on ``++<a href=>++`` to force its value to be ``++null++`` on the opened pages.
2022-02-04 17:28:24 +01:00
[source,html]
2021-04-28 16:49:39 +02:00
----
<a href="http://petssocialnetwork.io" target="_blank" rel="noopener"> <!-- Compliant -->
----
== 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 {}$()[]
----
<a href="internal.html" target="_blank" > <!-- Compliant -->
----
2021-05-11 01:20:07 +00:00
include::../see.adoc[]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]