Website abnormal request judgment method and device based on API, medium and equipment
By constructing exception baseline and multi-dimensional detection, the shortcomings of abnormal changes detection of API call distribution in the prior art are solved, and the accuracy and comprehensiveness of website exception request detection are improved.
Patent Information
- Application Number
- CN202411056171.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-02
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2044-08-02
AI Technical Summary
The prior art is difficult to effectively discover the abnormal trend of API call distribution from the dimension of website requests, and it is impossible to carefully and comprehensively detect the fluctuations in the visit volume of different APIs in the website and the changes in regional clients, resulting in some hidden problems that cannot be observed.
Obtain the API instance of the website through automatic discovery, build an exception baseline, including time baseline, region baseline and client baseline, extract the request source region and client information, count the number of visits, and use these baselines to make exception request judgments.
Improve the accuracy and accuracy of website exception request detection, refine the judgment of exception requests through API instance dimensions, and detect abnormalities in multiple dimensions (region, time, client), enhancing the comprehensiveness of exception detection.
Smart Images

Figure CN118972234A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to an API-based website abnormal request determination method, device, medium, and equipment. Background Art
[0002] With the rapid development of the Internet and the widespread use of website applications, ensuring website security and stability has become an important task. The current abnormal requests of websites are mainly compared with the previous baseline by counting the current access request data. When the baseline is exceeded, it means that abnormal access has occurred. The current statistical method mainly counts the number of access requests within a specified time from the dimension of the website. The statistics are not detailed and comprehensive enough, and some hidden problems cannot be discovered. The fluctuations in the number of visits to different APIs on the website cannot be effectively discovered from the dimension of website requests, and cannot well reflect the abnormal change trend of the distribution of API calls on the website. Sometimes there is no obvious abnormality in the number of access requests within a specified time, but the area or client accessed by the website may have undergone major changes, which cannot be observed using the current website abnormal request method. Summary of the invention
[0003] In view of at least one of the above technical problems, an embodiment of the present invention provides a method, device, medium, and equipment for determining abnormal website requests based on an API.
[0004] In a first aspect, an API-based website abnormal request determination method provided by an embodiment of the present invention includes:
[0005] Obtaining the API instance of the preset website in the first time period by automatic discovery;
[0006] Statistics are collected on the API instance, and an abnormal baseline is constructed based on the statistical results; wherein the abnormal baseline includes a time baseline, a region baseline, and a client baseline; the time baseline includes a baseline of the number of access requests corresponding to each time period of a day, and the region baseline includes a set of request source regions corresponding to each time period of a day and a baseline of the number of requests from each request source region in each time period;
[0007] When receiving the access request of the preset website, extracting the request source region and the client from the access request, and counting a first access quantity, where the first access quantity is the number of access requests within the time period when the access request is received;
[0008] Whether the current access request is an abnormal website request is determined according to the request source region and the client, the first access volume, and the abnormal baseline extracted from the current access request.
[0009] In one embodiment, the method of obtaining an API instance of a preset website within a first time period by automatic discovery includes:
[0010] Divide each website request of the preset website within the first time period into corresponding groups according to the request mode, and generate a corresponding tree structure according to the URL of each website request in each group;
[0011] If the number of website requests of the preset website in the first time period reaches a preset number, each node in the tree structure is merged; wherein each child node in the merged tree structure is the API instance.
[0012] In one embodiment, the merging of nodes in each tree structure includes:
[0013] Calculate the number of child nodes under each parent node that has child nodes;
[0014] If the number of child nodes is greater than the specified threshold or the child node matches the specified regular expression, the similarity between all child nodes under the corresponding parent node is calculated to form a similarity matrix, and the mean of the similarity matrix is calculated;
[0015] Based on the similarity matrix, the discrete values of all child nodes under the parent node are calculated using the Z-score;
[0016] Based on the similarity matrix, the entropy values of all child nodes under the parent node are calculated;
[0017] Calculate the merge scores corresponding to all child nodes under the parent node according to the mean, the discrete value and the entropy value;
[0018] If the merge score exceeds a preset threshold, all child nodes under the parent node are merged to obtain a merged API instance;
[0019] The combined score is calculated using a first calculation formula, which is:
[0020] R=a*sb*kc*h
[0021] Among them, a, b, c are weights, R is the merge score, s is the mean, k is the discrete value, and h is the entropy value.
[0022] In one embodiment, the process of constructing the regional baseline includes:
[0023] Determine a request source region corresponding to an access request of each API instance in each time period of each day within the first time period;
[0024] By sliding the time window, the distribution of request source regions in each time period of each day in the current time window is counted to obtain the request source region set in each time period of each day in the current time window; the average number of requests corresponding to each request source region in each time period of each day in the current time window is counted, and the average number of requests is used as the baseline of the number of requests for the request source region in the time period in the current time window.
[0025] In one embodiment, the process of constructing the time baseline includes:
[0026] Count the number of access requests for each API instance in each time period of each day in the current time window to obtain a set of the number of access requests for the API instance in the time period;
[0027] Remove the maximum and minimum values in the set of access request numbers for each API instance in each time period, calculate the average value of each data after removing the maximum value, and use the average value as the baseline of the access request number of the API instance in the time period.
[0028] In one embodiment, the process of building the client baseline includes:
[0029] The currently determined normal clients are sorted to determine the regular matching expression of the normal clients; or the currently determined abnormal clients are sorted to determine the regular matching expression of the abnormal clients; the regular matching expression of the normal client or the regular matching expression of the abnormal client is used as the client baseline.
[0030] In one embodiment, determining whether the current access request is an abnormal website request based on the request source region and the client, the first page views, and the abnormal baseline extracted from the current access request includes:
[0031] Determine the correction factor p that changes due to the change of time period;
[0032] Determine whether the request source region of the current access request is included in the request source region set corresponding to the time period in which the current access request is received in the regional baseline; if not, the current access request is an abnormal website request; if so, determine whether the number of requests from the request source region of the current access request in the time period exceeds (p+1) times the corresponding request number baseline; if exceeded, the current access request is an abnormal website request; if not, proceed to the next step;
[0033] Determine whether the first access volume exceeds (p+1) times the access request quantity baseline of the corresponding time period in the time baseline; if exceeded, the access request is an abnormal website request; if not exceeded, proceed to the next step;
[0034] Determine whether the client of the current access request matches the regular matching expression of the normal client. If so, the current access request is a normal request for the website; if not, the current access request is an abnormal request for the website; or, determine whether the client of the current access request matches the regular matching expression of the abnormal client. If not, the current access request is a normal request for the website; if so, the current access request is an abnormal request for the website.
[0035] According to the second aspect, the API-based website abnormal request determination device provided by the embodiment of the present invention includes:
[0036] A first acquisition module, used to acquire an API instance of a preset website within a first time period by automatic discovery;
[0037] A baseline construction module is used to collect statistics on the API instance and construct an abnormal baseline based on the statistical results; wherein the abnormal baseline includes a time baseline, a region baseline and a client baseline; the time baseline includes a baseline of the number of access requests corresponding to each time period of a day, and the region baseline includes a set of request source regions corresponding to each time period of a day and a baseline of the number of requests of each request source region in each time period;
[0038] an information determination module, configured to extract a request source region and a client from the access request when receiving the access request for the preset website, and to count a first access quantity, wherein the first access quantity is the number of access requests within a time period when the access request is received;
[0039] The baseline comparison module is used to determine whether the current access request is an abnormal website request based on the request source region and the client, the first access volume and the abnormal baseline extracted from the current access request.
[0040] According to a third aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, enables the computer to execute the method provided in the first aspect.
[0041] According to a fourth aspect, an embodiment of the present invention provides a computing device, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method provided in the first aspect is implemented.
[0042] The API-based website abnormal request determination method, device, medium, and equipment provided in the embodiments of the present invention obtain API instances of a preset website within a first time period by automatic discovery, and then perform statistics on the API instances, and build an abnormal baseline based on the statistical results. The abnormal baseline includes a time baseline, a regional baseline, and a client baseline. When receiving the current access request of the preset website, the request source region and client are extracted from the current access request, and the first access volume is counted, and then the abnormal baseline is used for comparison to obtain a judgment result. It can be seen that the embodiments of the present invention improve the accuracy of abnormal website request detection by building an abnormal baseline on the API instance and refining the judgment of abnormal requests from the dimension of the API instance. At the same time, the access request is judged abnormally from the three dimensions of region, time, and client. Compared with the traditional abnormal request, this judgment method performs detection from different dimensions, which improves the accuracy of abnormal detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 It is a flowchart of a method for determining abnormal website requests based on an API in one embodiment of the present invention;
[0044] Figure 2 A schematic diagram of four access requests grouped into one group in one embodiment of the present invention;
[0045] Figure 3 Based on Figure 2 A schematic diagram of a tree structure constructed by access requests in;
[0046] Figure 4 The structure diagram of an API-based website abnormal request determination device in one embodiment of the present invention. DETAILED DESCRIPTION
[0047] In a first aspect, an embodiment of the present invention provides a method for determining abnormal website requests based on an API, see Figure 1 The method comprises the following steps S110 to S140:
[0048] S110, obtaining an API instance of a preset website within a first time period by automatic discovery;
[0049] The first time period is, for example, the most recent month.
[0050] In one embodiment, the step of acquiring the API instance of the preset website in the first time period by automatic discovery in S110 may include:
[0051] S111, dividing each website request of the preset website within the first time period into corresponding groups according to the request mode, and generating a corresponding tree structure according to the URL of each website request in each group;
[0052] For example, there are four request methods: GET, POST, DELETE, and PUT. In this way, the website requests of each website in the first time period can be divided into four groups, and then a corresponding tree structure is generated according to the URLs of the website requests in each group.
[0053] For example, for each access request with the request method of GET, see Figure 2 The tree structure corresponding to the groups formed by each access request based on the request method of GET is Figure 3 ,exist Figure 3 It includes a root node and two first-level child nodes, and each child node includes its own child nodes.
[0054] S112: If the number of website requests for the preset website in the first time period reaches a preset number, merge the nodes in each tree structure; wherein each child node in the merged tree structure is the API instance.
[0055] Each time a request is received, it is determined whether the number of requests currently received has reached a preset number or whether the current time period has reached a first time period. If so, the child nodes in the tree structure are aggregated.
[0056] The merging process of each node in the tree structure in S112 may include the following steps 1-6:
[0057] 1. Calculate the number of child nodes under each parent node with child nodes;
[0058] 2. If the number of child nodes is greater than the specified threshold or the child node matches the specified regular expression, the similarity between all child nodes under the corresponding parent node is calculated to form a similarity matrix, and the mean of the similarity matrix is calculated;
[0059] That is, if the number of child nodes under a node is greater than the specified threshold, or the child node matches the specified regular expression, the similarity between the child nodes is calculated. For example, the similarity between two child nodes is calculated using the Jaccard similarity index. The similarity matrix is constructed using the similarity between the child nodes, and the mean of each element in the similarity matrix is calculated, and the mean is used as the evaluation value of these child nodes.
[0060] 3. Based on the similarity matrix, the Z-score is used to calculate the discrete values of all child nodes under the parent node;
[0061] 4. Based on the similarity matrix, calculate the entropy values of all child nodes under the parent node;
[0062] 5. Calculate the merged scores corresponding to all child nodes under the parent node according to the mean, the discrete value and the entropy value;
[0063] The combined score may be calculated using a first calculation formula, which is:
[0064] R=a*sb*kc*h
[0065] Among them, a, b, c are weights, R is the merge score, s is the mean, k is the discrete value, and h is the entropy value.
[0066] 6. If the merge score exceeds a preset threshold, all child nodes under the parent node are merged to obtain a merged API instance.
[0067] It can be seen that if the merge score exceeds the preset threshold, it is considered that all child nodes under the parent node can be merged into a unified representation, so a merge process is performed, and the merged node is used as an API instance.
[0068] S120, collect statistics on the API instance, and build an abnormal baseline according to the statistical results; wherein the abnormal baseline includes a time baseline, a region baseline, and a client baseline; the time baseline includes a baseline of the number of access requests corresponding to each time period of a day, and the region baseline includes a set of request source regions corresponding to each time period of a day and a baseline of the number of requests of each request source region in each time period;
[0069] Among them, a sliding time window method can be used to calculate sample data of a specified number of days from the current time every day in units of days. As the sample data slides forward with the date, the abnormal baseline of website visits also changes.
[0070] The construction process of the regional baseline may include:
[0071] 1. Determine the request source region corresponding to the access request of each API instance in each time period of each day within the first time period;
[0072] 2. By sliding the time window, count the distribution of the request source regions in each time period of each day in the current time window, and obtain the request source region set in each time period of each day in the current time window; count the average number of requests corresponding to each request source region in each time period of each day in the current time window, and use the average number of requests as the baseline of the number of requests for the request source region in the time period in the current time window.
[0073] For example, a day is divided into 24 time periods, with each hour being one time period.
[0074] For example, if the time window is 7 days, then the baseline of the number of requests from the request source region a2 in time period a1 is the average number of requests from the request source region a2 in the 7 time periods a1 in these 7 days. The request source regions of each access request in the 7 time periods a1 in these 7 days are aggregated to obtain the request source region set corresponding to this time period a1. Time period a1, for example, is 8:00-9:00 in the morning.
[0075] In the process of building the regional baseline, requests from the same IP address to the same site are treated as one request to prevent a large number of requests from the same IP from diluting the sample.
[0076] The process of constructing the time baseline may include:
[0077] 1. Count the number of access requests for each API instance in each time period of each day within the current time window to obtain the set of access request numbers for the API instance in the time period;
[0078] 2. Remove the maximum and minimum values in the set of access request numbers for each API instance in each time period, calculate the average value of each data after removing the maximum value, and use the average value as the baseline of the access request number of the API instance in the time period.
[0079] For example, a time window is 7 days. The number of access requests to API instance x1 in the current time window between 8:00 and 9:00 in the morning for 7 days is counted to obtain 7 statistical values. These 7 statistical values form the set of access request numbers for API instance x1 between 8:00 and 9:00 in the morning. Remove the maximum and minimum values in the set. By removing the maximum value, the interference of abnormal data samples on sample data can be reduced. After removing the maximum value, average the remaining 5 statistical values, and the obtained average value is the baseline of the number of access requests for API instance x1 between 8:00 and 9:00 in the morning.
[0080] The process of constructing the client baseline may include:
[0081] The currently determined normal clients are sorted to determine the regular matching expression of the normal clients; or the currently determined abnormal clients are sorted to determine the regular matching expression of the abnormal clients; the regular matching expression of the normal client or the regular matching expression of the abnormal client is used as the client baseline.
[0082] The set formed by the currently determined abnormal clients can be enumerated as the regular matching expression of the abnormal clients. The set formed by the currently determined normal clients can be used as the regular matching expression of the normal and abnormal clients.
[0083] S130: when receiving the access request of the preset website, extracting the request source region and the client from the access request, and counting a first access quantity, where the first access quantity is the number of access requests within the time period when the access request is received;
[0084] S140: Determine whether the current access request is an abnormal website request based on the request source region and the client, the first page views, and the abnormal baseline extracted from the current access request.
[0085] In one embodiment, determining whether the access request is an abnormal website request according to the request source region and the client, the first access volume, and the abnormal baseline extracted from the access request in S140 may include S141 to S144:
[0086] S141, determining a correction factor p that changes due to a change in the time period;
[0087] Among them, the correction factor is used to correct the abnormal data in the seasonal changes of time series data. Since the changes of some data in different seasons or time periods will cause the accuracy of the judgment results to decrease with the introduction of abnormal values, the introduction of the correction factor can eliminate this influence and obtain more accurate judgment results.
[0088] It is understandable that the website access situation is often affected by the uncertainty of actual holidays, special events, etc. during the quarterly changes. Different time periods sometimes show special situations. If the sample for building the baseline contains data from abnormal time periods, it will have a great impact on the prediction. Therefore, in the process of statistically analyzing the website access request samples, the correction factor for website access can be constructed based on the website's historical access behavior with a weekly time period. The default correction factor for normal website conditions is 0.15, and the website's request access volume fluctuates between 0.85 and 1.15 of the normal request volume. Different website businesses have their own seasonal changes, and the correction factor p is introduced according to the specific situation of the website.
[0089] S142, determining whether the request source region of the current access request is included in the request source region set corresponding to the time period in which the time when the current access request is received in the regional baseline; if not, the current access request is an abnormal website request; if so, determining whether the number of requests from the request source region of the current access request in the time period exceeds (p+1) times the corresponding request number baseline; if exceeded, the current access request is an abnormal website request; if not exceeded, proceeding to the next step;
[0090] That is, determine whether the request source region of this access request exists in the request source region set of the corresponding time period in the regional baseline. If so, continue to determine whether the number of requests from the request source region of this access request in this time period is greater than (p+1) times the request number baseline of this time period. If so, this access request is considered to be an abnormal website request. If not, further judgment is required based on the time baseline and the client baseline.
[0091] S143, determining whether the first access volume exceeds (p+1) times the access request quantity baseline of the corresponding time period in the time baseline; if exceeded, the current access request is an abnormal website request; if not exceeded, proceeding to the next step;
[0092] That is to say, if the number of access requests in the time period of this access request does not exceed (p+1) times the number of access requests baseline corresponding to this time period in the time baseline, then further judgment is required according to the client baseline. If it exceeds, this access request is considered to be an abnormal request of the website.
[0093] S144. Determine whether the client of the current access request matches the regular matching expression of the normal client. If so, the current access request is a normal request for the website. If not, the current access request is an abnormal request for the website. Alternatively, determine whether the client of the current access request matches the regular matching expression of the abnormal client. If not, the current access request is a normal request for the website. If so, the current access request is an abnormal request for the website.
[0094] That is, if the client of this access request is a normal client, this access request is considered to be a normal request of the website. If the client of this access request is an abnormal client, this access request is considered to be an abnormal request of the website.
[0095] The embodiment of the present invention realizes the detection of abnormal requests of the website through the dimension of API instances. In order to be able to detect through the dimension of API instances, a set of automatic discovery methods of API instances is proposed. The number of access requests to the website will produce periodic changes with the differences in the website's own services. However, in addition to the periodic changes, some abnormal interference will affect the sample values and ultimately generate an inaccurate baseline. The embodiment of the present invention reduces the impact of this situation on the data through a "correction factor" and improves the accuracy of judgment. At the same time, the detection of anomalies is not only the statistics of the number of visits, but also the statistics of the request source region and client, making the detection of website anomalies more comprehensive.
[0096] It can be seen that the embodiment of the present invention improves the accuracy of abnormal request detection on the website by building an abnormal baseline on the API instance, building different baselines for API instances with different functions, and refining abnormal requests from the dimension of API instances. At the same time, abnormal access requests are judged from three dimensions: region, time, and client. Compared with traditional abnormal requests, this judgment method performs detection from different dimensions, which improves the accuracy of abnormal detection.
[0097] In a second aspect, an embodiment of the present invention provides an API-based website abnormal request determination device, see Figure 4 , the device comprises:
[0098] A first acquisition module, used to acquire an API instance of a preset website within a first time period by automatic discovery;
[0099] A baseline construction module is used to collect statistics on the API instance and construct an abnormal baseline based on the statistical results; wherein the abnormal baseline includes a time baseline, a region baseline and a client baseline; the time baseline includes a baseline of the number of access requests corresponding to each time period of a day, and the region baseline includes a set of request source regions corresponding to each time period of a day and a baseline of the number of requests of each request source region in each time period;
[0100] an information determination module, configured to extract a request source region and a client from the access request when receiving the access request for the preset website, and to count a first access quantity, wherein the first access quantity is the number of access requests within a time period when the access request is received;
[0101] The baseline comparison module is used to determine whether the current access request is an abnormal website request based on the request source region and the client, the first access volume and the abnormal baseline extracted from the current access request.
[0102] In one embodiment, the first acquisition module includes:
[0103] A request grouping unit, used to divide each website request of the preset website within the first time period into corresponding groups according to the request mode, and generate a corresponding tree structure according to the URL of each website request in each group;
[0104] The node merging unit is used to merge the nodes in each tree structure if the number of website requests of the preset website in the first time period reaches a preset number; wherein each child node in the merged tree structure is the API instance.
[0105] In one embodiment, the node merging unit is specifically used to: calculate the number of child nodes under each parent node with child nodes; if the number of child nodes is greater than a specified threshold or the child node matches a specified regular expression, calculate the similarity between all child nodes under the corresponding parent node, form a similarity matrix, and calculate the mean of the similarity matrix; based on the similarity matrix, use the Z-score to calculate the discrete values of all child nodes under the parent node; based on the similarity matrix, calculate the entropy value of all child nodes under the parent node; calculate the merge score corresponding to all child nodes under the parent node according to the mean, the discrete value and the entropy value; if the merge score exceeds a preset threshold, merge all child nodes under the parent node to obtain a merged API instance; wherein, the merge score is calculated using a first calculation formula, and the first calculation formula is:
[0106] R=a*sb*kc*h
[0107] Among them, a, b, c are weights, R is the merge score, s is the mean, k is the discrete value, and h is the entropy value.
[0108] In one embodiment, the baseline building module includes:
[0109] The regional baseline construction unit is used to determine the request source region corresponding to the access request of each API instance in each time period of each day within the first time period; by sliding the time window, count the distribution of the request source region in each time period of each day under the current time window, and obtain the request source region set in each time period of each day in the current time window; count the average number of requests corresponding to each request source region in each time period of each day in the current time window, and use the average number of requests as the request number baseline of the request source region in the time period under the current time window.
[0110] In one embodiment, the baseline building module includes:
[0111] The time baseline construction unit is used to count the number of access requests of each API instance in each time period of each day in the current time window, and obtain the set of access request numbers of the API instance in the time period; remove the maximum and minimum values in the set of access request numbers of each API instance in each time period, and calculate the average value of each data after removing the maximum value, and use the average value as the baseline of the access request number of the API instance in the time period.
[0112] In one embodiment, the baseline building module includes:
[0113] The client baseline construction unit is used to sort out the currently determined normal clients to determine the regular matching expression of the normal clients; or to sort out the currently determined abnormal clients to determine the regular matching expression of the abnormal clients; and use the regular matching expression of the normal client or the regular matching expression of the abnormal client as the client baseline.
[0114] In one embodiment, the baseline comparison module is specifically used to: determine the correction factor p that changes due to the change of the time period; determine whether the request source region of the current access request is included in the request source region set corresponding to the time period when the current access request is received in the regional baseline; if not, the current access request is an abnormal website request; if so, determine whether the number of requests from the request source region of the current access request within the time period exceeds (p+1) times the corresponding request number baseline; if exceeded, the current access request is an abnormal website request; if not, proceed to the next step; determine whether the first access volume exceeds The method further comprises the following steps: determining whether the access request number of the current access request matches the regular matching expression of the normal client, and if so, the access request is a normal request for the website; if not, the access request is an abnormal request for the website; or determining whether the access request number of the current access request matches the regular matching expression of the abnormal client, and if so, the access request is a normal request for the website; if not, the access request is an abnormal request for the website.
[0115] It is understandable that the explanation, specific implementation, beneficial effects, examples, etc. of the relevant contents in the device provided in the embodiment of the present invention can be found in the corresponding parts of the method provided in the first aspect, and will not be repeated here.
[0116] In a third aspect, an embodiment of the present invention provides a computer-readable medium, on which computer instructions are stored. When the computer instructions are executed by a processor, the processor executes the method provided in the first aspect.
[0117] Specifically, a system or device equipped with a storage medium can be provided, on which software program code that implements the functions of any of the above-mentioned embodiments is stored, and a computer (or CPU or MPU) of the system or device can be enabled to read and execute the program code stored in the storage medium.
[0118] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.
[0119] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer by a communication network.
[0120] In addition, it should be clear that the functions of any of the above embodiments can be implemented not only by executing the program code read by the computer, but also by enabling an operating system operating on the computer to complete part or all of the actual operations based on instructions from the program code.
[0121] In addition, it can be understood that the program code read from the storage medium is written to a memory provided in an expansion board inserted into the computer or to a memory provided in an expansion module connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or expansion module is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above-mentioned embodiments.
[0122] It is understandable that the explanation, specific implementation methods, beneficial effects, examples, etc. of the relevant contents in the computer-readable medium provided in the embodiment of the present invention can be found in the corresponding parts of the method provided in the first aspect, and will not be repeated here.
[0123] In a fourth aspect, an embodiment of the present specification provides a computing device, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, it implements the method in any embodiment of the specification.
[0124] It is understandable that the explanation, specific implementation, beneficial effects, examples, etc. of the relevant contents in the computing device provided in the embodiment of the present invention can be found in the corresponding parts of the method provided in the first aspect, and will not be repeated here.
[0125] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0126] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the present invention can be implemented by hardware, software, widgets, or any combination thereof. When implemented by software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium.
[0127] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solution of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for determining abnormal website requests based on an API, characterized in that: include: Obtaining the API instance of the preset website in the first time period by automatic discovery; Statistics are collected on the API instance, and an abnormal baseline is constructed based on the statistical results; wherein the abnormal baseline includes a time baseline, a region baseline, and a client baseline; the time baseline includes a baseline of the number of access requests corresponding to each time period of a day, and the region baseline includes a set of request source regions corresponding to each time period of a day and a baseline of the number of requests from each request source region in each time period; When receiving the access request of the preset website, extracting the request source region and the client from the access request, and counting a first access quantity, where the first access quantity is the number of access requests within the time period when the access request is received; Whether the current access request is an abnormal website request is determined according to the request source region and the client, the first access volume, and the abnormal baseline extracted from the current access request.
2. The method according to claim 1, characterized in that The step of obtaining an API instance of a preset website within a first time period by automatically discovering the API instance includes: Divide each website request of the preset website within the first time period into corresponding groups according to the request mode, and generate a corresponding tree structure according to the URL of each website request in each group; If the number of website requests of the preset website in the first time period reaches a preset number, each node in the tree structure is merged; wherein each child node in the merged tree structure is the API instance.
3. The method according to claim 2, characterized in that The merging process of each node in the tree structure includes: Calculate the number of child nodes under each parent node that has child nodes; If the number of child nodes is greater than the specified threshold or the child node matches the specified regular expression, the similarity between all child nodes under the corresponding parent node is calculated to form a similarity matrix, and the mean of the similarity matrix is calculated; Based on the similarity matrix, the discrete values of all child nodes under the parent node are calculated using the Z-score; Based on the similarity matrix, the entropy values of all child nodes under the parent node are calculated; Calculate the merge scores corresponding to all child nodes under the parent node according to the mean, the discrete value and the entropy value; If the merge score exceeds a preset threshold, all child nodes under the parent node are merged to obtain a merged API instance; The combined score is calculated using a first calculation formula, which is: R=a*sb*kc*h Among them, a, b, c are weights, R is the merge score, s is the mean, k is the discrete value, and h is the entropy value.
4. The method according to claim 1, characterized in that: The construction process of the regional baseline includes: Determine a request source region corresponding to an access request of each API instance in each time period of each day within the first time period; By sliding the time window, the distribution of request source regions in each time period of each day in the current time window is counted to obtain the request source region set in each time period of each day in the current time window; the average number of requests corresponding to each request source region in each time period of each day in the current time window is counted, and the average number of requests is used as the baseline of the number of requests for the request source region in the time period in the current time window.
5. The method according to claim 1, characterized in that The construction process of the time baseline includes: Count the number of access requests for each API instance in each time period of each day in the current time window to obtain a set of the number of access requests for the API instance in the time period; Remove the maximum and minimum values in the set of access request numbers for each API instance in each time period, calculate the average value of each data after removing the maximum value, and use the average value as the baseline of the access request number of the API instance in the time period.
6. The method according to claim 1, characterized in that The process of building the client baseline includes: The currently determined normal clients are sorted to determine the regular matching expression of the normal clients; or the currently determined abnormal clients are sorted to determine the regular matching expression of the abnormal clients; the regular matching expression of the normal client or the regular matching expression of the abnormal client is used as the client baseline.
7. The method according to claim 6, characterized in that The determining whether the access request is an abnormal website request according to the request source region and the client extracted from the access request, the first page views, and the abnormal baseline includes: Determine the correction factor p that changes due to the change of time period; Determine whether the request source region of the current access request is included in the request source region set corresponding to the time period in which the current access request is received in the regional baseline; if not, the current access request is an abnormal website request; if so, determine whether the number of requests from the request source region of the current access request in the time period exceeds (p+1) times the corresponding request number baseline; if exceeded, the current access request is an abnormal website request; if not, proceed to the next step; Determine whether the first access volume exceeds (p+1) times the access request quantity baseline of the corresponding time period in the time baseline; if exceeded, the access request is an abnormal website request; if not exceeded, proceed to the next step; Determine whether the client of the current access request matches the regular matching expression of the normal client. If so, the current access request is a normal request for the website; if not, the current access request is an abnormal request for the website; or, determine whether the client of the current access request matches the regular matching expression of the abnormal client. If not, the current access request is a normal request for the website; if so, the current access request is an abnormal request for the website.
8. A website abnormal request determination device based on API, characterized in that: include: A first acquisition module, used to acquire an API instance of a preset website within a first time period by automatic discovery; A baseline construction module is used to collect statistics on the API instance and construct an abnormal baseline based on the statistical results; wherein the abnormal baseline includes a time baseline, a region baseline and a client baseline; the time baseline includes a baseline of the number of access requests corresponding to each time period of a day, and the region baseline includes a set of request source regions corresponding to each time period of a day and a baseline of the number of requests of each request source region in each time period; an information determination module, configured to extract a request source region and a client from the access request when receiving the access request for the preset website, and to count a first access quantity, wherein the first access quantity is the number of access requests within a time period when the access request is received; The baseline comparison module is used to determine whether the current access request is an abnormal website request based on the request source region and the client, the first access volume and the abnormal baseline extracted from the current access request.
9. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed in a computer, the computer is caused to execute the method according to any one of claims 1 to 7.
10. A computing device, characterized in that: The method comprises a memory and a processor, wherein the memory stores executable codes, and when the processor executes the executable codes, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Exception determination method and device for application programming interface API
CN110673973A
API abnormal access behavior detection method and system
CN116668185A
API (Application Program Interface) abnormal access behavior detection method and device and electronic equipment
CN117336032A
Methods and apparatus for analyzing sequences of application programming interface traffic to identify potential malicious actions
US20190114417A1
Anomaly detection based on an event tree
US20220222238A1
