@@ -792,14 +792,10 @@ predicate defaultValueFlowStep(CfgNode nodeFrom, CfgNode nodeTo) {
792792predicate readStep ( Node nodeFrom , Content c , Node nodeTo ) {
793793 subscriptReadStep ( nodeFrom , c , nodeTo )
794794 or
795- dictReadStep ( nodeFrom , c , nodeTo )
796- or
797795 iterableUnpackingReadStep ( nodeFrom , c , nodeTo )
798796 or
799797 matchReadStep ( nodeFrom , c , nodeTo )
800798 or
801- popReadStep ( nodeFrom , c , nodeTo )
802- or
803799 forReadStep ( nodeFrom , c , nodeTo )
804800 or
805801 attributeReadStep ( nodeFrom , c , nodeTo )
@@ -832,51 +828,6 @@ predicate subscriptReadStep(CfgNode nodeFrom, Content c, CfgNode nodeTo) {
832828 )
833829}
834830
835- predicate dictReadStep ( CfgNode nodeFrom , Content c , CfgNode nodeTo ) {
836- // see
837- // - https://docs.python.org/3.10/library/stdtypes.html#dict.get
838- // - https://docs.python.org/3.10/library/stdtypes.html#dict.setdefault
839- exists ( MethodCallNode call |
840- call .calls ( nodeFrom , [ "get" , "setdefault" ] ) and
841- call .getArg ( 0 ) .asExpr ( ) .( StrConst ) .getText ( ) = c .( DictionaryElementContent ) .getKey ( ) and
842- nodeTo = call
843- )
844- }
845-
846- /** Data flows from a sequence to a call to `pop` on the sequence. */
847- predicate popReadStep ( CfgNode nodeFrom , Content c , CfgNode nodeTo ) {
848- // set.pop or list.pop
849- // `s.pop()`
850- // nodeFrom is `s`, cfg node
851- // nodeTo is `s.pop()`, cfg node
852- // c denotes element of list or set
853- exists ( CallNode call , AttrNode a |
854- call .getFunction ( ) = a and
855- a .getName ( ) = "pop" and // Should match appropriate call since we tracked a sequence here.
856- not exists ( call .getAnArg ( ) ) and
857- nodeFrom .getNode ( ) = a .getObject ( ) and
858- nodeTo .getNode ( ) = call and
859- (
860- c instanceof ListElementContent
861- or
862- c instanceof SetElementContent
863- )
864- )
865- or
866- // dict.pop
867- // `d.pop("key")`
868- // nodeFrom is `d`, cfg node
869- // nodeTo is `d.pop("key")`, cfg node
870- // c denotes the key `"key"`
871- exists ( CallNode call , AttrNode a |
872- call .getFunction ( ) = a and
873- a .getName ( ) = "pop" and // Should match appropriate call since we tracked a dictionary here.
874- nodeFrom .getNode ( ) = a .getObject ( ) and
875- nodeTo .getNode ( ) = call and
876- c .( DictionaryElementContent ) .getKey ( ) = call .getArg ( 0 ) .getNode ( ) .( StrConst ) .getS ( )
877- )
878- }
879-
880831predicate forReadStep ( CfgNode nodeFrom , Content c , Node nodeTo ) {
881832 exists ( ForTarget target |
882833 nodeFrom .asExpr ( ) = target .getSource ( ) and
0 commit comments