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

Fix self-referencing issue in getMethodSignatureInSubClass at ICFGDotExporter #920

Merged
merged 1 commit into from
Apr 15, 2024

Conversation

shenjunjiekoda
Copy link
Contributor

@shenjunjiekoda shenjunjiekoda commented Apr 13, 2024

Problem

In the current implementation of getMethodSignatureInSubClass within ICFGDotExporter.java, there's a logical oversight where the method could potentially include the target method in its own set of sub-class method signatures. This leads to the incorrect behavior in connectEdgesToSubClasses, where a method might connect an edge from its starting statement back to itself, causing confusion in the call graph visualization.

Before applying the PR change:
source in connectEdgesToSubClasses:

Set<MethodSignature> methodSignatureInSubClass =
        getMethodSignatureInSubClass(source, target, callgraph);

Here result methodSignatureInSubClass will contains target

sink in connectEdgesToSubClasses:

calls.put(
                  method.get().getBody().getStmtGraph().getStartingStmt().hashCode(),
                  subclassmethodSignature);

which will also overwrite previous entry set where call the connectEdgesToSubClasses in computeCalls

 if (stmt.containsInvokeExpr()) {
            MethodSignature target = stmt.getInvokeExpr().getMethodSignature();
            int hashCode = stmt.hashCode();
            calls.put(hashCode, target);
            // compute all the classes that are made to the subclasses as well
            connectEdgesToSubClasses(source, target, view, calls, callgraph);

Solution

This PR addresses the issue by adding an additional check in the filter operation within getMethodSignatureInSubClass. The updated logic ensures that the target method signature is explicitly excluded from the set of callable sub-class signatures.

Changes Made

  • Updated the filter condition to exclude the target from the results if it matches the source.

Thank you for considering this fix to improve the accuracy of our tool.

@shenjunjiekoda shenjunjiekoda changed the title Fix self-referencing issue in getMethodSignatureInSubClass at ICFGDotExporter Fix self-referencing issue in getMethodSignatureInSubClass at ICFGDotExporter and update implementation for BackwardsStmtGraph Apr 13, 2024
@shenjunjiekoda shenjunjiekoda changed the title Fix self-referencing issue in getMethodSignatureInSubClass at ICFGDotExporter and update implementation for BackwardsStmtGraph Fix self-referencing issue in getMethodSignatureInSubClass at ICFGDotExporter Apr 13, 2024
Copy link

codecov bot commented Apr 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.04%. Comparing base (5af272d) to head (0ff4b1c).
Report is 18 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #920      +/-   ##
=============================================
+ Coverage      69.97%   70.04%   +0.06%     
- Complexity      4061     4069       +8     
=============================================
  Files            312      312              
  Lines          15281    15303      +22     
  Branches        2611     2618       +7     
=============================================
+ Hits           10693    10719      +26     
+ Misses          3731     3727       -4     
  Partials         857      857              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@swissiety swissiety requested a review from JonasKlauke April 15, 2024 07:55
Copy link
Collaborator

@JonasKlauke JonasKlauke left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this bug 👍

@JonasKlauke JonasKlauke merged commit 68865f1 into soot-oss:develop Apr 15, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants