Interface matching method, device and equipment based on different data sources
By obtaining traffic packets of the API interface from different data sources, extracting and parsing request response messages, and generating high-dimensional feature vectors, the complexity of API interface management in the existing technology is solved, and the accurate identification and management of API interfaces is realized.
Patent Information
- Application Number
- CN202411601066.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-11
- Publication Date
- 2025-02-18
AI Technical Summary
It is difficult for the prior art to accurately identify and manage a large number of changes in API interfaces, resulting in complex management of API interfaces, and simple string matching or fixed rule comparison cannot achieve accurate recognition.
By obtaining traffic data packets of the API interface from different data sources, extracting request messages and response messages, parsing the list of request and response parameter names, performing feature extraction and fusion, generating high-dimensional feature vectors, and filtering out similar APIs based on multi-dimensional feature similarity Interface combination.
It improves the recognition accuracy of API interfaces, realizes accurate recognition of similar API interfaces, and simplifies API interface management.
Smart Images

Figure CN119474908A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, in particular to the field of big data processing technology, and in particular to an interface matching method, device and equipment based on different data sources. Background Art
[0002] With the continuous development of computer technology and software development technology, in order to meet the various needs of users, the functions of application programs are becoming more and more diversified. In the process of application development, in order to improve the encapsulation and portability, application programs usually use the form of application programming interface (API) to provide external services and function access. Accordingly, a large number of APIs have been generated on the Internet for different functions, development platforms and programming languages.
[0003] In modern enterprises, internal projects are complicated, a large number of API interfaces change every day, and a large amount of API interface information is generated, which makes the management of API interfaces more and more complicated. In order to identify similar API interfaces from a large amount of API interface information, the relevant technology usually adopts simple string matching or comparison methods based on fixed rules, which cannot achieve accurate identification of similar API interfaces. Summary of the invention
[0004] In view of this, the embodiments of the present application provide an interface matching method, apparatus, device, medium and product based on different data sources, which can improve the recognition accuracy of similar API interfaces based on the multi-dimensional features of the API interface.
[0005] In the first aspect, an embodiment of the present application provides an interface matching method based on different data sources, the method comprising: obtaining N traffic data packets of N API interfaces from different data sources; for each API interface, extracting request messages and response messages from the traffic data packets, and parsing the request messages and response messages to obtain a request parameter name list corresponding to the request message, and a response parameter name list corresponding to the response message; performing feature extraction on the request parameter name list and the response parameter name list respectively to obtain a request feature vector and a response feature vector, and performing feature vector fusion on the request feature vector and the response feature vector to obtain a high-dimensional feature vector corresponding to the API interface; based on the multi-dimensional feature similarity between the high-dimensional feature vectors of any two API interfaces, screening to obtain multiple pairs of API interface combinations whose multi-dimensional feature similarity is greater than a preset similarity threshold.
[0006] In some implementation methods of the first aspect, the request parameter name list includes a first parameter name list and a second parameter name list, the response parameter name list includes a third parameter name list and a fourth parameter name list, and the request message and the response message are parsed to obtain a request parameter name list corresponding to the request message and a response parameter name list corresponding to the response message, including: parsing the request header of the request message line by line, extracting all parameter names contained in the request header, and obtaining a first parameter name list; parsing the request body of the request message, extracting all parameter names contained in the request body, and obtaining a second parameter name list; parsing the response header of the response message, extracting all parameter names contained in the response header, and obtaining a third parameter name list; parsing the response body of the response message, extracting all parameter names contained in the response body, and obtaining a fourth parameter name list.
[0007] In some implementable methods of the first aspect, the request feature vector includes a request header vector and a request body vector, the response feature vector includes a response header vector and a response body vector, and feature extraction is performed on the request parameter name list and the response parameter name list respectively to obtain the request feature vector and the response feature vector, including: based on the Word2Vec model, feature extraction is performed on all parameter names in the first parameter name list, the second parameter name list, the third parameter name list, and the fourth parameter name list respectively to obtain the feature vector corresponding to each parameter name; weighted averaging is performed on the feature vectors corresponding to all parameter names in the first parameter name list to obtain the request header vector; weighted averaging is performed on the feature vectors corresponding to all parameter names in the second parameter name list to obtain the request body vector; weighted averaging is performed on the feature vectors corresponding to all parameter names in the third parameter name list to obtain the response header vector; weighted averaging is performed on the feature vectors corresponding to all parameter names in the fourth parameter name list to obtain the response body vector.
[0008] In some implementations of the first aspect, before performing feature extraction on the request parameter name list and the response parameter name list respectively, the method further includes: assigning a weight value to each parameter name in the second parameter name list based on the hierarchical depth of all parameter names in the second parameter name list in the request body; assigning a weight value to each parameter name in the fourth parameter name list based on the hierarchical depth of all parameter names in the fourth parameter name list in the response body; wherein the weight value is negatively correlated with the hierarchical depth.
[0009] In some implementations of the first aspect, corresponding weight values of parameter names in the request body and the response body are higher than corresponding weight values of parameter names in the request header and the response header.
[0010] In some implementable embodiments of the first aspect, after screening and obtaining multiple pairs of API interface combinations whose first similarity is greater than a first similarity threshold, the method also includes: for each pair of API interface combinations, based on the URL path and parameter name in the traffic data packet of the API interface, searching in the interface document platform and the code hosting repository to obtain text description information and code information matching the API interface; using a large language model to perform semantic analysis on the text description information and code information of the API interface, and converting the text description information and code information into semantic vectors; based on the semantic vectors of the two API interfaces in each pair of API interface combinations, calculating the semantic similarity of each pair of API interface combinations; performing weighted summation of the semantic similarity and multi-dimensional feature similarity of each pair of API interface combinations to obtain a comprehensive similarity score; identifying the API interface combinations whose comprehensive similarity scores are greater than the target scores as the same API interface.
[0011] In some implementations of the first aspect, the various different data sources include edge traffic devices, interactive security detection devices, interface document platforms, log management systems, and API gateways.
[0012] In some implementation methods of the first aspect, after obtaining N traffic data packets of N API interfaces from different data sources, the method also includes: parsing the traffic data packets to obtain response time information, data type information and association relationship information, wherein the association relationship information is used to characterize the association relationship between the response host address and the configuration management database; performing feature extraction on the response time information, data type information and association relationship information respectively to obtain three feature vectors; and fusing the three feature vectors into a high-dimensional feature vector.
[0013] In the second aspect, an embodiment of the present application provides an interface matching device based on different data sources, the device comprising: an acquisition module, used to acquire N traffic data packets of N API interfaces from different data sources; a parsing module, used to extract request messages and response messages from the traffic data packets for each API interface, and parse the request messages and response messages to obtain a request parameter name list corresponding to the request message, and a response parameter name list corresponding to the response message; a feature extraction and fusion module, used to perform feature extraction on the request parameter name list and the response parameter name list respectively to obtain a request feature vector and a response feature vector, and perform feature vector fusion on the request feature vector and the response feature vector to obtain a high-dimensional feature vector corresponding to the API interface; an interface matching module, used to screen out multiple pairs of API interface combinations whose multi-dimensional feature similarity is greater than a preset similarity threshold based on the multi-dimensional feature similarity between the high-dimensional feature vectors of any two API interfaces.
[0014] In some implementation methods of the second aspect, the request parameter name list includes a first parameter name list and a second parameter name list, the response parameter name list includes a third parameter name list and a fourth parameter name list, and the parsing module is specifically used to: parse the request header of the request message line by line, extract all parameter names contained in the request header, and obtain a first parameter name list; parse the request body of the request message, extract all parameter names contained in the request body, and obtain a second parameter name list; parse the response header of the response message, extract all parameter names contained in the response header, and obtain a third parameter name list; parse the response body of the response message, extract all parameter names contained in the response body, and obtain a fourth parameter name list.
[0015] In some implementation methods of the second aspect, the request feature vector includes a request header vector and a request body vector, the response feature vector includes a response header vector and a response body vector, and the feature extraction and fusion module is specifically used to: based on the Word2Vec model, perform feature extraction on all parameter names in the first parameter name list, the second parameter name list, the third parameter name list, and the fourth parameter name list to obtain a feature vector corresponding to each parameter name; perform weighted averaging on the feature vectors corresponding to all parameter names in the first parameter name list to obtain a request header vector; perform weighted averaging on the feature vectors corresponding to all parameter names in the second parameter name list to obtain a request body vector; perform weighted averaging on the feature vectors corresponding to all parameter names in the third parameter name list to obtain a response header vector; perform weighted averaging on the feature vectors corresponding to all parameter names in the fourth parameter name list to obtain a response body vector.
[0016] In some implementations of the second aspect, the device also includes: a weight allocation module, which is used to allocate a weight value to each parameter name in the second parameter name list based on the hierarchical depth of all parameter names in the second parameter name list in the request body before performing feature extraction on the request parameter name list and the response parameter name list respectively; the weight allocation module is also used to allocate a weight value to each parameter name in the fourth parameter name list based on the hierarchical depth of all parameter names in the fourth parameter name list in the response body; wherein the weight value is negatively correlated with the hierarchical depth.
[0017] In some implementations of the second aspect, corresponding weight values of parameter names in the request body and the response body are higher than corresponding weight values of parameter names in the request header and the response header.
[0018] In some possible implementations of the second aspect, the device also includes: a retrieval module, which is used to, after screening to obtain multiple pairs of API interface combinations whose first similarity is greater than a first similarity threshold, for each pair of API interface combinations, search in the interface document platform and the code hosting repository based on the URL path and parameter name in the traffic data packet of the API interface to obtain text description information and code information matching the API interface; a semantic analysis module, which is used to use a large language model to perform semantic analysis on the text description information and code information of the API interface, and convert the text description information and code information into semantic vectors; a similarity calculation module, which is used to calculate the semantic similarity of each pair of API interface combinations based on the semantic vectors of the two API interfaces in each pair of API interface combinations; the similarity calculation module is also used to perform weighted summation of the semantic similarity and multi-dimensional feature similarity of each pair of API interface combinations to obtain a comprehensive similarity score; an interface identification module, which is used to identify the API interface combination whose comprehensive similarity score is greater than the target score as the same API interface.
[0019] In some implementations of the second aspect, the various different data sources include edge traffic devices, interactive security detection devices, interface document platforms, log management systems, and API gateways.
[0020] In some possible implementations of the second aspect, the device also includes: a parsing module, which is used to parse the traffic data packets after obtaining N traffic data packets of N API interfaces from different data sources, and obtain response time information, data type information and association relationship information, wherein the association relationship information is used to characterize the association relationship between the response host address and the configuration management database; a feature extraction module, which is used to extract features of the response time information, data type information and association relationship information respectively, to obtain three feature vectors; and a feature fusion module, which is used to fuse the three feature vectors into a high-dimensional feature vector.
[0021] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the steps of the interface matching method based on different data sources as in the first aspect are implemented.
[0022] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having computer program instructions stored thereon. When the computer program instructions are executed by a processor, the steps of the interface matching method based on different data sources as in the first aspect are implemented.
[0023] In a fifth aspect, an embodiment of the present application provides a computer program product, which is stored in a non-volatile storage medium, and when the computer program product is executed by a processor, implements the steps of the interface matching method based on different data sources as in the first aspect.
[0024] In a sixth aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the steps of the interface matching method based on different data sources as in the first aspect.
[0025] The present application provides an interface matching method, device, equipment, medium and product based on different data sources, which can obtain traffic data packets of API interfaces from various different data sources, and can extract request messages and response messages from each traffic data packet, and obtain a request parameter name list corresponding to the request message and a response parameter name list corresponding to the response message by parsing the request message and the response message. Based on this, by performing feature extraction on the request parameter name list and the response parameter name list respectively, a request feature vector and a response feature vector are obtained, and the request feature vector and the response feature vector are fused to comprehensively extract the multi-dimensional features of the API interface, and the information of the API interface is converted into a high-dimensional feature vector, which can embed text information into the vector space, capture the semantic information and contextual relationship of the API parameters, and therefore, based on the multi-dimensional feature similarity between the high-dimensional feature vectors of any two API interfaces, the similarity judgment between the API interfaces can be made more accurate, and the accurate identification of similar API interfaces is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following briefly introduces the drawings in the embodiments of the present application.
[0027] Figure 1 It is a flowchart of an interface matching method based on different data sources provided in an embodiment of the present application;
[0028] Figure 2 It is a structural diagram of an interface matching device based on different data sources provided in an embodiment of the present application;
[0029] Figure 3 It is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0030] The principles and spirit of the present application will be described below with reference to several exemplary embodiments. It should be understood that the purpose of providing these embodiments is to make the principles and spirit of the present application clearer and more thorough, so that those skilled in the art can better understand and implement the principles and spirit of the present application. The exemplary embodiments provided herein are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments herein, all other embodiments obtained by ordinary technicians of the art without creative work are within the scope of protection of this application.
[0031] In this document, terms such as first, second, third, etc. are only used to distinguish one entity (or operation) from another entity (or operation), but not to require or imply any order or relationship between these entities (or operations).
[0032] The following is a detailed description of the interface matching method based on different data sources provided by the embodiment of the present application through specific embodiments and application scenarios in conjunction with the accompanying drawings.
[0033] Figure 1 It is a flowchart of an interface matching method based on different data sources provided by an embodiment of the present application. The execution subject of the interface matching method based on different data sources can be a server.
[0034] Exemplarily, the server may be a B-end server or a C-end server of an online recruitment platform. The B-end may be an online talent recruitment system, an online application recruitment system, a training system, etc. used by recruitment users, and the C-end may be a job search system for fresh graduates, an online application job search system, a job recommendation system, etc. used by job seekers. In this way, through the interface matching method based on different data sources of this application, similar API interfaces of online recruitment platforms can be effectively identified and matched.
[0035] The following takes the execution subject of the interface matching method based on different data sources as a server as an example to illustrate the interface matching method based on different data sources of the present application. It should be noted that the above execution subject and application scenario do not constitute a limitation on the present application.
[0036] like Figure 1 As shown, the interface matching method based on different data sources provided in the embodiment of the present application may include steps 110 to 140.
[0037] Step 110, obtaining N traffic data packets of N API interfaces from different data sources;
[0038] Step 120: for each API interface, extract the request message and the response message from the traffic data packet, and parse the request message and the response message to obtain a request parameter name list corresponding to the request message and a response parameter name list corresponding to the response message;
[0039] Step 130, feature extraction is performed on the request parameter name list and the response parameter name list respectively to obtain a request feature vector and a response feature vector, and feature vector fusion is performed on the request feature vector and the response feature vector to obtain a high-dimensional feature vector corresponding to the API interface;
[0040] Step 140 , based on the multi-dimensional feature similarity between the high-dimensional feature vectors of any two API interfaces, screen out multiple pairs of API interface combinations whose multi-dimensional feature similarity is greater than a preset similarity threshold.
[0041] The interface matching method based on different data sources provided in the embodiment of the present application can obtain the traffic data packets of the API interface from various different data sources, and can extract the request message and the response message from each traffic data packet, and obtain the request parameter name list corresponding to the request message and the response parameter name list corresponding to the response message by parsing the request message and the response message. Based on this, by performing feature extraction on the request parameter name list and the response parameter name list respectively, the request feature vector and the response feature vector are obtained, and the request feature vector and the response feature vector are fused to comprehensively extract the multi-dimensional features of the API interface, and the information of the API interface is converted into a high-dimensional feature vector, which can embed text information into the vector space, capture the semantic information and contextual relationship of the API parameters, and therefore, based on the multi-dimensional feature similarity between the high-dimensional feature vectors of any two API interfaces, the similarity judgment between the API interfaces can be made more accurate, and the accurate identification of similar API interfaces can be achieved.
[0042] The specific implementation of the above steps will be described in detail below in conjunction with specific embodiments.
[0043] Involving step 110, N traffic data packets of N API interfaces are obtained from different data sources.
[0044] In step 110, the various data sources may include, but are not limited to: edge traffic devices, interactive security detection devices, interface document platforms, log management systems, and API gateways. N is a positive integer, and the traffic data packets of the API interface may come from any data source, which is not specifically limited in this application.
[0045] Specifically, the boundary traffic device can be an enterprise network boundary traffic device. The present application can obtain traffic data packets from the enterprise network boundary traffic device and perform preprocessing to delete sensitive data of actual business; obtain traffic data packets with Mock data from interactive security detection devices in QA testing or pre-release environments; obtain API document information from the unified interface document platform within the enterprise (such as YAPI, Swagger, etc.), and the API document information can also be used as a traffic data packet. The API document information may include request methods, paths, parameters, and other contents.
[0046] In related technologies, many API interfaces lack complete documentation due to the parallel development of new and old projects in enterprises, inconsistent development specifications, and personnel changes. Early development projects do not follow modern development specifications, making interface information difficult to collect and manage.
[0047] Based on this, this application can cover API data from different sources by parsing the traffic data packets of boundary traffic devices and interactive security detection devices, as well as the information in the interface document platform, making up for the identification difficulties caused by missing documents and inconsistent project specifications, and effectively identifying and collecting API interface information within the enterprise. In addition, by obtaining more API call data from the log management system and API gateway, the system can dynamically adapt to different application scenarios and support mixed analysis of real-time data and historical data.
[0048] Involving step 120, for each API interface, the request message and the response message are extracted from the traffic data packet, and the request message and the response message are parsed to obtain a request parameter name list corresponding to the request message and a response parameter name list corresponding to the response message.
[0049] In step 120, after parsing the request message, all parameter names in the request message are extracted and combined to obtain a request parameter name list, wherein the request message includes a request header and a request body; after parsing the response message, all parameter names in the response message are extracted and combined to obtain a response parameter name list, wherein the response message includes a response header and a response body.
[0050] In some embodiments of the present application, the request parameter name list includes a first parameter name list and a second parameter name list, and the response parameter name list includes a third parameter name list and a fourth parameter name list. In the above step 120, the request message and the response message are parsed to obtain a request parameter name list corresponding to the request message and a response parameter name list corresponding to the response message, which may include the following steps:
[0051] Step 1201, parse the request header of the request message line by line, extract all parameter names contained in the request header, and obtain a first parameter name list.
[0052] Specifically, first extract the request method (such as GET, POST) and URL path, analyze the multi-level segmentation path and exclude the influence of the RESTful-style resource ID; then parse the request header parameters, extract the parameter name in the request header, and generate the first parameter name list.
[0053] Exemplarily, the HTTP method is extracted from the request line, such as GET; the URL path is extracted from the request line, such as / api / backend / getLatestNotices; and the protocol version is extracted from the request line, such as HTTP / 2.
[0054] In some embodiments, after extracting the URL path from the request line, the URL path is segmented and parsed into multiple levels of segmented paths, and each level of segmented path is assigned a weight based on the location of each level of segmented path, wherein the later the segmented path is, the greater the corresponding weight.
[0055] Exemplarily, the URL path is split into multiple parts by “ / ” to obtain a path list, such as [api, backend, getLatestNotices], where the weight of api is 0.1; the weight of backend is 0.2; and the weight of getLatestNotices is 0.8.
[0056] In some embodiments, it is determined whether each level of segmentation path contains numbers or strings in a specific format (such as UUID); if so, the segmentation path is identified as a RESTful-style resource ID, and the weight of the segmentation path is adjusted to 0. In this way, the RESTful-style resource ID can be identified and excluded.
[0057] For example, if the path is / api / news / 21455433, 21455433 is identified as a resource ID with a weight of 0.
[0058] In some embodiments of the present application, the present application may assign a lower initial weight to common parameter names in the first parameter name list, and assign a higher initial weight to parameter names other than the common parameter names.
[0059] For example, common parameter names are Host, User-Agent, Accept, etc., where Host: weight 0.1; User-Agent: weight 0.1; Accept: weight 0.1; Accept-Language: weight 0.1; Accept-Encoding: weight 0.1; Referer: weight 0.1; Cookie: weight 0.1;
[0060] Assign higher initial weights to other parameter names (such as sentry-trace, baggage, etc.), for example, sentry-trace: weight 0.5; baggage: weight 0.5; Sec-Fetch-Dest: weight 0.2; Sec-Fetch-Mode: weight 0.2; Sec-Fetch-Site: weight 0.2; TE: weight 0.2.
[0061] Step 1202: parse the request body of the request message, extract all parameter names contained in the request body, and obtain a second parameter name list.
[0062] Exemplarily, the parameter names extracted from the request body may include, but are not limited to: user_id, user_name, email, phone, address, street, city, state, and zip.
[0063] In some embodiments, step 1202 may specifically include: extracting the Content-Type parameter from the request header, performing structural identification based on the Content-type parameter, and determining the structural type of the request body, such as a key-value pair, JSON, XML, etc.; then calling a parsing module associated with the structural type to parse the request body; storing the parsed request body data in the form of a dictionary; traversing the parsed dictionary, extracting all the keys to obtain the parameter names, and for a dictionary with a nested structure, recursively extracting the keys in the nested dictionary to generate a second parameter name list.
[0064] For example, Content-Type is application / json, indicating that the structure type of the request body is in JSON format, and therefore the JSON parsing module is used to parse it and convert it into a dictionary format.
[0065] Step 1203: parse the response header of the response message, extract all parameter names contained in the response header, and obtain a third parameter name list.
[0066] Specifically, the HTTP protocol version and HTTP response code are extracted from the first line of the response header, each field of the response header is traversed, all parameter names are extracted, and a third parameter name list is generated.
[0067] Exemplarily, the parameter names extracted from the response header may include, but are not limited to: server, date, content-type, vary, strict-transport-security, x-frame-options, x-xss-protection, x-content-type-options, set-cookie, content-encoding, and X-Firefox-Spdy.
[0068] Step 1204: parse the response body of the response message, extract all parameter names contained in the response body, and obtain a fourth parameter name list.
[0069] Specifically, the structure type of the response body is determined by analyzing the Content-Type parameter; the parsing module associated with the structure type is called to parse the response body, the parsed response body data is stored in the form of a dictionary, the parsed dictionary is traversed, all keys are extracted to obtain parameter names, and for dictionaries with nested structures, the keys in the nested dictionaries can be recursively extracted to generate a fourth parameter name list.
[0070] Exemplarily, the parameter names extracted from the response body may include, but are not limited to: code, message, data, items, notice_type, update_time, read, alert, content, agent_list, agent_num, auto, host_name, is_global, task_content, task_detail, task_id, task_status, task_type, umid_list, ts, notice.
[0071] In the embodiment of the present application, if two API interfaces are the same, the request parameter names and response parameter names of the two API interfaces will be highly similar. Based on this, the present application can obtain a comprehensive parameter name list of the API interface through detailed analysis of the request header, request body, response header, and response body. The subsequent interface similarity judgment based on the similarity between the parameter name lists is more convincing and can improve the accuracy of the interface similarity judgment.
[0072] In step 130, feature extraction is performed on the request parameter name list and the response parameter name list respectively to obtain a request feature vector and a response feature vector, and feature vector fusion is performed on the request feature vector and the response feature vector to obtain a high-dimensional feature vector corresponding to the API interface.
[0073] In step 130, the request feature vector is obtained by extracting features of all parameter names in the request parameter name list, and the response feature vector is obtained by extracting features of all parameter names in the response parameter name list. The present application can use the Word2Vec model to extract features from the request parameter name list and the response parameter name list, respectively, convert the parameter names in the request parameter name list into a request feature vector, and convert the parameter names in the response parameter name list into a response feature vector. The request feature vector and the response feature vector can be specifically fused by feature concatenation.
[0074] Exemplarily, feature extraction Word2Vec("Host") is performed on the parameter name "Host" through the Word2Vec model to obtain a feature vector [0.25, 0.1, 0.3, ...]; feature extraction Word2Vec("User-Agent") is performed on the parameter name "User-Agent" through the Word2Vec model to obtain a feature vector [0.1, 0.2, 0.15, ...].
[0075] In some embodiments of the present application, the request feature vector may include a request header vector and a request body vector, and the response feature vector may include a response header vector and a response body vector. The above step 130 extracts features from the request parameter name list and the response parameter name list respectively to obtain the request feature vector and the response feature vector, which may specifically include the following steps:
[0076] Step 1301, based on the Word2Vec model, feature extraction is performed on all parameter names in the first parameter name list, the second parameter name list, the third parameter name list, and the fourth parameter name list to obtain a feature vector corresponding to each parameter name;
[0077] Step 1302, performing weighted averaging on the feature vectors corresponding to all parameter names in the first parameter name list to obtain a request header vector;
[0078] Step 1303, performing weighted averaging on the feature vectors corresponding to all parameter names in the second parameter name list to obtain a request body vector;
[0079] Step 1304, performing weighted averaging on the feature vectors corresponding to all parameter names in the third parameter name list to obtain a response header vector;
[0080] Step 1305: perform weighted averaging on the feature vectors corresponding to all parameter names in the fourth parameter name list to obtain a response body vector.
[0081] Specifically, a weighted average is performed on the eigenvectors corresponding to all parameter names. Specifically, a first sum is obtained by weighted summing up the eigenvectors corresponding to all parameter names, a second sum is obtained by weighted summing up the weight values corresponding to all parameter names, and the ratio of the first sum to the second sum is taken as the weighted average result.
[0082] For example, if the first parameter name list contains the parameter names "Host" and "User-Agent", and the corresponding weights are 0.5 and 0.8 respectively, then the corresponding feature vectors of the two parameter names can be weighted averaged to obtain the request header vector
[0083] In an embodiment of the present application, for each parameter name in the request header, request body, response header, and response body, the Word2Vec model is used to generate the feature vector corresponding to each parameter name, and the weighted average method is combined to generate a comprehensive feature vector. This flexible weight adjustment mechanism can be optimized according to the actual application scenario and historical data, so that important parameters are given higher attention in the similarity calculation, and the accuracy of the interface similarity analysis is further improved. For example, the weight information of key parameters is integrated into the feature vector calculation through weighted average, which effectively retains the distinguishing degree of the importance of parameter names, and focuses on the similarity of important parameter names when judging similarity, thereby improving the accuracy of interface similarity judgment.
[0084] The multi-dimensional features extracted from the API interface can not only capture the semantic information of the API parameters, but also make adjustments based on the weights of the features to improve the accuracy of similarity judgment.
[0085] In some embodiments of the present application, before extracting features from the request parameter name list and the response parameter name list, the method may further include the following steps:
[0086] assigning a weight value to each parameter name in the second parameter name list based on the hierarchical depth of all parameter names in the second parameter name list in the request body;
[0087] A weight value is assigned to each parameter name in the fourth parameter name list based on the hierarchical depth of all parameter names in the fourth parameter name list in the response body.
[0088] Among them, the hierarchy depth is determined based on the hierarchical position of the parameter name in the response body, and the weight value is negatively correlated with the hierarchy depth, that is, the deeper the hierarchy depth of the parameter name, the lower the corresponding weight value, and the deeper the hierarchy depth of the parameter name, the higher the corresponding weight value.
[0089] Exemplarily, the fourth parameter name list corresponding to the response body includes three hierarchical depths, where the first layer includes code and message, with corresponding weights of 0.9 and 0.8 respectively; the second layer includes items, notice_type, update_time, read, and alert, with corresponding weights of 0.7; the third layer includes agent_list, agent_num, auto, host_name, is_global, task_content, task_detail, task_id, task_status, task_type, and umid_list, with corresponding weights of 0.6.
[0090] In the embodiment of the present application, the parameter names of the deep structure are obtained by subdividing the parameter names of the shallow structure. Therefore, the parameter names of the shallow structure are equivalent to a large category, and their importance is higher than that of the parameter names obtained after subdivision. Based on this, higher weight values are assigned to parameter names with lower hierarchy depth, which can effectively retain the distinction of the importance of parameter names, and focus on the similarity of the large category of parameter names when judging similarity, thereby improving the accuracy of interface similarity judgment.
[0091] In some embodiments of the present application, the corresponding weight values of the parameter names in the request body and the response body are higher than the corresponding weight values of the parameter names in the request header and the response header.
[0092] Exemplarily, the weight allocation example of the parameter names extracted from the request header is: Host: weight 0.1; User-Agent: weight 0.1; Accept: weight 0.1; Accept-Language: weight 0.1; Accept-Encoding: weight 0.1; Referer: weight 0.1; Cookie: weight 0.1; sentry-trace: weight 0.5; baggage: weight 0.5; Sec-Fetch-Dest: weight 0.2; Sec-Fetch-Mode: weight 0.2; Sec-Fetch-Site: weight 0.2; TE: weight 0.2.
[0093] An example of weight assignment for parameter names extracted from the request body: user_id: weight 0.9; user_name: weight 0.8; email: weight 0.8; phone: weight 0.7; address: weight 0.5; street: weight 0.5; city: weight 0.5; state: weight 0.5; zip: weight 0.5.
[0094] An example of weight allocation for parameter names extracted from the response header: server: weight 0.1; date: weight 0.1; content-type: weight 0.2; vary: weight 0.1; strict-transport-security: weight 0.1; x-frame-options: weight 0.1; x-xss-protection: weight 0.1; x-content-type-options: weight 0.1; set-cookie: weight 0.1; content-encoding: weight 0.1; X-Firefox-Spdy: weight 0.1.
[0095] Example of weight allocation for parameter names extracted from the response body: code: weight 0.9; message: weight 0.8; data: weight 0.5; items: weight 0.5; notice_type: weight 0.7; update_time: weight 0.7; read: weight 0.7; alert: weight 0.7; content: weight 0.5; agent_list: weight 0.6; agent_num: weight 0.6; auto: weight 0.6; host_name: weight 0.6; is_global: weight 0.6; task_content: weight 0.6; task_detail: weight 0.6; task_id: weight 0.6; task_status: weight 0.6; task_type: weight 0.6; umid_list: weight 0.6; ts: weight 0.5; notice: weight 0.5.
[0096] In the embodiment of the present application, the distinction of the importance of parameter names is effectively retained, and the similarity of the parameter names in the request body and the response body is emphasized when judging the similarity, thereby improving the accuracy of interface similarity judgment.
[0097] In step 140, based on the multi-dimensional feature similarity between the high-dimensional feature vectors of any two API interfaces, multiple pairs of API interface combinations whose multi-dimensional feature similarity is greater than a preset similarity threshold are screened.
[0098] In step 140, the similarity between the two high-dimensional feature vectors can be calculated using a cosine similarity algorithm, a Jaccard similarity coefficient, an Euclidean distance, etc. to obtain a multi-dimensional feature similarity. The preset similarity threshold can be set according to specific needs, for example, to 0.8, 0.85, 0.9 or other values, and this application does not make specific limitations on this.
[0099] As an example, if the cosine similarity algorithm is used to calculate the multidimensional feature similarity, the vector dot product and vector modulus between two high-dimensional feature vectors are first calculated, and then the cosine similarity is calculated based on the vector dot product and vector modulus. The cosine similarity is the multidimensional feature similarity.
[0100] In some embodiments of the present application, in order to further improve the accuracy of determining similar API interfaces, after screening and obtaining multiple pairs of API interface combinations whose first similarity is greater than the first similarity threshold in the above step 140, the method may further include the following steps:
[0101] For each pair of API interface combinations, based on the URL path and parameter name in the traffic data packet of the API interface, a search is performed in the interface document platform and the code hosting repository to obtain text description information and code information matching the API interface;
[0102] Use a large language model to perform semantic analysis on the text description information and code information of the API interface, and convert the text description information and code information into semantic vectors;
[0103] Based on the semantic vectors of the two API interfaces in each pair of API interface combinations, the semantic similarity of each pair of API interface combinations is calculated;
[0104] The semantic similarity and multi-dimensional feature similarity of each pair of API interface combinations are weighted and summed to obtain a comprehensive similarity score;
[0105] API interface combinations whose comprehensive similarity scores are greater than the target score are identified as the same API interface.
[0106] Specifically, by parsing the comment information and interface definition information in the code information, some text description information can also be obtained. By combining the text description information extracted from the interface document platform with the text description information obtained by parsing the code information, API description information can be obtained. The API description information includes the functional description of the API interface, parameter meaning information, response structure information, etc.
[0107] Exemplarily, API-A describes: obtaining the latest notification, including notification type, update time, reading status, etc.; API-B describes: obtaining the most recent system message, including message type, etc.
[0108] The target score can be set according to specific needs, for example, to 0.8, 0.85, 0.9 or other values, and this application does not make specific limitations on this.
[0109] Specifically, the comprehensive similarity score final_similarity can be calculated using the following formula:
[0110] final_similarity=α·cosine_similarity+β·semantic_similarity
[0111] Among them, α and β are weight parameters corresponding to feature similarity and semantic similarity respectively, which can be set according to specific needs. For example, the weights α=0.5 and β=0.5 can be set.
[0112] In this way, after initially screening out API interface combinations with similar multi-dimensional features based on high-dimensional feature vectors, the text description, parameter meaning and response structure of the API interface are deeply analyzed by analyzing the text description and code information of the API interface to provide more accurate semantic similarity. Combining the semantic similarity with the feature similarity, and judging whether the traffic data packets of different data sources are the same API interface through comprehensive similarity calculation, can effectively combine the structural features and semantic information of the API, overcome the shortcomings of traditional methods in semantic understanding and contextual relationship processing, and effectively improve the accuracy of the judgment effect of API interface similarity.
[0113] In some embodiments, after the above steps, API pairs with higher comprehensive similarity scores can be output as potential similar APIs for further verification by subsequent business systems, and an API similarity analysis report can be generated, including detailed feature comparisons and similarity scores.
[0114] In some embodiments, the present application may adjust feature weights and similarity thresholds based on historical data and feedback, and periodically update the vector generation model and LLM model to maintain the accuracy of the analysis.
[0115] In some embodiments, the present application may use more machine learning models (such as support vector machines, random forests) to optimize the calculation of the comprehensive similarity score and adjust the model selection according to the specific application scenario.
[0116] In some embodiments of the present application, after the above step 140 obtains N traffic data packets of N API interfaces from different data sources, the method may further include the following steps:
[0117] Parsing the traffic data packets to obtain response time information, data type information, and association information, wherein the association information is used to characterize the association between the answering host address and the configuration management database;
[0118] Feature extraction is performed on response time information, data type information and association relationship information respectively to obtain three feature vectors;
[0119] The three feature vectors are fused into a high-dimensional feature vector.
[0120] Specifically, the three feature vectors can be concatenated with the high-dimensional feature vector.
[0121] In this way, more feature dimensions can be added on the basis of high-dimensional feature dimensions, such as response time, data type, response host address and the relationship between the CMDB database, to improve the richness and expression ability of the feature vector, improve the accuracy and scope of application of the analysis, and then further improve the accuracy of similarity calculation when calculating the similarity of the API interface based on the fused high-dimensional feature vector. Moreover, this flexible scalability enables the present invention to continuously adapt to new needs and technological developments and maintain the long-term effectiveness of the system.
[0122] As a specific example, in step 140, the multidimensional feature similarity between the high-dimensional feature vectors of any two API interfaces can be calculated based on the cosine similarity algorithm, and multiple pairs of API interface combinations whose multidimensional feature similarity is greater than a preset similarity threshold are screened; and after step 140, for each pair of API interface combinations, based on the URL path and parameter name in the traffic data packet of the API interface, a search is performed in the interface document platform and the code hosting repository to obtain text description information and code information matching the API interface; the text description information and code information of the API interface are semantically analyzed using a large language model, and the text description information and code information are converted into semantic vectors; based on the semantic vectors of the two API interfaces in each pair of API interface combinations, the semantic similarity of each pair of API interface combinations is calculated; the semantic similarity and multidimensional feature similarity of each pair of API interface combinations are weightedly summed to obtain a comprehensive similarity score; and the API interface combinations whose comprehensive similarity scores are greater than the target scores are identified as the same API interface.
[0123] In this way, by combining cosine similarity and semantic analysis of large language models, high-precision similarity analysis of APIs can be achieved. Cosine similarity is used to preliminarily screen API pairs to ensure that the screened API pairs have high structural similarity; while LLM further analyzes the text description, parameter meaning, and response structure of the API from a semantic level to provide a more complete and accurate similarity score. This combination not only improves the accuracy of similarity analysis, but also effectively reduces the possibility of misjudgment.
[0124] Corresponding to the method embodiment of the present application, the present application also provides an interface matching device based on different data sources.
[0125] Figure 2 Schematic diagram of the structure of an interface matching device based on different data sources provided in an embodiment of the present application. Figure 2 As shown, the interface matching device 200 based on different data sources may include: an acquisition module 210 , a parsing module 220 , a feature extraction and fusion module 230 , and an interface matching module 240 .
[0126] Among them, the acquisition module 210 is used to obtain N traffic data packets of N API interfaces from different data sources; the parsing module 220 is used to extract request messages and response messages from the traffic data packets for each API interface, and parse the request messages and response messages to obtain a request parameter name list corresponding to the request message, and a response parameter name list corresponding to the response message; the feature extraction and fusion module 230 is used to perform feature extraction on the request parameter name list and the response parameter name list respectively to obtain a request feature vector and a response feature vector, and perform feature vector fusion on the request feature vector and the response feature vector to obtain a high-dimensional feature vector corresponding to the API interface; the interface matching module 240 is used to screen and obtain multiple pairs of API interface combinations whose multi-dimensional feature similarity is greater than a preset similarity threshold based on the multi-dimensional feature similarity between the high-dimensional feature vectors of any two API interfaces.
[0127] The interface matching device based on different data sources provided in the embodiment of the present application can obtain the traffic data packets of the API interface from various different data sources, and can extract the request message and the response message from each traffic data packet, and obtain the request parameter name list corresponding to the request message and the response parameter name list corresponding to the response message by parsing the request message and the response message. Based on this, by performing feature extraction on the request parameter name list and the response parameter name list respectively, the request feature vector and the response feature vector are obtained, and the request feature vector and the response feature vector are fused to fully extract the multi-dimensional features of the API interface, and the information of the API interface is converted into a high-dimensional feature vector, which can embed text information into the vector space, capture the semantic information and contextual relationship of the API parameters, and therefore, based on the multi-dimensional feature similarity between the high-dimensional feature vectors of any two API interfaces, the similarity judgment between the API interfaces can be made more accurate, and the accurate identification of similar API interfaces is achieved.
[0128] In some embodiments of the present application, the request parameter name list includes a first parameter name list and a second parameter name list, the response parameter name list includes a third parameter name list and a fourth parameter name list, and the parsing module is specifically used to: parse the request header of the request message line by line, extract all parameter names contained in the request header, and obtain a first parameter name list; parse the request body of the request message, extract all parameter names contained in the request body, and obtain a second parameter name list; parse the response header of the response message, extract all parameter names contained in the response header, and obtain a third parameter name list; parse the response body of the response message, extract all parameter names contained in the response body, and obtain a fourth parameter name list.
[0129] In some embodiments of the present application, the request feature vector includes a request header vector and a request body vector, the response feature vector includes a response header vector and a response body vector, and the feature extraction fusion module is specifically used to: based on the Word2Vec model, perform feature extraction on all parameter names in the first parameter name list, the second parameter name list, the third parameter name list, and the fourth parameter name list to obtain a feature vector corresponding to each parameter name; perform weighted averaging on the feature vectors corresponding to all parameter names in the first parameter name list to obtain a request header vector; perform weighted averaging on the feature vectors corresponding to all parameter names in the second parameter name list to obtain a request body vector; perform weighted averaging on the feature vectors corresponding to all parameter names in the third parameter name list to obtain a response header vector; perform weighted averaging on the feature vectors corresponding to all parameter names in the fourth parameter name list to obtain a response body vector.
[0130] In some embodiments of the present application, the device also includes: a weight allocation module, which is used to allocate a weight value to each parameter name in the second parameter name list based on the hierarchical depth of all parameter names in the second parameter name list in the request body before performing feature extraction on the request parameter name list and the response parameter name list respectively; the weight allocation module is also used to allocate a weight value to each parameter name in the fourth parameter name list based on the hierarchical depth of all parameter names in the fourth parameter name list in the response body; wherein the weight value is negatively correlated with the hierarchical depth.
[0131] In some embodiments of the present application, the corresponding weight values of the parameter names in the request body and the response body are higher than the corresponding weight values of the parameter names in the request header and the response header.
[0132] In some embodiments of the present application, the device also includes: a retrieval module, which is used to, after screening to obtain multiple pairs of API interface combinations whose first similarity is greater than a first similarity threshold, for each pair of API interface combinations, search in the interface document platform and the code hosting repository based on the URL path and parameter name in the traffic data packet of the API interface to obtain text description information and code information matching the API interface; a semantic analysis module, which is used to use a large language model to perform semantic analysis on the text description information and code information of the API interface, and convert the text description information and code information into semantic vectors; a similarity calculation module, which is used to calculate the semantic similarity of each pair of API interface combinations based on the semantic vectors of the two API interfaces in each pair of API interface combinations; the similarity calculation module is also used to perform weighted summation of the semantic similarity and multi-dimensional feature similarity of each pair of API interface combinations to obtain a comprehensive similarity score; an interface identification module, which is used to identify the API interface combination whose comprehensive similarity score is greater than the target score as the same API interface.
[0133] In some embodiments of the present application, various different data sources include boundary traffic devices, interactive security detection devices, interface document platforms, log management systems, and API gateways.
[0134] In some embodiments of the present application, the device also includes: a parsing module, which is used to parse the traffic data packets after obtaining N traffic data packets of N API interfaces from different data sources, and obtain response time information, data type information and association relationship information, wherein the association relationship information is used to characterize the association relationship between the response host address and the configuration management database; a feature extraction module, which is used to extract features of the response time information, data type information and association relationship information respectively, and obtain three feature vectors; a feature fusion module, which is used to fuse the three feature vectors into a high-dimensional feature vector.
[0135] The interface matching device based on different data sources provided in the embodiment of the present application can achieve Figure 1 The various processes implemented by the service platform in the method embodiment can achieve the same technical effect. To avoid repetition, they will not be described here.
[0136] Figure 3 It is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application.
[0137] like Figure 3 As shown, the electronic device 300 includes a memory 301 , a processor 302 , and a computer program stored in the memory 301 and executable on the processor 302 .
[0138] In an example, the processor 302 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0139] The memory 301 may include a read-only memory (ROM), a random access memory (RAM), a disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Therefore, generally, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software including computer executable instructions, and when the software is executed (e.g., by one or more processors), it can be operated to perform the operations described with reference to the card opening method in the embodiment according to the first aspect of the present application.
[0140] The processor 302 runs a computer program corresponding to the executable program code by reading the executable program code stored in the memory 301, so as to implement the card activation method in the embodiment of the first aspect.
[0141] In some examples, the electronic device 300 may further include a communication interface 303 and a bus 310. Figure 3 As shown, the memory 301, the processor 302, and the communication interface 303 are connected via a bus 310 and communicate with each other.
[0142] The communication interface 303 is mainly used to realize the communication between the modules, devices, units and / or equipment in the embodiment of the present application. The communication interface 303 can also be used to access input devices and / or output devices.
[0143] The bus 310 includes hardware, software, or both, coupling the components of the electronic device 300 to each other. By way of example and not limitation, the bus 310 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a Memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-E) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses or a combination of two or more of these. Where appropriate, the bus 310 may include one or more buses. Although embodiments of the present application describe and illustrate a particular bus, the present application contemplates any suitable bus or interconnect.
[0144] The electronic device provided in the embodiment of the present application can realize Figure 1The various processes implemented by the electronic device in the method embodiment can achieve the same technical effect, and to avoid repetition, they will not be described here.
[0145] In combination with the interface matching method based on different data sources in the above embodiment, the embodiment of the present application can provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when the computer program instructions are executed by the processor, the steps of any one of the interface matching methods based on different data sources in the above embodiment are implemented.
[0146] In combination with the interface matching method based on different data sources in the above embodiment, the embodiment of the present application can provide a computer program product for implementation. The (computer) program product is stored in a non-volatile storage medium, and when the program product is executed by at least one processor, it implements the steps of any one of the interface matching methods based on different data sources in the above embodiment.
[0147] An embodiment of the present application further provides a chip, which includes a processor and a communication interface. The communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned interface matching method embodiment based on different data sources, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0148] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0149] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.
[0150] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), appropriate firmware, plug-in, function card, etc. When implemented in software, the elements of the present application are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0151] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.
[0152] Aspects of the present disclosure are described above with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit. It can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0153] The above is only a specific implementation of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be covered by the protection scope of this application.
Claims
1. An interface matching method based on different data sources, characterized in that: include: Obtain N traffic data packets of N API interfaces from different data sources; For each API interface, extract the request message and the response message from the traffic data packet, and parse the request message and the response message to obtain a request parameter name list corresponding to the request message and a response parameter name list corresponding to the response message; Performing feature extraction on the request parameter name list and the response parameter name list respectively to obtain a request feature vector and a response feature vector, and performing feature vector fusion on the request feature vector and the response feature vector to obtain a high-dimensional feature vector corresponding to the API interface; Based on the multi-dimensional feature similarity between high-dimensional feature vectors of any two API interfaces, multiple pairs of API interface combinations whose multi-dimensional feature similarity is greater than a preset similarity threshold are screened out.
2. The method according to claim 1, characterized in that The request parameter name list includes a first parameter name list and a second parameter name list, and the response parameter name list includes a third parameter name list and a fourth parameter name list. The request message and the response message are parsed to obtain a request parameter name list corresponding to the request message and a response parameter name list corresponding to the response message, including: Parsing the request header of the request message line by line, extracting all parameter names contained in the request header, and obtaining the first parameter name list; Parsing the request body of the request message, extracting all parameter names contained in the request body, and obtaining the second parameter name list; Parsing a response header of the response message, extracting all parameter names contained in the response header, and obtaining the third parameter name list; Parse the response body of the response message, extract all parameter names contained in the response body, and obtain the fourth parameter name list.
3. The method according to claim 2, characterized in that The request feature vector includes a request header vector and a request body vector, the response feature vector includes a response header vector and a response body vector, and the feature extraction of the first parameter name list and the second parameter name list is performed to obtain the request feature vector and the response feature vector, respectively, including: Based on the Word2Vec model, feature extraction is performed on all parameter names in the first parameter name list, the second parameter name list, the third parameter name list, and the fourth parameter name list, respectively, to obtain a feature vector corresponding to each parameter name; Taking a weighted average of the feature vectors corresponding to all parameter names in the first parameter name list to obtain the request header vector; Taking a weighted average of the feature vectors corresponding to all parameter names in the second parameter name list to obtain the request header vector; Performing weighted averaging on the feature vectors corresponding to all parameter names in the third parameter name list to obtain the response header vector; The response body vector is obtained by performing weighted averaging on the feature vectors corresponding to all parameter names in the fourth parameter name list.
4. The method according to claim 3, characterized in that Before performing feature extraction on the first parameter name list and the second parameter name list respectively, the method further includes: assigning a weight value to each parameter name in the second parameter name list based on the hierarchical depth of all parameter names in the second parameter name list in the request body; assigning a weight value to each parameter name in the fourth parameter name list based on the hierarchical depth of all parameter names in the fourth parameter name list in the response body; The weight value is negatively correlated with the depth of the hierarchy.
5. The method according to claim 3, characterized in that: The corresponding weight values of the parameter names in the request body and response body are higher than the corresponding weight values of the parameter names in the request header and response header.
6. The method according to claim 1, characterized in that After screening to obtain multiple pairs of API interface combinations whose first similarity is greater than a first similarity threshold, the method further includes: For each pair of API interface combinations, based on the URL path and parameter name in the traffic data packet of the API interface, a search is performed in the interface document platform and the code hosting repository to obtain text description information and code information matching the API interface; Using a large language model to perform semantic analysis on the text description information and code information of the API interface, and converting the text description information and code information into semantic vectors; Calculate the semantic similarity of each pair of API interface combinations based on the semantic vectors of the two API interfaces in each pair of API interface combinations; The semantic similarity and multi-dimensional feature similarity of each pair of API interface combinations are weighted and summed to obtain a comprehensive similarity score; The API interface combinations whose comprehensive similarity scores are greater than the target scores are identified as the same API interface.
7. The method according to claim 1, characterized in that The various data sources include boundary traffic devices, interactive security detection devices, interface document platforms, log management systems, and API gateways.
8. The method according to claim 1, characterized in that After obtaining N traffic data packets of N API interfaces from different data sources, the method further includes: Parsing the traffic data packet to obtain response time information, data type information, and association information, wherein the association information is used to characterize the association between the response host address and the configuration management database; Feature extraction is performed on response time information, data type information and association relationship information respectively to obtain three feature vectors; The three feature vectors are fused into the high-dimensional feature vector.
9. An interface matching device based on different data sources, characterized in that: include: The acquisition module is used to obtain N traffic data packets of N API interfaces from various data sources; A parsing module, for each API interface, extracting a request message and a response message from the traffic data packet, and parsing the request message and the response message to obtain a request parameter name list corresponding to the request message and a response parameter name list corresponding to the response message; A feature extraction and fusion module is used to extract features from the request parameter name list and the response parameter name list respectively to obtain a request feature vector and a response feature vector, and to perform feature vector fusion on the request feature vector and the response feature vector to obtain a high-dimensional feature vector corresponding to the API interface; The interface matching module is used to screen multiple pairs of API interface combinations whose multi-dimensional feature similarity is greater than a preset similarity threshold based on the multi-dimensional feature similarity between the high-dimensional feature vectors of any two API interfaces.
10. An electronic device, characterized in that: The electronic device comprises: a processor and a memory storing computer program instructions; when the electronic device executes the computer program instructions, the method according to any one of claims 1 to 8 is implemented.