Repository navigation
C++: Fix a FN in cpp/cleartext-storage-file
#23019
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
Changes from all commits
1bcea30
11561b0
03a8c20
37581e4
c1402e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,37 @@ | ||||||||||||||||
| private import cpp | ||||||||||||||||
| private import semmle.code.cpp.dataflow.new.DataFlow | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * Holds if `node` should be a barrier for the CWE-311 queries | ||||||||||||||||
| * because it is of a non-char integral type. | ||||||||||||||||
| */ | ||||||||||||||||
| predicate isBarrier(DataFlow::Node node) { | ||||||||||||||||
| exists(IntegralType type | | ||||||||||||||||
| type = node.asCertainDefinition().getUnspecifiedType() and | ||||||||||||||||
| not type instanceof CharType and | ||||||||||||||||
| not type instanceof WideCharType and | ||||||||||||||||
| not type instanceof Char8Type and | ||||||||||||||||
| not type instanceof Char16Type and | ||||||||||||||||
| not type instanceof Char32Type | ||||||||||||||||
| ) | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| private Expr asExprOrIndirectExpr(DataFlow::Node node, int indirectionIndex) { | ||||||||||||||||
| indirectionIndex = 0 and | ||||||||||||||||
| result = node.asExpr() | ||||||||||||||||
| or | ||||||||||||||||
| result = node.asIndirectExpr(indirectionIndex) | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * Holds if `source` is the relevant `DataFlow::Node` for | ||||||||||||||||
| * expression `e`. | ||||||||||||||||
| */ | ||||||||||||||||
| predicate isSource(DataFlow::Node source, Expr e) { | ||||||||||||||||
| exists(int indirectionIndex | | ||||||||||||||||
| e = asExprOrIndirectExpr(source, indirectionIndex) and | ||||||||||||||||
| if e.getUnspecifiedType() instanceof ReferenceType | ||||||||||||||||
| then indirectionIndex = 1 | ||||||||||||||||
| else indirectionIndex = 0 | ||||||||||||||||
|
Comment on lines
+32
to
+35
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason you've written it in this very general way rather than just:
Suggested change
(which doesn't require
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would also work, yeah. |
||||||||||||||||
| ) | ||||||||||||||||
| } | ||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * The `cpp/cleartext-transmission` and `cpp/cleartext-storage-file` queries now track flow through character types. As a result, these queries may find additional results. |
Uh oh!
There was an error while loading. Please reload this page.