Full-automatic code access method and system based on machine learning
Through a fully automated code access method based on machine learning, static analysis and dynamic testing generate review suggestions, the problem that code review results are susceptible to subjective factors is solved, and efficient and accurate code access review is achieved.
Patent Information
- Application Number
- CN202411988092.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-02-07
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the prior art, code review results are susceptible to subjective factors, resulting in the inability to accurately identify the risks of codes to be admitted and the inability to effectively provide users with risk treatment suggestions.
Using a fully automated code access method based on machine learning, we generate review suggestions information through static code analysis, feature quantification, risk classification and dynamic testing to realize automated code access.
It improves the automation of code review, reduces the workload of manual review, improves the efficiency and accuracy of code access review, ensures code quality, and avoids the impact of the review results by subjective factors.
Smart Images

Figure CN119396451A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a fully automated code access method and system based on machine learning. Background Art
[0002] In the modern software development process, code admission is a crucial link, which ensures that only strictly tested and verified code can be merged into the main branch and then deployed to the production environment. With the expansion of software development scale and the acceleration of version iteration, code quality control has become an important link to ensure software stability. How to effectively manage code changes has become a major challenge facing software development teams. Traditional code review and quality analysis rely on manual work, which is time-consuming, labor-intensive, and inefficient. The review results are easily affected by subjective factors and lack consistency, which makes it impossible to accurately identify the risks of the code to be admitted, and it is also impossible to effectively provide users with effective risk management suggestions. Summary of the invention
[0003] The main purpose of the present invention is to provide a fully automated code access method and system based on machine learning, which aims to solve the technical problem that the review results of the prior art are easily affected by subjective factors, resulting in the inability to accurately identify the risks of the code to be approved and the inability to effectively provide users with effective risk management suggestions.
[0004] To achieve the above object, the present invention provides a fully automated code access method based on machine learning, the method comprising the following steps: In response to the code admission request, performing code static analysis on the code to be admitted in the code admission request to obtain a static analysis result file; Performing feature quantification on the static analysis result file to obtain a static analysis result feature vector; Input the static analysis result feature vector into a pre-built risk classification model for risk classification, and determine the risk label of the code to be admitted, wherein the risk classification model is built based on the historical code analysis result file and the risk label annotation data corresponding to the historical code analysis result file, and the risk classification model is a support vector machine; Performing a code dynamic test on the code to be admitted according to the risk label, and obtaining a dynamic test result; Based on the risk tag and the dynamic test result, review suggestion information of the code to be approved is generated, and the code admission request is replied based on the review suggestion information, wherein the review suggestion information includes risk factor information and risk improvement strategy.
[0005] Optionally, before inputting the static analysis result feature vector into a pre-built risk classification model for risk classification and determining the risk label of the code to be admitted, the method further includes: Obtaining historical code analysis result files and risk label annotation data corresponding to the historical code analysis result files; Preprocessing the historical code analysis result file to obtain candidate historical code analysis data; Performing feature quantification on the candidate historical code analysis data to obtain a historical static analysis result feature vector; Obtaining a mapping relationship between the risk label annotation data and the historical static analysis result feature vector; Generate a training data set and a test data set based on the risk label annotation data, the historical static analysis result feature vector and the mapping relationship; Training the original classification model according to the training data set to obtain a candidate classification model; The candidate classification model is tested based on the test data set, and the candidate classification model is iteratively optimized based on the test result, until the iteratively optimized candidate classification model meets the preset optimization condition, thereby obtaining a risk classification model.
[0006] Optionally, the step of performing feature quantization on the static analysis result file to obtain a static analysis result feature vector includes: Parsing the static analysis result file according to the file format of the static analysis result file to obtain data to be analyzed; Performing data cleaning on the data to be analyzed to obtain candidate data; Performing differential analysis on the candidate data, and acquiring target data from the candidate data based on the differential analysis result; Obtaining a target code dictionary matching the code to be admitted; Extracting keywords from the target data according to the target code dictionary to obtain target keywords; Get the word frequency and inverse document frequency of each target keyword; The static analysis result file is feature quantified based on the word frequency and the inverse document frequency to obtain a static analysis result feature vector.
[0007] Optionally, the performing a code dynamic test on the code to be admitted according to the risk label to obtain a dynamic test result further includes: Determine the main branch code of the target merge of the code to be admitted based on the code admission request; Generate a mirror code corresponding to the main branch code, and merge the code to be admitted into the mirror code to obtain the full code to be tested; Obtaining security operation requirement information of the main branch code; Generate a test case based on the risk label and the safe operation requirement information; Configuring an operating environment for the full amount of code, running the full amount of code based on the operating environment, and running the test case to perform a code dynamic test on the code to be admitted; Monitor the running status of the full code and obtain dynamic test results.
[0008] Optionally, the generating the review suggestion information of the code to be admitted based on the risk label and the dynamic test result further includes: Determine the main branch code to be merged with the target code to be admitted based on the code admission request, and obtain project tree information of the main branch code; Determine the target merging position of the code to be admitted according to the main branch code; Performing structural analysis on the main branch code to obtain code structure information of the main branch code; Constructing a code block tree structure according to the code structure information and the project tree information; Performing a structural dependency analysis on the code to be admitted based on the code block tree structure and the target merge position, and determining a structural dependency code block in the main branch code that has a structural dependency relationship with the code to be admitted; Review suggestion information for the code to be admitted is generated according to the structure-dependent code block, the risk label and the dynamic test result.
[0009] Optionally, generating the review suggestion information of the code to be admitted according to the structure-dependent code block, the risk label and the dynamic test result includes: Acquire project function information of each code block in the main branch code according to the project tree information; Acquire a code block running path of the main branch code based on a historical running log of the main branch code; Performing functional dependency analysis on the code to be admitted according to the project functional information and the code block running path, and obtaining functional dependency information of the code to be admitted; Obtaining annotation information of the main branch code; Correcting the functional dependency information based on the annotation information, and determining, according to the correction result, a functional dependency code block in the main branch code that has a functional dependency relationship with the code to be admitted; Review suggestion information for the code to be admitted is generated according to the function-dependent code block, the structure-dependent code block, the risk label and the dynamic test result.
[0010] In addition, to achieve the above purpose, the present invention also proposes a fully automated code access system based on machine learning, and the fully automated code access system based on machine learning includes: A static analysis module, configured to perform a code static analysis on the code to be admitted in the code admission request in response to the code admission request, and obtain a static analysis result file; A feature quantification module, used to perform feature quantification on the static analysis result file to obtain a static analysis result feature vector; A risk classification module is used to input the static analysis result feature vector into a pre-built risk classification model for risk classification, and determine the risk label of the code to be admitted. The risk classification model is built based on the historical code analysis result file and the risk label annotation data corresponding to the historical code analysis result file. The risk classification model is a support vector machine; A dynamic testing module, used to perform a code dynamic test on the code to be admitted according to the risk label, and obtain a dynamic testing result; A review suggestion generation module is used to generate review suggestion information for the code to be approved based on the risk label and the dynamic test result, and to respond to the code approval request based on the review suggestion information, wherein the review suggestion information includes risk factor information and risk improvement strategy.
[0011] In addition, to achieve the above-mentioned purpose, the present application also proposes a fully-automated code access device based on machine learning, the device comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being configured to implement the steps of the fully-automated code access method based on machine learning as described above.
[0012] In addition, to achieve the above-mentioned purpose, the present application also proposes a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the fully automated code access method based on machine learning as described above are implemented.
[0013] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the steps of the fully automated code access method based on machine learning as described above.
[0014] The present invention performs code static analysis on the code to be admitted in the code admission request in response to a code admission request, obtains a static analysis result file, performs feature quantification on the static analysis result file, obtains a static analysis result feature vector, inputs the static analysis result feature vector into a pre-built risk classification model for risk classification, determines the risk label of the code to be admitted, the risk classification model is built based on a historical code analysis result file and risk label annotation data corresponding to the historical code analysis result file, the risk classification model is a support vector machine, performs code dynamic testing on the code to be admitted according to the risk label, obtains a dynamic test result, and obtains a dynamic test result based on the risk label and the dynamic test result. The present invention generates review suggestion information of the code to be admitted based on the static test result, and replies to the code admission request based on the review suggestion information, wherein the review suggestion information includes risk factor information and risk improvement strategy; since the present invention improves the efficiency and accuracy of risk classification by quantifying the features of the code to be admitted, and classifies the risk of the feature vector of the static analysis result through the risk classification model, the automation degree of code review is effectively improved, and the review suggestion information is generated based on the risk label of the code to be admitted, and the risk factor information and risk improvement strategy are promptly replied to the code admission request, thereby improving the efficiency of code admission review, realizing automatic analysis of code admission, ensuring code quality, and avoiding the influence of subjective factors on admission review. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The accompanying drawings herein are incorporated in and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the description, are used to explain the principles of the present application.
[0016] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0017] Figure 1 It is a structural diagram of a fully automated code access device based on machine learning in a hardware operating environment involved in an embodiment of the present invention; Figure 2 This is a flow chart of a first embodiment of a fully automated code access method based on machine learning according to the present invention; Figure 3 This is a flow chart of a second embodiment of a fully automated code access method based on machine learning according to the present invention; Figure 4 This is a structural block diagram of the first embodiment of the fully automated code admission system based on machine learning of the present invention.
[0018] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0019] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0020] Reference Figure 1 , Figure 1 This is a schematic diagram of the structure of a fully automated code access device based on machine learning in the hardware operating environment involved in an embodiment of the present invention.
[0021] like Figure 1 As shown, the fully automated code access device based on machine learning may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (Wireless-Fidelity, WI-FI) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM), or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk storage. The memory 1005 may also be a storage system independent of the aforementioned processor 1001.
[0022] Those skilled in the art will understand that Figure 1 The structure shown in does not constitute a limitation on the fully automated code access device based on machine learning, and may include more or fewer components than shown in the figure, or a combination of certain components, or a different arrangement of components.
[0023] like Figure 1 As shown, the memory 1005 as a computer-readable storage medium may include an operating system, a network communication module, a user interface module, and a fully automated code admission program based on machine learning.
[0024] exist Figure 1In the fully-automatic code access device based on machine learning shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the fully-automatic code access device based on machine learning of the present invention can be set in the fully-automatic code access device based on machine learning, and the fully-automatic code access device based on machine learning calls the fully-automatic code access program based on machine learning stored in the memory 1005 through the processor 1001, and executes the fully-automatic code access method based on machine learning provided in an embodiment of the present invention.
[0025] The embodiment of the present invention provides a fully automated code access method based on machine learning, referring to Figure 2 , Figure 2 This is a flow chart of the first embodiment of the fully automated code access method based on machine learning of the present invention.
[0026] In this embodiment, the fully automated code access method based on machine learning includes the following steps: Step S10: In response to the code admission request, a code static analysis is performed on the code to be admitted in the code admission request to obtain a static analysis result file.
[0027] It should be understood that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or a terminal electronic device capable of realizing the above functions, etc. The following takes a fully automated code access device based on machine learning (hereinafter referred to as the access device) as an example to illustrate this embodiment and the following embodiments.
[0028] It should be noted that a code admission request can be a request message sent by a user to merge new code into the main branch code or the full code. The above-mentioned code static analysis can be a static analysis of the code to be admitted, and the potential problems in the code are detected through static analysis, including syntax and semantic detection, coding standard detection, unused variables, potential security vulnerabilities, and dependency management detection (such as version conflicts and third-party library detection).
[0029] In some embodiments, the access device may perform static analysis on the access code through a static code analysis tool, for example, perform static code analysis on the access code through a static analysis tool such as Klocwork or SonarQube, obtain a static analysis result file, and parse the file format of the static analysis result file (such as XML or JSON) to obtain analysis information.
[0030] In some embodiments, the user submits the code to be approved through Gitlab, and the access device obtains the user's code access request through Gitlab. After detecting the code submission, Jenkins is automatically triggered to perform the CI / CD process, including preliminary code building and testing. At the same time, the manual review user is notified to perform code review to ensure code quality and implement a preliminary review of the code to be approved. If the preliminary review passes, static analysis is performed on the code to be approved, thereby realizing the analysis of the code to be approved in a way that combines manual review with machine review, avoiding the problem that the code analysis results are affected by subjective factors of manual review and large errors in machine review, ensuring the accuracy and efficiency of code analysis, and improving the efficiency and accuracy of code classification.
[0031] In some embodiments, the access device can pre-set the trigger conditions for automated code access review, thereby establishing an automated mechanism to automatically perform static analysis, risk classification, and review suggestion information generation on the code to be accessed, such as by writing a Jenkins task script, triggering it at a scheduled time or when the code is submitted, thereby responding to code access requests.
[0032] Step S20: performing feature quantization on the static analysis result file to obtain a static analysis result feature vector.
[0033] It should be noted that the static analysis result feature vector can be a quantitative expression of the information in the static analysis result file, thereby converting the text data in the static analysis result file into a static analysis result feature vector in numerical form. The static analysis result feature vector can reflect the key information and feature information in the static analysis result file.
[0034] It is understandable that this embodiment can preprocess the static analysis result file, quantify the features of the preprocessed static analysis result file, and convert the text data into numerical form to facilitate risk classification model processing by machine learning.
[0035] In some embodiments, the access device can read the static analysis result file, parse the static analysis result file based on the format of the static analysis result file, extract keywords in the static analysis result file, such as file name, line number, problem description, risk level, etc., and convert the text data of the keywords into a static analysis result feature vector.
[0036] Furthermore, in order to accurately extract code features and improve classification accuracy, the above step S20 may include: Step S201: parsing the static analysis result file according to the file format of the static analysis result file to obtain data to be analyzed.
[0037] It should be noted that the file format of the static analysis result file can be JSON, XML, CSV and other formats.
[0038] It is understandable that the access device can select the corresponding parsing method based on the file format of the static analysis result file. For example, for a Klocwork static analysis result file in JSON format, the "kwcheckrun" command with the "-Fjson" option can be used to generate an output file in JSON format. The output file in JSON format usually contains the following fields: severity indicates the risk level (such as Critical, High, Medium, Low), file indicates the file path, line indicates the line number, message indicates the problem description, and trace indicates an object containing tracing information, which describes the code path in detail.
[0039] Step S202: performing data cleaning on the data to be analyzed to obtain candidate data.
[0040] It is understandable that data cleaning may include cleaning abnormal data, garbled data, and duplicate data in the data to be analyzed, and filling in missing values in the data to be analyzed, thereby deleting duplicate information, correcting existing errors, and providing data consistency.
[0041] Step S203: performing differential analysis on the candidate data, and acquiring target data from the candidate data based on the differential analysis result.
[0042] It is understandable that the access device can filter out differentiated data in the candidate data by analyzing differentiated information in the candidate data to avoid analyzing the same or repeated data, such as filtering analysis results of code blocks with the same function to avoid analyzing the same static analysis data.
[0043] Step S204: Acquire a target code dictionary that matches the code to be admitted.
[0044] It should be noted that the target code dictionary can be a dictionary of the main branch code related field merged with the code to be approved and the target of the code to be approved, and the target code dictionary contains keywords of business logic and technical terms related to the code to be approved.
[0045] Step S205: extracting keywords from the target data according to the target code dictionary to obtain target keywords.
[0046] It should be noted that the target keyword may be a keyword in the target data that matches the target code dictionary.
[0047] It is understandable that the access device may perform word segmentation on the target data to separate the target data into separate words or tags.
[0048] Step S206: Obtain the word frequency and inverse document frequency of each target keyword.
[0049] It is understandable that the access device can implement TF-IDF (Term Frequency-Inverse Document Frequency) feature vector analysis by calculating the term frequency (TF) and inverse document frequency (IDF) of the target keyword. The term frequency can be the frequency of the target keyword appearing in the document, which is used to measure the effect of the target keyword on distinguishing different documents in the document set when statically analyzing the result file. The inverse document frequency can be a measure of the general importance of the target keyword in the static analysis result file.
[0050] Step S207: quantifying the features of the static analysis result file based on the word frequency and the inverse document frequency to obtain a static analysis result feature vector.
[0051] It can be understood that the access device can calculate the TF-IDF value of each target keyword based on the word frequency and inverse document frequency, specifically including multiplying the TF value of each target keyword by the IDF value to obtain the TF-IDF value. For the static analysis result file, a feature vector is constructed in which each dimension corresponds to the TF-IDF value of a word.
[0052] Step S30: Input the static analysis result feature vector into a pre-built risk classification model for risk classification, and determine the risk label of the code to be admitted.
[0053] It should be noted that the risk classification model is constructed based on the historical code analysis result file and the risk label annotation data corresponding to the historical code analysis result file.
[0054] It should be noted that the risk classification model can be a deep machine learning model pre-trained based on historical annotated data, and the machine learning model can be a supervised learning model for classification and regression tasks. For example, the risk classification model can be obtained based on support vector machine (SVM) training.
[0055] It should be noted that the risk label may be a label that marks the risk level and risk type of the code to be admitted.
[0056] In some embodiments, the admission device may train a support vector machine (SVM) model by using a historically annotated Klocwork analysis result dataset, and save the trained model and vectorizer for subsequent classification.
[0057] In some embodiments, the access device may select a suitable machine learning model, such as a support vector machine (SVM), random forest, gradient boosting tree, or deep learning model (such as LSTM, BERT), etc., for training, and then use a validation set to evaluate the performance of the model and select the best performing model.
[0058] Furthermore, in order to construct a risk classification model with excellent performance, thereby ensuring the accuracy of the risk classification result, before the above step S30, it also includes: Step S31: Obtain a historical code analysis result file and risk label annotation data corresponding to the historical code analysis result file.
[0059] It should be noted that the historical analysis result file may be a historical code static analysis result file, for example, the historical analysis result file may include code snippets and their analysis results, such as the number of code lines, function complexity, keyword usage, etc. The above-mentioned risk annotation data may be the risk label of the code snippet corresponding to the historical code static analysis result file, such as a high risk label, a medium risk label, a low risk label, etc.
[0060] In some embodiments, the historical code analysis result files and risk label annotation data may include manually annotated data and machine annotated data, thereby improving the rationality of the training data, thereby ensuring that the training data avoids the instability problem of using only manually annotated data or machine annotated data.
[0061] Step S32: pre-processing the historical code analysis result file to obtain candidate historical code analysis data.
[0062] It should be noted that preprocessing may include data cleaning, data conversion, feature extraction, etc.
[0063] In some embodiments, the access device may perform data cleaning to remove abnormal data and duplicate data in the historical code analysis result files, and fill in missing data, and perform unified encoding of the historical code analysis result files in different formats through data conversion.
[0064] Step S33: quantify the characteristics of the candidate historical code analysis data to obtain a historical static analysis result characteristic vector.
[0065] It is understandable that the access device may convert the text features into numerical features, for example, using TF-IDF or word embedding, and normalize the numerical features so that they have the same scale.
[0066] In some embodiments, the access device may parse the historical code analysis result file according to the file format of the historical code analysis result file, obtain candidate historical code analysis data, perform data cleaning and differential analysis on the candidate historical code analysis data, obtain target historical data, extract keywords from the target historical data according to the domain dictionary, and obtain target keywords. Obtain the word frequency and inverse document frequency of each target keyword, perform feature quantification on the historical code analysis result file based on the word frequency and inverse document frequency, and obtain a feature vector of the historical static analysis result.
[0067] Step S34: Obtain the mapping relationship between the risk label annotation data and the historical static analysis result feature vector.
[0068] It should be noted that, in order to ensure the accuracy of the training data and the test data, this embodiment ensures a one-to-one correspondence between each feature vector and its corresponding risk label by constructing a mapping relationship between the labeled data and the feature vector of the static analysis result.
[0069] It should be noted that this embodiment analyzes the mapping relationship between the annotation data and the risk data, which can be achieved by checking which features in the data set are most relevant to the risk level. For example, some features may be strongly related to high risk levels, while other features may be related to low risk levels.
[0070] It should be noted that the access device ensures that the data of these key features are included in both the training set and the test set according to the mapping relationship. This ensures that the model can learn the relationship between these key features and risk levels during training, and at the same time verify the generalization ability of the model on the test set.
[0071] Step S35: Generate a training data set and a test data set based on the risk label annotation data, the historical static analysis result feature vector and the mapping relationship.
[0072] It is understandable that the access device can construct an initial data set based on the risk label annotation data, the historical static analysis result feature vector and the mapping relationship, and divide the initial data set into a training set and a test set. For example, the training set accounts for 70%-80% of the initial data set, and the test set accounts for 20%-30%.
[0073] Step S36: training the original classification model according to the training data set to obtain a candidate classification model.
[0074] It should be noted that the access device can select a suitable machine learning model, such as support vector machine (SVM), random forest, gradient boosting tree or deep learning model (such as LSTM, BERT), etc. to build the original classification model, train the original classification model, and then use the validation set to evaluate the performance of the model, select the best performing model, and thus obtain the candidate classification model.
[0075] Step S37: testing the candidate classification model based on the test data set, and iteratively optimizing the candidate classification model based on the test result, until the iteratively optimized candidate classification model meets the preset optimization conditions, thereby obtaining a risk classification model.
[0076] It should be noted that the preset optimization conditions may include optimization times conditions and optimization performance conditions. The above-mentioned optimization times conditions may be that the number of iteration optimizations of the candidate classification model reaches a preset number threshold, for example, when the number of iteration optimizations reaches 100, the iteration optimization is stopped. The above-mentioned optimization performance conditions may be that the output performance of the candidate classification model after iteration optimization meets the performance requirements, for example, the accuracy of the candidate classification model reaches the accuracy threshold.
[0077] Step S40: Performing a dynamic code test on the code to be admitted according to the risk tag, and obtaining a dynamic test result.
[0078] Furthermore, in order to improve the accuracy and rationality of the review suggestions, the above step S40 may include: Step S41: Determine the main branch code to be merged with the code target to be admitted based on the code admission request.
[0079] It should be noted that the main branch code can be the main branch part of the full code to be merged with the target code to be admitted.
[0080] Step S42: Generate a mirror code corresponding to the main branch code, and merge the code to be admitted into the mirror code to obtain the full code to be tested.
[0081] It is understandable that the access device can clone the main branch code to an independent test environment, generate a mirror code copy, and ensure that the mirror code is consistent with the main branch code to facilitate accurate testing.
[0082] In a specific implementation, the admission device can merge the code to be admitted into the image code to generate the full code to be tested, and ensure that no new compilation errors or runtime errors are introduced during the merging process.
[0083] Step S43: Obtain the security operation requirement information of the main branch code.
[0084] It should be noted that the access device can obtain security operation requirement information based on the security requirement document and operation requirement document of the main branch code. The security operation requirement information may include requirements in terms of input verification, authentication mechanism, authorization control, session management, error handling and logging.
[0085] Step S44: Generate a test case based on the risk label and the safe operation requirement information.
[0086] It is understandable that the access device can generate test cases based on the operation scenarios, security scenarios, risk labels and safe operation requirement information of the main branch code. For example, the test cases may include SQL injection, XSS attack, CSRF attack, buffer overflow, etc.
[0087] In some embodiments, the access device may use automated testing tools (eg, OWASP ZAP, Burp Suite) to generate and execute test cases.
[0088] Step S45: configuring an operating environment for the full amount of code, running the full amount of code based on the operating environment, and running the test case to perform a dynamic code test on the code to be admitted.
[0089] It should be noted that the access device can configure the operating environment based on the database, dependent libraries, and configuration files of the main branch code, and ensure that the test environment is as similar as possible to the production environment to improve the accuracy of the test.
[0090] Step S46: monitor the running status of the full code and obtain dynamic test results.
[0091] In the specific implementation, the access device can start the full code in the configured operating environment, run the generated test cases, record the test results, monitor the running status of the application, and collect logs and performance data.
[0092] It is understandable that the access device analyzes the test results, identifies potential security vulnerabilities and risks, and provides detailed repair suggestions for each problem found, including code modification, configuration adjustment, enhanced input validation and other measures. Based on risk positioning and repair suggestions, a formal review report is formed to record the test process, test results and repair suggestions.
[0093] Step S50: Generate review suggestion information for the code to be approved based on the risk label and the dynamic test result, and reply to the code approval request based on the review suggestion information.
[0094] It should be noted that the review suggestion information includes risk factor information and risk improvement strategies. The above risk factor information may include information such as the risk code location, risk type, risk level, and risk impact results of the code to be approved. The above risk improvement strategy may include solution suggestions and processing suggestion strategies for solving risk factors in the code to be approved. For example, the risk improvement strategy may be to suggest that the user delete a line of code or modify a line of code.
[0095] It can be understood that the access device obtains the abnormal information of the code to be approved according to the risk label, locates the risk according to the abnormal information, obtains the risk factor information, matches the corresponding risk improvement strategy for the code to be approved according to the risk label, generates review suggestion information based on the risk factor information and the risk improvement strategy, responds to the code access request based on the review suggestion information, and thus replies to the code access request, so that the submitting user can modify and improve the code to be approved based on the review suggestion information.
[0096] It should be noted that this embodiment can realize automatic classification and suggestion generation of static analysis results by introducing a machine learning model, which will greatly improve the automation of access code review, reduce the workload of manual review, and improve overall work efficiency.
[0097] In this embodiment, in response to a code access request, a code static analysis is performed on the code to be admitted in the code access request to obtain a static analysis result file, a feature quantification is performed on the static analysis result file to obtain a static analysis result feature vector, the static analysis result feature vector is input into a pre-built risk classification model for risk classification, and a risk label of the code to be admitted is determined, the risk classification model is built based on a historical code analysis result file and risk label annotation data corresponding to the historical code analysis result file, the risk classification model is a support vector machine, a code dynamic test is performed on the code to be admitted according to the risk label, a dynamic test result is obtained, and a dynamic test result is obtained based on the risk label and the dynamic test result. The static test result generates review suggestion information of the code to be approved, and replies to the code access request based on the review suggestion information, wherein the review suggestion information includes risk factor information and risk improvement strategies. Since this embodiment improves the efficiency and accuracy of risk classification by quantifying the features of the code to be approved, and classifies the risk of the feature vectors of the static analysis results through the risk classification model, the automation level of code review is effectively improved, and review suggestion information is generated based on the risk label of the code to be approved, and the risk factor information and risk improvement strategies are promptly replied to the code access request, thereby improving the efficiency of code access review, realizing automated analysis of code access, ensuring code quality, and preventing the access review from being affected by subjective factors.
[0098] refer to Figure 3 , Figure 3This is a flow chart of the second embodiment of the fully automated code access method based on machine learning of the present invention.
[0099] Based on the above first embodiment, in this embodiment, the step S50 further includes: Step S501: Determine the main branch code to be merged with the code target to be admitted based on the code admission request, and obtain project tree information of the main branch code.
[0100] It should be noted that this embodiment can determine the main branch code of the target merge by parsing the code access request, identifying the keywords included in the code access request, for example, the keywords may include main and master, etc.
[0101] It should be noted that the project tree information may include the functional structure, directory structure and file path of the main branch code.
[0102] Step S502: Determine the target merging position of the code to be admitted according to the main branch code.
[0103] It should be noted that the target merge position may be the specific merge position where the code to be admitted will be merged in the main branch code.
[0104] Step S503: Perform structural analysis on the main branch code to obtain code structure information of the main branch code.
[0105] It should be noted that the code structure information may be the structure information of the code blocks, functions, variables, and modules that constitute the main branch code.
[0106] Step S504: construct a code block tree structure according to the code structure information and the project tree information.
[0107] It should be noted that in the code block tree structure, each node represents a code block (such as a class or function), and the edge represents the dependency relationship between these code blocks. For example, if function A calls function B, an edge from A to B can be created in the tree.
[0108] In some embodiments, the admission device gradually builds the tree by traversing the code structure information and the project tree information. For each code block, other code blocks that it depends on are checked and added as child nodes.
[0109] Step S505: performing a structural dependency analysis on the code to be admitted based on the code block tree structure and the target merge position, and determining a structural dependency code block in the main branch code that has a structural dependency relationship with the code to be admitted.
[0110] It can be understood that the access device can traverse the objects that are mutually dependent on the code to be admitted in the code block tree structure based on the target merge position, obtain dependency information, and determine the structurally dependent code blocks in the main branch code that have a structural dependency relationship with the code to be admitted based on the dependency information.
[0111] In some embodiments, the access device can split the code blocks according to the abstract syntax tree, especially for complex statements such as Forstmt, Whilestmt, etc., separate them from the original abstract syntax tree to form subtrees so that the structural dependency between the code to be admitted and the main branch code can be analyzed more accurately.
[0112] Step S506: Generate review suggestion information for the code to be admitted based on the structure-dependent code block, the risk label and the dynamic test result.
[0113] It can be understood that the access device can analyze whether there is a risk correlation between the code to be approved and the structural dependent code blocks based on the risk labels, and realize the structural dependency risk analysis of the code to be approved, so as to determine which code blocks in the main branch code will be affected by the merger of the code to be approved, thereby identifying potential conflicts and risks before the code is merged.
[0114] For example, the structurally dependent code blocks in the main branch code that have a structural dependency relationship with the code to be approved include code block A, code block B, and code block C. A structural dependency risk analysis is performed on the code to be approved based on the risk label, and it is determined that code block C will be affected by the merging of the code to be approved. Therefore, the access device can generate a risk improvement strategy based on the risk factor information of code block C and the code to be approved.
[0115] Further, in order to analyze whether the code block related to the code function to be admitted in the main branch code has the risk of admission impact, the above step S506 may include: Step S5061: Obtain project function information of each code block in the main branch code according to the project tree information.
[0116] It should be noted that the project function information may include function description information of each code block, code block calling information, interface information, etc.
[0117] It can be understood that the access device can perform abstract analysis on the main branch code based on the project tree information, obtain each code block in the main branch code based on the code function, identify the type and scope of each code block, and obtain the project function information of each code block respectively.
[0118] In some embodiments, the access device can traverse the project directory of the main branch code, generate project tree information, traverse each file in the project tree based on the project tree information, extract the function definition, class definition and comment information of each code block, and thus obtain the project function information of each code block.
[0119] Step S5062: Obtain the code block execution path of the main branch code based on the historical execution log of the main branch code.
[0120] It should be noted that the access device can parse the historical operation log based on the log format of the historical operation log, extract key information in the historical operation log (such as timestamp, log level, log message and call stack), extract the function call path from the call stack information in the log, and construct the extracted call path into an ordered code block execution path.
[0121] Step S5063: Performing a functional dependency analysis on the code to be admitted according to the project functional information and the code block running path, and obtaining functional dependency information of the code to be admitted.
[0122] It should be noted that the access device can parse the main branch code, extract function calls, method calls and module import relationships, generate initial functional dependency information, correct the initial functional dependency information according to the annotation information, ensure the accuracy of the dependency relationship, match the functional dependency information of the code to be allowed with the functional dependency information of the main branch code, and determine the functional dependency code blocks in the main branch code that have functional dependency relationships with the code to be allowed.
[0123] Step S5064: Obtain annotation information of the main branch code.
[0124] It should be noted that the comment information may be the author's annotation and explanation information of different versions in the main branch code, for example, it may include version information, author information, function and type comments, variable comments, module comments and other information of the main branch code.
[0125] Step S5065: modifying the functional dependency information based on the annotation information, and determining the functional dependency code blocks in the main branch code that have a functional dependency relationship with the code to be admitted according to the modification result.
[0126] It is understandable that the access device can correct the functional dependency information based on the annotation information, perform functional dependency matching between the code to be allowed and each code block based on the corrected functional dependency information, and determine the functional dependency code block that has a functional dependency relationship with the code to be allowed.
[0127] Step S5066: Generate review suggestion information for the code to be approved based on the function-dependent code block, the structure-dependent code block, the risk label and the dynamic test result.
[0128] It can be understood that the access device can determine the target code blocks in the functional dependency code blocks and the structural dependency code blocks that are affected by the risks of the code to be approved based on the risk labels, analyze the risk factors between the code to be approved and the target code blocks, obtain risk factor information, and generate review suggestion information based on the risk factor information, thereby eliminating the functional dependency impact risks and structural dependency impact risks brought by the code to be approved.
[0129] This embodiment determines the main branch code of the target merge of the code to be admitted based on the code admission request, and obtains the project tree information of the main branch code, determines the target merge position of the code to be admitted according to the main branch code, performs structural analysis on the main branch code, obtains the code structure information of the main branch code, builds a code block tree structure according to the code structure information and the project tree information, performs structural dependency analysis on the code to be admitted based on the code block tree structure and the target merge position, determines the structural dependency code block in the main branch code that has a structural dependency relationship with the code to be admitted, and generates review suggestion information for the code to be admitted according to the structural dependency code block, the risk label and the dynamic test result; because this embodiment performs structural dependency analysis on the code to be admitted and the main branch code, thereby locating the code block in the main branch code that has a structural dependency relationship with the code to be admitted, and analyzes the structural conflict between the code block to be admitted and the main branch code according to the existing risk of the code to be admitted in combination with the structural dependency code block, thereby improving the accuracy of code admission review and providing reasonable review suggestions for users.
[0130] In addition, an embodiment of the present invention also proposes a computer-readable storage medium, on which a fully-automated code access program based on machine learning is stored. When the fully-automated code access program based on machine learning is executed by a processor, the steps of the fully-automated code access method based on machine learning as described above are implemented.
[0131] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.
[0132] The above-mentioned computer-readable storage medium may be included in the fully-automatic code access device based on machine learning; or it may exist independently without being assembled into the fully-automatic code access device based on machine learning.
[0133] In addition, an embodiment of the present invention also proposes a computer program product, including a fully-automated code access program based on machine learning, which, when executed by a processor, implements the steps of the fully-automated code access method based on machine learning as described above.
[0134] The specific implementation method of the computer program product of the present invention is basically the same as the various embodiments of the above-mentioned fully automated code access method based on machine learning, and will not be repeated here.
[0135] Reference Figure 4 , Figure 4 This is a structural block diagram of the first embodiment of the fully automated code admission system based on machine learning of the present invention.
[0136] like Figure 4 As shown, the fully automated code access system based on machine learning proposed in the embodiment of the present invention includes: The static analysis module 10 is used to perform a code static analysis on the code to be admitted in the code admission request in response to the code admission request, and obtain a static analysis result file; A feature quantification module 20 is used to perform feature quantification on the static analysis result file to obtain a static analysis result feature vector; A risk classification module 30 is used to input the static analysis result feature vector into a pre-built risk classification model for risk classification, and determine the risk label of the code to be admitted. The risk classification model is built based on the historical code analysis result file and the risk label annotation data corresponding to the historical code analysis result file. The risk classification model is a support vector machine; A dynamic testing module 40 is used to perform a code dynamic test on the code to be admitted according to the risk label and obtain a dynamic test result; The review suggestion generation module 50 is used to generate review suggestion information of the code to be approved based on the risk label and the dynamic test result, and reply to the code approval request based on the review suggestion information, wherein the review suggestion information includes risk factor information and risk improvement strategy.
[0137] Furthermore, the fully automated code access system further includes: The model building module 60 is used to obtain the historical code analysis result file and the risk label annotation data corresponding to the historical code analysis result file; preprocess the historical code analysis result file to obtain candidate historical code analysis data; feature quantify the candidate historical code analysis data to obtain the historical static analysis result feature vector; obtain the mapping relationship between the risk label annotation data and the historical static analysis result feature vector; generate a training data set and a test data set based on the risk label annotation data, the historical static analysis result feature vector and the mapping relationship; train the original classification model according to the training data set to obtain a candidate classification model; test the candidate classification model based on the test data set, and iteratively optimize the candidate classification model based on the test result until the iteratively optimized candidate classification model meets the preset optimization conditions to obtain a risk classification model.
[0138] Furthermore, the feature quantification module 20 is also used to parse the static analysis result file according to the file format of the static analysis result file to obtain the data to be analyzed; perform data cleaning on the data to be analyzed to obtain candidate data; perform differential analysis on the candidate data, and obtain target data in the candidate data based on the differential analysis results; obtain a target code dictionary matching the code to be admitted; perform keyword extraction on the target data according to the target code dictionary to obtain target keywords; obtain the word frequency and inverse document frequency of each target keyword; perform feature quantification on the static analysis result file based on the word frequency and the inverse document frequency to obtain a static analysis result feature vector.
[0139] Furthermore, the dynamic testing module 40 is also used to determine the main branch code to be merged with the target of the code to be allowed to be allowed based on the code access request; generate a mirror code corresponding to the main branch code, and merge the code to be allowed to be allowed into the mirror code to obtain the full code to be tested; obtain the safety operation requirement information of the main branch code; generate a test case based on the risk label and the safety operation requirement information; configure an operating environment for the full code, run the full code based on the operating environment, and run the test case to perform dynamic code testing on the code to be allowed to be allowed; monitor the running status of the full code and obtain dynamic test results.
[0140] Furthermore, the review suggestion generation module 50 is also used to determine the main branch code of the target merge of the code to be approved based on the code access request, and obtain the project tree information of the main branch code; determine the target merge position of the code to be approved based on the main branch code; perform structural analysis on the main branch code to obtain the code structure information of the main branch code; build a code block tree structure based on the code structure information and the project tree information; perform structural dependency analysis on the code to be approved based on the code block tree structure and the target merge position, and determine the structurally dependent code block in the main branch code that has a structural dependency relationship with the code to be approved; generate review suggestion information for the code to be approved based on the structurally dependent code block, the risk label and the dynamic test result.
[0141] Furthermore, the review suggestion generation module 50 is also used to obtain project function information of each code block in the main branch code according to the project tree information; obtain the code block running path of the main branch code based on the historical running log of the main branch code; perform functional dependency analysis on the code to be approved according to the project function information and the code block running path to obtain functional dependency information of the code to be approved; obtain comment information of the main branch code; correct the functional dependency information based on the comment information, and determine the functional dependency code block in the main branch code that has a functional dependency relationship with the code to be approved according to the correction result; generate review suggestion information for the code to be approved based on the functional dependency code block, the structural dependency code block, the risk label and the dynamic test result.
[0142] In this embodiment, in response to a code access request, a code static analysis is performed on the code to be admitted in the code access request to obtain a static analysis result file, a feature quantification is performed on the static analysis result file to obtain a static analysis result feature vector, the static analysis result feature vector is input into a pre-built risk classification model for risk classification, and a risk label of the code to be admitted is determined, the risk classification model is built based on a historical code analysis result file and risk label annotation data corresponding to the historical code analysis result file, the risk classification model is a support vector machine, a code dynamic test is performed on the code to be admitted according to the risk label, a dynamic test result is obtained, and a dynamic test result is obtained based on the risk label and the dynamic test result. The static test result generates review suggestion information of the code to be approved, and replies to the code access request based on the review suggestion information, wherein the review suggestion information includes risk factor information and risk improvement strategies. Since this embodiment improves the efficiency and accuracy of risk classification by quantifying the features of the code to be approved, and classifies the risk of the feature vectors of the static analysis results through the risk classification model, the automation level of code review is effectively improved, and review suggestion information is generated based on the risk label of the code to be approved, and the risk factor information and risk improvement strategies are promptly replied to the code access request, thereby improving the efficiency of code access review, realizing automated analysis of code access, ensuring code quality, and preventing the access review from being affected by subjective factors.
[0143] The fully automated code access system based on machine learning provided by the present application adopts the fully automated code access method based on machine learning in the above-mentioned embodiment, and can solve the technical problem of fully automated code access based on machine learning. Compared with the prior art, the beneficial effects of the fully automated code access system based on machine learning provided by the present application are the same as the beneficial effects of the fully automated code access method based on machine learning provided by the above-mentioned embodiment, and other technical features of the fully automated code access system based on machine learning are the same as the features disclosed in the above-mentioned embodiment method, which will not be described in detail here.
[0144] It should be understood that the above is only an example and does not constitute any limitation on the technical solution of the present invention. In specific applications, technicians in this field can make settings as needed, and the present invention does not limit this.
[0145] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of the present invention. In practical applications, technicians in this field can select part or all of them according to actual needs to achieve the purpose of the present embodiment, and no limitation is made here.
[0146] In addition, for technical details not described in detail in this embodiment, please refer to the fully automated code access method based on machine learning provided in any embodiment of the present invention, which will not be repeated here.
[0147] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0148] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0149] Through the above description of the implementation method, those skilled in the art can clearly understand that the above embodiment method can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory / random access memory, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0150] The above are only preferred embodiments of the present invention, and the protection scope of the present invention is not limited thereto. Any equivalent structure or equivalent process transformation made by using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the protection scope of the present invention.
Claims
1. A fully automated code access method based on machine learning, characterized in that: The fully automated code admission method based on machine learning includes: In response to the code admission request, performing code static analysis on the code to be admitted in the code admission request to obtain a static analysis result file; Performing feature quantification on the static analysis result file to obtain a static analysis result feature vector; Input the static analysis result feature vector into a pre-built risk classification model for risk classification, and determine the risk label of the code to be admitted, wherein the risk classification model is built based on the historical code analysis result file and the risk label annotation data corresponding to the historical code analysis result file, and the risk classification model is a support vector machine; Performing a code dynamic test on the code to be admitted according to the risk label, and obtaining a dynamic test result; Based on the risk tag and the dynamic test result, review suggestion information of the code to be approved is generated, and the code admission request is replied based on the review suggestion information, wherein the review suggestion information includes risk factor information and risk improvement strategy.
2. The fully automated code access method based on machine learning as claimed in claim 1, characterized in that: Before inputting the static analysis result feature vector into a pre-built risk classification model for risk classification and determining the risk label of the code to be admitted, the method further includes: Obtaining historical code analysis result files and risk label annotation data corresponding to the historical code analysis result files; Preprocessing the historical code analysis result file to obtain candidate historical code analysis data; Performing feature quantification on the candidate historical code analysis data to obtain a historical static analysis result feature vector; Obtaining a mapping relationship between the risk label annotation data and the historical static analysis result feature vector; Generate a training data set and a test data set based on the risk label annotation data, the historical static analysis result feature vector and the mapping relationship; Training the original classification model according to the training data set to obtain a candidate classification model; The candidate classification model is tested based on the test data set, and the candidate classification model is iteratively optimized based on the test result, until the iteratively optimized candidate classification model meets the preset optimization condition, thereby obtaining a risk classification model.
3. The fully automated code access method based on machine learning as claimed in claim 1, characterized in that: The step of quantifying the characteristics of the static analysis result file to obtain a static analysis result characteristic vector includes: Parsing the static analysis result file according to the file format of the static analysis result file to obtain data to be analyzed; Performing data cleaning on the data to be analyzed to obtain candidate data; Performing differential analysis on the candidate data, and acquiring target data from the candidate data based on the differential analysis result; Obtaining a target code dictionary matching the code to be admitted; Extracting keywords from the target data according to the target code dictionary to obtain target keywords; Get the word frequency and inverse document frequency of each target keyword; The static analysis result file is feature quantified based on the word frequency and the inverse document frequency to obtain a static analysis result feature vector.
4. The fully automated code access method based on machine learning as claimed in claim 1, characterized in that: The performing a code dynamic test on the code to be admitted according to the risk label to obtain a dynamic test result also includes: Determine the main branch code of the target merge of the code to be admitted based on the code admission request; Generate a mirror code corresponding to the main branch code, and merge the code to be admitted into the mirror code to obtain the full code to be tested; Obtaining security operation requirement information of the main branch code; Generate a test case based on the risk label and the safe operation requirement information; Configuring an operating environment for the full amount of code, running the full amount of code based on the operating environment, and running the test case to perform a code dynamic test on the code to be admitted; Monitor the running status of the full code and obtain dynamic test results.
5. The fully automated code access method based on machine learning as claimed in any one of claims 1 to 3, characterized in that: The generating of the review suggestion information of the code to be admitted based on the risk label and the dynamic test result also includes: Determine the main branch code to be merged with the target code to be admitted based on the code admission request, and obtain project tree information of the main branch code; Determine the target merging position of the code to be admitted according to the main branch code; Performing structural analysis on the main branch code to obtain code structure information of the main branch code; Constructing a code block tree structure according to the code structure information and the project tree information; Performing a structural dependency analysis on the code to be admitted based on the code block tree structure and the target merge position, and determining a structural dependency code block in the main branch code that has a structural dependency relationship with the code to be admitted; Review suggestion information for the code to be admitted is generated according to the structure-dependent code block, the risk label and the dynamic test result.
6. The fully automated code access method based on machine learning as claimed in claim 5, characterized in that: The generating of the review suggestion information of the code to be admitted according to the structure-dependent code block, the risk label and the dynamic test result includes: Acquire project function information of each code block in the main branch code according to the project tree information; Acquire a code block running path of the main branch code based on a historical running log of the main branch code; Performing functional dependency analysis on the code to be admitted according to the project functional information and the code block running path, and obtaining functional dependency information of the code to be admitted; Obtaining annotation information of the main branch code; Correcting the functional dependency information based on the annotation information, and determining, according to the correction result, a functional dependency code block in the main branch code that has a functional dependency relationship with the code to be admitted; Review suggestion information for the code to be admitted is generated according to the function-dependent code block, the structure-dependent code block, the risk label and the dynamic test result.
7. A fully automated code access system based on machine learning, characterized in that: The fully automated code admission system based on machine learning includes: A static analysis module, configured to perform a code static analysis on the code to be admitted in the code admission request in response to the code admission request, and obtain a static analysis result file; A feature quantification module, used to perform feature quantification on the static analysis result file to obtain a static analysis result feature vector; A risk classification module is used to input the static analysis result feature vector into a pre-built risk classification model for risk classification, and determine the risk label of the code to be admitted. The risk classification model is built based on the historical code analysis result file and the risk label annotation data corresponding to the historical code analysis result file. The risk classification model is a support vector machine; A dynamic testing module, used to perform a code dynamic test on the code to be admitted according to the risk label, and obtain a dynamic testing result; A review suggestion generation module is used to generate review suggestion information for the code to be approved based on the risk label and the dynamic test result, and to respond to the code approval request based on the review suggestion information, wherein the review suggestion information includes risk factor information and risk improvement strategy.
8. A fully automated code access device based on machine learning, characterized in that: The fully-automated code access device based on machine learning includes: a memory, a processor, and a fully-automated code access program based on machine learning stored on the memory and executable on the processor, wherein the fully-automated code access program based on machine learning is configured to implement the fully-automated code access method based on machine learning as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a fully automated code access program based on machine learning, and when the fully automated code access program based on machine learning is executed by the processor, the fully automated code access method based on machine learning as described in any one of claims 1 to 6 is implemented.
10. A computer program product, characterized in that The computer program product includes a fully automated code admission program based on machine learning, which, when executed by a processor, implements the steps of the fully automated code admission method based on machine learning as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Test based static analysis misinformation eliminating method
CN103294594A
A software vulnerability automatic classification method based on a deep neural network
CN109886020A
Source code vulnerability detection method based on multi-dimensional representation
CN113779590A
Source code vulnerability detection method and device
CN115510449A
Vulnerability false alarm elimination method for continuous integration platform
CN115525899A