Looking for breakthrough ideas for innovation challenges? Try Patsnap Eureka!

API misuse detection method and system based on attention mechanism

A misuse detection and attention technology, applied in neural learning methods, software testing/debugging, biological neural network models, etc., can solve problems such as different degrees of interdependence, inconsistent contributions, misuse of the first API, etc. To achieve the effect of fast training convergence

Active Publication Date: 2022-07-12
BEIHANG UNIV
View PDF4 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

In addition, in the existing paper research, when the code in the project set is converted into a sequence call, the degree of interdependence between different API elements in a sequence is not exactly the same, that is, in a series of API call sequences, the last element may be It leads to misuse of the first API, such as "getWidgetByName(string.substring(0,10)).setText()" when setting the text or title of the control in Android development. There are multiple APIs in this line of code, resulting in .setText () The misuse should be that the getWidgetByName API cannot get the object or the object does not exist, rather than the string.substring() API element, so elements at different positions in the API call sequence have inconsistent contributions to API misuse
In addition, experienced programmers often pay attention to different misuse defects for different situations when detecting whether the API is misused. For example, when checking object processing, they often pay attention to whether the object is empty. , often pay attention to API parameters and other information that lead to security

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • API misuse detection method and system based on attention mechanism
  • API misuse detection method and system based on attention mechanism
  • API misuse detection method and system based on attention mechanism

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0054] According to an embodiment of the present invention, as figure 1 As shown, an attention mechanism-based API misuse detection method is proposed, which includes the following steps:

[0055] Step 1. Obtain a predetermined amount of code in the detection field;

[0056] Step 2, converting the predetermined amount of code into training data required for the misuse detection model based on the attention mechanism API;

[0057] According to an embodiment of the present invention, the code contains the following key information: method name (such as a callable method or function in an open source framework), development language keywords (such as while, for, do, foreach, try, catch, etc.) , the variables in the method (such as integer variables, global variables, etc.), extract the key information in a piece of code in order, and organize them into a tuple, which contains all the key information of the piece of code.

[0058] For example the following code:

[0059] "whil...

Embodiment 2

[0086] According to an embodiment of the present invention, an attention mechanism-based API misuse detection system is proposed, including:

[0087] The code acquisition module is used to acquire the predetermined amount of codes in the detection field;

[0088] a conversion module, for converting the code into the training data required for the misuse detection model based on the attention mechanism API according to the obtained code;

[0089] a training module, configured to train the API misuse detection model based on the attention mechanism by using the training data to obtain the model parameters;

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention provides an attention mechanism-based API misuse detection method and system. The method comprises the following steps of 1, obtaining a predetermined quantity code of a detection field; 2, converting the predetermined quantity of codes into training data required by an attention mechanism-based API misuse detection model; 3, training the API misuse detection model based on the attention mechanism by using the training data to obtain model parameters; and step 4, obtaining a to-be-detected code, converting the to-be-detected code into a data format required by the API misuse detection model based on the attention mechanism, enabling the data format converted by the to-be-detected code to pass through the API misuse detection model based on the attention mechanism to obtain a detection result, and generating a detection report for the to-be-detected code. According to the method, a self-attention mechanism is applied to API use protocol learning and API misuse detection, a sample set used by an API is constructed by collecting a large number of Java codes and through static analysis, samples are trained by using a neural network, and a model for automatically detecting API misuse is constructed.

Description

technical field [0001] The present invention relates to the technical field of computer and artificial intelligence, and in particular, to an API misuse detection method and system based on an attention mechanism. Background technique [0002] With the rapid development of computer technology, more and more software frameworks, class libraries, etc. have emerged. Developers only need to call the Application Programming Interface (API) of these frameworks or class libraries to realize various functions. . However, due to reasons such as programmers ignoring the documentation when using the API, or it is difficult to understand the API, misuse of the API occurs, which brings defects or hidden dangers to the software. On the one hand, the use of artificial detection of these APIs is expensive to maintain, and on the other hand, the efficiency is relatively low. [0003] In the current API misuse research algorithm, it can be basically divided into two categories: one is to us...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
Patent Type & Authority Applications(China)
IPC IPC(8): G06F11/36G06F8/75G06N3/04G06N3/08
CPCG06F11/3608G06F8/75G06N3/08G06N3/045
Inventor 吴文峻杨京波
Owner BEIHANG UNIV
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Patsnap Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Patsnap Eureka Blog
Learn More
PatSnap group products