Skip to content

Conversation

rdmarsh2
Copy link
Contributor

@rdmarsh2 rdmarsh2 commented Apr 16, 2020

This adds a new RemoteFlowSource class for IR flow, based on a new model interface. I've included flow source models for fread and gets, 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.

Copy link
Contributor

@jbj jbj left a 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);
Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@rdmarsh2 rdmarsh2 force-pushed the rdmarsh/cpp/RemoteFlowSource-model branch from f3b84fe to d0bb5ad Compare April 20, 2020 20:25
@rdmarsh2 rdmarsh2 marked this pull request as ready for review April 20, 2020 20:26
@rdmarsh2 rdmarsh2 requested a review from a team as a code owner April 20, 2020 20:26
output.isParameterDeref(0)
override predicate hasRemoteFlowSource(FunctionOutput output, string description) {
output.isParameterDeref(0) and
description = "String read by " + this.getName()
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@jbj jbj merged commit cbed175 into master Apr 23, 2020
@rdmarsh2 rdmarsh2 deleted the rdmarsh/cpp/RemoteFlowSource-model branch February 15, 2022 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants