Skip to content

Conversation

@JeffreyHuynh1
Copy link
Contributor

@JeffreyHuynh1 JeffreyHuynh1 commented Jul 23, 2024

Overview

It was discovered that the jar callgraph logic doesn’t account for creating all the appropriate edges for interfaces. Looking at the dependency mvn+com.squareup.okio_okio$1.15.0 we can see where our current jar callgraph logic fails to create the edges for interfaces.

Acceptance criteria

  • Properly create edges for interfaces

  • Update all code paths that use jar-callgraph.jar

    • jar-callgraph

    • fossa-cli

    • core

Testing plan

Manual testing plan:

  • checkout this branch
  • cd scripts
  • Run: java -jar jar-callgraph-1.0.2.jar /path/to/example/jar

Look at the output and see that we now edges for:

Makes edges for interface methods and the classes that implement them

M:okio.Source:timeout() (M)okio.Okio$2:timeout()
M:okio.Source:read(okio.Buffer,long) (M)okio.Okio$2:read(okio.Buffer,long)
M:okio.Source:close() (M)okio.Okio$2:close()
M:okio.Source:timeout() (M)okio.Pipe$PipeSource:timeout()
M:okio.Source:read(okio.Buffer,long) (M)okio.Pipe$PipeSource:read(okio.Buffer,long)
M:okio.Source:close() (M)okio.Pipe$PipeSource:close()
M:okio.Source:timeout() (M)okio.InflaterSource:timeout()
M:okio.Source:read(okio.Buffer,long) (M)okio.InflaterSource:read(okio.Buffer,long)
M:okio.Source:close() (M)okio.InflaterSource:close()
M:okio.Source:timeout() (M)okio.GzipSource:timeout()
M:okio.Source:read(okio.Buffer,long) (M)okio.GzipSource:read(okio.Buffer,long)
M:okio.Source:close() (M)okio.GzipSource:close()
M:okio.Source:timeout() (M)okio.AsyncTimeout$2:timeout()
M:okio.Source:read(okio.Buffer,long) (M)okio.AsyncTimeout$2:read(okio.Buffer,long)
M:okio.Source:close() (M)okio.AsyncTimeout$2:close()
M:okio.Source:timeout() (M)okio.ForwardingSource:timeout()
M:okio.Source:read(okio.Buffer,long) (M)okio.ForwardingSource:read(okio.Buffer,long)

Previously, we only had an edge like: M:okio.Buffer:writeAll(okio.Source) (I)okio.Source:read(okio.Buffer,long)
for interface method calls. Because we are calling an interface method, it is also possible to call of the classes that implement the interface depending on implementation. These are the newly added edges after the update.

M:okio.Buffer:writeAll(okio.Source) (I)okio.BufferedSource:read(okio.Buffer,long)
M:okio.Buffer:writeAll(okio.Source) (I)okio.Pipe$PipeSource:read(okio.Buffer,long)
M:okio.Buffer:writeAll(okio.Source) (I)okio.ForwardingSource:read(okio.Buffer,long)
M:okio.Buffer:writeAll(okio.Source) (I)okio.GzipSource:read(okio.Buffer,long)
M:okio.Buffer:writeAll(okio.Source) (I)okio.InflaterSource:read(okio.Buffer,long)
M:okio.Buffer:writeAll(okio.Source) (I)okio.AsyncTimeout$2:read(okio.Buffer,long)
M:okio.Buffer:writeAll(okio.Source) (I)okio.Okio$2:read(okio.Buffer,long)

Risks

Metrics

References

Checklist

  • I added tests for this PR's change (or explained in the PR description why tests don't make sense).
  • If this PR introduced a user-visible change, I added documentation into docs/.
  • If this PR added docs, I added links as appropriate to the user manual's ToC in docs/README.ms and gave consideration to how discoverable or not my documentation is.
  • If this change is externally visible, I updated Changelog.md. If this PR did not mark a release, I added my changes into an # Unreleased section at the top.
  • If I made changes to .fossa.yml or fossa-deps.{json.yml}, I updated docs/references/files/*.schema.json AND I have updated example files used by fossa init command. You may also need to update these if you have added/removed new dependency type (e.g. pip) or analysis target type (e.g. poetry).
  • If I made changes to a subcommand's options, I updated docs/references/subcommands/<subcommand>.md.

@JeffreyHuynh1 JeffreyHuynh1 requested a review from csasarak July 24, 2024 16:17
@JeffreyHuynh1 JeffreyHuynh1 marked this pull request as ready for review July 24, 2024 16:17
@JeffreyHuynh1 JeffreyHuynh1 requested a review from a team as a code owner July 24, 2024 16:17
Copy link
Contributor

@csasarak csasarak left a comment

Choose a reason for hiding this comment

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

Why do we need scripts/jar-callgraph-1.0.1.jar anymore?

@JeffreyHuynh1
Copy link
Contributor Author

Thanks for catching that, forgot to delete jar-callgraph-1.0.1.jar

@JeffreyHuynh1 JeffreyHuynh1 requested a review from csasarak July 30, 2024 20:05
@JeffreyHuynh1 JeffreyHuynh1 merged commit 93514ae into master Aug 6, 2024
@JeffreyHuynh1 JeffreyHuynh1 deleted the jar-callgraph-interface branch August 6, 2024 20:50
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.

3 participants