GithubHelp home page GithubHelp logo

aurore54f / static-pdg-js Goto Github PK

View Code? Open in Web Editor NEW
16.0 3.0 1.0 59 KB

Static JavaScript Analysis: AST, Control Flow, Data Flow, & Pointer Analysis

License: GNU Affero General Public License v3.0

Python 98.99% JavaScript 1.01%
javascript ast data-flow control-flow pointer-analysis static-analysis

static-pdg-js's People

Contributors

aurore54f avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

chenzx-github

static-pdg-js's Issues

There may be a bug when constructing dfg.

Hi Aurore,

I notice there may be a bug leading to insufficient data flow relations. Here is an example:

1 function demo(flag){
2   if(flag){
3        return true;
4   }
5    else{
6       return false;
7    }
8  }
9  var this_flag = "1".toString(); // this_flag could be anything, we don't know its value when statically analyzing
10 var test_var;
11  if(demo(this_flag)){
12   console.log(test_var);
13  }
14  else{
15    console.log(test_var);
16 }

The variable test_var in line 10 has two data dependency children in line 12 and line 15. However, in the output dfg there is only one of them, which is the child test_var in line 15.

I suppose the problems comes from line 880 in data_flow.py

    return_value = None
    if function_def.fun_return:
           return_value = get_node_value(function_def.fun_return[-1], initial_node=node) #Here 
        # Last in, only one out
        # Beware, NOT get_node_computed_value because we want to compute the value again: the
        # previously stored value is the returned value hard coded in the function def before exec
    logging.debug('The function %s returns %s', function_name, return_value)
    node.set_value(return_value)

where you aggressively pop the last return value. However, the function demo may return two different values(true or false) according to parameter flag.
When we don't know the actual value of this parameter, the return value of demo(this_flag) in line 11 should be set to None instead of false. As the program always fetches the last value (i.e. false) in the func_return, code in true branch(line 12 in this case) would never be analyzed.

Thank you for your time and attention, and for providing such a valuable tool to the community. I look forward to hearing back from you soon.

Best regards,
Yifan

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.