File tree Expand file tree Collapse file tree
javascript/ql/src/semmle/javascript/frameworks Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -363,6 +363,26 @@ module Angular2 {
363363 }
364364 }
365365
366+ /** A class with the `@Pipe` decorator. */
367+ class PipeClass extends DataFlow:: ClassNode {
368+ DataFlow:: CallNode decorator ;
369+
370+ PipeClass ( ) {
371+ decorator = DataFlow:: moduleMember ( "@angular/core" , "Pipe" ) .getACall ( ) and
372+ decorator = getADecorator ( )
373+ }
374+
375+ /** Gets the value of the `name` option passed to the `@Pipe` decorator. */
376+ string getPipeName ( ) {
377+ decorator .getOptionArgument ( 0 , "name" ) .mayHaveStringValue ( result )
378+ }
379+
380+ /** Gets a reference to this pipe. */
381+ DataFlow:: Node getAPipeRef ( ) {
382+ result .asExpr ( ) .( PipeRefExpr ) .getName ( ) = getPipeName ( )
383+ }
384+ }
385+
366386 private class ComponentSteps extends PreCallGraphStep {
367387 override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
368388 exists ( ComponentClass cls , string name |
@@ -386,4 +406,13 @@ module Angular2 {
386406 )
387407 }
388408 }
409+
410+ private class PipeSteps extends PreCallGraphStep {
411+ override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
412+ exists ( PipeClass cls |
413+ pred = cls .getInstanceMethod ( "transform" ) and
414+ succ = cls .getAPipeRef ( )
415+ )
416+ }
417+ }
389418}
You can’t perform that action at this time.
0 commit comments