Method and system for proxy interface by analyzing curl command
By analyzing the curl command automatic proxy interface, the errors and operation and maintenance problems caused by the traditional interface gateway registration method relying on manual input are solved, and the efficiency and availability of interface proxy are improved.
Patent Information
- Application Number
- CN202411720774.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2044-11-28
AI Technical Summary
The registration method of traditional interface gateways relies on manual configuration or page registration, resulting in manual input errors, many operation and maintenance problems, and high technical thresholds, limiting the use scenarios of interface gateways.
By analyzing the curl command automatic proxy interface, the user only needs to enter the curl command, and the system automatically parses and generates the proxy interface to avoid manual input errors.
It improves the efficiency and availability of interface agents, reduces operation and maintenance issues, and is suitable for operation scenarios for non-technical personnel.
Smart Images

Figure CN119676332A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of interface gateway, in particular to a method and system for parsing a curl command proxy interface. Background Art
[0002] With the development of Internet technology and the popularity of microservices, more and more services need to be exposed, and the management of these services has prompted the emergence of interface gateways. The term gateway first appeared in network devices. For example, two independent LANs communicate through routers, and the routing device in the middle is called a gateway. At the software development level, it is a gateway between the client and the microservice system. From a business perspective, when the client completes a business, it needs to call multiple microservices at the same time. From a system perspective, if any application system needs to be called by other systems, it needs to expose interfaces, which represent business function points.
[0003] Registering the interface with the interface gateway is an important step in using the interface gateway. Traditional methods generally use manual configuration, page registration, etc. Manual configuration is limited to the interface proxy at the application system layer, and has high technical requirements for operators. Only operation and maintenance or developers can operate it, which limits the use scenarios of the interface gateway. Compared with manual configuration, page registration is simpler, has a lower technical threshold, and is more convenient to operate. However, traditional page registration requires users to manually enter various information, including but not limited to interface address, request method, request parameters, etc. The inevitable errors in manual operation can easily cause proxy failures, bringing more operation and maintenance problems to use. Summary of the invention
[0004] In view of the needs and shortcomings of current technological development, the present invention provides a method and system for parsing a proxy interface by parsing a curl command, which parses the curl command by automatic parsing, thereby assisting the user proxy interface, avoiding errors caused by manual input, and improving the efficiency of the interface proxy and the availability of the proxy interface.
[0005] In the first aspect, the present invention provides a method for parsing a curl command proxy interface, and the technical solution adopted to solve the above technical problem is as follows:
[0006] A method for parsing a curl command proxy interface, comprising the following steps:
[0007] S1. The user refers to the interface document to call the interface in the third-party tool. When the interface call is successful, copy the generated curl command and paste it on the front-end page;
[0008] S2. The front-end page verifies the curl command;
[0009] S3. The front-end page transmits the verified curl command to the back-end for processing. After receiving the curl command, the back-end splits the curl command into several instructions and stores them in an array. Each instruction is an option or an option parameter.
[0010] S4. Refer to the curl documentation, and the backend executes each instruction in the array in turn, and extracts five types of options and corresponding option parameters: interface address, request method, parameter list, parameter position, and request body type;
[0011] S5, the backend processes the extracted interface address and saves it into a parameter list;
[0012] S6, the backend transmits the information extracted in step S4 to the front-end page for display;
[0013] S7. After the user confirms the modification of the display information of the front-end page, it is saved in the database. The back-end forms a proxy interface based on the saved information in the database, thereby realizing the gateway proxy function.
[0014] Optionally, step S2 is performed, and the front-end page verifies the curl command, specifically including:
[0015] Check whether the curl command contains special characters that affect command security or command parsing;
[0016] Check whether the length of the curl command exceeds the preset length range;
[0017] Use a regular expression to verify whether the curl command contains required information.
[0018] Optionally, execute step S3. After the backend receives the curl command:
[0019] (1) Check whether the curl command is legal and whether it contains malicious commands or scripts, and execute subsequent steps after passing the detection;
[0020] (2) Use a regular expression to verify whether the format of the curl command is legal. If the verification is legal, execute the subsequent steps. The verification content includes: whether it contains the "curl" character, whether it contains special characters, whether it contains characters that are not curl commands, whether it contains the request address, and whether the included request address is legal.
[0021] (3) Standardize the curl command: remove the leading and trailing spaces and remove useless command symbols;
[0022] (4) Remove the first "curl" character to perform segment processing;
[0023] (5) Split the curl command into several instructions according to spaces and store them in an array. Each instruction is an option or an option parameter.
[0024] Optionally, step S5 is executed, and the backend processes the extracted interface address as follows:
[0025] Determine whether there is a protocol number. If not, add "http: / / " in front.
[0026] Determine whether there is a "?", if so, cut off the part after the question mark;
[0027] Split the intercepted part into multiple key-value pairs using "&", each key-value pair is a string;
[0028] Traverse multiple key-value pairs, and then extract each key-value pair into parameter name and parameter value according to "=";
[0029] Save the results to the parameter list.
[0030] Optionally, after executing step S6, the information displayed on the front-end page is as follows: request address, request method, request body type, request parameter list, cookie, interface address IP protocol, interface address http protocol version number, maximum transmission time, proxy address, proxy username and password, whether files are included, user-agent settings, where the cookie information is extracted from the response header returned by the server during the execution of the curl command, and the user-agent setting displays the parameter value corresponding to the '-A' or '--user-agent' option in the curl command.
[0031] In a second aspect, the present invention provides a system for parsing a curl command proxy interface, and the technical solution adopted to solve the above technical problem is as follows:
[0032] A system for proxying an interface by parsing a curl command, comprising a front-end part and a back-end part;
[0033] The front end includes:
[0034] Call the copy module to support users to call the interface in third-party tools by referring to the interface documentation, and copy the generated curl command when the interface call is successful and paste it into the verification transmission module;
[0035] The verification and transmission module supports verification of the pasted curl command and transmits the verified curl command to the backend;
[0036] The visual editing module supports displaying the transmission information of the backend part for users to view and modify;
[0037] The transmission and saving module supports transmitting the displayed information after the user's modification and confirmation to the database for saving;
[0038] The backend part includes:
[0039] The receiving and splitting module supports receiving the curl command sent by the verification and transmission module, and splits it into several instructions and stores them in an array. Each instruction is an option or an option parameter.
[0040] The execution extraction module supports referring to the curl usage documentation, executing each instruction in the array in turn, and extracting five types of options and corresponding option parameters: interface address, request method, parameter list, parameter position, and request body type;
[0041] The address processing module supports processing the extracted interface addresses and saving them into the parameter list;
[0042] The information transmission module supports transmitting the information extracted by the execution extraction module to the visual editing module;
[0043] The proxy implementation module supports the formation of a proxy interface based on the information saved in the database to realize the gateway proxy function.
[0044] Optionally, the verification transmission module verifies the pasted curl command, specifically including:
[0045] Check whether the curl command contains special characters that affect command security or command parsing;
[0046] Check whether the length of the curl command exceeds the preset length range;
[0047] Use a regular expression to verify whether the curl command contains required information.
[0048] Optionally, the receiving and splitting module receives the curl command sent by the verification and transmission module and first performs the following operations:
[0049] (1) Check whether the curl command is legal and whether it contains malicious commands or scripts, and execute subsequent steps after passing the detection;
[0050] (2) Use a regular expression to check whether the format of the curl command is legal. If the verification is legal, execute the subsequent steps; the verification content includes: whether it contains the "curl" character, whether it contains special characters, whether it contains characters that are not curl commands, whether it contains the request address, and whether the included request address is legal.
[0051] (3) Standardize the curl command: remove the leading and trailing spaces and remove useless command symbols;
[0052] (4) Remove the first "curl" character to perform segment processing;
[0053] Then the curl command is split into several instructions according to spaces and stored in an array. Each instruction is an option or an option parameter.
[0054] Optionally, the address processing module involved performs the following processing on the extracted interface address:
[0055] Determine whether there is a protocol number. If not, add "http: / / " in front.
[0056] Determine whether there is a "?", if so, cut off the part after the question mark;
[0057] Split the intercepted part into multiple key-value pairs using "&", each key-value pair is a string;
[0058] Traverse multiple key-value pairs, and then extract each key-value pair into parameter name and parameter value according to "=";
[0059] Save the results to the parameter list.
[0060] Optionally, the visual editing module involved specifically displays the following information for users to view and modify: request address, request method, request body type, request parameter list, cookie, interface address IP protocol, interface address http protocol version number, maximum transmission time, proxy address, proxy username and password, whether to include files, user-agent settings, where cookie information is extracted from the response header returned by the server during the execution of the curl command, and the user-agent setting displays the parameter value corresponding to the '-A' or '--user-agent' option in the curl command.
[0061] The method and system of the present invention for parsing a curl command proxy interface have the following beneficial effects compared with the prior art:
[0062] 1. The present invention gets rid of the trouble of manually registering the gateway interface. The user only needs to enter the curl command to parse the curl command and generate the proxy interface, thus avoiding the errors caused by manual input and improving the efficiency of the interface proxy and the availability of the proxy interface;
[0063] 2. The present invention performs analysis on the curl command through front-end verification, back-end verification, command analysis and address analysis, which not only ensures system security but also ensures data accuracy. The present invention also supports confirmation and error correction operations, allowing users to view and confirm and input corrections when there is a parsing failure or command error. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] AttachedFigure 1 is a flow chart of a method according to Embodiment 1 of the present invention;
[0065] Attached Figure 2 This is a module connection block diagram of the second embodiment of the present invention. DETAILED DESCRIPTION
[0066] In order to make the technical solution, the technical problem solved and the technical effect of the present invention more clearly understood, the technical solution of the present invention is clearly and completely described below in conjunction with specific embodiments.
[0067] Embodiment 1:
[0068] Combined with Figure 1 This embodiment proposes a method for parsing a curl command proxy interface, which includes the following steps:
[0069] S1. The user refers to the interface document and calls the interface in a third-party tool (such as Postman, etc.) according to the established parameter requirements and calling specifications. When the interface call is successful, copy the generated curl command and paste it on the front-end page. The page can also fill in relevant business information, such as interface name, interface description, and proxy context.
[0070] S2. The front-end page verifies the curl command, including:
[0071] Check whether the curl command contains special characters that affect command security or command parsing, such as &|. Before using it, you should list the complete special character set according to the actual system security policy.
[0072] Check whether the length of the curl command exceeds the preset length range. The specific length range can be adjusted according to the actual system carrying capacity and business requirements;
[0073] Use a regular expression to verify whether the curl command contains required information.
[0074] S3. The front-end page transmits the verified curl command to the back-end for processing;
[0075] After receiving the curl command, the backend first performs the following operations:
[0076] (1) Check whether the curl command is legal, for example, ① check whether the curl command length meets the system preset maximum length limit (such as 1000 bytes, depending on the system configuration), ② check whether the encoding uses the UTF-8 encoding format supported by the system, ③ for the legitimacy of the characters, in addition to the special characters previously checked, it is also necessary to check whether there are unrecognizable control characters (the control character range can be defined by referring to the ASCII code table); check whether the curl command contains malicious commands or scripts. This process can integrate open source security detection libraries (such as ClamAV, etc.), regularly update the virus feature library, and check whether malicious scripts or commands are hidden in the curl command based on feature matching;
[0077] (2) Use a regular expression to verify whether the format of the curl command is legal. If the verification is legal, execute the subsequent steps. The verification content includes: whether it contains the "curl" character, whether it contains special characters, whether it contains characters that are not curl commands, whether it contains the request address, and whether the included request address is legal.
[0078] (3) Standardize the curl command: remove the leading and trailing spaces and remove useless command symbols;
[0079] (4) Remove the first "curl" character to perform segment processing;
[0080] Then, the curl command is split into several instructions according to spaces and stored in an array, each of which is an option or an option parameter.
[0081] S4. Refer to the curl documentation. The backend executes each instruction in the array in turn and extracts five types of options and corresponding option parameters, including interface address, request method, parameter list, parameter position and request body type.
[0082] It should be added that in the process of executing each instruction in the array, if an execution error is encountered due to non-compliance with the curl standard syntax format, an error log should be recorded to record the error instruction content and error type (such as syntax error, parameter missing error, etc.) in detail, and an error prompt message should be returned to the front end to inform the user that there is a problem with the instruction execution and the curl command needs to be rechecked and corrected; when extracting various options and parameters, if the format does not meet expectations (such as parameter values lacking quotation marks, etc.), it should be processed according to the preset fault tolerance and correction rules (specific fault tolerance and correction methods can be illustrated with examples, such as simple correction operations such as automatically filling in missing quotation marks) to ensure that the required information can be extracted as accurately as possible.
[0083] S5. The backend processes the extracted interface address and saves it into a parameter list. The processing process of the interface address is as follows:
[0084] Determine whether there is a protocol number. If not, add "http: / / " in front.
[0085] Determine whether there is a "?", if so, cut off the part after the question mark;
[0086] Split the intercepted part into multiple key-value pairs using "&", each key-value pair is a string;
[0087] Traverse multiple key-value pairs, and then extract each key-value pair into parameter name and parameter value according to "=";
[0088] Save the results to the parameter list.
[0089] It should be added that before the above processing is performed on the interface address, first verify whether the interface address conforms to the basic URL format specification by means of regular expressions or the like (a specific regular expression example can be given, such as matching ^(https?|ftp): / / [^\s / $.?#].[^\s]*$ and other common URL formats). If it does not conform to the format specification, an error message is recorded and returned to the front end to prompt the user that the interface address format is incorrect and needs to be re-filled or corrected. Subsequently, if an abnormal situation such as '?' does not exist or '&' does not conform to the key-value pair format after segmentation is encountered during the processing, the error is also recorded and fed back to the front end for corresponding processing.
[0090] S6. The backend transmits the information extracted in step S4 to the frontend page for display.
[0091] The specific display content includes: request address (address), request method (method), request body type (content-type), request parameter list (header, body, params), cookie, interface address IP protocol (ipProtocol), interface address http protocol version number (httpVersion), maximum transmission time (maxSocketTime), proxy address (proxyUrl), proxy username and password (proxyUser, proxyPassword), whether to include files (file), user-agent settings (header.user-agent), where cookie information is extracted from the response header returned by the server during the execution of the curl command (specifically, the relevant cookie value can be obtained by parsing the 'Set-Cookie' field in the response header); user-agent settings display the parameter value corresponding to the '-A' or '--user-agent' option in the curl command (if the option exists), if not, the default system user-agent value is displayed (such as 'Mozilla / 5.0(Windows NT 10.0; Win64; x64)AppleWebKit / 5.0(KHTML,like Gecko)Chrome / XX.XX.XXSafari / 5.0', the specific default value depends on the system configuration).
[0092] S7. After the user confirms the modification of the display information of the front-end page, it is saved in the database. The back-end forms a proxy interface based on the saved information in the database, thereby realizing the gateway proxy function.
[0093] Embodiment 2:
[0094] Combined with Figure 2 , this embodiment proposes a system for parsing a curl command proxy interface, which includes a front-end part and a back-end part.
[0095] (I) The front end part includes:
[0096] Call the copy module to support users to call the interface in third-party tools by referring to the interface documentation, and copy the generated curl command when the interface call is successful and paste it into the verification transmission module;
[0097] The verification and transmission module supports verification of the pasted curl command and transmits the verified curl command to the backend;
[0098] The visual editing module supports displaying the transmission information of the backend part for users to view and modify;
[0099] The transmission and saving module supports transmitting the display information after the user's modification and confirmation to the database for saving.
[0100] In this embodiment, the verification transmission module involved verifies the pasted curl command, specifically including:
[0101] Check whether the curl command contains special characters that affect command security or command parsing;
[0102] Check whether the length of the curl command exceeds the preset length range;
[0103] Use a regular expression to verify whether the curl command contains required information.
[0104] In this embodiment, the receiving and splitting module receives the curl command transmitted by the verification transmission module and first performs the following operations:
[0105] (1) Check whether the curl command is legal, for example, ① check whether the curl command length meets the system preset maximum length limit (such as 1000 bytes, depending on the system configuration); ② check whether the encoding uses the UTF-8 encoding format supported by the system; ③ for the legality of the characters, in addition to the special characters previously checked, it is also necessary to check whether there are unrecognizable control characters (the control character range can be defined by referring to the ASCII code table);
[0106] Detect whether the curl command contains malicious commands or scripts. This process can integrate open source security detection libraries (such as ClamAV, etc.), regularly update the virus feature library, and check whether malicious scripts or commands are hidden in the curl command based on feature matching;
[0107] After passing the test, follow up steps;
[0108] (2) Use a regular expression to check whether the format of the curl command is legal. If the verification is legal, execute the subsequent steps; the verification content includes: whether it contains the "curl" character, whether it contains special characters, whether it contains characters that are not curl commands, whether it contains the request address, and whether the included request address is legal.
[0109] (3) Standardize the curl command: remove the leading and trailing spaces and remove useless command symbols;
[0110] (4) Remove the first "curl" character to perform segment processing;
[0111] Then the curl command is split into several instructions according to spaces and stored in an array. Each instruction is an option or an option parameter.
[0112] (ii) The backend part includes:
[0113] The receiving and splitting module supports receiving the curl command sent by the verification and transmission module, and splits it into several instructions and stores them in an array. Each instruction is an option or an option parameter.
[0114] The execution extraction module supports referring to the curl usage documentation, executing each instruction in the array in turn, and extracting five types of options and corresponding option parameters: interface address, request method, parameter list, parameter position, and request body type;
[0115] The address processing module supports processing the extracted interface addresses and saving them into the parameter list;
[0116] The information transmission module supports transmitting the information extracted by the execution extraction module to the visual editing module;
[0117] The proxy implementation module supports the formation of a proxy interface based on the information saved in the database to realize the gateway proxy function.
[0118] This embodiment executes each instruction in the execution extraction module array, extracts five types of options and corresponding option parameters, including interface address, request method, parameter list, parameter position and request body type. What needs to be supplemented in this process is that in the process of executing each instruction in the array, if an execution error is caused by non-compliance with the curl standard syntax format, an error log should be recorded to record the erroneous instruction content and error type (such as syntax error, parameter missing error, etc.) in detail, and an error prompt message should be returned to the front end to inform the user that there is a problem with the instruction execution and the curl command needs to be rechecked and corrected; when extracting various options and parameters, if the format does not meet expectations (such as parameter values lacking quotation marks, etc.), it is processed according to the preset fault tolerance and correction rules (specific fault tolerance and correction methods can be illustrated by examples, such as simple correction operations such as automatically filling in missing quotation marks) to ensure that the required information can be extracted as accurately as possible.
[0119] In this embodiment, the address processing module performs the following processing on the extracted interface address:
[0120] Determine whether there is a protocol number. If not, add "http: / / " in front.
[0121] Determine whether there is a "?", if so, cut off the part after the question mark;
[0122] Use "&" to split the intercepted part into multiple key-value pairs, each of which is a string;
[0123] Traverse multiple key-value pairs, and then extract each key-value pair into parameter name and parameter value according to "=";
[0124] Save the results to the parameter list.
[0125] It should be added that before the address processing module performs the above processing on the interface address, it should first verify whether the interface address conforms to the basic URL format specification by means of regular expressions or the like (a specific regular expression example can be given, such as matching ^(https?|ftp): / / [^\s / $.?#].[^\s]*$ and other common URL formats). If it does not conform to the format specification, an error message is recorded and returned to the front-end part to prompt the user that the interface address format is incorrect and needs to be re-filled or corrected. Subsequently, if an abnormal situation such as '?' does not exist or '&' does not conform to the key-value pair format after segmentation is encountered during the processing, the error is also recorded and fed back to the front-end part for corresponding processing.
[0126] In this embodiment, the visual editing module involved specifically displays the following information for users to view and modify: request address, request method, request body type, request parameter list, cookie, interface address IP protocol, interface address http protocol version number, maximum transmission time, proxy address, proxy username and password, whether to include files, user-agent settings, wherein the cookie information is extracted from the response header returned by the server during the execution of the curl command (specifically, the relevant cookie value can be obtained by parsing the 'Set-Cookie' field in the response header); the user-agent setting displays the parameter value corresponding to the '-A' or '--user-agent' option in the curl command (if the option exists), and if not, the default system user-agent value is displayed (such as 'Mozilla / 5.0 (Windows NT 10.0; Win64; x64) AppleWebKit / 5.0 (KHTML, like Gecko) Chrome / XX.XX.XX Safari / 5.0', the specific default value depends on the system configuration).
[0127] In summary, the method and system of the present invention for parsing a curl command proxy interface avoids the trouble of manually registering a gateway interface. The user only needs to input a curl command to parse the curl command and generate a proxy interface, thus avoiding errors caused by manual input and improving the efficiency of the interface proxy and the availability of the proxy interface.
[0128] The above specific examples are used to explain the principles and implementation methods of the present invention in detail. These examples are only used to help understand the core technical content of the present invention. Based on the above specific embodiments of the present invention, any improvements and modifications made by technicians in this technical field without departing from the principles of the present invention should fall within the scope of patent protection of the present invention.
Claims
1. A method for parsing a curl command proxy interface, characterized in that: The steps include: S1. The user refers to the interface document to call the interface in the third-party tool. When the interface call is successful, copy the generated curl command and paste it on the front-end page; S2. The front-end page verifies the curl command; S3. The front-end page transmits the verified curl command to the back-end for processing. After receiving the curl command, the back-end splits the curl command into several instructions and stores them in an array. Each instruction is an option or an option parameter. S4. Refer to the curl documentation, and the backend executes each instruction in the array in turn, and extracts five types of options and corresponding option parameters: interface address, request method, parameter list, parameter position, and request body type; S5, the backend processes the extracted interface address and saves it into a parameter list; S6, the backend transmits the information extracted in step S4 to the front-end page for display; S7. After the user confirms the modification of the display information of the front-end page, it is saved in the database. The back-end forms a proxy interface based on the saved information in the database, thereby realizing the gateway proxy function.
2. A method for proxying an interface by parsing a curl command according to claim 1, characterized in that: Execute step S2, the front-end page verifies the curl command, specifically including: Check whether the curl command contains special characters that affect command security or command parsing; Check whether the length of the curl command exceeds the preset length range; Use a regular expression to verify whether the curl command contains required information.
3. The method for proxying an interface by parsing a curl command according to claim 1, characterized in that: Execute step S3. After the backend receives the curl command: (1) Check whether the curl command is legal and whether it contains malicious commands or scripts, and execute subsequent steps after passing the detection; (2) Use a regular expression to verify whether the format of the curl command is legal. If the verification is legal, execute the subsequent steps. The verification content includes: whether it contains the "curl" character, whether it contains special characters, whether it contains characters that are not curl commands, whether it contains the request address, and whether the included request address is legal. (3) Standardize the curl command: remove the leading and trailing spaces and remove useless command symbols; (4) Remove the first "curl" character to perform segment processing; (5) Split the curl command into several instructions according to spaces and store them in an array. Each instruction is an option or an option parameter.
4. The method for proxying an interface by parsing a curl command according to claim 1, characterized in that: Execute step S5, the backend processes the extracted interface address as follows: Determine whether there is a protocol number. If not, add "http: / / " in front. Determine whether there is a "?", if so, cut off the part after the question mark; Split the intercepted part into multiple key-value pairs using "&", each key-value pair is a string; Traverse multiple key-value pairs, and then extract each key-value pair into parameter name and parameter value according to "="; Save the results to the parameter list.
5. The method for proxying an interface by parsing a curl command according to claim 1, characterized in that: After executing step S6, the information displayed on the front-end page is as follows: request address, request method, request body type, request parameter list, cookie, interface address IP protocol, interface address http protocol version number, maximum transmission time, proxy address, proxy username and password, whether to include files, user-agent settings, among which, cookie information is extracted from the response header returned by the server during the execution of the curl command, and the user-agent setting displays the parameter value corresponding to the '-A' or '--user-agent' option in the curl command.
6. A system for proxying an interface by parsing a curl command, characterized in that: It includes a front end portion and a back end portion; The front end includes: Call the copy module to support users to call the interface in third-party tools by referring to the interface documentation, and copy the generated curl command when the interface call is successful and paste it into the verification transmission module; The verification and transmission module supports verification of the pasted curl command and transmits the verified curl command to the backend; The visual editing module supports displaying the transmission information of the backend part for users to view and modify; The transmission and saving module supports transmitting the displayed information after the user's modification and confirmation to the database for saving; The backend part includes: The receiving and splitting module supports receiving the curl command sent by the verification and transmission module, and splits it into several instructions and stores them in an array. Each instruction is an option or an option parameter. The execution extraction module supports referring to the curl usage documentation, executing each instruction in the array in turn, and extracting five types of options and corresponding option parameters: interface address, request method, parameter list, parameter position, and request body type; The address processing module supports processing the extracted interface addresses and saving them into the parameter list; The information transmission module supports transmitting the information extracted by the execution extraction module to the visual editing module; The proxy implementation module supports the formation of a proxy interface based on the information saved in the database to realize the gateway proxy function.
7. A system for proxying an interface by parsing curl commands according to claim 6, characterized in that: The verification transmission module verifies the pasted curl command, specifically including: Check whether the curl command contains special characters that affect command security or command parsing; Check whether the length of the curl command exceeds the preset length range; Use a regular expression to verify whether the curl command contains required information.
8. The system for proxying an interface by parsing curl commands according to claim 6, characterized in that: The receiving and splitting module receives the curl command transmitted by the verification and transmission module, and first performs the following operations: (1) Check whether the curl command is legal and whether it contains malicious commands or scripts, and execute subsequent steps after passing the detection; (2) Use a regular expression to check whether the format of the curl command is legal. If the verification is legal, execute the subsequent steps. The verification content includes: whether it contains the "curl" character, whether it contains special characters, whether it contains characters that are not curl commands, whether it contains the request address, and whether the included request address is legal. (3) Standardize the curl command: remove the leading and trailing spaces and remove useless command symbols; (4) Remove the first "curl" character to perform segment processing; Then the curl command is split into several instructions according to spaces and stored in an array. Each instruction is an option or an option parameter.
9. The system for proxying an interface by parsing curl commands according to claim 6, characterized in that: The address processing module processes the extracted interface address as follows: Determine whether there is a protocol number. If not, add "http: / / " in front. Determine whether there is a "?", if so, cut off the part after the question mark; Split the intercepted part into multiple key-value pairs using "&", each key-value pair is a string; Traverse multiple key-value pairs, and then extract each key-value pair into parameter name and parameter value according to "="; Save the results to the parameter list.
10. The system for proxying an interface by parsing curl commands according to claim 6, characterized in that: The visual editing module specifically displays the following information for users to view and modify: request address, request method, request body type, request parameter list, cookie, interface address IP protocol, interface address http protocol version number, maximum transmission time, proxy address, proxy username and password, whether to include files, user-agent settings, where cookie information is extracted from the response header returned by the server during the execution of the curl command, and the user-agent setting displays the parameter value corresponding to the '-A' or '--user-agent' option in the curl command.
Citation Information
Patent Citations
Web service proxy method, apparatus, device, and storage medium
CN109067914A
Method for directly obtaining local command execution result and local server
CN111291299A
Method and device for generating interface code and / or interface document and storage medium
CN112631557A
Dynamic reverse proxy method and device, reverse proxy system, equipment and medium
CN114338796A
Method for safely, efficiently and automatically converting Curl command into API gateway low-code interface file
CN115756479A