Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3c08671

Browse files
committed
JS: Remove FP in TargetBlank
1 parent 97f7cb4 commit 3c08671

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

javascript/ql/src/DOM/TargetBlank.ql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ import javascript
1616
import semmle.javascript.frameworks.Templating
1717
import semmle.javascript.RestrictedLocations
1818

19+
/**
20+
* Holds if the `rel` attribute may be injected by an Angular2 directive.
21+
*/
22+
predicate maybeInjectedByAngular() {
23+
DataFlow::moduleMember("@angular/core", "HostBinding").getACall().getArgument(0).mayHaveStringValue("attr.rel")
24+
}
25+
1926
/**
2027
* Holds if the href attribute contains a host that we cannot determine statically.
2128
*/
@@ -44,6 +51,8 @@ where
4451
e.getName() = "a" and
4552
// and the host in the href is not hard-coded
4653
hasDynamicHrefHostAttributeValue(e) and
54+
// disable for Angular applications that dynamically inject the 'rel' attribute
55+
not maybeInjectedByAngular() and
4756
e.getAttributeByName("target").getStringValue() = "_blank" and
4857
// there is no `rel` attribute specifying link type `noopener`/`noreferrer`;
4958
// `rel` attributes with non-constant value are handled conservatively

0 commit comments

Comments
 (0)