JavaScript: Make TargetBlank only highlight the first line of the link.

Otherwise alerts for multi-line `<a>` elements end up looking very red.

I also took the opportunity to improve the tests slightly.
This commit is contained in:
Max Schaefer
2018-11-20 12:51:37 +00:00
parent dd4c9654f2
commit c1690a69e5
3 changed files with 13 additions and 2 deletions

View File

@@ -13,6 +13,7 @@
import javascript
import semmle.javascript.frameworks.Templating
import semmle.javascript.RestrictedLocations
/**
* Holds if the href attribute contains a host that we cannot determine statically.
@@ -53,4 +54,4 @@ where // `e` is a link that opens in a new browsing context (that is, it has `ta
not exists (DOM::AttributeDefinition attr | attr = e.getAnAttribute() |
not exists(attr.getName())
)
select e, "External links without noopener/noreferrer are a potential security risk."
select (FirstLineOf)e, "External links without noopener/noreferrer are a potential security risk."