Skip to content

[Go] Trouble getting the resolved type of an argument from nested function #15886

Answered by owen-mc
rh-tguittet asked this question in Q&A
Discussion options

You must be logged in to vote

Good point. Try this:

/**
 * @kind path-problem
 */

import go

DataFlow::Node getA() { result.asExpr() instanceof StructLit }

DataFlow::Node getB() {
  exists(Function f | f.getName() = "ReadObject" and result = f.getACall().getArgument(1))
}

DataFlow::Node getC() {
  exists(Function sink | sink.getName() = "sink" and result = sink.getACall().getAnArgument())
}

module AtoB implements DataFlow::ConfigSig {
  predicate isSource(DataFlow::Node node) { node = getA() }

  predicate isSink(DataFlow::Node node) { node = getB() }
}

module BtoC implements DataFlow::ConfigSig {
  predicate isSource(DataFlow::Node node) {
    node.(DataFlow::PostUpdateNode).getPreUpdateNode() = getB()
  }

  pr…

Replies: 1 comment 13 replies

Comment options

You must be logged in to vote
13 replies
@owen-mc
Comment options

@rh-tguittet
Comment options

@rh-tguittet
Comment options

@owen-mc
Comment options

Answer selected by rh-tguittet
@rh-tguittet
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants