-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C++: Add remote flow sources via models #3273
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
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.
Otherwise LGTM. I like this design as it lets us avoid repeating the charpreds and boilerplate we already have for modelling other aspects of functions (like fgets
). It's also, AFAICT, possible for users to extend RemoteFlowSource
directly if they should prefer.
* A library function which returns data read from a network connection. | ||
*/ | ||
abstract class RemoteFlowFunction extends Function { | ||
abstract predicate hasFlowSource(FunctionOutput output); |
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.
If we later add a LocalFlowFunction
, like C# has LocalFlowSource
, the name hasFlowSource
becomes ambiguous. I suggest renaming to hasRemoteFlowSource
.
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.
Done
* A library function which returns data read from a network connection. | ||
*/ | ||
abstract class RemoteFlowFunction extends Function { | ||
abstract predicate hasFlowSource(FunctionOutput output); |
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.
Would it be any problem to add a string
parameter to hold the textual description of the flow type, like you did in #3274 to be compatible with the other languages?
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.
Done
Co-Authored-By: Jonas Jensen <jbj@github.com>
f3b84fe
to
d0bb5ad
Compare
output.isParameterDeref(0) | ||
override predicate hasRemoteFlowSource(FunctionOutput output, string description) { | ||
output.isParameterDeref(0) and | ||
description = "String read by " + this.getName() |
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.
This description looks good enough to me. If we're not planning to provide any more detail, then it doesn't seem necessary to have a description
parameter on hasRemoteFlowSource
. The same information is available in the Tainted{Parameter,Return}Source
classes, and it should be less work to construct the description there than to repeat it for every RemoteFlowFunction
.
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.
I was expecting that we would provide more detail when it's useful, but fread
and gets
are the least-specific sources we'll deal with.
This adds a new
RemoteFlowSource
class for IR flow, based on a new model interface. I've included flow source models forfread
andgets
, since they had model classes already.This is consistent with the direction the C++ library is moving for flow sinks such as allocation sizes and format arguments, but rather different from the Java and C# versions of
RemoteFlowSource
. I've also opened #3274 showing a version that's closer to the Java and C# versions.