Abstract Code Graph for Multi-Level Software Pattern Analysis
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Current software development and debugging tools lack efficient methods for comparing and analyzing software programs, particularly in representing source code at multiple levels of abstraction, which hinders effective identification of common code patterns and vulnerabilities.
Innovation Solution
The method generates an abstract code graph based on an abstract syntax tree, allowing for the representation of source code constructs and their relationships at various levels of abstraction, enabling meaningful comparisons and analyses of software programs.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Measurement precision
If source code is represented at a single level of abstraction (concrete level), then detailed code structure and relationships are preserved, but the ability to identify common code patterns across different implementations is hindered
Solution Approach 1:
The patent introduces a new dimension of abstraction levels by generating multiple representations of the same code at different abstraction levels (first level, second level, and third level). This allows the system to simultaneously preserve detailed code structure information while enabling high-level pattern matching, effectively resolving the contradiction between detail preservation and pattern identification capability.
Solution Approach 2:
The patent segments the code representation into multiple hierarchical levels, where each level captures different aspects of code structure. The first level maintains concrete details, while higher levels capture abstract patterns. This segmentation allows the system to query and compare code at the appropriate level of abstraction for each specific analysis task.
2Adaptability or versatility
If multiple levels of abstraction are introduced to represent code at different granularities, then code pattern identification improves, but the complexity of the representation structure increases
Solution Approach 1:
The patent implements a nested hierarchical structure where higher-level abstraction nodes contain references to lower-level nodes. The third level (most abstract) nodes are connected to second level nodes, which in turn are connected to first level nodes (most detailed). This nesting allows the system to manage complexity by organizing representations hierarchically, where each level builds upon the previous level rather than creating entirely separate structures.
Solution Approach 2:
The patent creates a universal representation framework that can handle multiple types of code analyses through a single multi-level structure. The same abstract code graph structure serves multiple purposes: detailed code understanding, pattern identification, vulnerability detection, and cross-language comparison, thereby reducing overall system complexity despite the multi-level representation.
3Productivity
If abstract code graphs are generated from abstract syntax trees with multiple abstraction levels, then software development and testing efficiency improves, but the processing time and computational resources increase
Solution Approach 1:
The patent performs preliminary action by pre-generating the multi-level abstract code graph representation during the code analysis phase. Once generated, this structured representation can be reused for multiple subsequent tasks such as pattern matching, vulnerability detection, and code comparison, avoiding the need to re-process the original source code repeatedly and thus reducing overall processing time.
Solution Approach 2:
The patent applies local quality by allowing different parts of the code representation to exist at different levels of abstraction simultaneously. Not all code regions need to be represented at the highest level of abstraction - the system can selectively use higher abstraction levels for pattern-matching regions while maintaining detailed representations for regions requiring precise analysis, optimizing the balance between processing speed and analysis depth.
Data Source
AI summary
According to an aspect of an embodiment, a method may include generating an abstract code graph (ACG). The method may include obtaining an abstract syntax tree (AST). The AST may include a first AST node that may represent a first construct at a first level of abstraction and a second AST node that may represent a second construct. The method may further include generating an ACG, based on the AST. The generating of ACG may include generating a first ACG node based on the first AST node and a second ACG node based on the second AST node. The generating of ACG may also include generating, based on the first ACG node, a third ACG node that represents the first construct at a second level of abstraction. The third ACG node may be connected between the first ACG node and the second ACG node based on the AST.


