A cloud security application testing method, system, device and storage medium

By combining a BERT-based multi-expert dynamic integration model with TestContainer, the problem of the disconnect between generation and execution in cloud security testing is solved, enabling efficient and accurate cloud security testing. This approach can handle unknown configurations and novel logical anomalies, improving the confidence of test results and environmental consistency.

CN123138124APending Publication Date: 2026-11-20BEIJING VENUS INFORMATION SECURITY TECH +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202611405454.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-10
Publication Date
2026-11-20

AI Technical Summary

Technical Problem

Existing cloud security testing technologies suffer from problems such as static knowledge dependence being disconnected from dynamic threats, environmental distortion, and low confidence in test results. In particular, the generation and execution phases are separated, making it difficult to effectively deal with unknown configurations and new logical anomalies.

Method used

The source code of cloud applications is analyzed using a multi-expert dynamic ensemble model based on pre-trained BERT, a target test set is generated, and a real test environment is created through TestContainer. By combining the dynamic expert committee mechanism and deep integration with TestContainer, a closed loop of test generation and execution is achieved, and a real cloud context is dynamically constructed.

Benefits of technology

It improves the confidence and environmental consistency of test results, can cope with unknown configurations and new logical anomalies, achieves second-level startup and resource isolation, and ensures the accuracy and reliability of test results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123138124A_ABST
    Figure CN123138124A_ABST
Patent Text Reader

Abstract

A cloud security application testing method, system, device and storage medium, by based on pre-trained code pre-training model BERT multi-expert dynamic integration model, analyzes the source code of the to-be-tested cloud application to identify potential security vulnerability data; according to the potential security vulnerability data, a target test set is generated; based on the dependency requirements of the source code of the to-be-tested cloud application, a target test environment is created through TestContainer; execute the test cases in the target test set in the target test environment to obtain the test results, the method integrates the multi-expert dynamic integration model and TestContainer deeply, binds the test generation and the real execution environment together, forms a closed loop of "generation ready for execution", solves the problem of "generation-execution" two-stage fragmentation; not dependent on a static library containing all cloud service knowledge, can cope with unknown configuration and new type of logic exception.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This article relates to cloud computing technology, and in particular to a cloud security application testing method, system, device, and storage medium. Background Technology

[0002] With the widespread adoption of cloud computing and microservice architectures, security testing of cloud-native applications has become a critical aspect of ensuring system reliability. Among existing automated testing technologies, the following are the main mainstream solutions: Firstly, in terms of test environment construction, the industry commonly uses lightweight cluster tools based on Kubernetes (K8s) (such as Kind) or static virtual machine (VM) environments. For example, patent document CN115640221A discloses a cloud testing solution that eliminates environmental differences by starting a test cluster within the same base image. However, such solutions have significant limitations: on the one hand, they require pre-building a complex K8s cluster and configuring image repository authentication, resulting in high operation and maintenance costs and a large base image size, leading to slow test startup speeds; on the other hand, they rely on pre-written test scripts (such as JUnit / TestNG), and the test environment often uses mock services to simulate external dependencies, resulting in poor environment consistency. The mock behavior deviates from real cloud services (such as PostgreSQL and Redis) in terms of error codes, network policies, and performance, making it difficult to expose configuration and integration security risks.

[0003] Secondly, in terms of test case generation, technologies based on Large Language Models (LLM) and Retrieval Enhanced Generation (RAG) are gradually becoming mainstream. For example, patent documents CN119576799A and CN119537222A both utilize large models to generate test cases. Among them, CN119576799A focuses on generating test cases to verify "functional correctness," lacking targeted awareness of security attributes and failing to deeply explore security vulnerabilities such as SQL injection and privilege circumvention; while CN119537222A, although introducing the RAG framework, typically uses static historical data or documents as its knowledge base, which cannot match the dynamic nature of cloud security threats, and also faces the problem of a disconnect between the "generation-execution" two-stage process.

[0004] In summary, existing technologies generally suffer from the following insurmountable defects: Static knowledge is disconnected from dynamic threats: relying on static knowledge bases makes it impossible to deal with new and unknown vulnerability patterns; Environmental distortion: Neither mock nor static containers can fully reproduce the complex interactions of a real cloud environment, resulting in low confidence in the test results. Summary of the Invention

[0005] This application provides a cloud security application testing method, system, device, and storage medium that solves the problem of the disconnect between the "generation-execution" two-stage test case testing. It does not rely on a static library containing knowledge of all cloud services, can cope with unknown configurations and new logical anomalies, and can effectively improve the confidence of test results.

[0006] In a first aspect, embodiments of this application provide a cloud security application testing method, including: Based on a pre-trained BERT-based multi-expert dynamic ensemble model, the source code of the cloud application under test is analyzed to identify potential security vulnerabilities. The BERT-based multi-expert dynamic ensemble model includes multiple task-specific BERT variants, each of which is used to identify different types of security vulnerabilities. Based on potential security vulnerability data, generate a target test set, which includes at least one first test case. Based on the dependency requirements of the source code of the cloud application under test, a target test environment is created using TestContainer; Execute each of the first test cases in the target test set in the target test environment to obtain test results.

[0007] In one possible implementation, the BERT-based multi-expert dynamic ensemble model also includes at least one meta-arbitrator; Based on a pre-trained BERT-based multi-expert dynamic ensemble model, the source code of the cloud application under test is analyzed to identify potential security vulnerability data, including: By using BERT variants tailored to each task, different types of security vulnerability analysis are performed on the source code of the cloud application under test to determine the vulnerability analysis results corresponding to various security vulnerabilities. The meta-arbiter identifies potential security vulnerabilities in the source code of the cloud application under test based on vulnerability analysis results corresponding to various security vulnerabilities.

[0008] In one possible implementation, a task-specific BERT variant includes a BERT encoder and a classification head; By using task-specific variants of BERT, security vulnerability analysis is performed on the source code of the cloud application under test to determine the vulnerability analysis results, including: The source code of the cloud application under test is converted into a sequence of context vectors using the BERT encoder. Based on the classification header, vulnerability analysis results are obtained from the context vector sequence.

[0009] In one possible implementation, each first test case is executed in the target test environment to obtain test results, including: S1. Execute each first test case in the target test environment and evaluate the target test set based on the execution information. The execution information includes at least one of the following: test execution result data, code coverage data, test environment data, and security threat analysis data. S2, determine whether the evaluation result of the target test set is less than the first preset threshold; S3. If the evaluation result of the target test set is less than the first preset threshold, then based on the test execution result data, a supplementary test case is generated and added to the target test set as a new first test case, and step S1 is executed again. S4. If the evaluation result of the target test set is greater than or equal to the first preset threshold, the final test result is obtained based on the execution information.

[0010] In one possible implementation, the test set is evaluated based on execution performance, including: The following expression is used for calculation: , in, , and This indicates the preset weighting coefficients; This represents the overall code coverage of the test set; This indicates the security threat coverage score; Indicates test redundancy; Represents the test set; , Represents test cases i The code vector representation, n This indicates the number of test cases in the test set. Represents test cases j The code vector representation.

[0011] In one possible implementation, the test execution result data includes at least one of the following: uncovered code blocks, discovered crash information, and untested vulnerability data streams; Based on the execution information, generate supplementary test cases, including: Based on the following expression, construct supplementary test case prompts according to the test execution result data. Prompt_iterate=BasePrompt+GapContext, Among them, BasePrompt represents the basic instructions used to generate test cases, GapContextt represents the test execution result data, and Prompt_iterate represents the prompt information for supplementing test cases; Generate supplementary test cases based on the prompts provided.

[0012] Secondly, this application also provides a cloud security application testing device, including a code analysis and test case generation module, a dynamic test environment management module, and a test execution module; the code analysis and test case generation module includes a code analysis unit and a test case generation unit; the code analysis unit is deployed with a pre-trained BERT-based multi-expert dynamic ensemble model, which includes multiple task-specific BERT variants, each task-specific BERT variant being used to identify different types of security vulnerabilities; The code analysis unit is used to analyze the source code of the cloud application under test based on a pre-trained BERT-based multi-expert dynamic ensemble model to identify potential security vulnerabilities. The test case generation unit is used to generate a target test set based on potential security vulnerability data. The target test set includes at least one first test case. The dynamic test environment management module is used to create target test environments through TestContainer based on the dependency requirements of the source code of the cloud application under test. The test execution module is used to control the execution of each first test case in the target test environment to obtain test results.

[0013] One possible implementation also includes: Feedback collection module and central control and iterative optimization module; The feedback collection module is used to collect execution information corresponding to each test set and feed the execution information back to the central control and iterative optimization module. The execution information includes at least one of the following: test execution result data, code coverage data, test environment data, and security threat analysis data. The central control and iterative optimization module is used to evaluate the target test set based on the execution information; determine whether the evaluation result of the target test set is less than the first preset threshold; when it is determined that the evaluation result of the target test set is less than the first preset threshold, generate supplementary test cases based on the test execution result data, and add the supplementary test cases as new first test cases to the target test set to obtain a new target test set; The test execution module is also used to control the execution of each first test case in the new target test case in the target test environment to obtain test results.

[0014] Thirdly, embodiments of this application also provide an electronic device, including a processor and a computer-readable storage medium, wherein the computer-readable storage medium stores instructions that, when executed by the processor, implement the method as provided in any of the first aspects.

[0015] Fourthly, embodiments of this application also provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method as provided in any of the first aspects.

[0016] This application provides a cloud security application testing method, system, device, and storage medium. The method includes analyzing the source code of the cloud application under test based on a pre-trained BERT-based multi-expert dynamic ensemble model; generating a target test set based on the analysis results of the source code, the target test set including at least one first test case; creating a target test environment through a TestContainer based on the dependency requirements of the source code of the cloud application under test; and executing each first test case in the target test environment to obtain test results. This method deeply integrates the BERT-based dynamic expert committee mechanism with the TestContainer, binding test generation with the real execution environment. The target execution environment for each generated test case is a dynamically constructed, isolated, and real cloud context by the TestContainer. Through dynamic context combination, a closed loop of generation and execution preparation is formed, solving the problem of the separation between the "generation-execution" two-stage test case in the prior art. The BERT-based multi-expert dynamic ensemble model serves as the planning and decision-making center, analyzing the code and planning the test strategy. As an action and execution tool, it is responsible for taking action (starting a real database, configuring the network) to build a lightweight containerized test environment, dynamically generating minimal dependency images (such as PostgreSQL and Redis), achieving second-level startup and resource isolation, and ensuring environment consistency. Instead of relying on a static library containing knowledge of all cloud services, it relies on the code semantic understanding capabilities of a BERT-based multi-expert dynamic ensemble model to infer potential risks, and on the real environment provided by TestContainer to verify these risks. This makes its testing foundation the code itself and the real behavior at runtime, thus enabling it to cope with unknown configurations and new logical anomalies.

[0017] Other features and advantages of this application will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing the application. Other advantages of this application can be realized and obtained by means of the embodiments described in the description and the accompanying drawings. Attached Figure Description

[0018] The accompanying drawings are used to provide an understanding of the technical solutions of this application and constitute a part of the specification. They are used together with the embodiments of this application to explain the technical solutions of this application and do not constitute a limitation on the technical solutions of this application.

[0019] Figure 1This application provides a flowchart illustrating a cloud security application testing method. Figure 2 This application provides a schematic diagram of the structure of a cloud security application testing device. Detailed Implementation

[0020] This application describes several embodiments, but these descriptions are exemplary and not limiting, and it will be apparent to those skilled in the art that many more embodiments and implementations are possible within the scope of the embodiments described herein. Although many possible combinations of features are shown in the drawings and discussed in the detailed description, many other combinations of the disclosed features are also possible. Unless specifically limited, any feature or element of any embodiment may be used in combination with, or may replace, any feature or element of any other embodiment.

[0021] This application includes and contemplates combinations of features and elements known to those skilled in the art. The embodiments, features, and elements disclosed in this application can also be combined with any conventional features or elements to form unique inventive solutions. Any feature or element of any embodiment can also be combined with features or elements from other inventive solutions to form another unique inventive solution. Therefore, it should be understood that any feature shown and / or discussed in this application can be implemented individually or in any suitable combination. Therefore, the embodiments are not limited except by the limitations imposed by the appended claims and their equivalents. Furthermore, various modifications and changes can be made within the scope of the appended claims.

[0022] Furthermore, in describing representative embodiments, the specification may have presented methods and / or processes as a specific sequence of steps. However, the method or process should not be limited to a specific order of steps to the extent that it does not depend on this specific order. As will be understood by those skilled in the art, other sequences of steps are also possible. Therefore, the specific order of steps set forth in the specification should not be construed as a limitation of the claims. Moreover, the claims relating to the method and / or process should not be limited to the steps performed in the order written, and those skilled in the art will readily understand that these orders can be varied and still remain within the spirit and scope of the embodiments of this application.

[0023] To address the problems existing in the prior art, embodiments of this application provide a cloud security application testing method, such as... Figure 1 As shown, the method includes: S101. Based on a pre-trained BERT-based multi-expert dynamic ensemble model, analyze the source code of the cloud application under test to identify potential security vulnerabilities. The BERT-based multi-expert dynamic ensemble model includes multiple task-specific BERT variants, each of which is used to identify different types of security vulnerabilities.

[0024] The BERT-based multi-expert dynamic ensemble model is a model based on a multi-expert ensemble learning architecture.

[0025] For example, a BERT-based multi-expert dynamic ensemble model includes multiple parallel "experts" and a "general referee." Each "expert" is a pre-trained BERT encoder, operating independently and focusing on different types of security vulnerabilities. Each expert analyzes the entire code segment and outputs its own domain's judgment. For instance, an SQL injection expert focuses on whether there is a dangerous data flow from taint sources to database execution functions, and is better at mapping "dangerous SQL concatenation patterns" to specific regions in the union space; an XSS expert focuses on whether there is an unfiltered data flow from user input to webpage output, and is better at mapping "unfiltered user output" to another region; and a privilege bypass expert focuses on whether there are missing authentication checks or flawed permission verification logic in the code. By performing parallel analysis through multiple task-specialized BERT variants, the limitations of a single model are overcome, enabling more comprehensive and robust automated detection of cloud environment configurations and code vulnerabilities.

[0026] The "chief referee" is a trained meta-arbiter, which can be a lightweight neural network, such as a two-layer neural network, used to determine the final security vulnerability data based on the analysis results of various "experts".

[0027] In one possible implementation, the BERT-based multi-expert dynamic ensemble model includes multiple task-specific BERT variants and at least one meta-arbiter.

[0028] Based on a pre-trained BERT-based multi-expert dynamic ensemble model, the source code of the cloud application under test is analyzed, including: performing different types of security vulnerability analysis on the source code of the cloud application under test through BERT variants tailored to each task, and determining the vulnerability analysis results corresponding to various security vulnerabilities; and using a meta-arbitrator, determining the potential security vulnerability data of the source code of the cloud application under test based on the vulnerability analysis results corresponding to various security vulnerabilities.

[0029] For example, each task-specific BERT variant acts as an "expert" with different focuses, taking the source code of the cloud application under test as input and performing parallel and independent analysis, each generating preliminary analysis results with confidence levels. The meta-arbitrator can employ a lightweight neural network, which makes the final vulnerability determination decision by comprehensively analyzing the analysis results of each task-specific BERT variant.

[0030] It should be noted that when performing different types of security vulnerability analysis on the source code of the cloud application under test, the BERT variants for each task can accept not only the code as input, but also variants of the code (such as code attribute graphs). To improve the analysis results, natural language data (comments, vulnerability descriptions, etc.) related to the code can also be used as input. Then, by learning the code (code attribute graph) and natural language, a joint vector representation is obtained, and the vulnerability analysis results are obtained based on the joint vector representation and the classification head.

[0031] This "committee" mechanism not only effectively avoids the biases and blind spots of a single model, but its dynamic adjudication logic also enables it to adapt to new and complex attack methods.

[0032] In one possible implementation, task-specific BERT variants include a BERT encoder and a classification head.

[0033] By using a task-specific BERT variant, security vulnerability analysis is performed on the source code of the cloud application under test, and the vulnerability analysis results are determined. This includes: converting the source code of the cloud application under test into a context vector sequence using the BERT encoder; and obtaining the vulnerability analysis results based on the classification header and the context vector sequence.

[0034] Optionally, the vulnerability analysis results may include at least one of the following: vulnerability type and its corresponding confidence level information.

[0035] For example, the data processing flow of each task-specific BERT variant is shown below: Input: Code sequence and / or natural language sequences .

[0036] Embedding layer: Maps each input token to a vector. ,in A token refers to the smallest semantic unit obtained after lexical analysis of the input sequence.

[0037] Transformer encoder: computes context-aware representations through a multi-layer self-attention mechanism.

[0038] Self-attention mechanism: For an input sequence E, a query matrix is ​​obtained through a linear transformation. Q Key matrix K Value matrix V .

[0039] , in, This represents the dimension of the key vector. This is a scaling factor used to prevent the gradient from vanishing due to an excessively large inner product.

[0040] Output: A sequence of context vectors from the BERT encoder output code. ,in Includes the first i Each token and its context contain semantic information. The context vector sequence of the BERT encoder output code is the joint vector sequence.

[0041] Classification Head: The structure of a classification head is typically a fully connected layer plus a softmax function. The classification head is used to classify the joint vector sequence. The system processes the vulnerability and outputs two types of results: vulnerability category (e.g., whether it is SQL injection) and corresponding confidence score (probability value between 0 and 1).

[0042] It should be noted that when the input also includes additional code attribute graph features (such as control flow graphs), these features can also be concatenated with the joint vector sequence and fed into the classification head as supplementary information.

[0043] BERT-based multi-expert dynamic ensemble models include training BERT variants tailored to each task.

[0044] In one possible implementation, BERT variants specializing in training tasks include: Task Modeling: Vulnerability identification is modeled as a sequence labeling task. That is, each token in the code is labeled (e.g., O (irrelevant), B-SOURCE (taint source), I-SOURCE (inside the taint source), B-SINK (dangerous function), I-SINK (inside the dangerous function)).

[0045] Fine-tuning formula: For the joint vector sequence H output by the BERT encoder, the probability of each token belonging to each label is calculated through the classification head (a fully connected layer and a softmax function), which can be specifically expressed as: , in, Indicates the first i A context vector for each code token; and It consists of a trainable parameter matrix and bias terms; It is a probability distribution, representing the... i The probability that a code token belongs to each tag.

[0046] Loss function: During the fine-tuning phase, the standard cross-entropy loss is used to train the model. in, N It is the total number of tokens in the sequence; C This represents the total number of tag categories; It is an indicator function, if the sample i The true category equals j If it is 1, then it is 1; otherwise, it is 0.

[0047] The following example illustrates the training process of a task-specific BERT variant step by step, specifically demonstrating how this variant learns to associate the data flow from `request.getParameter()` to `Statement.execute()` with SQL injection vulnerabilities: A1. Preparation of training data (fine-tuning stage): Construct a batch of labeled training samples. Each sample is a code snippet, along with a sequence label.

[0048] For example, a Java method with an SQL injection vulnerability: The code snippet is as follows: String userInput = request.getParameter("id"); String sql = "SELECT FROM users WHERE id=" + userInput; Statement stmt = conn.createStatement(); stmt.executeQuery(sql); The corresponding sequence labeling is as follows: each token is labeled with its role. request.getParameter() is labeled as "B-SOURCE" (the source of the taint), userInput is labeled as "I-SOURCE" (a variable on the taint propagation chain), Statement.executeQuery() is labeled as "B-SINK" (a dangerous function), the sql variable is labeled as "I-SINK" (data flowing into the dangerous function), and the remaining tokens are labeled as "O" (irrelevant).

[0049] A2. Input the code into the BERT encoder in the task-specific BERT variant.

[0050] The code snippet above is first tokenized into a sequence of tokens, such as ["String", "userInput", "=", "request", ".", "getParameter", "(", ""id"", ")", ...]. Then, it is mapped to a vector E through an embedding layer, and finally, a context vector sequence H is calculated using the self-attention mechanism of the Transformer encoder. At this point, the vector H of each token has incorporated its contextual information from the entire code snippet.

[0051] A3. The classification head performs sequence labeling tasks.

[0052] The classification head receives a vector sequence H as input and outputs the probability distribution of each token belonging to each label. For example, for the token "getParameter", the classification head may output: B-SOURCE probability 0.85, O probability 0.10, and other label probability 0.05.

[0053] A4. Calculate the loss and backpropagate to update the parameters.

[0054] The cross-entropy loss between the probability distribution output by the classifier head and the true label is calculated using the loss function formula. For the token "getParameter", if the true label is B-SOURCE, but the current model predicts a B-SOURCE probability of only 0.2, the loss value is relatively large. Through backpropagation, the model simultaneously updates the parameters of the BERT encoder and the parameters Wv and bv of the classifier head, so that when encountering a similar pattern in the future, the probability of predicting the B-SOURCE label for "getParameter" is higher.

[0055] A5. Through repeated training with a large number of samples, the model learns the association patterns.

[0056] After training with tens of thousands of positive samples (code containing SQL injection vulnerabilities) and negative samples (secured code after patching), the BERT encoder gradually learned that when a specific data flow pattern occurs—such as "request.getParameter()" followed by string concatenation, and then the string variable is passed to "Statement.executeQuery()"—it should generate a vector representation H at the corresponding token position that supports the correct label output in the sequence labeling classification header. Essentially, the 125 million parameters of the BERT encoder have encoded the sensitive data flow pattern of "taint source → dangerous function".

[0057] In this way, task-specific BERT variants learn to associate specific patterns in the code (such as the data flow from request.getParameter() to Statement.execute()) with security vulnerabilities.

[0058] By fine-tuning the model, targeted security testing can be achieved, improving testing efficiency and the accuracy of test results.

[0059] The meta-arbiter's input consists of vulnerability analysis results (which can be in the form of confidence vectors) from BERT variants tailored to each task. The meta-arbiter's input may also include shallow features of the code generated during the analysis process by these task-specific BERT variants (such as keyword distribution and API call patterns), and the historical accuracy of each task-specific BERT variant. The meta-arbiter dynamically calculates the fusion weights of each task-specific BERT variant in the current judgment based on the input. For example, when a large number of SQL strings are detected, the weight of the SQL-related task-specific BERT variants is automatically increased. Then, based on the weights and the vulnerability analysis results of each task-specific BERT variant, a final judgment is made to obtain the vulnerability information of the cloud application's source code under test. Potential security vulnerability data = Σ(fusion weight a) Vulnerability analysis results of task-specific BERT variant a).

[0060] S102. Based on the identified potential security vulnerability data, generate a target test set, which includes at least one first test case.

[0061] Based on the identified potential security vulnerabilities, generate at least one specific, executable test case.

[0062] By employing the BERT model, which specializes in code security, potential security vulnerabilities (such as SQL injection) are targeted and discovered through analysis of code data flow. This generates targeted test cases, rather than general functional tests, enabling targeted security testing and improving the accuracy of test results.

[0063] S103. Based on the dependency requirements of the source code of the cloud application under test, create the target test environment through TestContainer.

[0064] TestContainer is an open-source library for Java testing (also supporting other JVM languages). It allows you to manage Docker containers directly through code in unit or integration tests, providing realistic, lightweight, and programmable dependency services (such as databases, message queues, caches, web browsers, etc.). TestContainer provides realistic, isolated containerized dependencies (such as PostgreSQL and Redis), and starts multiple containers to simulate a real microservice environment.

[0065] For example, when analyzing code and identifying the need for PostgreSQL, the generated test case code can directly include Java code that uses TestContainer to start a real PostgreSQL container (newPostgreSQLContainer(...)). The test case generation logic is bound to the real environment from the source, thus providing a more realistic testing environment.

[0066] This method dynamically constructs isolated environments containing real dependent services and deeply integrates TestContainer. It dynamically builds containerized environments containing real dependent services (such as MySQL and Redis) for each test, upgrading the test from traditional "simulation verification" to "real verification". This ensures that the test can expose configuration and integration security risks that only appear in the production environment, and improves the accuracy and reliability of the test results.

[0067] Optionally, the created test environment can be destroyed after the test is completed.

[0068] S104. Execute each of the first test cases in the target test set in the target test environment to obtain test results.

[0069] The cloud security application testing method provided in this application includes analyzing the source code of the cloud application under test based on a pre-trained BERT-based multi-expert dynamic ensemble model; generating a target test set based on the analysis results of the source code of the cloud application under test, the target test set including at least one first test case; creating a target test environment through TestContainer based on the dependency requirements of the source code of the cloud application under test; and executing each first test case in the target test set in the target test environment to obtain test results. This method deeply integrates the BERT-based dynamic expert committee mechanism with TestContainer, binding test generation with the real execution environment. The target execution environment for each generated test case is a dynamically constructed, isolated, and real cloud context by TestContainer. Through dynamic combination of contexts, a closed loop of generation and preparation for execution is formed, solving the problem of the separation of the "generation-execution" two-stage test case in the prior art; the BERT-based multi-expert dynamic ensemble model serves as the planning and decision-making center, analyzing the code and planning the test strategy, and TestContainer... As an action and execution tool, it is responsible for taking action (starting a real database, configuring the network) to build a lightweight containerized test environment, dynamically generating minimal dependency images (such as PostgreSQL and Redis), achieving second-level startup and resource isolation, and ensuring environment consistency. Instead of relying on a static library containing knowledge of all cloud services, it relies on the code semantic understanding capabilities of a BERT-based multi-expert dynamic ensemble model to infer potential risks, and on the real environment provided by TestContainer to verify these risks. This makes its testing foundation the code itself and the real behavior at runtime, thus enabling it to cope with unknown configurations and new logical anomalies.

[0070] Furthermore, to further improve testing effectiveness, in one possible implementation, each first test case is executed in the target testing environment to obtain test results, including: S1. Execute each first test case in the target test environment and evaluate the target test set based on the execution information.

[0071] The execution information includes at least one of the following: test execution result data, code coverage data, test environment data, and security threat analysis data.

[0072] For example, test execution result data includes the execution status (pass, fail, skip) of each test case, execution time, exception stack information when it fails, the specific location of the assertion failure, and a comparison between the expected value and the actual value.

[0073] Code coverage data includes statement coverage (the percentage of executed statements out of total statements), branch coverage (the percentage of executed branches out of total branches), and specific line numbers and branch paths of uncovered code. This data can be obtained by integrating coverage tools such as JaCoCo or Clover.

[0074] Test environment data includes container configuration (image version, environment variables, resource limits) during test execution, actual mapped port numbers, network connection status, and container log output.

[0075] The security threat analysis data includes a list of all security vulnerabilities discovered in this test. Each vulnerability includes the vulnerability type (such as SQL injection), the code location (file path and line number), the confidence score, and whether it was successfully triggered by dynamic scanning.

[0076] Optionally, evaluate the test set based on execution performance, including: The following expression is used for calculation: , in, , and This represents the preset weighting coefficients used to balance the importance of the three objectives of coverage, security, and redundancy in the adequacy assessment. This corresponds to the coverage weight. In security testing scenarios, coverage is usually used as a basic metric, and a default value of 0.4 is recommended. If the testing goal is to fully cover the code logic, it can be increased. If the focus is more on security vulnerability discovery, the cost can be appropriately reduced. . Corresponding security score weights; in security testing scenarios, The priority is usually the highest, and a default value of 0.5 is recommended; if testing highly security-sensitive systems such as financial or payment systems, The adjustment should be increased; for low-risk modules, the adjustment can be appropriately decreased. . Corresponding redundancy penalty weight; redundancy is used as a penalty item, and the default value is recommended to be 0.1; if the test case repetition rate is found to be too high or the execution time is too long, it can be increased. If there are very few test cases, you can lower the setting. The constraints for the three weights are: + + =1, and all three are greater than or equal to 0.

[0077] This represents the overall code coverage of the test set, calculated as a weighted average of statement coverage and branch coverage based on the sum of coverage data from all test cases. The security threat coverage score is calculated based on dynamic scan results, which count the types and number of vulnerabilities that have been successfully triggered. It represents test redundancy by calculating the similarity between test cases based on the embedding vectors of the test case code and penalizing duplicate and redundant test cases; This represents the test set. , Indicates the first i Each test case has [number] test cases. It not only includes the code content, but also the execution result data of the use case, including whether it passed, which lines of code were covered, and whether a specific vulnerability was triggered.

[0078] , Indicates the first i Code vector representation of each test case n This indicates the number of test cases in the test set. Indicates the first j The code vector representation of each test case.

[0079] S2. Determine whether the evaluation result of the target test set is less than the first preset threshold.

[0080] The first preset threshold can be set according to the actual situation. For example, assuming the first preset threshold is θ, the default value of θ can be set to 0.75. For systems with high security requirements, it can also be set to 0.85 or higher; for rapidly iterating development environments, it can also be set to 0.60.

[0081] S3. If the evaluation result of the target test set is less than the first preset threshold, then based on the test execution result data, a supplementary test case is generated and added to the target test set as a new first test case, and step S1 is executed again.

[0082] Test execution results data can be obtained from logs, coverage reports, security vulnerability reports, etc. generated during the test execution process.

[0083] In one possible implementation, the test execution result data includes at least one of the following: uncovered code blocks, discovered crash information, and untested vulnerability data streams; Based on the execution information, generate supplementary test cases, including: Based on the following expression, construct supplementary test case prompts according to the test execution result data. , in, This represents the basic directive used to generate test cases, and GapContext represents the test execution result data. This indicates a prompt message to supplement the test cases; Generate supplementary test cases based on the prompts provided.

[0084] For example, GapContext includes context information extracted from the previous round of feedback. For instance, it may be necessary to cover lines 45-50 of the auth.py file for permission checks (corresponding to the uncovered code block); reproduce and verify whether the service throws an IllegalArgumentException when null input is received (corresponding to the discovered crash information); and test whether SQL injection exists in the data stream from 'userInput' to 'sql.execute()' (corresponding to the untested vulnerable data stream).

[0085] By using GapContext as additional information, the model's generation capabilities can be effectively guided and focused on identified test gaps, thereby enabling intelligent and targeted iterative generation of test cases.

[0086] S4. If the evaluation result of the target test set is greater than or equal to the first preset threshold, the final test result is obtained based on the execution information.

[0087] For example, when F(S) ≥ θ, the test is considered sufficient and the iteration stops; when F(S) < θ, a new round of test generation is triggered.

[0088] It should be noted that, , , Neither θ nor θ is fixed. The system can support different configuration files, such as those used in "security priority mode". =0.3、 =0.6、 =0.1, θ=0.8; Used in "Overlay Priority Mode" =0.6、 =0.2、 =0.2, θ=0.7. Users can also customize these parameters according to specific project requirements.

[0089] This method enables a fully automated loop of "analysis-generation-real-environment execution-feedback-iteration," allowing for self-optimization based on test results and proactively initiating new rounds of targeted testing, rather than generating test cases all at once. Through iterative optimization, the quality of test cases is improved, enhancing the accuracy of test results. By deeply integrating a BERT-based multi-expert dynamic integration model, TestContainer, and autonomous iteration, end-to-end automated testing of cloud security applications, from "intelligent generation" to "real-world verification," is achieved. This method allows the construction of a cloud security application testing intelligence agent capable of autonomous execution, awareness, and iteration, forming a closed-loop intelligent testing ecosystem. It evolves from a "static tool" to a "self-evolving expert system," achieving truly intelligent testing, significantly improving test coverage and efficiency, and effectively addressing the shortcomings of existing technologies (such as RAG-based systems) in test realism, environmental adaptability, and vulnerability discovery depth.

[0090] Figure 2 This application provides an embodiment of a cloud security application testing device, as shown in the following schematic diagram. Figure 2 As shown, the cloud security application testing device includes a code analysis and test case generation module 21, a dynamic test environment management module 22, and a test execution module 23.

[0091] The code analysis and test case generation module 21 includes a code analysis unit 211 and a test case generation unit 212; the code analysis unit 212 is equipped with a pre-trained BERT-based multi-expert dynamic ensemble model.

[0092] Code analysis unit 212 is used to analyze the source code of the cloud application under test based on a pre-trained BERT-based multi-expert dynamic ensemble model.

[0093] The BERT-based multi-expert dynamic integration model includes multiple task-specific BERT variants, each used to identify different types of security vulnerabilities.

[0094] The test case generation unit 212 is used to generate a target test set based on the analysis results of the source code of the cloud application under test. The target test set includes at least one first test case.

[0095] The dynamic test environment management module 22 is used to create a target test environment through TestContainer based on the dependency requirements of the source code of the cloud application under test.

[0096] Test execution module 23 is used to control the execution of each first test case in the target test environment to obtain test results.

[0097] In one possible implementation, such as Figure 2As shown, the device also includes a feedback collection module 24 and a central control and iterative optimization module 25.

[0098] The feedback collection module 24 is used to collect the execution information corresponding to each test set and feed the execution information back to the central control and iterative optimization module. The execution information includes at least one of the following: test execution result data, code coverage data, test environment data, and security threat analysis data.

[0099] The central control and iterative optimization module 25 is used to evaluate the target test set based on the execution information; determine whether the evaluation result of the target test set is less than the first preset threshold; when it is determined that the evaluation result of the target test set is less than the first preset threshold, generate supplementary test cases based on the test execution result data, and add the supplementary test cases as new first test cases to the target test set to obtain a new target test set; The test execution module 23 is also used to control the execution of each first test case in the new target test case in the target test environment to obtain test results.

[0100] Optionally, the feedback collection module 24 includes a code scanner and a data collector.

[0101] Code scanners, as a supplement to test execution, perform dynamic scanning during test runtime.

[0102] The data collector gathers various result data from the test execution.

[0103] In one possible implementation, the pre-trained BERT-based multi-expert dynamic ensemble model also includes at least one meta-arbitrator; The code analysis unit 212 is used to perform different types of vulnerability analysis on the source code of the cloud application under test through BERT variants tailored to each task, determine the shallow features of the source code of the cloud application under test and the vulnerability analysis results corresponding to various vulnerabilities; and through the meta-arbitrator, determine the vulnerability information of the source code of the cloud application under test based on the shallow features of the source code of the cloud application under test and the corresponding vulnerability analysis results.

[0104] Optionally, the central control and iterative optimization module 25 is also used to send messages to the code analysis unit 212.

[0105] The code analysis unit 211 is specifically used to respond to messages sent by the central control and iterative optimization module 25 and analyze the source code of the cloud application under test based on a pre-trained BERT-based multi-expert dynamic ensemble model.

[0106] Optionally, the central control and iterative optimization module 25 is also used to send messages to the dynamic test environment management module 22.

[0107] The dynamic test environment management module 22 is specifically used to respond to messages sent by the central control and iterative optimization module 25 and create the target test environment through TestContainer based on the dependency requirements of the source code of the cloud application under test.

[0108] This application also provides an electronic device, including a processor and a computer-readable storage medium, wherein the computer-readable storage medium stores instructions that, when executed by the processor, implement any of the methods provided in the above method embodiments.

[0109] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements any of the methods provided in the above-described method embodiments.

[0110] It will be understood by those skilled in the art that all or some of the steps, systems, or apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all components may be implemented as software executed by a processor, such as a digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software may be distributed on a computer-readable medium, which may include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term "computer storage medium" includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.

[0111] Furthermore, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined with "first," "second," etc., may explicitly or implicitly include at least one of those features.

[0112] In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise expressly and specifically limited.

[0113] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0114] Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of this application.

Claims

1. A cloud security application testing method, characterized in that, include: Based on a pre-trained BERT-based multi-expert dynamic ensemble model, the source code of the cloud application under test is analyzed to identify potential security vulnerabilities. The BERT-based multi-expert dynamic ensemble model includes multiple task-specific BERT variants, each of which is used to identify different types of security vulnerabilities. Based on the potential security vulnerability data, a target test set is generated, the target test set including at least one first test case; Based on the dependency requirements of the source code of the cloud application under test, a target test environment is created using TestContainer; Each of the first test cases in the target test set is executed in the target test environment to obtain test results.

2. The method according to claim 1, characterized in that, The BERT-based multi-expert dynamic ensemble model also includes at least one meta-arbiter; The method uses a pre-trained BERT-based multi-expert dynamic ensemble model to analyze the source code of the cloud application under test to identify potential security vulnerabilities, including: By using different types of BERT variants tailored to each task, the source code of the cloud application under test is analyzed for different types of security vulnerabilities, and the vulnerability analysis results corresponding to various security vulnerabilities are determined. The meta-arbiter determines the potential security vulnerability data of the source code of the cloud application under test based on the vulnerability analysis results corresponding to various security vulnerabilities.

3. The method according to claim 1 or 2, characterized in that, The task-specific BERT variants include a BERT encoder and a classification head; Using the task-specific BERT variant, security vulnerability analysis is performed on the source code of the cloud application under test to determine the vulnerability analysis results, including: The BERT encoder converts the source code of the cloud application under test into a sequence of context vectors. Based on the classification header, vulnerability analysis results are obtained according to the context vector sequence.

4. The method according to claim 1 or 2, characterized in that, The step of executing each of the first test cases in the target test environment to obtain test results includes: S1, execute each of the first test cases in the target test environment, and evaluate the target test set based on the execution information, wherein the execution information includes at least one of the following: test execution result data, code coverage data, test environment data, and security threat analysis data; S2, determine whether the evaluation result of the target test set is less than a first preset threshold; S3, if the evaluation result of the target test set is less than the first preset threshold, then based on the test execution result data, a supplementary test case is generated, and the supplementary test case is added to the target test set as a new first test case, and step S1 is executed again; S4. If the evaluation result of the target test set is greater than or equal to the first preset threshold, the final test result is obtained based on the execution information.

5. The method according to claim 4, characterized in that, The evaluation of the test set based on execution includes: The following expression is used for calculation: , in, , and This indicates the preset weighting coefficients; This represents the overall code coverage of the test set; This indicates the security threat coverage score; Indicates test redundancy; Represents the test set; , Represents test cases i The code vector representation, n This indicates the number of test cases in the test set. Represents test cases j The code vector representation.

6. The method according to claim 5, characterized in that, The test execution result data includes at least one of the following: uncovered code blocks, discovered crash information, and untested vulnerability data streams; The step of generating supplementary test cases based on the execution information includes: Based on the following expression, supplementary test case prompts are constructed according to the test execution result data. , in, This represents the basic directive used to generate test cases, and GapContext represents the test execution result data. This indicates a prompt message to supplement the test cases; Based on the prompts provided by the supplementary test cases, supplementary test cases are generated.

7. A cloud security application testing device, characterized in that, The system includes a code analysis and test case generation module, a dynamic test environment management module, and a test execution module. The code analysis and test case generation module comprises a code analysis unit and a test case generation unit. The code analysis unit is equipped with a pre-trained BERT-based multi-expert dynamic ensemble model, which includes multiple task-specific BERT variants. Each task-specific BERT variant is used to identify different types of security vulnerabilities. The code analysis unit is used to analyze the source code of the cloud application under test based on a pre-trained BERT-based multi-expert dynamic ensemble model in order to identify potential security vulnerability data. The test case generation unit is used to generate a target test set based on the potential security vulnerability data, wherein the target test set includes at least one first test case. The dynamic test environment management module is used to create a target test environment through TestContainer based on the dependency requirements of the source code of the cloud application under test. The test execution module is used to control the execution of each of the first test cases in the target test environment to obtain test results.

8. The apparatus according to claim 7, characterized in that, Also includes: Feedback collection module and central control and iterative optimization module; The feedback collection module is used to collect execution information corresponding to each test set and feed the execution information back to the central control and iterative optimization module. The execution information includes at least one of the following: test execution result data, code coverage data, test environment data, and security threat analysis data. The central control and iterative optimization module is used to evaluate the target test set based on the execution information; Determine whether the evaluation result of the target test set is less than a first preset threshold; When it is determined that the evaluation result of the target test set is less than the first preset threshold, supplementary test cases are generated based on the test execution result data, and the supplementary test cases are added to the target test set as new first test cases to obtain a new target test set; The test execution module is also used to control each of the first test cases in the new target test case to be executed in the target test environment in order to obtain test results.

9. An electronic device, characterized in that, The method includes a processor and a computer-readable storage medium storing instructions that, when executed by the processor, implement the method as described in any one of claims 1-6.

10. 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 as described in any one of claims 1-6.

Citation Information

Patent Citations

  • General containerization test method based on kubernetes

    CN115640221A

  • Test case generation method and system based on large model and retrieval enhancement generation

    CN119537222A

  • Dynamic language test case automatic generation method based on large language model

    CN119576799A