[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: RE: [sarif] Nested graphs: adopting Luke's proposal
TL;DR: Michael and I discussed this extensively and Luke’s proposal is fine. I wrongly thought that the design couldn’t handle calls to the same function from multiple call sites. But it can. Details: Michael pointed out that the return from a function to each of its call sites is represented by a separate edge. Here is an extended example, which I will leave you to trace through, rather than me writing a novel to explain it 😊 Larry { # A result object "graphs": [ { "id": "function_a", "nodes": [ { "id": "na1", # First call to function_b }, { "id": "na2", # Return from first call to function_b }, { "id": "na3", # Second call to function_b. }, { "id": "na4", # Return from second call to function_b. } ], "edges": [ { "id": "ea1", "sourceNodeId": "na1", "targetNodeId": "nb1", "targetGraphId": "function_b" }, { "id": "ea2", "sourceNodeId": "na2", "targetNodeId": "na3" }, { "id": "ea3", "sourceNodeId": "na3", "targetNodeId": "nb1", "targetGraphId": "function_b" } ] }, { "id": "function_b", "nodes": [ { "id": "nb1", # Entry point }, { "id": "nb2", # Some other node }, { "id": "nb3" # Return statement } ], "edges": [ { "id": "eb1", "sourceNodeId" : "nb1", "targetNodeId" : "nb2" }, { "id": "eb2", "sourceNodeId" : "nb2", "targetNodeId" : "nb3" }, { "id": "eb3.1", # Return to first call site. "sourceNodeId" : "nb3", "targetNodeId" : "na2", "targetGraphdId": "function_a" }, { "id": "eb3.2", # Return to second call site. "sourceNodeId" : "nb3", "targetNodeId" : "na4", "targetGraphdId": "function_a" } ] } # End of graph "function_b". ] # End of "graphs" array. } # End of result object. From: sarif@lists.oasis-open.org <sarif@lists.oasis-open.org> On Behalf Of Larry Golding (Comcast) Luke, I think there’s a slight problem in your example, which I reproduce here: { # A result object "graphs": [ { "id": "file_a", "nodes": [ { "id": "function_a", "nestedGraphId": "function_a" }, { "id": "function_b", "nestedGraphId": "function_b" } ], }, { "id": "function_a", "nodes": [ { "id": "a1", }, { "id": "a2", }, { "id": "a3" } ], "edges": [ ... { "id": "e1", "sourceNodeId" : "a2", "targetNodeId" : "b1", "targetGraphId" : "function_b" } ] }, { "id": "function_b", "nodes": [ { "id": "b1" }, "edges": [ ... { "id": "e1", "sourceNodeId" : "b1", "targetNodeId" : "a3", "targetGraphId" : "function_a" } ] ] } ], ... } It’s fine that graph function_a’s edge e1 represents a call to function_b. The problem is that function_b’s edge e1 represents a return to function_a (in fact, a return to a specific location within function_a). function_b can be called from multiple places in multiple functions. This part of the example conflates the notion of graph with the notion of graph traversal, in that function_b’s edge e1 represents a particular code path. I think we’re missing the notion of an “exit node” from a graph. We might represent it, for example, by adding a Boolean property isExit to the edge object. Thoughts? Larry From: sarif@lists.oasis-open.org <sarif@lists.oasis-open.org> On Behalf Of Larry Golding (Comcast) Ok, I’ll add the words. From: sarif@lists.oasis-open.org <sarif@lists.oasis-open.org> On Behalf Of Luke Cartey I would also like to prohibit the final case, because I believe graph viewers will find it difficult to display. Cheers, Luke On Mon, May 7, 2018 at 2:11 PM Larry Golding (Comcast) <larrygolding@comcast.net> wrote:
|
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]