-
Notifications
You must be signed in to change notification settings - Fork 1.9k
C++: Refine Node.asDefinition
#19001
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
C++: Refine Node.asDefinition
#19001
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot wasn't able to review any files in this pull request.
Files not reviewed (6)
- cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll: Language not supported
- cpp/ql/src/Security/CWE/CWE-079/CgiXss.ql: Language not supported
- cpp/ql/src/Security/CWE/CWE-114/UncontrolledProcessOperation.ql: Language not supported
- cpp/ql/src/Security/CWE/CWE-134/UncontrolledFormatString.ql: Language not supported
- cpp/ql/src/Security/CWE/CWE-170/ImproperNullTerminationTainted.ql: Language not supported
- cpp/ql/src/Security/CWE/CWE-190/ArithmeticTainted.ql: Language not supported
Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more
jketema
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bit of nitpicking below, otherwise LGTM.
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll
Outdated
Show resolved
Hide resolved
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll
Outdated
Show resolved
Hide resolved
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll
Outdated
Show resolved
Hide resolved
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll
Outdated
Show resolved
Hide resolved
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll
Outdated
Show resolved
Hide resolved
Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
In #18942 we're slightly changing how we handle uncertain writes. For example, consider this example:
On
mainwe get dataflow from// 1to// 3by realizing that// 2is an uncertain write (i.e., it doesn't overwrite the entire buffer), and so we insert a direct def-use step from// 1to// 3here.This has always been a bit of a hack since this can create a quadratic number of def-use edges. Luckily, the
DataFlowIntegrationmodule that Schack is porting to C++ in #18942 does flow through uncertain writes slightly differently. In the above example, it adds a step from// 1to// 2and (because//2is an uncertain definition) another step from// 2to// 3. This gets rid of the quadratic number of steps 🎉However, we have some queries that assume that, if we reach a
StoreInstructionthen we'll continue with that def-use flow. For example here we place a barrier when writing to a non-char pointer type since we don't want to track flow to arithmetic values in that query.Now that we have other flows out of that
StoreInstructionthis no longer holds true. So this PR adds a column toasDefinitionso that it's possible to check whether or not the definition overwrites the entire buffer. I also added convenience predicatesasCertainDefinitionandasUncertainDefinitionto avoid memorizing what that boolean means, and changed all our queries to use the new API.New results
We have three new results:
openjdk-jdkresult is a new TP. Previously, we were marking this assignment as a barrier, and we obviusly don't want to do that as this is basically astrcpy-like function. By only marking certain writes as barriers this is no longer considered a barrier for the query.vim__vimresult also looks TP-ish. Onmainwe place a barrier on this assignment, and now we don't do that since the write only partially overwrites the buffer. As far as I can tell this write sits inside a very large loop that iterators over some tainted data, and so we write each character individually intoformat(i.e., we grab each character here). So I thinks this result is genuine as well.neovim__neovimresult is identical to thevim__vimresult