This commit is contained in:
Asger Feldthaus 2020-12-17 15:26:34 +00:00
Родитель 97f7cb4dc1
Коммит 3c0867125b
1 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -16,6 +16,13 @@ import javascript
import semmle.javascript.frameworks.Templating
import semmle.javascript.RestrictedLocations
/**
* Holds if the `rel` attribute may be injected by an Angular2 directive.
*/
predicate maybeInjectedByAngular() {
DataFlow::moduleMember("@angular/core", "HostBinding").getACall().getArgument(0).mayHaveStringValue("attr.rel")
}
/**
* Holds if the href attribute contains a host that we cannot determine statically.
*/
@ -44,6 +51,8 @@ where
e.getName() = "a" and
// and the host in the href is not hard-coded
hasDynamicHrefHostAttributeValue(e) and
// disable for Angular applications that dynamically inject the 'rel' attribute
not maybeInjectedByAngular() and
e.getAttributeByName("target").getStringValue() = "_blank" and
// there is no `rel` attribute specifying link type `noopener`/`noreferrer`;
// `rel` attributes with non-constant value are handled conservatively