-
Notifications
You must be signed in to change notification settings - Fork 381
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When trying to find nodes by which an ifBlock condition is reachable, joern will fail to do so if the condition is formed by a single identifier node, in this case I'm trying to find that the condition of the ifBlock, formed only by the variable one_copy, is reachable by the call to givemeone()
To Reproduce
int givemeone(){
return 1;
}
int main(){
int one = givemeone();
int one_copy = one;
if (one_copy) {
return 1;
}
return 0;
}// in joern, after importCode():
cpg.ifBlock.condition.reachableBy(cpg.call).loutput:
val res3: List[io.shiftleft.codepropertygraph.generated.nodes.Call] = List()
Expected behavior
I'd expect to see that one_copy is reachable by the givemeone() call.
Desktop (please complete the following information):
- OS: Arch Linux
- Joern Version: 4.0.460
Additional context
I've found that reachableBy works correctly when you add almost anything to the condition, the bug only seems to affect the case where an identifier is found alone as the condition.
int givemeone(){
return 1;
}
int main(){
int one = givemeone();
int one_copy = one;
if (one_copy + 0) { // <--------- Notice how I've only added '+ 0'
return 1;
}
return 0;
}// in joern, after importCode():
cpg.ifBlock.condition.reachableBy(cpg.call).loutput:
val res6: List[io.joern.dataflowengineoss.language.Path] = List(
Path(
elements = List(
Call(
argumentIndex = -1,
argumentName = None,
code = "one_copy + 0",
columnNumber = Some(value = 9),
dispatchType = "STATIC_DISPATCH",
dynamicTypeHintFullName = IndexedSeq(),
lineNumber = Some(value = 8),
methodFullName = "<operator>.addition",
name = "<operator>.addition",
offset = None,
offsetEnd = None,
order = 1,
possibleTypes = IndexedSeq(),
signature = "",
staticReceiver = None,
typeFullName = "ANY"
)
)
),
Path(
elements = List(
Call(
argumentIndex = 2,
argumentName = None,
code = "givemeone()",
columnNumber = Some(value = 15),
dispatchType = "STATIC_DISPATCH",
dynamicTypeHintFullName = IndexedSeq(),
lineNumber = Some(value = 6),
methodFullName = "givemeone",
name = "givemeone",
offset = None,
offsetEnd = None,
order = 2,
possibleTypes = IndexedSeq(),
signature = "",
staticReceiver = None,
typeFullName = "int"
),
Identifier(
argumentIndex = 1,
argumentName = None,
code = "one",
columnNumber = Some(value = 9),
dynamicTypeHintFullName = IndexedSeq(),
lineNumber = Some(value = 6),
name = "one",
offset = None,
offsetEnd = None,
order = 1,
possibleTypes = IndexedSeq(),
typeFullName = "int"
),
Identifier(
argumentIndex = 2,
argumentName = None,
code = "one",
columnNumber = Some(value = 20),
dynamicTypeHintFullName = IndexedSeq(),
lineNumber = Some(value = 7),
name = "one",
offset = None,
offsetEnd = None,
order = 2,
possibleTypes = IndexedSeq(),
typeFullName = "int"
),
Identifier(
argumentIndex = 1,
argumentName = None,
code = "one_copy",
columnNumber = Some(value = 9),
dynamicTypeHintFullName = IndexedSeq(),
lineNumber = Some(value = 7),
name = "one_copy",
offset = None,
offsetEnd = None,
order = 1,
possibleTypes = IndexedSeq(),
typeFullName = "int"
),
Call(
argumentIndex = -1,
argumentName = None,
code = "one_copy + 0",
columnNumber = Some(value = 9),
dispatchType = "STATIC_DISPATCH",
dynamicTypeHintFullName = IndexedSeq(),
lineNumber = Some(value = 8),
methodFullName = "<operator>.addition",
name = "<operator>.addition",
offset = None,
offsetEnd = None,
order = 1,
possibleTypes = IndexedSeq(),
signature = "",
staticReceiver = None,
typeFullName = "ANY"
)
)
)
)
LaureanoOlocco
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working