Shadow API interface detection method and device, server, medium and product
By receiving API interface documents and network traffic data and using large language models to judge status codes, the problem of low detection efficiency and accuracy of shadow API interfaces in the prior art is solved, and efficient detection of complex applications is achieved.
Patent Information
- Application Number
- CN202411208674.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2044-08-30
AI Technical Summary
The prior art has low efficiency and accuracy in detecting shadow API interfaces in large and complex applications, especially shadow API interfaces that are not explicitly specified in code comments or documents are difficult to detect.
By receiving API interface documents and network traffic data, an API interface baseline is formed, and the trained large language model is used to obtain the API interface to be detected, and the status code is used to determine whether it is a shadow API interface, which improves detection efficiency and accuracy.
Even if the code is frequently changed and updated, all code bases are covered by network traffic data, and the shadow API interface is judged with the help of a large language model, without relying on code comments or documents, which significantly improves the detection efficiency and accuracy of the shadow API interface.
Smart Images

Figure CN119094401A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method, device, server, medium and product for detecting a shadow API interface. Background Art
[0002] Shadow API (Application Programming Interface) refers to an application programming interface that is not formally documented, unofficially released or not publicly available. During the software development process, developers may create temporary API interfaces to test functions. These API interfaces may not be cleaned up after the project is completed, thus becoming shadow API interfaces; these shadow API interfaces not only consume resources, but may also introduce security risks.
[0003] Currently, the existing technology detects shadow API interfaces in the code base through manual code auditing methods.
[0004] However, for large and complex applications, with frequent code changes and updates, manual code audits may not cover all code bases, and shadow API interfaces that are not clearly pointed out in code comments or documents cannot be discovered through manual code audits, resulting in reduced efficiency and accuracy in detecting shadow API interfaces. Summary of the invention
[0005] The embodiments of the present application provide a method, device, server, medium and product for detecting a shadow API interface, so as to achieve the effect of improving the efficiency and accuracy of detecting a shadow API interface.
[0006] In the first aspect, an embodiment of the present application provides a method for detecting a shadow API interface, including: receiving an API interface document sent by a management terminal; capturing network traffic data, and obtaining all API interfaces in the network traffic data; forming multiple API interface baselines based on the API interface document and all API interfaces; inputting any API interface baseline into a trained large language model to output multiple API interfaces corresponding to any API interface baseline; determining multiple API interfaces to be detected based on the network traffic data and the multiple API interfaces; constructing a request body for each API interface to be detected, and sending the request body of each API interface to be detected to each API interface to be detected to obtain a response result; wherein the response result includes a status code; determining whether the status code exists in a preset status code set; if it is determined that the status code exists in the preset status code set, then determining each API interface to be detected corresponding to the status code as a shadow API interface.
[0007] In a possible implementation, after forming multiple API interface baselines, it also includes: obtaining API standard interface naming information and an API standard interface naming example set; using the API standard interface naming information and the API standard interface naming example set as a first standard interface naming training set; obtaining a second standard interface naming training set based on the API interface document and all API interfaces; training a first large language model for standard interface naming based on the first standard interface naming training set and the second standard interface naming training set to obtain a second large language model; obtaining a dynamic parameter training set based on the API interface document and all API interfaces; training the second large language model for dynamic parameters based on the dynamic parameter training set to obtain a trained large language model.
[0008] In one possible implementation, multiple API interface baselines are formed based on the API interface document and all API interfaces, including: deduplicating all API interfaces to obtain multiple deduplicated API interfaces; merging the API interface document with the same API interfaces in the multiple deduplicated API interfaces to form multiple API interface baselines.
[0009] In one possible implementation, multiple API interfaces include multiple API interfaces containing dynamic parameters and multiple API interfaces that do not contain dynamic parameters; accordingly, multiple API interfaces to be detected are determined based on network traffic data and the multiple API interfaces, including: obtaining dynamic parameter values corresponding to the dynamic parameters in each API interface containing dynamic parameters from the network traffic data; replacing the dynamic parameters in each API interface containing dynamic parameters with the dynamic parameter values to obtain each API interface with dynamic parameter values; and determining all API interfaces with dynamic parameter values and multiple API interfaces that do not contain dynamic parameters as multiple API interfaces to be detected.
[0010] In a possible implementation, after determining each API interface to be detected corresponding to the status code as a shadow API interface, it also includes: saving all shadow API interfaces to a shadow API interface management ledger; sending the shadow API interface management ledger to the operation and maintenance terminal, so that the operation and maintenance terminal manages them according to the shadow API interface management ledger.
[0011] In a second aspect, an embodiment of the present application provides a detection device for a shadow API interface, including:
[0012] The receiving module is used to receive the API interface document sent by the management terminal.
[0013] The capture module is used to capture network traffic data and obtain all API interfaces in the network traffic data.
[0014] The acquisition module is used to form multiple API interface baselines according to the API interface documents and all API interfaces.
[0015] The output module is used to input any API interface baseline into the trained large language model to output multiple API interfaces corresponding to any API interface baseline.
[0016] The determination module is used to determine multiple API interfaces to be detected based on network traffic data and multiple API interfaces.
[0017] The construction module is used to construct the request body of each API interface to be detected, and send the request body of each API interface to be detected to each API interface to be detected to obtain a response result; wherein the response result includes a status code.
[0018] The judging module is used to judge whether the status code exists in the preset status code set.
[0019] The determination module is used to determine each to-be-detected API interface corresponding to the status code as a shadow API interface if the status code is determined to exist in a preset status code set.
[0020] In a possible implementation, the device also includes a training module for obtaining API standard interface naming information and an API standard interface naming example set; using the API standard interface naming information and the API standard interface naming example set as a first standard interface naming training set; obtaining a second standard interface naming training set based on the API interface document and all the API interfaces; training a first large language model for standard interface naming based on the first standard interface naming training set and the second standard interface naming training set to obtain a second large language model; obtaining a dynamic parameter training set based on the API interface document and all the API interfaces; and training the second large language model for dynamic parameters based on the dynamic parameter training set to obtain a trained large language model.
[0021] In a third aspect, an embodiment of the present application provides a server, including: a memory, a processor;
[0022] The memory stores computer-executable instructions;
[0023] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the above first aspect and / or various possible implementations of the first aspect.
[0024] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the first aspect above and / or various possible implementations of the first aspect.
[0025] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the above first aspect and / or various possible implementation methods of the first aspect.
[0026] The detection method, device, server, medium and product of shadow API interface provided by the embodiments of the present application. Obtain all API interfaces in the network traffic data, and form an API interface baseline according to the API interface documents and all API interfaces; use the trained large language model to obtain multiple API interfaces of any API interface baseline, and then obtain multiple API interfaces to be detected; send the request body of each API interface to be detected to each API interface to be detected, and obtain a response result; if it is determined that the status code in the response result exists in the preset status code set, then determine each API interface to be detected corresponding to the status code as a shadow API interface. Even if the code is frequently changed and updated, all code bases can be covered by network traffic data; with the help of the trained large language model, obtain each API interface to be detected, and determine whether it is a shadow API interface according to the status code, without the help of code comments or shadow API interfaces clearly stated in the document, thereby improving the efficiency and accuracy of detecting shadow API interfaces. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0028] Figure 1 A schematic diagram of a scenario of a method for detecting a shadow API interface provided in an embodiment of the present application;
[0029] Figure 2 A flowchart of a method for detecting a shadow API interface provided in an embodiment of the present application;
[0030] Figure 3 A schematic diagram of the structure of a detection device for a shadow API interface provided in an embodiment of the present application;
[0031] Figure 4 A schematic diagram of the structure of a server provided in an embodiment of the present application.
[0032] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0033] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0034] Figure 1 A scenario diagram of a method for detecting a shadow API interface provided in an embodiment of the present application, such as Figure 1 As shown, the specific application scenarios of the present application include: management device 101, server 102 and operation and maintenance terminal 103.
[0035] refer to Figure 1 , the management terminal 101 sends the API interface document to the server 102; the server 102 captures the network traffic data and obtains all the API interfaces in the network traffic data; the server 102 forms multiple API interface baselines based on the API interface document and all the API interfaces; any API interface baseline is input into the trained large language model to output multiple API interfaces corresponding to any API interface baseline, and then multiple API interfaces to be detected are determined; the request body of each API interface to be detected is constructed, and the request body of each API interface to be detected is sent to each API interface to be detected to obtain a response result; if the status code in the response result exists in the preset status code set, the API interface to be detected corresponding to the status code is determined as a shadow API interface. The server 102 sends all shadow API interfaces to the operation and maintenance terminal 103 for management.
[0036] Shadow API (Application Programming Interface) refers to an application programming interface that is not formally documented, unofficially released or undisclosed. During the software development process, developers may create temporary API interfaces to test functions. These API interfaces may not be cleaned up after the project is completed, thus becoming shadow API interfaces; these shadow API interfaces not only consume resources, but may also introduce security risks. At present, the existing technology detects shadow API interfaces in the code base through manual code auditing. However, for large and complex applications, with frequent changes and updates to the code, manual code auditing may not cover all code bases, and shadow APIs that are not clearly stated in code comments or documents cannot be discovered through manual code auditing, resulting in reduced efficiency and accuracy in detecting shadow API interfaces.
[0037] In order to solve the above technical problems, the embodiments of the present application propose the following technical ideas: obtain all API interfaces in the network traffic data, and form an API interface baseline based on the API interface documents and all API interfaces; use the trained large language model to obtain multiple API interfaces of any API interface baseline, and then obtain multiple API interfaces to be detected; send the request body of each API interface to be detected to each API interface to be detected to obtain a response result; if it is determined that the status code in the response result exists in the preset status code set, then determine each API interface to be detected corresponding to the status code as a shadow API interface. Even if the code is frequently changed and updated, all code bases can be covered by network traffic data; with the help of the trained large language model, obtain each API interface to be detected, and determine whether it is a shadow API interface based on the status code, without the help of code comments or shadow API interfaces clearly stated in the document, thereby improving the efficiency and accuracy of detecting shadow API interfaces.
[0038] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0039] Figure 2 A flowchart of a method for detecting a shadow API interface provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the method includes:
[0040] S201: Receive an API interface document sent by a management terminal.
[0041] The management terminal exports all publicly available and legal API interface documents from the existing API interface management system, including HTTP methods, request paths, request body templates, and response body examples.
[0042] S202: Capture network traffic data, and obtain all API interfaces in the network traffic data.
[0043] Specifically, use tools to capture network traffic data, filter out HTTP requests from the captured network traffic data, check the request path, method, parameters and response body, and identify and obtain API interfaces in the network traffic data.
[0044] Optionally, network traffic data can be captured using network packet capture tools, API gateway logs, and application server access logs.
[0045] S203: Form multiple API interface baselines based on the API interface document and all API interfaces.
[0046] Among them, the API interface baseline refers to the known and legal API interface calling pattern, including but not limited to the API interface HTTP method, request path, request body and response body.
[0047] Specifically, all API interfaces are deduplicated to obtain multiple deduplicated API interfaces; the API interface document is merged with the same API interfaces in the multiple deduplicated API interfaces to form multiple API interface baselines.
[0048] Specifically, the API interfaces that exist in both the API interface document and the multiple API interfaces after deduplication are merged.
[0049] For example, the baseline API interface is:
[0050] Interface Name: List Devices
[0051] Application: console-dmp.cuiot.cn
[0052] Interface: / dmp-web / dmp-device / device / listDevices
[0053] Request method: GET
[0054] Interface Description: Get device list
[0055] Request parameters:
[0056] •page (optional, int): paging page number, default is 1.
[0057] •size (optional, int): The number of devices to display per page, the default is 10
[0058] •status (optional, string): device status, such as "online", "offline". The default is to query all statuses.
[0059] Request header:
[0060] •Content-Type:application / json
[0061] Optionally, new API interfaces may be added and old API interfaces may be deprecated. Therefore, the API interface baseline needs to be updated regularly to ensure its accuracy and completeness.
[0062] S204: Input any API interface baseline into the trained large language model to output multiple API interfaces corresponding to any API interface baseline.
[0063] Optionally, a trained large language model (LLM) is used to infer any API interface baseline from aspects such as interface request method, interface naming pattern and structure, business logic relationship and version number, so as to output multiple API interfaces.
[0064] For example, for the API interface baseline "GET / dmp-web / dmp-device / device / get", the trained large language model infers other possible HTTP operations such as POST, PUT and DELETE, such as:
[0065] Create a device: POST / dmp-web / dmp-device / device / create
[0066] Device login: POST / dmp-web / dmp-device / device / login
[0067] Device logout: POST / dmp-web / dmp-device / device / logout
[0068] Active devices: GET / dmp-web / dmp-device / device / active
[0069] Inactive devices: GET / dmp-web / dmp-device / device / inactive
[0070] Device list v1: / v1 / dmp-web / dmp-device / device / listDevices
[0071] Device list v2: / v2 / dmp-web / dmp-device / device / listDevices
[0072] Device Commands:
[0073] GET / dmp-web / dmp-device / device / {DeviceKey} / commands
[0074] Device logs: GET / dmp-web / dmp-device / device / {DeviceKey} / logs
[0075] Filter devices by organization:
[0076] GET / dmp-web / dmp-device / device?org={orgName}
[0077] Search for a device by name:
[0078] GET / dmp-web / dmp-device / device?search={DeviceName}
[0079] In this embodiment, assuming that v2 is the current version, then v1 and earlier versions may be shadow API interfaces, such as:
[0080] v1 device list: / v1 / dmp-web / dmp-device / device / listDevices
[0081] v0.1 device creation: POST / v0.1 / dmp-web / dmp-device / device
[0082] v0.2 Device Updates:
[0083] PUT / v0.2 / dmp-web / dmp-device / device / {DeviceKey}
[0084] v0.3 Device removal:
[0085] DELETE / v0.3 / dmp-web / dmp-device / device / {DeviceKey}
[0086] S205: Determine multiple API interfaces to be detected based on the network traffic data and multiple API interfaces.
[0087] The multiple API interfaces include multiple API interfaces containing dynamic parameters and multiple API interfaces not containing dynamic parameters.
[0088] Specifically: step S205 includes S2051~S2053:
[0089] S2051: Obtaining, from the network traffic data, dynamic parameter values corresponding to the dynamic parameters in each API interface containing dynamic parameters.
[0090] Exemplarily, the dynamic parameter in "GET / dmp-web / dmp-device / device / {DeviceKey} / logs" is {DeviceKey}, and the real value of {DeviceKey}, such as A123456789, is obtained from the network traffic data. Based on A123456789, the dynamic parameter set {DeviceKey}={A123456789, B123456789, C123456789} is generated as the dynamic parameter value of the dynamic parameter.
[0091] S2052: Replace the dynamic parameters in each API interface containing the dynamic parameter with the dynamic parameter value, and obtain each API interface having the dynamic parameter value.
[0092] Exemplarily, the API interfaces with dynamic parameter values are as follows:
[0093] GET / dmp-web / dmp-device / device / A123456789 / logs
[0094] GET / dmp-web / dmp-device / device / B123456789 / logs
[0095] GET / dmp-web / dmp-device / device / C123456789 / logs
[0096] S2053: Determine all API interfaces with dynamic parameter values and multiple API interfaces without dynamic parameters as multiple API interfaces to be detected.
[0097] S206: construct a request body for each API interface to be detected, and send the request body for each API interface to be detected to each API interface to be detected to obtain a response result; wherein the response result includes a status code.
[0098] In this embodiment, the construction process includes necessary HTTP methods, URL paths, request headers and request bodies. Optionally, the request body can be constructed by commands, such as curl commands.
[0099] S207: Determine whether the status code exists in the preset status code set.
[0100] S208: If it is determined that the status code exists in the preset status code set, each to-be-detected API interface corresponding to the status code is determined as a shadow API interface.
[0101] Specifically, the status codes in the preset status code set include: 200, 201, 202, 204, 301, 302, 304 and 405.
[0102] Among them, 200 means that the request has been successful, and the response expected by the request has been presented in the return body; 201 means that a new resource has been created through a POST or PUT request; 202 means that the request has been accepted but has not been processed yet. This does not mean that the request has been successful, but at least it confirms that the API interface is valid; 204 has successfully processed the request, but no content has been returned; 301 and 302 mean that the resource has been moved to a new location, but both status codes indicate that the original URL once existed and can now be found through the URL in the Location header; 304 means that when using conditional GET, such as with If-Modified-Since or If-None-Match headers, this status code will be returned if the resource has not been modified since the last request. This also indicates that the API interface exists; 405 means that the API interface exists, but when the HTTP request method is not allowed, the status code returned is 405, which also indicates that the API exists.
[0103] In summary, all API interfaces in the network traffic data are obtained, and an API interface baseline is formed according to the API interface documents and all API interfaces; multiple API interfaces of any API interface baseline are obtained by using the trained large language model, and then multiple API interfaces to be detected are obtained; the request body of each API interface to be detected is sent to each API interface to be detected to obtain a response result; if it is determined that the status code in the response result exists in the preset status code set, then each API interface to be detected corresponding to the status code is determined as a shadow API interface. Even if the code is frequently changed and updated, all code bases can be covered by network traffic data; with the help of the trained large language model, each API interface to be detected is obtained, and whether it is a shadow API interface is determined according to the status code, without the help of code comments or shadow API interfaces clearly stated in the document, thereby improving the efficiency and accuracy of detecting shadow API interfaces.
[0104] On the basis of the above embodiment, all shadow API interfaces are saved in the shadow API interface management ledger; the shadow API interface management ledger is sent to the operation and maintenance terminal, so that the operation and maintenance terminal manages according to the shadow API interface management ledger.
[0105] Specifically, the shadow API interface can be sent via wireless communication or via wired communication.
[0106] In summary, saving the confirmed shadow API interface to the shadow API interface management ledger can achieve dynamic updates, reduce the workload of manual maintenance, and ensure the comprehensiveness and real-time nature of the shadow API interface.
[0107] Based on the above embodiment, in this embodiment, the process of training a large language model is introduced, which is described in detail as follows:
[0108] S301: Acquire API specification interface naming information and an API specification interface naming example set.
[0109] Optionally, obtain RESTful standard interface naming information and a set of RESTful standard interface naming examples.
[0110] S302: Use the API standard interface naming information and the API standard interface naming example set as the first standard interface naming training set.
[0111] S303: Obtain a second standard interface naming training set according to the API interface document and all API interfaces.
[0112] Specifically, based on the API interface document and all API interfaces, a large number of API interface naming instances and corresponding descriptions or functional specifications are obtained as the second standard interface naming training set.
[0113] S304: According to the first standard interface naming training set and the second standard interface naming training set, the first large language model is trained on standard interface naming to obtain a second large language model.
[0114] In this embodiment, the rules for training through the first standard interface naming mainly include:
[0115] a. Use nouns to express resources, and use plural nouns to express resource collections, such as / users to express a user resource collection. A single resource is accessed by ID, such as / users / {userId}.
[0116] b. Avoid using verbs in the interface, and use HTTP methods to express operations on resources, such as GET for reading, POST for creating, PUT or PATCH for updating, and DELETE for deleting.
[0117] S305: Obtain a dynamic parameter training set according to the API interface document and all API interfaces.
[0118] Specifically, use the API interface documents and all API interfaces to identify dynamic parameters, obtain the common points and change patterns of these dynamic parameters, such as whether the dynamic parameters are related to the timestamp, the user identity or session ID, the operation or data ID, etc., and use these dynamic parameters as the dynamic parameter training set.
[0119] S306: According to the dynamic parameter training set, the second largest language model is trained with dynamic parameters to obtain a trained large language model.
[0120] In summary, by conducting standardized interface naming and dynamic parameter training, a model for inferring API interface baselines is established, and multiple API interfaces corresponding to each API interface baseline are output, providing data support for subsequent shadow API interface detection and management.
[0121] Figure 3 A schematic diagram of the structure of a detection device for a shadow API interface provided in an embodiment of the present application is shown in FIG. Figure 3 As shown, the shadow API interface detection device provided in this embodiment includes: a receiving module 301, a capturing module 302, an acquiring module 303, an output module 304, a determining module 305, a constructing module 306, a judging module 307 and a determining module 308.
[0122] The receiving module 301 is used to receive the API interface document sent by the management terminal.
[0123] The capture module 302 is used to capture network traffic data and obtain all API interfaces in the network traffic data.
[0124] The acquisition module 303 is used to form multiple API interface baselines according to the API interface document and all API interfaces.
[0125] The output module 304 is used to input any API interface baseline into the trained large language model to output multiple API interfaces corresponding to any API interface baseline.
[0126] The determination module 305 is used to determine multiple API interfaces to be detected according to the network traffic data and multiple API interfaces.
[0127] The construction module 306 is used to construct the request body of each API interface to be detected, and send the request body of each API interface to be detected to each API interface to be detected to obtain a response result; wherein the response result includes a status code.
[0128] The judging module 307 is used to judge whether the status code exists in the preset status code set.
[0129] The determination module 308 is used to determine each to-be-detected API interface corresponding to the status code as a shadow API interface if the status code is determined to exist in the preset status code set.
[0130] In a possible implementation, the detection device for the shadow API interface also includes: a training module, used to obtain API standard interface naming information and an API standard interface naming example set; using the API standard interface naming information and the API standard interface naming example set as a first standard interface naming training set; obtaining a second standard interface naming training set based on the API interface document and all API interfaces; training the first large language model for standard interface naming based on the first standard interface naming training set and the second standard interface naming training set to obtain a second large language model; obtaining a dynamic parameter training set based on the API interface document and all API interfaces; training the second large language model for dynamic parameters based on the dynamic parameter training set to obtain a trained large language model.
[0131] In a possible implementation, the acquisition module 303 is specifically used to: deduplicate all API interfaces to obtain multiple deduplicated API interfaces; merge the API interface document with the same API interfaces in the multiple deduplicated API interfaces to form multiple API interface baselines.
[0132] In one possible implementation, the multiple API interfaces include multiple API interfaces containing dynamic parameters and multiple API interfaces that do not contain dynamic parameters; accordingly, the determination module 305 is specifically used to: obtain dynamic parameter values corresponding to dynamic parameters in each API interface containing dynamic parameters from network traffic data; replace the dynamic parameters in each API interface containing dynamic parameters with the dynamic parameter values to obtain each API interface with dynamic parameter values; determine all API interfaces with dynamic parameter values and multiple API interfaces that do not contain dynamic parameters as multiple API interfaces to be detected
[0133] In a possible implementation, the shadow API interface detection device also includes: a sending module, used to save all shadow API interfaces to a shadow API interface management ledger; and send the shadow API interface management ledger to an operation and maintenance terminal so that the operation and maintenance terminal manages them according to the shadow API interface management ledger.
[0134] The shadow API interface detection device provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be described in detail here.
[0135] Figure 4 This is a schematic diagram of the structure of the server provided in the embodiment of the present application. Figure 4 As shown, the server provided in this embodiment includes: at least one processor 401 and a memory 402. Optionally, the device 40 further includes a communication component 403. The processor 401, the memory 402 and the communication component 403 are connected via a bus 404.
[0136] In a specific implementation process, at least one processor 401 executes the computer-executable instructions stored in the memory 402, so that at least one processor 401 executes the above method.
[0137] The specific implementation process of the processor 401 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.
[0138] In the above embodiments, it should be understood that the processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the invention can be directly implemented as a hardware processor, or can be implemented by a combination of hardware and software modules in the processor.
[0139] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (NVM), such as at least one disk storage.
[0140] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of this application is not limited to only one bus or one type of bus.
[0141] The present application also provides a computer program product, including a computer program, which implements the above method when executed by a processor.
[0142] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the above method is implemented.
[0143] The above-mentioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0144] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (Application Specific Integrated Circuits, referred to as: ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.
[0145] The division of units is only a logical function division, and there may be other divisions in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.
[0146] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0147] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0148] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0149] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0150] Finally, it should be noted that those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention, which follow the general principles of the present invention and include common knowledge or customary technical means in the art not disclosed by the present invention, are not limited to the precise structure described above and shown in the drawings, and may be modified and changed in various ways without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
Claims
1. A method for detecting a shadow API interface, characterized in that: Applicable to servers, including: Receive API interface documents sent by the management terminal; Capturing network traffic data and obtaining all API interfaces in the network traffic data; According to the API interface document and all the API interfaces, a plurality of API interface baselines are formed; Input any API interface baseline into the trained large language model to output multiple API interfaces corresponding to the any API interface baseline; Determine a plurality of API interfaces to be detected according to the network traffic data and the plurality of API interfaces; Constructing a request body of each API interface to be detected, and sending the request body of each API interface to be detected to each API interface to be detected, to obtain a response result; wherein the response result includes a status code; Determine whether the status code exists in a preset status code set; If it is determined that the status code exists in the preset status code set, each to-be-detected API interface corresponding to the status code is determined as a shadow API interface.
2. The method according to claim 1, characterized in that After forming multiple API interface baselines, the following is also included: Get API specification interface naming information and API specification interface naming example set; The API standard interface naming information and the API standard interface naming example set are used as a first standard interface naming training set; According to the API interface document and all the API interfaces, a second standard interface naming training set is obtained; According to the first standard interface naming training set and the second standard interface naming training set, the first large language model is trained on standard interface naming to obtain a second large language model; According to the API interface document and all the API interfaces, a dynamic parameter training set is obtained; According to the dynamic parameter training set, dynamic parameter training is performed on the second large language model to obtain a trained large language model.
3. The method according to claim 1, characterized in that: The forming of multiple API interface baselines according to the API interface document and all the API interfaces includes: Deduplication is performed on all the API interfaces to obtain multiple deduplicated API interfaces; The API interface document is merged with the same API interface in the multiple API interfaces after deduplication to form the multiple API interface baselines.
4. The method according to claim 1, characterized in that: The multiple API interfaces include multiple API interfaces containing dynamic parameters and multiple API interfaces not containing dynamic parameters; Accordingly, the determining of multiple API interfaces to be detected based on the network traffic data and the multiple API interfaces includes: Obtaining, from the network traffic data, dynamic parameter values corresponding to the dynamic parameters in each API interface containing dynamic parameters; Replace the dynamic parameters in the API interfaces containing the dynamic parameters with the dynamic parameter values to obtain the API interfaces containing the dynamic parameter values; All API interfaces with dynamic parameter values and the multiple API interfaces that do not contain dynamic parameters are determined as the multiple API interfaces to be detected.
5. The method according to any one of claims 1 to 4, characterized in that: After determining each to-be-detected API interface corresponding to the status code as a shadow API interface, the method further includes: Save all shadow API interfaces to the shadow API interface management ledger; The shadow API interface management ledger is sent to the operation and maintenance terminal, so that the operation and maintenance terminal performs management according to the shadow API interface management ledger.
6. A detection device for a shadow API interface, characterized in that: Applicable to servers, including: The receiving module is used to receive the API interface document sent by the management terminal; A capture module is used to capture network traffic data and obtain all API interfaces in the network traffic data; An acquisition module, used to form multiple API interface baselines according to the API interface document and all the API interfaces; An output module, used to input any API interface baseline into the trained large language model to output multiple API interfaces corresponding to the any API interface baseline; A determination module, used to determine a plurality of API interfaces to be detected according to the network traffic data and the plurality of API interfaces; A construction module, used for constructing a request body of each API interface to be detected, and sending the request body of each API interface to be detected to each API interface to be detected to obtain a response result; wherein the response result includes a status code; A judging module, used to judge whether the status code exists in a preset status code set; The determination module is used to determine each to-be-detected API interface corresponding to the status code as a shadow API interface if it is determined that the status code exists in a preset status code set.
7. The device according to claim 6, characterized in that The device also includes a training module, which is used to obtain API standard interface naming information and an API standard interface naming example set; and use the API standard interface naming information and the API standard interface naming example set as a first standard interface naming training set; According to the API interface document and all the API interfaces, a second standard interface naming training set is obtained; according to the first standard interface naming training set and the second standard interface naming training set, the first large language model is trained on standard interface naming to obtain a second large language model; according to the API interface document and all the API interfaces, a dynamic parameter training set is obtained; according to the dynamic parameter training set, the second large language model is trained on dynamic parameters to obtain a trained large language model.
8. A server, characterized in that: include: Memory, processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 5.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 5 when executed by a processor.
10. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 5 when being executed by a processor.
Citation Information
Patent Citations
Interface testing method, interface testing device, electronic device and storage medium
CN109446071A
Private API detection method for IOS application, terminal and storage medium
CN110059485A
Object vulnerability detection method and device, medium and electronic equipment
CN111435393A
Method and device for identifying application program interface (API)
CN115242434A
Web application API sensitive data risk monitoring method and system
CN116132119A
Cited By
Interface traversal method and system based on multi-dimensional flow analysis and intelligent fuzzy testing
CN122086786A
