JavaScript Control Flow Graph via Lambda-JS and CPS

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

JavaScript's dynamic typing and implicit behaviors make it challenging to detect bugs and vulnerabilities in software code, as variable types are not enforced, leading to complex and difficult-to-analyze runtime behaviors.

Innovation Solution

Constructing a control flow graph (CFG) for JavaScript software programs using lambda-JS semantics and continuation-passing style (CPS) models, followed by optimization and analysis to expose implicit behaviors, allowing for bug detection and validation through flow analysis, taint analysis, and symbolic execution.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Ease of operation

If JavaScript's dynamic typing and implicit behaviors are used, then flexibility and ease of programming are improved, but code analysis difficulty and bug detection difficulty increase

Engineering Contradiction:
Improveease of programmingVSAvoidcode analysis difficulty
Core Design Contradiction:
Ease of operationVSDifficulty of detecting and measuring

Solution Approach 1:

The patent introduces an intermediary representation (IR) that serves as a mediator between the JavaScript source code and the control flow graph. This IR captures the dynamic typing and implicit behaviors explicitly, allowing static analysis tools to reason about JavaScript code without being hindered by its dynamic nature. The IR acts as a bridge that preserves JavaScript's flexibility while making the code amenable to static analysis.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The patent performs preliminary transformation of JavaScript code into an intermediary representation before constructing the control flow graph. This preliminary action captures implicit behaviors and dynamic typing characteristics in advance, converting them into explicit structures that can be easily analyzed. By doing this transformation beforehand, the patent eliminates the need for complex runtime analysis while preserving JavaScript's dynamic features.

Inventive Principle:
Principle #10Preliminary action

2Speed

If JavaScript code is executed directly without transformation, then execution speed is maintained, but static analysis capability is lost

Engineering Contradiction:
Improveexecution speedVSAvoidstatic analysis capability
Core Design Contradiction:
SpeedVSReliability

Solution Approach 1:

The patent segments the JavaScript code analysis process into distinct phases: code transformation to intermediary representation, control flow graph construction, and static analysis. This segmentation allows the original JavaScript code to remain unchanged for execution, while a transformed version is created specifically for analysis purposes. The segmentation ensures that execution speed is not impacted while enabling comprehensive static analysis capability.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent creates a copy of the JavaScript code in the form of an intermediary representation that is suitable for static analysis. This copy preserves the semantic meaning and control flow of the original code while making implicit behaviors explicit. The original code continues to execute at full speed, while the copied IR version enables reliable static analysis for bug detection and validation.

Inventive Principle:
Principle #26Copying

3Measurement precision

If control flow graph construction includes detailed implicit behavior transformation, then bug detection accuracy is improved, but processing time and computational complexity increase

Engineering Contradiction:
Improvebug detection accuracyVSAvoidprocessing time
Core Design Contradiction:
Measurement precisionVSLoss of time

Solution Approach 1:

The patent applies local quality by transforming only the necessary implicit behaviors into explicit forms in the intermediary representation, rather than transforming all possible aspects of the code. This selective transformation focuses on capturing the specific implicit behaviors that affect control flow and bug detection, while leaving other aspects unchanged. This approach achieves high bug detection accuracy without incurring excessive processing time or computational complexity.

Inventive Principle:
Principle #3Local quality

Data Source

PatentUS8949811B2Constructing a control flow graph for a software program
Publication Date: 2015.02.03 FUJITSU LTD
  • US8949811B2 patent drawing
  • US8949811B2 patent drawing
  • US8949811B2 patent drawing

AI summary

A method includes constructing a lambda object-oriented scripting language (λJS) model for a software program written in JavaScript; converting the λJS model to a continuation-passing style (CPS) model for the software program; constructing a control flow graph (CFG) for the software program based on the CPS model; and optimizing the CPS model by merging a sequence of two or more “let” operations. The two or more “let” operations in the CPS model and are generated based on the λJS model, so that they are represented by a single node in the CFG.