Interface code generation method and device, computer equipment and storage medium
By identifying and generating the interface description sent by the user terminal security compliance and generating code, the problem of low interception accuracy of traditional methods of preventing over-authorization vulnerabilities is solved, and high security and compliance of the interface are achieved, reducing security risks.
Patent Information
- Application Number
- CN202411011432.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-26
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2044-07-26
AI Technical Summary
Traditional methods have low interception accuracy when preventing overreach of authority loopholes, high labor costs and low efficiency, and poses security risks.
By obtaining the original requirements interface description sent by the user terminal, calling specification details and regulatory rules for security compliance identification, and generating interface codes for controlling secure access, including noise removal, semantic analysis, structured data model construction, code generation, Static and dynamic code analysis for security.
It significantly improves the security and compliance of the interface, realizes the full process of security control from demand analysis to code generation, reduces security risks, and enhances the overall protection capabilities of the system.
Smart Images

Figure CN118981769A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of security protection technology, and in particular to an interface code generation method, device, computer equipment and storage medium. Background Art
[0002] The Security Development Lifecycle (SDLC) is a set of security engineering methods for Web and APP development, which aims to reduce security vulnerabilities in the R&D process, help developers reduce product security issues, and improve product security quality. Security vulnerabilities may come from design defects or coding errors in application software or operating systems, or from design defects or unreasonable logical processes in the interactive processing of businesses.
[0003] Common security vulnerabilities such as XSS cross-site scripting attacks, CSRF cross-site request forgery, and SQL injection are purely technical vulnerabilities, which can be avoided through unified architecture, unified middleware, unified interceptors, and unified controls. However, unauthorized access security vulnerabilities are business logic vulnerabilities that cannot be solved with unified tools.
[0004] Currently, the industry's prevention of unauthorized access vulnerabilities is mainly through expert identification, design and coding to avoid unauthorized access security vulnerabilities.
[0005] However, the applicant found that the traditional prevention of unauthorized vulnerabilities not only has high manpower costs, but also has low efficiency and is very easy to miss. This shows that the traditional prevention method for unauthorized vulnerabilities still has security risks.
[0006] Application Contents
[0007] The purpose of the embodiments of the present application is to propose an interface code generation method, device, computer equipment and storage medium to solve the problem of low interception accuracy in traditional methods for preventing unauthorized vulnerabilities.
[0008] In order to solve the above technical problems, the embodiment of the present application provides an interface code generation method, which adopts the following technical solution:
[0009] Obtain the original demand interface description sent by the user terminal;
[0010] Calling specification details and regulatory rules, and performing security compliance identification processing on the original requirement interface description according to the specification details and regulatory rules, to obtain a risk requirement interface description that does not comply with the specification details and regulatory rules;
[0011] Acquire new interface data corresponding to the risk requirement interface description;
[0012] Classify the newly added interface data according to the preset security interface category to obtain security interface category information;
[0013] Acquire a security design solution corresponding to the security interface category information according to a preset format;
[0014] An interface code for controlling security access is generated according to the security design solution.
[0015] Furthermore, after the step of obtaining the original demand interface description sent by the user terminal, the following steps are also included:
[0016] Performing noise removal processing on the original demand interface description according to text cleaning technology to obtain a cleaned original demand interface description;
[0017] Performing semantic analysis on the cleaned original demand interface description according to natural language processing technology to obtain preliminary semantic analysis results;
[0018] Matching and mapping the preliminary semantic analysis results according to a preset interface description template to obtain an interface description element list;
[0019] Constructing a structured data model according to the interface description element list;
[0020] The data of each field of the structured data model is converted into JSON format to obtain a standardized original requirement interface description.
[0021] Furthermore, the step of generating an interface code for controlling security access according to the security design solution specifically includes the following steps:
[0022] Parsing the security design scheme according to the code generator to obtain preliminary configuration data;
[0023] Calling a code template library, and acquiring a predefined template corresponding to the preliminary configuration data in the code template library;
[0024] The preliminary configuration data and the predefined template are integrated to obtain the interface code.
[0025] Furthermore, after the step of generating an interface code for controlling security access according to the security design solution, the method further includes the following steps:
[0026] Performing a comprehensive scan on the interface code using a static code analysis tool to obtain a comprehensive scan result;
[0027] If the comprehensive scan result has a security vulnerability, there is no need to modify the interface code;
[0028] If there is a security vulnerability in the comprehensive scan result, the vulnerability location and vulnerability type of the security vulnerability are recorded;
[0029] The automatic repair function corresponding to the vulnerability type is called, and the security vulnerability is corrected according to the automatic repair function to obtain a corrected interface code.
[0030] Furthermore, after the step of generating an interface code for controlling security access according to the security design solution, the method further includes the following steps:
[0031] Monitor the behavior of the interface code when it is running according to a dynamic code analysis tool, and record abnormal behavior and triggering conditions when the interface code is running to obtain abnormal behavior data;
[0032] The effectiveness of the security access control mechanism of the interface code is analyzed according to the abnormal behavior data, and an analysis report is generated.
[0033] In order to solve the above technical problems, the embodiment of the present application also provides an interface code generation device, which adopts the following technical solution:
[0034] The demand acquisition module is used to obtain the original demand interface description sent by the user terminal;
[0035] A security compliance identification and acquisition module is used to call specification details and regulatory rules, and perform security compliance identification processing on the original demand interface description according to the specification details and regulatory rules to obtain a risk demand interface description that does not comply with the specification details and regulatory rules;
[0036] A new interface acquisition module is used to acquire new interface data corresponding to the risk requirement interface description;
[0037] A classification module, used to classify the newly added interface data according to a preset security interface category to obtain security interface category information;
[0038] A solution acquisition module, used to acquire a security design solution corresponding to the security interface category information according to a preset format;
[0039] A code generation module is used to generate an interface code for controlling security access according to the security design solution.
[0040] Furthermore, the device also includes:
[0041] A noise removal module, used for performing noise removal processing on the original demand interface description according to a text cleaning technology to obtain a cleaned original demand interface description;
[0042] A semantic analysis module is used to perform semantic analysis on the cleaned original demand interface description according to natural language processing technology to obtain a preliminary semantic analysis result;
[0043] A matching and mapping module, used to match and map the preliminary semantic analysis results according to a preset interface description template to obtain an interface description element list;
[0044] A model building module, used to build a structured data model according to the interface description element list;
[0045] The format conversion module is used to convert the data of each field of the structured data model into JSON format to obtain a standardized original requirement interface description.
[0046] Furthermore, the code generation module includes:
[0047] A parsing submodule, used for parsing the security design scheme according to the code generator to obtain preliminary configuration data;
[0048] A template acquisition submodule, used for calling a code template library and acquiring a predefined template corresponding to the preliminary configuration data in the code template library;
[0049] The data integration submodule is used to integrate the preliminary configuration data and the predefined template to obtain the interface code.
[0050] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:
[0051] The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the interface code generation method as described above when executing the computer-readable instructions.
[0052] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:
[0053] The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps of the interface code generation method described above are implemented.
[0054] The present application provides an interface code generation method, including: obtaining the original demand interface description sent by the user terminal; calling the specification details and regulatory rules, and performing security compliance identification processing on the original demand interface description according to the specification details and regulatory rules, and obtaining the risk demand interface description that does not comply with the specification details and regulatory rules; obtaining the newly added interface data corresponding to the risk demand interface description; classifying the newly added interface data according to the preset security interface category to obtain security interface category information; obtaining the security design scheme corresponding to the security interface category information according to the preset format; generating an interface code for controlling security access according to the security design scheme. Compared with the prior art, the present application effectively solves the security risk problem in interface design by performing security compliance identification on the original demand and formulating a security design scheme for the risk interface. In addition, the present application realizes the full process security management and control from demand analysis to code generation, significantly improves the security and compliance of the interface, reduces security risks for enterprises, and enhances the overall protection capability of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0056] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0057] Figure 2 This is a flowchart of the implementation of the interface code generation method provided in Example 1 of the present application;
[0058] Figure 3 It is a structural diagram of the interface code generation device provided in the second embodiment of the present application;
[0059] Figure 4 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION
[0060] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0061] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0062] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0063] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0064] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0065] The terminal devices 101, 102, and 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers, desktop computers, etc.
[0066] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .
[0067] It should be noted that the interface code generation method provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the interface code generation device is generally arranged in the server / terminal device.
[0068] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0069] Embodiment 1
[0070] Continue to refer Figure 2 , shows a flow chart of an embodiment of the interface code generation method according to the present application. The interface code generation method comprises: step S201, step S202, step S203, step S204, step S205 and step S206.
[0071] In step S201, the original required interface description sent by the user terminal is obtained.
[0072] In the embodiments of the present application, the user terminal refers to a terminal device used to execute the image processing method for preventing document abuse provided by the present application. The user terminal can be a mobile terminal such as a mobile phone, a smart phone, a laptop computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a navigation device, etc., as well as a fixed terminal such as a digital TV, a desktop computer, etc. It should be understood that the examples of user terminals here are only for the convenience of understanding and are not used to limit the present application.
[0073] In the embodiment of this application, this application applies the big model to SDLC. Although the big model cannot complete all the tasks of SDLC independently, it can enhance the function, improve development safety and improve product quality by splitting tasks, process design, providing feedback and correction. Among them, the specific application process of the big model is as follows:
[0074] (1) Identify security risks in business requirement interface orchestration;
[0075] (2) Perform security identification of interfaces based on business requirements;
[0076] (3) Conduct security design based on security identification content;
[0077] (4) Generate code based on the design content.
[0078] In step S202, the specification details and regulatory rules are called, and the original requirement interface description is subjected to security compliance identification processing according to the specification details and regulatory rules to obtain a risk requirement interface description that does not comply with the specification details and regulatory rules.
[0079] In the embodiments of this application, security risks in business requirements are identified, such as whether they violate internal regulations and regulatory requirements; whether there are security risks at the demand level, etc. This application classifies internal regulations into 25 categories based on data classification and grading, asset security, content security, access authorization, etc.
[0080] In the embodiment of the present application, in order to identify the security risks of business requirements, the present application constructs the following four components of the large model input prompt:
[0081] 1) Instructions: Given a requirement description, analyze the security risks of the business requirement;
[0082] 2) Context: List the different categories of industry regulations and regulatory rules one by one;
[0083] 3) Input data: requirement description and its application information;
[0084] 4) Output prompt: Output the requirements that do not meet security compliance, and output in the format of function point: specific function description - reason for non-compliance: specific regulatory rules; if the requirements do not involve security risks, the output will be empty.
[0085] Input the above-constructed prompt information into the big model to get the result of whether the business demand has designed security risks.
[0086] In step S203, newly added interface data corresponding to the risk requirement interface description is obtained.
[0087] In the embodiment of the present application, in order to obtain the security identification result of the interface, the four components of the large model input prompt are constructed as follows:
[0088] Obtain the required specific interfaces and interface dependencies based on business requirements.
[0089] 1) Instructions: Given a requirement description, analyze the specific interfaces and interface arrangement relationships required by the business requirements;
[0090] 2) Context: List the contents of the four attribute fields of each interface information one by one (interface ID, interface input and output definition, interface function description and dependent interface);
[0091] 3) Input data: requirement description (detailed task objectives), process orchestration configuration (input parameters, output parameters, attributes);
[0092] 4) Output prompt: Output the input and output definitions of the newly added interface according to the interface ID list and arrangement process.
[0093] The above-constructed prompt information is input into the large model to obtain the calling relationship between the interface IDs involved in the requirements.
[0094] In step S204, the newly added interface data is classified according to the preset security interface category to obtain security interface category information.
[0095] In the embodiment of the present application, the security identification content is divided into 7 categories, specifically including: security parameterization SQL, that is, whether there is a new or modified SQL; security sensitive information, that is, whether there is information transmission and storage of personal sensitive data specifications; security input verification, that is, whether there is new or modified user data input; and security access control.
[0096] In the embodiment of the present application, the four components of constructing the large model input prompt are as follows:
[0097] 1) Instructions: Given the functional description and input and output definitions of the newly added interface, analyze and obtain the security identification results.
[0098] 2) Context: List the above 7 types of security identification content one by one;
[0099] 3) Input data: Add functional description and input and output definitions of the new interface;
[0100] 4) Output prompt: Output in the format of interface ID-identified security content. If no security identification content is involved, the output is blank.
[0101] The above-constructed prompt information is input into the large model to obtain the security identification result of the newly added interface.
[0102] In step S205, a security design solution corresponding to the security interface category information is obtained according to a preset format.
[0103] In the embodiment of the present application, in order to obtain the security design logic of the interface, the interfaces involving security identification content are sorted out, and the four components of the large model input prompt are constructed as follows:
[0104] 1) Instructions: Given the functional description and input / output definitions of the new interface and the dependencies with the existing interfaces, analyze and derive a security design solution.
[0105] 2) Context: List the interface information involved in the security identification content and the corresponding security design examples one by one.
[0106] 3) Input data: Add input and output descriptions of new interfaces and restrictions on upstream and downstream interfaces;
[0107] 4) Output prompt: Output the security design plan of the newly added interface in the following format.
[0108] Category: Input validation
[0109] Interface ID: 001
[0110] Field 1 {Chinese name: User password field; English name: user password; Data type: string; Allowed values: letters and numbers, no special characters; Minimum character length 6; Maximum character length 64}
[0111] Category: Access Control
[0112] Interface ID: 001
[0113] {Interface path, interface description, who can access this API, how to ensure that the API can only be accessed by legitimate users}
[0114] The above-constructed prompt information is input into the large model to obtain a security design solution with different security identification contents for a specific interface.
[0115] In step S206, an interface code for controlling security access is generated according to the security design solution.
[0116] In the embodiment of the present application, if there is a security design content that requires input and output verification, in order to avoid XSS cross-site scripting attacks, a unified interceptor can be directly added to the code to solve the problem;
[0117] If security access control is involved, in order to avoid unauthorized access vulnerabilities, the main thing to do is to verify the permissions of the interface.
[0118] The permission verification is divided into three types for encoding: interface permission, user status, and interface operable object filtering.
[0119] The four components of constructing a large model input prompt for secure access control are as follows:
[0120] 1) Instructions: Based on the security design content and interface definition in step 3, use java code to implement access control functions;
[0121] 2) Context: List the corresponding permission verification instructions and examples one by one, such as verifying the status of the user accessing the current interface, verifying whether the current user has the permission for the current interface, verifying whether the current user has the permission for the current operation object, etc.
[0122] 3) Input data: The security design content includes each interface of the access control category and the requirement description:
[0123] 4) Output prompt: Output interface related codes.
[0124] The above-constructed prompt information is input into the large model to obtain the code related to the security access control of the specific interface.
[0125] In some optional implementation methods of the embodiments of the present application, the security design identification content generated above is encapsulated into a plug-in and embedded in the developer platform to assist in the generation of security design content for reference and supplement by developers. Code generation is performed for the supplemented security design content of the access control and input verification categories, and code examples are provided. After the developers supplement the code details, they can proceed to the next step of security audit and testing according to the normal process.
[0126] In the actual application process, it may be difficult for a large model to give the most correct code at once, so it is necessary to constantly prompt and correct it until the same set of process design can be reused in a specific type of business scenario. This application uses ChatGPT as the control group (the data is fictitious test data) during the application process, and uses the open source Chatg L M2 + Langcha in deployed in the bank as the experimental group for process debugging. Considering data security management and actual resource application limitations, Chatg LM2 + Langcha in is not as effective as ChatGPT in response speed and accuracy, but it still has great reference significance for actual implementation, and greatly reduces code logic errors or security vulnerabilities generated by human development and design.
[0127] In an embodiment of the present application, a method for generating interface code is provided, including: obtaining the original demand interface description sent by the user terminal; calling the specification details and regulatory rules, and performing security compliance identification processing on the original demand interface description according to the specification details and regulatory rules, and obtaining a risk demand interface description that does not comply with the specification details and regulatory rules; obtaining the newly added interface data corresponding to the risk demand interface description; classifying the newly added interface data according to the preset security interface category to obtain security interface category information; obtaining the security design scheme corresponding to the security interface category information according to the preset format; generating an interface code for controlling security access according to the security design scheme. Compared with the prior art, the present application effectively solves the problem of potential safety hazards in interface design by performing security compliance identification on the original demand and formulating a security design scheme for the risk interface. In addition, the present application realizes the full process security management and control from demand analysis to code generation, significantly improves the security and compliance of the interface, reduces security risks for enterprises, and enhances the overall protection capabilities of the system.
[0128] In some optional implementations of the embodiments of the present application, after step S201, the following steps are further included:
[0129] The original requirement interface description is subjected to noise removal processing according to the text cleaning technology to obtain the cleaned original requirement interface description;
[0130] Perform semantic analysis on the cleaned original requirement interface description using natural language processing technology to obtain preliminary semantic analysis results;
[0131] Match and map the preliminary semantic analysis results according to the preset interface description template to obtain a list of interface description elements;
[0132] Build a structured data model based on the list of interface description elements;
[0133] Convert each field data of the structured data model into JSON format to obtain a standardized original requirement interface description.
[0134] In an embodiment of the present application, after receiving the original demand interface description sent by the user, the original text data needs to be preprocessed. Specifically, the text cleaning method in NLP (natural language processing) technology is adopted, such as removing stop words, punctuation marks and HTML tags; then, the NLTK library is used to perform word segmentation, part-of-speech tagging and syntactic analysis on the cleaned text data, and the dependency parsing function in the Spacy library is used to extract key sentence structures and semantic information.
[0135] In an embodiment of the present application, in the semantic information matching stage, the preset interface description template can be represented by a JSON object, for example, `template={"interface name":"","interface address":"","request method":"","request parameters":,"return result":"","interface description":"","call example":"","abnormal situation":"","remarks":""}`, by matching the preliminary semantic analysis results, the extracted keywords are mapped to the corresponding template fields. As an example, assuming that the request method is identified as "POST" during the word segmentation and part-of-speech tagging process, the request method field `template="POST"` in the template is updated.
[0136] In an embodiment of the present application, when constructing a structured data model, the interface description element list is converted into a dictionary form, and each field is completed, for example, `data_mode l = {"interface name":"user login","interface address":" / ap i / log ogi n","request method":"POST","request parameters":[{"parameter name":"user name","type":"str ing"}],"return result":"login successful","interface description":"user login interface","call example":"POST / ap i / log in{user name:test","abnormal situation":"user name does not exist","remarks":"make sure the user name has been registered"}`.
[0137] In the embodiment of the present application, when generating standardized interface description data, the structured data model is converted into JSON format using Python's json library.
[0138] In some optional implementation methods of the embodiments of the present application, the integrity and correctness of the JSON data can be verified through predefined rules and verification procedures, for example, checking whether the required fields are empty and whether the field type is correct, and performing field existence and non-empty verification through `assert "interface name" i nj son_data and j son_data,"interface name cannot be empty"`.
[0139] In some optional implementations of the embodiments of the present application, step S206 specifically includes the following steps:
[0140] Analyze the security design plan according to the code generator to obtain preliminary configuration data;
[0141] Calling a code template library, and obtaining a predefined template corresponding to the preliminary configuration data in the code template library;
[0142] Integrate preliminary configuration data and predefined templates to obtain interface code.
[0143] In an embodiment of the present application, in order to enable the code generator to parse the security design plan document and generate a security access control code framework, first, the present application uses natural language processing (NLP) technology to parse the security design plan document and extract key configuration parameters and security policies; through parsing, the present application uses regular expressions to extract specific parameters such as "OAuth0" and "AES-256"; the code generator searches for the corresponding template in the predefined code template library according to the extracted configuration parameters; the code generator integrates these template fragments with the extracted information to generate a code framework containing interface security access control.
[0144] In some optional implementations of the embodiments of the present application, after step S206, the following steps are further included:
[0145] Perform a comprehensive scan on the interface code using a static code analysis tool to obtain a comprehensive scan result;
[0146] If the comprehensive scan results show security vulnerabilities, there is no need to modify the interface code;
[0147] If there are security vulnerabilities in the comprehensive scan results, the location and type of the security vulnerabilities will be recorded;
[0148] The automatic repair function corresponding to the vulnerability type is called, and the security vulnerability is corrected according to the automatic repair function to obtain a corrected interface code.
[0149] In an embodiment of the present application, after obtaining the interface code, the interface code is passed to a static code analysis tool for a comprehensive scan. The static code analysis tool uses known security rules, such as the rules in the CWE (Common Weakness Enumeration) list, to detect potential security vulnerabilities in the code.
[0150] In an embodiment of the present application, if a vulnerability is found, the present application will record the specific location of the vulnerability and the vulnerability type. This information will generate a vulnerability report. Based on the vulnerability report, the code generator will call the automatic repair function. The repair strategy will locate the SQL query part in the code and replace the vulnerable string concatenation statement with a safe parameterized query syntax.
[0151] In the embodiment of the present application, a fully automated process is implemented from parsing the security design solution document to generating the final security code framework, ensuring the high security and traceability of the code.
[0152] In some optional implementations of the embodiments of the present application, after step S206, the following steps are further included:
[0153] Monitor the behavior of the interface code at runtime using a dynamic code analysis tool, and record abnormal behavior and triggering conditions during the runtime of the interface code to obtain abnormal behavior data;
[0154] Analyze the effectiveness of the security access control mechanism of the interface code based on abnormal behavior data and generate an analysis report.
[0155] In the embodiment of the present application, the dynamic code analysis tool is mainly used to monitor the behavior of the code at runtime. The dynamic code analysis tool may be Dynat race or New Relic, etc.
[0156] In the embodiment of the present application, abnormal behaviors and their triggering conditions during code execution are recorded. For example, in a user registration request, the input data triggers an unhandled exception. Based on these abnormal behavior data, the present application analyzes whether the security access control mechanism of the interface is effective, determines whether there is a vulnerability that bypasses identity authentication or permission control, and generates a detailed analysis report.
[0157] In the embodiment of the present application, the aforementioned analysis report is combined to propose improvement suggestions for interface code optimization and security reinforcement, thereby ensuring that they are implemented in the subsequent development process.
[0158] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0159] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0160] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0161] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0162] Embodiment 2
[0163] Further references Figure 3 , as a response to the above Figure 2 The present application provides an embodiment of an interface code generation device, and the device embodiment is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0164] like Figure 3 As shown, the interface code generating device 200 of the embodiment of the present application includes:
[0165] The demand acquisition module 210 is used to acquire the original demand interface description sent by the user terminal;
[0166] The safety compliance identification and acquisition module 220 is used to call the specification details and regulatory rules, and perform safety compliance identification processing on the original demand interface description according to the specification details and regulatory rules to obtain a risk demand interface description that does not comply with the specification details and regulatory rules;
[0167] A new interface acquisition module 230 is used to acquire new interface data corresponding to the risk requirement interface description;
[0168] The classification module 240 is used to classify the newly added interface data according to the preset security interface category to obtain security interface category information;
[0169] A solution acquisition module 250, used to acquire a security design solution corresponding to the security interface category information according to a preset format;
[0170] The code generation module 260 is used to generate interface codes for controlling security access according to the security design solution.
[0171] In the embodiment of the present application, an interface code generation device 200 is provided, including: a demand acquisition module 210, used to acquire the original demand interface description sent by the user terminal; a security compliance identification acquisition module 220, used to call the specification details and regulatory rules, and perform security compliance identification processing on the original demand interface description according to the specification details and regulatory rules, and obtain a risk demand interface description that does not comply with the specification details and regulatory rules; a new interface acquisition module 230, used to acquire new interface data corresponding to the risk demand interface description; a classification module 240, used to classify the new interface data according to the preset security interface category, and obtain security interface category information; a solution acquisition module 250, used to acquire the security design solution corresponding to the security interface category information according to the preset format; and a code generation module 260, used to generate an interface code for controlling security access according to the security design solution. . Compared with the existing technology, this application effectively solves the security risks in interface design by identifying the security compliance of the original requirements and formulating a security design plan for the risky interfaces. In addition, this application realizes the full-process security management from requirements analysis to code generation, which significantly improves the security and compliance of the interface, reduces security risks for enterprises, and enhances the overall protection capabilities of the system.
[0172] In some optional implementations of the embodiments of the present application, the apparatus 200 further includes:
[0173] A noise removal module is used to remove noise from the original requirement interface description according to the text cleaning technology to obtain the cleaned original requirement interface description;
[0174] The semantic analysis module is used to perform semantic analysis on the cleaned original requirement interface description based on natural language processing technology to obtain preliminary semantic analysis results;
[0175] A matching and mapping module is used to match and map the preliminary semantic analysis results according to a preset interface description template to obtain a list of interface description elements;
[0176] A model building module, used to build a structured data model according to the interface description element list;
[0177] The format conversion module is used to convert the data of each field of the structured data model into JSON format to obtain a standardized original requirement interface description.
[0178] In some optional implementations of the embodiments of the present application, the code generation module includes:
[0179] The parsing submodule is used to parse the security design scheme according to the code generator to obtain preliminary configuration data;
[0180] The template acquisition submodule is used to call the code template library and acquire the predefined template corresponding to the preliminary configuration data in the code template library;
[0181] The data integration submodule is used to integrate the preliminary configuration data and predefined templates to obtain the interface code.
[0182] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of a computer device according to an embodiment of the present application.
[0183] The computer device 300 includes a memory 310, a processor 320, and a network interface 330 that are interconnected and communicated through a system bus. It should be noted that the figure only shows a computer device 300 having components 310-330, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital processors (DSPs), embedded devices, etc.
[0184] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0185] The memory 310 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 310 can be an internal storage unit of the computer device 300, such as a hard disk or memory of the computer device 300. In other embodiments, the memory 310 can also be an external storage device of the computer device 300, such as a plug-in hard disk equipped on the computer device 300, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card, etc. Of course, the memory 310 can also include both the internal storage unit of the computer device 300 and its external storage device. In the embodiment of the present application, the memory 310 is generally used to store the operating system and various application software installed on the computer device 300, such as computer-readable instructions of the interface code generation method, etc. In addition, the memory 310 can also be used to temporarily store various data that have been output or are to be output.
[0186] The processor 320 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip in some embodiments. The processor 320 is generally used to control the overall operation of the computer device 300. In the embodiment of the present application, the processor 320 is used to run the computer-readable instructions stored in the memory 310 or process data, such as computer-readable instructions for running the interface code generation method.
[0187] The network interface 330 may include a wireless network interface or a wired network interface. The network interface 330 is generally used to establish a communication connection between the computer device 300 and other electronic devices.
[0188] The computer equipment provided in this application effectively solves the potential safety hazards in interface design by identifying the security compliance of original requirements and formulating security design plans for risky interfaces. In addition, it realizes full-process security management from requirements analysis to code generation, significantly improves the security and compliance of interfaces, reduces security risks for enterprises, and enhances the overall protection capabilities of the system.
[0189] The present application also provides another implementation, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the interface code generation method as described above.
[0190] The computer-readable storage medium provided by this application effectively solves the potential safety hazards in interface design by identifying the security compliance of original requirements and formulating security design plans for risky interfaces. In addition, it realizes full-process security management from requirements analysis to code generation, significantly improves the security and compliance of interfaces, reduces security risks for enterprises, and enhances the overall protection capabilities of the system.
[0191] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0192] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
Claims
1. A method for generating interface code, It is characterized in that The steps include: Obtain the original demand interface description sent by the user terminal; Calling specification details and regulatory rules, and performing security compliance identification processing on the original requirement interface description according to the specification details and regulatory rules, to obtain a risk requirement interface description that does not comply with the specification details and regulatory rules; Acquire new interface data corresponding to the risk requirement interface description; Classify the newly added interface data according to the preset security interface category to obtain security interface category information; Acquire a security design solution corresponding to the security interface category information according to a preset format; An interface code for controlling security access is generated according to the security design solution.
2. The interface code generation method according to claim 1, It is characterized in that After the step of obtaining the original demand interface description sent by the user terminal, the following steps are also included: Performing noise removal processing on the original demand interface description according to text cleaning technology to obtain a cleaned original demand interface description; Performing semantic analysis on the cleaned original demand interface description according to natural language processing technology to obtain preliminary semantic analysis results; Matching and mapping the preliminary semantic analysis results according to a preset interface description template to obtain an interface description element list; Constructing a structured data model according to the interface description element list; The data of each field of the structured data model is converted into JSON format to obtain a standardized original requirement interface description.
3. The interface code generation method according to claim 1, It is characterized in that The step of generating an interface code for controlling secure access according to the security design solution specifically comprises the following steps: Parsing the security design scheme according to the code generator to obtain preliminary configuration data; Calling a code template library, and acquiring a predefined template corresponding to the preliminary configuration data in the code template library; The preliminary configuration data and the predefined template are integrated to obtain the interface code.
4. The interface code generation method according to claim 3, It is characterized in that After the step of generating an interface code for controlling security access according to the security design solution, the following steps are also included: Performing a comprehensive scan on the interface code using a static code analysis tool to obtain a comprehensive scan result; If the comprehensive scan result has a security vulnerability, there is no need to modify the interface code; If there is a security vulnerability in the comprehensive scan result, the vulnerability location and vulnerability type of the security vulnerability are recorded; The automatic repair function corresponding to the vulnerability type is called, and the security vulnerability is corrected according to the automatic repair function to obtain a corrected interface code.
5. The interface code generation method according to claim 1, It is characterized in that After the step of generating an interface code for controlling security access according to the security design solution, the following steps are also included: Monitor the behavior of the interface code when it is running according to a dynamic code analysis tool, and record abnormal behavior and triggering conditions when the interface code is running to obtain abnormal behavior data; The effectiveness of the security access control mechanism of the interface code is analyzed according to the abnormal behavior data, and an analysis report is generated.
6. An interface code generating device, It is characterized in that include: The demand acquisition module is used to obtain the original demand interface description sent by the user terminal; A security compliance identification and acquisition module is used to call specification details and regulatory rules, and perform security compliance identification processing on the original demand interface description according to the specification details and regulatory rules to obtain a risk demand interface description that does not comply with the specification details and regulatory rules; A new interface acquisition module is used to acquire new interface data corresponding to the risk requirement interface description; A classification module, used to classify the newly added interface data according to a preset security interface category to obtain security interface category information; A solution acquisition module, used to acquire a security design solution corresponding to the security interface category information according to a preset format; A code generation module is used to generate an interface code for controlling security access according to the security design solution.
7. The interface code generating device according to claim 6, It is characterized in that The device also includes: A noise removal module, used for performing noise removal processing on the original demand interface description according to a text cleaning technology to obtain a cleaned original demand interface description; A semantic analysis module is used to perform semantic analysis on the cleaned original demand interface description according to natural language processing technology to obtain a preliminary semantic analysis result; A matching and mapping module, used to match and map the preliminary semantic analysis results according to a preset interface description template to obtain an interface description element list; A model building module, used to build a structured data model according to the interface description element list; The format conversion module is used to convert the data of each field of the structured data model into JSON format to obtain a standardized original requirement interface description.
8. The interface code generating device according to claim 6, It is characterized in that The code generation module includes: A parsing submodule, used for parsing the security design scheme according to the code generator to obtain preliminary configuration data; A template acquisition submodule, used for calling a code template library and acquiring a predefined template corresponding to the preliminary configuration data in the code template library; The data integration submodule is used to integrate the preliminary configuration data and the predefined template to obtain the interface code.
9. A computer device, comprising a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the interface code generation method according to any one of claims 1 to 5 when executing the computer-readable instructions.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the interface code generation method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Vulnerability detection method and device
CN116933264A
Code generation method of application program interface, terminal equipment and storage medium
CN117215570A
Code generation method and device, equipment, storage medium and program product
CN117707503A
Network event processing method and apparatus, and readable storage medium
WO2021151335A1
