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

[Java Integration]: Add in WALA support #540

Merged
merged 6 commits into from
Oct 12, 2022

Conversation

arthurscchan
Copy link
Contributor

@arthurscchan arthurscchan commented Oct 10, 2022

Add in WALA support as an alternative to generate more static analysing data for java code.
This PR is targeting step 2 and 3 from Issue #536

Signed-off-by: Arthur Chan [email protected]

@arthurscchan
Copy link
Contributor Author

Node: synthetic < Primordial, Lcom/ibm/wala/FakeRootClass, fakeRootMethod()V > Context: Everywhere
 - invokestatic < Primordial, Lcom/ibm/wala/FakeRootClass, fakeWorldClinit()V >@0
   -> Node: synthetic < Primordial, Lcom/ibm/wala/FakeRootClass, fakeWorldClinit()V > Context: Everywhere
 - invokespecial < Primordial, Ljava/lang/Object, <init>()V >@4
   -> Node: < Primordial, Ljava/lang/Object, <init>()V > Context: Everywhere
 - invokestatic < Application, LTestFuzzer, main([Ljava/lang/String;)V >@5
   -> Node: < Application, LTestFuzzer, main([Ljava/lang/String;)V > Context: Everywhere
Node: synthetic < Primordial, Lcom/ibm/wala/FakeRootClass, fakeWorldClinit()V > Context: Everywhere
 - invokestatic < Primordial, Ljava/lang/Object, <clinit>()V >@0
   -> Node: < Primordial, Ljava/lang/Object, <clinit>()V > Context: Everywhere
 - invokestatic < Primordial, Ljava/lang/String, <clinit>()V >@1
   -> Node: < Primordial, Ljava/lang/String, <clinit>()V > Context: Everywhere
Node: < Primordial, Ljava/lang/Object, <clinit>()V > Context: Everywhere
 - invokestatic < Primordial, Ljava/lang/Object, registerNatives()V >@0
   -> Node: < Primordial, Ljava/lang/Object, registerNatives()V > Context: Everywhere
Node: < Primordial, Ljava/lang/Object, registerNatives()V > Context: Everywhere
Node: < Primordial, Ljava/lang/String, <clinit>()V > Context: Everywhere
 - invokespecial < Primordial, Ljava/lang/String$CaseInsensitiveComparator, <init>(Ljava/lang/String$1;)V >@12
   -> Node: < Primordial, Ljava/lang/String$CaseInsensitiveComparator, <init>(Ljava/lang/String$1;)V > Context: Everywhere
Node: < Primordial, Ljava/lang/String$CaseInsensitiveComparator, <init>(Ljava/lang/String$1;)V > Context: Everywhere
 - invokespecial < Primordial, Ljava/lang/String$CaseInsensitiveComparator, <init>()V >@1
   -> Node: < Primordial, Ljava/lang/String$CaseInsensitiveComparator, <init>()V > Context: Everywhere
Node: < Primordial, Ljava/lang/String$CaseInsensitiveComparator, <init>()V > Context: Everywhere
 - invokespecial < Primordial, Ljava/lang/Object, <init>()V >@1
   -> Node: < Primordial, Ljava/lang/Object, <init>()V > Context: Everywhere
Node: < Primordial, Ljava/lang/Object, <init>()V > Context: Everywhere
Node: < Application, LTestFuzzer, main([Ljava/lang/String;)V > Context: Everywhere
 - invokestatic < Application, LTestFuzzer, fuzzerTestOneInput(Lcom/code_intelligence/jazzer/api/FuzzedDataProvider;)V >@9
   -> Node: < Application, LTestFuzzer, fuzzerTestOneInput(Lcom/code_intelligence/jazzer/api/FuzzedDataProvider;)V > Context: Everywhere
Node: < Application, LTestFuzzer, fuzzerTestOneInput(Lcom/code_intelligence/jazzer/api/FuzzedDataProvider;)V > Context: Everywhere

The above is a dump of the CallGraph object generated when statically analyse the following program.

import com.code_intelligence.jazzer.api.FuzzedDataProvider;
import com.code_intelligence.jazzer.api.CannedFuzzedDataProvider;


public class TestFuzzer {
        public static void fuzzerTestOneInput(FuzzedDataProvider data) {
                return;
        }

        public static void main(String[] args) {
                TestFuzzer.fuzzerTestOneInput(new CannedFuzzedDataProvider("RANDOM"));
        }
}

@arthurscchan
Copy link
Contributor Author

Some findings right now

  1. The call graph will shows everything it goes through, including the WALA logic itself, it is possible to use exclude options to exclude result from files in certain java package. This has been confirmed.
  2. By default, it will look for a public class with main method to act as starting point for the analysis. This could be specified by commands. Investigating different settings to allow this.
  3. The call graph object store much more information, including method signature and line number in source code, that could be retrieved through different method. Will read the javadoc and investigate on this after lunch.

Javadoc of the WALA is at follows
https://wala.github.io/javadoc/

@DavidKorczynski
Copy link
Contributor

3. The call graph object store much more information, including method signature and line number in source code, that could be retrieved through different method.

This is promising

@DavidKorczynski
Copy link
Contributor

Am not sure about legalities with license, but I think it might be best to keep all that is WALA licensed (eclipse license) in a separate repository, similar to what we did with PyCG for the Python frontend. Can we move some of this to Ada Logics for now?

Signed-off-by: Arthur Chan <[email protected]>
@arthurscchan arthurscchan reopened this Oct 10, 2022
@DavidKorczynski DavidKorczynski marked this pull request as draft October 10, 2022 18:58
@arthurscchan arthurscchan force-pushed the fix-logic branch 2 times, most recently from 1449f05 to 7124638 Compare October 12, 2022 12:43
Signed-off-by: Arthur Chan <[email protected]>
Signed-off-by: Arthur Chan <[email protected]>
@arthurscchan arthurscchan marked this pull request as ready for review October 12, 2022 13:00
@DavidKorczynski DavidKorczynski merged commit 914111b into ossf:main Oct 12, 2022
@arthurscchan arthurscchan deleted the fix-logic branch October 29, 2022 00:09
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