Skip to content

Conversation

@aschackmull
Copy link
Contributor

This should make it easier to add custom taint steps that apply to all queries.

@aschackmull aschackmull requested a review from a team as a code owner August 22, 2019 14:44
* Gets a `DataFlow::Node` that this node can step to in one taint step.
*/
abstract DataFlow::Node step();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This interface differs slightly from the equivalent one in Javascript. Would it make sense to make this consistent across languages? (cc @xiemaisi)

Perhaps also add a similar warning re performance to the QLDoc?

Choose a reason for hiding this comment

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

I agree that it would be nice to make the API consistent. @aschackmull, could you explain the advantages of your proposed API? (The name of the class doesn't matter since we can always provide aliases, but the member predicate name and signature more difficult to assimilate.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For javascript there's the class

abstract class AdditionalTaintStep extends DataFlow::Node {
    abstract predicate step(DataFlow::Node pred, DataFlow::Node succ);
  }

I find this interface confusing as it is using a 3-column relation to specify a 2-column step relation. As far as I can see the this column is mostly ignored and appears to be arbitrarily restricted to be equal to one of the two other columns in the various overrides. I also think the name of the class in the javascript QL is slightly off (as it says it's a step, but really it's a single node), but that ties into the this column being mostly ignored, so a name describing the this column isn't tied to much.

As for the performance warning, I don't think it applies in the same way here as for javascript, since the default taint steps that we include are added as a separate predicate instead of being part of the dispatch, so that means we could cache it separately (which we btw. don't do currently - I haven't checked whether it would be worth it)

Choose a reason for hiding this comment

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

Thanks. Unfortunately that explanation does not convince me, in particular I would expect step to look like a binary predicate, not a predicate-with-a-result as in your API. The fact that in JavaScript this must be bound to something is indeed unfortunate, but the alternatives in present-day QL seemed worse.

I do, however, acknowledge that this is a matter of taste, so if most people feel that this API is better I won't stand in the way of its adoption.

Copy link
Contributor Author

@aschackmull aschackmull Aug 23, 2019

Choose a reason for hiding this comment

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

I could of course also use a single ordinary column instead of the result column:

abstract predicate step(DataFlow::Node node);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But I'm not sure that's better. It remains that it unfortunately isn't possible to write an abstract predicate in QL that both looks like a binary predicate and also is a binary predicate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jbj Suggests a third alternative, add an ipa unit-type as a base of the class, such that the this column is a trivial one-valued column. Then we can have a looks-like-binary predicate that also effectively is sort-of binary.

Choose a reason for hiding this comment

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

That is a very interesting idea. I think I would like that approach (even though it would still require an incompatible change in the JavaScript libraries, and hence would take time).

What do others think? (@esben-semmle, @asger-semmle, ...)

Copy link
Contributor

Choose a reason for hiding this comment

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

The unit type sounds good to me. I've been tempted to do the same thing in a few other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to use a unit type.

@yh-semmle yh-semmle merged commit c359675 into github:master Aug 30, 2019
@aschackmull aschackmull deleted the java/taint-step-extension-point branch September 2, 2019 07:24
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.

4 participants