API information determination method and device, electronic equipment and storage medium

By extracting path information from network traffic and matching parameter type rules using a rule database, the problem of API information determination methods relying on description documents is solved, enabling API information determination without documentation and improving the method's versatility and accuracy.

CN120825536APending Publication Date: 2025-10-21QI AN XIN TECHNOLOGY GROUP INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410447857.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-12
Publication Date
2025-10-21

AI Technical Summary

Technical Problem

In the prior art, the API information determination method relies on the description document of the API, which results in the inability to determine the API information when the description document cannot be obtained, thereby reducing the versatility of the method.

Method used

Path information is extracted from network traffic, and parameters in the path information are matched using parameter type rules in the rule database. API information is obtained by substitution, including precise and fuzzy aggregation strategies, to determine the API information.

Benefits of technology

It does not rely on API scanning documents, but reconstructs API information by extracting path information from network traffic and pre-configured parameter type rules, improving the versatility and accuracy of API information determination methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120825536A_ABST
    Figure CN120825536A_ABST
Patent Text Reader

Abstract

The invention provides an API information determination method and device, electronic equipment and a storage medium, and relates to the technical field of information security, and the method comprises the steps: extracting path information from network traffic; for each parameter in the path information, matching the parameter with each parameter type rule in a rule database, the parameter type rule being determined based on the parameter type of a variable sample parameter in at least one sample path information; and replacing the successfully matched target parameter in the path information, and determining the replaced path information as the API information. According to the method, the API information is restored through the path information extracted from the network flow and the pre-configured parameter type rule, and the method does not need to depend on an AIP scanning document, so that the universality of the API information determination method is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information security technology, and in particular to a method, device, electronic device and storage medium for determining API information. Background Art

[0002] With the rapid development of information technology, Application Programming Interfaces (APIs) have become a core component of modern applications and systems. They not only connect different software systems but also carry the important mission of data exchange and sharing. However, at the same time, APIs have also become a potential security risk point. Therefore, extracting API information for security monitoring is particularly important.

[0003] In the related art, the API description document is usually analyzed to determine the API information from the description document.

[0004] However, in the above-mentioned related technologies, when determining API information, it is necessary to rely on the API description document. If the API description document cannot be obtained, the API information cannot be determined, thereby reducing the versatility of the API information determination method. Summary of the Invention

[0005] The present invention provides a method, device, electronic device and storage medium for determining API information, so as to solve the defect in the prior art that the versatility of the method for determining API information is reduced.

[0006] The present invention provides a method for determining API information, comprising:

[0007] Extracting path information from network traffic;

[0008] For each parameter in the path information, matching the parameter with each parameter type rule in a rule database, wherein the parameter type rule is determined based on a parameter type of a variable sample parameter in at least one sample path information;

[0009] The successfully matched target parameter in the path information is replaced, and the replaced path information is determined as the API information.

[0010] According to a method for determining API information provided by the present invention, replacing the successfully matched target parameter in the path information includes:

[0011] Get the target aggregation policy configured by the user;

[0012] In a case where the target aggregation strategy is a precise aggregation strategy, the successfully matched target parameter in the path information is replaced with identification information of a target parameter type rule that matches the target parameter.

[0013] According to a method for determining API information provided by the present invention, replacing the successfully matched target parameter in the path information includes:

[0014] Get the target aggregation policy configured by the user;

[0015] In the case where the target aggregation strategy is a fuzzy aggregation strategy, the successfully matched target parameters in the path information are replaced with preset parameters, and the preset parameters are fuzzy matching parameters corresponding to the fuzzy aggregation strategy.

[0016] According to a method for determining API information provided by the present invention, replacing the successfully matched target parameter in the path information includes:

[0017] The location of the target parameter is searched from the path information, and the target parameter is replaced based on the location.

[0018] According to a method for determining API information provided by the present invention, the method further includes:

[0019] Obtain at least one sample path information;

[0020] Determining at least one variable sample parameter in each of the sample path information, and determining a parameter type of each of the variable sample parameters;

[0021] For each of the parameter types, determining a corresponding parameter type rule based on the parameter type;

[0022] Compiling each of the parameter type rules to obtain compiled parameter type rules;

[0023] The compiled parameter type rules are stored in the rule database.

[0024] According to a method for determining API information provided by the present invention, the parameter type rule includes a general parameter type rule and a parameter type rule corresponding to at least one target scenario.

[0025] According to a method for determining API information provided by the present invention, the method further includes:

[0026] Obtain the number of calls to the API information within a preset time period;

[0027] When the number of calls is greater than or equal to a first preset number, adding an active flag to the API information;

[0028] When the number of calls is less than a second preset number, an inactivation mark is added to the API information and a reminder message is output, wherein the reminder message is used to remind the target person to verify the validity of the API information, and the second preset number is less than the first preset number.

[0029] The present invention also provides a device for determining API information, comprising:

[0030] an extraction unit, configured to extract path information from network traffic;

[0031] a matching unit, configured to match each parameter in the path information with each parameter type rule in a rule database, wherein the parameter type rule is determined based on a parameter type of a variable sample parameter in at least one sample path information;

[0032] The first determining unit is configured to replace the successfully matched target parameter in the path information, and determine the replaced path information as the API information.

[0033] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method for determining API information as described above is implemented.

[0034] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-mentioned methods for determining API information.

[0035] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method for determining API information as described above is implemented.

[0036] The method, device, electronic device, and storage medium for determining API information provided by the present invention extract path information from network traffic. For each parameter in the path information, the method matches the parameter with each parameter type rule in a pre-stored rule database. The successfully matched target parameter in the path information is replaced, and the replaced path information is determined as the API information. This method restores API information by using path information extracted from network traffic and pre-configured parameter type rules, eliminating the need for scanning API documents. This improves the versatility of the API information determination method. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0038] Figure 1 This is one of the flow charts of the method for determining API information provided by an embodiment of the present invention;

[0039] Figure 2 This is a second flow chart of the method for determining API information provided by an embodiment of the present invention;

[0040] Figure 3 It is a structural diagram of an apparatus for determining API information provided by an embodiment of the present invention;

[0041] Figure 4 It is a schematic diagram of the physical structure of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0042] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.

[0043] The following combination Figure 1 and Figure 2 The present invention describes a method for determining API information. The method can be performed by an electronic device such as a terminal, computer, or server, or by an API information determination device provided in the electronic device. The API information determination device can be implemented using software, hardware, or a combination of both.

[0044] Figure 1 This is one of the flow charts of the method for determining API information provided by an embodiment of the present invention, such as Figure 1 As shown, the method for determining the API information includes the following steps:

[0045] Step 101: Extract path information from network traffic.

[0046] For example, the device configured with the method for determining the API information collects network traffic and extracts path information from the network traffic, wherein the network traffic can be Hypertext Transfer Protocol (HTTP) traffic or other traffic including path information; the path information in the HTTP traffic refers to a part of the Uniform Resource Locator (URL), which indicates the location of the requested resource on the server. The path information is the part of the URL in the header of the HTTP request, which follows the domain name and usually starts with a slash ( / ). For example, in the URL http: / / www.example.com / images / photo.jpg, images / photo.jpg is the path information. This path information tells the server where the requested resource is located on the server. In this example, the requested resource is a picture named photo.jpg, which is located in the images directory on the server.

[0047] For another example, the path information is / api / v1 / user / 1001 / getimg / xxx123-a0c9d78bxxx.

[0048] Step 102: For each parameter in the path information, match the parameter with each parameter type rule in a rule database, where the parameter type rule is determined based on a parameter type of a variable sample parameter in at least one sample path information.

[0049] For example, when the path information is extracted, each piece of information separated by a slash in the path information is a parameter, that is, the path information includes multiple parameters. Hyperscan is used to put each parameter into the rule database for scanning to match each parameter with each parameter type rule in the rule database until all parameters in the path information are matched. When it is determined that the path information includes parameters containing only numbers, it means that the parameters containing only numbers match the parameter type rule corresponding to the numbers, and the parameters containing only numbers are determined to be the target parameters that have successfully matched; when it is determined that the path information includes parameters containing only timestamps, it means that the parameters containing only timestamps match the parameter type rule corresponding to the timestamp, and the parameters containing only timestamps are determined to be the target parameters that have successfully matched; when it is determined that the path information includes parameters containing a combination of letters and numbers, it means that the parameters containing a combination of letters and numbers match the parameter type rule corresponding to the combination of letters and numbers, and the parameters containing a combination of letters and numbers are determined to be the target parameters that have successfully matched. For example, if the path information is / api / v1 / user / 1001 / getimg / xxx123-a0c9d78bxxx, and the parameter "1001" contains only numbers, the parameter "1001" matches the parameter type rule corresponding to numbers. If the parameter "xxx123-a0c9d78bxxx" contains a combination of letters and numbers, the parameter "xxx123-a0c9d78bxxx" matches the parameter type rule corresponding to the combination of letters and numbers.

[0050] Step 103: Replace the successfully matched target parameters in the path information, and determine the replaced path information as API information.

[0051] For example, when each target parameter that is successfully matched is obtained, each target parameter in the path information is replaced to obtain the replaced path information, the replaced path information is determined as the API information, and the determined API information is saved. The corresponding API information can be extracted for each network flow, so the extraction and preservation of multiple API information can be achieved, which is convenient for the security monitoring of the saved API information in the later stage. For example, a certain API information is API information that is not open to the outside world. If the path information representing the API information is detected in the external network traffic, it can be determined that the API information is unsafe. For example, the API information that is not open to the outside world is / api / v1 / user / {param} / getimg / {param}. If the path information representing the API information is detected in the external network traffic as / api / v1 / user / 1002 / getimg / xxx123-a0c9d78bxxx, it is determined that the API information that is not open to the outside world is / api / v1 / user / {param} / getimg / {param} and is unsafe and may be leaked.

[0052] The method for determining API information provided by the present invention extracts path information from network traffic, matches each parameter in the path information with each parameter type rule in a pre-stored rule database, replaces the target parameter in the path information that successfully matches, and determines the replaced path information as the API information. This method, by using path information extracted from network traffic and pre-configured parameter type rules to restore API information, eliminates the need for scanning API documents, thereby increasing the versatility of the method for determining API information.

[0053] In one embodiment, in step 103, the successfully matched target parameter in the path information is replaced, which can be specifically achieved by the following method:

[0054] Obtain a target aggregation strategy configured by the user; if the target aggregation strategy is a precise aggregation strategy, replace the successfully matched target parameter in the path information with identification information of a target parameter type rule that matches the target parameter.

[0055] Among them, the user can select the corresponding aggregation strategy based on the needs. The aggregation strategy includes a precise aggregation strategy or a fuzzy aggregation strategy. The accuracy of the precise aggregation strategy is greater than the accuracy of the fuzzy aggregation strategy.

[0056] For example, when the target parameters that are successfully matched in the path information are obtained, the target aggregation strategy configured by the user is obtained. When the target aggregation strategy configured by the user is the precise aggregation strategy, the target parameters that are successfully matched in the path information are replaced with the identification information of the target parameter type rule that matches the target parameter. The identification information of the target parameter type rule can be the name of the target parameter type rule, etc. Taking the path information as / api / v1 / user / 1001 / getimg / xxx123-a0c9d78bxxx as an example, the parameter "1001" matches the parameter type rule corresponding to the number, and the parameter "xxx123-a0c9d78bxxx" matches the parameter type rule corresponding to the combination of letters and numbers. If the number type rule matches, replace the parameter "1001" in the path information / api / v1 / user / 1001 / getimg / xxx123-a0c9d78bxxx with the name of the parameter type rule corresponding to the number. If the name of the parameter type rule corresponding to the number is number, replace the parameter "1001" with {number}; replace the parameter "xxx123-a0c9d78bxxx" in the path information / api / v1 / user / 1001 / getimg / xxx123-a0c9d78bxxx with the name of the parameter type rule corresponding to the combination of letters and numbers. If the name of the parameter type rule corresponding to the number is number, replace the parameter "1001" with {number}. If the parameter type rule name is complex, replace the parameter "xxx123-a0c9d78bxxx" with {complex}, and the resulting API information is / api / v1 / user / {number} / getimg / {complex}. You can then detect from other network traffic whether the path information representing the API information / api / v1 / user / {number} / getimg / {complex} is included. The parameters api, v1, user, and getimg in the API information / api / v1 / user / {number} / getimg / {complex} are All are static parameters, and {number} and {complex} are variable parameters. If the position of each static parameter in the path information is the same as the position of the static parameters in the API information / api / v1 / user / {number} / getimg / {complex}, and the parameter type and position of the variable parameters in the path information are the same as the parameter type and position in the API information / api / v1 / user / {number} / getimg / {complex}, then it can be determined that the path information represents the path information of the API information / api / v1 / user / {number} / getimg / {complex};For example, if the path information extracted from other network traffic is / api / v1 / user / 1002 / getimg / xxx123-a0c9d78bxxx, then it can be determined that the path information represents the API information / api / v1 / user / {number} / getimg / {complex}, thereby achieving accurate detection of the path information representing the API information.

[0057] In this embodiment, when the target aggregation strategy configured by the user is a precise aggregation strategy, the successfully matched target parameters in the path information can be replaced based on the precise aggregation strategy, so that when the replaced path information is used as API information, the API information can accurately detect the path information representing the API information in the network traffic, thereby improving the accuracy of path information detection.

[0058] In one embodiment, in step 103, the successfully matched target parameter in the path information is replaced, which can be specifically implemented in the following manner:

[0059] In the case where the target aggregation strategy is a fuzzy aggregation strategy, the successfully matched target parameters in the path information are replaced with preset parameters, and the preset parameters are fuzzy matching parameters corresponding to the fuzzy aggregation strategy.

[0060] For example, when the target aggregation strategy configured by the user is a fuzzy aggregation strategy, each target parameter that successfully matches in the path information is replaced with a preset parameter, such as param. Taking the path information / api / v1 / user / 1001 / getimg / xxx123-a0c9d78bxxx as an example, the parameter "1001" matches the parameter type rule corresponding to the number, and the parameter "xxx123-a0c9d78bxxx" matches the parameter type rule corresponding to the combination of letters and numbers. Therefore, the path information / api / v1 / user / 1001 / getimg / xx Replace the parameter "1001" in x123-a0c9d78bxxx with {param}; replace the parameter "xxx123-a0c9d78bxxx" in the path information / api / v1 / user / 1001 / getimg / xxx123-a0c9d78bxxx with {param}, and the obtained API information is / api / v1 / user / {param} / getimg / {param}. You can then detect from other network traffic whether the API information / api / v1 / user / {param} / getimg is included. mg / {param}, the parameters api, v1, user, and getimg in the API information / api / v1 / user / {param} / getimg / {param} are all static parameters, and {param} is a variable parameter. If the positions of the static parameters in the path information are the same as those in the API information / api / v1 / user / {param} / getimg / {param}, the positions of the variable parameters in the path information are the same as those in the API information / api / v1 / user / {number} / getimg / {complex}, the positions of the variable parameters are the same, then it can be determined that the path information is the path information representing the API information / api / v1 / user / {param} / getimg / {param}; for example, if the path information extracted from other network traffic is / api / v1 / user / xy0 / getimg / 1001, then it can be determined that the path information is the path information representing the API information / api / v1 / user / {param} / getimg / {param}, thereby achieving fuzzy detection of the path information representing the API information.

[0061] In this embodiment, when the target aggregation strategy configured by the user is a fuzzy aggregation strategy, the successfully matched target parameters in the path information can be replaced based on the fuzzy aggregation strategy, so that when the replaced path information is used as API information, the API information can fuzzily detect the path information representing the API information in the network traffic, thereby improving the efficiency of path information detection.

[0062] In one embodiment, in step 103, the successfully matched target parameter in the path information is replaced, which can be specifically implemented in the following manner:

[0063] The location of the target parameter is searched from the path information, and the target parameter is replaced based on the location.

[0064] For example, when using hyperscan to place each parameter into the rule database for scanning, hyperscan can obtain the position of the target parameter in the path information that is successfully matched by the parameter type rule, and replace the target parameter at that position according to the user-configured target aggregation policy. For example, taking the path information / api / v1 / user / 1001 / getimg / xxx123-a0c9d78bxxx as an example, assuming that the parameter "1001" successfully matches the parameter type rule corresponding to the number, it can be determined that the parameter "1001" is the fourth parameter in the path information / api / v1 / user / 1001 / getimg / xxx123-a0c9d78bxxx, and the parameter at the fourth parameter position is replaced.

[0065] In this embodiment, the target parameter can be replaced based on the position of the target parameter in the path information, and the replacement is relatively accurate.

[0066] In one embodiment, Figure 2 This is a second flow chart of the method for determining API information provided by an embodiment of the present invention. Figure 2 As shown, before the above step 101, the method for determining API information further includes the following steps:

[0067] Step 201: Obtain at least one sample path information.

[0068] For example, the user may summarize multiple common sample path information and store all the sample path information.

[0069] Step 202: Determine at least one variable sample parameter in each sample path information, and determine the parameter type of each variable sample parameter.

[0070] For example, for each sample path information, a variable sample parameter whose value changes is obtained from all sample parameters in the sample path information, and the parameter type of each variable sample parameter is determined. For example, if the variable sample parameter is 1001, the parameter type is a number. For another example, if the variable sample parameter is 529**qq.com, the parameter type is an email address.

[0071] Step 203: For each parameter type, determine a corresponding parameter type rule based on the parameter type.

[0072] For example, for the parameter type of each variable sample parameter, a corresponding parameter type rule is determined. For example, if the parameter type is a number, the parameter type rule corresponding to the number is that the parameter only includes numbers; if the parameter type is an email, the parameter type rule corresponding to the email is that the information included in the parameter represents the email; if the parameter type is a time and date, the parameter type rule corresponding to the time and date is that the information included in the parameter represents the time and date; if the parameter type is a timestamp, the parameter type rule corresponding to the timestamp is that the information included in the parameter represents the timestamp; if the parameter type is a key-value pair, the parameter type rule corresponding to the key-value pair is that the information included in the parameter is a key-value pair, etc. According to the above method, the parameter type rule corresponding to each parameter type will be determined.

[0073] It should be noted that parameter type rules are all regular expression rules. Each parameter type rule corresponds to a regular expression rule. For example, the regular expression rule for numbers is / \-? \d+( / |$), named {number}; the regular expression rule for key-value pairs is / [^ / ]+=[^ / ]+( / |$), named {query}; the regular expression rule for email is / [az][a-z0-9_.-]{1,8}@[az][a-z0-9-.]{2,12}\.[az]{2,4}( / |$), named {email}; the regular expression rule for character and number combinations is / [^ / ]*\d{3,}[_\-\.][a-fA-F0-9]{8,}[^ / ]*( / |$), named {complex}, and so on.

[0074] It should be noted that when the parameter type is time, date, or timestamp, the corresponding parameter type rule can correspond to multiple regular expressions. For example, when the time and date is year and month, it corresponds to one regular expression, and when the time and date is year, month, and day, it corresponds to one regular expression, etc. The present invention does not limit this.

[0075] Step 204: compile each of the parameter type rules to obtain each compiled parameter type rule, and store each of the compiled parameter type rules in the rule database.

[0076] For example, when obtaining the parameter type rules corresponding to all parameter types, the open source high-performance regular expression matching library hyperscan is used to compile each parameter type rule to obtain each compiled parameter type rule, and each compiled parameter type rule is stored in a rule database, so that the compiled parameter type rules stored in the rule database are in a format or code that can be executed by a computer, which is convenient for subsequent matching and can be applied to different network environments.

[0077] It should be noted that in the process of using the rule database, if a new parameter type is obtained that is different from the parameter type corresponding to the parameter type rule in the established rule database, a new parameter type rule corresponding to the new parameter type can be determined, and the rule database can be updated based on the new parameter type rule, so that the parameter type rules in the updated rule database are more comprehensive.

[0078] In this embodiment, the parameter types of all variable sample parameters are summarized in advance from multiple sample path information, and corresponding parameter type rules are formulated for each parameter type, thereby realizing the establishment of a rule database, which facilitates the subsequent determination of API information from the network process based on the rule database without relying on the API description information, thereby improving the versatility of the API information determination method.

[0079] In one embodiment, the parameter type rules include general parameter type rules and parameter type rules corresponding to at least one target scenario.

[0080] For example, parameter type rules can be divided into predefined general parameter type rules and customized parameter type rules corresponding to target scenarios. General parameter type rules can be rules based on parameter types included in common path information or parameter types determined based on experience. For example, parameter types include ipv4, ipv6, time date, timestamp, key-value pair, email, number, base64, uuid, hash string, combination of letters and numbers, etc. Taking the parameter type as a number as an example, the parameter type rule corresponding to the number can be that the parameter only includes numbers; taking the parameter type as a combination of letters and numbers as an example, the parameter type rule corresponding to the combination of letters and numbers can be that the parameter includes both numbers and letters. The parameter type rule corresponding to the target scenario can be a rule determined based on the parameter type included in the sample path information extracted from the real traffic that occurs in the specific usage scenario.

[0081] In one embodiment, after step 103, the method for determining API information further includes the following steps:

[0082] Obtain the number of times the API information is called within a preset time period; if the number of calls is greater than or equal to a first preset number, add an active mark to the API information; if the number of calls is less than a second preset number, add an inactive mark to the API information and output a reminder message, wherein the reminder message is used to remind the target person to verify the validity of the API information, and the second preset number is less than the first preset number.

[0083] The specific values ​​of the first preset number and the second preset number can be set based on a specific application scenario. For example, the first preset number is 5 and the second preset number is 1.

[0084] For example, after restoring API information based on path information extracted from network traffic, the API information can be stored in an API database. For each API information in the API database, the number of calls to the API information within a preset time period can be determined, and the number of calls to the API information can be compared with a first preset number and a second preset number. When the number of calls to the API information is greater than or equal to the first preset number, it indicates that the API information is active, and an active flag is added to the API information; when the number of calls to the API information is less than the second preset number, it indicates that the API information has not been called or has been called very rarely, and an inactive flag is added to the API information. Each API information in the API database is marked using the same method, allowing the target person to quickly understand the status of each API information through the added flags. In addition, when the number of calls to the API information is less than the second preset number, a prompt message can be output to remind the target person to verify the validity of the API information. When the target person receives the prompt message, he or she can determine whether the API information corresponding to the prompt message is the API information developed by the business party. If it is not the API information developed by the business party, it can be determined that the API information is API information obtained through a malicious attack.

[0085] In this embodiment, corresponding identifiers can be added to API information based on the number of times the API information is called within a preset time period, so that the target personnel can quickly understand the status of each API information through the added identifiers; in addition, when the number of calls is less than a second preset number, a prompt message can be output to remind the target personnel to verify the validity of the API information, so as to check the validity of the API information.

[0086] The following describes the device for determining API information provided by the present invention. The device for determining API information described below and the method for determining API information described above can refer to each other.

[0087] Figure 3FIG. 1 is a schematic diagram of the structure of an apparatus for determining API information provided by an embodiment of the present invention. Figure 3 As shown, the API information determination device 300 includes an extraction unit 301, a matching unit 302 and a first determination unit 303; wherein:

[0088] Extraction unit 301, used to extract path information from network traffic;

[0089] a matching unit 302 configured to match each parameter in the path information with each parameter type rule in a rule database, wherein the parameter type rule is determined based on a parameter type of a variable sample parameter in at least one sample path information;

[0090] The first determining unit 303 is configured to replace the successfully matched target parameter in the path information, and determine the replaced path information as API information.

[0091] The device for determining API information provided by the present invention extracts path information from network traffic, matches each parameter in the path information with parameter type rules in a pre-stored rule database, replaces the target parameters in the path information that successfully match, and determines the replaced path information as API information. This method restores API information by using path information extracted from network traffic and pre-configured parameter type rules, eliminating the need for scanning API documents. This improves the versatility of the API information determination method.

[0092] Based on any of the foregoing embodiments, the first determining unit 303 is specifically configured to:

[0093] Get the target aggregation policy configured by the user;

[0094] In a case where the target aggregation strategy is a precise aggregation strategy, the successfully matched target parameter in the path information is replaced with identification information of a target parameter type rule that matches the target parameter.

[0095] Based on any of the foregoing embodiments, the first determining unit 303 is further specifically configured to:

[0096] Get the target aggregation policy configured by the user;

[0097] In the case where the target aggregation strategy is a fuzzy aggregation strategy, the successfully matched target parameters in the path information are replaced with preset parameters, and the preset parameters are fuzzy matching parameters corresponding to the fuzzy aggregation strategy.

[0098] Based on any of the foregoing embodiments, the first determining unit 303 is further specifically configured to:

[0099] The location of the target parameter is searched from the path information, and the target parameter is replaced based on the location.

[0100] Based on any of the above embodiments, the API information determination device 300 further includes:

[0101] A first acquiring unit, configured to acquire at least one sample path information;

[0102] a second determining unit, configured to determine at least one variable sample parameter in each of the sample path information, and determine a parameter type of each of the variable sample parameters;

[0103] a third determining unit, configured to determine, for each parameter type, a corresponding parameter type rule based on the parameter type;

[0104] a fourth determining unit, configured to compile each of the parameter type rules to obtain compiled parameter type rules;

[0105] A storage unit is used to store each of the compiled parameter type rules in the rule database.

[0106] Based on any of the above embodiments, the parameter type rules include general parameter type rules and parameter type rules corresponding to at least one target scenario.

[0107] Based on any of the above embodiments, the API information determination device 300 further includes:

[0108] The second acquisition unit is used to obtain the number of calls of the API information within a preset time period;

[0109] A first adding unit, configured to add an active identifier to the API information when the number of calls is greater than or equal to a first preset number;

[0110] The second adding unit is used to add an inactivation mark to the API information and output a reminder message when the number of calls is less than a second preset number, and the reminder message is used to remind the target person to verify the validity of the API information, and the second preset number is less than the first preset number.

[0111] Figure 4 FIG is a schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention, such as Figure 4As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430, and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 430 communicate with each other via the communication bus 440. The processor 410 may call logic instructions in the memory 430 to execute a method for determining API information, the method including: extracting path information from network traffic;

[0112] For each parameter in the path information, matching the parameter with each parameter type rule in a rule database, wherein the parameter type rule is determined based on a parameter type of a variable sample parameter in at least one sample path information;

[0113] The successfully matched target parameter in the path information is replaced, and the replaced path information is determined as the API information.

[0114] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. 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 and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0115] On the other hand, the present invention further provides a computer program product, the computer program product including a computer program, the computer program being storable on a non-transitory computer-readable storage medium, and when the computer program is executed by a processor, the computer is capable of performing the method for determining API information provided by the above methods, the method including: extracting path information from network traffic;

[0116] For each parameter in the path information, matching the parameter with each parameter type rule in a rule database, wherein the parameter type rule is determined based on a parameter type of a variable sample parameter in at least one sample path information;

[0117] The successfully matched target parameter in the path information is replaced, and the replaced path information is determined as the API information.

[0118] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the method for determining the API information provided by the above methods is implemented, the method comprising: extracting path information from network traffic;

[0119] For each parameter in the path information, matching the parameter with each parameter type rule in a rule database, wherein the parameter type rule is determined based on a parameter type of a variable sample parameter in at least one sample path information;

[0120] The successfully matched target parameter in the path information is replaced, and the replaced path information is determined as the API information.

[0121] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.

[0122] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, or of course, by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or certain parts of the embodiments.

[0123] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A method for determining API information, characterized in that: include: Extracting path information from network traffic; For each parameter in the path information, matching the parameter with each parameter type rule in a rule database, wherein the parameter type rule is determined based on a parameter type of a variable sample parameter in at least one sample path information; The successfully matched target parameter in the path information is replaced, and the replaced path information is determined as the API information.

2. The method for determining API information according to claim 1, wherein: The replacing the successfully matched target parameter in the path information includes: Get the target aggregation policy configured by the user; In a case where the target aggregation strategy is a precise aggregation strategy, the successfully matched target parameter in the path information is replaced with identification information of a target parameter type rule that matches the target parameter.

3. The method for determining API information according to claim 1, wherein: The replacing the successfully matched target parameter in the path information includes: Get the target aggregation policy configured by the user; In the case where the target aggregation strategy is a fuzzy aggregation strategy, the successfully matched target parameters in the path information are replaced with preset parameters, and the preset parameters are fuzzy matching parameters corresponding to the fuzzy aggregation strategy.

4. The method for determining API information according to claim 1, wherein: The method further comprises: Obtain at least one sample path information; Determining at least one variable sample parameter in each of the sample path information, and determining a parameter type of each of the variable sample parameters; For each of the parameter types, determining a corresponding parameter type rule based on the parameter type; Compiling each of the parameter type rules to obtain compiled parameter type rules; The compiled parameter type rules are stored in the rule database.

5. The method for determining API information according to claim 1, wherein: The parameter type rules include general parameter type rules and parameter type rules corresponding to at least one target scenario.

6. The method for determining API information according to any one of claims 1 to 5, characterized in that: The method further comprises: Obtain the number of calls to the API information within a preset time period; When the number of calls is greater than or equal to a first preset number, adding an active flag to the API information; When the number of calls is less than a second preset number, an inactivation mark is added to the API information and a reminder message is output, wherein the reminder message is used to remind the target person to verify the validity of the API information, and the second preset number is less than the first preset number.

7. A device for determining API information, characterized in that: include: an extraction unit, configured to extract path information from network traffic; a matching unit, configured to match each parameter in the path information with each parameter type rule in a rule database, wherein the parameter type rule is determined based on a parameter type of a variable sample parameter in at least one sample path information; The first determining unit is configured to replace the successfully matched target parameter in the path information, and determine the replaced path information as the API information.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method for determining API information according to any one of claims 1 to 6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for determining API information according to any one of claims 1 to 6 is implemented.

10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method for determining API information according to any one of claims 1 to 6 is implemented.