[go: up one dir, main page]

CN115314483A - API asset determining method and abnormal calling early warning method - Google Patents

API asset determining method and abnormal calling early warning method Download PDF

Info

Publication number
CN115314483A
CN115314483A CN202210926753.XA CN202210926753A CN115314483A CN 115314483 A CN115314483 A CN 115314483A CN 202210926753 A CN202210926753 A CN 202210926753A CN 115314483 A CN115314483 A CN 115314483A
Authority
CN
China
Prior art keywords
access
historical
api
log
path
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210926753.XA
Other languages
Chinese (zh)
Inventor
李云龙
谭学士
陈祚松
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Secworld Information Technology Beijing Co Ltd
Qax Technology Group Inc
Original Assignee
Secworld Information Technology Beijing Co Ltd
Qax Technology Group Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Secworld Information Technology Beijing Co Ltd, Qax Technology Group Inc filed Critical Secworld Information Technology Beijing Co Ltd
Priority to CN202210926753.XA priority Critical patent/CN115314483A/en
Publication of CN115314483A publication Critical patent/CN115314483A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/04Processing captured monitoring data, e.g. for logfile generation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/22Parsing or analysis of headers

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Data Mining & Analysis (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application provides a method for determining API assets and a method for early warning of abnormal calling, which comprises the following steps: acquiring a historical access log of an API (application programming interface) of a web service; splitting an access address of each access request in the historical access log to obtain an access path of each access request; merging the historical access logs with the same access path to obtain a merged target access log; and performing characteristic analysis on the historical parameters of the target access log to obtain a characteristic threshold value of the API corresponding to the access path, and determining the characteristic threshold value of the API as the API asset. According to the scheme, the characteristic threshold value of the API interface can be automatically determined only by analyzing the historical access log, an API gateway does not need to be additionally deployed, the workload of manually combing the API interface is reduced, the efficiency is greatly improved, careless omission is avoided, the cost is reduced, and the safety is improved.

Description

API资产的确定方法及异常调用的预警方法The determination method of API assets and the early warning method of abnormal calls

技术领域technical field

本申请涉及网络安全技术领域,特别涉及一种API资产的确定方法、API接口异常调用的预警方法、电子设备及计算机可读存储介质。The present application relates to the technical field of network security, and in particular to a method for determining API assets, an early warning method for abnormal calls of API interfaces, electronic equipment, and a computer-readable storage medium.

背景技术Background technique

API接口(Application Programming Interface,应用程序接口),是软件系统不同组成部分衔接的约定。由于近年来软件的规模日益庞大,常常需要把复杂的系统划分成小的组成部分,编程接口的设计十分重要。API interface (Application Programming Interface, Application Programming Interface) is a convention for the connection of different components of a software system. Due to the increasing scale of software in recent years, it is often necessary to divide complex systems into small components, so the design of programming interface is very important.

本申请中涉及的API接口主要是web(WWW是World Wide Web(环球信息网)的缩写,也可以简称为web,中文名字为“万维网”)服务的应用程序接口。API接口作为web服务的重要组成部分,通过API接口,用户可以获得或修改数据,实现程序间的连接,但同时也为攻击者提供了攻击web服务器的机会,攻击者可以通过精心构造的数据包,获得服务器权限,敏感数据等关键信息。所以,对API接口的发现与分析至关重要。现有技术一般是通过API网关或人工梳理登记的管理平台,将web服务器的API接口进行登记,再对这些已知的API接口进行分析。The API interface involved in this application is mainly the application program interface of web (WWW is the abbreviation of World Wide Web (Global Information Network), which can also be referred to as web for short, and the Chinese name is "World Wide Web"). API interface is an important part of web services. Through API interface, users can obtain or modify data and realize the connection between programs, but at the same time, it also provides an opportunity for attackers to attack web servers. Attackers can use carefully constructed data packets to , to obtain key information such as server permissions and sensitive data. Therefore, the discovery and analysis of the API interface is very important. In the prior art, the API interfaces of the web server are generally registered through an API gateway or a management platform manually combed and registered, and then these known API interfaces are analyzed.

但是API接口会随着web服务的更新迭代,也随之变化,仅通过人工梳理的方法,很容易造成疏漏,而且人工梳理很难获取API接口除uri(Uniform Resource Identifier,统一资源标识符)的其他特征。部署API网关同样也需要消耗一定的资源,并增加了开发的复杂性。攻击者对API接口的攻击越来越频繁,如果不能即时的梳理API接口,很难发现攻击者造成的危害,使web服务暴露在危险之中。However, the API interface will change with the update and iteration of the web service. Only through manual sorting, it is easy to cause omissions, and it is difficult to obtain the API interface except uri (Uniform Resource Identifier, Uniform Resource Identifier). other features. Deploying an API gateway also consumes certain resources and increases the complexity of development. Attackers attack the API interface more and more frequently. If the API interface cannot be sorted out in real time, it is difficult to find the damage caused by the attacker, and the web service is exposed to danger.

发明内容Contents of the invention

本申请实施例提供了API资产的确定方法,用以减少人工梳理造成的疏漏和特征不足,提高web服务的安全性。The embodiment of the present application provides a method for determining API assets, so as to reduce omissions and insufficient features caused by manual sorting, and improve the security of web services.

本申请实施例提供了一种API资产的确定方法,包括:The embodiment of this application provides a method for determining API assets, including:

获取web服务的API接口的历史访问日志;Obtain the historical access log of the API interface of the web service;

对所述历史访问日志中每个访问请求的访问地址进行拆分,获得每个访问请求的访问路径;Splitting the access address of each access request in the historical access log to obtain the access path of each access request;

将所述访问路径相同的历史访问日志进行归并,得到归并后的目标访问日志;Merging the historical access logs with the same access path to obtain the merged target access log;

对所述目标访问日志的历史参数进行特征分析,获得所述访问路径对应的API接口的特征阈值,并将所述API接口的特征阈值确定为API资产。Perform characteristic analysis on the historical parameters of the target access log, obtain the characteristic threshold of the API interface corresponding to the access path, and determine the characteristic threshold of the API interface as the API asset.

在一实施例中,所述对所述目标访问日志的历史参数进行特征分析,获得所述访问路径对应的API接口的特征阈值,包括:In an embodiment, the characteristic analysis of the historical parameters of the target access log to obtain the characteristic threshold of the API interface corresponding to the access path includes:

根据所述目标访问日志的历史参数,统计预设时间段内指定参数值的出现次数,获得所述访问路径对应的API接口的流行度特征的特征阈值。According to the historical parameters of the target access log, the number of occurrences of the specified parameter value within a preset time period is counted to obtain the feature threshold of the popularity feature of the API interface corresponding to the access path.

在一实施例中,所述对所述目标访问日志的历史参数进行特征分析,获得所述访问路径对应的API接口的特征阈值,包括:In an embodiment, the characteristic analysis of the historical parameters of the target access log to obtain the characteristic threshold of the API interface corresponding to the access path includes:

根据所述目标访问日志的历史参数,统计不同字段特征的最大值、均值、方差或中位数中的任意一种或多种,获得所述访问路径对应的API接口的字段特征的特征阈值。According to the historical parameters of the target access log, any one or more of the maximum value, mean value, variance or median of different field features is counted to obtain the feature threshold of the field feature of the API interface corresponding to the access path.

在一实施例中,所述对所述目标访问日志的历史参数进行特征分析,获得所述访问路径对应的API接口的特征阈值,包括:In an embodiment, the characteristic analysis of the historical parameters of the target access log to obtain the characteristic threshold of the API interface corresponding to the access path includes:

根据所述目标访问日志的历史参数,提取有效载荷信息中的参数特征和数值型特征的均值,最大值,最小值,方差以及中位数中的任意一种或多种,获得所述访问路径对应的API接口的参数特征和数值型特征的特征阈值。According to the historical parameters of the target access log, extract any one or more of the parameter features and numerical features in the payload information, the maximum value, the minimum value, the variance and the median, and obtain the access path The feature threshold of parameter features and numeric features of the corresponding API interface.

在一实施例中,所述获取web服务的API接口的历史访问日志,包括:In one embodiment, the historical access log of the API interface of the acquisition web service includes:

获取web服务的历史日志数据;Obtain historical log data of web services;

对所述历史日志数据进行解析,获得每个访问请求的目标字段信息;Analyzing the historical log data to obtain target field information of each access request;

根据所述目标字段信息,对所述历史日志数据进行过滤筛选,获得调用API接口的历史访问日志。According to the information of the target field, the historical log data is filtered to obtain the historical access log of calling the API interface.

在一实施例中,所述对所述历史访问日志中每个访问请求的访问地址进行拆分,获得每个访问请求的访问路径,包括:In an embodiment, the splitting the access address of each access request in the historical access log to obtain the access path of each access request includes:

从每个访问请求的访问地址中获取统一资源标识符和域名;Obtain the uniform resource identifier and domain name from the access address of each access request;

将所述统一资源标识符按照拆分标识符,拆分为路径部分和参数部分;Splitting the uniform resource identifier into a path part and a parameter part according to the split identifier;

将所述路径部分和所述域名一起组成所述访问路径。The path part and the domain name are combined to form the access path.

在一实施例中,所述根据所述路径部分,得到所述访问请求的访问路径,包括:In an embodiment, the obtaining the access path of the access request according to the path part includes:

若所述路径部分包含随机字符串,将所述随机字符串替换为指定字符;If the path part contains a random character string, replace the random character string with a specified character;

将所述域名与替换后的路径部分一起组成所述访问路径。The domain name and the replaced path part are combined to form the access path.

在一实施例中,所述方法还包括:从所述历史访问日志中提取API资产。In an embodiment, the method further includes: extracting API assets from the historical access log.

本申请实施例提供了一种API接口异常调用的预警方法,包括:The embodiment of the present application provides an early warning method for API interface abnormal calls, including:

获取web服务的API接口的实时访问日志;Obtain real-time access logs of the API interface of the web service;

从所述实时访问日志中提取实时访问路径和实时访问参数值;Extracting a real-time access path and a real-time access parameter value from the real-time access log;

通过检测模型对所述实时访问路径对应的实时访问参数值进行分析,确定所述实时访问路径对应的API接口是否出现异常调用,并在出现异常调用时输出告警信息;Analyzing the real-time access parameter value corresponding to the real-time access path through the detection model, determining whether an abnormal call occurs in the API interface corresponding to the real-time access path, and outputting an alarm message when an abnormal call occurs;

其中,所述检测模型是根据不同访问路径对应的API接口的特征阈值训练得到的;所述不同访问路径对应的API接口的特征阈值是通过获取web服务的API接口的历史访问日志,对所述历史访问日志中每个访问请求的访问地址进行拆分,获得每个访问请求的访问路径,将所述访问路径相同的历史访问日志进行归并,得到归并后的目标访问日志,之后对所述目标访问日志的历史参数进行特征分析得到。Wherein, the detection model is obtained according to the feature threshold training of API interfaces corresponding to different access paths; The access address of each access request in the historical access log is split to obtain the access path of each access request, and the historical access logs with the same access path are merged to obtain the merged target access log, and then the target The historical parameters of the access log are obtained through characteristic analysis.

本申请实施例还提供了一种电子设备,所述电子设备包括:The embodiment of the present application also provides an electronic device, and the electronic device includes:

处理器;processor;

用于存储处理器可执行指令的存储器;memory for storing processor-executable instructions;

其中,所述处理器被配置为执行上述API资产的确定方法或API接口异常调用的预警方法。Wherein, the processor is configured to execute the method for determining the above-mentioned API assets or the method for early warning of abnormal calling of the API interface.

本申请实施例还提供了一种计算机可读存储介质,所述存储介质存储有计算机程序,所述计算机程序可由处理器执行以完成上述API资产的确定方法或上述API接口异常调用的预警方法。The embodiment of the present application also provides a computer-readable storage medium, the storage medium stores a computer program, and the computer program can be executed by a processor to complete the above-mentioned API asset determination method or the above-mentioned API interface abnormal call early warning method.

本申请上述实施例提供的技术方案,通过获取web服务的API接口的历史访问日志;对历史访问日志中每个访问请求的访问地址进行拆分,获得每个访问请求的访问路径;将访问路径相同的历史访问日志进行归并,得到同一访问路径对应的目标访问日志;对目标访问日志的历史参数进行特征分析,获得访问路径对应的API接口的特征阈值,并将所述API接口的特征阈值确定为API资产。上述技术方案,仅通过分析历史访问日志,即可自动确定API接口的特征阈值,不需要额外部署API网关,降低了人工梳理API接口的工作量,极大了提高了效率,避免了疏漏,降低了成本,提高了安全性。In the technical solution provided by the foregoing embodiments of the present application, by obtaining the historical access log of the API interface of the web service; splitting the access address of each access request in the historical access log to obtain the access path of each access request; Merge the same historical access logs to obtain the target access logs corresponding to the same access path; perform feature analysis on the historical parameters of the target access logs to obtain the feature threshold of the API interface corresponding to the access path, and determine the feature threshold of the API interface for API assets. The above technical solution can automatically determine the feature threshold of the API interface only by analyzing historical access logs, without additional deployment of API gateways, which reduces the workload of manually sorting out API interfaces, greatly improves efficiency, avoids omissions, and reduces Reduced cost and improved safety.

附图说明Description of drawings

为了更清楚地说明本申请实施例的技术方案,下面将对本申请实施例中所需要使用的附图作简单地介绍。In order to illustrate the technical solutions of the embodiments of the present application more clearly, the following briefly introduces the drawings that are used in the embodiments of the present application.

图1为本申请一实施例提供的电子设备的结构示意图;FIG. 1 is a schematic structural diagram of an electronic device provided by an embodiment of the present application;

图2是本申请实施例提供的一种API资产的确定方法的流程示意图;FIG. 2 is a schematic flowchart of a method for determining an API asset provided in an embodiment of the present application;

图3是图2对应实施例中步骤S210的细节流程图;Fig. 3 is a detailed flowchart of step S210 in the embodiment corresponding to Fig. 2;

图4是本申请实施例提供的特征分析的三个部分内容对比示意图;Fig. 4 is a schematic diagram of the content comparison of three parts of the feature analysis provided by the embodiment of the present application;

图5是本申请一实施例提供的payload信息的示意图;Fig. 5 is a schematic diagram of payload information provided by an embodiment of the present application;

图6是本申请实施例提供的一种API接口异常调用的预警方法的流程示意图;6 is a schematic flow diagram of an early warning method for an API interface abnormal call provided by an embodiment of the present application;

图7为本申请一实施例示出的一种API资产的确定装置的框图;FIG. 7 is a block diagram of a device for determining API assets shown in an embodiment of the present application;

图8为本申请一实施例示出的一种API接口异常调用的预警装置的框图。Fig. 8 is a block diagram of an early warning device for an abnormal call of an API interface according to an embodiment of the present application.

具体实施方式Detailed ways

下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述。The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.

相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。同时,在本申请的描述中,术语“第一”、“第二”等仅用于区分描述,而不能理解为指示或暗示相对重要性。Like numbers and letters denote similar items in the following figures, so that once an item is defined in one figure, it does not require further definition and explanation in subsequent figures. Meanwhile, in the description of the present application, the terms "first", "second" and the like are only used to distinguish descriptions, and cannot be understood as indicating or implying relative importance.

图1是本申请实施例提供的电子设备的结构示意图。该电子设备100可以用于执行本申请实施例提供的API资产的确定方法以及API接口异常调用的预警方法。如图1所示,该电子设备100包括:一个或多个处理器102、一个或多个存储处理器可执行指令的存储器104。其中,所述处理器102被配置为执行本申请下述实施例提供的API资产的确定方法以及API接口异常调用的预警方法。FIG. 1 is a schematic structural diagram of an electronic device provided by an embodiment of the present application. The electronic device 100 can be used to execute the method for determining API assets and the method for early warning of abnormal call of API interface provided by the embodiment of the present application. As shown in FIG. 1 , the electronic device 100 includes: one or more processors 102 , and one or more memories 104 storing processor-executable instructions. Wherein, the processor 102 is configured to execute the method for determining API assets and the method for early warning of abnormal calls of API interfaces provided in the following embodiments of the present application.

所述处理器102可以是网关,也可以为智能终端,或者是包含中央处理单元(CPU)、图像处理单元(GPU)或者具有数据处理能力和/或指令执行能力的其它形式的处理单元的设备,可以对所述电子设备100中的其它组件的数据进行处理,还可以控制所述电子设备100中的其它组件以执行期望的功能。The processor 102 may be a gateway, or an intelligent terminal, or a device including a central processing unit (CPU), a graphics processing unit (GPU), or other forms of processing units with data processing capabilities and/or instruction execution capabilities , can process data of other components in the electronic device 100, and can also control other components in the electronic device 100 to perform desired functions.

所述存储器104可以包括一个或多个计算机程序产品,所述计算机程序产品可以包括各种形式的计算机可读存储介质,例如易失性存储器和/或非易失性存储器。所述易失性存储器例如可以包括随机存取存储器(RAM)和/或高速缓冲存储器(cache)等。所述非易失性存储器例如可以包括只读存储器(ROM)、硬盘、闪存等。在所述计算机可读存储介质上可以存储一个或多个计算机程序指令,处理器102可以运行所述程序指令,以实现下文所述的API资产的确定方法以及API接口异常调用的预警方法。在所述计算机可读存储介质中还可以存储各种应用程序和各种数据,例如所述应用程序使用和/或产生的各种数据等。The memory 104 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and/or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and/or cache memory (cache). The non-volatile memory may include, for example, a read-only memory (ROM), a hard disk, a flash memory, and the like. One or more computer program instructions can be stored on the computer-readable storage medium, and the processor 102 can execute the program instructions to implement the method for determining API assets and the method for early warning of API interface abnormal calls described below. Various application programs and various data, such as various data used and/or generated by the application programs, may also be stored in the computer-readable storage medium.

在一实施例中,图1示电子设备100还可以包括输入装置106、输出装置108以及数据采集装置110,这些组件通过总线系统112和/或其它形式的连接机构(未示出)互连。应当注意,图1示的电子设备100的组件和结构只是示例性的,而非限制性的,根据需要,所述电子设备100也可以具有其他组件和结构。In one embodiment, the electronic device 100 shown in FIG. 1 may further include an input device 106, an output device 108, and a data collection device 110, and these components are interconnected through a bus system 112 and/or other forms of connection mechanisms (not shown). It should be noted that the components and structure of the electronic device 100 shown in FIG. 1 are only exemplary rather than limiting, and the electronic device 100 may also have other components and structures as required.

所述输入装置106可以是用户用来输入指令的装置,并且可以包括键盘、鼠标、麦克风和触摸屏等中的一个或多个。所述输出装置108可以向外部(例如,用户)输出各种信息(例如,图像或声音),并且可以包括显示器、扬声器等中的一个或多个。所述数据采集装置110可以采集对象的图像,并且将所采集的图像存储在所述存储器104中以供其它组件使用。示例性地,该数据采集装置110可以为摄像头。The input device 106 may be a device used by a user to input instructions, and may include one or more of a keyboard, a mouse, a microphone, and a touch screen. The output device 108 may output various information (eg, images or sounds) to the outside (eg, a user), and may include one or more of a display, a speaker, and the like. The data acquisition device 110 can acquire images of objects and store the acquired images in the memory 104 for use by other components. Exemplarily, the data collection device 110 may be a camera.

在一实施例中,用于实现本申请实施例的API资产的确定方法以及API接口异常调用的预警方法的示例电子设备100中的各器件可以集成设置,也可以分散设置,诸如将处理器102、存储器104、输入装置106和输出装置108集成设置于一体,而将数据采集装置110分离设置。In one embodiment, the various devices in the example electronic device 100 used to implement the method for determining API assets and the method for early warning of API interface exception calls in the embodiment of the present application can be integrated or distributed, such as the processor 102 , the memory 104, the input device 106 and the output device 108 are integrated into one body, and the data collection device 110 is separately provided.

在一实施例中,用于实现本申请实施例的API资产的确定方法以及API接口异常调用的预警方法的示例电子设备100可以被实现为诸如服务器、台式电脑等智能终端。In an embodiment, the exemplary electronic device 100 for realizing the method for determining API assets and the method for early warning of API interface abnormal calls in the embodiment of the present application may be implemented as a smart terminal such as a server or a desktop computer.

图2是本申请实施例提供的一种API资产的确定方法的流程示意图。如图2所示,该方法包括:步骤S210-步骤S240。Fig. 2 is a schematic flowchart of a method for determining an API asset provided by an embodiment of the present application. As shown in FIG. 2, the method includes: step S210-step S240.

步骤S210:获取web服务的API接口的历史访问日志。Step S210: Obtain the historical access log of the API interface of the web service.

WWW是World Wide Web(环球信息网)的缩写,也可以简称为web,中文名字为“万维网”。web服务是指驻留于因特网上某种类型计算机的程序,可以处理浏览器等web客户端的请求并返回相应响应。WWW is the abbreviation of World Wide Web (Global Information Network), and it can also be referred to as web for short. The Chinese name is "World Wide Web". A web service refers to a program residing in a certain type of computer on the Internet, which can process requests from web clients such as browsers and return corresponding responses.

API接口是指web服务的应用程序接口,通过该API接口可以访问web服务。历史访问日志是相对实时访问日志而言的,是当前时刻之前或一段时间之前的访问日志,访问日志用于记录浏览器等web客户端从web服务上请求网页数据的行为,一条访问请求的访问日志可以包括源ip地址(nternet Protocol Address,互联网协议地址)、目的ip地址、访问的uri(统一资源标识符)、访问的域名、访问时发送的payload(有效载荷)等信息。An API interface refers to an application program interface of a web service, through which the web service can be accessed. Historical access logs are relative to real-time access logs. They are access logs before the current moment or a period of time. Access logs are used to record the behavior of web clients such as browsers requesting web page data from web services. The log may include information such as source ip address (Internet Protocol Address, Internet Protocol Address), destination ip address, accessed uri (Uniform Resource Identifier), accessed domain name, and payload (payload) sent during access.

在一实施例中,web服务的API接口的历史访问日志可以直接存储在web服务器中。在另一实施例中,如图3所示,上述步骤S210具体可以包括以下步骤S211-步骤S213。In an embodiment, the historical access log of the API interface of the web service may be directly stored in the web server. In another embodiment, as shown in FIG. 3 , the above step S210 may specifically include the following steps S211 - S213.

步骤S211:获取web服务的历史日志数据。Step S211: Obtain historical log data of the web service.

其中,web服务的历史日志数据包括API接口的历史访问日志和非API接口的历史访问日志。为进行区分,二者一起统称为历史日志数据。Wherein, the historical log data of the web service includes historical access logs of API interfaces and historical access logs of non-API interfaces. For distinction, the two are collectively referred to as historical log data.

步骤S212:对所述历史日志数据进行解析,获得每个访问请求的目标字段信息。Step S212: Analyze the historical log data to obtain target field information of each access request.

其中,历史日志数据中的一条记录可以认为是一个访问请求。目标字段信息可以包括源ip地址、目的ip地址、访问的uri、访问的域名、访问时发送的payload等信息。Wherein, a record in the historical log data can be regarded as an access request. The target field information may include information such as source ip address, destination ip address, accessed uri, accessed domain name, and payload sent during access.

步骤S213:根据所述目标字段信息,对所述历史日志数据进行过滤筛选,获得调用API接口的历史访问日志。Step S213: According to the target field information, filter the historical log data to obtain the historical access log of calling the API interface.

对历史日志数据进行过滤筛选,仅保留需要分析的属于API接口的历史访问日志。举例来说,对于uri字段来说,以jpg、txt等结尾的uri会被过滤掉,因为这些uri通常是静态资源页面,并不是API接口,故可以从历史日志数据中去除uri以jpg、txt结尾的日志,得到API接口的历史访问日志。Filter the historical log data, and only keep the historical access logs that belong to the API interface that need to be analyzed. For example, for the uri field, uri ending in jpg, txt, etc. will be filtered out, because these uris are usually static resource pages, not API interfaces, so uri ending in jpg, txt can be removed from historical log data At the end of the log, the historical access log of the API interface is obtained.

步骤S220:对所述历史访问日志中每个访问请求的访问地址进行拆分,获得每个访问请求的访问路径。Step S220: Split the access address of each access request in the historical access log to obtain the access path of each access request.

其中,访问地址可以是url(统一资源定位符),也就是网页地址。具体的,从每个访问请求的访问地址中获取uri和域名;将所述uri按照拆分标识符,拆分为路径部分和参数部分;将所述路径部分和所述域名一起组成所述访问路径。Wherein, the access address may be a url (uniform resource locator), that is, a web page address. Specifically, the uri and domain name are obtained from the access address of each access request; the uri is split into a path part and a parameter part according to the split identifier; the path part and the domain name are combined to form the access path.

拆分标识符是指将uri拆分为路径部分和参数部分的标志,拆分标识符之前的部分称为路径部分,拆分标识符之后的部分称为参数部分。举例来说,一个访问请求的uri可能是“/v1/info/create?token=******”,拆分标识符可以是“?”,从而uri可以拆分为“/v1/info/create”和“token=******”,“/v1/info/create”称为路径部分,“token=******”称为参数部分。在一实施例中,域名和路径部分一起组成访问请求的访问路径,举例来说,域名“www.baidu.com”和路径部分“/v1/info/create”一起组成访问路径,从而便于将访问路径作为唯一标识,在步骤S230将访问路径相同的历史访问日志进行归并。The split identifier is a flag that splits the uri into a path part and a parameter part, the part before the split identifier is called the path part, and the part after the split identifier is called the parameter part. For example, the uri of an access request may be "/v1/info/create?token=******", the split identifier may be "?", so the uri may be split into "/v1/info /create" and "token=******", "/v1/info/create" is called the path part, and "token=******" is called the parameter part. In one embodiment, the domain name and the path part together form the access path of the access request. For example, the domain name "www.baidu.com" and the path part "/v1/info/create" together form the access path, so that the access The path is used as a unique identifier, and historical access logs with the same access path are merged in step S230.

在另一实施例中,若所述路径部分包含随机字符串,将所述随机字符串替换为指定字符;将所述域名与替换后的路径部分一起组成所述访问路径。In another embodiment, if the path part contains a random character string, the random character string is replaced with a specified character; and the domain name and the replaced path part are combined to form the access path.

需要说明的是,如果uri中存在一些随机字符串,影响了uri的归并,可以采用替换的方式,先进行替换,再进行归并。如一个访问请求的uri为“/v1/21wq23ewqewq1/create?token=******”,其中,随机字符串“21wq23ewqewq1”每次访问都会变换,针对于这种,可以将随机字符串“21wq23ewqewq1”替换为指定字符“*”,得到“/v1/*/create?token=******”,路径部分变为“/v1/*/create”。之后将域名和替换的路径部分一起组成访问路径,将访问路径作为唯一标识再执行步骤S230进行归并。It should be noted that if there are some random character strings in the uri, which affect the merging of the uri, you can use the replacement method, first replace and then merge. For example, the uri of an access request is "/v1/21wq23ewqewq1/create?token=******", where the random string "21wq23ewqewq1" will change every time it is accessed. For this, the random string " 21wq23ewqewq1" is replaced with the specified character "*", and "/v1/*/create?token=******" is obtained, and the path part becomes "/v1/*/create". Afterwards, the domain name and the replaced path part are combined to form an access path, and the access path is used as a unique identifier, and then step S230 is executed for merging.

步骤S230:将所述访问路径相同的历史访问日志进行归并,得到归并后的目标访问日志。Step S230: Merge the historical access logs with the same access path to obtain the merged target access log.

其中,归并是指将访问路径相同的历史访问日志划分到一起。为进行区分,同一访问路径对应的历史访问日志称为目标访问日志。举例来说,可以将域名为“www.baidu.com”,uri的路径部分为“/v1/info/create”的历史访问日志进行归并,得到“www.baidu.com/v1/info/create”对应的目标访问日志,从而提高特征阈值的分析准确性。Wherein, merging refers to dividing historical access logs with the same access path together. For distinction, historical access logs corresponding to the same access path are called target access logs. For example, historical access logs whose domain name is "www.baidu.com" and the path part of uri is "/v1/info/create" can be merged to obtain "www.baidu.com/v1/info/create" Corresponding target access logs, thereby improving the analysis accuracy of feature thresholds.

步骤S240:对所述目标访问日志的历史参数进行特征分析,获得所述访问路径对应的API接口的特征阈值,并将所述API接口的特征阈值确定为API资产。Step S240: Perform characteristic analysis on the historical parameters of the target access log, obtain the characteristic threshold of the API interface corresponding to the access path, and determine the characteristic threshold of the API interface as an API asset.

其中,历史参数可以包括源ip地址、目的ip地址、访问的uri、访问的域名、访问时发送的payload等信息。API接口以及API接口的特征阈值均属于API资产。Among them, the historical parameters may include information such as source IP address, destination IP address, accessed uri, accessed domain name, and payload sent during access. API interfaces and feature thresholds of API interfaces belong to API assets.

特征分析是指提取目标访问日志中这些历史参数的特征,比如访问某个uri的次数,某个目的ip地址的出现次数、url(uniform resource locator,统一资源定位符)的长度,payload的长度等。Feature analysis refers to extracting the characteristics of these historical parameters in the target access log, such as the number of visits to a certain uri, the number of occurrences of a certain destination ip address, the length of url (uniform resource locator, uniform resource locator), the length of payload, etc. .

其中,特征阈值是指特征的极限值,可以包括最大值、最小值等。例如url的最大长度,payload的最大长度。Wherein, the feature threshold refers to a limit value of a feature, which may include a maximum value, a minimum value, and the like. For example, the maximum length of url and the maximum length of payload.

举例来说,访问某个uri的次数,某个目的ip地址的出现次数、uri的最大长度,payload的最大长度等均可作为访问路径对应的API接口的特征阈值。举例来说,当实时访问日志中某个url的长度超过上述url的最大长度(即超过特征阈值),则可以认为出现了API接口的异常调用。For example, the number of visits to a certain uri, the number of occurrences of a certain destination ip address, the maximum length of the uri, and the maximum length of the payload can all be used as the feature threshold of the API interface corresponding to the access path. For example, when the length of a certain url in the real-time access log exceeds the maximum length of the above url (that is, exceeds the feature threshold), it can be considered that an abnormal call of the API interface has occurred.

如图4所示,特征分析可以包括三个部分,流行度特征、字段特征和payload特征。下面对三种特征的特征阈值获得方式分别展开描述,本申请实施例可以提取其中任意一种、二种或三种特征的特征阈值。As shown in Figure 4, feature analysis may include three parts, popularity feature, field feature and payload feature. The methods for obtaining the feature thresholds of the three features are described below, and the embodiment of the present application can extract the feature thresholds of any one, two or three features.

其中,流行度特征用于表征指定参数值在一段时间内的出现次数。在一实施例中,上述步骤S240可以包括:根据所述目标访问日志的历史参数,统计预设时间段内指定参数值的出现次数,获得所述访问路径对应的API接口的流行度特征的特征阈值。Among them, the popularity feature is used to characterize the number of occurrences of a specified parameter value within a period of time. In an embodiment, the above step S240 may include: according to the historical parameters of the target access log, counting the number of occurrences of the specified parameter value within a preset time period, and obtaining the feature of the popularity feature of the API interface corresponding to the access path threshold.

举例来说,指定参数值的出现次数可以是预设时间段内某个源ip地址的出现次数,某个uri的出现次数。如图4所示,流行度特征可以包括源ip地址的流行度,目的ip地址的流行度,调用uri的流行度,源ip地址对应此uri的流行度等等。其中,流行度特征的特征阈值可以是流行度的具体值。流行度是指在一段时间内的出现次数。For example, the number of occurrences of the specified parameter value may be the number of occurrences of a certain source ip address or the number of occurrences of a certain uri within a preset time period. As shown in Figure 4, the popularity feature may include the popularity of the source ip address, the popularity of the destination ip address, the popularity of calling uri, the popularity of the source ip address corresponding to this uri, and so on. Wherein, the feature threshold of the popularity feature may be a specific value of the popularity. Popularity refers to the number of occurrences over a period of time.

在一实施例中,上述步骤S240可以包括:根据所述目标访问日志的历史参数,统计不同字段特征的最大值、均值、方差或中位数中的任意一种或多种,获得所述访问路径对应的API接口的字段特征的特征阈值。In an embodiment, the above step S240 may include: according to the historical parameters of the target access log, counting any one or more of the maximum value, mean value, variance or median of different field features to obtain the access The characteristic threshold of the field characteristic of the API interface corresponding to the path.

如图4所示,字段特征可以包括url参数的长度、payload的长度、请求响应的时间长度,请求的时间是否在工作时间、响应包的长度、请求头的长度等等。字段特征的特征阈值可以包括字段特征的最大值、均值、方差或中位数中的任意一种或多种。举例来说,目标访问日志中url参数的最大长度可以作为访问路径对应的API接口的字段特征的特征阈值。As shown in Figure 4, the field characteristics may include the length of the url parameter, the length of the payload, the length of the request response, whether the request time is within working hours, the length of the response packet, the length of the request header, and so on. The characteristic threshold of the field characteristic may include any one or more of the maximum value, mean value, variance or median of the field characteristic. For example, the maximum length of the url parameter in the target access log can be used as the feature threshold of the field feature of the API interface corresponding to the access path.

在一实施例中,上述步骤S240还可以包括:根据所述目标访问日志的历史参数,提取有效载荷信息中的参数特征和数值型特征的均值,最大值,最小值,方差以及中位数中的任意一种或多种,获得所述访问路径对应的API接口的参数特征和数值型特征的特征阈值。In an embodiment, the above step S240 may further include: extracting the mean value, maximum value, minimum value, variance and median of parameter features and numerical features in the payload information according to the historical parameters of the target access log. Any one or more of the parameters of the API interface corresponding to the access path and the feature threshold of the numerical feature are obtained.

有效载荷信息(payload)中的参数特征和数值型特征可以统称为payload特征。其中,参数特征包括参数、参数值的类型、层级、父参数。如图5所示,是payload的格式,存在第一层的参数deviceID,center,org,walq,根据参数值的类型,这4个参数可以记录为deviceID_string_0,center_json_0,org_json_0,walq_string_0,其中,0代表第0层,string代表它的参数值是字符串类型,json代表参数值是json类型。同理,下一层的参数userId可以记录为userId_json_1_org,除去第0层的参数,都需要带上它的父参数进行区分,这样payload的参数特征就可以提取出来。举例来说,“userId_json_1_org”就是其中一个参数特征(称为key),“userId”表示参数,“json”表示参数值的类型,“1”表示层级,“org”表示父参数。本申请实施例可以将key和参数值作为payload特征进行存储。The parameter features and numerical features in the payload information (payload) may be collectively referred to as payload features. Wherein, the parameter feature includes the parameter, the type of the parameter value, the level, and the parent parameter. As shown in Figure 5, it is the format of the payload. There are first-level parameters deviceID, center, org, and walq. According to the type of parameter value, these four parameters can be recorded as deviceID_string_0, center_json_0, org_json_0, and walq_string_0, where 0 represents For layer 0, string means its parameter value is a string type, and json means its parameter value is a json type. Similarly, the parameter userId of the next layer can be recorded as userId_json_1_org, except for the parameters of the 0th layer, it needs to be distinguished with its parent parameter, so that the parameter characteristics of the payload can be extracted. For example, "userId_json_1_org" is one of the parameter characteristics (called key), "userId" indicates the parameter, "json" indicates the type of the parameter value, "1" indicates the level, and "org" indicates the parent parameter. In this embodiment of the present application, key and parameter values can be stored as payload characteristics.

其中,数值型特征是指参数特征的特征值,举例来说,参数特征walq_string_0的特征值就是参数值(如wlaqtest)的长度。参数特征org_json_0的特征值就是参数org包含的key的个数,如果参数特征是int型的,则特征值就是它的参数值。数值型特征的特征阈值可以是上述特征值的均值,最大值,最小值,方差以及中位数中的一种或多种。举例来说,当实时访问日志中某个请求的payload信息中包含未出现过的参数特征,则可以认为出现了API的异常调用。举例来说,当实时访问日志中某个请求的payload信息中某个参数的参数值超过该参数的最大值,也可以认为出现了API的异常调用。Among them, the numerical feature refers to the feature value of the parameter feature. For example, the feature value of the parameter feature walq_string_0 is the length of the parameter value (such as wlaqtest). The characteristic value of the parameter characteristic org_json_0 is the number of keys contained in the parameter org. If the parameter characteristic is int type, the characteristic value is its parameter value. The feature threshold of a numerical feature may be one or more of the mean, maximum, minimum, variance, and median of the above-mentioned feature values. For example, when the payload information of a request in the real-time access log contains parameters that have not appeared before, it can be considered that an abnormal API call has occurred. For example, when the parameter value of a parameter in the payload information of a request in the real-time access log exceeds the maximum value of the parameter, it can also be considered that an abnormal API call has occurred.

在另外一个实施例中,上述方法还包括:从历史访问日志中提取API资产。In another embodiment, the above method further includes: extracting API assets from historical access logs.

基于上述任一实施例中得到的API接口的特征阈值后,可以基于API接口的特征阈值,发现API接口,并从历史访问日志中提取API接口的特征阈值和API接口等API资产,从而能够自动发现并提取API资产。Based on the feature threshold of the API interface obtained in any of the above-mentioned embodiments, the API interface can be discovered based on the feature threshold of the API interface, and the feature threshold of the API interface and API assets such as the API interface can be extracted from the historical access log, so that it can automatically Discover and extract API assets.

图6是本申请实施例提供的一种API接口异常调用的预警方法的流程示意图。如图6所示,该方法包括:Fig. 6 is a schematic flow chart of an early warning method for an API interface abnormal call provided by an embodiment of the present application. As shown in Figure 6, the method includes:

步骤S610:获取web服务的API接口的实时访问日志。Step S610: Obtain the real-time access log of the API interface of the web service.

其中,实时访问日志是相当于上文的历史访问日志而言的,可以认为是当前时刻的访问日志,或者最近一段时间的访问日志。Wherein, the real-time access log is equivalent to the historical access log above, and can be regarded as the access log at the current moment, or the access log in the most recent period.

步骤S620:从所述实时访问日志中提取实时访问路径和实时访问参数值。Step S620: Extracting real-time access paths and real-time access parameter values from the real-time access logs.

实时访问路径可以参照上文步骤S220对于访问路径的获得方式。实时访问参数值可以包括上述流行度特征的特征值、字段特征的特征值、参数特征以及数值型特征的特征值。For the real-time access path, refer to the manner of obtaining the access path in step S220 above. The real-time access parameter values may include the feature values of the above-mentioned popularity features, field features, parameter features, and numeric features.

步骤S630:通过检测模型对所述实时访问路径对应的实时访问参数值进行分析,确定所述实时访问路径对应的API接口是否出现异常调用,并在出现异常调用时输出告警信息;Step S630: Analyze the real-time access parameter value corresponding to the real-time access path through the detection model, determine whether the API interface corresponding to the real-time access path has an abnormal call, and output an alarm message when an abnormal call occurs;

其中,所述检测模型是根据不同访问路径对应的API接口的特征阈值训练得到的;而不同访问路径对应的API接口的特征阈值可以采用上文实施例提供的API资产的确定方法获得。Wherein, the detection model is trained according to the feature thresholds of API interfaces corresponding to different access paths; and the feature thresholds of API interfaces corresponding to different access paths can be obtained by using the methods for determining API assets provided in the above embodiments.

其中,检测模型用于判断是否出现API异常调用,检测模型中规定了出现API异常调用时实时访问参数值与特征阈值之间的关系。举例来说,实时访问参数值超过特征阈值时,认为出现异常调用。特征阈值可以参照上文API资产的确定方法实施例中的描述,从历史访问日志中提取得到。Among them, the detection model is used to judge whether there is an abnormal API call, and the detection model specifies the relationship between the real-time access parameter value and the feature threshold when the API abnormal call occurs. For example, when the value of the real-time access parameter exceeds the characteristic threshold, it is considered that an abnormal call occurs. The feature threshold can be obtained from historical access logs with reference to the description in the above embodiment of the method for determining API assets.

举例来说,参数phoneNum代表电话号数字长度,基于历史访问日志统计的长度是11位(即特征阈值),但是实时访问参数值中指示电话号数字长度大于11,且返回的状态是正常,很有可能是攻击者伪造了payload信息,按照检测模型的判断,可以认为是出现了异常的API调用,可以发出告警信息。For example, the parameter phoneNum represents the number length of the phone number. The length based on historical access log statistics is 11 digits (that is, the characteristic threshold), but the real-time access parameter value indicates that the number length of the phone number is greater than 11, and the returned status is normal, very It is possible that the attacker forged the payload information. According to the judgment of the detection model, it can be considered that an abnormal API call has occurred, and an alarm message can be issued.

进一步的,一线运营人员可以对告警信息进行管理,如是误报可以通过人工干预的方法,修改检测模型中的特征阈值,降低误报,提高准确率。此外,API接口除了提供给管理人员对网络安全进行监控,还可以提供给业务线的开发人员,分析API的调用情况和特征阈值,指导业务线迭代优化开发API接口。Furthermore, the front-line operators can manage the alarm information. In the case of false alarms, manual intervention can be used to modify the feature thresholds in the detection model to reduce false alarms and improve accuracy. In addition, the API interface is not only provided to managers to monitor network security, it can also be provided to business line developers to analyze API call status and feature thresholds, and guide business lines to iteratively optimize the development of API interfaces.

下述为本申请装置实施例,可以用于执行本申请上述API资产的确定方法实施例。对于本申请装置实施例中未披露的细节,请参照本申请API资产的确定方法实施例。The following is an embodiment of the device of the present application, which can be used to implement the embodiment of the method for determining the above-mentioned API assets of the present application. For the details not disclosed in the device embodiment of this application, please refer to the embodiment of the method for determining API assets in this application.

图7为本申请一实施例示出的一种API资产的确定装置的框图,如图7所示,该装置包括:Fig. 7 is a block diagram of a device for determining API assets shown in an embodiment of the present application. As shown in Fig. 7, the device includes:

日志获取模块610,用于获取web服务的API接口的历史访问日志;Log obtaining module 610, for obtaining the historical access log of the API interface of web service;

地址拆分模块620,用于对所述历史访问日志中每个访问请求的访问地址进行拆分,获得每个访问请求的访问路径;The address splitting module 620 is configured to split the access address of each access request in the historical access log to obtain the access path of each access request;

日志归并模块630,用于将所述访问路径相同的历史访问日志进行归并,得到归并后的目标访问日志;A log merging module 630, configured to merge historical access logs with the same access path to obtain a merged target access log;

特征分析模块640,用于对所述目标访问日志的历史参数进行特征分析,获得所述访问路径对应的API接口的特征阈值,并将所述API接口的特征阈值确定为API资产。The characteristic analysis module 640 is configured to perform characteristic analysis on the historical parameters of the target access log, obtain the characteristic threshold of the API interface corresponding to the access path, and determine the characteristic threshold of the API interface as an API asset.

上述装置中各个模块的功能和作用的实现过程具体详见上述API资产的确定方法中对应步骤的实现过程,在此不再赘述。For the implementation process of the functions and functions of each module in the above-mentioned device, please refer to the implementation process of the corresponding steps in the method for determining the API asset above for details, and details will not be repeated here.

图8为本申请一实施例示出的一种API接口异常调用的预警装置的框图。如图8所示,该装置包括:Fig. 8 is a block diagram of an early warning device for an abnormal call of an API interface according to an embodiment of the present application. As shown in Figure 8, the device includes:

日志获取模块710,用于获取web服务的API接口的实时访问日志;Log obtaining module 710, for obtaining the real-time access log of the API interface of web service;

地址拆分模块720,用于从所述实时访问日志中提取实时访问路径和实时访问参数值;An address splitting module 720, configured to extract a real-time access path and a real-time access parameter value from the real-time access log;

异常检测模块730,用于通过检测模型对所述实时访问路径对应的实时访问参数值进行分析,确定所述实时访问路径对应的API接口是否出现异常调用,并在出现异常调用时输出告警信息;The abnormal detection module 730 is used to analyze the real-time access parameter value corresponding to the real-time access path through the detection model, determine whether the API interface corresponding to the real-time access path has an abnormal call, and output an alarm message when an abnormal call occurs;

其中,所述检测模型是根据不同访问路径对应的API接口的特征阈值训练得到的;所述不同访问路径对应的API接口的特征阈值是通过获取web服务的API接口的历史访问日志,对所述历史访问日志中每个访问请求的访问地址进行拆分,获得每个访问请求的访问路径,将所述访问路径相同的历史访问日志进行归并,得到归并后的目标访问日志,之后对所述目标访问日志的历史参数进行特征分析得到。Wherein, the detection model is obtained according to the feature threshold training of API interfaces corresponding to different access paths; The access address of each access request in the historical access log is split to obtain the access path of each access request, and the historical access logs with the same access path are merged to obtain the merged target access log, and then the target The historical parameters of the access log are obtained through feature analysis.

上述装置中各个模块的功能和作用的实现过程具体详见上述API接口异常调用的预警方法中对应步骤的实现过程,在此不再赘述。For the implementation process of the functions and functions of each module in the above-mentioned device, please refer to the implementation process of the corresponding steps in the above-mentioned early warning method for API interface abnormal call for details, and will not be repeated here.

在本申请所提供的几个实施例中,所揭露的装置和方法,也可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,附图中的流程图和框图显示了根据本申请的多个实施例的装置、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或代码的一部分,模块、程序段或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。在有些作为替换的实现方式中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或动作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。In the several embodiments provided in this application, the disclosed devices and methods may also be implemented in other ways. The device embodiments described above are only illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the architecture, functions and possible implementations of devices, methods and computer program products according to multiple embodiments of the present application. operate. In this regard, each block in a flowchart or block diagram may represent a module, program segment, or portion of code that contains one or more executable instruction. In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks in succession may, in fact, be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved. It should also be noted that each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented by a dedicated hardware-based system that performs the specified function or action , or may be implemented by a combination of dedicated hardware and computer instructions.

另外,在本申请各个实施例中的各功能模块可以集成在一起形成一个独立的部分,也可以是各个模块单独存在,也可以两个或两个以上模块集成形成一个独立的部分。In addition, each functional module in each embodiment of the present application may be integrated to form an independent part, each module may exist independently, or two or more modules may be integrated to form an independent part.

功能如果以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods in the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes. .

Claims (11)

1.一种API资产的确定方法,其特征在于,包括:1. A method for determining API assets, comprising: 获取web服务的API接口的历史访问日志;Obtain the historical access log of the API interface of the web service; 对所述历史访问日志中每个访问请求的访问地址进行拆分,获得每个访问请求的访问路径;Splitting the access address of each access request in the historical access log to obtain the access path of each access request; 将所述访问路径相同的历史访问日志进行归并,得到归并后的目标访问日志;Merging the historical access logs with the same access path to obtain the merged target access log; 对所述目标访问日志的历史参数进行特征分析,获得所述访问路径对应的API接口的特征阈值,并将所述API接口的特征阈值确定为API资产。Perform characteristic analysis on the historical parameters of the target access log, obtain the characteristic threshold of the API interface corresponding to the access path, and determine the characteristic threshold of the API interface as the API asset. 2.根据权利要求1所述的方法,其特征在于,所述对所述目标访问日志的历史参数进行特征分析,获得所述访问路径对应的API接口的特征阈值,包括:2. The method according to claim 1, wherein the characteristic analysis of the historical parameters of the target access log to obtain the characteristic threshold of the API interface corresponding to the access path comprises: 根据所述目标访问日志的历史参数,统计预设时间段内指定参数值的出现次数,获得所述访问路径对应的API接口的流行度特征的特征阈值。According to the historical parameters of the target access log, the number of occurrences of the specified parameter value within a preset time period is counted to obtain the feature threshold of the popularity feature of the API interface corresponding to the access path. 3.根据权利要求1所述的方法,其特征在于,所述对所述目标访问日志的历史参数进行特征分析,获得所述访问路径对应的API接口的特征阈值,包括:3. The method according to claim 1, wherein the characteristic analysis of the historical parameters of the target access log to obtain the characteristic threshold of the API interface corresponding to the access path comprises: 根据所述目标访问日志的历史参数,统计不同字段特征的最大值、均值、方差或中位数中的任意一种或多种,获得所述访问路径对应的API接口的字段特征的特征阈值。According to the historical parameters of the target access log, any one or more of the maximum value, mean value, variance or median of different field features is counted to obtain the feature threshold of the field feature of the API interface corresponding to the access path. 4.根据权利要求1所述的方法,其特征在于,所述对所述目标访问日志的历史参数进行特征分析,获得所述访问路径对应的API接口的特征阈值,包括:4. The method according to claim 1, wherein the characteristic analysis of the historical parameters of the target access log to obtain the characteristic threshold of the API interface corresponding to the access path comprises: 根据所述目标访问日志的历史参数,提取有效载荷信息中的参数特征和数值型特征的均值,最大值,最小值,方差以及中位数中的任意一种或多种,获得所述访问路径对应的API接口的参数特征和数值型特征的特征阈值。According to the historical parameters of the target access log, extract any one or more of the parameter features and numerical features in the payload information, the maximum value, the minimum value, the variance and the median, and obtain the access path The feature threshold of parameter features and numeric features of the corresponding API interface. 5.根据权利要求1所述的方法,其特征在于,所述获取web服务的API接口的历史访问日志,包括:5. The method according to claim 1, wherein said acquiring the historical access log of the API interface of the web service comprises: 获取web服务的历史日志数据;Obtain historical log data of web services; 对所述历史日志数据进行解析,获得每个访问请求的目标字段信息;Analyzing the historical log data to obtain target field information of each access request; 根据所述目标字段信息,对所述历史日志数据进行过滤筛选,获得调用API接口的历史访问日志。According to the information of the target field, the historical log data is filtered to obtain the historical access log of calling the API interface. 6.根据权利要求1所述的方法,其特征在于,所述对所述历史访问日志中每个访问请求的访问地址进行拆分,获得每个访问请求的访问路径,包括:6. The method according to claim 1, wherein said splitting the access address of each access request in the historical access log to obtain the access path of each access request comprises: 从每个访问请求的访问地址中获取统一资源标识符和域名;Obtain the uniform resource identifier and domain name from the access address of each access request; 将所述统一资源标识符按照拆分标识符,拆分为路径部分和参数部分;Splitting the uniform resource identifier into a path part and a parameter part according to the split identifier; 将所述路径部分和所述域名一起组成所述访问路径。The path part and the domain name are combined to form the access path. 7.根据权利要求6所述的方法,其特征在于,所述将所述路径部分和所述域名一起组成所述访问路径,包括:7. The method according to claim 6, wherein said forming said access path together with said path part and said domain name comprises: 若所述路径部分包含随机字符串,将所述随机字符串替换为指定字符;If the path part contains a random character string, replace the random character string with a specified character; 将所述域名与替换后的路径部分一起组成所述访问路径。The domain name and the replaced path part are combined to form the access path. 8.根据权利要求1-7任一项所述的方法,其特征在于,所述方法还包括:8. The method according to any one of claims 1-7, characterized in that the method further comprises: 从所述历史访问日志中提取API资产。API assets are extracted from the historical access logs. 9.一种API接口异常调用的预警方法,其特征在于,包括:9. An early warning method for an API interface abnormal call, characterized in that it comprises: 获取web服务的API接口的实时访问日志;Obtain real-time access logs of the API interface of the web service; 从所述实时访问日志中提取实时访问路径和实时访问参数值;Extracting a real-time access path and a real-time access parameter value from the real-time access log; 通过检测模型对所述实时访问路径对应的实时访问参数值进行分析,确定所述实时访问路径对应的API接口是否出现异常调用,并在出现异常调用时输出告警信息;Analyzing the real-time access parameter value corresponding to the real-time access path through the detection model, determining whether an abnormal call occurs in the API interface corresponding to the real-time access path, and outputting an alarm message when an abnormal call occurs; 其中,所述检测模型是根据不同访问路径对应的API接口的特征阈值训练得到的;所述不同访问路径对应的API接口的特征阈值是通过获取web服务的API接口的历史访问日志,对所述历史访问日志中每个访问请求的访问地址进行拆分,获得每个访问请求的访问路径,将所述访问路径相同的历史访问日志进行归并,得到归并后的目标访问日志,之后对所述目标访问日志的历史参数进行特征分析得到。Wherein, the detection model is obtained according to the feature threshold training of API interfaces corresponding to different access paths; The access address of each access request in the historical access log is split to obtain the access path of each access request, and the historical access logs with the same access path are merged to obtain the merged target access log, and then the target The historical parameters of the access log are obtained through characteristic analysis. 10.一种电子设备,其特征在于,所述电子设备包括:10. An electronic device, characterized in that the electronic device comprises: 处理器;processor; 用于存储处理器可执行指令的存储器;memory for storing processor-executable instructions; 其中,所述处理器被配置为执行权利要求1-8任意一项所述的API资产的确定方法或权利要求9所述的API接口异常调用的预警方法。Wherein, the processor is configured to execute the method for determining API assets according to any one of claims 1-8 or the method for early warning of API interface abnormal calls according to claim 9 . 11.一种计算机可读存储介质,其特征在于,所述存储介质存储有计算机程序,所述计算机程序可由处理器执行以完成权利要求1-8任意一项所述的API资产的确定方法或权利要求9所述的API接口异常调用的预警方法。11. A computer-readable storage medium, characterized in that the storage medium stores a computer program, and the computer program can be executed by a processor to complete the method for determining API assets described in any one of claims 1-8 or The early warning method of API interface abnormal call described in claim 9.
CN202210926753.XA 2022-08-03 2022-08-03 API asset determining method and abnormal calling early warning method Pending CN115314483A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210926753.XA CN115314483A (en) 2022-08-03 2022-08-03 API asset determining method and abnormal calling early warning method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210926753.XA CN115314483A (en) 2022-08-03 2022-08-03 API asset determining method and abnormal calling early warning method

Publications (1)

Publication Number Publication Date
CN115314483A true CN115314483A (en) 2022-11-08

Family

ID=83859025

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210926753.XA Pending CN115314483A (en) 2022-08-03 2022-08-03 API asset determining method and abnormal calling early warning method

Country Status (1)

Country Link
CN (1) CN115314483A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116015834A (en) * 2022-12-21 2023-04-25 中盈优创资讯科技有限公司 API asset management method and device based on business system
CN116208591A (en) * 2023-02-27 2023-06-02 深圳市安络科技有限公司 API interface checking method, device and equipment
CN116248550A (en) * 2022-12-29 2023-06-09 中国联合网络通信集团有限公司 Interface performance determining method, device and storage medium
CN117150493A (en) * 2023-09-26 2023-12-01 中电云计算技术有限公司 Method and device for identifying API (application program interface) parameter value increment type traversal
CN117978471A (en) * 2024-01-18 2024-05-03 南方电网数字电网集团信息通信科技有限公司 Unauthorized access detection method, device, equipment and storage medium for access request

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140366118A1 (en) * 2013-06-05 2014-12-11 Fortinet, Inc. Cloud based logging service
CN105515836A (en) * 2015-11-27 2016-04-20 小米科技有限责任公司 Log processing method, device and server
CN109743295A (en) * 2018-12-13 2019-05-10 平安科技(深圳)有限公司 Access thresholds method of adjustment, device, computer equipment and storage medium
CN109992470A (en) * 2017-12-29 2019-07-09 北京国双科技有限公司 A kind of threshold adjustment method and device
CN110086649A (en) * 2019-03-19 2019-08-02 深圳壹账通智能科技有限公司 Detection method, device, computer equipment and the storage medium of abnormal flow
CN111092757A (en) * 2019-12-06 2020-05-01 网宿科技股份有限公司 A kind of abnormal data detection method, system and device
CN111159706A (en) * 2019-12-26 2020-05-15 深信服科技股份有限公司 Database security detection method, device, equipment and storage medium
US20210174253A1 (en) * 2019-12-10 2021-06-10 Triad National Security, Llc Analysis of system log data using machine learning
CN114090407A (en) * 2021-11-29 2022-02-25 平安科技(深圳)有限公司 Interface performance early warning method and related equipment based on linear regression model
CN114357394A (en) * 2021-12-16 2022-04-15 绿盟科技集团股份有限公司 Data flow correlation identification method and device, electronic equipment and storage medium

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140366118A1 (en) * 2013-06-05 2014-12-11 Fortinet, Inc. Cloud based logging service
CN105515836A (en) * 2015-11-27 2016-04-20 小米科技有限责任公司 Log processing method, device and server
CN109992470A (en) * 2017-12-29 2019-07-09 北京国双科技有限公司 A kind of threshold adjustment method and device
CN109743295A (en) * 2018-12-13 2019-05-10 平安科技(深圳)有限公司 Access thresholds method of adjustment, device, computer equipment and storage medium
CN110086649A (en) * 2019-03-19 2019-08-02 深圳壹账通智能科技有限公司 Detection method, device, computer equipment and the storage medium of abnormal flow
CN111092757A (en) * 2019-12-06 2020-05-01 网宿科技股份有限公司 A kind of abnormal data detection method, system and device
US20210174253A1 (en) * 2019-12-10 2021-06-10 Triad National Security, Llc Analysis of system log data using machine learning
CN111159706A (en) * 2019-12-26 2020-05-15 深信服科技股份有限公司 Database security detection method, device, equipment and storage medium
CN114090407A (en) * 2021-11-29 2022-02-25 平安科技(深圳)有限公司 Interface performance early warning method and related equipment based on linear regression model
CN114357394A (en) * 2021-12-16 2022-04-15 绿盟科技集团股份有限公司 Data flow correlation identification method and device, electronic equipment and storage medium

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116015834A (en) * 2022-12-21 2023-04-25 中盈优创资讯科技有限公司 API asset management method and device based on business system
CN116248550A (en) * 2022-12-29 2023-06-09 中国联合网络通信集团有限公司 Interface performance determining method, device and storage medium
CN116208591A (en) * 2023-02-27 2023-06-02 深圳市安络科技有限公司 API interface checking method, device and equipment
CN117150493A (en) * 2023-09-26 2023-12-01 中电云计算技术有限公司 Method and device for identifying API (application program interface) parameter value increment type traversal
CN117978471A (en) * 2024-01-18 2024-05-03 南方电网数字电网集团信息通信科技有限公司 Unauthorized access detection method, device, equipment and storage medium for access request
CN117978471B (en) * 2024-01-18 2024-11-26 南方电网数字电网集团信息通信科技有限公司 Method, device, equipment and storage medium for detecting unauthorized access requests

Similar Documents

Publication Publication Date Title
CN115314483A (en) API asset determining method and abnormal calling early warning method
CN111949803B (en) A method, device and equipment for detecting abnormal network users based on knowledge graph
US9146787B2 (en) Analytics for application programming interfaces
US10044737B2 (en) Detection of beaconing behavior in network traffic
CN108228875B (en) Log parsing method and device based on perfect hash
CN113496032A (en) Big data operation abnormity monitoring system based on distributed computation and rule engine
CN109698814B (en) Botnet discovery method and botnet discovery device
CN110519263B (en) Anti-brush amount method, apparatus, device and computer readable storage medium
CN102870118A (en) Access method, device and system to user behavior
Liu et al. Fingerprinting web browser for tracing anonymous web attackers
CN115333966A (en) Nginx log analysis method, system and equipment based on topology
CN115811468A (en) Distribution method, device, electronic equipment and storage medium of flow collection strategy
CN113742207A (en) Interface testing method, device, equipment and computer readable storage medium
CN116389099A (en) Threat detection method, threat detection device, electronic equipment and storage medium
CN116881926A (en) A risk scanning method, system and computing device based on device code
CN115442109B (en) Method, device, equipment and storage medium for determining network attack results
CN115048533A (en) Knowledge graph construction method and device, electronic equipment and readable storage medium
Zhou et al. Characterizing Network Anomaly Traffic with Euclidean Distance‐Based Multiscale Fuzzy Entropy
Noskov Smart city webgis applications: proof of work concept for high-level quality-of-service assurance
CN112685255A (en) Interface monitoring method and device, electronic equipment and storage medium
CN115834183A (en) Flow detection method and device, electronic equipment and storage medium
EP3924827A1 (en) Activity detection in web applications
CN118349866B (en) A large-scale fine-grained classification algorithm for SNI information of mobile applications
CN111191234A (en) Method and device for detecting virus information
JP7544670B2 (en) Signature management device and signature management method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination