Security defect automatic classification method based on feedback data enhancement

By performing data enhancement and quality assessment on the defect report data set, a balanced training data set is generated, and the T5 model is used to train the classifier, which solves the problem of low accuracy of minority category classification in the existing technology and realizes the classification of safety-related defect reports. Effective identification and processing reduce network security risks.

CN118690018AInactive Publication Date: 2024-09-24BEIJING UNIV OF POSTS & TELECOMM
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410832736.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-09-24
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

When existing classifiers classify defect report data sets, the classification prediction accuracy for a few categories is low, resulting in the inability to process security-related defect reports in a timely manner, which may cause network security problems.

Method used

By performing data enhancement on the defect report data set, we generate enhanced text, perform quality assessment on it, build a training data set, and use the T5 model to train the classifier to improve the classification effect of minority categories. Specific methods include determining enhancement coefficients, using synonym replacement, random insertion, random exchange, random deletion and other data enhancement methods, combined with undersampling technology to generate a balanced training data set.

Benefits of technology

Improves the classification accuracy of minority categories, ensures timely identification and processing of security-related defect reports, and reduces network security risks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118690018A
    Figure CN118690018A
Patent Text Reader

Abstract

The invention discloses an automatic security defect classification method based on feedback data enhancement, belongs to the technical field of security defect classification, and can solve the problem that an existing classifier is low in classification prediction accuracy of minority categories in a defect report data set. The method comprises the following steps: S1, performing data enhancement on each defect report in a defect report data set to generate an enhanced text; s2, performing quality evaluation on the enhanced text, and establishing a training data set according to an evaluation result of the enhanced text; and S3, training a classifier by using the training data set to obtain a classification model, and performing classification prediction on the defect reports in the defect report data set by using the classification model to obtain a classification prediction result. The method is used for automatically classifying the defect reports.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to an automatic security defect classification method based on feedback data enhancement, and belongs to the technical field of security defect classification. Background Art

[0002] In recent years, the rapid popularization of the Internet has caused more and more network security issues, and security defects are the main cause of security issues. Defect reports record various problems found during software development, operation and maintenance, and are the main basis for defect investigation and reproduction. Automatic classification of defect reports can help relevant personnel to discover problems and determine the categories of problems in a timely manner, thereby improving the efficiency of problem solving.

[0003] However, when the existing classifiers classify the defect report dataset, the accuracy of the classifier prediction is very low for the minority categories in each label of the defect report dataset. This is due to the problem of uneven sample distribution in the defect report dataset. There are too few samples of minority categories in the training set and the test set, which causes the classifier to focus on the majority category when making classification predictions, which ultimately affects the classification prediction effect of the minority category. However, in the defect report dataset, those minority categories are often security-related, which means that the problems recorded in the defect reports of these categories are the most in need of timely processing. If they are not processed in a timely manner, they may cause serious network security problems. Summary of the invention

[0004] The present invention provides a method for automatic classification of security defects based on feedback data enhancement, which can solve the problem of low classification prediction accuracy of existing classifiers for a minority of categories in a defect report data set.

[0005] The present invention provides a method for automatically classifying security defects based on feedback data enhancement, the method comprising:

[0006] S1. Perform data enhancement on each defect report in the defect report dataset to generate enhanced text;

[0007] S2, performing a quality assessment on the enhanced text, and forming a training data set according to the assessment results of the enhanced text;

[0008] S3. Using the training data set to train a classifier to obtain a classification model, and using the classification model to perform classification prediction on the defect reports in the defect report data set to obtain a classification prediction result.

[0009] Optionally, the S1 specifically includes:

[0010] Determine the enhancement factor for each defect category in the defect report dataset;

[0011] The defect reports in each defect category in the defect report dataset are enhanced using the corresponding enhancement coefficient to generate enhanced text.

[0012] Optionally, the S2 specifically includes:

[0013] Performing a quality assessment on the enhanced text, and determining an enhanced data set according to the assessment result of the enhanced text;

[0014] The defect reports in each defect category in the enhanced data set are undersampled to obtain a training data set.

[0015] Optionally, the performing of quality assessment on the enhanced text and determining the enhanced data set according to the assessment result of the enhanced text is specifically:

[0016] Determine the similarity between each enhanced text and its reference text, and add the defect category label of the reference text to the enhanced text that meets the similarity standard and add it to the enhanced data set;

[0017] For the reference text corresponding to the enhanced text that does not meet the similarity standard, the enhanced text is regenerated until the similarity of the regenerated enhanced text meets the similarity standard, or the number of regenerations reaches the repeated stop number. The last regenerated enhanced text is added with the defect category label of its reference text and added to the enhanced dataset.

[0018] Optionally, the data enhancement method includes synonym replacement, random insertion, random exchange and random deletion.

[0019] Optionally, the defect reports within each defect category use the four data augmentation methods an equal number of times.

[0020] Optionally, the measurement indicator of the similarity is a METEOR score; the similarity standard is that the METEOR score is greater than or equal to a preset threshold.

[0021] Optionally, the enhancement coefficient of the minority defect category in the defect report dataset is greater than the enhancement coefficient of the majority defect category.

[0022] Optionally, the step of training a classifier using the training data set to obtain a classification model in S3 is specifically as follows:

[0023] The T5 model is used to obtain the description text representation vector of the defect report in the training data set, and the description text representation vector is used to train a classifier to obtain a classification model.

[0024] Optionally, the step of using the classification model to perform classification prediction on the defect reports in the defect report dataset to obtain a classification prediction result is specifically:

[0025] The T5 model is used to obtain the description text representation vector of the defect report in the defect report data set, and the classification model is used to perform classification prediction on the description text representation vector to obtain a classification prediction result.

[0026] Optionally, the preset threshold is 0.85 to 0.95; and the number of repeated stops is 4 to 6 times.

[0027] Optionally, the undersampling method is a random undersampling method.

[0028] The beneficial effects that the present invention can produce include:

[0029] The automatic classification method for security defects based on feedback data enhancement provided by the present invention performs data enhancement on the defect reports in each defect category in the defect report data set, and performs quality assessment on the generated enhanced text, thereby obtaining a training data set with high quality and a relatively balanced number of categories. The training data set can be used to train a classification model with better classification effect on minority classes. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 A flow chart of a method for automatic classification of security defects based on feedback data enhancement provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0031] The present invention is described in detail below in conjunction with embodiments, but the present invention is not limited to these embodiments.

[0032] The embodiment of the present invention provides a method for automatically classifying security defects based on feedback data enhancement, such as Figure 1 As shown, the method includes:

[0033] S1. Perform data augmentation on each defect report in the defect report dataset to generate enhanced text.

[0034] The embodiment of the present invention is described by taking the defect report dataset of the Chromium project as an example. Chromium is an open source browser project that aims to provide a safer, faster, and more stable network experience for all Internet users. The defect report dataset includes a total of 10 CWE (Common Weak Enumeration) categories. The CWE categories contained in the defect report dataset and the specific defect categories represented are shown in Table 1; the quantitative statistics of each category and the corresponding labels are shown in Table 2.

[0035] Table 1 Defect categories represented by CWE categories

[0036] CWE Categories Corresponding defect category CWE-266 Incorrect permissions assignment CWE-399 Resource management errors CWE-438 Behavioral problems CWE-1218 Memory buffer error CWE-359 Expose private personal information to unauthorized actors CWE-79 Cross-site scripting vulnerability CWE-562 Returns the address of a stack variable CWE-1021 Improper restrictions on rendered UI layers or frames CWE-430 Deployment error handler CWE-1219 File handling issues

[0037] Table 2 CWE category statistics and label correspondence

[0038] category quantity Tag value No category 40987 0 CWE-226 314 1 CWE-396 120 2 CWE-438 89 3 CWE-1218 79 4 CWE-359 40 5 CWE-79 30 6 CWE-562 16 7 CWE-1021 16 8 CWE-403 14 9 CWE-1219 9 10 total 41714

[0039] The above S1 specifically includes:

[0040] (1) Determine the enhancement factor for each defect category in the defect report dataset.

[0041] First, set the specific value of the enhancement coefficient, that is, how many new defect reports are regenerated for each defect report. Since the number of defect reports for each CWE category is different, the value of the enhancement coefficient is set for the number of defect reports for each CWE category. The enhancement coefficient of the minority defect category in the defect report dataset is greater than the enhancement coefficient of the majority defect category to ensure that the number of newly generated defect reports for each CWE category is roughly equal. For example, for a class with a CWE label value of 10, set the value of the enhancement coefficient to 576, so that each defect report can regenerate 576 new defect reports. The specific enhancement coefficients corresponding to each CWE label value are shown in Table 3.

[0042] Table 3 Enhancement coefficient corresponding to each cwe label value

[0043] cwe tag value Enhancement factor 0 1 1 48 2 48 3 192 4 192 5 192 6 192 7 576 8 576 9 576 10 576

[0044] (2) The corresponding enhancement coefficient is used to perform data enhancement on the defect reports in each defect category in the defect report dataset to generate enhanced text.

[0045] The data enhancement methods include synonym replacement, random insertion, random exchange, and random deletion. The defect reports in each defect category use the four data enhancement methods equally.

[0046] Specifically, for each defect report that needs text enhancement, in the process of generating a new defect report, four methods in the simple data enhancement technology EDA can be used simultaneously, namely synonym replacement, random insertion, random exchange, and random deletion. In this process, the program can be controlled to cross-use the above four methods by taking the remainder method. Taking the class with a cwe label value of 10 as an example, each EDA method is used 144 times. After using the four methods, each defect report can generate 576 enhanced texts (i.e., new defect reports).

[0047] S2. Perform quality assessment on the enhanced text and build a training dataset based on the assessment results of the enhanced text.

[0048] Specifically include:

[0049] (1) Perform a quality assessment on the enhanced text and determine the enhanced dataset based on the assessment results of the enhanced text.

[0050] Specifically: determine the similarity between each enhanced text and its reference text, add the defect category label of the reference text to the enhanced text that meets the similarity standard and add it to the enhanced data set; regenerate the enhanced text for the reference text corresponding to the enhanced text that does not meet the similarity standard until the similarity of the regenerated enhanced text meets the similarity standard, or the number of regenerations reaches the repeated stop number, and add the defect category label of the reference text to the last regenerated enhanced text and add it to the enhanced data set.

[0051] The similarity measurement index may be a METEOR score; the similarity standard is that the METEOR score is greater than or equal to a preset threshold.

[0052] In practical applications, the preset threshold value may be 0.85 to 0.95, and for example, may be 0.85, 0.9 or 0.95; the number of repeated stops may be 4 to 6 times, and for example, may be 4 times, 5 times or 6 times.

[0053] In the process of generating enhanced text, the quality of the generated text can be evaluated using the automatic evaluation index METEOR in machine translation and natural language generation tasks. During the evaluation process, a METEOR score can be obtained. The METEOR score ranges from 0 to 1 and is used to evaluate the similarity between the generated enhanced text and its reference text. The higher the METEOR score, the higher the similarity between the generated enhanced text and its reference text.

[0054] The following describes the generation process of enhanced text by taking the preset threshold of 0.9 and the number of repeated stops as 5 as an example. During the experiment, for each newly generated defect report, its METEOR score with the reference text can be calculated. If the METEOR score is greater than or equal to 0.9, then the newly generated defect report is retained. If the METEOR score is less than 0.9, then the original method is used to regenerate a new defect report and calculate the METEOR score, which is repeated up to five times. If the number of repeated stops is reached, the last generated defect report is retained. Finally, the CWE label value corresponding to the reference defect report (ie, the reference text) is assigned to the newly generated defect report (ie, the enhanced text), and each newly generated defect report is added to the enhanced dataset.

[0055] According to the above method, the 10 categories with cwe label values ​​of 1-10 are respectively enhanced. At the same time, for the defect report with a cwe label value of 0, a method in the EDA technology is randomly used to perform text enhancement, and the newly generated defect report is added to the enhanced data set. Through the above steps, an enhanced data set can be obtained, and it can be guaranteed that there are no defect reports in the enhanced data set that are the same as the original data set. That is to say, each defect report in the enhanced data set is newly generated using the EDA technology, which is also done to facilitate the subsequent training and testing of the data set.

[0056] After completing text enhancement using EDA technology, the present invention makes statistics on the distribution of the EDA enhanced data set, and the statistical results are shown in Table 4.

[0057] Table 4 Number of defect reports corresponding to each cwe label value

[0058] cwe tag value quantity Calculation process 0 40987 40987*1 1 15072 314*48 2 5760 120*48 3 17088 89*192 4 15168 79*192 5 7680 40*192 6 5760 30*192 7 9216 16*576 8 9216 16*576 9 8064 14*576 10 5184 9*576 total 139195

[0059] (2) Undersample the defect reports in each defect category in the enhanced dataset to obtain the training dataset.

[0060] The undersampling method may be a random undersampling method.

[0061] After applying the simple data enhancement technology EDA to the original data set, an enhanced data set is obtained. Compared with the original defect report data set, the sample imbalance problem in the enhanced data set is alleviated, but the number of defect reports corresponding to different CWE categories is still different. For this reason, the present invention uses an undersampling method to further process the enhanced data set. During the processing, the present invention uses a random undersampling method to reduce the number of defect reports corresponding to each CWE category in the enhanced data set to 5000, so that the final training data set is obtained. The number of defect reports corresponding to each CWE category in the training data set is equal, and there will be no sample imbalance problem similar to the original defect report data set.

[0062] S3. Use the training data set to train a classifier to obtain a classification model, and use the classification model to classify and predict the defect reports in the defect report data set to obtain a classification prediction result.

[0063] Specifically, the T5 model is used to obtain the description text representation vector of the defect report in the training data set, and the description text representation vector is used to train the classifier to obtain the classification model.

[0064] The T5 model is used to obtain the description text representation vector of the defect report in the defect report dataset, and the classification model is used to perform classification prediction on the description text representation vector to obtain the classification prediction result.

[0065] Specifically, the present invention uses the obtained training data set as the training set and the original defect report data set as the test set; first, the T5 model is used to obtain the defect report description text representation vectors of the training data set and the original defect report data set respectively. Then a logistic regression classifier is established for the cwe label for training and testing. After the logistic regression classifier is established, it is first trained using the description text representation vector corresponding to the training data set, and then tested on the description text representation vector corresponding to the original defect report data set.

[0066] In the process of classifying defect reports, for each label, the present invention can obtain a confusion matrix in the classification process, which is used to compare the classification prediction result and the true value. For category i in the label, the confusion matrix in the classification process is shown in Table 5.

[0067] Table 5 Confusion matrix

[0068]

[0069] For each category in the label, the precision, recall and F1-score can be used to evaluate the experimental results. The calculation formulas of these three evaluation indicators are shown in formula (1), formula (2) and formula (3) respectively.

[0070]

[0071]

[0072] Among them, TP represents the number of defect reports predicted to be category i and whose true category is also category i; FP represents the number of defect reports predicted to be category i but whose true category is other categories; FN represents the number of defect reports whose true category is category i but predicted to be other categories.

[0073] The present invention uses an untrained logistic regression classifier to directly classify and predict the description text representation vector corresponding to the original defect report data set, and the obtained classification results are shown in Table 6; the present invention uses a simple data enhancement EDA technology and an undersampling method to process the original defect report data set to obtain a training data set, and trains the logistic regression classifier to obtain a trained classification model, and then uses the trained classification model to classify and predict the description text representation vector corresponding to the original defect report data set, and the obtained classification results are shown in Table 7;

[0074] Table 6 Classification results of the untrained classifier on each cwe label value

[0075] Tag value Accuracy Recall F1 value 0 98.67% 99.99% 99.32% 1 82.35% 29.62% 40.58% 2 0 0 0 3 0 0 0 4 0 0 0 5 0 0 0 6 0 0 0 7 0 0 0 8 0 0 0 9 0 0 0 10 0 0 0

[0076] Table 7 Classification results of the trained classification model on each cwe label value

[0077]

[0078]

[0079] By comparing Table 6 and Table 7, we can find that after using simple data enhancement EDA technology and undersampling method to solve the problem of sample imbalance in the training set, the precision, recall and F1 value of the classifier on most minority categories have been significantly improved. For the category with cwe label value of 1, its precision has decreased, but its recall has been significantly improved. For the majority category, that is, the category with cwe label value of 0, although its recall and F1 value have decreased, the classification effect is still very good, and the precision, recall and F1 value can be maintained at a very high level, and the precision has been improved compared with the previous experiment.

[0080] For minority categories, the recall rate can be maintained at a very high level, but the precision rate is relatively low. According to the calculation formula of precision and recall rate, we can analyze the reasons for the above results. For precision and recall rate, the numerators in the calculation formula are the same, both are TP, that is, the number of defect reports predicted as category i and the true category is also category i. However, the denominators in the calculation formulas of the two are different. For the calculation formula of precision rate, the denominator is the sum of TP and FP. For the calculation formula of recall rate, the denominator is the sum of TP and FN. Among them, FP represents the number of defect reports predicted as category i, but the true category is other categories, and FN represents the number of defect reports predicted as category i, but the true category is other categories. A low precision rate indicates a high FP value, and a high recall rate indicates a low FN value. Through the above analysis, it can be concluded that for minority categories, a high recall rate indicates that the vast majority of defect reports in minority categories can be predicted correctly. The low precision indicates that defect reports of other categories are predicted as the minority category, and most of these incorrectly predicted defect reports are categories with a cwe label value of 0. The reason is that categories with a cwe label value of 0 account for a large proportion of the test set, exceeding 98%. Therefore, it is inevitable that some defect reports will be incorrectly predicted as the minority category during the prediction process.

[0081] In summary, after using simple data enhancement EDA technology and undersampling methods to solve the sample imbalance problem in the training set, the classifier can accurately predict the minority category, that is, the defect reports with CWE label values ​​of 1-10, and these defect reports are often security-related defect reports and need to be processed in a timely manner. Therefore, by using the strategy proposed in the present invention to solve the sample imbalance, it can effectively help relevant personnel identify security-related and defect reports belonging to certain specific CWE categories, so that the problems recorded in these defect reports can be effectively and timely processed to avoid causing more serious network security problems.

[0082] The above are only a few embodiments of the present application and do not constitute any form of limitation to the present application. Although the present application is disclosed as above with preferred embodiments, it is not intended to limit the present application. Any technician familiar with the profession, without departing from the scope of the technical solution of the present application, using the technical content disclosed above to make slight changes or modifications are equivalent to equivalent implementation cases and fall within the scope of the technical solution.

Claims

1. A method for automatic classification of security defects based on feedback data enhancement, characterized in that: The method comprises: S1. Perform data enhancement on each defect report in the defect report dataset to generate enhanced text; S2, performing a quality assessment on the enhanced text, and forming a training data set according to the assessment results of the enhanced text; S3. Using the training data set to train a classifier to obtain a classification model, and using the classification model to perform classification prediction on the defect reports in the defect report data set to obtain a classification prediction result.

2. The method according to claim 1, characterized in that The S1 specifically includes: Determine the enhancement factor for each defect category in the defect report dataset; The defect reports in each defect category in the defect report dataset are enhanced using the corresponding enhancement coefficient to generate enhanced text.

3. The method according to claim 1, characterized in that The S2 specifically includes: Performing a quality assessment on the enhanced text, and determining an enhanced data set according to the assessment result of the enhanced text; The defect reports in each defect category in the enhanced data set are undersampled to obtain a training data set.

4. The method according to claim 3, characterized in that The step of performing a quality assessment on the enhanced text and determining an enhanced data set according to the assessment result of the enhanced text is specifically as follows: Determine the similarity between each enhanced text and its reference text, and add the defect category label of the reference text to the enhanced text that meets the similarity standard and add it to the enhanced data set; For the reference text corresponding to the enhanced text that does not meet the similarity standard, the enhanced text is regenerated until the similarity of the regenerated enhanced text meets the similarity standard, or the number of regenerations reaches the repeated stop number. The last regenerated enhanced text is added with the defect category label of its reference text and added to the enhanced dataset.

5. The method according to claim 2, characterized in that: The data enhancement methods include synonym replacement, random insertion, random exchange and random deletion.

6. The method according to claim 5, characterized in that Bug reports within each bug category use the four data augmentation methods equally often.

7. The method according to claim 4, characterized in that The similarity measurement indicator is the METEOR score; the similarity standard is that the METEOR score is greater than or equal to a preset threshold.

8. The method according to claim 2, characterized in that: The enhancement coefficient of the minority defect category in the defect report data set is greater than the enhancement coefficient of the majority defect category.

9. The method according to claim 1, characterized in that: The S3 uses the training data set to train the classifier to obtain a classification model, specifically: The T5 model is used to obtain the description text representation vector of the defect report in the training data set, and the description text representation vector is used to train a classifier to obtain a classification model.

10. The method according to claim 1, characterized in that The S3 uses the classification model to perform classification prediction on the defect reports in the defect report dataset to obtain the classification prediction result, which is specifically: The T5 model is used to obtain the description text representation vector of the defect report in the defect report data set, and the classification model is used to perform classification prediction on the description text representation vector to obtain a classification prediction result.

Citation Information

Patent Citations

  • Fault recognition model training method and device, fault recognition method and device and electronic equipment

    CN113689111A

  • Method and equipment for updating training data set

    CN114022737A

  • Model training method, text classification method, system, equipment and medium

    CN114297385A

  • Text processing model training method, electronic equipment and readable storage medium

    CN116628132A

  • Text augmentation of a minority class in a text classification problem

    US20220366293A1