Skip to content
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

[dataflowengineoss] Turn Semantics into a node-directed trait #4920

Merged
merged 4 commits into from
Sep 17, 2024

Conversation

xavierpinho
Copy link
Contributor

Presently, Semantics are exclusively based on method fullNames and, while that is perfectly reasonable for statically typed languages such as Java, they are not so great for dynamic ones.

The proposal here is to turn Semantics into a common trait equipped with a forMethod :: Method -> Option[FlowSemantic] operation, that can take into account more information (since it's given the node itself) other than just its fullName. In doing so, I also renamed the current Semantics class to FullNameSemantics, to make it clear what the latter operates on.

In particular, this would allow users of Joern as-a-library to provide their own custom Semantics instance, that can inform the dataflowengine on a node-by-node basis.

If this proposal is welcomed, I also intend to refactor SemanticTestCpg and friends to allow custom Semantic objects, instead of FullNameSemantics exclusively. Moreover, I'd also like to introduce a NoCrossTaint semantics -- essentially a lifted PassThroughMapping. This patch is already too large as is, so I refrained from doing so at this point.

@xavierpinho xavierpinho added the dataflow engine Relates to dataflowengineoss label Sep 13, 2024
@maltek maltek removed their request for review September 13, 2024 11:58
Copy link
Contributor

@mpollmeier mpollmeier left a comment

Choose a reason for hiding this comment

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

Sounds like a good idea from my POV, but since I'm not super familiar with Semantics I'll pass the torch to someone else, maybe @DavidBakerEffendi for approval..?

Copy link
Collaborator

@DavidBakerEffendi DavidBakerEffendi left a comment

Choose a reason for hiding this comment

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

Looks nice! Opens up a world of possibilities for this notation

@DavidBakerEffendi
Copy link
Collaborator

FYI I've experimented with representing parameters undergoing fine-grained operations such as field accesses and calls within a method, and that used a similar approach as above, but was pretty difficult (not undoable though). This already makes the semantic DSL more readable though.

@DavidBakerEffendi
Copy link
Collaborator

@xavierpinho do you have permissions to merge?

@xavierpinho xavierpinho merged commit 3a530c0 into master Sep 17, 2024
5 checks passed
@xavierpinho xavierpinho deleted the xavierp/dataflowengine/semantics-trait branch September 17, 2024 11:53
@xavierpinho
Copy link
Contributor Author

@xavierpinho do you have permissions to merge?

I have, thanks for asking :) Was just giving it some time in case someone wanted to chime in any other feedback first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dataflow engine Relates to dataflowengineoss
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants