The Wayback Machine - https://web.archive.org/web/20220108160548/https://github.com/github/codeql/pull/7526
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't include arg -> param edges in PathGraph::edges where arg is not reachable #7526

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

@smowton
Copy link
Contributor

@smowton smowton commented Jan 6, 2022

This avoids lots of missing-node warnings from codeql bqrs interpret as it discards the nodes that occur in the edges relation but not nodes. The problem arises because subpaths introduced two variants of reach, one of which is more restrictive than simply reach(succ) and succ = pred.getASuccessor(), so it no longer suffices to just check that the successor is reachable.

Suggestions re: the best way to test this welcome.

smowton added 2 commits Jan 6, 2022
…ot reachable

This avoids lots of missing-node warnings from `codeql bqrs interpret` as it discards the nodes that occur in the `edges` relation but not `nodes`. The problem arises because subpaths introduced two variants of `reach`, one of which is more restrictive than simply `reach(succ) and succ = pred.getASuccessor()`, so it no longer suffices to just check that the successor is reachable.
@@ -3416,7 +3416,7 @@ private predicate pathSuccPlus(PathNode n1, PathNode n2) = fastTC(pathSucc/2)(n1
*/
module PathGraph {
/** Holds if `(a,b)` is an edge in the graph of data flow path explanations. */
query predicate edges(PathNode a, PathNode b) { a.getASuccessor() = b and reach(b) }
query predicate edges(PathNode a, PathNode b) { a.getASuccessor() = b and reach(a) and reach(b) }
Copy link
Contributor

@hvitved hvitved Jan 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we shouldn't restrict sub path nodes to those that can reach a sink as well. I.e., redefine retReach as

  predicate retReach(PathNode n) {
    exists(PathNodeMid out |
      subpaths(_, _, n, out) and
      reach(out)
    )
    or
    exists(PathNode mid |
      retReach(mid) and
      n.getASuccessor() = mid and
      not subpaths(_, mid, _, _)
    )
  }

@aschackmull : What do you think?

Copy link
Contributor

@aschackmull aschackmull Jan 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, although I think I'd prefer

  predicate retReach(PathNode n) {
    exists(PathNodeMid out |
      subpaths(_, _, n, out)
    |
      directReach(out) or retReach(out)
    )
    or
    exists(PathNode mid |
      retReach(mid) and
      n.getASuccessor() = mid and
      not subpaths(_, mid, _, _)
    )
  }

to avoid making it mutually recursive with reach.

Copy link
Contributor

@aschackmull aschackmull Jan 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might also want to restrict the final subpaths relation if we want to get rid of the Skipping subpaths tuple with missing node warnings.

Copy link
Contributor

@hvitved hvitved Jan 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should certainly also restrict subpaths.

@MathiasVP
Copy link
Contributor

@MathiasVP MathiasVP commented Jan 7, 2022

The changes to the .expected files LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.