Skip to content

Python Class Variable data flow #9684

Discussion options

You must be logged in to vote

Hi, thank you very much for alerting us to this hole in our analysis! It looks like we do indeed not handle this flow. I think what would be needed is to add a jump step along the lines of

predicate readClassVarStep(DataFlow::EssaNode fromNode, DataFlow::AttrRead toNode) {
  exists(ClassDef classDef, SsaVariable c | classDef.defines(c.getVariable()) |
    fromNode.getVar().getScope() = classDef.getDefinedClass() and
    toNode.getObject().(DataFlow::CallCfgNode).getFunction().(DataFlow::CfgNode).getNode() =
      c.getAUse()
  )
}

and then a corresponding one for writing to class variables.

I think you cannot add jump steps, but you could add

  override predicate isAdditionalFlowStep(Data…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@michal-sladecek-cognite
Comment options

@yoff
Comment options

yoff Jun 24, 2022
Maintainer

@michal-sladecek-cognite
Comment options

@michal-sladecek-cognite
Comment options

@yoff
Comment options

yoff Jun 29, 2022
Maintainer

Answer selected by michal-sladecek-cognite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants