# US 2023/0273789 A1 · Language agnostic code classification

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2023/0273789 A1
- Document ID: US20230273789A1
- Status: Published application
- Kind: A1
- Application number: 18/111,465
- Filed: 2023-02-17
- Published: 2023-08-31
- Earliest claimed: 2021-03-04
- Assignees: Oracle International Corporation
- Applicants: Oracle International Corporation
- Inventors: Mahinthan Chandramohan; Robert James Wall
- Web page: https://patentgrep.com/patent/US20230273789A1

## CPC

- G06F 8/73: Program documentation
- G06N 3/08: Learning methods
- G06F 8/75: Structural analysis for program understanding
- G06N 3/042: Knowledge-based neural networks; Logical representations of neural networks
- G06N 3/045: Combinations of networks
- G06N 3/09: Supervised learning
- G06N 3/096: Transfer learning
- G06N 5/01: Dynamic search techniques; Heuristics; Dynamic trees; Branch-and-bound
- G06N 20/00: Machine learning
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS

## Abstract

A system may include a computer processor and a repository configured to store a first code fragment including language features represented in a first programming language, and a second code fragment including language features represented in a second programming language. The system may further include a universal code fragment classifier, executing on the computer processor and configured to generate a first universal abstract syntax tree for the first code fragment and a second universal abstract syntax tree for the second code fragment, generate, using a graph embedding model, first vectors for the first universal abstract syntax tree and second vectors for the second universal abstract syntax tree, and classify, by executing an abstract syntax tree classifier on the first vectors and the second vectors, the first code fragment as a first code category and the second code fragment as a second code category.

## Claims

### Claim 1

A system comprising:
a computer processor;
a repository configured to store:
a first code fragment comprising a first plurality of language features represented in a first programming language,
a second code fragment comprising a second plurality of language features represented in a second programming language,
a first universal abstract syntax tree for the first code fragment, and
a second universal abstract syntax tree for the second code fragment, wherein the first universal abstract syntax tree and the second universal abstract syntax tree each comprise at least one language independent feature; and
a universal code fragment classifier executing on the computer processor and configured to:
generate the first universal abstract syntax tree for the first code fragment and the second universal abstract syntax tree for the second code fragment,
generate, using a graph embedding model, a first plurality of vectors directly from subtrees of the first universal abstract syntax tree,
generate, using a graph embedding model, a second plurality of vectors directly from subtrees of the second universal abstract syntax tree, and
classify, by executing an abstract syntax tree classifier on the first plurality of vectors and the second plurality of vectors, the first code fragment as a first code category and the second code fragment as a second code category.

### Claim 2 (depends on 1)

The system of claim 1, wherein the universal code fragment classifier is further configured to:
in response to classifying the first code fragment as the first code category, perform a security analysis using the first code fragment, wherein the first code category is at least one selected from a group consisting of “taint source,” “taint sink,” and “sanitizer”.

### Claim 3 (depends on 1)

The system of claim 1, wherein the universal code fragment classifier is further configured to:
train the abstract syntax tree classifier using training code fragments comprising first code fragments represented in the first programming language and second code fragments represented in the second programming language to generate a trained abstract syntax tree classifier.

### Claim 4 (depends on 3)

The system of claim 3, wherein the universal code fragment classifier is further configured to:
using the trained abstract syntax tree classifier to classify a third code fragment comprising third language features represented in a third programming language by executing the abstract syntax tree classifier on a third plurality of vectors generated from a third universal abstract syntax tree for the third code fragment.

### Claim 5 (depends on 1)

The system of claim 1,
wherein the first universal abstract syntax tree comprises a subtree for a first language feature of the first plurality of language features,
wherein the first language feature is one selected from a group consisting of a control flow statement and a declaration statement, and
wherein the first plurality of vectors comprises a vector for the subtree.

### Claim 6 (depends on 5)

The system of claim 5, wherein the first universal abstract syntax tree comprises a plurality of nodes, wherein the subtree comprises a first node of the plurality of nodes, and wherein the universal code fragment classifier is further configured to generate the first plurality of vectors by:
identifying, for the first node, a subset of the plurality of nodes in a local neighborhood of the first node, and
aggregating information from a subset of the first plurality of language features corresponding to the subset of the plurality of nodes in the local neighborhood of the first node.

### Claim 7 (depends on 1)

The system of claim 1, wherein the universal code fragment classifier is further configured to:
generate a language-specific abstract syntax tree for the first code fragment and the first programming language, and
convert the language-specific abstract syntax tree to the first universal abstract syntax tree.

### Claim 8 (depends on 1)

The system of claim 1,
wherein the first universal abstract syntax tree further comprises a first language-specific feature that is specific to the first programming language, and
wherein the second universal abstract syntax tree further comprises a second language-specific feature that is specific to the second programming language.

### Claim 9

A method comprising:
obtaining a first code fragment comprising a first plurality of language features represented in a first programming language and a second code fragment comprising a second plurality of language features represented in a second programming language;
generating a first universal abstract syntax tree for the first code fragment and a second universal abstract syntax tree for the second code fragment, wherein the first universal abstract syntax tree and the second universal abstract syntax tree each comprise at least one language independent feature;
generating, using a graph embedding model, a first plurality of vectors directly from subtrees of the first universal abstract syntax tree;
generating, using the graph embedding model, a second plurality of vectors directly from subtrees of the second universal abstract syntax tree; and
classifying, by executing an abstract syntax tree classifier on the first plurality of vectors and the second plurality of vectors, the first code fragment as a first code category and the second code fragment as a second code category.

### Claim 10 (depends on 9)

The method of claim 9, further comprising:
in response to classifying the first code fragment as the first code category, performing a security analysis using the first code fragment, wherein the first code category is a security relevant category.

### Claim 11 (depends on 9)

The method of claim 9, further comprising:
training the abstract syntax tree classifier using training code fragments comprising first code fragments represented in the first programming language and second code fragments represented in the second programming language to generate a trained abstract syntax tree classifier.

### Claim 12 (depends on 11)

The method of claim 11, further comprising:
using the trained abstract syntax tree classifier to classify a third code fragment comprising third language features represented in a third programming language by executing the abstract syntax tree classifier on a third plurality of vectors generated from a third universal abstract syntax tree for the third code fragment.

### Claim 13 (depends on 9)

The method of claim 9,
wherein the first universal abstract syntax tree comprises a subtree for a first language feature of the first plurality of language features,
wherein the first language feature is one selected from a group consisting of a control flow statement and a declaration statement, and
wherein the first plurality of vectors comprises a vector for the subtree.

### Claim 14 (depends on 13)

The method of claim 13, wherein the first universal abstract syntax tree comprises a plurality of nodes, wherein the subtree comprises a first node of the plurality of nodes, and wherein generating the first plurality of vectors comprises:
identifying, for the first node, a subset of the plurality of nodes in a local neighborhood of the first node; and
aggregating information from a subset of the first plurality of language features corresponding to the subset of the plurality of nodes in the local neighborhood of the first node.

### Claim 15 (depends on 9)

The method of claim 9, further comprising:
generating a language specific abstract syntax tree for the first code fragment and the first programming language; and
converting the language specific abstract syntax tree to the first universal abstract syntax tree.

### Claim 16 (depends on 9)

The method of claim 9,
wherein the first universal abstract syntax tree further comprises a first language specific feature that is specific to the first programming language, and
wherein the second universal abstract syntax tree further comprises a second language specific feature that is specific to the second programming language.

### Claim 17

A method comprising:
obtaining a first code fragment comprising a first plurality of language features represented in a first programming language;
sending the first code fragment to a universal code fragment classifier configured to perform:
generating a first universal abstract syntax tree for the first code fragment, wherein the first universal abstract syntax tree comprises at least one language independent feature,
generating, using a graph embedding model, a first plurality of vectors directly from subtrees of the first universal abstract syntax tree,
classifying, by executing an abstract syntax tree classifier on the first plurality of vectors, the first code fragment as a first code category, and
transmitting the first code category for the first code fragment; and
receiving, from the universal code fragment classifier, the first code category for the first code fragment.

### Claim 18 (depends on 17)

The method of claim 17, wherein the universal code fragment classifier is further configured to:
in response to classifying the first code fragment as the first code category, perform a security analysis using the first code fragment, wherein the first code category is a security relevant category.

### Claim 19 (depends on 17)

The method of claim 17, wherein the universal code fragment classifier is further configured to:
train the abstract syntax tree classifier using training code fragments comprising first code fragments represented in the first programming language and second code fragments represented in the second programming language to generate a trained abstract syntax tree classifier,
using the trained abstract syntax tree classifier to classify a third code fragment comprising third language features represented in a third programming language by executing the abstract syntax tree classifier on a third plurality of vectors generated from a third universal abstract syntax tree for the third code fragment.

### Claim 20 (depends on 17)

The method of claim 17,
wherein the first universal abstract syntax tree comprises a subtree for a first language feature of the first plurality of language features,
wherein the first language feature is one selected from a group consisting of a control flow statement and a declaration statement, and
wherein the first plurality of vectors comprises a vector for the subtree.
