Giter VIP home page Giter VIP logo

simplecfg's Introduction

Simple CFG module for ExtendJ

This is a Control Flow Graph (CFG) module for the ExtendJ compiler for building simplified CFGs. This module builds CFGs for Java methods where only branches and method calls have are included. These simple CFGs provide enough information to perform intraprocedural static analyses on Java code.

This repository also includes two sample Java static analyzers based on the this CFG module. One analyzer checks for additional calls to a java.io.Reader/java.io.Writer after close() was called on the same instance. The other analyzer checks for potential null dereferences on paramters annotated with javax.annotation.Nullable.

Disclaimer

This is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google.

Shipshape Module

The demo analyzers can be plugged into the Shipshape pipeline. The Shipshape integration is currently experimental.

Dependencies

To build the Simplified CFG generator you need the following dependencies:

  • Git
  • Gradle 2.4
  • ExtendJ

This repository has a submodule for the ExtendJ compiler. If you did not clone this repository with the --recursive flag you will have to run git submodule init followed by git submodule update, this will clone a specific commit from the ExtendJ repository into the third_party/extendj/ directory.

Building

Note that you must have the Git submodule third_party/extendj/git in order to build SimpleCFG. To download the submodule, use the following commands:

git submodule init
git submodule update

Build the Simplified CFG generator Jar file by running the following Gradle command:

gradle jar

Testing

The tests may be run by issuing the following command:

gradle test

Most tests check that a well-formed SimpleCFG is built for each Java file in the testdata directory. The tests are structured so that they test the successors of each node in the resulting CFG for the single block/method in each of the Java files.

You can generate images for the CFGs in each test file by running the graph.sh shell script.

simplecfg's People

Contributors

emsod avatar llbit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

simplecfg's Issues

Null checks in method argument

The Nullable Dereference analyzer currently does not handle the case when a null check is performed by passing the result of the null check to a function that aborts execution if the checked parameter was null, for example:

void m(@Nullable String argument) {
  ensureTrue(argument != null);  // Throws exception if argument == null.
  argument.hashCode();  // False positive generated here.
}

To be able to exactly analyze the above an intraprocedural analysis would be required, so to avoid this false positive the analyzer could just stop analyzing the rest of the control flow after it sees the parameter inside an expression that is passed ot a method.

Security Policy violation Binary Artifacts

This issue was automatically created by Allstar.

Security Policy Violation
Project is out of compliance with Binary Artifacts policy: binaries present in source code

Rule Description
Binary Artifacts are an increased security risk in your repository. Binary artifacts cannot be reviewed, allowing the introduction of possibly obsolete or maliciously subverted executables. For more information see the Security Scorecards Documentation for Binary Artifacts.

Remediation Steps
To remediate, remove the generated executable artifacts from the repository.

Artifacts Found

  • third_party/shipshape/java_dispatcher_deploy.jar

Additional Information
This policy is drawn from Security Scorecards, which is a tool that scores a project's adherence to security best practices. You may wish to run a Scorecards scan directly on this repository for more details.


Allstar has been installed on all Google managed GitHub orgs. Policies are gradually being rolled out and enforced by the GOSST and OSPO teams. Learn more at http://go/allstar

This issue will auto resolve when the policy is in compliance.

Issue created by Allstar. See https://github.com/ossf/allstar/ for more information. For questions specific to the repository, please contact the owner or maintainer.

Indirect null checks of fields

The analyzer can't handle the case where there is an indirect null check of a field and then a dereferencing of that field.

For instance:

protected Object obj;
void m() {
...
if (test()) {
obj.m();
}
...
}
boolean test() {
return obj != null;
}

NullDereference is missing non-null case

This case produces a false positive:

if (x == null && y == null) {
return null;
}
// If x is null then y is not null
z = (x != null) ? x.m() : y.m(); // false positive for y.m()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.