# US 2023/0267066 A1 · Software anomaly detection

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

- Number: US 2023/0267066 A1
- Document ID: US20230267066A1
- Status: Published application
- Kind: A1
- Application number: 17/652,353
- Filed: 2022-02-24
- Published: 2023-08-24
- Earliest claimed: 2022-02-24
- Assignees: International Business Machines Corporation
- Applicants: International Business Machines Corporation
- Inventors: Steven I. Ross; Stephanie Houde; Fernando Carlos Martinez; Hendrik Strobelt
- Web page: https://patentgrep.com/patent/US20230267066A1

## CPC

- G06F 11/3616: {using software metrics}
- G06F 8/75: Structural analysis for program understanding
- G06F 11/3604: Analysis of software for verifying properties of programs (testing of software G06F11/3668)
- G06F 21/563: {by source code analysis}
- G06F 2201/81: Threshold
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method, computer system, and a computer program product for software anomaly detection is provided. The present invention may include, receiving a target source code including a sequence of tokens. The present invention may also include, determining a probability of a candidate token in the sequence of tokens based on a context of other tokens in the sequence of tokens. The present invention may further include, in response to the determined probability of the candidate token satisfying a low probability threshold, detecting a low probability region in the received target source code, wherein the detected low probability region is associated with the candidate token satisfying the low probability threshold.

## Claims

### Claim 1

A computer-implemented method, comprising:
receiving a target source code including a sequence of tokens;
determining a probability of a candidate token in the sequence of tokens based on a context of other tokens in the sequence of tokens; and
in response to the determined probability of the candidate token satisfying a low probability threshold, detecting a low probability region in the received target source code, wherein the detected low probability region is associated with the candidate token satisfying the low probability threshold.

### Claim 2 (depends on 1)

The method of claim 1, further comprising:
generating an alternative to the detected low probability region of the received target source code, wherein the generated alternative includes an alternative token to replace the candidate token in the sequence of tokens, wherein the determined probability of the alternative token in the sequence of tokens is relatively higher than the determined probability of the candidate token satisfying the low probability threshold.

### Claim 3 (depends on 2)

The method of claim 2, further comprising:
modifying the received target source code based on the generated alternative to the detected low probability region of the received target source code; and
determining the probability of each token in the sequence of tokens based on the context of other tokens in the sequence of tokens, wherein the sequence of tokens in the modified target source code includes the alternative token.

### Claim 4 (depends on 1)

The method of claim 1, wherein determining the probability of the candidate token in the sequence of tokens based on the context of other tokens in the sequence of tokens further comprises:
determining the probability of each token in the sequence of tokens based on the context of other tokens in the sequence of tokens.

### Claim 5 (depends on 4)

The method of claim 4, wherein the detected low probability region in the received target source code is detected based on the determined probability of a corresponding token in the detected low probability region satisfying the low probability threshold.

### Claim 6 (depends on 1)

The method of claim 1, wherein receiving the target source code including the sequence of tokens further comprises:
detecting a selection from a source code file, wherein the detected selection includes the target source code; and
receiving the detected selection from the source code file as the target source code for analysis.

### Claim 7 (depends on 1)

The method of claim 1, wherein the context of other tokens in the sequence of tokens further comprises:
analyzing a number of tokens on each side of the candidate token in the sequence of tokens.

### Claim 8

A computer system for software anomaly detection, comprising:
one or more processors, one or more computer-readable memories, one or more computer-readable tangible storage media, and program instructions stored on at least one of the one or more computer-readable tangible storage media for execution by at least one of the one or more processors via at least one of the one or more memories, wherein the computer system is capable of performing a method comprising:
receiving a target source code including a sequence of tokens;
determining a probability of a candidate token in the sequence of tokens based on a context of other tokens in the sequence of tokens; and
in response to the determined probability of the candidate token satisfying a low probability threshold, detecting a low probability region in the received target source code, wherein the detected low probability region is associated with the candidate token satisfying the low probability threshold.

### Claim 9 (depends on 8)

The computer system of claim 8, further comprising:
generating an alternative to the detected low probability region of the received target source code, wherein the generated alternative includes an alternative token to replace the candidate token in the sequence of tokens, wherein the determined probability of the alternative token in the sequence of tokens is relatively higher than the determined probability of the candidate token satisfying the low probability threshold.

### Claim 10 (depends on 9)

The computer system of claim 9, further comprising:
modifying the received target source code based on the generated alternative to the detected low probability region of the received target source code; and
determining the probability of each token in the sequence of tokens based on the context of other tokens in the sequence of tokens, wherein the sequence of tokens in the modified target source code includes the alternative token.

### Claim 11 (depends on 8)

The computer system of claim 8, wherein determining the probability of the candidate token in the sequence of tokens based on the context of other tokens in the sequence of tokens further comprises:
determining the probability of each token in the sequence of tokens based on the context of other tokens in the sequence of tokens.

### Claim 12 (depends on 11)

The computer system of claim 11, wherein the detected low probability region in the received target source code is detected based on the determined probability of a corresponding token in the detected low probability region satisfying the low probability threshold.

### Claim 13 (depends on 8)

The computer system of claim 8, wherein receiving the target source code including the sequence of tokens further comprises:
detecting a selection from a source code file, wherein the detected selection includes the target source code; and
receiving the detected selection from the source code file as the target source code for analysis.

### Claim 14 (depends on 8)

The computer system of claim 8, wherein the context of other tokens in the sequence of tokens further comprises:
analyzing a number of tokens on each side of the candidate token in the sequence of tokens.

### Claim 15

A computer program product for software anomaly detection, comprising:
one or more computer-readable storage media and program instructions collectively stored on the one or more computer-readable storage media, the program instructions executable by a processor to cause the processor to perform a method comprising:
receiving a target source code including a sequence of tokens;
determining a probability of a candidate token in the sequence of tokens based on a context of other tokens in the sequence of tokens; and
in response to the determined probability of the candidate token satisfying a low probability threshold, detecting a low probability region in the received target source code, wherein the detected low probability region is associated with the candidate token satisfying the low probability threshold.

### Claim 16 (depends on 15)

The computer program product of claim 15, further comprising:
generating an alternative to the detected low probability region of the received target source code, wherein the generated alternative includes an alternative token to replace the candidate token in the sequence of tokens, wherein the determined probability of the alternative token in the sequence of tokens is relatively higher than the determined probability of the candidate token satisfying the low probability threshold.

### Claim 17 (depends on 16)

The computer program product of claim 16, further comprising:
modifying the received target source code based on the generated alternative to the detected low probability region of the received target source code; and
determining the probability of each token in the sequence of tokens based on the context of other tokens in the sequence of tokens, wherein the sequence of tokens in the modified target source code includes the alternative token.

### Claim 18 (depends on 15)

The computer program product of claim 15, wherein determining the probability of the candidate token in the sequence of tokens based on the context of other tokens in the sequence of tokens further comprises:
determining the probability of each token in the sequence of tokens based on the context of other tokens in the sequence of tokens.

### Claim 19 (depends on 18)

The computer program product of claim 18, wherein the detected low probability region in the received target source code is detected based on the determined probability of a corresponding token in the detected low probability region satisfying the low probability threshold.

### Claim 20 (depends on 15)

The computer program product of claim 15, wherein receiving the target source code including the sequence of tokens further comprises:
detecting a selection from a source code file, wherein the detected selection includes the target source code; and
receiving the detected selection from the source code file as the target source code for analysis.
