Methods, devices, and electronic equipment for determining test cases
By acquiring test requirement information and industry scenarios to filter candidate test cases, identifying target vulnerabilities and generating multi-format test cases, the problem of generating redundant test cases in existing technologies is solved, improving testing efficiency and adaptability.
Patent Information
- Application Number
- CN202611348551.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-01
- Publication Date
- 2026-11-17
AI Technical Summary
Existing technologies rely on simple feature combinations when generating security test cases, resulting in a large number of redundant test cases that do not match industry testing needs, leading to low testing efficiency.
By acquiring test requirement information, candidate test cases are selected from the full set of test cases based on industry type and test scenario to identify target vulnerabilities and generate target test cases in various formats, including interface access mode and upload verification mode, to ensure the accuracy and adaptability of the test cases.
It enables precise screening of test cases and differentiated configuration of vulnerabilities, eliminates redundant test cases that do not match the scenario, and improves testing efficiency and targeting.
Smart Images

Figure CN123114969A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of security testing technology, and more specifically, to a method, apparatus, and electronic device for determining test cases. Background Technology
[0002] In software security testing, the test case generation techniques used in related technologies rely on simple feature combinations, such as feature enumeration or mechanical combinations, resulting in the generation of a large number of outdated code test cases that are useless in the industry, with serious redundancy. This not only does not match the industry's testing needs, but also leads to low testing efficiency.
[0003] There is currently no effective solution to the above problems. Summary of the Invention
[0004] This application provides a method, apparatus, and electronic device for determining test cases, which at least solves the technical problem that related technologies use only simple feature combinations to generate a large number of redundant test cases that do not match industry testing needs, resulting in low testing efficiency.
[0005] According to one aspect of the embodiments of this application, a method for determining test cases is provided, comprising: obtaining test requirement information, wherein the test requirement information is used to reflect at least the target industry type and test scenario of the software to be tested; determining candidate test cases from a full set of test cases based on the test requirement information; determining target vulnerabilities from vulnerabilities contained in the candidate test cases, wherein the target vulnerabilities are used to verify whether the software to be tested has security defects; and generating target test cases in multiple formats that embed the target vulnerabilities.
[0006] In some embodiments of this application, candidate test cases are determined from the full set of test cases based on test requirement information, including: obtaining the test case feature vector corresponding to each test case in the full set of test cases, wherein the test case feature vector is used to characterize at least the industry technology stack status and vulnerability type of the test case; determining the matching degree between each test case and the software to be tested based on the test case feature vector; and determining the test cases with a matching degree greater than or equal to a preset matching degree as candidate test cases.
[0007] In some embodiments of this application, determining the matching degree between each test case and the software under test based on the test case feature vector includes: determining the industry adaptability coefficient between each test case and the target industry type based on the test case feature vector, wherein the industry adaptability coefficient is used to quantify the usage rate of the test case's technology stack in the target industry type, and the frequency of occurrence of the vulnerability type in the target industry type; determining the test case weight corresponding to each test case; obtaining the preset scenario coefficient corresponding to the test scenario; and determining the matching degree corresponding to each test case based on the industry adaptability coefficient, the test case weight, and the preset scenario coefficient.
[0008] In some embodiments of this application, determining a target vulnerability from vulnerabilities contained in candidate test cases includes: obtaining vulnerability feature vectors corresponding to vulnerabilities contained in candidate test cases; determining the similarity between the input feature vector corresponding to the test requirement information and the vulnerability feature vector, and identifying vulnerabilities with a similarity greater than or equal to a preset similarity as candidate vulnerabilities; obtaining the file format and verification mode corresponding to the software to be tested; and generating a target vulnerability corresponding to each combination of file format and verification mode based on the candidate vulnerabilities.
[0009] In some embodiments of this application, the number of vulnerabilities allocated is determined by: determining the format adaptation coefficient corresponding to the file format in the combination; determining the verification mode coefficient corresponding to the verification mode in the combination; and determining the number of vulnerabilities allocated to the combination based on the format adaptation coefficient and the verification mode coefficient, based on a preset basic number of vulnerabilities.
[0010] In some embodiments of this application, generating target test cases in multiple formats that embed target vulnerabilities includes: generating vulnerability files based on the target vulnerabilities; and structurally encapsulating the vulnerability files according to verification modes to obtain target test cases. The verification modes include at least one of the following: an interface access mode and an upload verification mode. The interface access mode is used to construct a first target test case with an embedded network service monitoring component. After startup, the first target test case triggers the target vulnerability by responding to external network requests. The upload verification mode is used to construct a second target test case that is independent and has no external runtime environment dependency. The second target test case is uploaded to a vulnerability detection platform for automated scanning and analysis of the target vulnerability.
[0011] In some embodiments of this application, the method further includes: determining the generation parameters, compilation parameters, and running parameters corresponding to the target test case, and establishing ternary dynamic constraint equations corresponding to the generation parameters, compilation parameters, and running parameters; performing pre-compilation verification on the target test case based on the ternary dynamic constraint equations to obtain error values; and optimizing the generation parameters and compilation parameters and re-performing the pre-compilation verification if the error value is not zero, iterating until the error value is zero to obtain an executable target test case.
[0012] According to another aspect of the embodiments of this application, a test case determination apparatus is also provided, comprising: an acquisition module for acquiring test requirement information, wherein the test requirement information is used to reflect at least the target industry type and test scenario of the software under test; a screening module for determining candidate test cases from a full set of test cases based on the test requirement information; a determination module for determining a target vulnerability from the vulnerabilities contained in the candidate test cases, wherein the target vulnerability is used to verify whether the software under test has a security flaw; and a generation module for generating target test cases in multiple formats that embed the target vulnerability.
[0013] According to another aspect of the embodiments of this application, an electronic device is also provided, including: a memory and a processor, wherein the memory is used to store program instructions; the processor is connected to the memory and is used to execute the method for determining the above-described test cases.
[0014] According to another aspect of the embodiments of this application, a non-volatile storage medium is also provided, the non-volatile storage medium including a stored computer program, wherein the device where the non-volatile storage medium is located executes the above-described method for determining test cases by running the computer program.
[0015] According to another aspect of the embodiments of this application, a computer program product is also provided, including computer instructions that, when executed by a processor, implement the method for determining the above-described test cases.
[0016] In this embodiment, a method based on demand scenario adaptation screening and vulnerability-oriented mapping is adopted. By parsing test requirements to obtain target industry types and test scenarios, candidate test cases matching the current scenario are selected from the full set of test cases according to scenario adaptation rules. From these, target vulnerabilities for verifying security flaws are identified, and corresponding vulnerability configurations are dynamically allocated according to the target format to generate multi-format target test cases. This achieves the goals of accurate test case screening, differentiated vulnerability configuration, and multi-format file generation. As a result, redundant test cases that do not match the scenario are eliminated, and the relevance and adaptability of test cases are improved. This solves the technical problem that related technologies only use simple feature combinations when generating security test cases, resulting in a large number of redundant test cases that do not match industry test requirements, leading to low testing efficiency. Attached Figure Description
[0017] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0018] Figure 1 This is a hardware structure block diagram of a computer terminal for a method of determining test cases according to an embodiment of this application;
[0019] Figure 2 This is a flowchart of a method for determining test cases according to an embodiment of this application;
[0020] Figure 3 This is a schematic diagram illustrating the test case hierarchy of a test case determination method according to an embodiment of this application;
[0021] Figure 4 This is a schematic diagram illustrating the industry adaptation of a test case determination method according to an embodiment of this application;
[0022] Figure 5 This is a flowchart illustrating the target test case generation process of a test case determination method according to an embodiment of this application.
[0023] Figure 6 This is a schematic diagram of a test case determination device according to an embodiment of this application. Detailed Implementation
[0024] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0025] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0026] In software security testing, related technologies suffer from several major problems, including a lack of test case selection logic, poor industry adaptability, and severe redundancy caused by indiscriminate output of test scenarios. On the one hand, these technologies are essentially feature enumeration and mechanical combination, lacking similarity screening mechanisms and industry-specific core data support. They cannot accurately remove outdated code test cases from a million-level full test case library based on the target industry's technology stack preferences and security requirements, resulting in a large number of redundant test cases that do not match industry testing needs. On the other hand, these technologies lack screening mechanisms for lightweight testing scenarios such as main function regression testing, making it impossible to select core test cases as needed. This leads to the indiscriminate output of all test cases, resulting in severe consumption of storage and execution resources and poor test targeting.
[0027] Furthermore, the related technologies also face problems such as a disconnect between generation and compilation, heavy environmental dependencies, and insufficient realism of test cases: there is no data linkage between test case generation and compilation, and a lack of end-to-end constraint optimization, which means that the generated files cannot be guaranteed to run directly. Testers need to manually adjust the code and configure a local multilingual compilation environment, resulting in high barriers to entry, poor compatibility, and long environment preparation time. In addition, the related technologies only disclose the functional effects without disclosing the specific execution logic, and all format files generate the same set of vulnerabilities without differentiating them according to file format and verification mode, resulting in test cases that do not match real-world scenarios and lack realism.
[0028] To address the aforementioned technical problems, this application provides corresponding solutions, which are detailed below.
[0029] The method for determining test cases provided in this application can be executed on a mobile terminal, computer terminal, or similar computing device. Figure 1 A hardware block diagram of a computer terminal for implementing a method for determining test cases is shown. Figure 1 As shown, the computer terminal 10 may include a processor 102, a memory 104 for storing data, and a transmission module 106 for communication functions. The processor 102 may include one or more processors. For ease of explanation, Figure 1 The illustration uses multiple processors, including a first processor 102a, a second processor 102b, ..., an nth processor 102n. Processor 102 may include, but is not limited to, processing devices such as microcontroller units (MCUs) or field-programmable gate arrays (FPGAs). In addition, it may include: a display, a keyboard, a cursor control device, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, and a BUS bus. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0030] It should be noted that the aforementioned one or more processors and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 10. As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).
[0031] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the test case determination method in the embodiments of this application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby implementing the aforementioned test case determination method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0032] The transmission module 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission module 106 includes a network interface controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission module 106 may be a radio frequency (RF) module, used for data interaction with external networks or devices via wired and / or wireless network connections.
[0033] The display can be, for example, a touchscreen liquid crystal display (LCD), which allows the user to interact with the user interface of the computer terminal 10. Furthermore, the computer terminal 10 can be connected to a cursor control device and a keyboard via an input / output interface. The cursor control device (e.g., a mouse, trackball, or touchpad) is primarily used to transmit directional information and command selections to the terminal and control the movement of the cursor on the display; the keyboard is primarily used to receive letters, numbers, and other control commands input by the user, thereby enabling interaction between the user and the computer terminal 10.
[0034] It should be noted here that, in some optional embodiments, the above... Figure 1 The computer terminal shown may include hardware elements (including circuitry), software elements (including computer code stored on a computer-readable medium), or a combination of both hardware and software elements. It should be noted that... Figure 1 This is only one instance of a specific particular instance, and is intended to illustrate the types of components that may exist in the aforementioned computer terminal.
[0035] In the above operating environment, this application provides an embodiment of a method for determining test cases. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0036] Figure 2 This is a flowchart of a method for determining test cases according to an embodiment of this application, such as... Figure 2 As shown, the method includes the following steps:
[0037] Step S202: Obtain test requirement information, wherein the test requirement information is at least used to reflect the target industry type and test scenario of the software to be tested.
[0038] In step S202 above, the test requirement information refers to the set of input data used to describe the characteristics of the security test task of the software to be tested, including but not limited to the target industry type, test scenario, interface type and technology stack information. The target industry type is used to limit the industry background to which the test cases are applicable (such as finance, Internet, education, etc.), thereby determining the technology stack preference and vulnerability distribution characteristics. The test scenario is used to limit the scope and depth of the test (such as full test or main function regression test), thereby determining the granularity and quantity of test cases.
[0039] In some embodiments of this application, the system supports two input modes: an automatic mode, which parses unstructured requirement documents (such as Word, TXT, or XMind mind maps) provided by the user and uses natural language processing technology to extract implicit business modules, interface types, and technology stack information to construct an automatic input feature vector; and a manual mode, where testers directly and explicitly select the target programming language, target framework, and target vulnerability type as customized parameters on the interactive interface. Furthermore, the system can also provide a graphical interface for users to select target industry tags (such as "finance") and test scenario types (such as "main function regression" or "full-scale testing"), and uniformly encapsulate the structured data obtained from the above parsing or selection into test requirement information, serving as the input source for subsequent algorithm modules.
[0040] Step S204: Based on the test requirement information, candidate test cases are determined from the full set of test cases.
[0041] In step S204 above, the full set of test cases are extracted from a pre-built comprehensive database containing a large number of security test scripts, vulnerability exploitation code and corresponding execution environments. Candidate test cases refer to a subset of test cases retained from the full set of test cases that meet the technical stack preferences and test scenario requirements of a specific target industry. In other words, candidate test cases are test cases that are adapted to the target industry type and test scenario.
[0042] In some embodiments of this application, the system retrieves an industry tag library, technology lifecycle data, and technology stack usage data corresponding to the target industry type. The industry tag library identifies the mainstream technology stack and frequently encountered vulnerability types in the industry; the technology lifecycle data indicates the status of various frameworks and plugins (mainstream, marginal, or obsolete); and the usage data statistically analyzes the actual prevalence of specific technologies in the target industry. Furthermore, the system scores test cases based on the above information and, according to a preset threshold, retains test cases with scores higher than the threshold and automatically removes test cases marked as "outdated and useless" (such as test cases using obsolete JDK versions or unpopular frameworks), ultimately forming a candidate test case set highly adapted to the target industry type and testing scenario.
[0043] To accurately select candidate test cases that are highly relevant to the target industry and testing scenario, candidate test cases can be determined from the full set of test cases in the following way: obtain the test case feature vector corresponding to each test case in the full set of test cases, wherein the test case feature vector is used to at least characterize the industry technology stack status and vulnerability type of the test case; determine the matching degree between each test case and the software under test based on the test case feature vector; and determine the test cases with a matching degree greater than or equal to the preset matching degree as candidate test cases.
[0044] It should be noted that the test case feature vector refers to the vector representation formed by mapping the multidimensional attributes of a test case (such as industry, technology stack status, vulnerability type, risk level, code complexity, etc.) to a high-dimensional numerical space. Matching degree is used to quantify the degree of association between a test case and the target industry type and test scenario. In other words, it refers to a numerical metric calculated using a specific algorithm (such as cosine similarity, Euclidean distance, or a weighted scoring model) to quantify the degree of association between a single test case and the current test requirements (including the target industry type and test scenario).
[0045] Specifically, the system extracts the test case feature vector of each test case from the full test case library. This vector includes dimensions such as technology stack utilization, vulnerability type frequency, and test case availability level (S / A / B / C level). It also retrieves industry tag library and technology lifecycle data corresponding to the target industry type to determine the mainstream technology stack and high-frequency vulnerability types of the target industry.
[0046] Furthermore, the matching degree between each test case and the software under test can be determined in the following ways: Based on the test case feature vector, determine the industry fit coefficient between each test case and the target industry type. The industry fit coefficient is used to quantify the usage rate of the test case's technology stack in the target industry type, and the frequency of occurrence of the vulnerability type in the target industry type; determine the test case weight corresponding to each test case; obtain the preset scenario coefficient corresponding to the test scenario; and determine the matching degree corresponding to each test case based on the industry fit coefficient, test case weight, and preset scenario coefficient.
[0047] It should be noted that the industry fit coefficient refers to a numerical indicator reflecting the degree of fit between a test case and a specific industry background. This is derived by quantitatively analyzing the actual usage rate of the technology stack upon which the test case relies in the target industry, as well as the historical occurrence frequency of the vulnerability types involved in the test case within the target industry. The test case weight is used to quantitatively represent the technical effectiveness level of the test case, that is, the quantitative value assigned based on the technical effectiveness level of the test case (e.g., S-level core usability, A-level general usability, B-level marginal usability, C-level outdated and useless). The preset scenario coefficient is used to quantitatively represent the degree of demand for the test case in the test task, that is, the parameter set according to the type of test task currently being executed (e.g., full security testing or main function regression testing) to quantify the degree of testing demand.
[0048] Specifically, first, the system retrieves the target industry's tag library from the industry's core data storage module, obtaining the usage rate data of the technology stack used in each test case within that industry, as well as the historical occurrence frequency data of the vulnerability types involved in that test case within that industry. The industry fit coefficient is then calculated through weighted summation. Second, based on a preset test case availability level classification mechanism, the system reads the current test case's level (S, A, B, or C) and assigns it a corresponding fixed weight value (e.g., S level 1.0, A level 0.8, B level 0.3, C level 0). Next, based on the user-selected test scenario (full-scale testing or main function regression), the system retrieves the corresponding preset scenario coefficient from the configuration table (e.g., full-scale testing 1.0, regression 0.3, with C-level test cases directly set to zero in regression scenarios). Finally, the system multiplies these three values or combines them according to a specific formula to obtain the final matching score for each test case, and identifies test cases with scores higher than a preset threshold (e.g., 0.3) as candidate test cases.
[0049] To facilitate understanding of the test case selection process described above, the following explanation will be provided in conjunction with some specific examples.
[0050] Step 1: Build the industry's core data system and use case availability level classification mechanism.
[0051] Construct an industry core database containing the following three types of data:
[0052] (1) Industry tag library: For different industry types, the core technology stack preferences and high-frequency vulnerability types are labeled;
[0053] (2) Technology lifecycle data: Record the lifecycle status of various frameworks and plugins, and clearly distinguish between mainstream availability, edge support and obsolete status;
[0054] (3) Industry usage data: Statistics and storage of actual usage data of each technology stack and vulnerability type in the target industry.
[0055] Figure 3 This is a schematic diagram illustrating the test case hierarchy of a test case determination method according to an embodiment of this application, as shown below. Figure 3 As shown, the availability levels of test cases are categorized into four levels based on the technology stack status, vulnerability frequency, and business relevance:
[0056] S-level (core available) 302: Defined as a use case that simultaneously meets the mainstream industry technology stack, high-frequency vulnerability types, and is related to the main function;
[0057] Level A (Regularly Available) 304: Defined as a use case that uses a common industry technology stack and involves medium to high frequency vulnerability types;
[0058] Category B (Edge Availability) 306: Defined as a use case that uses a niche industry technology stack and involves low-frequency vulnerability types;
[0059] Level C (Outdated and Useless) 308: Defined as a use case that uses an obsolete technology stack or involves outdated vulnerability types, and will be automatically removed in subsequent processes.
[0060] It should be noted that in the main function regression scenario, only S-level test cases can be retained; in the full-scale testing scenario, S / A / B-level test cases can be retained and C-level test cases can be removed; C-level test cases can be automatically removed and not included in the generation.
[0061] Figure 4 This is a schematic diagram illustrating the industry adaptation of a test case determination method according to an embodiment of this application, as shown below. Figure 4As shown, S-level use cases have 100% core functionality coverage and are suitable for all industries; A-level use cases have >=80% core functionality coverage and are suitable for mainstream industries; B-level use cases have >=60% core functionality coverage and are suitable for specific industries; C-level use cases have <60% core functionality coverage and are suitable for edge scenarios. Different types of use cases can be filtered out in different industries. For example, in the financial scenario, S / A / B level use cases can be filtered out; in the education scenario, A / B / C level use cases can be filtered out; and in the medical scenario, B / C level use cases can be filtered out.
[0062] Step 2: Execute the industry's core data-driven screening algorithm.
[0063] (1) Calculate the industry fit coefficient (Kind): Based on the target industry type, obtain the usage rate of the technology stack involved in the use case and the frequency of the vulnerability type, and calculate the industry fit coefficient according to the formula (the value range is 0 to 1).
[0064] (2) Determine the use case level weight (Wlevel): Based on the use case availability level determined in step one, assign the corresponding use case level weight. For example, the weight of level S is 1.0, the weight of level A is 0.8, the weight of level B is 0.3, and the weight of level C is 0.
[0065] (3) Obtain test scenario coefficient (Kscene): Determine the test scenario coefficient based on the currently selected test scenario type. For example, the full test scenario coefficient is 1.0 and the main function regression test scenario coefficient is 0.3.
[0066] (4) Calculate the screening score (i.e., matching degree, Score): Multiply the industry adaptability coefficient, the test case level weight and the test scenario coefficient to obtain the screening score for each test case.
[0067] That is: Score = Kind Wlevel Kscene.
[0068] Further, execute the filtering rules:
[0069] General rule: Retain test cases with a screening score greater than or equal to a preset threshold (e.g., 0.3);
[0070] Specific scenario rule: If the test scenario is a primary function regression, then only S-level test cases will be retained.
[0071] After being filtered according to the above rules, the retained test cases form a set of candidate test cases that are adapted to the target industry type and test scenario.
[0072] Step S206: Identify the target vulnerability from the vulnerabilities contained in the candidate test cases, wherein the target vulnerability is used to verify whether the software under test has security flaws.
[0073] In step S206 above, the target vulnerability includes specific security defect types that are highly matched with the current test task, selected after calculating the similarity between the feature vectors of candidate test cases and the requirement feature vectors of the software under test. Its function is to achieve targeted generation of highly correlated vulnerabilities, that is, instead of randomly or allocating vulnerabilities, it accurately locates those vulnerabilities that occur frequently in the target industry and are most likely to exist under the current technology stack, ensuring that the generated test files can truly and effectively verify whether the software under test has specific security defects.
[0074] To generate highly correlated vulnerabilities, target vulnerabilities can be identified from the vulnerabilities contained in candidate test cases using the following methods: obtaining the vulnerability feature vectors corresponding to the vulnerabilities contained in the candidate test cases; determining the similarity between the input feature vectors corresponding to the test requirement information and the vulnerability feature vectors, and identifying vulnerabilities with similarity greater than or equal to a preset similarity as candidate vulnerabilities; obtaining the file format and verification mode corresponding to the software under test; and generating target vulnerabilities corresponding to each combination of file format and verification mode based on the candidate vulnerabilities.
[0075] It should be noted that vulnerability feature vectors can be used to characterize the technical attributes and security risks of vulnerabilities. In other words, they map the technical attributes of vulnerabilities (such as vulnerability type, risk level, and difficulty of discovery) into vector representations in a multi-dimensional numerical space. Input feature vectors, on the other hand, map test requirement information (such as business modules, interface types, technology stacks, target languages, target frameworks, etc.) into vector representations in a multi-dimensional numerical space.
[0076] The file format determines the vulnerability's encapsulation and compilation logic. It refers to the physical encapsulation form of the generated test file, such as source code files (.java, .py), compiled files (.class, .jar, .exe), or service package files (.war, .zip). This determines the method of embedding the vulnerability code, the logic for referencing dependent libraries, and the compilation and runtime environment requirements of the final file. The verification mode determines the vulnerability's verification logic, referring to the triggering and verification logic of the test case. This includes, but is not limited to, "interface access mode" and "upload verification mode." It determines how the vulnerability is triggered and the expected behavior of the testing platform for that test case. Interface access mode typically generates a file with an embedded HTTP service, triggering the vulnerability via a URL; upload verification mode generates a clean package for the vulnerability detection platform to upload and automatically scan.
[0077] Target vulnerabilities refer to the specific set of vulnerabilities that are ultimately determined for generating test files after being filtered by similarity and differentiated according to file format and verification mode.
[0078] Specifically, the vulnerability feature vector can be, for example, Vvul=[ftype,frisk,fcomplex], where ftype is the vulnerability type, frisk is the risk level, and fcomplex is the difficulty of discovery;
[0079] The input feature vector Vinput (automatic / manual mode unified) can be determined in the following way:
[0080] Automatic mode (requirements document): Vbiz=[fmodule,finterface,ftech], where fmodule is the business module, finterface is the interface type, and ftech is the technology stack;
[0081] Manual mode (custom parameters): Vparam=[flang,fframe,fvul], where flang is the target language, fframe is the target frame, and fvul is the target vulnerability;
[0082] Furthermore, similarity calculation: The matching degree between input features and vulnerability features is calculated using the cosine similarity algorithm: Sim = cosθ = (Vinput) / (Vinput) Vvul) / (∣Vinput∣ |Vvul|).
[0083] Targeted filtering rules: The generation process is triggered only when Sim≥ a preset threshold (e.g., 0.85) to filter out low-association redundant use cases.
[0084] To dynamically adjust the vulnerability set based on file format and verification mode, the target vulnerability corresponding to each combination of file format and verification mode can be generated as follows: determine the vulnerability allocation information corresponding to each combination of file format and verification mode, wherein the vulnerability allocation information includes the number of vulnerability allocations and the vulnerability type; and determine the target vulnerability from the candidate vulnerabilities based on the vulnerability allocation information.
[0085] Specifically, firstly, a vulnerability priority matrix is constructed, defining vulnerabilities of different risk levels (e.g., critical, high, medium, low) and their corresponding weights. Next, the number of vulnerabilities allocated under each file format and verification mode combination is determined. Based on format association rules (e.g., .war packages prioritize web vulnerabilities, .exe packages prioritize local execution vulnerabilities) and verification mode rules (e.g., interface access modes prioritize network vulnerabilities, filtering local vulnerabilities), the system selects eligible vulnerability types from the candidate vulnerability set. Finally, based on the calculated allocation numbers and the selected vulnerability types, the system extracts corresponding vulnerability instances from the candidate vulnerabilities to form a target vulnerability set for subsequent file generation.
[0086] In some embodiments of this application, the number of vulnerabilities allocated is determined by: determining the format adaptation coefficient corresponding to the file format in the combination; determining the verification mode coefficient corresponding to the verification mode in the combination; and determining the number of vulnerabilities allocated to the combination based on the format adaptation coefficient and the verification mode coefficient, based on a preset basic number of vulnerabilities.
[0087] It should be noted that the format compatibility coefficient is used to quantify the compatibility of the file format with the vulnerability, while the verification mode coefficient is used to quantify the range of vulnerabilities that can be triggered by the verification mode.
[0088] Specifically, the vulnerability priority matrix can be defined as Mprio=[PCritical,PHigh,PMedium,PLow], corresponding to weights (1.0, 0.8, 0.5, 0.3); determine the format compatibility coefficient: Kformat, the file format compatibility with the vulnerability (e.g., .war=1.0, .exe=0.8); determine the verification mode coefficient: Kverify, the range of vulnerabilities that can be triggered by the verification mode (upload verification=1.0, interface access=0.6).
[0089] The number of vulnerability allocations can be calculated as follows: N=[Nbase] Kformat Kverify+ΔNprio], where Nbase is the number of base vulnerabilities and ΔNprio is the priority adjustment value.
[0090] It should be noted that ΔNprio is a dynamically adjusted numerical variable used to fine-tune the final number of vulnerabilities based on the base number of vulnerabilities and the weight differences of vulnerabilities at each level in the vulnerability priority matrix. In some embodiments of this application, ΔNprio can be determined as follows: From the candidate vulnerability set after similarity screening, the specific number of vulnerabilities belonging to the four risk levels of Critical, High, Medium, and Low is counted to obtain the candidate vulnerability level distribution; According to the vulnerability priority matrix, the number of vulnerabilities of each level is multiplied by its corresponding weight (Critical 1.0, High 0.8, Medium 0.5, Low 0.3), and all products are added together to obtain the weighted total risk score of the current candidate vulnerability set; The weighted total risk score is compared with a preset base reference value or base number of vulnerabilities, and a numerical correction amount (i.e., ΔNprio) is calculated according to a preset algorithm or mapping rule based on the deviation of the total risk score. For example, if the total risk score is high, a positive correction amount is generated to increase the number of vulnerabilities; if the total risk score is low, a negative or zero correction amount is generated to reduce or maintain the number of vulnerabilities.
[0091] Vulnerability type allocation rules can be set as follows: Interface access mode: prioritize network vulnerabilities and filter local vulnerabilities; Upload verification mode: allocate all types of vulnerabilities.
[0092] For example, format association rules can be set as follows: .war packages are given priority for assigning web vulnerabilities, and .exe packages are given priority for assigning local execution vulnerabilities.
[0093] As an example, (1) Interface access mode: Assign vulnerability set {A,B} (2 network vulnerabilities);
[0094] (2) Upload verification mode (.war package): Assign vulnerability set {A,B,C,D} (4 Web + network type vulnerabilities);
[0095] (3) Upload verification mode (.zip package): Assign vulnerability set {A,B,C,D,E} (5 mixed vulnerabilities);
[0096] (4) Upload verification mode (.exe package): Assign vulnerability set {B,C,D} (3 local + network vulnerabilities).
[0097] Step S208: Generate target test cases in various formats that embed the target vulnerability.
[0098] In step S208 above, the target test case refers to the complete test entity that is finally determined after industry screening, vulnerability mapping and differentiated allocation, and is used to verify a specific security flaw. Its role is to transform the abstract vulnerability logic into specific, executable test files, which directly serve the software security testing process and ensure that testers or automation platforms can directly run these files to verify whether the software has corresponding security vulnerabilities.
[0099] It should be noted that target test cases in various formats correspond to different target vulnerability configurations. The various formats refer to the physical file forms of the target test cases, including but not limited to source code files (such as .java, .py), compiled files (such as .class, .jar, .exe), service package files (such as .war, .zip, .tar.gz), and executable binary files, to adapt to different testing scenarios and platform requirements.
[0100] Target vulnerability configuration refers to information embedded in a specific format test case, such as the number of vulnerabilities, vulnerability types, vulnerability code snippets, triggering logic, dependent library versions, and environment parameters (such as ports and configuration items).
[0101] In some embodiments of this application, target test cases in various formats embedding target vulnerabilities can be generated in the following ways: generating vulnerability files based on the target vulnerabilities; encapsulating the vulnerability files according to a verification mode to obtain target test cases, wherein the verification mode includes at least one of the following: interface access mode and upload verification mode. The interface access mode is used to construct a first target test case with an embedded network service listening component. After the first target test case is started, it triggers the target vulnerability by responding to external network requests. The upload verification mode is used to construct a second target test case that is independent and has no external runtime environment dependency. The second target test case is uploaded to a vulnerability detection platform for automated scanning and analysis of the target vulnerability.
[0102] It should be noted that vulnerability files include at least one of the following file types: source code files, compiled files, service package files, and executable files. That is, they refer to intermediate products containing the target vulnerability logic code or binary data, which transform the abstract target vulnerability into a specific, compileable or executable technical entity. Depending on the file format, vulnerability files may be source code files (such as Java or Python source code, which are easy for manual review and secondary development), compiled files (such as .class or .jar, which are easy to run in a specific JVM environment), service package files (such as .war or .zip, which are easy to deploy to a web container), or executable files (such as .exe or Linux binary files, which are easy to execute directly locally).
[0103] The Interface Access mode is used to build target test cases with embedded network service listening components. Its purpose is to allow the test cases to automatically listen on a specific port after startup and trigger the target vulnerability by responding to external HTTP requests. The first target test case refers to the target test case encapsulated using the Interface Access mode. The Upload Verification mode is used to build independent target test cases without external runtime environment dependencies. Its purpose is to encapsulate the vulnerability file into a clean format that can be directly uploaded to the vulnerability detection platform without complex configuration. The second target test case refers to the target test case encapsulated using the Upload Verification mode.
[0104] Specifically, the system first starts a multi-format vulnerability file generation factory, extracting corresponding source code or binary templates from a pre-built code template library based on the target vulnerability type and file format requirements. For source code files, the system uses a template engine to embed the target vulnerability code snippet into the business logic and automatically adds necessary dependency declarations; for compiled files, the system directly calls pre-compiled binary modules. Subsequently, the system structurally encapsulates the vulnerability file according to the verification mode. In the interface access mode, the system automatically injects a network service listening component (such as embedded Tomcat or Netty server code), configures the listening port and URL mapping relationship, and constructs the first target test case, enabling it to respond to network requests after startup. In the upload verification mode, the system removes unnecessary runtime dependencies, packages the vulnerability file into an independent compressed package or executable package, constructs the second target test case, and ensures that it can be scanned by the platform without external configuration.
[0105] Figure 5 This is a flowchart illustrating the target test case generation process of a test case determination method according to an embodiment of this application, as shown below. Figure 5 As shown, the target vulnerability set 502 is first obtained, and then input into the multi-format file generation factory 504. This factory generates source code file 504a, executable file 504b, and service package file 504c according to the format requirements. Next, the dual-authentication mode construction 506 stage is entered. In the interface access mode 506a, the embedded HTTP service is built and the vulnerability is triggered by the URL, while the upload verification mode 506b builds a clean package to support direct upload platform detection.
[0106] In some embodiments of this application, the following steps may also be performed: determining the generation parameters, compilation parameters, and running parameters corresponding to the target test case, and establishing ternary dynamic constraint equations corresponding to the generation parameters, compilation parameters, and running parameters; performing pre-compilation verification on the target test case based on the ternary dynamic constraint equations to obtain error values; if the error value is not zero, optimizing the generation parameters and compilation parameters and re-performing the pre-compilation verification, iterating until the error value is zero, and obtaining an executable target test case.
[0107] It's important to note that generation parameters refer to the configuration information used during the creation of the target test case code or structure, including code logic, the specific implementation of vulnerability trigger points, version numbers of dependent libraries, and coding style guidelines. Compilation parameters refer to the build configuration required to convert source code into executable files or intermediate bytecode, including the development toolkit version (e.g., JDK version), build tool version (e.g., Maven or Gradle version), build command options, platform architecture (e.g., x86 or ARM), and compiler optimization level. Runtime parameters refer to the external environment configuration required when the target test case starts and executes, including the listening port number, database connection address, configuration file path, environment variables, and runtime dependent service addresses.
[0108] A ternary dynamic constraint equation is a mathematical or logical model used to describe the coupling relationship between generation parameters, compilation parameters, and runtime parameters, and their impact on the usability of the final test cases.
[0109] Specifically, by establishing a ternary dynamic constraint equation, the entire chain of generation, compilation, and execution is linked; F(G,C,R)=α Gparam+β Cparam+γ Rparam-Error, where Gparam are the generated parameters (code logic, vulnerability trigger point, dependency version); Cparam are the compilation parameters (JDK version, Maven version, compilation command); Rparam are the runtime parameters (port, configuration, runtime environment); α, β, γ are weighting coefficients, dynamically optimized based on historical compilation success rate; Error is the compilation / runtime error value, and the constraint is satisfied when Error=0.
[0110] Furthermore, based on the input feature vector, the optimal generation parameters and compilation parameters are derived; pre-compilation verification is performed, and the Error value is calculated; if Error is not 0 (compilation fails), the engine automatically backtracks to optimize Gparam and Cparam; iterative optimization continues until Error = 0, and the final file that can be run directly is output.
[0111] The above steps, by establishing ternary dynamic constraint equations and implementing iterative optimization, solve the problem of the disconnect between generated test cases and the compilation and runtime environment in the existing technology, which requires manual adjustment of configuration. This achieves an automated closed loop in the test case generation process, ensuring that the generated files are 100% directly executable.
[0112] Through steps S202 to S208 above, a method based on demand scenario adaptation screening and vulnerability-oriented mapping is adopted. By parsing test requirements to obtain target industry types and test scenarios, candidate test cases matching the current scenario are selected from the full set of test cases according to scenario adaptation rules. From these, target vulnerabilities for verifying security flaws are identified, and corresponding vulnerability configurations are dynamically allocated according to the target format to generate multi-format target test cases. This achieves the goals of accurate test case screening, differentiated vulnerability configuration, and multi-format file generation. As a result, redundant test cases that do not match the scenario are eliminated, and the relevance and adaptability of test cases are improved. This solves the technical problem that related technologies only use simple feature combinations when generating security test cases, generating a large number of redundant test cases that do not match industry test requirements, resulting in low testing efficiency.
[0113] This application also provides a test case determination system, the system comprising:
[0114] Dual-mode input and scene configuration module: Receives basic input and industry / scene configuration information, and outputs a unified input feature vector Vinput;
[0115] The core data storage module for the industry stores industry tag libraries, technology lifecycle data, and usage rate data, providing support for filtering.
[0116] Industry-adaptive test case filtering module: Based on industry core data-driven filtering algorithms, it filters test cases from the full test case library and eliminates outdated code;
[0117] Vulnerability Feature Vector Mapping Module: Calculates similarity and filters the candidate vulnerability set (Scandidate).
[0118] Vulnerability Differentiation Allocation Module: Dynamically allocates target vulnerability sets (Starget) based on file format and verification mode;
[0119] Multi-format vulnerability file generation factory module: Generates multiple types of vulnerability files based on Starget;
[0120] Dual-verification mode construction module: Constructs dual modes for interface access and upload verification;
[0121] Full-link constraint optimization engine module (core hub): Establishes ternary constraint equations, drives closed-loop optimization throughout the entire process, and ensures that the file can be run directly;
[0122] Cloud-based compilation scheduling module: Built-in multilingual compilation environment, executes compilation based on engine parameters;
[0123] File output and management module: Automatically names, outputs, and stores files, and provides multi-dimensional search functionality;
[0124] Unified Data Bus: Used for standardized data transmission between the engine and various modules.
[0125] It should be noted that all modules are driven by the end-to-end constraint optimization engine and have no independent operating logic. They form a strongly correlated closed loop of "scenario configuration → filtering → mapping → allocation → generation → optimization → output", which solves the problem of technology stacking from the root.
[0126] It should be noted that the above system is used to execute Figure 2 The method for determining the test cases shown is therefore Figure 2 The explanations regarding the method for determining test cases also apply to the above system, and will not be repeated here.
[0127] To facilitate understanding of the implementation of the test case determination method of this application, the following description is provided in conjunction with some specific embodiments.
[0128] (1) Dual-mode input and scene configuration:
[0129] Basic input: Automatically parse the requirements document (supports doc / txt / xmind format) or manually select the three elements of "language + framework + vulnerability".
[0130] Scenario configuration: Select the target industry (finance / internet / education, etc.) and the test scenario (full test / main function regression, etc.).
[0131] (2) Industry-specific filtering of the full test case library:
[0132] Access the industry's core data system to obtain the target industry's technology stack usage rate and vulnerability type frequency.
[0133] Based on industry core data-driven screening algorithms, a screening score is calculated for the full range of use cases (e.g., millions of cases).
[0134] Based on the test scenario threshold, use cases that are usable in the industry (S / A / B level) are retained, while outdated C-level code use cases are removed, forming the industry-adaptive use case set Sind.
[0135] (3) Vulnerability feature vector mapping and targeted screening:
[0136] Extract the feature vector Vvul of the vulnerability from Sind, and calculate the cosine similarity Sim with the input feature vector Vinput; only when Sim≥0.85, start the subsequent process to obtain the candidate vulnerability set Scandidate.
[0137] (4) Differentiated vulnerability allocation:
[0138] Determine the file format to be generated (.java / .exe / .jar / .war / .zip, etc.) and the verification mode (interface access / upload verification); based on the vulnerability differential allocation algorithm, calculate the number of vulnerability allocations N and the type set corresponding to each format / mode; generate the target vulnerability set Starget corresponding to each format / mode.
[0139] (5) Unified generation of vulnerability files in multiple formats:
[0140] Start the multi-format file generation factory, embed vulnerability logic according to Starget, and generate multiple file types:
[0141] Source files: .java, .py, .php; Compiled files: .class, .jar, .exe; Service pack files: .war, .zip, .tar.gz; Executable files: .exe (Windows), binary files (Linux).
[0142] (6) Automatic construction of dual-validation mode:
[0143] Interface access mode: Generates a file with an embedded HTTP interface service, and triggers the Starget vulnerability via URL after startup.
[0144] Upload verification mode: Generates a clean, dependency-free package that can be directly uploaded to a vulnerability detection platform to verify Starget vulnerabilities.
[0145] (7) End-to-end constraint optimization:
[0146] The end-to-end constraint optimization engine establishes a ternary constraint equation F(G,C,R) and derives the optimal parameters; it schedules the corresponding compilation environment in the cloud, loads matching dependency libraries, and performs pre-compilation verification; if Error=0, the engine automatically backtracks to optimize the parameters and iterates until Error=0.
[0147] (8) File output and management:
[0148] Automatically names files according to the format "industry_scenario_language_framework_format_verification mode_timestamp"; batch packages output files and accompanying test case documents (including industry adaptation instructions, test case levels, and vulnerability sets); stores them in a cloud file library, supporting multi-dimensional retrieval and version tracing by feature vector, industry, and scenario.
[0149] The implementation process of this application will be described below with reference to two specific embodiments.
[0150] Specifically, Example 1: Generating Java+Log4j2 RCE vulnerability files in a main function regression scenario in the financial industry.
[0151] (1) Perform dual-mode input and scenario configuration. By manually inputting Java, Log4j2 and RCE elements, the scenario is configured as the financial industry and main function regression test scenario, and only S-level test cases are retained.
[0152] (2) Industry adaptation screening was performed. Based on the full test case library containing 1 million test cases and core data of the financial industry (of which the Java technology stack usage rate was 90%, SpringBoot was 85%, and high-frequency vulnerabilities included data leakage, RCE, and privilege escalation), the screening algorithm was used to calculate that only S-level test cases (i.e. Java combined with mainstream frameworks and high-frequency vulnerabilities) had a score of Score≥0.8. A total of 800 industry-adaptive test cases were screened out. At the same time, outdated code test cases such as Log4j1 and JDK 6 and below were removed. The removal rate of C-level test cases reached 99.2%.
[0153] (3) Perform vector mapping screening, calculate the similarity Sim to be 0.98, and select 3 S-level vulnerabilities containing data leakage and privilege escalation from 800 test cases as a candidate vulnerability set.
[0154] (4) Perform vulnerability differentiation allocation. For .war packages in interface access mode, set the format adaptation coefficient Kformat to 1.0 and the verification mode coefficient Kverify to 0.6, and allocate a set {A,B} containing 2 core vulnerabilities. For .zip packages in upload verification mode, set Kformat to 1.0 and Kverify to 1.0, and allocate a set {A,B,C} containing 3 core vulnerabilities. For .exe packages in upload verification mode, set Kformat to 0.8 and Kverify to 1.0, and allocate a set {B,C} containing 2 local and network vulnerabilities.
[0155] (5) Generate multiple file formats. For the interface access mode, generate a .war package with embedded HTTP service, embed vulnerabilities A and B. After startup, accessing http: / / 127.0.0.1:8080 / trigger can trigger the vulnerability. For the upload verification mode, generate a .java source code file, a .jar executable package, a .zip upload package, and a .exe executable file.
[0156] (6) After the file is generated, the engine performs full-link optimization. The engine automatically infers the compilation parameters (including JDK 8, Maven 3.6, Log4j2 2.14.1 dependencies), schedules the cloud Java compilation environment to perform pre-compilation verification and fix dependency conflicts, and iterates and optimizes until the error value is 0, ensuring that all files can be run directly.
[0157] (7) Perform file output and management, name the files in the format of "finance_main function regression_java_log4j2_war_interface access_20260415103000", batch output files and supporting use case documents (the documents clearly indicate industry adaptation instructions, use case level, and vulnerability set), and store the results in the cloud file library, supporting multi-dimensional retrieval by "finance + Java + Log4j2".
[0158] Specific Implementation Example 2: Generating Python+Django SQL Injection Vulnerability Files for Full-Scale Testing Scenarios in the Internet Industry.
[0159] First, dual-mode input and scenario configuration are performed. The requirements document inputs the internet user login module and the Python + Django technology stack, configuring the scenario as both an internet industry scenario and a full-scale testing scenario, retaining S-level, A-level, and B-level test cases. Next, industry-adaptation filtering is performed, removing C-level test cases such as Python 2.x versions and outdated Django versions from the full test case library, ultimately retaining 1200 industry-usable test cases. Then, vector mapping and differentiated allocation are performed, determining the candidate vulnerability set to include SQL injection (A), XSS (B), file upload (C), and privilege escalation (D) vulnerabilities. For the .zip package in upload verification mode, a set containing 5 vulnerabilities (covering S-level and A-level) is assigned. Afterwards, file generation and optimization are performed, generating .py source code files, .exe executable files, and .zip upload packages in multiple formats, and automatically compiling and optimizing through an engine to ensure all files are directly executable. Finally, file output is performed, batch outputting files and accompanying test case documents, supporting full-scale security testing in the internet industry.
[0160] The technical chain of this application uses a full-link constraint optimization engine as its sole core, with all modules serving as extensions of the engine and having no independent operating logic, thus forming a strongly correlated closed loop. Regarding industry adaptation, filtering is based on core industry data, ensuring that the technology stack and vulnerability types perfectly match the target industry's needs, achieving a high level of accurate adaptation. Simultaneously, by automatically eliminating outdated and useless code test cases, redundant test cases are significantly reduced, noticeably decreasing the number of test cases in main function regression scenarios, effectively improving resource utilization efficiency.
[0161] In terms of security and usability, this application differentiates the allocation of vulnerability sets, making the generated test cases more closely resemble real-world scenarios. This makes it difficult for vulnerability inspection platforms to identify them as manually generated test cases, thus significantly improving the authenticity of the test cases. Furthermore, end-to-end constraint optimization ensures that all file formats require no additional environment configuration or compilation, allowing testers to perform zero-code operations and guaranteeing that the files are 100% directly executable. The system supports various testing scenarios, including full and lightweight testing, and can output multiple file types such as source code, executable files, and service packages. It also adapts to both interface access and upload verification modes, possessing strong multi-scenario and multi-format adaptability.
[0162] In terms of efficiency and cost advantages, the test case generation time has been significantly shortened from a long cycle to a short cycle, resulting in a significant improvement in testing efficiency and a substantial reduction in labor costs. Overall, the system is highly deployable, adaptable to multiple industries and scenarios, meets diverse testing needs, and significantly enhances its commercial value and market competitiveness.
[0163] Figure 6 This is a structural diagram of a test case determination device according to an embodiment of this application, such as... Figure 6 As shown, the device includes:
[0164] The acquisition module 602 is used to acquire test requirement information, wherein the test requirement information is at least used to reflect the target industry type and test scenario of the software to be tested;
[0165] The filtering module 604 is used to determine candidate test cases from the full set of test cases based on test requirement information;
[0166] Module 606 is used to identify target vulnerabilities from the vulnerabilities contained in candidate test cases, wherein the target vulnerabilities are used to verify whether the software under test has security flaws.
[0167] Module 608 is used to generate target test cases in various formats that embed the target vulnerability.
[0168] It should be noted that, Figure 6 The test case determination device shown is used to execute Figure 2 The method for determining the test cases shown is therefore Figure 2 The explanations and instructions regarding the method for determining test cases also apply to... Figure 6 The device for determining the test cases shown will not be described in detail here.
[0169] This application also provides an electronic device, which includes a memory and a processor, wherein the memory is used to store program instructions; the processor is connected to the memory and is used to execute the steps of determining the test cases in the various embodiments of this application.
[0170] This application also provides a non-volatile storage medium including a stored computer program, wherein the device containing the non-volatile storage medium executes the steps of the test case determination method in various embodiments of this application by running the computer program.
[0171] This application also provides a computer program product, including computer instructions that, when executed by a processor, implement the steps of the test case determination method in various embodiments of this application.
[0172] This application also provides a computer program that, when executed by a processor, implements the steps of the test case determination method in various embodiments of this application.
[0173] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0174] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0175] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0176] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0177] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0178] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0179] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for determining test cases, characterized in that, include: Obtain test requirement information, wherein the test requirement information is at least used to reflect the target industry type and test scenario of the software to be tested; Candidate test cases are determined from the full set of test cases based on the aforementioned test requirements information; The target vulnerability is determined from the vulnerabilities contained in the candidate test cases, wherein the target vulnerability is used to verify whether the software under test has a security flaw; Generate target test cases in various formats that embed the target vulnerability.
2. The method according to claim 1, characterized in that, Based on the aforementioned test requirements information, candidate test cases are determined from the full set of test cases, including: Obtain the test case feature vector corresponding to each test case in the full set of test cases, wherein the test case feature vector is used to characterize at least the industry technology stack status and vulnerability type of the test case; The matching degree between each test case and the software under test is determined based on the test case feature vector. Test cases with a matching degree greater than or equal to a preset matching degree are identified as candidate test cases.
3. The method according to claim 2, characterized in that, Determining the matching degree between each test case and the software under test based on the test case feature vector includes: Based on the use case feature vector, an industry fit coefficient is determined for each test case and the target industry type. The industry fit coefficient is used to quantify the usage rate of the technology stack of the test case in the target industry type and the frequency of occurrence of the vulnerability type in the target industry type. Determine the test case weight corresponding to each of the test cases; Obtain the preset scenario coefficients corresponding to the test scenario; The matching degree of each test case is determined based on the industry adaptability coefficient, the test case weight, and the preset scenario coefficient.
4. The method according to claim 1, characterized in that, Identifying the target vulnerability from the vulnerabilities contained in the candidate test cases includes: Obtain the vulnerability feature vectors corresponding to the vulnerabilities contained in the candidate test cases; Determine the similarity between the input feature vector corresponding to the test requirement information and the vulnerability feature vector, and identify vulnerabilities whose similarity is greater than or equal to a preset similarity as candidate vulnerabilities; Obtain the file format and verification mode corresponding to the software to be tested; Based on the candidate vulnerabilities, a target vulnerability is generated corresponding to each combination of the file format and the verification mode.
5. The method according to claim 4, characterized in that, The number of vulnerability assignments for the target vulnerability is determined in the following way: Determine the format adaptation coefficient corresponding to the file format in the combination; Determine the verification mode coefficient corresponding to the verification mode in the combination; Based on the preset number of basic vulnerabilities, the number of vulnerabilities allocated to the combination is determined according to the format adaptation coefficient and the verification mode coefficient.
6. The method according to claim 1, characterized in that, Generate target test cases in various formats that embed the target vulnerability, including: Generate a vulnerability file based on the target vulnerability; The vulnerability file is structurally encapsulated according to the verification mode to obtain the target test case. The verification mode includes at least one of the following: interface access mode and upload verification mode. The interface access mode is used to construct a first target test case with an embedded network service listening component. After the first target test case is started, it triggers the target vulnerability by responding to external network requests. The upload verification mode is used to construct a second target test case that is independent and has no external runtime environment dependency. The second target test case is uploaded to a vulnerability detection platform to perform automated scanning and analysis of the target vulnerability.
7. The method according to claim 6, characterized in that, The method further includes: Determine the generation parameters, compilation parameters, and runtime parameters corresponding to the target test case, and establish the ternary dynamic constraint equations corresponding to the generation parameters, compilation parameters, and runtime parameters; Based on the ternary dynamic constraint equation, pre-compilation verification is performed on the target test cases to obtain error values; If the error value is not zero, optimize the generation parameters and compilation parameters and re-execute the pre-compilation verification. Iterate until the error value is zero to obtain an executable target test case.
8. A device for determining test cases, characterized in that, include: The acquisition module is used to acquire test requirement information, wherein the test requirement information is at least used to reflect the target industry type and test scenario of the software to be tested; The filtering module is used to determine candidate test cases from the full set of test cases based on the test requirement information; A determination module is used to determine a target vulnerability from the vulnerabilities contained in the candidate test cases, wherein the target vulnerability is used to verify whether the software under test has a security flaw; The generation module is used to generate target test cases in various formats that embed the target vulnerability.
9. An electronic device, characterized in that, include: A memory and a processor, wherein the memory is used to store program instructions; the processor is connected to the memory and is used to execute the method for determining test cases according to any one of claims 1 to 7.
10. A non-volatile storage medium, characterized in that, The non-volatile storage medium includes a stored computer program, wherein the device containing the non-volatile storage medium executes the method for determining test cases according to any one of claims 1 to 7 by running the computer program.
11. A computer program product comprising computer instructions, characterized in that, When the computer instructions are executed by the processor, they implement the method for determining test cases as described in any one of claims 1 to 7.
