-
| Hi, I have this unusual case where a bird-view of the problem is as follow: class Art
      @staticmethod
      def down(in1, btw):
             // the source fct_source() is being identified and it is within a static method.
             fct_source(in1,btw)
      @staticmethod 
      def copy(btw, out1):
             // the sink is supposed to be inside another static method  
             fct_sink(btw,out1)             
       @staticmethod 
       def call():
             Art.down(in1,btw)
             Art.copy(btw, out1)Now, what I did is a very basic CodeQL query as follow: class Config extends TaintTracking::Configuration {
  Config() { this = "Config" }
  override predicate isSource(DataFlow::Node source) {
         // catch fct_source()
         source = API::moduleimport("fct_source").getACall().getArg(0)
  }
  override predicate isSink(DataFlow::Node sink) {
    // catch out1 of fct_sink(), for instance
     sink = API::moduleimport("fct_sink").getACall().getArg(1)
      
  }
}
from Config config, DataFlow::PathNode source, DataFlow::PathNode sink
where config.hasFlowPath(source, sink)
select sink.getNode(), source, sink, "There is a way between the source and the sink !"My problem is there is no found way between the source and the sink despite the fact that a  | 
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
| It seems that the use of  | 
Beta Was this translation helpful? Give feedback.
-
| Your source is first argument of  Additionally, your sink is the second argument of  Also note that, in your snippet, neither  | 
Beta Was this translation helpful? Give feedback.
-
| As mentioned by @atorralba, there is no way to conclude the flow you are expecting without knowing something about  class Foo:
    def __init__(self, foo=NONSOURCE):
        self.foo = foo
def prop_source(in1, btw):
    btw.foo = in1.foo
def prop_sink(btw, out1):
    out1.foo = btw.foo
def test_prop():
    in1 = Foo(SOURCE)
    btw = Foo()
    out1 = Foo()
    prop_source(in1,btw)
    prop_sink(btw,out1)
    SINK(out1.foo) # $ flow="SOURCE, l:-5 -> out1.foo"
class ArtProp:
    def __init__(self, foo=NONSOURCE):
        self.foo = foo
    @staticmethod
    def down(in1, btw):
        prop_source(in1, btw)
    @staticmethod
    def copy(btw, out1):
        prop_sink(btw, out1)
    @staticmethod
    def call():
        in1 = Foo(SOURCE)
        btw = Foo()
        out1 = Foo()
        ArtProp.down(in1,btw)
        ArtProp.copy(btw, out1)
        SINK(out1.foo) # $ flow="SOURCE, l:-5 -> out1.foo"
def test_prop_static():
    ArtProp.call()then both the annotated lines receive taint. override predicate isAdditionalTaintStep(DataFlow::Node n1, DataFlow::Node n2) {
    exists(DataFlow::CallCfgNode c |
      c = API::moduleImport(...).getMember(...).getACall() // use this if you have a nice API expression for the calls
      c.getFunction().asExpr().(Name).getId() = ["fct_source", "fct_sink"] // use this as a raw alternative
    |
      n1 = c.getArg(0) and
      n2.(DataFlow::PostUpdateNode).getPreUpdateNode() = c.getArg(1)
    )
  }where you pick the line defining  | 
Beta Was this translation helpful? Give feedback.
As mentioned by @atorralba, there is no way to conclude the flow you are expecting without knowing something about
fct_sourceandfct_sink. If I write the program