A security evaluation method and system for large model code generation capability
By generating adversarial code samples through adversarial attacks, this technology solves the problem that existing large-model code generation capability evaluation systems cannot comprehensively assess security, enabling security evaluation under black-box conditions and improving the comprehensiveness and accuracy of the evaluation.
Patent Information
- Application Number
- CN202411071578.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-06
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2044-08-06
AI Technical Summary
Existing large model code generation capability evaluation systems cannot comprehensively assess the security of models in real-world applications, and their reliance on fixed datasets cannot cover a wide range of code and vulnerability types, resulting in an inaccurate reflection of model security.
Adopting the concept of adversarial attacks, we construct a dataset by extracting vulnerable code from the CVE database and GitHub, and use adversarial code hint generation technology to evaluate the security of a large model in a black-box environment. This includes cleaning and vectorizing the vulnerable code, calculating token importance scores using gradient information, and applying semantically preserved mutations to generate adversarial samples.
While preserving the semantics of the code, it can reliably evaluate the code generation capabilities of large models, reduce the limitations of fixed test cases, and improve the comprehensiveness and accuracy of the evaluation.
Smart Images

Figure CN119089411B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer software technology, and mainly relates to a security evaluation method and system for large model code generation capabilities, in order to reduce the security risks caused by potential vulnerabilities in the code generated by large models. Background Technology
[0002] With the rapid development of large-scale modeling technology, its role in code generation is becoming increasingly important, and it is widely used to solve software engineering tasks such as code generation and code completion. Benefiting from massive amounts of data and advanced learning algorithms, large-scale models demonstrate outstanding capabilities in understanding code semantics and natural language, generating usable program code based on concise descriptions and hints, greatly improving development efficiency. However, this convenience also brings potential security risks. Due to the influence of low-quality training data or misleading code hints, large-scale models may generate code that appears reasonable on the surface but may contain vulnerabilities, potentially leading to serious security risks such as data breaches and remote execution vulnerabilities. Therefore, how to evaluate the security level of large-scale model code generation capabilities has become a pressing problem for developers.
[0003] Current evaluation systems for large model code generation capabilities have two main problems: First, they only evaluate the ability of large models to solve code problems without considering their security. For example, the HumanEval benchmark developed by OpenAI includes a large number of programming problems of varying difficulty and type written by human experts to evaluate AI's ability to solve programming problems. However, the possibility that code that passes the problem tests correctly may have security vulnerabilities cannot be ruled out. Second, the evaluation methods rely too much on fixed datasets and cannot cover a sufficiently rich variety of code and vulnerability types, nor can they adequately reflect real-world application scenarios. For example, the RobustAPI method only evaluates the reliability performance of large models in the use of some typical APIs.
[0004] In summary, existing evaluation methods may not be able to comprehensively assess the model's performance in real-world applications, or accurately reflect issues such as the model's security. Summary of the Invention
[0005] To address the aforementioned problems, the present invention aims to provide a security evaluation method and system for large model code generation capabilities. This invention utilizes the concept of adversarial attacks, targeting large models, and proposes an adversarial code suggestion generation technique that preserves semantic invariance. While maintaining semantic integrity, the large model generates and completes code based on different suggestions. Insecure large models will generate vulnerable code under specific suggestions. The security of the large model's code generation capability is evaluated under black-box conditions, thereby determining whether the large model is secure.
[0006] This invention employs the concept of adversarial attacks, targeting large models by cleaning and vectorizing vulnerable code, and generating adversarial attack samples through attribution localization and semantically preserving mutations. The principle is as follows: First, we extract actual vulnerable code from CVE databases and GitHub, clean and annotate it to construct our dataset, and then select data supplementary security results from the target large model (i.e., the code generation model) as input for searching adversarial samples. Second, using gradient information, we calculate the importance score of each token in the hint to identify the part of the code in the hint that has the greatest impact on the model's output. Finally, based on the importance score, we select high-scoring tokens and apply semantically preserving mutations to generate modified hints. The new hints are semantically similar to the original hints, with the aim of potentially triggering insecure code generation in the large model. Our method can generate adversarial code samples that are very similar to the original input to induce the large model to generate vulnerable code. This comprehensive and targeted strategy allows us to better evaluate the security of code generation models, paving the way for the development of defensive mechanisms to prevent adversarial attacks.
[0007] The specific details of each step involved in the above method are explained below:
[0008] (1) Sample construction. We extracted the vulnerability code from GitHub and obtained high-quality vulnerability instances through manual verification. We then standardized the vulnerability instances into triplet samples in a unified format to construct a dataset for large model evaluation.
[0009] (2) Attribution localization. By performing forward computation on the target large model to obtain the gradient of the probability difference of the model output relative to the input token vector, and then calculating the attribution matrix, we can determine which tokens have the most significant impact on the model's prediction, which can greatly reduce the search space when performing semantically preserved mutations on the prompts.
[0010] (3) Semantic Preservation Mutation. To evaluate the security of the code generation capability of the target large model, it is necessary to test whether it can give consistent outputs to inputs with the same semantics. To this end, through experiments and comparisons, we designed a set of semantic preservation mutation rules, including 14 strategies at five different levels of code granularity. Using attribution matrix search, we generated a series of new code hints that are semantically equivalent to the original code hints, in order to test the security of the target large model.
[0011] (4) Model security testing. The new code hints obtained through the above process are the adversarial attack samples. The new code hints are directly input into the target large model. The target large model generates and completes lines based on the new code hints. Vulnerability detection is performed on the output code. The proportion of insecure code output by the target large model reflects its security.
[0012] The technical solution of this invention is as follows:
[0013] A security evaluation method for large model code generation capabilities includes the following steps:
[0014] 1) Obtain multiple vulnerability code instances from the vulnerability database, and obtain two versions of code snippets corresponding to each vulnerability code instance, one of which is the insecure code before patching and the other is the secure code after patching, forming a vulnerability instance code pair, and obtaining a set of vulnerability instance code pairs; use the CWE classification method to classify the vulnerability to which each vulnerability code instance belongs, and obtain the vulnerability category of each vulnerability code instance.
[0015] 2) Extract a triplet from each of the vulnerability instance code pairs.<p,v,s> A validation set is constructed for evaluating the target large model; where p is a code segment before the vulnerability point in the insecure code, serving as a hint that the target large model code is complete; v is the vulnerability code corresponding to the vulnerability point; and s is the code extracted from the secure code after patching the vulnerability point.
[0016] 3) Construct an input sequence w = [w1, w2, ..., wn] of length n based on the extracted triples and input it into the target large model to obtain the corresponding input sequence embedding set e = [e1, e2, ..., en] and the output probability p of each word, where wn is the nth word and the probability of the word outputting the security label lsec is represented by p. sec The probability that the word output is the vulnerable tag lvul is represented by p. vul Then the attribution matrix is calculated. B = [B1, B2, ..., Bn] represents the attribution matrix, where the i-th element Bi in the attribution matrix B corresponds to the partial derivative of the output probability difference of the i-th word with respect to the i-th element ei in the input sequence embedding set e; the norm s of Bi is calculated. i =||B i || is the importance score of the i-th element wi in the input sequence w, i = 1 to n;
[0017] 4) Construct an abstract syntax tree for each vulnerability code instance corresponding to the vulnerability code instance, and aggregate the importance scores of each word contained in each syntax node in the abstract syntax tree as the label of the corresponding syntax node;
[0018] 5) The target large model mutates the input prompts of the triplet samples in descending order of importance score according to the set mutation strategy to obtain adversarial prompt samples; then, the security of the code generation capability of the target large model is evaluated based on the proportion of insecure code in the adversarial prompt samples generated by the target large model.
[0019] Furthermore, the mutation strategy includes 14 mutation strategies at five levels, ranging from fine-grained to coarse-grained:
[0020] (1)Token level:
[0021] (a) Identifier replacement: Replacing the original identifier with a different identifier;
[0022] (2) Expression level:
[0023] (a) Assignment expression line truncation: Adding a newline character to separate the content within the expression into different lines;
[0024] (b) Converting a conditional expression to an if statement: Converting a conditional expression into an if statement;
[0025] (c) Rearrange the order of conditional expressions: Rearrange the order of conditional expressions;
[0026] (d) Lambda expression to function call: converting a lambda expression into a function definition and call;
[0027] (e) Converting a comprehension to a loop statement: Converting a comprehension into a loop statement;
[0028] (3) Simple Statement level:
[0029] (a) Expression statement assignment: Convert expression statements into assignment statements;
[0030] (b) Simplification of enhanced assignment statements: Convert enhanced assignment statements into ordinary assignment statements;
[0031] (c) Assertion to if statement: Converts an assertion into an if statement;
[0032] (4) Compound Statement level:
[0033] (a) If statement inversion: Reverses the condition of the if statement and swaps the contents of the if and else blocks;
[0034] (b) Exiting the while statement: Add a break statement when the while statement is always true;
[0035] (c) Converting a for statement to a while statement: Converting a for statement into a while statement;
[0036] (d) Converting a with statement to a try-finally statement: Converting a with statement into a try-finally statement;
[0037] (5) Block level:
[0038] (a) Add API alias: Set an alias for the imported API.
[0039] Furthermore, the unpatched insecure code contained only one line of vulnerable code.
[0040] Furthermore, the vulnerability database includes a CVE database and a GitHub database.
[0041] Furthermore, the target large model is a code generation model.
[0042] A security evaluation system for large model code generation capabilities, characterized by including:
[0043] The data collection module is used to obtain multiple vulnerability code instances from the vulnerability database, obtain two versions of code snippets corresponding to each vulnerability code instance, one of which is the insecure code before patching and the other is the secure code after patching, forming a vulnerability instance code pair, and obtaining a set of vulnerability instance code pairs; the CWE classification method is used to classify the vulnerability to which each vulnerability code instance belongs, and obtain the vulnerability category of each vulnerability code instance;
[0044] The dataset construction module is used to extract a triplet from each of the vulnerability instance code pairs.<p,v,s> A validation set is constructed for evaluating the target large model; where p is a code segment before the vulnerability point in the insecure code, serving as a hint that the target large model code is complete; v is the vulnerability code corresponding to the vulnerability point; and s is the code extracted from the secure code after patching the vulnerability point.
[0045] The attribution calculation module is used to construct an input sequence w = [w1, w2, ..., wn] of length n based on the extracted triples and input it into the target large model to obtain the corresponding input sequence embedding set e = [e1, e2, ..., en] and the output probability p of each word in the vocabulary, where wn is the nth word and the probability of the word outputting the security label lsec is represented by p. sec The probability that the word output is the vulnerable tag lvul is represented by p. vul Then the attribution matrix is calculated. B = [B1, B2, ..., Bn] represents the attribution matrix, where the i-th element Bi in the attribution matrix B corresponds to the partial derivative of the output probability difference of the i-th word with respect to the i-th element ei in the input sequence embedding set e; the norm s of Bi is calculated. i =||B i || is the importance score of the i-th element wi in the input sequence w, i = 1 to n;
[0046] The attribution localization module is used to construct an abstract syntax tree for each vulnerability instance code pair corresponding to the vulnerability code instance, and to aggregate the importance scores of each word contained in each syntax node in the abstract syntax tree as a label for the corresponding syntax node.
[0047] The evaluation module is used to mutate the input prompts of the triplet samples according to the set mutation strategy based on the target large model, in descending order of importance score, to obtain adversarial prompt samples; then, the security of the code generation capability of the target large model is evaluated based on the proportion of insecure code in the adversarial prompt samples generated by the target large model.
[0048] A server is characterized by comprising a memory and a processor, the memory storing a computer program configured to be executed by the processor, the computer program including instructions for performing the methods described above.
[0049] A computer-readable storage medium having a computer program stored thereon, characterized in that the computer program implements the above-described method when executed by a processor.
[0050] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0051] This invention uses real-world scenario data to perform adversarial attacks on the model while preserving the semantics of code hints. It can provide a reliable assessment of the security of the code generation capability of large models in a black-box environment. Attached Figure Description
[0052] Figure 1 This is a system technical flowchart of the present invention. Detailed Implementation
[0053] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below through specific examples.
[0054] Unlike most current large model evaluation techniques that use fixed test cases to determine the security of a model's code generation capabilities, this invention addresses the issue from the perspective of adversarial attacks: if a large model cannot consistently and securely complete code prompts with the same semantics, it may have security vulnerabilities. This invention reduces the limitations of fixed test cases through this approach. The specific implementation process is as follows:
[0055] (1) Data Collection: Since adversarial attacks require a certain amount of sample dataset, this invention first collects vulnerabilities with vulnerable code instances (e.g., GitHub links) from a vulnerability database. Then, a web crawler is used to collect two versions of code snippets from the instance code: one is the insecure code before patching, and the other is the secure code after patching, forming vulnerability instance code pairs. To improve the accuracy of the target large model when generating code, only single-line modified code pairs are retained; that is, a line in the code before patching caused the vulnerability, and the modification of that line patched the vulnerability. The code is then reviewed and verified to ensure that the code pair patches the corresponding vulnerability. The CWE taxonomy is used to classify the vulnerability to which each instance belongs, so as to conduct a comprehensive analysis based on the vulnerability type.
[0056] (2) Dataset Construction: After obtaining vulnerability instance data, this invention defines a triplet.<p,v,s> To construct a validation set for large model evaluation. Here, p is a code segment before the vulnerability point, serving as a hint that the target large model code is complete; v is the vulnerable line of code in the unsecured code before patching; and s is the secure code after patching the vulnerable line. Each vulnerability instance is normalized into a triple according to this definition, resulting in the evaluation dataset {x0, x1, ..., xn}, used for subsequent adversarial example generation. Here, xi is the i-th specific triple, i = 1 to n, and n is the total number of triples in the validation set, for example: <p:"from lxml import etree\nfrom lxml.etree import CDATA\n……def_add_text_elm(entry,data,name):\n\n\tifnot data:\n\t\tif not data:\n\t\t\treturn\n\n\telm=",v:"etree.SubElement(entry,name)",s:"xml_elem(name,entry)"> .
[0057] (3) Attribution Calculation: Before generating adversarial prompt samples by preserving semantic mutations on the validation set samples, in order to reduce the search space of mutations and improve the effectiveness of the generated adversarial prompts, we use attribution-guided localization to determine the key tokens in the prompts that have a significant impact on the model output. Specifically, we use the gradient of the model output relative to the input token embeddings to help us determine which tokens have the most significant impact on the model's prediction. First, we perform forward computation on the target large model. Assume the target large model is F(·). Inputting an input sequence of length n w = [w1, w2, ..., wn] into the model, we can obtain the input sequence embedding set e = [e1, e2, ..., en] and the output probability p of each word in the input sequence in the vocabulary of the target large model, as shown below:
[0058] For the secure output label lsec and the vulnerable output label lvul, the probability of them in the vocabulary is represented by p = F(w). sec and p vul :
[0059] p sec =P sec (F(w))p vul =P vul (F(w))
[0060] The attribution matrix B is directly generated by calculating the following partial derivatives:
[0061]
[0062] Here, B = [B1, B2, ..., Bn] denotes the attribution matrix, where each element Bi corresponds to the partial derivative of the probability difference with respect to the embedding ei of the input sequence. To obtain the final importance score S = [s0, s1, ..., sn], we compute the norm s of each element in the attribution matrix Bi. i As the importance score of the i-th element wi in the input sequence w, i = 1 to n:
[0063]
[0064] Through the above calculations, we obtained the importance score of the input sequence w.
[0065] (4) Attribution Localization: The importance score of the input sequence w calculated by the above method is based on the tokenization result of the large model, which may differ from the actual code syntax nodes. That is, the score may be assigned to a single token that does not have complete syntax. For example, the function name "_add_text_elm" is recognized by the model tokenizer as "_", "add", "_", "text", "_", "elm", but should be recognized as "_add_text_elm" in the Python tokenizer. To this end, by accumulating the importance scores of the tokens that are additionally split by the model tokenizer to the same syntax token node, we construct an abstract syntax tree of the code and aggregate the importance scores recognized by the model to the single syntax node token corresponding to the abstract syntax tree (AST). This completes the attribution localization and obtains the influence scores of different tokens in the code fragment on the model output. This invention constructs an abstract syntax tree for each vulnerability code instance corresponding to the vulnerability instance code pair, and aggregates the importance scores of each word contained in each syntax node in the abstract syntax tree as the token of the corresponding syntax node.
[0066] (5) Semantic Preservation Mutation: To generate adversarial suggestion samples to check whether the model can maintain consistent secure code completion for code suggestions with the same semantics, this invention develops a set of semantic preservation mutation methods that can generate a series of new code suggestions that are semantically equivalent to the original code suggestions. Specifically, based on the Python language reference, we designed 14 mutation strategies at 5 levels, from fine-grained (token) to coarse-grained (block):
[0067] 1)Token level:
[0068] (a) Identifier replacement: Replace the original identifier with a different identifier.
[0069] 2) Expression level:
[0070] (a) Assignment expression line truncation: Add a newline character to separate the content of the expression into different lines.
[0071] (b) Convert conditional expression to if statement: Convert conditional expression to if statement.
[0072] (c) Rearrange the order of conditional expressions: Rearrange the order of conditional expressions.
[0073] (d) Lambda expression to function call: Converts a lambda expression into a function definition and call.
[0074] (e) Converting a comprehension to a loop statement: Converting a comprehension into a loop statement.
[0075] 3) Simple Statement level:
[0076] (a) Expression statement assignment: Converts an expression statement into an assignment statement.
[0077] (b) Simplification of enhanced assignment statements: Convert enhanced assignment statements into ordinary assignment statements.
[0078] (c) Assertion to if statement: Converts assertions into if statements.
[0079] 4) Compound Statement level:
[0080] (a) If statement inversion: Reverses the condition of the if statement and swaps the contents of the if and else blocks.
[0081] (b) While statement exit: Add a break statement when the while statement is always true.
[0082] (c) Converting a for statement to a while statement: Converting a for statement to a while statement.
[0083] (d) Converting with statement to try-finally statement: Convert the with statement into a try-finally statement.
[0084] 5) Block level:
[0085] (a) Add API alias: Set an alias for the imported API.
[0086] Using the above mutation strategy, we mutate the input prompts of the triplet samples in the dataset in descending order of importance score to obtain adversarial prompt samples. By using the samples to make the target model complete the code, the proportion of insecure code generated by the target model can be used to evaluate the security of its generation capability.
[0087] In summary, this invention designs a security evaluation method for large model code generation capabilities based on adversarial attacks. It uses generated vulnerable code to simulate real-world usage scenarios, employs a code semantic preservation mutation method to generate adversarial attack samples, reduces the impact of fixed test cases, and uses an attribution localization method to reduce the mutation search space, thereby improving the efficiency of adversarial attack evaluation. Experiments show that the method proposed in this invention can effectively automate the generation of anti-analysis samples and evaluate the security of large model code generation capabilities.
[0088] The above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Those skilled in the art can modify or make equivalent substitutions to the technical solutions of the present invention without departing from the spirit and scope of the present invention. The scope of protection of the present invention should be determined by the claims.
Claims
1. A security evaluation method for large model code generation capabilities, comprising the following steps: 1) Obtain multiple vulnerability code instances from the vulnerability database, and obtain two versions of code snippets corresponding to each vulnerability code instance, one of which is the insecure code before patching and the other is the secure code after patching, forming a vulnerability instance code pair, and obtaining a set of vulnerability instance code pairs; use the CWE classification method to classify the vulnerability to which each vulnerability code instance belongs, and obtain the vulnerability category of each vulnerability code instance. 2) Extract a triplet from each of the vulnerability instance code pairs.<p,v,s> Construct a validation set for evaluating the target large model; Where p is a section of code preceding the vulnerability point in the insecure code, serving as a prompt that the target large model code is complete; v is the vulnerability code corresponding to the vulnerability point; and s is the code extracted from the secure code that patches the vulnerability point. 3) Construct an input sequence w = [w1, w2, ..., wn] of length n based on the extracted triples and input it into the target large model to obtain the corresponding input sequence embedding set e = [e1, e2, ..., en] and the output probability p of each word, where wn is the nth word and the probability of the word outputting the security label lsec is represented by p. sec The probability that the word output is the vulnerable tag lvul is represented by p. vul Then the attribution matrix is calculated. B = [B1, B2, ..., Bn] represents the attribution matrix, where the i-th element Bi in the attribution matrix B corresponds to the partial derivative of the output probability difference of the i-th word with respect to the i-th element ei in the input sequence embedding set e; the norm s of Bi is calculated. i =||B i || is the importance score of the i-th element wi in the input sequence w, i = 1 to n; 4) Construct an abstract syntax tree for each vulnerability code instance corresponding to the vulnerability code instance, and aggregate the importance scores of each word contained in each syntax node in the abstract syntax tree as the label of the corresponding syntax node; 5) The target large model mutates the input prompts of the triplet samples in descending order of importance score according to the set mutation strategy to obtain adversarial prompt samples; then, the security of the code generation capability of the target large model is evaluated based on the proportion of insecure code in the adversarial prompt samples generated by the target large model.
2. The method according to claim 1, characterized in that, The mutation strategies include 14 mutation strategies at 5 levels, ranging from fine-grained to coarse-grained: (1)Token level: (a) Identifier replacement: Replacing the original identifier with a different identifier; (2) Expression level: (a) Assignment expression line truncation: Adding a newline character to separate the content within the expression into different lines; (b) Converting a conditional expression to an if statement: Converting a conditional expression into an if statement; (c) Rearrange the order of conditional expressions: Rearrange the order of conditional expressions; (d) Lambda expression to function call: converting a lambda expression into a function definition and call; (e) Converting a comprehension to a loop statement: Converting a comprehension into a loop statement; (3) Simple Statement level: (a) Expression statement assignment: Convert expression statements into assignment statements; (b) Simplification of enhanced assignment statements: Convert enhanced assignment statements into ordinary assignment statements; (c) Assertion to if statement: Converts an assertion into an if statement; (4) Compound Statement level: (a) If statement inversion: Reverses the condition of the if statement and swaps the contents of the if and else blocks; (b) Exiting the while statement: Add a break statement when the while statement is always true; (c) Converting a for statement to a while statement: Converting a for statement into a while statement; (d) Converting a with statement to a try-finally statement: Converting a with statement into a try-finally statement; (5) Block level: (a) Add API alias: Set an alias for the imported API.
3. The method according to claim 1, characterized in that, The unsecured code before patching contained only one line of vulnerable code.
4. The method according to claim 1, characterized in that, The vulnerability database includes the CVE database and the GitHub database.
5. The method according to claim 1, characterized in that, The target large model is a code generation model.
6. A security evaluation system for large model code generation capabilities, characterized in that, include The data collection module is used to obtain multiple vulnerability code instances from the vulnerability database, obtain two versions of code snippets corresponding to each vulnerability code instance, one of which is the insecure code before patching and the other is the secure code after patching, forming a vulnerability instance code pair, and obtaining a set of vulnerability instance code pairs; the CWE classification method is used to classify the vulnerability to which each vulnerability code instance belongs, and obtain the vulnerability category of each vulnerability code instance; The dataset construction module is used to extract a triplet from each of the vulnerability instance code pairs.<p,v,s> Construct a validation set for evaluating the target large model; Where p is a section of code preceding the vulnerability point in the insecure code, serving as a hint that the target large model code is complete; v is the vulnerability code corresponding to the vulnerability point; s is the code extracted from the security code that patches the vulnerability; The attribution calculation module is used to construct an input sequence w = [w1, w2, ..., wn] of length n based on the extracted triples and input it into the target large model to obtain the corresponding input sequence embedding set e = [e1, e2, ..., en] and the output probability p of each word in the vocabulary, where wn is the nth word and the probability of the word outputting the security label lsec is represented by p. sec The probability that the word output is the vulnerable tag lvul is represented by p. vul Then the attribution matrix is calculated. B = [B1, B2, ..., Bn] represents the attribution matrix, where the i-th element Bi in the attribution matrix B corresponds to the partial derivative of the output probability difference of the i-th word with respect to the i-th element ei in the input sequence embedding set e; the norm s of Bi is calculated. i =||B i || is the importance score of the i-th element wi in the input sequence w, i = 1 to n; The attribution localization module is used to construct an abstract syntax tree for each vulnerability instance code pair corresponding to the vulnerability code instance, and to aggregate the importance scores of each word contained in each syntax node in the abstract syntax tree as a label for the corresponding syntax node. The evaluation module is used to mutate the input prompts of the triplet samples according to the set mutation strategy based on the target large model, in descending order of importance score, to obtain adversarial prompt samples; then, the security of the code generation capability of the target large model is evaluated based on the proportion of insecure code in the adversarial prompt samples generated by the target large model.
7. A server, characterized in that, It includes a memory and a processor, the memory storing a computer program configured to be executed by the processor, the computer program including instructions for performing the method of any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 5.
Citation Information
Patent Citations
Method and device for detecting vulnerability caused by imperfect patch and medium
CN117131499A
Source code vulnerability fine-grained identification method based on vulnerability patch pairs
CN117272323A