-
Notifications
You must be signed in to change notification settings - Fork 1.8k
JS: Add decorator edges in API graphs and corresponding MaD tokens #8576
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
0f18f64
to
cf596a1
Compare
exists(Parameter param | | ||
useNodeFlowsToDecorator(base, param.getADecorator()) and | ||
lbl = Label::decoratedParameter() and | ||
ref = DataFlow::parameterNode(param) |
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'm unsure if there should be a def-node for this parameter-node.
And the tests pass just fine if I move the decoratedParameter
edge to the decoratorUseEdge
predicate.
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.
It's technically possible for the parameter decorator to replace the whole method with one that treats that parameter as a sink.
I have never seen any decorators that would have such behaviour, though. A made-up example might be a decorator that adds some expensive runtime checks on a value, which could then be a DoS sink.
In any case, it turns out using a parameter node as a sink is actually a terrible idea, at least with the current implementation (see test case in ca145f2).
So I've changed it to only generate use-nodes 👍
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
…ql into js/decorated-method-or-class
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.
👍
You just need the autoformatter to be happy.
Thanks for the reviews! I've started an evaluation |
Evaluation seems ok |
Adds the following
API::Node
members:getADecoratedClass
getADecoratedMember
getADecoratedParameter
And corresponding MaD tokens:
DecoratedClass
DecoratedMember
DecoratedParameter
For example:
DecoratedClass
could alternatively be expressed in terms ofArgument[0]
andReturnValue
. The others are not so simple, however, as they involve passing a base object and member name as an argument to the decorator, which typically then performs a reflective lookup. We don't have API edges for reflective lookups as they're tricky to model as unary operators.So for the time being, no argument/return edges are generated for any of the decorator patterns although it's possible we should do so for class decorators in the future.
Awaiting evaluation when DCA comes up again.