@@ -148,6 +148,8 @@ abstract class TaintKind extends string {
148148 none ( )
149149 }
150150
151+ string repr ( ) { result = this }
152+
151153}
152154
153155/** Taint kinds representing collections of other taint kind.
@@ -208,6 +210,10 @@ class SequenceKind extends CollectionKind {
208210 name = "pop" and result = this .getItem ( )
209211 }
210212
213+ override string repr ( ) {
214+ result = "sequence of " + itemKind
215+ }
216+
211217}
212218
213219/* Helper for getTaintForStep() */
@@ -281,6 +287,10 @@ class DictKind extends CollectionKind {
281287 name = "itervalues" and result .( SequenceKind ) .getItem ( ) = valueKind
282288 }
283289
290+ override string repr ( ) {
291+ result = "dict of " + valueKind
292+ }
293+
284294}
285295
286296
@@ -603,7 +613,9 @@ private predicate user_tainted_def(TaintedDefinition def, TaintFlowImplementatio
603613 */
604614class TaintedNode extends TTaintedNode {
605615
606- string toString ( ) { result = this .getTrackedValue ( ) .toString ( ) + " at " + this .getLocation ( ) }
616+ string toString ( ) { result = this .getTrackedValue ( ) .repr ( ) }
617+
618+ string debug ( ) { result = this .getTrackedValue ( ) .toString ( ) + " at " + this .getNode ( ) .getLocation ( ) }
607619
608620 TaintedNode getASuccessor ( ) {
609621 exists ( TaintFlowImplementation:: TrackedValue tokind , CallContext tocontext , ControlFlowNode tonode |
@@ -675,25 +687,33 @@ class TaintedNode extends TTaintedNode {
675687
676688}
677689
678- class TaintedNodeSource extends TaintedNode {
690+ class TaintedPathSource extends TaintedNode {
679691
680- TaintedNodeSource ( ) {
692+ TaintedPathSource ( ) {
681693 this .getNode ( ) .( TaintSource ) .isSourceOf ( this .getTaintKind ( ) , this .getContext ( ) )
682694 }
683695
684696 /** Holds if taint can flow from this source to sink `sink` */
685- final predicate flowsTo ( TaintedNodeSink sink ) {
697+ final predicate flowsTo ( TaintedPathSink sink ) {
686698 this .getASuccessor * ( ) = sink
687699 }
688700
701+ TaintSource getSource ( ) {
702+ result = this .getNode ( )
703+ }
704+
689705}
690706
691- class TaintedNodeSink extends TaintedNode {
707+ class TaintedPathSink extends TaintedNode {
692708
693- TaintedNodeSink ( ) {
709+ TaintedPathSink ( ) {
694710 this .getNode ( ) .( TaintSink ) .sinks ( this .getTaintKind ( ) )
695711 }
696712
713+ TaintSink getSink ( ) {
714+ result = this .getNode ( )
715+ }
716+
697717}
698718
699719/** This module contains the implementation of taint-flow.
@@ -739,12 +759,18 @@ library module TaintFlowImplementation {
739759
740760 abstract string toString ( ) ;
741761
762+ abstract string repr ( ) ;
763+
742764 abstract TrackedValue toKind ( TaintKind kind ) ;
743765
744766 }
745767
746768 class TrackedTaint extends TrackedValue , TTrackedTaint {
747769
770+ override string repr ( ) {
771+ result = this .getKind ( ) .repr ( )
772+ }
773+
748774 override string toString ( ) {
749775 result = "Taint " + this .getKind ( )
750776 }
@@ -761,6 +787,13 @@ library module TaintFlowImplementation {
761787
762788 class TrackedAttribute extends TrackedValue , TTrackedAttribute {
763789
790+ override string repr ( ) {
791+ exists ( string name , TaintKind kind |
792+ this = TTrackedAttribute ( name , kind ) and
793+ result = "." + name + "=" + kind .repr ( )
794+ )
795+ }
796+
764797 override string toString ( ) {
765798 exists ( string name , TaintKind kind |
766799 this = TTrackedAttribute ( name , kind ) and
0 commit comments