Security detection method and device, equipment, storage medium and product

By obtaining and counting interface call logs, combined with adjacent period data and approximate interface correlation, the problem of poor existing API security detection results is solved, more accurate security detection is achieved, and human maintenance costs are reduced.

CN118656258APending Publication Date: 2024-09-17CHINA MOBILE INFORMATION TECHNOLOGY CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410711739.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-03
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

Existing API security detection methods require a lot of manpower to maintain blacklist detection features and are difficult to cover all business scenarios, resulting in missed reports of attack behaviors and poor detection results.

Method used

By obtaining the interface call log, the security detection data of each detection cycle is counted, the data of the current and adjacent cycles is selected, the interface security detection is performed based on the indicator threshold, and the correlation of the approximate interface is used to assist detection to improve detection accuracy.

Benefits of technology

It achieves more accurate API security detection, reduces false positives and false negatives, improves detection results, and ensures interface security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118656258A
    Figure CN118656258A
Patent Text Reader

Abstract

The invention belongs to the technical field of safety detection, and discloses a safety detection method, device and equipment, a storage medium and a product. The method comprises the steps of obtaining an interface calling log corresponding to a to-be-detected interface; performing statistics on the interface calling logs to obtain security detection data corresponding to each detection period; selecting a current detection period from the detection periods, and obtaining at least one detection period adjacent to the period time corresponding to the current detection period as a target detection period; and performing interface security detection on the to-be-detected interface based on the security detection data corresponding to the current detection period and the target detection period and the index threshold corresponding to the security detection data. According to the method, the calling of each time in the interface calling log is periodically summarized, the security detection data of the specific period is selected, the security detection data is compared with the preset index, various types of detection are carried out, whether the interface is abnormal or not is determined, and corresponding early warning is carried out when the abnormality is found, so that the interface security is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of security detection technology, and in particular to a security detection method, device, equipment, storage medium and product. Background Art

[0002] Application Programming Interface (API) is a predefined function that aims to provide applications and developers with the ability to access a set of routines based on certain software or hardware without having to access the source code or understand the details of the internal working mechanism. Due to the powerful functions of API and its standardization and versatility, API is used more and more widely, including in various scenarios such as microprograms, applications, data sharing and exchange platforms, API gateways, etc., where API interfaces are mainly used to process user input or internal system communication. At the same time, due to the widespread use and powerful functions of API, there are more and more security attacks against API.

[0003] Currently, API security detection methods usually require a lot of manpower to maintain blacklist detection features, which makes it difficult to cover all business scenarios, resulting in underreporting of attack behaviors and poor detection results. Summary of the invention

[0004] The main purpose of the present invention is to provide a safety detection method, device, equipment, storage medium and product, aiming to solve the technical problem that the existing technology has poor effect on API safety detection.

[0005] To achieve the above object, the present invention provides a safety detection method, which comprises the following steps:

[0006] Get the interface call log corresponding to the interface to be detected;

[0007] Collect statistics on the interface call logs to obtain security detection data corresponding to each detection cycle;

[0008] Selecting a current detection cycle from each detection cycle, and obtaining at least one detection cycle with a cycle time adjacent to that corresponding to the current detection cycle as a target detection cycle;

[0009] Interface security detection is performed on the interface to be detected based on the security detection data corresponding to the current detection cycle and the target detection cycle, and the indicator threshold corresponding to the security detection data.

[0010] Optionally, performing interface security detection on the interface to be detected based on the security detection data corresponding to the current detection period and the target detection period, and an indicator threshold corresponding to the security detection data, includes:

[0011] Acquire an approximate interface corresponding to the interface to be detected, where the approximate interface is another interface whose interface correlation with the interface to be detected is greater than a correlation threshold;

[0012] Interface security detection is performed on the interface to be detected according to the security detection data corresponding to the interface to be detected and the approximate interface in the target detection cycle and the current detection cycle, and an indicator threshold corresponding to the security detection data.

[0013] Optionally, obtaining an approximate interface corresponding to the interface to be detected includes:

[0014] Traverse each interface to be compared to obtain the current comparison interface;

[0015] Obtain the parameter body, parameter type and parameter name corresponding to the current comparison interface;

[0016] Determine the subject similarity corresponding to each interface according to the parameter subject corresponding to the interface to be detected and the parameter subject corresponding to the current comparison interface;

[0017] Determine the type similarity corresponding to each interface according to the parameter type corresponding to the interface to be detected and the parameter type corresponding to the current comparison interface;

[0018] Determine the name similarity corresponding to each interface according to the parameter name corresponding to the interface to be detected and the parameter name corresponding to the current comparison interface;

[0019] Determining interface relevance according to the subject similarity, the type similarity and the name similarity;

[0020] If the interface relevance is greater than the relevance threshold, the current comparison interface is used as an approximate interface;

[0021] At the end of the traversal, an approximate interface corresponding to the interface to be detected is obtained.

[0022] Optionally, before taking the current comparison interface as the approximate interface corresponding to the interface to be detected if the interface correlation is greater than the correlation threshold, the method further includes:

[0023] If there are interfaces to be compared that are determined to be approximate interfaces, the number of approximate interfaces is obtained, and a correlation average is determined according to the interface correlations corresponding to each approximate interface;

[0024] Determine an envelope value according to the correlation mean and the number of approximate interfaces, wherein the envelope value is used to characterize a maximum change in the correlation of an interface similar to the interface to be detected;

[0025] A correlation threshold is determined according to the envelope value and the correlation mean.

[0026] Optionally, determining the interface relevance according to the subject similarity, the type similarity and the name similarity includes:

[0027] If the subject similarity, the type similarity or the name similarity is zero, then the interface relevance is determined to be zero;

[0028] If the subject similarity, the type similarity and the name similarity are all non-zero, the name similarity is used as the interface relevance.

[0029] Optionally, the interface security detection includes inflow flow detection, outflow flow detection and / or call detection;

[0030] The acquiring at least one detection cycle adjacent to the cycle time corresponding to the current detection cycle as the target detection cycle includes:

[0031] According to the detection type of the interface security detection, extracting a type comparison value from the security detection data corresponding to the current detection cycle of the interface to be detected;

[0032] If the type comparison value is greater than the determination threshold corresponding to the detection type, at least one detection cycle adjacent to the cycle time corresponding to the current detection cycle is obtained as the target detection cycle.

[0033] In addition, to achieve the above object, the present invention also provides a safety detection device, the safety detection device comprising:

[0034] The acquisition module is used to obtain the interface call log corresponding to the interface to be detected;

[0035] A statistics module is used to collect statistics on the interface call logs to obtain security detection data corresponding to each detection cycle;

[0036] A selection module, used to select a current detection cycle from each detection cycle, and obtain at least one detection cycle with a cycle time adjacent to the cycle time corresponding to the current detection cycle as a target detection cycle;

[0037] The detection module is used to perform interface security detection on the interface to be detected based on the security detection data corresponding to the current detection cycle and the target detection cycle, and the indicator threshold corresponding to the security detection data.

[0038] In addition, to achieve the above object, the present invention also provides a safety detection device, the safety detection device comprising:

[0039] The acquisition module is used to obtain the interface call log corresponding to the interface to be detected;

[0040] A statistics module is used to collect statistics on the interface call logs to obtain security detection data corresponding to each detection cycle;

[0041] The detection module is used to perform interface security detection on the interface to be detected based on the security detection data and the indicator threshold corresponding to the security detection data.

[0042] In addition, to achieve the above-mentioned purpose, the present invention also proposes a security detection device, which includes: a processor, a memory, and a security detection program stored in the memory and executable on the processor, and the security detection program implements the steps of the security detection method described above when executed by the processor.

[0043] In addition, to achieve the above-mentioned purpose, the present invention also proposes a computer-readable storage medium, on which a security detection program is stored, and when the security detection program is executed, the steps of the security detection method described above are implemented.

[0044] In addition, to achieve the above-mentioned purpose, the present invention also proposes a computer program product, which includes a security detection program, and when the security detection program is executed, the steps of the security detection method described above are implemented.

[0045] The present invention obtains the interface call log corresponding to the interface to be detected; performs statistics on the interface call log to obtain the security detection data corresponding to each detection cycle; selects the current detection cycle from each detection cycle, and obtains at least one detection cycle adjacent to the cycle time corresponding to the current detection cycle as the target detection cycle; performs interface security detection on the interface to be detected based on the security detection data corresponding to the current detection cycle and the target detection cycle, and the index threshold corresponding to the security detection data. Because each call in the interface call log is periodically summarized, and the security detection data of a specific cycle is selected, it is compared with the pre-set index, and multiple types of detection are performed to determine whether the interface is abnormal. When an abnormality is found, a corresponding early warning will be issued, thereby ensuring the safety of the interface. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 It is a schematic diagram of the structure of an electronic device in a hardware operating environment involved in an embodiment of the present invention;

[0047] Figure 2 It is a flowchart of the first embodiment of the safety detection method of the present invention;

[0048] Figure 3 It is a flowchart of the second embodiment of the safety detection method of the present invention;

[0049] Figure 4It is a structural block diagram of the first embodiment of the safety detection device of the present invention.

[0050] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0051] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0052] Reference Figure 1 , Figure 1 It is a schematic diagram of the structure of the security detection equipment of the hardware operating environment involved in the embodiment of the present invention.

[0053] like Figure 1 As shown, the electronic device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (WIreless-FIdelity, WI-FI) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM), or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk storage. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0054] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0055] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module and a security detection program.

[0056] exist Figure 1In the electronic device shown, the network interface 1004 is mainly used for data communication with a network server; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 in the electronic device of the present invention can be set in a security detection device, and the electronic device calls the security detection program stored in the memory 1005 through the processor 1001, and executes the security detection method provided by an embodiment of the present invention.

[0057] The embodiment of the present invention provides a safety detection method, referring to Figure 2 , Figure 2 It is a flowchart of a first embodiment of a safety detection method of the present invention.

[0058] In this embodiment, the safety detection method includes the following steps:

[0059] Step S10: Obtain the interface call log corresponding to the interface to be detected.

[0060] It should be noted that the executor of this embodiment can be the security detection device, and the security detection device can be an electronic device such as a personal computer or a server, or other devices that can achieve the same or similar functions. This embodiment does not limit this. In this embodiment and the following embodiments, the security detection method of the present invention is described by taking the security detection device as an example.

[0061] It should be noted that the interface to be tested can be an API that is designated to be tested for security, and can be pre-specified by the administrator of the security testing device. The API call log is a log that records the API call situation, which may include request parameters (request), response results (response), call time (requestHandleTime), request parameter size (requestSize), response result size (responseSize), etc.

[0062] The request parameters may include: account, key, timestamp, and API request parameters.

[0063] After obtaining the request parameters, the API will perform access control on the call based on the account, key, etc. If the access is illegal, it will directly return to the request end. If the access is legal, it will get the corresponding result of this call and perform the parameter output operation. The parameter output and response result. The call time is the time of the call.

[0064] Specifically, the fields and field meanings included in the interface call log (the separator is "---", the field name is before the separator, and the field meaning is after the separator) can be as follows:

[0065] apiUid---API ID;

[0066] apiName---API name;

[0067] statusCode---HttpStatusCode, http request status code;

[0068] appId---caller application ID;

[0069] appName---caller application name;

[0070] requestHandleTime---request time, UTC;

[0071] requestId---request ID, globally unique;

[0072] requestSize---request size, unit: bytes;

[0073] responseSize---return data size, unit: bytes;

[0074] requestHeaders---header content requested by the client;

[0075] requestBody---the body content requested by the client;

[0076] responseHeaders---header content of API response;

[0077] responseBody---the response content of the API response.

[0078] Step S20: Collect statistics on the interface call log to obtain security detection data corresponding to each detection cycle.

[0079] It should be noted that the detection cycle can be determined based on the calling frequency of the interface to be detected. If the API is called frequently (such as at least once every minute or every hour), the cycle duration can be relatively short, such as one day, one week, etc.; if the API is called occasionally (such as only once a day or a month), the cycle duration can be longer, such as one month, one year, etc.

[0080] Among them, the security detection data may include the number of legal calls, the number of illegal calls, the inflow flow, the variance of the inflow flow, the outflow flow, the variance of the outflow flow, etc.

[0081] In actual use, the statistical process can be:

[0082] 1. For the number of legal calls nRi And the number of illegal calls nW i

[0083] For example, for any detection cycle i, which includes 10 API call data, 2 of which have response results indicating illegal access and 8 of which have response results indicating call results, then the number of legal calls in detection cycle i, nR i =8 and the number of illegal calls nW i =2;

[0084] 2. For inbound traffic IF i and the variance of inflow σIF i

[0085] For example, for any detection cycle i, the request parameter size (requestSize) of the first call is IF i (1) The request parameter size (requestSize) of the second call is IF i (2), ..., the request parameter size (requestSize) of the tenth call is IF i (10), then

[0086] IF i =∑[IF i (1)+IF i (2)+…IF i (10)],

[0087]

[0088] in, It is the average request parameter size of a call within detection period i.

[0089] For the two calls, the traffic difference is mainly in the request parameters, and the traffic difference between accounts, keys, and timestamps is not much. Therefore, the variance of the incoming traffic can be used to obtain the degree of change in the amount of request parameter data for each call within the period.

[0090] 3. ROF for outbound traffic i and the variance of outflow σROF i

[0091] For example, for any detection cycle i, the response size (responseSize) of the first call is ROF i (1) The response size (responseSize) of the second call is ROF i (2), ..., the response size of the tenth call (responseSize) is ROF i(10), then

[0092] ROF i =∑[ROF i (1)+ROF i (2)+…ROF i (10)],

[0093]

[0094] in, It is the average response result size of a call within detection period i.

[0095] Step S30: Select a current detection cycle from each detection cycle, and obtain at least one detection cycle with a cycle time adjacent to that corresponding to the current detection cycle as a target detection cycle.

[0096] It should be noted that selecting the current detection cycle from each detection cycle may be to randomly select one of the detection cycles as the current detection cycle, or to select a detection cycle closest to the current moment as the current detection cycle.

[0097] It should be noted that the specific selection of multiple detection cycles as target detection cycles can be pre-set by the management personnel of the safety detection equipment. Among them, the detection cycles with adjacent cycle times can refer to other detection cycles whose cycle times are close to the cycle time of the current detection cycle and whose corresponding cycle times are earlier than the current detection cycle.

[0098] For example: assuming that each detection cycle is sorted in the order of cycle time, each detection cycle can be represented as 1, 2, 3, ..., L, where L is selected as the current detection cycle. At this time, the number of selected target detection cycles is set to 2, then the two detection cycles L-1 and L-2 can be used as target detection cycles.

[0099] Step S40: performing interface security detection on the interface to be detected based on the security detection data corresponding to the current detection cycle and the target detection cycle, and an indicator threshold corresponding to the security detection data.

[0100] In a specific implementation, the manager of the security detection equipment can set corresponding thresholds for various indicators in the security detection data according to actual needs, and perform security detection based on the thresholds. If any data in the security detection data exceeds the corresponding threshold, it can be determined that an abnormality exists.

[0101] Of course, if interface security detection is performed only by setting thresholds, more false alarms may occur in the end because the detection is too fixed. In order to solve this technical problem, the security detection data of other adjacent detection cycles can be combined to jointly perform security detection and improve the accuracy of detection. Therefore, interface security detection can be performed on the interface to be detected based on the security detection data corresponding to the current detection cycle and the target detection cycle, as well as the indicator threshold corresponding to the security detection data.

[0102] In a specific implementation, since each calculation of the correlation etc. requires a large amount of calculation, in order to avoid unnecessary calculations, the step of obtaining at least one detection cycle adjacent to the cycle time corresponding to the current detection cycle as the target detection cycle in this embodiment may include:

[0103] According to the detection type of the interface security detection, extracting a type comparison value from the security detection data corresponding to the current detection cycle of the interface to be detected;

[0104] If the type comparison value is greater than the determination threshold corresponding to the detection type, at least one detection cycle adjacent to the cycle time corresponding to the current detection cycle is obtained as the target detection cycle.

[0105] It should be noted that interface security detection includes inflow traffic detection, outflow traffic detection and / or call detection, and different types of interface security detection have different selected type comparison values. For example: if the detection type is inflow traffic detection, the type comparison value is the total inflow traffic; if the detection type is outflow traffic detection, the type comparison value is the total outflow traffic; if the detection type is call detection, the type comparison value is the illegal call ratio.

[0106] For ease of understanding, the following example is given:

[0107] The detection process of the inbound flow detection type may include:

[0108] 1. If IF L ≤IF0, then the inflow flow is normal

[0109] Among them, IF L It is the total amount of inflow traffic of the interface to be detected in the current detection cycle; IF0 is the preset inflow traffic threshold, which is an empirical value. As long as the total amount of inflow traffic is not greater than this value, the traffic is considered normal. If it is greater than this value, it is uncertain whether the inflow traffic is normal.

[0110] 2. If IF L >IF0, then

[0111] 1) Determine the inflow volume in the last x cycles

[0112] Wherein x is a preset value, such as x is 2. In addition, the x cycles do not include the current cycle.

[0113] If x is 2, the inflow flow of the L-1 and L-2 cycles will be obtained

[0114] 2) Determine the mean inflow flow rate for x periods and variance

[0115] The average inflow flow = the sum of inflows in all periods / x, and the variance is [(the inflows in each period and square root of the difference) / x].

[0116] It shows the average inflow flow in the last x periods. It shows the degree of change of the inflow flow in the recent x period. The larger the value, the greater the degree of change, that is, the input fluctuation of the API call is large and the API call is unstable.

[0117] 3) Determine other APIs similar to this API (i.e., similar interfaces). For the convenience of description, the API is recorded as API0 and the other selected APIs are recorded as API y .

[0118] 4) Determine the maximum inflow flow of other similar APIs in the x period IF max , average flow rate of x period and variance

[0119] 5) If This indicates that the current API inflow traffic does not change much. If Confirm that the inflow flow is normal. But if L ≤IF max , confirm that the inflow flow is normal. Otherwise, confirm that the flow is abnormal and issue an early warning.

[0120] like If Confirm that the inflow flow is normal. Otherwise, confirm that the flow is abnormal and issue an early warning. Otherwise, confirm that the flow is abnormal and issue an early warning.

[0121] Similar to the inbound traffic detection process, the inbound traffic is converted into all legitimate outbound traffic. The detection process of outbound traffic detection type can include:

[0122] 1. If ROF L ≤ROF0, then the outflow flow is normal

[0123] Among them, ROF L It is the total outflow traffic of the interface to be detected in the current detection cycle; ROF0 is the preset outflow traffic threshold, which is an empirical value. As long as the outflow traffic is not greater than this value, the traffic is considered normal. If it is greater than this value, it is uncertain whether the outflow traffic is normal.

[0124] 2. If ROF L >ROF0, then

[0125] 1) Determine the outflow volume in the last x cycles

[0126] 2) Determine the mean outflow flow rate for x periods and variance

[0127] 3) Identify other APIs similar to this API (i.e., similar interfaces), and the characters used can be consistent with the above;

[0128] 4) Determine the maximum outflow ROF of other similar APIs in x cycles max , average flow rate of x period and variance

[0129] 5) If This indicates that the outflow traffic of the current API does not change much. If Confirm that the outflow flow is normal. But ROF L ≤ROF max Confirm that the outflow flow is normal. Otherwise, confirm that the flow is abnormal and issue an early warning.

[0130] like If Confirm that the outflow flow is normal. Otherwise, confirm that the flow is abnormal and issue an early warning.

[0131] Otherwise, confirm that the traffic is abnormal and issue an early warning.

[0132] The detection process of the detection type call detection can include:

[0133] 1. Determine the proportion of illegal calls

[0134] Among them, nW L is the number of illegal calls in the current detection cycle (i.e., the Lth cycle), nR L is the number of legal calls in the Lth cycle.

[0135] 2. If Confirm that the call is normal

[0136] Among them, R0 is the preset call threshold, which is an empirical value. As long as the illegal call rate is not greater than this value, the call is considered normal. If it is greater than this value, it is uncertain whether the call is normal.

[0137] 3. If but

[0138] 1) Determine the illegal call ratio R1 in the last x cycles

[0139] 2) Identify other APIs similar to this one

[0140] 3) Determine the maximum illegal call ratio R in x cycles of other similar APIs max .

[0141] 4) If If the call is normal, it is confirmed that the call is normal; otherwise, it is confirmed that the call is abnormal and an early warning is issued.

[0142] This embodiment obtains the interface call log corresponding to the interface to be detected; collects statistics on the interface call log to obtain the security detection data corresponding to each detection cycle; selects the current detection cycle from each detection cycle, and obtains at least one detection cycle adjacent to the cycle time corresponding to the current detection cycle as the target detection cycle; performs interface security detection on the interface to be detected based on the security detection data corresponding to the current detection cycle and the target detection cycle, and the index threshold corresponding to the security detection data. Because each call in the interface call log is periodically summarized, and the security detection data of a specific period is selected and compared with the pre-set indicators, multiple types of detection are performed to determine whether the interface is abnormal. When an abnormality is found, a corresponding warning will be issued to ensure the safety of the interface.

[0143] refer to Figure 3 , Figure 3 It is a flow chart of a second embodiment of a safety detection method of the present invention.

[0144] Based on the first embodiment, step S40 of the safety detection method of this embodiment includes:

[0145] Step S401: Acquire an approximate interface corresponding to the interface to be detected.

[0146] It should be noted that the approximate interface may be another interface whose interface correlation with the interface to be detected is greater than a correlation threshold.

[0147] In a specific implementation, in order to accurately obtain the approximate interface corresponding to the interface to be detected, step S401 in this embodiment may include:

[0148] Traverse each interface to be compared to obtain the current comparison interface;

[0149] Obtain the parameter body, parameter type and parameter name corresponding to the current comparison interface;

[0150] Determine the subject similarity corresponding to each interface according to the parameter subject corresponding to the interface to be detected and the parameter subject corresponding to the current comparison interface;

[0151] Determine the type similarity corresponding to each interface according to the parameter type corresponding to the interface to be detected and the parameter type corresponding to the current comparison interface;

[0152] Determine the name similarity corresponding to each interface according to the parameter name corresponding to the interface to be detected and the parameter name corresponding to the current comparison interface;

[0153] Determining interface relevance according to the subject similarity, the type similarity and the name similarity;

[0154] If the interface relevance is greater than the relevance threshold, the current comparison interface is used as an approximate interface;

[0155] At the end of the traversal, an approximate interface corresponding to the interface to be detected is obtained.

[0156] It should be noted that the interface to be compared may be an interface that has not been previously approximately compared with the interface to be detected, and the traversal of the interfaces to be compared may be to select one from the interfaces to be compared in sorted order or randomly as the current comparison interface, wherein the sorting order may be the interface development time of the interface to be compared, alphabetical order of the interface name, etc., and this embodiment does not impose any restrictions on this.

[0157] In actual use, for the convenience of description, the interface to be detected can be recorded as API0, and the current comparison interface to be compared can be recorded as API y , you can remove the parameter body string of API0 and API y The prefix of the parameter subject string (for example, if the parameter subject string of API0 is getObject, then its prefix is ​​get, and after removing the prefix, it becomes Object). If the two subject strings without the prefix are exactly the same, then the subject similarity S1=1 can be determined, otherwise the subject similarity S1=0;

[0158] If the parameter type of API0 is the same as API y If the parameter types are the same, the type similarity S2 = 1, otherwise the subject similarity S2 = 0;

[0159] The parameter name of API0 is matched with API y The similarity between the parameter names is taken as the name similarity S3.

[0160] Among them, there are at least two ways to calculate the name similarity:

[0161] Solution 1: Since the parameter name can reflect the meaning of the parameter, such as name, we can first perform semantic recognition on the parameter name, and then determine the similarity between the two semantics through the existing semantic similarity calculation solution.

[0162] Solution 2: a. Split the parameters to obtain multiple substrings.

[0163] For example, name can be split into n, a, m, e, na, am, me, nam, ane, name.

[0164] b. Determine the maximum identical substring of the two sets of parameters

[0165] For example, the parameter name of API0 is name, which can be divided into n, a, m, e, na, am, me, nam, ane, name. y The parameter name is nam, which is split into n, a, m, na, am, nam. The substrings of the two splits are the same, n, a, m, na, am, nam, but the largest one is nam. In this case, the largest identical substring is determined to be nam.

[0166] c. Similarity is the maximum number of characters in the same substring / min{total number of characters in the parameter name of API0, API y The total number of characters in the parameter name.

[0167] In a specific implementation, in order to reasonably determine the interface relevance, the step of determining the interface relevance according to the subject similarity, the type similarity and the name similarity in this embodiment may include:

[0168] If the subject similarity, the type similarity or the name similarity is zero, then the interface relevance is determined to be zero;

[0169] If the subject similarity, the type similarity and the name similarity are all non-zero, the name similarity is used as the interface relevance.

[0170] It should be noted that the interface correlation is used to characterize the similarity between two interfaces. If the parameter types are different, the parameter subjects are different, or the names are completely dissimilar, it can be determined that the two interfaces are not similar. Therefore, if any of the subject similarity, type similarity, or name similarity is zero, the interface correlation is determined to be zero; and if the subject similarity, type similarity, and name similarity are all non-zero, it means that there is a certain degree of similarity between the two interfaces. The specific similarity can be characterized by name similarity. Therefore, name similarity can be used as interface correlation.

[0171] For example: If one of S1, S2, and S3 is 0, then the API y If it is not similar to API0, select another API that has not been selected and calculate the correlation between the two. If S1, S2, and S3 are all not 0, then the interface correlation = S3.

[0172] If the interface correlation corresponding to the current comparison interface is less than the correlation threshold, it means that the degree of similarity between the current comparison interface and the interface to be detected is low, and the current comparison interface can be reselected; if the interface correlation corresponding to the current comparison interface is greater than or equal to the correlation threshold, the interface to be detected can be used as an approximate interface.

[0173] In a specific implementation, if there is no other API similar to API0 (e.g., only one other API is currently compared), the relevance threshold is an empirical value, which can be obtained by using existing big data analysis or can be pre-set by the manager of the safety detection equipment;

[0174] If there are other APIs similar to API0, the relevance threshold can be set according to the relevant data of the similar APIs. In this case, before the step of taking the current comparison interface as the approximate interface corresponding to the interface to be detected if the interface relevance is greater than the relevance threshold, the following steps may also be included:

[0175] If there are interfaces to be compared that are determined to be approximate interfaces, the number of approximate interfaces is obtained, and a correlation average is determined according to the interface correlations corresponding to each approximate interface;

[0176] Determine an envelope value according to the correlation mean and the number of approximate interfaces, wherein the envelope value is used to characterize a maximum change in the correlation of an interface similar to the interface to be detected;

[0177] A correlation threshold is determined according to the envelope value and the correlation mean.

[0178] For example: a. Determine the number of other APIs similar to the interface to be detected API0, and then obtain the approximate number of interfaces n other ;

[0179] b. Calculate the mean correlation of other APIs currently identified as similar to API0

[0180] Among them, j is the identifier of other APIs similar to API0, S j is the correlation between the jth other API similar to API0 and API0.

[0181] c. Calculate the envelope value

[0182] The envelope value represents the maximum change in correlation of other APIs similar to API0. If the change is greater than this value, other APIs are not correlated with API0.

[0183] d) The correlation threshold is

[0184] When comparing, the currently calculated correlation is not used for comparison, but the adjusted correlation is used for comparison. The adjusted correlation is Where S is the correlation currently calculated.

[0185] if Then determine the API y Not similar to API0. Otherwise, determine API y Similar to API0.

[0186] Step S402: performing interface security detection on the interface to be detected according to the security detection data corresponding to the interface to be detected and the approximate interface in the target detection cycle and the current detection cycle, and the indicator threshold corresponding to the security detection data.

[0187] In actual use, security detection can be performed on the interface to be detected through the security detection data of the interface to be detected and the similar interfaces in the current detection cycle and other cycles close to the current detection cycle, combined with the indicator thresholds set for each indicator in the security detection data, and the security detection data of other cycles and other similar interfaces can be used to assist in detection, thereby trying to improve the accuracy of detection.

[0188] This embodiment improves the accuracy of security detection of the interface to be detected by combining security detection data of similar interfaces to assist detection.

[0189] In addition, an embodiment of the present invention further provides a storage medium, on which a security detection program is stored. When the security detection program is executed by a processor, the steps of the security detection method described above are implemented.

[0190] In addition, an embodiment of the present invention further provides a computer program product, which includes a security detection program. When the security detection program is executed by a processor, the steps of the security detection method described above are implemented.

[0191] Reference Figure 4 , Figure 4 It is a structural block diagram of the first embodiment of the safety detection device of the present invention.

[0192] like Figure 4 As shown, the safety detection device proposed in the embodiment of the present invention includes:

[0193] The acquisition module 10 is used to obtain the interface call log corresponding to the interface to be detected;

[0194] A statistics module 20 is used to collect statistics on the interface call logs to obtain security detection data corresponding to each detection cycle;

[0195] A selection module 30, configured to select a current detection cycle from the detection cycles, and obtain at least one detection cycle with a cycle time adjacent to that corresponding to the current detection cycle as a target detection cycle;

[0196] The detection module 40 is used to perform interface security detection on the interface to be detected based on the security detection data corresponding to the current detection cycle and the target detection cycle, and the indicator threshold corresponding to the security detection data.

[0197] This embodiment obtains the interface call log corresponding to the interface to be detected; collects statistics on the interface call log to obtain the security detection data corresponding to each detection cycle; selects the current detection cycle from each detection cycle, and obtains at least one detection cycle adjacent to the cycle time corresponding to the current detection cycle as the target detection cycle; performs interface security detection on the interface to be detected based on the security detection data corresponding to the current detection cycle and the target detection cycle, and the index threshold corresponding to the security detection data. Because each call in the interface call log is periodically summarized, and the security detection data of a specific period is selected and compared with the pre-set indicators, multiple types of detection are performed to determine whether the interface is abnormal. When an abnormality is found, a corresponding warning will be issued to ensure the safety of the interface.

[0198] Furthermore, the detection module 40 is also used to obtain an approximate interface corresponding to the interface to be detected, wherein the approximate interface is another interface whose interface correlation with the interface to be detected is greater than a correlation threshold; and to perform interface security detection on the interface to be detected according to the security detection data corresponding to the interface to be detected and the approximate interface in the target detection cycle and the current detection cycle, and the indicator threshold corresponding to the security detection data.

[0199] Furthermore, the detection module 40 is also used to traverse each interface to be compared to obtain the current comparison interface; obtain the parameter body, parameter type and parameter name corresponding to the current comparison interface; determine the body similarity corresponding to each interface according to the parameter body corresponding to the interface to be detected and the parameter body corresponding to the current comparison interface; determine the type similarity corresponding to each interface according to the parameter type corresponding to the interface to be detected and the parameter type corresponding to the current comparison interface; determine the name similarity corresponding to each interface according to the parameter name corresponding to the interface to be detected and the parameter name corresponding to the current comparison interface; determine the interface relevance according to the body similarity, the type similarity and the name similarity; if the interface relevance is greater than the relevance threshold, the current comparison interface is used as an approximate interface; at the end of the traversal, the approximate interface corresponding to the interface to be detected is obtained.

[0200] Furthermore, the detection module 40 is also used to obtain the number of approximate interfaces if there is an interface to be compared that is determined to be an approximate interface, and determine a correlation mean based on the interface correlation corresponding to each approximate interface; determine an envelope value based on the correlation mean and the number of approximate interfaces; and determine a correlation threshold based on the envelope value and the correlation mean.

[0201] Furthermore, the detection module 40 is also used to determine that the interface relevance is zero if the subject similarity, the type similarity or the name similarity is zero; if the subject similarity, the type similarity and the name similarity are all not zero, then the name similarity is used as the interface relevance.

[0202] Further, the interface security detection includes inflow flow detection, outflow flow detection and / or call detection;

[0203] The selection module 30 is also used to extract a type comparison value from the security detection data corresponding to the current detection cycle of the interface to be detected according to the detection type of the interface security detection; if the type comparison value is greater than the judgment threshold corresponding to the detection type, then obtain at least one detection cycle adjacent to the cycle time corresponding to the current detection cycle as the target detection cycle.

[0204] It should be understood that the above is only an example and does not constitute any limitation on the technical solution of the present invention. In specific applications, technicians in this field can make settings as needed, and the present invention does not limit this.

[0205] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of the present invention. In practical applications, technicians in this field can select part or all of them according to actual needs to achieve the purpose of the present embodiment, and no limitation is made here.

[0206] In addition, for technical details not fully described in this embodiment, reference can be made to the security detection method provided in any embodiment of the present invention, and will not be repeated here.

[0207] In addition, it should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0208] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0209] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory (ROM) / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0210] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A safety detection method, characterized in that: The safety detection method comprises: Get the interface call log corresponding to the interface to be detected; Collect statistics on the interface call logs to obtain security detection data corresponding to each detection cycle; Selecting a current detection cycle from each detection cycle, and obtaining at least one detection cycle with a cycle time adjacent to that corresponding to the current detection cycle as a target detection cycle; Interface security detection is performed on the interface to be detected based on the security detection data corresponding to the current detection cycle and the target detection cycle, and the indicator threshold corresponding to the security detection data.

2. The safety detection method according to claim 1, characterized in that: The performing interface security detection on the interface to be detected based on the security detection data corresponding to the current detection cycle and the target detection cycle, and the index threshold corresponding to the security detection data, includes: Acquire an approximate interface corresponding to the interface to be detected, where the approximate interface is another interface whose interface correlation with the interface to be detected is greater than a correlation threshold; Interface security detection is performed on the interface to be detected according to the security detection data corresponding to the interface to be detected and the approximate interface in the target detection cycle and the current detection cycle, and an indicator threshold corresponding to the security detection data.

3. The safety detection method according to claim 2, characterized in that: The obtaining an approximate interface corresponding to the interface to be detected includes: Traverse each interface to be compared to obtain the current comparison interface; Obtain the parameter body, parameter type and parameter name corresponding to the current comparison interface; Determine the subject similarity corresponding to each interface according to the parameter subject corresponding to the interface to be detected and the parameter subject corresponding to the current comparison interface; Determine the type similarity corresponding to each interface according to the parameter type corresponding to the interface to be detected and the parameter type corresponding to the current comparison interface; Determine the name similarity corresponding to each interface according to the parameter name corresponding to the interface to be detected and the parameter name corresponding to the current comparison interface; Determining interface relevance according to the subject similarity, the type similarity and the name similarity; If the interface relevance is greater than the relevance threshold, the current comparison interface is used as an approximate interface; At the end of the traversal, an approximate interface corresponding to the interface to be detected is obtained.

4. The safety detection method according to claim 3, characterized in that: If the interface correlation is greater than the correlation threshold, before taking the current comparison interface as the approximate interface corresponding to the interface to be detected, the method further includes: If there are interfaces to be compared that are determined to be approximate interfaces, the number of approximate interfaces is obtained, and a correlation average is determined according to the interface correlations corresponding to each approximate interface; Determine an envelope value according to the correlation mean and the number of approximate interfaces, wherein the envelope value is used to characterize a maximum change in the correlation of an interface similar to the interface to be detected; A correlation threshold is determined according to the envelope value and the correlation mean.

5. The safety detection method according to claim 3, characterized in that: The determining of the interface relevance according to the subject similarity, the type similarity and the name similarity includes: If the subject similarity, the type similarity or the name similarity is zero, then the interface relevance is determined to be zero; If the subject similarity, the type similarity and the name similarity are all non-zero, the name similarity is used as the interface relevance.

6. The safety detection method according to any one of claims 1 to 5, characterized in that: The interface security detection includes inflow flow detection, outflow flow detection and / or call detection; The acquiring at least one detection cycle adjacent to the cycle time corresponding to the current detection cycle as the target detection cycle includes: According to the detection type of the interface security detection, extracting a type comparison value from the security detection data corresponding to the current detection cycle of the interface to be detected; If the type comparison value is greater than the determination threshold corresponding to the detection type, at least one detection cycle adjacent to the cycle time corresponding to the current detection cycle is obtained as the target detection cycle.

7. A safety detection device, characterized in that: The safety detection device comprises: The acquisition module is used to obtain the interface call log corresponding to the interface to be detected; A statistics module is used to collect statistics on the interface call logs to obtain security detection data corresponding to each detection cycle; A selection module, used to select a current detection cycle from each detection cycle, and obtain at least one detection cycle with a cycle time adjacent to the cycle time corresponding to the current detection cycle as a target detection cycle; The detection module is used to perform interface security detection on the interface to be detected based on the security detection data corresponding to the current detection cycle and the target detection cycle, and the indicator threshold corresponding to the security detection data.

8. A safety detection device, characterized in that: The security detection device comprises: a processor, a memory, and a security detection program stored in the memory and executable on the processor, wherein the security detection program implements the steps of the security detection method according to any one of claims 1 to 6 when executed by the processor.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a security detection program, which, when executed, implements the steps of the security detection method according to any one of claims 1 to 6.

10. A computer program product, characterized in that The computer program product includes a security detection program, and when the security detection program is executed, the steps of the security detection method according to any one of claims 1 to 6 are implemented.