File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,13 @@ import javascript
1616import semmle.javascript.frameworks.Templating
1717import 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 */
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
You can’t perform that action at this time.
0 commit comments