Nothing Special   »   [go: up one dir, main page]

CN118567699B - Component version upgrading method, device, equipment and medium - Google Patents

Component version upgrading method, device, equipment and medium Download PDF

Info

Publication number
CN118567699B
CN118567699B CN202411046666.0A CN202411046666A CN118567699B CN 118567699 B CN118567699 B CN 118567699B CN 202411046666 A CN202411046666 A CN 202411046666A CN 118567699 B CN118567699 B CN 118567699B
Authority
CN
China
Prior art keywords
update
class
target
target component
code
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.)
Active
Application number
CN202411046666.0A
Other languages
Chinese (zh)
Other versions
CN118567699A (en
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.)
Hangzhou New China And Big Polytron Technologies Inc
Original Assignee
Hangzhou New China And Big Polytron Technologies 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 Hangzhou New China And Big Polytron Technologies Inc filed Critical Hangzhou New China And Big Polytron Technologies Inc
Priority to CN202411046666.0A priority Critical patent/CN118567699B/en
Publication of CN118567699A publication Critical patent/CN118567699A/en
Application granted granted Critical
Publication of CN118567699B publication Critical patent/CN118567699B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/658Incremental updates; Differential updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/57Certifying or maintaining trusted computer platforms, e.g. secure boots or power-downs, version controls, system software checks, secure updates or assessing vulnerabilities
    • G06F21/577Assessing vulnerabilities and evaluating computer system security
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Stored Programmes (AREA)

Abstract

本发明公开了一种组件版本升级方法、装置、设备及介质。该方法包括:获取目标应用的待升级的目标组件及目标组件的目标版本号,生成目标组件的更新依赖配置,并更新目标组件对应的节点;根据目标组件以及目标版本号生成目标组件的更新调用代码;根据目标组件的更新调用代码,获取至少一个更新依赖类的更新信息;将各更新依赖类的更新信息与目标组件的相应适配器类进行比较,得到各更新依赖类的类比较结果,检测是否对目标组件的相应适配器类进行更新;检测更新调用代码与目标组件的目标调用代码的差异,并确定差异类型,检测是否对目标组件的目标调用代码进行更新。本发明实施例的技术方案提升了组件版本升级的准确率。

The present invention discloses a component version upgrade method, device, equipment and medium. The method comprises: obtaining a target component to be upgraded and a target version number of the target component of a target application, generating an update dependency configuration of the target component, and updating a node corresponding to the target component; generating an update call code of the target component according to the target component and the target version number; obtaining update information of at least one update dependency class according to the update call code of the target component; comparing the update information of each update dependency class with the corresponding adapter class of the target component, obtaining a class comparison result of each update dependency class, and detecting whether to update the corresponding adapter class of the target component; detecting the difference between the update call code and the target call code of the target component, and determining the difference type, and detecting whether to update the target call code of the target component. The technical solution of the embodiment of the present invention improves the accuracy of component version upgrade.

Description

一种组件版本升级方法、装置、设备及介质A component version upgrade method, device, equipment and medium

技术领域Technical Field

本发明涉及数据处理技术领域,尤其涉及一种组件版本升级方法、装置、设备及介质。The present invention relates to the field of data processing technology, and in particular to a component version upgrade method, device, equipment and medium.

背景技术Background Art

Java作为最流行的应用开发语言,相关开源业务组件层出不穷,所有Java类开源业务组件都会通过项目管理工具软件进行管理。在开源框架组件应用过程中,会暴露框架漏洞,若被黑客利用,会导致数据泄露等重大事故的发生。因此,需对应用系统进行漏洞监测,对有漏洞的应用系统的组件进行升级。Java is the most popular application development language, and related open source business components are emerging in an endless stream. All Java-based open source business components are managed through project management tool software. In the process of applying open source framework components, framework vulnerabilities will be exposed. If they are exploited by hackers, major accidents such as data leakage will occur. Therefore, it is necessary to monitor the vulnerabilities of the application system and upgrade the components of the application system with vulnerabilities.

目前,在应用系统的组件升级为最新版本组件时,通过人为操作对应用系统的组件进行升级。Currently, when components of an application system are upgraded to the latest version of the components, the components of the application system are upgraded through manual operations.

但是,由于各组件的应用程序编程接口发生变化,需要对大量组件进行修改和测试,人为操作准确率和效率较低。However, due to changes in the application programming interfaces of various components, a large number of components need to be modified and tested, and the accuracy and efficiency of manual operations are low.

发明内容Summary of the invention

本发明提供了一种组件版本升级方法、装置、设备及介质,在兼顾了硬件需求的同时,提高了组件版本升级的准确率,保证了组件版本升级的性能。The present invention provides a component version upgrade method, device, equipment and medium, which improve the accuracy of component version upgrade while taking into account hardware requirements and ensure the performance of component version upgrade.

根据本发明的一方面,提供了一种组件版本升级方法,方法包括:According to one aspect of the present invention, a component version upgrade method is provided, the method comprising:

获取目标应用的待升级的目标组件,以及目标组件的目标版本号;Obtain the target component to be upgraded of the target application and the target version number of the target component;

根据目标组件以及目标版本号生成目标组件的更新依赖配置,并在目标应用的项目文件中更新目标组件对应的节点;Generate the update dependency configuration of the target component according to the target component and the target version number, and update the node corresponding to the target component in the project file of the target application;

根据目标组件以及目标版本号生成目标组件的更新调用代码;Generate the update calling code of the target component according to the target component and the target version number;

根据目标组件的更新调用代码,获取至少一个更新依赖类的更新信息;According to the update calling code of the target component, obtaining update information of at least one update dependent class;

将各更新依赖类的更新信息与目标组件的相应适配器类进行比较,得到各更新依赖类的类比较结果;Compare the update information of each update dependency class with the corresponding adapter class of the target component to obtain a class comparison result of each update dependency class;

根据各更新依赖类的类比较结果,检测是否对目标组件的相应适配器类进行更新;According to the class comparison results of each update dependent class, detect whether to update the corresponding adapter class of the target component;

检测更新调用代码与目标组件的目标调用代码的差异,并确定差异类型;Detecting differences between the update call code and the target call code of the target component, and determining the type of the difference;

根据差异和差异类型,检测是否对目标组件的目标调用代码进行更新。Based on the difference and the difference type, detect whether to update the target calling code of the target component.

根据本发明的另一方面,提供了一种组件版本升级装置,装置包括:According to another aspect of the present invention, a component version upgrade device is provided, the device comprising:

组件信息获取模块,用于获取目标应用的待升级的目标组件,以及目标组件的目标版本号;A component information acquisition module is used to acquire the target component to be upgraded of the target application and the target version number of the target component;

节点更新模块,用于根据目标组件以及目标版本号生成目标组件的更新依赖配置,并在目标应用的项目文件中更新目标组件对应的节点;A node update module is used to generate an update dependency configuration of a target component according to the target component and the target version number, and to update the node corresponding to the target component in the project file of the target application;

代码生成模块,用于根据目标组件以及目标版本号生成目标组件的更新调用代码;A code generation module, used to generate an update calling code of a target component according to a target component and a target version number;

更新信息获取模块,用于根据目标组件的更新调用代码,获取至少一个更新依赖类的更新信息;An update information acquisition module, used to acquire update information of at least one update dependency class according to an update calling code of a target component;

比较结果获取模块,用于将各更新依赖类的更新信息与目标组件的相应适配器类进行比较,得到各更新依赖类的类比较结果;A comparison result acquisition module, used to compare the update information of each update dependency class with the corresponding adapter class of the target component to obtain a class comparison result of each update dependency class;

更新检测模块,用于根据各更新依赖类的类比较结果,检测是否对目标组件的相应适配器类进行更新;An update detection module, used to detect whether to update the corresponding adapter class of the target component according to the class comparison result of each update dependency class;

类型确定模块,用于检测更新调用代码与目标组件的目标调用代码的差异,并确定差异类型;A type determination module, used to detect the difference between the update call code and the target call code of the target component, and determine the type of the difference;

更新检测模块,用于根据差异和差异类型,检测是否对目标组件的目标调用代码进行更新。The update detection module is used to detect whether to update the target calling code of the target component according to the difference and the difference type.

根据本发明的另一方面,提供了一种组件版本升级设备,组件版本升级设备包括:According to another aspect of the present invention, a component version upgrade device is provided, the component version upgrade device comprising:

至少一个处理器;以及at least one processor; and

与至少一个处理器通信连接的存储器;其中,a memory communicatively connected to at least one processor; wherein,

存储器存储有可被至少一个处理器执行的计算机程序,计算机程序被至少一个处理器执行,以使至少一个处理器能够执行本发明任一实施例的组件版本升级方法。The memory stores a computer program that can be executed by at least one processor. The computer program is executed by at least one processor so that the at least one processor can execute the component version upgrade method of any embodiment of the present invention.

根据本发明的另一方面,提供了一种计算机可读存储介质,计算机可读存储介质存储有计算机指令,计算机指令用于使处理器执行时实现本发明任一实施例的组件版本升级方法。According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the component version upgrade method of any embodiment of the present invention when executed.

本发明实施例的技术方案,通过获取目标应用的待升级的目标组件,以及目标组件的目标版本号,生成目标组件的更新依赖配置,根据目标组件以及目标版本号生成目标组件的更新调用代码,获取至少一个更新依赖类的更新信息,将各更新依赖类的更新信息与目标组件的相应适配器类进行比较,得到各更新依赖类的类比较结果,检测是否对目标组件的相应适配器类进行更新,实现细粒度的类更新,细化了组件版本升级的操作,提升了组件版本升级的准确性,通过多维数据检测更新调用代码与目标组件的目标调用代码的差异,并确定差异类型,检测是否对目标组件的目标调用代码进行更新,可以针对不同的差异类型,判断是否进行更新,以及实现相应的更新操作,可以实现差异化更新,并且更新减少人为操作,降低更新的人工成本,提高了组件版本升级的效率。The technical solution of the embodiment of the present invention obtains the target component to be upgraded of the target application and the target version number of the target component, generates the update dependency configuration of the target component, generates the update calling code of the target component according to the target component and the target version number, obtains the update information of at least one update dependency class, compares the update information of each update dependency class with the corresponding adapter class of the target component, obtains the class comparison result of each update dependency class, detects whether to update the corresponding adapter class of the target component, implements fine-grained class update, refines the operation of component version upgrade, improves the accuracy of component version upgrade, detects the difference between the update calling code and the target calling code of the target component through multi-dimensional data, determines the difference type, detects whether to update the target calling code of the target component, can judge whether to update according to different difference types, and implements the corresponding update operation, can implement differentiated update, and reduces manual operation in the update, reduces the labor cost of the update, and improves the efficiency of the component version upgrade.

应当理解,本部分所描述的内容并非旨在标识本发明的实施例的关键或重要特征,也不用于限制本发明的范围。本发明的其它特征将通过以下的说明书而变得容易理解。It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

图1是根据本发明实施例一提供的一种组件版本升级方法的流程图;FIG1 is a flow chart of a component version upgrade method provided according to an embodiment of the present invention;

图2是根据本发明实施例二提供的一种组件版本升级方法的流程图;FIG2 is a flow chart of a component version upgrade method provided according to a second embodiment of the present invention;

图3是根据本发明实施例二提供的一种组件版本升级方法的流程图;FIG3 is a flow chart of a component version upgrade method provided according to Embodiment 2 of the present invention;

图4是根据本发明实施例提供的一种组件版本升级装置的结构示意图;FIG4 is a schematic diagram of the structure of a component version upgrade device provided according to an embodiment of the present invention;

图5是实现本发明实施例提供的一种组件版本升级设备的结构示意图。FIG. 5 is a schematic diagram of the structure of a component version upgrade device provided by an embodiment of the present invention.

具体实施方式DETAILED DESCRIPTION

为了使本技术领域的人员更好地理解本发明方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明保护的范围。In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

需要说明的是,本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本发明的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

实施例一Embodiment 1

图1为本发明实施例一提供的一种组件版本升级方法的流程图。本发明实施例可适用于组件版本升级的情况,该方法可以由组件版本升级装置来执行,该组件版本升级装置可以采用硬件和/或软件的形式实现,该组件版本升级装置可配置于组件版本升级设备中。Figure 1 is a flow chart of a component version upgrade method provided by Embodiment 1 of the present invention. The embodiment of the present invention is applicable to the case of component version upgrade, and the method can be executed by a component version upgrade device, which can be implemented in the form of hardware and/or software, and can be configured in a component version upgrade device.

参见图1所示的组件版本升级方法,包括:Referring to FIG. 1 , the component version upgrade method includes:

S101、获取目标应用的待升级的目标组件,以及目标组件的目标版本号。S101. Obtain a target component to be upgraded of a target application and a target version number of the target component.

其中,组件用于实现特定功能,可以集成在目标应用中。目标组件通常是由第三方提供功能的组件。示例性的,目标应用为文档编辑应用,目标组件可以是公式编辑组件。目标版本号可以是目标组件对应的待升级版本的标识。The component is used to implement a specific function and can be integrated into the target application. The target component is usually a component whose functions are provided by a third party. For example, the target application is a document editing application, and the target component can be a formula editing component. The target version number can be an identifier of the version to be upgraded corresponding to the target component.

具体的,可通过集成开发环境(IntelliJ IDEA,IDEA)构建自动化脚本,通过自动化脚本对项目管理工具软件(maven)的组件增加和升级进行管理,实现在项目管理工具软件中maven组件的升级。目标应用包括至少一个组件。可对至少一个组件进行升级,因此,目标应用对应至少一个目标组件,一个目标组件对应一个目标版本号。获取目标应用的待升级的目标组件,以及目标组件的目标版本号。目标组件和目标版本号可以是用户指定,也可以是在升级的组件库中自动识别。Specifically, an automated script can be built through an integrated development environment (IntelliJ IDEA, IDEA), and the addition and upgrade of components of the project management tool software (maven) can be managed through the automated script to achieve the upgrade of the maven components in the project management tool software. The target application includes at least one component. At least one component can be upgraded, so the target application corresponds to at least one target component, and one target component corresponds to a target version number. Obtain the target component to be upgraded of the target application and the target version number of the target component. The target component and the target version number can be specified by the user or automatically identified in the upgraded component library.

在一个例子中,获取目标应用的待升级的目标组件为log4j,获得目标组件的目标版本号为2.18.1。In one example, the target component to be upgraded of the target application is log4j, and the target version number of the target component is 2.18.1.

可以预设各组件的升级机制,在检测到某个目标组件的更新数据较多,表明该组件漏洞比较多,可自动监听该组件,并在自动检测到目标组件需要升级时,预警开发人员,由开发人员判断是否对目标组件进行更新。获取目标组件的上一次升级时间,若组件每次升级之间的时间间隔较长,表明组件升级有可能出现重大更新,可以判断上一次升级时间和当前时间之间的时长,在该时长大于预设时长阈值时,预警开发人员谨慎升级。The upgrade mechanism of each component can be preset. When a target component is detected to have a lot of update data, it indicates that the component has many vulnerabilities. The component can be automatically monitored and the developer can be warned when the target component needs to be upgraded. The developer can then decide whether to update the target component. The last upgrade time of the target component can be obtained. If the time interval between each component upgrade is long, it indicates that there may be a major update in the component upgrade. The time between the last upgrade time and the current time can be determined. When the time is longer than the preset time threshold, the developer is warned to upgrade with caution.

可建立升级过程版本库,通过组件升级的频率和组件的升级版本之间的跨度,建立版本升级模型,如果升级组件频率比较高,自动把该组件作为监听,说明该组件漏洞比较多,自动预警开发人员进行替换。An upgrade process version library can be established, and a version upgrade model can be established based on the frequency of component upgrades and the span between component upgrade versions. If the frequency of component upgrades is relatively high, the component will be automatically used as a monitor, indicating that the component has many vulnerabilities, and the developer will be automatically warned to replace it.

S102、根据目标组件以及目标版本号生成目标组件的更新依赖配置,并在目标应用的项目文件中更新目标组件对应的节点。S102: Generate an update dependency configuration of the target component according to the target component and the target version number, and update a node corresponding to the target component in a project file of the target application.

其中,更新依赖配置可以用于描述目标组件和目标版本号对应的配置数据。项目文件可以是项目管理工具maven对应的项目对象模型文件。在项目文件中设置有节点,一个组件对应一个节点。不同节点存储不同组件的配置数据,一个节点还配置有该节点与其他节点之间的关系。Among them, updating dependency configuration can be used to describe the configuration data corresponding to the target component and the target version number. The project file can be a project object model file corresponding to the project management tool Maven. Nodes are set in the project file, and one component corresponds to one node. Different nodes store configuration data of different components, and a node is also configured with the relationship between the node and other nodes.

具体的,根据目标组件以及目标版本号生成目标组件的更新依赖配置,生成方法包括但不限于:大语言模型、反向传播神经网络、卷积神经网络、循环神经网络、生成对抗神经网络、图神经网络或长短时记忆网络等,本发明实施例对此不进行限制。在目标应用的项目文件中,查找是否含有更新依赖配置信息,若未包含,则自动在项目文件中添加一个目标组件对应的节点,相当于是在应用程序中集成了该组件的功能。从而,在目标组件需要升级,且目标应用的项目文件中存在该目标组件对应的节点时,需要修改该目标组件对应的节点;在目标组件需要升级,且目标应用的项目文件中不存在该目标组件对应的节点时,需要新建该目标组件对应的节点。其中,修改该目标组件对应的节点可以是删除已建立的节点,并新建更新依赖配置对应的节点。Specifically, the update dependency configuration of the target component is generated according to the target component and the target version number. The generation method includes but is not limited to: large language model, back propagation neural network, convolutional neural network, recurrent neural network, generative adversarial neural network, graph neural network or long short-term memory network, etc., and the embodiment of the present invention does not limit this. In the project file of the target application, find whether it contains update dependency configuration information. If not, a node corresponding to the target component is automatically added to the project file, which is equivalent to integrating the function of the component in the application. Therefore, when the target component needs to be upgraded and there is a node corresponding to the target component in the project file of the target application, it is necessary to modify the node corresponding to the target component; when the target component needs to be upgraded and there is no node corresponding to the target component in the project file of the target application, it is necessary to create a new node corresponding to the target component. Among them, modifying the node corresponding to the target component can be to delete the established node and create a new node corresponding to the update dependency configuration.

在一个例子中,目标组件为log4j,log4j的目标版本号为2.18.1。根据目标组件以及目标版本号,可作为大语言模型的输入数据,预设大语言模型的输入模版(prompt)为:“XX YY的maven依赖”,XX和YY位置处的数据可被替换,XX可被目标组件替换,YY可被目标版本号替换,示例的:大语言模型的输入数据可以是log4j 2.18.1的maven依赖,通过大语言模型生成目标组件log4j的更新依赖配置,更新依赖配置为<artifactId>log4j</artifactId><version>2.18.1</version>。查找可执行的项目文件,在项目文件内查找不含有maven的更新依赖配置信息,自动在dependencies节点中插入dependency从属节点,即在项目文件中插入待添加目标组件对应的节点,大语言模型返回dependency节点的信息,完成节点的更新。In one example, the target component is log4j, and the target version number of log4j is 2.18.1. According to the target component and the target version number, it can be used as the input data of the large language model. The preset input template (prompt) of the large language model is: "XX YY's Maven dependency", the data at the position of XX and YY can be replaced, XX can be replaced by the target component, and YY can be replaced by the target version number. For example: the input data of the large language model can be the Maven dependency of log4j 2.18.1, and the update dependency configuration of the target component log4j is generated by the large language model, and the update dependency configuration is <artifactId>log4j</artifactId><version>2.18.1</version>. Search for executable project files, search for update dependency configuration information that does not contain Maven in the project file, and automatically insert the dependency subordinate node in the dependencies node, that is, insert the node corresponding to the target component to be added in the project file. The large language model returns the information of the dependency node and completes the node update.

S103、根据目标组件以及目标版本号生成目标组件的更新调用代码。S103: Generate an update calling code for the target component according to the target component and the target version number.

其中,更新调用代码可以是调用目标版本号的目标组件的代码。The update calling code may be a code for calling a target component of a target version number.

可以将目标组件和目标版本号输入到大语音模型中,得到更新调用代码。具体的,预设大语言模型的prompt为:“组件为XX 版本号为YY的更新调用代码”,根据目标组件及目标版本号与大语言模型的prompt融合,通过将目标组件的标识替换为XX,将目标版本号替换为YY,可通过大语言模型生成目标组件对应的可执行文件中的代码进行调用的更新调用代码。The target component and the target version number can be input into the large speech model to obtain the update calling code. Specifically, the preset prompt of the large language model is: "Update calling code for component XX and version number YY". According to the fusion of the prompt of the target component and the target version number with the large language model, by replacing the identifier of the target component with XX and the target version number with YY, the update calling code for calling the code in the executable file corresponding to the target component can be generated by the large language model.

在一个例子中,目标组件为log4j,log4j的目标版本号为2.18.1,生成大语言模型的输入数据为:log4j 2.18.1的更新调用代码,通过大语言模型得到目标组件log4j的更新调用代码。In an example, the target component is log4j, the target version number of log4j is 2.18.1, and the input data for generating the large language model is: the update calling code of log4j 2.18.1. The update calling code of the target component log4j is obtained through the large language model.

S104、根据目标组件的更新调用代码,获取至少一个更新依赖类的更新信息。S104: Obtain update information of at least one update-dependent class according to the update calling code of the target component.

其中,更新依赖类可以是指目标组件中需要更新的依赖类。目标组件包括至少一个依赖类。更新信息可以是指更新依赖类相对于目标组件的当前的依赖类所更新的数据。The updated dependency class may refer to the dependency class that needs to be updated in the target component. The target component includes at least one dependency class. The update information may refer to the data updated by the updated dependency class relative to the current dependency class of the target component.

具体的,根据目标组件的更新调用代码,可获取更新调用代码中包括的更新依赖类的更新信息,可对目标组件的当前的依赖类的函数头和更新依赖类的函数头进行遍历,将目标组件的当前的依赖类的函数头和其相应的更新依赖类的函数头进行比较,得到目标组件的当前的依赖类的函数头和更新依赖类的函数头和的差异,确定更新依赖类的更新信息。遍历方式包括但不限于:深度优先遍历或广度优先遍历等,本发明实施例对此不进行限制。Specifically, according to the update calling code of the target component, the update information of the update dependency class included in the update calling code can be obtained, the function header of the current dependency class of the target component and the function header of the update dependency class can be traversed, and the function header of the current dependency class of the target component and the function header of the corresponding update dependency class can be compared to obtain the difference between the function header of the current dependency class of the target component and the function header of the update dependency class, and determine the update information of the update dependency class. The traversal method includes but is not limited to: depth-first traversal or breadth-first traversal, etc., and the embodiment of the present invention does not limit this.

在一个例子中,目标组件的更新调用代码为:In an example, the update call code of the target component is:

class t test0(a,b,c)class t test0(a,b,c)

class t test1(a,b,c)class t test1(a, b, c)

目标组件的当前的依赖类为class t test0(a,b,c),通过深度优先遍历目标组件的当前的依赖类的函数头和更新依赖类的函数头,将目标组件的当前的依赖类的函数头和其相应的更新依赖类的函数头进行比较,得到目标组件的当前的依赖类的函数头和更新依赖类的函数头之间的差异为class t test1(a,b,c),获取更新依赖类t的更新信息为classt test1(a,b,c)。The current dependency class of the target component is class t test0 (a, b, c). By depth-first traversing the function header of the current dependency class of the target component and the function header of the updated dependency class, the function header of the current dependency class of the target component is compared with the function header of its corresponding updated dependency class, and the difference between the function header of the current dependency class of the target component and the function header of the updated dependency class is class t test1 (a, b, c). The update information of the updated dependency class t is obtained as classt test1 (a, b, c).

S105、将各更新依赖类的更新信息与目标组件的相应适配器类进行比较,得到各更新依赖类的类比较结果。S105 . Compare the update information of each update-dependent class with the corresponding adapter class of the target component to obtain a class comparison result of each update-dependent class.

其中,适配器类与目标组件包括的依赖类一一对应。适配器类可以是指对目标组件包括的依赖类进行继承,适配器类实现了对应的依赖类对应的功能。类比较结果可以是更新依赖类的更新信息与目标组件的相应适配器类中包含的数据的比较结果。The adapter class corresponds to the dependency class included in the target component one by one. The adapter class may refer to the inheritance of the dependency class included in the target component, and the adapter class implements the corresponding function of the corresponding dependency class. The class comparison result may be the comparison result of the update information of the updated dependency class and the data contained in the corresponding adapter class of the target component.

更新信息包括下述至少一项:类名、方法名和参数名。具体的,更新信息包括:类名、方法名和参数名,将各更新依赖类的更新信息与目标组件的相应适配器类进行比较,相当于将更新依赖类的更新信息中的类名、方法名和参数名分别与其对应的目标组件的相应适配器类中的类名、方法名和参数名比较。获取各更新依赖类的更新信息与目标组件的相应适配器类不一致的数据。获取方式包括但不限于:暴力匹配算法、优化的字符串匹配算法或多模式匹配算法等,本发明实施例对此不进行限制,得到各更新依赖类的类比较结果。The update information includes at least one of the following: class name, method name and parameter name. Specifically, the update information includes: class name, method name and parameter name. Comparing the update information of each update-dependent class with the corresponding adapter class of the target component is equivalent to comparing the class name, method name and parameter name in the update information of the update-dependent class with the class name, method name and parameter name in the corresponding adapter class of the corresponding target component. Obtain data that is inconsistent with the update information of each update-dependent class and the corresponding adapter class of the target component. The acquisition method includes but is not limited to: brute force matching algorithm, optimized string matching algorithm or multi-pattern matching algorithm, etc., and the embodiment of the present invention does not limit this, and obtains the class comparison result of each update-dependent class.

在一个例子中,更新依赖类的更新信息为class t test(a,b,c)。将更新依赖类的更新信息为与目标组件的相应适配器类class t test(a,b)进行比较,得到更新依赖类的类比较结果为类标识相同、方法标识相同以及参数标识不同。In one example, the update information of the update dependency class is class t test (a, b, c). The update information of the update dependency class is compared with the corresponding adapter class class t test (a, b) of the target component, and the class comparison result of the update dependency class is that the class identifier is the same, the method identifier is the same, and the parameter identifier is different.

S106、根据各更新依赖类的类比较结果,检测是否对目标组件的相应适配器类进行更新。S106. According to the class comparison result of each update dependent class, detect whether to update the corresponding adapter class of the target component.

具体的,根据各更新依赖类的类比较结果,获得类标识的比较结果、方法标识的比较结果及参数标识的比较结果,可以根据各标识的比较结果检测是否对目标组件的相应适配器类进行更新。例如,可以根据不同的标识的类型,以及不同的标识的数量,检测是否对目标组件的相应适配器类进行更新。示例性的,可以通过大语言模型对输入的类比较结果进行识别,得到是否更新的判断结果。Specifically, based on the class comparison results of each update dependent class, the comparison results of the class identifier, the comparison results of the method identifier and the comparison results of the parameter identifier are obtained, and it can be detected whether to update the corresponding adapter class of the target component based on the comparison results of each identifier. For example, it is possible to detect whether to update the corresponding adapter class of the target component based on different types of identifiers and different numbers of identifiers. Exemplarily, the input class comparison results can be identified through a large language model to obtain a judgment result on whether to update.

在一个例子中,更新依赖类的类比较结果为类标识相同、方法标识相同以及参数标识不同。通过大语言模型检测,检测结果为需对目标组件的适配器类class t test(a,b)进行更新。In one example, the class comparison result of updating the dependent class is that the class identifiers are the same, the method identifiers are the same, and the parameter identifiers are different. Through the large language model detection, the detection result is that the adapter class class t test (a, b) of the target component needs to be updated.

S107、检测更新调用代码与目标组件的目标调用代码的差异,并确定差异类型。S107: Detect the difference between the update calling code and the target calling code of the target component, and determine the difference type.

其中,目标调用代码可以是调用当前版本号(未更新的版本号)的目标组件的代码。差异可以是更新调用代码与目标组件的目标调用代码之间的不同的数据。差异类型可以是更新调用代码与目标组件的目标调用代码之间的差异的数据类型。The target calling code may be a code for calling a target component of a current version number (a version number that has not been updated). The difference may be different data between the update calling code and the target calling code of the target component. The difference type may be a data type of the difference between the update calling code and the target calling code of the target component.

具体的,差异类型可以包括方法增加或方法删除。获取目标组件的目标调用代码,通过字符串匹配算法将更新调用代码与目标调用代码进行比较,得到更新调用代码与目标调用代码的不一致的数据,得到更新调用代码与目标调用代码的差异,对更新调用代码与目标组件的目标调用代码的差异进行识别,确定差异类型。Specifically, the difference type may include method addition or method deletion. Obtain the target calling code of the target component, compare the update calling code with the target calling code through a string matching algorithm, obtain inconsistent data between the update calling code and the target calling code, obtain the difference between the update calling code and the target calling code, identify the difference between the update calling code and the target calling code of the target component, and determine the difference type.

在一个例子中,更新调用代码为test1(a,b,c)和test2(a,b),目标组件的目标调用代码为test1(a,b,c)。通过神经网络检测更新调用代码与目标组件的目标调用代码的差异为test2(a,b),并确定差异类型为方法增加。In one example, the update call codes are test1(a, b, c) and test2(a, b), and the target call code of the target component is test1(a, b, c). The difference between the update call code and the target call code of the target component is detected by the neural network as test2(a, b), and the difference type is determined to be method addition.

S108、根据差异和差异类型,检测是否对目标组件的目标调用代码进行更新。S108. Detect whether to update the target calling code of the target component according to the difference and the difference type.

具体的,根据差异和差异类型,检测是否对目标组件的目标调用代码进行更新,可以根据差异类型以及差异的数据的数量,检测是否对目标组件的目标调用代码进行更新。可预设更新条件,若对差异和差异类型进行分析,得到的更新数据结果满足更新条件,则表明需要对目标组件的目标调用代码进行更新,若对差异和差异类型进行分析,得到的更新数据结果不满足更新条件,则表明不需要对目标组件的目标调用代码进行更新。更新条件可以是大于更新调用代码与目标组件的目标调用代码的差异的数据的数量阈值。Specifically, whether to update the target calling code of the target component can be detected based on the difference and the difference type, and whether to update the target calling code of the target component can be detected based on the difference type and the amount of difference data. An update condition can be preset. If the update data result obtained by analyzing the difference and the difference type meets the update condition, it indicates that the target calling code of the target component needs to be updated. If the update data result obtained by analyzing the difference and the difference type does not meet the update condition, it indicates that the target calling code of the target component does not need to be updated. The update condition can be a threshold value of the amount of data that is greater than the difference between the update calling code and the target calling code of the target component.

在一个例子中,预设更新条件为差异参数大于2个,差异类型为方法增加。更新调用代码为test1(a,b,c)和test2(a,b),目标组件的目标调用代码为test1(a,b,c)。更新调用代码与目标组件的目标调用代码的差异为test2(a,b),差异类型为方法增加。根据差异和差异类型,检测得到差异参数大于2个,差异类型为方法增加,对目标组件的目标调用代码进行更新。In one example, the preset update condition is that the difference parameters are greater than 2, and the difference type is method addition. The update call codes are test1 (a, b, c) and test2 (a, b), and the target call code of the target component is test1 (a, b, c). The difference between the update call code and the target call code of the target component is test2 (a, b), and the difference type is method addition. According to the difference and difference type, it is detected that the difference parameters are greater than 2, and the difference type is method addition, and the target call code of the target component is updated.

在确定更新时,根据差异和差异类型,确定相应的更新方式,采用相应的更新方式对目标调用代码进行更新。示例性的,采用更新调用代码替换目标调用代码。When determining the update, a corresponding update method is determined according to the difference and the difference type, and the target calling code is updated using the corresponding update method. Exemplarily, the target calling code is replaced with the updated calling code.

本发明实施例的技术方案,通过获取目标应用的待升级的目标组件,以及目标组件的目标版本号,生成目标组件的更新依赖配置,根据目标组件以及目标版本号生成目标组件的更新调用代码,获取至少一个更新依赖类的更新信息,将各更新依赖类的更新信息与目标组件的相应适配器类进行比较,得到各更新依赖类的类比较结果,检测是否对目标组件的相应适配器类进行更新,实现细粒度的类更新,细化了组件版本升级的操作,提升了组件版本升级的准确性,通过多维数据检测更新调用代码与目标组件的目标调用代码的差异,并确定差异类型,检测是否对目标组件的目标调用代码进行更新,可以针对不同的差异类型,判断是否进行更新,以及实现相应的更新操作,可以实现差异化更新,并且更新减少人为操作,降低更新的人工成本,提高了组件版本升级的效率。The technical solution of the embodiment of the present invention obtains the target component to be upgraded of the target application and the target version number of the target component, generates the update dependency configuration of the target component, generates the update calling code of the target component according to the target component and the target version number, obtains the update information of at least one update dependency class, compares the update information of each update dependency class with the corresponding adapter class of the target component, obtains the class comparison result of each update dependency class, detects whether to update the corresponding adapter class of the target component, implements fine-grained class update, refines the operation of component version upgrade, improves the accuracy of component version upgrade, detects the difference between the update calling code and the target calling code of the target component through multi-dimensional data, determines the difference type, detects whether to update the target calling code of the target component, can judge whether to update according to different difference types, and implements the corresponding update operation, can implement differentiated update, and reduces manual operation in the update, reduces the labor cost of the update, and improves the efficiency of the component version upgrade.

可选的,更新信息包括:类名、方法名和参数名;类比较结果包括类标识比较结果、方法标识比较结果和参数标识比较结果;根据各更新依赖类的类比较结果,检测是否对目标组件的相应适配器类进行更新,包括:根据各更新依赖类的类比较结果,检测各更新依赖类的标识变化数量;根据各更新依赖类的标识变化数量,确定各更新依赖类的变化类型;针对各更新依赖类,在更新依赖类的变化类型为微小变化时,根据更新依赖类的更新调用代码,调整更新依赖类对应的适配器类中的参数;针对各更新依赖类,在更新依赖类的变化类型为中等变化时,根据更新依赖类的更新调用代码,生成新的适配器类,并替换更新依赖类对应的适配器类;针对各更新依赖类,在更新依赖类的变化类型为重大变化时,生成目标组件的反编译代码,并根据更新依赖类的当前版本漏洞对编译代码进行修复。Optionally, the update information includes: class name, method name and parameter name; the class comparison results include class identification comparison results, method identification comparison results and parameter identification comparison results; based on the class comparison results of each update dependency class, detect whether to update the corresponding adapter class of the target component, including: based on the class comparison results of each update dependency class, detect the number of identification changes of each update dependency class; based on the number of identification changes of each update dependency class, determine the change type of each update dependency class; for each update dependency class, when the change type of the update dependency class is a minor change, according to the update calling code of the update dependency class, adjust the parameters in the adapter class corresponding to the update dependency class; for each update dependency class, when the change type of the update dependency class is a medium change, according to the update calling code of the update dependency class, generate a new adapter class and replace the adapter class corresponding to the update dependency class; for each update dependency class, when the change type of the update dependency class is a major change, generate the decompiled code of the target component, and repair the compiled code according to the current version vulnerability of the update dependency class.

其中,类名可以是具有共享数据和数据处理方法的对象集合的标识。方法名可以是数据处理方法的函数的标识。参数名可以是数据处理方法的函数头包含的参数的参数标识。类标识比较结果可以是更新依赖类的标识与目标组件的相应适配器类的标识比较的结果。方法标识比较结果可以是更新依赖类的函数与目标组件的相应适配器类的函数的标识比较的结果。参数标识比较结果可以是更新依赖类的函数头包含的参数与目标组件的相应适配器类的类名的比较结果。标识变化数量可以是更新依赖类与目标组件的相应适配器类的类名、方法名和参数名比较,发生变化的标识的数量。变化类型可以是标识变化的数量的类型。反编译代码可以是对更新依赖类进行反编译处理生成的代码。Among them, the class name can be the identifier of the object set with shared data and data processing methods. The method name can be the identifier of the function of the data processing method. The parameter name can be the parameter identifier of the parameter contained in the function header of the data processing method. The class identifier comparison result can be the result of comparing the identifier of the update dependency class with the identifier of the corresponding adapter class of the target component. The method identifier comparison result can be the result of comparing the identifier of the function of the update dependency class with the identifier of the function of the corresponding adapter class of the target component. The parameter identifier comparison result can be the result of comparing the parameter contained in the function header of the update dependency class with the class name of the corresponding adapter class of the target component. The number of identifier changes can be the number of identifiers that have changed by comparing the class name, method name and parameter name of the update dependency class with the class name, method name and parameter name of the corresponding adapter class of the target component. The change type can be the type of the number of identifier changes. The decompiled code can be the code generated by decompiling the update dependency class.

具体的,更新信息包括:类名、方法名和参数名;类比较结果包括类标识比较结果、方法标识比较结果和参数标识比较结果。通常标识比较结果可以包括不变、删除、修改和新增。根据类标识比较结果确定变化的类的标识以及变化的类的数量;根据方法标识比较结果,确定变化的函数的标识以及变化的函数的数量;根据参数标识比较结果,确定变化的参数的标识以及变化的参数的数量。可以为每个变化类型配置相应的检测条件,一个检测条件配置有变化的标识类型范围以及变化的数量阈值,检测一个更新依赖类对应的变化的标识以及变化的数量,并采用各变化类型的检测条件进行检测,确定该更新依赖类的变化类型。Specifically, the update information includes: class name, method name and parameter name; the class comparison result includes class identification comparison result, method identification comparison result and parameter identification comparison result. Usually the identification comparison result may include unchanged, deleted, modified and added. According to the class identification comparison result, the identification of the changed class and the number of changed classes are determined; according to the method identification comparison result, the identification of the changed function and the number of changed functions are determined; according to the parameter identification comparison result, the identification of the changed parameter and the number of changed parameters are determined. Corresponding detection conditions can be configured for each change type. A detection condition is configured with a change identification type range and a change quantity threshold. The change identification and the change quantity corresponding to an update-dependent class are detected, and the detection conditions of each change type are used for detection to determine the change type of the update-dependent class.

针对各更新依赖类,在更新依赖类的变化类型为微小变化时,表明标识变化数量较少,可通过匹配算法比对更新依赖类的更新信息与目标调用代码之间的差异,根据更新依赖类的更新调用代码,调整更新依赖类对应的适配器类中的参数。针对各更新依赖类,在更新依赖类的变化类型为中等变化时,表明标识变化数量处于预设的中等标识变化数量,可通过匹配算法比对更新依赖类的更新信息与目标调用代码之间的差异,根据更新依赖类的更新调用代码,生成新的适配器类,并替换更新依赖类对应的适配器类,可通过创建代码替换函数进行代码替换。针对各更新依赖类,在更新依赖类的变化类型为重大变化时,生成目标组件的反编译代码,并根据更新依赖类的当前版本漏洞对编译代码进行修复,可通过大语言模型查询修复方式。示例性的,微小变化的变化类型的检测条件可以是,变化的标识为参数标识,变化的数量小于预设第一数量阈值;中等标识变化的变化类型的检测条件可以是,变化的标识包括:参数标识、类标识和方法标识等至少一项,变化的数量小于预设第二数量阈值,或存在方法标识删除;重大变化的变化类型的检测条件可以是,变化的标识包括参数标识、类标识和方法标识等至少一项,变化的类标识数量大于第三阈值,或存在严重漏洞等。此外,还有其他情况,对此并未穷举,可以根据需要进行设定。For each update dependency class, when the change type of the update dependency class is a minor change, it indicates that the number of identification changes is small. The difference between the update information of the update dependency class and the target call code can be compared through a matching algorithm. According to the update call code of the update dependency class, the parameters in the adapter class corresponding to the update dependency class are adjusted. For each update dependency class, when the change type of the update dependency class is a medium change, it indicates that the number of identification changes is within the preset medium identification change number. The difference between the update information of the update dependency class and the target call code can be compared through a matching algorithm. According to the update call code of the update dependency class, a new adapter class is generated and the adapter class corresponding to the update dependency class is replaced. Code replacement can be performed by creating a code replacement function. For each update dependency class, when the change type of the update dependency class is a major change, the decompiled code of the target component is generated, and the compiled code is repaired according to the current version vulnerability of the update dependency class. The repair method can be queried through a large language model. Exemplarily, the detection condition of the change type of a minor change may be that the changed identifier is a parameter identifier, and the number of changes is less than a preset first quantity threshold; the detection condition of the change type of a medium identifier change may be that the changed identifier includes at least one of a parameter identifier, a class identifier, and a method identifier, the number of changes is less than a preset second quantity threshold, or there is a method identifier deletion; the detection condition of the change type of a major change may be that the changed identifier includes at least one of a parameter identifier, a class identifier, and a method identifier, the number of changed class identifiers is greater than a third threshold, or there is a serious vulnerability, etc. In addition, there are other situations, which are not exhaustive and can be set as needed.

在一个例子中,目标组件的相应适配器类为class t test(a,b)。更新依赖类的更新信息为class t test(a,b,c)。更新依赖类的类比较结果为类标识相同、方法标识相同以及参数标识不同。根据各更新依赖类的类比较结果,检测各更新依赖类的标识变化数量为1。预设标识变化数量的数据范围为[0,3],[4,10]。[0,3]对应的变化类型为微小变化,[4,10] 对应的变化类型为中等变化,更新依赖类的标识变化数量为1,根据更新依赖类的标识变化数量,确定更新依赖类的变化类型为微小变化。通过匹配算法比对更新依赖类的更新信息与目标调用代码,得到二者之间的差异,根据更新依赖类的更新调用代码,调整更新依赖类对应的适配器类中的参数。In one example, the corresponding adapter class of the target component is class t test (a, b). The update information of the update dependency class is class t test (a, b, c). The class comparison result of the update dependency class is that the class identifier is the same, the method identifier is the same, and the parameter identifier is different. According to the class comparison result of each update dependency class, the number of changes in the identifier of each update dependency class is detected to be 1. The data range of the preset identifier change number is [0,3], [4,10]. The change type corresponding to [0,3] is a minor change, and the change type corresponding to [4,10] is a medium change. The number of changes in the identifier of the update dependency class is 1. According to the number of changes in the identifier of the update dependency class, it is determined that the change type of the update dependency class is a minor change. The update information of the update dependency class is compared with the target call code through a matching algorithm to obtain the difference between the two. According to the update call code of the update dependency class, the parameters in the adapter class corresponding to the update dependency class are adjusted.

通过根据各更新依赖类的标识变化数量,确定各更新依赖类的变化类型,在更新依赖类的变化类型为微小变化时,根据更新依赖类的更新调用代码,调整更新依赖类对应的适配器类中的参数,在更新依赖类的变化类型为中等变化时,根据更新依赖类的更新调用代码,生成新的适配器类,并替换更新依赖类对应的适配器类,在更新依赖类的变化类型为重大变化时,生成目标组件的反编译代码,并根据更新依赖类的当前版本漏洞对编译代码进行修复,针对不同的更新依赖类的变化类型,执行不同的更新依赖类的处理方法,细化了组件版本升级的操作,提升了组件版本升级的准确率。By determining the change type of each update dependency class according to the number of changes in the identification of each update dependency class, when the change type of the update dependency class is a minor change, adjusting the parameters in the adapter class corresponding to the update dependency class according to the update calling code of the update dependency class, when the change type of the update dependency class is a medium change, generating a new adapter class according to the update calling code of the update dependency class, and replacing the adapter class corresponding to the update dependency class, when the change type of the update dependency class is a major change, generating the decompiled code of the target component, and repairing the compiled code according to the current version vulnerability of the update dependency class, executing different update dependency class processing methods for different update dependency class change types, refining the component version upgrade operation, and improving the accuracy of component version upgrade.

可选的,根据差异和差异类型,检测是否对目标组件的目标调用代码进行更新,包括:在差异类型为方法删除时,在更新调用代码中提取更新方法传参;对各更新方法传参进行分类,得到各更新方法传参的参数类型;在更新调用代码中,为参数类型为非调用变量的更新方法传参建立相应变量,并将非调用变量的更新方法传参的参数值赋值给相应变量;将相应变量替换并插入非调用变量的更新方法传参的位置处;在更新调用代码中,添加各适配器类对应的包标识和类标识的引用代码,得到新的代码,并替换目标组件的目标调用代码。Optionally, based on the differences and difference types, detect whether to update the target calling code of the target component, including: when the difference type is method deletion, extracting update method parameters in the update calling code; classifying each update method parameter to obtain the parameter type of each update method parameter; in the update calling code, establishing corresponding variables for update method parameters whose parameter types are non-calling variables, and assigning the parameter values of the update method parameters of the non-calling variables to the corresponding variables; replacing and inserting the corresponding variables at the position of the update method parameters of the non-calling variables; in the update calling code, adding reference codes of the package identifier and class identifier corresponding to each adapter class to obtain new code, and replacing the target calling code of the target component.

在差异类型为方法删除时,确定对目标组件的目标调用代码进行更新。其中,方法删除可以是更新调用代码与目标组件的目标调用代码比较更新调用代码,减少了数据处理方法的差异类型。更新方法传参可以是更新调用代码中函数头对应的参数。参数类型可以是更新方法传参的类型。参数类型可以包括非调用变量和调用变量。其中,非调用变量可以包括固定数值的变量和/或从配置文件中可以获取数值的变量。调用变量可以包括:调用链的变量和/或调用数据库得到的数值的变量等外部提供的变量,可以根据是否设置网络地址,是否通过调用接口得到数值判断该变量的参数类型。引用代码可以是引用包标识和类标识的代码,该包标识可以是指适配器类对应的数据包的标识,该类标识可以是指适配器类包括的类的标识,适配器类可以是指更新后的全部适配器类。When the difference type is method deletion, determine to update the target call code of the target component. Wherein, method deletion can be to update the call code by comparing the update call code with the target call code of the target component, thereby reducing the difference type of the data processing method. The update method parameter can be the parameter corresponding to the function header in the update call code. The parameter type can be the type of the update method parameter. The parameter type can include non-call variables and call variables. Wherein, non-call variables can include variables with fixed values and/or variables whose values can be obtained from the configuration file. The call variables can include: variables provided externally such as variables of the call chain and/or variables with values obtained by calling the database, and the parameter type of the variable can be judged according to whether the network address is set and whether the value is obtained by calling the interface. The reference code can be a code that references a package identifier and a class identifier, and the package identifier can refer to the identifier of the data packet corresponding to the adapter class, and the class identifier can refer to the identifier of the class included in the adapter class, and the adapter class can refer to all adapter classes after the update.

具体的,在差异类型为方法删除时,确定对目标组件的目标调用代码进行更新。在更新调用代码中提取更新方法传参,对各更新方法传参进行分类,得到各更新方法传参的参数类型。在更新调用代码中,查找参数类型为非调用变量的更新方法传参,为参数类型为非调用变量的更新方法传参建立相应变量,并将非调用变量的更新方法传参的参数值赋值给相应变量,将相应变量替换并插入非调用变量的更新方法传参的位置处,在更新调用代码中,添加各适配器类对应的包标识和类标识的引用代码,得到新的代码,并替换目标组件的目标调用代码。Specifically, when the difference type is method deletion, determine to update the target calling code of the target component. Extract the update method parameters in the update calling code, classify each update method parameter, and obtain the parameter type of each update method parameter. In the update calling code, find the update method parameters whose parameter type is a non-calling variable, establish corresponding variables for the update method parameters whose parameter type is a non-calling variable, and assign the parameter values of the update method parameters of the non-calling variable to the corresponding variables, replace the corresponding variables and insert them into the position of the update method parameters of the non-calling variable, in the update calling code, add the reference code of the package identifier and class identifier corresponding to each adapter class, obtain the new code, and replace the target calling code of the target component.

在一个例子中,更新调用代码为test1(a,b※c),目标组件的目标调用代码为test1(a,b※c)和test2(d,e※f)。更新调用代码与目标组件的目标调用代码的差异为test2(d,e※f),差异类型为方法删除,确定对目标组件的目标调用代码进行更新。在更新调用代码中提取更新方法传参为a和b※c;对各更新方法传参进行分类,得到a的参数类型为非调用变量,b※c为调用变量;在更新调用代码中,为a建立变量n,并将a的参数值赋值给n;将n替换并a的位置处;在更新调用代码中,添加各适配器类对应的包标识和类标识的引用代码,得到新的代码,并替换目标组件的目标调用代码。In one example, the update call code is test1 (a, b※c), and the target call code of the target component is test1 (a, b※c) and test2 (d, e※f). The difference between the update call code and the target call code of the target component is test2 (d, e※f), and the difference type is method deletion, which determines that the target call code of the target component is updated. Extract the update method parameters a and b※c in the update call code; classify the parameters of each update method, and get the parameter type of a as a non-call variable, and b※c as a call variable; in the update call code, create a variable n for a, and assign the parameter value of a to n; replace n with a; in the update call code, add the reference code of the package identifier and class identifier corresponding to each adapter class to get the new code, and replace the target call code of the target component.

通过在差异类型为方法删除时,在更新调用代码中提取更新方法传参,对各更新方法传参进行分类,得到各更新方法传参的参数类型,在更新调用代码中,为参数类型为非调用变量的更新方法传参建立相应变量,并将非调用变量的更新方法传参的参数值赋值给相应变量,将相应变量替换并插入非调用变量的更新方法传参的位置处,在更新调用代码中,添加各适配器类对应的包标识和类标识的引用代码,得到新的代码,并替换目标组件的目标调用代码,实现细粒度的类更新,细化了组件版本升级的操作,针对不同的差异类型,执行不同的目标调用代码的处理方法,细化了组件升级操作,提升了组件升级的准确性。When the difference type is method deletion, the update method parameters are extracted in the update calling code, and the update method parameters are classified to obtain the parameter type of each update method parameter. In the update calling code, corresponding variables are established for the update method parameters whose parameter types are non-calling variables, and the parameter values of the update method parameters of the non-calling variables are assigned to the corresponding variables, and the corresponding variables are replaced and inserted into the position of the update method parameters of the non-calling variables. In the update calling code, reference codes of the package identifier and class identifier corresponding to each adapter class are added to obtain new codes, and the target calling code of the target component is replaced to realize fine-grained class updates, refine the operation of component version upgrades, and execute different target calling code processing methods for different difference types, refine component upgrade operations, and improve the accuracy of component upgrades.

可选的,根据差异和差异类型,检测是否对目标组件的目标调用代码进行更新,包括:在差异类型为方法增加时,根据差异中至少一个新增的参数,生成调用目标组件的目标调用代码的备选代码;在备选代码中,将各新增的参数赋值为空;将以相同输入分别备选代码和目标调用代码中,得到备选代码的输出和目标调用代码的输出;将备选代码的输出和目标调用代码的输出进行比较,得到单元测试结果;在单元测试结果为一致时,不对目标组件的目标调用代码进行更新;在单元测试结果为不一致时,检测各新增的参数是否存在相同意图的目标参数;在不存在相同意图的目标参数时,在目标调用代码中,根据各新增的参数的参数类型,生成各新增的参数对应的更新方法传参;在目标调用代码中,为参数类型为非调用变量的更新方法传参建立相应变量,并将非调用变量的更新方法传参的参数值赋值给相应变量,以及将相应变量替换并插入非调用变量的更新方法传参的位置处;在存在相同意图的目标参数时,在更新调用代码中采用目标参数的变量对新增的参数进行替换,并替换目标调用代码。Optionally, based on the difference and the difference type, detect whether to update the target calling code of the target component, including: when the difference type is method addition, generate alternative code for calling the target calling code of the target component based on at least one newly added parameter in the difference; in the alternative code, assign each newly added parameter to null; use the same input in the alternative code and the target calling code respectively to obtain the output of the alternative code and the output of the target calling code; compare the output of the alternative code with the output of the target calling code to obtain a unit test result; when the unit test results are consistent, do not update the target calling code of the target component; when the unit test results are inconsistent , detect whether each newly added parameter has a target parameter with the same intention; when there is no target parameter with the same intention, in the target calling code, generate the update method parameter corresponding to each newly added parameter according to the parameter type of each newly added parameter; in the target calling code, establish a corresponding variable for the update method parameter whose parameter type is a non-calling variable, assign the parameter value of the update method parameter of the non-calling variable to the corresponding variable, and replace and insert the corresponding variable at the position of the update method parameter of the non-calling variable; when there is a target parameter with the same intention, use the variable of the target parameter in the update calling code to replace the newly added parameter, and replace the target calling code.

其中,方法增加可以是与目标调用代码比较,更新调用代码增加了数据处理方法的类型。备选代码可以是对目标调用代码进行封装,生成的新的代码,备选代码中调用目标调用代码,继承目标调用代码的功能。单元测试结果可以是用于测试备选代码和目标调用代码的功能是否一致,具体是测试在同样输入的情况下,备选代码的输出的结果和目标调用代码的输出的结果是否一致。与新增的参数具有相同意图的目标参数可以是指新增的参数的功能和目标参数的功能相同,例如作为同样的函数的输入,进行相同处理,又如,处于相同的调用链节点中等。更新方法传参可以是更新调用代码中外部提供的参数。非调用变量可以是指内部传输指定的参数,例如非调用传参不是外部提供的参数。Among them, the method addition can be compared with the target calling code, and the updating calling code adds the type of data processing method. The alternative code can be a new code generated by encapsulating the target calling code, and the target calling code is called in the alternative code to inherit the function of the target calling code. The unit test result can be used to test whether the functions of the alternative code and the target calling code are consistent, specifically to test whether the output result of the alternative code is consistent with the output result of the target calling code under the same input. The target parameter with the same intention as the newly added parameter can refer to the function of the newly added parameter being the same as the function of the target parameter, for example, as the input of the same function, performing the same processing, or being in the same call chain node, etc. The update method parameter passing can be an externally provided parameter in the update calling code. Non-call variables can refer to parameters specified by internal transmission, for example, non-call parameters are not externally provided parameters.

具体的,在差异类型为方法增加时,差异包括至少一个新增的函数,并且一个新增的函数包括至少一个新增的参数。根据差异中至少一个新增的参数,生成调用目标调用代码的备选代码,具体是将备选代码的传参设置包括全部新增的参数,并在备选代码中,将各新增的参数赋值为空,将以相同输入分别备选代码和目标调用代码中,得到备选代码的输出和目标调用代码的输出,将备选代码的输出和目标调用代码的输出进行比较,得到单元测试结果。在单元测试结果为一致时,表明更新后增加的参数对原有的函数功能无改变,从而目标调用代码和更新调用代码实现的功能实质相同,不对目标组件的目标调用代码进行更新。在单元测试结果为不一致时,需要对目标组件的目标调用代码进行更新检测各新增的参数是否存在相同意图的目标参数。可以根据参数生成的知识图谱检测新增的参数是否存在相同意图的目标参数。在新增的参数不存在相同意图的目标参数时,在目标调用代码中,根据各新增的参数的参数类型,生成各新增的参数对应的更新方法传参。不同的参数类型对应的参数的更新方法不同,在目标调用代码中,为参数类型为非调用变量的更新方法传参建立相应变量,并将非调用变量的更新方法传参的参数值赋值给相应变量,以及将相应变量替换并插入非调用变量的更新方法传参的位置处,在存在相同意图的目标参数时,在更新调用代码中采用目标参数的变量对新增的参数进行替换,相当于是在目标调用代码中将新增的参数替换为目标参数的变量。Specifically, when the difference type is method addition, the difference includes at least one newly added function, and one newly added function includes at least one newly added parameter. According to at least one newly added parameter in the difference, an alternative code for calling the target calling code is generated, specifically, the parameter setting of the alternative code includes all newly added parameters, and in the alternative code, each newly added parameter is assigned to null, and the output of the alternative code and the output of the target calling code are obtained by using the same input in the alternative code and the target calling code, and the output of the alternative code and the output of the target calling code are compared to obtain the unit test result. When the unit test result is consistent, it indicates that the parameters added after the update have no change to the original function function, so that the functions implemented by the target calling code and the updated calling code are essentially the same, and the target calling code of the target component is not updated. When the unit test result is inconsistent, the target calling code of the target component needs to be updated to detect whether each newly added parameter has the same intended target parameter. It can be detected whether the newly added parameters have the same intended target parameters based on the knowledge graph generated by the parameters. When the newly added parameters do not have the same intended target parameters, in the target calling code, according to the parameter type of each newly added parameter, the updated method parameter corresponding to each newly added parameter is generated. Different parameter types correspond to different parameter update methods. In the target calling code, corresponding variables are established for the update method parameters whose parameter types are non-calling variables, and the parameter values of the update method parameters of the non-calling variables are assigned to the corresponding variables, and the corresponding variables are replaced and inserted into the position of the update method parameters of the non-calling variables. When there are target parameters with the same intention, the variables of the target parameters are used to replace the newly added parameters in the update calling code, which is equivalent to replacing the newly added parameters with the variables of the target parameters in the target calling code.

将备选代码的输出和目标调用代码的输出进行比较,得到单元测试结果。可创建单元测试类(mock程序),实现自动执行单元测试。可通过运行mock程序调用目标调用代码和备选代码处理相同输入,检测备选代码的输出和目标调用代码的输出是否相同,若备选代码的输出和目标调用代码的输出相同,表明备选代码和目标调用代码属于相同意图,若备选代码的输出和目标调用代码的输出不相同,表明备选代码和目标调用代码不属于相同意图。Compare the output of the candidate code with the output of the target calling code to get the unit test result. You can create a unit test class (mock program) to automatically execute unit tests. You can run the mock program to call the target calling code and the candidate code to process the same input, and check whether the output of the candidate code is the same as the output of the target calling code. If the output of the candidate code is the same as the output of the target calling code, it means that the candidate code and the target calling code have the same intention. If the output of the candidate code is different from the output of the target calling code, it means that the candidate code and the target calling code do not have the same intention.

在一个例子中,更新调用代码为test1(a,b※c),目标组件的目标调用代码为test1(a)。更新调用代码与目标组件的目标调用代码的差异为b※c,差异类型为方法增加。根据差异中新增的参数b※c,生成调用目标组件的目标调用代码的备选代码,在备选代码中,将各新增的参数赋值为空(null)。将以相同输入数据分别输入到备选代码和目标调用代码中,得到备选代码的输出为3和目标调用代码的输出为3。将备选代码的输出为3和目标调用代码的输出为3进行比较,得到单元测试结果为一致,表明更新后增加的参数对原有的函数功能无改变,从而目标调用代码和更新调用代码实现的功能实质相同,不对目标组件的目标调用代码进行更新。In one example, the update calling code is test1 (a, b ※ c), and the target calling code of the target component is test1 (a). The difference between the update calling code and the target calling code of the target component is b ※ c, and the difference type is method addition. Based on the newly added parameters b ※ c in the difference, an alternative code for calling the target calling code of the target component is generated. In the alternative code, each newly added parameter is assigned a value of null. The same input data is input into the alternative code and the target calling code respectively, and the output of the alternative code is 3 and the output of the target calling code is 3. The output of the alternative code 3 is compared with the output of the target calling code 3, and the unit test results are consistent, indicating that the parameters added after the update have no change to the original function function, so the functions implemented by the target calling code and the update calling code are essentially the same, and the target calling code of the target component is not updated.

通过在差异类型为方法增加时,根据差异中至少一个新增的参数,生成调用目标组件的目标调用代码的备选代码,在备选代码中,将各新增的参数赋值为空,将以相同输入分别备选代码和目标调用代码中,得到备选代码的输出和目标调用代码的输出,将备选代码的输出和目标调用代码的输出进行比较,得到单元测试结果,在单元测试结果为一致时,不对目标组件的目标调用代码进行更新,在单元测试结果为不一致时,检测各新增的参数是否存在相同意图的目标参数,在不存在相同意图的目标参数时,在目标调用代码中,根据各新增的参数的参数类型,生成各新增的参数对应的更新方法传参,在目标调用代码中,为参数类型为非调用变量的更新方法传参建立相应变量,并将非调用变量的更新方法传参的参数值赋值给相应变量,以及将相应变量替换并插入非调用变量的更新方法传参的位置处,在存在相同意图的目标参数时,在更新调用代码中采用目标参数的变量对新增的参数进行替换,并替换目标调用代码,针对不同的参数执行不同的参数替换方法,可实现差异化参数替换,细化了参数替换的方法,提升了组件升级的准确率,并且无需人为进行操作,降低了人工成本。By generating an alternative code for the target calling code of the target component according to at least one newly added parameter in the difference when the difference type is method addition, in the alternative code, assigning each newly added parameter to be empty, using the same input in the alternative code and the target calling code respectively, obtaining the output of the alternative code and the output of the target calling code, comparing the output of the alternative code with the output of the target calling code to obtain a unit test result, and when the unit test results are consistent, not updating the target calling code of the target component, and when the unit test results are inconsistent, detecting whether each newly added parameter has the target parameter with the same intention, and when there is no target parameter with the same intention, in the target calling code, checking whether each newly added parameter has the target parameter with the same intention, and when the target calling code does not have the target parameter with the same intention, The parameter type of the number is generated, and the update method parameters corresponding to the newly added parameters are generated. In the target calling code, corresponding variables are established for the update method parameters whose parameter types are non-calling variables, and the parameter values of the update method parameters of the non-calling variables are assigned to the corresponding variables, and the corresponding variables are replaced and inserted into the position of the update method parameters of the non-calling variables. When there are target parameters with the same intention, the variables of the target parameters are used in the update calling code to replace the newly added parameters, and the target calling code is replaced. Different parameter replacement methods are executed for different parameters, which can realize differentiated parameter replacement, refine the parameter replacement method, improve the accuracy of component upgrades, and do not require manual operation, thereby reducing labor costs.

可选的,检测各新增的参数是否存在相同意图的目标参数,包括:在项目代码中,查询是否存在与各新增的参数的参数类型相同的目标参数;和/或获取目标组件的升级数据包,以及目标组件的当前数据包;检测目标组件的升级数据包与当前数据包,检测各新增的参数是否存在相同调用链的目标参数。Optionally, detect whether each newly added parameter has a target parameter with the same intention, including: querying in the project code whether there is a target parameter with the same parameter type as each newly added parameter; and/or obtaining an upgrade data packet of the target component and a current data packet of the target component; detecting the upgrade data packet and the current data packet of the target component to detect whether each newly added parameter has a target parameter with the same call chain.

其中,项目代码可以是项目文件中包含的代码。升级数据包可以是用于升级目标组件的数据包,通常是从目标组件的服务系统中下载得到。当前数据包可以是当前版本号的目标组件的数据包。调用链可以用于描述组件中类和/或参数等元素之间的调用关系。The project code may be the code contained in the project file. The upgrade data package may be a data package used to upgrade the target component, which is usually downloaded from the service system of the target component. The current data package may be a data package of the target component with the current version number. The call chain may be used to describe the call relationship between elements such as classes and/or parameters in a component.

具体的,在项目代码中,查询是否存在与各新增的参数的参数类型相同的目标参数,查询方法包括但不限于:顺序查找算法、二分查找算法或哈希查找算法等。和/或获取目标组件的升级数据包,以及目标组件的当前数据包,检测目标组件的升级数据包与当前数据包,检测各新增的参数是否存在相同调用链的目标参数,检测方式可以是神经网络或知识图谱等。Specifically, in the project code, it is queried whether there are target parameters of the same parameter type as the newly added parameters, and the query method includes but is not limited to: sequential search algorithm, binary search algorithm or hash search algorithm, etc. And/or the upgrade data packet of the target component and the current data packet of the target component are obtained, and the upgrade data packet of the target component and the current data packet are detected, and whether there are target parameters of the same call chain for each newly added parameter, and the detection method can be a neural network or a knowledge graph, etc.

在一个例子中,在项目代码中,通过顺序查找算法查询存在与各新增的参数的参数类型相同的目标参数。获取目标组件的升级数据包import numpy,以及目标组件的当前数据包import numpy,检测目标组件的升级数据包与当前数据包相同,升级数据包中新增的参数1可被函数1调用,当前数据包中参数可被函数1调用,通过神经网络检测存在相同调用链的目标参数为参数1。In one example, in the project code, a sequential search algorithm is used to query the target parameters that have the same parameter type as each newly added parameter. The upgrade data packet of the target component imports numpy, and the current data packet of the target component imports numpy, detect that the upgrade data packet of the target component is the same as the current data packet, the newly added parameter 1 in the upgrade data packet can be called by function 1, and the parameter in the current data packet can be called by function 1, and the target parameter with the same call chain is detected as parameter 1 through a neural network.

通过在项目代码中,查询是否存在与各新增的参数的参数类型相同的目标参数,和/或获取目标组件的升级数据包,以及目标组件的当前数据包,检测目标组件的升级数据包与当前数据包,检测各新增的参数是否存在相同调用链的目标参数,可获取检测各新增的参数是否存在相同调用链的目标参数的检测结果,进而进行更新方式的选取,数据更新更加准确,提升了组件更新的准确率。By querying in the project code whether there are target parameters with the same parameter type as each newly added parameter, and/or obtaining the upgrade data packet of the target component and the current data packet of the target component, detecting the upgrade data packet and the current data packet of the target component, and detecting whether each newly added parameter has the target parameter of the same call chain, the detection result of detecting whether each newly added parameter has the target parameter of the same call chain can be obtained, and then the update method can be selected, so that data update is more accurate and the accuracy of component update is improved.

实施例二Embodiment 2

图2和图3为本发明实施例二提供的一种组件版本升级方法的流程图。本发明实施例在上述实施例的基础上,将“获取目标应用的待升级的目标组件,以及目标组件的目标版本号”具体化为“在获取目标应用的待升级的目标组件,以及目标组件的目标版本号之前,还包括:获取需要自动升级的目标组件和当前版本号;根据目标组件以及当前版本号生成目标组件的当前依赖配置,并在目标应用的项目文件中更新目标组件对应的节点;根据目标组件以及目标版本号生成目标组件的第一调用代码;根据目标组件的第一调用代码,获取至少一个当前依赖类的当前信息;根据各依赖类的当前信息,在项目文件中创建各当前依赖类对应的适配器类,当前依赖类对应的适配器类继承当前依赖类;在项目文件中建立项目文件与各当前依赖类的当前信息的对应关系;在第一调用代码中提取当前方法传参,并根据当前方法传参对第一调用代码进行调整,得到第二调用代码;在第二调用代码中,添加各当前适配器类对应的包标识和类标识的引用代码,得到目标组件的目标调用代码”,进一步提高了组件版本升级的准确度。需要说明的是,在本发明实施例中未详述的部分,可参见其他实施例的表述。Figures 2 and 3 are flowcharts of a component version upgrade method provided by Embodiment 2 of the present invention. Based on the above embodiments, the embodiment of the present invention concretizes "obtaining the target component to be upgraded of the target application and the target version number of the target component" as "before obtaining the target component to be upgraded of the target application and the target version number of the target component, it also includes: obtaining the target component to be automatically upgraded and the current version number; generating the current dependency configuration of the target component according to the target component and the current version number, and updating the node corresponding to the target component in the project file of the target application; generating the first call code of the target component according to the target component and the target version number; obtaining the current information of at least one current dependent class according to the first call code of the target component; creating the adapter class corresponding to each current dependent class in the project file according to the current information of each dependent class, and the adapter class corresponding to the current dependent class inherits the current dependent class; establishing the corresponding relationship between the project file and the current information of each current dependent class in the project file; extracting the current method parameter in the first call code, and adjusting the first call code according to the current method parameter to obtain the second call code; in the second call code, adding the reference code of the package identifier and class identifier corresponding to each current adapter class to obtain the target call code of the target component", further improving the accuracy of component version upgrade. It should be noted that for the parts not described in detail in the embodiments of the present invention, reference may be made to the descriptions of other embodiments.

参见图2和图3所示的组件版本升级方法,图2中步骤S210执行结束后执行图3中的步骤S211,包括:Referring to the component version upgrade method shown in FIG. 2 and FIG. 3 , after step S210 in FIG. 2 is executed, step S211 in FIG. 3 is executed, including:

S201、获取需要自动升级的目标组件和当前版本号。S201. Obtain the target component that needs to be automatically upgraded and the current version number.

本发明实施例适用于在对目标组件进行自动升级之前,需要对目标组件关联的数据进行改造的场景。具体的,可通过用户指定方式或自动扫描方式,获取需要自动升级的目标组件和目标组件对应的当前版本号。当前版本号可以是指目标组件当前应该处于的版本的标识。该当前版本号不一定是最新的版本号。示例的,自动扫描方式可以通过idea maven配置的settings.xml文件路径,解析mirror配置的组件库,获取组件库库的所有索引(index),自动扫描pom.xml文件的版本升级数据,获取需要自动升级的目标组件和当前版本号。用户指定方式可以是用户通过鼠标选择或键盘输入的方式指定需升级的maven组件及其当前版本号。The embodiments of the present invention are applicable to the scenario where the data associated with the target component needs to be modified before the target component is automatically upgraded. Specifically, the target component that needs to be automatically upgraded and the current version number corresponding to the target component can be obtained by user-specified method or automatic scanning method. The current version number may refer to the identifier of the version that the target component should currently be in. The current version number is not necessarily the latest version number. For example, the automatic scanning method can parse the component library configured by mirror through the settings.xml file path configured by idea Maven, obtain all indexes (index) of the component library, automatically scan the version upgrade data of the pom.xml file, and obtain the target component that needs to be automatically upgraded and the current version number. The user-specified method can be that the user specifies the Maven component to be upgraded and its current version number by mouse selection or keyboard input.

在一个例子中,idea启动后,通过获取idea的maven组件配置的settings.xml文件路径,解析镜像(mirror)配置的组件库路径,并通过网络爬虫,抓取所有组件的名称及版本,并进行本地化缓存或完成新版本的增加;当用户需要增加maven组件时,通过快捷键alt+M获取智能化组件界面,在智能化组件输入需要添加的maven组件的名称,并选择Maven组件版本号,获取需要自动升级的目标组件为log4j和当前版本号2.17.1。In one example, after idea is started, it obtains the settings.xml file path of the idea's Maven component configuration, parses the component library path of the mirror configuration, and crawls the names and versions of all components through a web crawler, and performs localized caching or adds new versions; when the user needs to add a Maven component, the intelligent component interface is obtained through the shortcut key alt+M, the name of the Maven component to be added is entered in the intelligent component, and the Maven component version number is selected to obtain the target component that needs to be automatically upgraded, which is log4j and the current version number 2.17.1.

S202、根据目标组件以及当前版本号生成目标组件的当前依赖配置,并在目标应用的项目文件中更新目标组件对应的节点。S202: Generate a current dependency configuration of the target component according to the target component and the current version number, and update a node corresponding to the target component in a project file of the target application.

其中,当前依赖配置可以是目标组件的当前版本号对应的配置信息。The current dependency configuration may be configuration information corresponding to the current version number of the target component.

具体的,根据目标组件以及当前版本号生成目标组件的当前依赖配置,生成方法包括但不限于:大语言模型、反向传播神经网络、卷积神经网络、循环神经网络、生成对抗神经网络、图神经网络或长短时记忆网络等,本发明实施例对此不进行限制。在目标应用的项目文件中,查找是否含有当前依赖配置信息,若未包含,则自动在项目文件中添加一个目标组件对应的节点,相当于是在应用程序中集成了该组件的功能。从而,在目标组件需要升级,且目标应用的项目文件中存在该目标组件对应的节点时,需要修改该目标组件对应的节点;在目标组件需要升级,且目标应用的项目文件中不存在该目标组件对应的节点时,需要新建该目标组件对应的节点。其中,修改该目标组件对应的节点可以是删除已建立的节点,并新建当前依赖配置对应的节点。Specifically, the current dependency configuration of the target component is generated according to the target component and the current version number. The generation method includes but is not limited to: large language model, back propagation neural network, convolutional neural network, recurrent neural network, generative adversarial neural network, graph neural network or long short-term memory network, etc., and the embodiment of the present invention does not limit this. In the project file of the target application, find whether it contains the current dependency configuration information. If not, a node corresponding to the target component is automatically added to the project file, which is equivalent to integrating the function of the component in the application. Therefore, when the target component needs to be upgraded and the node corresponding to the target component exists in the project file of the target application, the node corresponding to the target component needs to be modified; when the target component needs to be upgraded and the node corresponding to the target component does not exist in the project file of the target application, a new node corresponding to the target component needs to be created. Among them, modifying the node corresponding to the target component can be to delete the established node and create a new node corresponding to the current dependency configuration.

在一个例子中,目标组件为log4j,log4j的目标版本号为2.17.1。根据目标组件以及目标版本号,可作为大语言模型的输入数据,预设大语言模型的输入模版(prompt)为:“XX YY的maven依赖”,XX和YY位置处的数据可被替换,XX可被目标组件替换,YY可被目标版本号替换,示例的:大语言模型的输入数据可以是log4j 2.17.1的maven依赖,通过大语言模型生成目标组件log4j的当前依赖配置,当前依赖配置为<artifactId>log4j</artifactId><version>2.17.1</version>。查找可执行项目文件集合中的pom.xml文件,在文件内查找不含有maven的当前依赖配置信息,则自动在dependencies节点中插入dependency从属节点,即在项目文件中插入待添加目标组件对应的可执行文件,大语言模型返回dependency节点的信息,完成节点的更新。In one example, the target component is log4j, and the target version number of log4j is 2.17.1. According to the target component and the target version number, they can be used as input data for the large language model. The preset input template (prompt) of the large language model is: "XX YY's Maven dependency". The data at the positions of XX and YY can be replaced. XX can be replaced by the target component, and YY can be replaced by the target version number. For example, the input data of the large language model can be the Maven dependency of log4j 2.17.1. The current dependency configuration of the target component log4j is generated by the large language model. The current dependency configuration is <artifactId>log4j</artifactId><version>2.17.1</version>. Search the pom.xml file in the executable project file collection, and search the file for the current dependency configuration information that does not contain Maven. Then automatically insert the dependency subordinate node in the dependencies node, that is, insert the executable file corresponding to the target component to be added in the project file. The large language model returns the information of the dependency node and completes the node update.

S203、根据目标组件以及当前版本号生成目标组件的第一调用代码。S203: Generate a first calling code of the target component according to the target component and the current version number.

其中,第一调用代码可以是对目标组件的当前版本号对应的可执行文件中的代码进行调用的代码。具体的,第一调用代码的方法名,为预设的方法名。The first calling code may be a code for calling the code in the executable file corresponding to the current version number of the target component. Specifically, the method name of the first calling code is a preset method name.

具体的,预设大语言模型的prompt为:“XX YY的第一调用代码”,根据目标组件及当前版本号与大语言模型的prompt融合,通过将目标组件替换为XX,将当前版本号替换为YY,可通过大语言模型生成目标组件对应的第一调用代码。Specifically, the prompt of the preset large language model is: "XX YY's first calling code". According to the fusion of the target component and the current version number with the prompt of the large language model, by replacing the target component with XX and the current version number with YY, the first calling code corresponding to the target component can be generated through the large language model.

在一个例子中,目标组件为log4j,log4j的当前版本号为2.17.1,生成大语言模型的输入数据为:log4j 2.17.1的更新调用代码,通过大语言模型得到目标组件log4j的第一调用代码。In an example, the target component is log4j, the current version number of log4j is 2.17.1, and the input data for generating the large language model is: the updated calling code of log4j 2.17.1. The first calling code of the target component log4j is obtained through the large language model.

S204、根据目标组件的第一调用代码,获取至少一个当前依赖类的当前信息。S204. According to the first calling code of the target component, obtain current information of at least one current dependent class.

其中,第一调用代码中包括目标组件的当前依赖类的类名,具体的,第一调用代码中包括引用代码,引用代码中包括目标组件包括的全部依赖类的类名。此外,引用代码中还包括目标组件包括的全部数据包。当前依赖类可以是指第一调用代码中的依赖类。目标组件包括至少一个依赖类。当前信息可以是目标组件的当前依赖类的数据。The first calling code includes the class name of the current dependent class of the target component. Specifically, the first calling code includes a reference code, and the reference code includes the class names of all dependent classes included in the target component. In addition, the reference code also includes all data packets included in the target component. The current dependent class may refer to the dependent class in the first calling code. The target component includes at least one dependent class. The current information may be data of the current dependent class of the target component.

具体的,根据目标组件的第一调用代码,可获取第一调用代码中包括的当前依赖类的当前信息,获取方式包括但不限于:神经网络、深度优先遍历或广度优先遍历等,本发明实施例对此不进行限制。Specifically, according to the first calling code of the target component, the current information of the current dependency class included in the first calling code can be obtained, and the acquisition method includes but is not limited to: neural network, depth-first traversal or breadth-first traversal, etc., which is not limited by the embodiment of the present invention.

在一个例子中,根据目标组件log4j的第一调用代码,通过神经网络识别,获取为目标组件log4j的当前信息为test(a,b,c)。In one example, according to the first calling code of the target component log4j, the current information of the target component log4j is obtained as test (a, b, c) through neural network recognition.

S205、根据各依赖类的当前信息,在项目文件中创建各当前依赖类对应的适配器类,当前依赖类对应的适配器类继承当前依赖类。S205. Create an adapter class corresponding to each current dependent class in the project file according to the current information of each dependent class. The adapter class corresponding to the current dependent class inherits the current dependent class.

其中,适配器类与目标组件包括的依赖类一一对应。适配器类可以是指对目标组件包括的依赖类进行继承,适配器类实现了对应的依赖类对应的功能。The adapter class corresponds to the dependency class included in the target component one by one. The adapter class may refer to the inheritance of the dependency class included in the target component, and the adapter class implements the corresponding function of the corresponding dependency class.

具体的,根据各依赖类的当前信息,在项目文件中创建各当前依赖类对应的适配器类。根据第一调用代码对应的import数据,获取需要加载的数据包名和类名。根据类名从数据包里查询该类名对应的字节码,获取类名对应的数据包。解析该类名对应的字节码,获取该类名包括的公共(public)方法。根据类名和条件构造器(wapper)在当前项目工程下,创建新的适配器类,新的适配器类与当前依赖类一一对应,适配器类继承原有的当前依赖类。获取原来的当前依赖类的类名和方法名,在新的适配器类中生成与原来的当前依赖类的类名和方法名一模一样的方法。但该生成的方法只包括方法名和参数名,没有方法体。对该新生成的适配器类创建一个方法体,调用原来的当前依赖类的方法名。方法体可通过以下方式创建:调用当前依赖类,并传入当前依赖类所需的参数。Specifically, according to the current information of each dependent class, an adapter class corresponding to each current dependent class is created in the project file. According to the import data corresponding to the first calling code, the data package name and class name to be loaded are obtained. According to the class name, the bytecode corresponding to the class name is queried from the data package to obtain the data package corresponding to the class name. The bytecode corresponding to the class name is parsed to obtain the public method included in the class name. According to the class name and the conditional constructor (wapper), a new adapter class is created under the current project. The new adapter class corresponds to the current dependent class one by one, and the adapter class inherits the original current dependent class. The class name and method name of the original current dependent class are obtained, and a method with the same class name and method name as the original current dependent class is generated in the new adapter class. However, the generated method only includes the method name and parameter name, and there is no method body. A method body is created for the newly generated adapter class, and the method name of the original current dependent class is called. The method body can be created in the following way: calling the current dependent class and passing in the parameters required by the current dependent class.

在一个例子中,示例的,在适配器类进行重新和super进行原始类名的调用In an example, for example, in the adapter class, re-call the original class name with super.

针对当前依赖类test(a,b)创建的适配器类super.test(a,b),The adapter class super.test(a,b) created for the current dependent class test(a,b),

该适配器类的方法体为:test(a,b)The method body of the adapter class is: test(a,b)

此外,还需要在目录中创建相应的元数据。具体的,在资源(resource)文件中创建XX目标文件夹,并在该目标文件夹中建立对应关系元数据信息,元数据信息包括pom.xml和适配器类wapper之间的对应信息,建立pom.xml和包名之间的对应关系以及pom.xml和类名之间的对应关系。In addition, you need to create corresponding metadata in the directory. Specifically, create an XX target folder in the resource file, and establish corresponding metadata information in the target folder. The metadata information includes the corresponding information between pom.xml and the adapter class wapper, the corresponding relationship between pom.xml and the package name, and the corresponding relationship between pom.xml and the class name.

S206、在项目文件中建立项目文件与各当前依赖类的当前信息的对应关系。S206: Establish a correspondence between the project file and the current information of each current dependent class in the project file.

其中,对应关系可以是项目文件与各当前依赖类的当前信息之间的映射数据。一个项目文件对应至少一个当前依赖类的当前信息,一个当前依赖类对应一个当前信息。The corresponding relationship may be mapping data between the project file and the current information of each current dependency class. One project file corresponds to the current information of at least one current dependency class, and one current dependency class corresponds to one current information.

具体的,一个项目文件可对应至少一个当前依赖类,一个当前类与其当前信息一一对应,可通过大语言模型识别各项目文件与各当前依赖类的标识,根据各标识之间的对应关系,在项目文件中建立项目文件与各当前依赖类的当前信息的对应关系。Specifically, a project file may correspond to at least one current dependency class, and a current class may correspond one-to-one to its current information. The identifiers of each project file and each current dependency class may be identified through a large language model, and the correspondence between the project file and the current information of each current dependency class may be established in the project file based on the correspondence between the identifiers.

在一个例子中,项目文件的标识为class t,当前依赖类1的标识为class t,当前依赖类2的标识为class d,在项目文件中建立项目文件与当前依赖类1的当前信息的对应关系。In an example, the identifier of the project file is class t, the identifier of the current dependent class 1 is class t, the identifier of the current dependent class 2 is class d, and a correspondence between the project file and the current information of the current dependent class 1 is established in the project file.

S207、在第一调用代码中提取当前方法传参,并根据当前方法传参对第一调用代码进行调整,得到第二调用代码。S207. Extract the current method parameters from the first calling code, and adjust the first calling code according to the current method parameters to obtain a second calling code.

其中,当前方法传参可以是第一调用代码中包含的当前依赖类的参数。第二调用代码可以是第一调用代码的参数经过调整后的代码。The current method parameter may be a parameter of the current dependent class contained in the first calling code. The second calling code may be a code after the parameters of the first calling code are adjusted.

具体的,在第一调用代码中提取当前方法传参,对当前方法传参进行分类,得到各当前方法传参的参数类型,并根据当前方法传参的参数类型,在第一调用代码中,为参数类型为非调用变量的方法传参建立相应变量,并将非调用变量的方法传参的参数值赋值给相应变量;将相应变量替换并插入非调用变量的方法传参的位置处,得到第二调用代码。第一调用代码的生成方法与在差异类型为方法删除时,对目标调用代码进行更新的方法相同。调用变量的方法传参可以是网络地址或端口等依赖外部配置的参数。调用变量的方法传参可以直接进行变量替换,或者不进行变量替换。将替换非调用变量的方法传参的第一调用代码确定为第二调用代码。Specifically, extract the current method parameters in the first calling code, classify the current method parameters, obtain the parameter type of each current method parameter, and according to the parameter type of the current method parameter, establish corresponding variables for the method parameters whose parameter types are non-calling variables in the first calling code, and assign the parameter values of the method parameters of the non-calling variables to the corresponding variables; replace and insert the corresponding variables at the position of the method parameters of the non-calling variables to obtain the second calling code. The generation method of the first calling code is the same as the method for updating the target calling code when the difference type is method deletion. The method parameters of the calling variables can be parameters that depend on external configuration, such as network addresses or ports. The method parameters of the calling variables can directly perform variable replacement, or no variable replacement is performed. The first calling code that replaces the method parameters of the non-calling variables is determined as the second calling code.

在一个例子中,第一调用代码为test1(a,b),在第一调用代码中提取当前方法传参为a和b;对各当前方法传参进行分类,得到a的参数类型为非调用变量,b为调用变量;在第一调用代码中,为a建立变量n,并将a的参数值赋值给n;将n替换并a的位置处,得到新的代码为第二调用代码。In an example, the first calling code is test1 (a, b), and the current method parameters a and b are extracted in the first calling code; the current method parameters are classified to obtain the parameter type of a as a non-calling variable, and b as a calling variable; in the first calling code, a variable n is created for a, and the parameter value of a is assigned to n; n is replaced in the position of a, and the new code obtained is the second calling code.

S208、在第二调用代码中,添加各当前适配器类对应的包标识和类标识的引用代码,得到目标组件的目标调用代码。S208. In the second calling code, add the reference codes of the package identifier and class identifier corresponding to each current adapter class to obtain the target calling code of the target component.

具体的,对第二调用代码进行识别,获取第二调用代码对应的待添加的包标识和类标识,可通过大语言模型生成各当前适配器类对应的包标识和类标识的引用代码,将引用代码添加到第二调用代码,得到目标组件的目标调用代码。Specifically, the second calling code is identified, and the package identifier and class identifier to be added corresponding to the second calling code are obtained. The reference code of the package identifier and class identifier corresponding to each current adapter class can be generated through a large language model, and the reference code is added to the second calling code to obtain the target calling code of the target component.

在一个例子中,对第二调用代码进行识别,获取第二调用代码对应的待添加的包标识为org和类标识hutool,可通过大语言模型生成各当前适配器类对应的包标识和类标识的引用代码,例如引用代码为import org. hutool,将引用代码添加到第二调用代码中,得到目标组件的目标调用代码。In an example, the second calling code is identified, and the package identifier org and class identifier hutool to be added corresponding to the second calling code are obtained. The reference code of the package identifier and class identifier corresponding to each current adapter class can be generated through a large language model. For example, the reference code is import org. hutool. The reference code is added to the second calling code to obtain the target calling code of the target component.

S209、获取目标应用的待升级的目标组件,以及目标组件的目标版本号。S209: Obtain the target component to be upgraded of the target application and the target version number of the target component.

S210、根据目标组件以及目标版本号生成目标组件的更新依赖配置,并在目标应用的项目文件中更新目标组件对应的节点。S210: Generate an update dependency configuration of the target component according to the target component and the target version number, and update a node corresponding to the target component in a project file of the target application.

S211、根据目标组件以及目标版本号生成目标组件的更新调用代码。S211. Generate an update calling code for the target component according to the target component and the target version number.

S212、根据目标组件的更新调用代码,获取至少一个更新依赖类的更新信息。S212. Obtain update information of at least one update-dependent class according to the update calling code of the target component.

S213、将各更新依赖类的更新信息与目标组件的相应适配器类进行比较,得到各更新依赖类的类比较结果。S213: Compare the update information of each update-dependent class with the corresponding adapter class of the target component to obtain a class comparison result of each update-dependent class.

S214、根据各所述更新依赖类的类比较结果,检测是否对所述目标组件的相应适配器类进行更新。S214: Detect whether to update the corresponding adapter class of the target component according to the class comparison result of each update dependent class.

S215、检测更新调用代码与目标组件的目标调用代码的差异,并确定差异类型。S215: Detect the difference between the update calling code and the target calling code of the target component, and determine the difference type.

S216、根据差异和差异类型,检测是否对目标组件的目标调用代码进行更新。S216. Detect whether to update the target calling code of the target component according to the difference and the difference type.

本发明实施例的技术方案,通过获取需要自动升级的目标组件和当前版本号,根据目标组件以及当前版本号生成目标组件的当前依赖配置,并在目标应用的项目文件中更新目标组件对应的节点,根据目标组件以及目标版本号生成目标组件的第一调用代码,根据目标组件的第一调用代码,获取至少一个当前依赖类的当前信息,根据各依赖类的当前信息,在项目文件中创建各当前依赖类对应的适配器类,当前依赖类对应的适配器类继承当前依赖类,可对原有的类进行升级,不仅可以使用原有类的功能,还能添加新的功能,提升了功能的多样性,并且类的代码可复用,节约了存储资源。在项目文件中建立项目文件与各当前依赖类的当前信息的对应关系,在第一调用代码中提取当前方法传参,并根据当前方法传参对第一调用代码进行调整,得到第二调用代码,在第二调用代码中,添加各当前适配器类对应的包标识和类标识的引用代码,得到目标组件的目标调用代码,通过添加包标识和类标识的引用代码,可建立包标识与类标识与目标组件之间的映射关系,避免组件升级内容错误,提升了组件升级的准确性。The technical solution of the embodiment of the present invention obtains the target component that needs to be automatically upgraded and the current version number, generates the current dependency configuration of the target component according to the target component and the current version number, and updates the node corresponding to the target component in the project file of the target application, generates the first calling code of the target component according to the target component and the target version number, obtains the current information of at least one current dependent class according to the first calling code of the target component, and creates an adapter class corresponding to each current dependent class in the project file according to the current information of each dependent class. The adapter class corresponding to the current dependent class inherits the current dependent class and can upgrade the original class. Not only can the functions of the original class be used, but new functions can also be added, thereby improving the diversity of functions. The class code can be reused, saving storage resources. A correspondence between the project file and the current information of each current dependent class is established in the project file, the current method parameters are extracted in the first calling code, and the first calling code is adjusted according to the current method parameters to obtain the second calling code, and in the second calling code, the reference code of the package identifier and class identifier corresponding to each current adapter class is added to obtain the target calling code of the target component. By adding the reference code of the package identifier and class identifier, a mapping relationship between the package identifier, the class identifier and the target component can be established, thereby avoiding errors in component upgrade content and improving the accuracy of component upgrade.

可选的,在得到目标组件的目标调用代码之后,还包括:以相同输入分别输入到第一调用代码和目标调用代码中,得到第一调用代码的输出和目标调用代码的输出;在第一调用代码的输出和目标调用代码的输出一致时,确定目标调用代码正确。Optionally, after obtaining the target calling code of the target component, it also includes: inputting the same input into the first calling code and the target calling code respectively to obtain the output of the first calling code and the output of the target calling code; when the output of the first calling code and the output of the target calling code are consistent, determining that the target calling code is correct.

具体的,以相同输入分别输入到第一调用代码和目标调用代码中,得到第一调用代码的输出和目标调用代码的输出,在第一调用代码的输出和目标调用代码的输出一致时,确定第一调用代码的计算结果和目标调用代码相同,确定目标调用代码正确。Specifically, the same input is input into the first calling code and the target calling code respectively to obtain the output of the first calling code and the output of the target calling code. When the output of the first calling code is consistent with the output of the target calling code, it is determined that the calculation result of the first calling code is the same as the target calling code, and the target calling code is determined to be correct.

在一个例子中,将a=1,b=2输入到第一调用代码和目标调用代码中,得到第一调用代码的输出为3,目标调用代码的输出为3。第一调用代码的输出和目标调用代码的输出一致,确定目标调用代码正确。In one example, a=1, b=2 are input into the first calling code and the target calling code, and the output of the first calling code is 3, and the output of the target calling code is 3. The output of the first calling code is consistent with the output of the target calling code, and it is determined that the target calling code is correct.

通过以相同输入分别输入到第一调用代码和目标调用代码中,得到第一调用代码的输出和目标调用代码的输出,在第一调用代码的输出和目标调用代码的输出一致时,确定目标调用代码正确,便于测试第一调用代码和目标调用代码的功能是否相同,可检测目标调用代码的准确性,提升了组件升级的准确性。By inputting the same input into the first calling code and the target calling code respectively, the output of the first calling code and the output of the target calling code are obtained. When the output of the first calling code and the output of the target calling code are consistent, it is determined that the target calling code is correct, which is convenient for testing whether the functions of the first calling code and the target calling code are the same, and the accuracy of the target calling code can be detected, thereby improving the accuracy of component upgrades.

实施例三Embodiment 3

图4为本发明实施例三提供的一种组件版本升级装置的结构示意图。本发明实施例可适用于对组件版本升级的情况,该装置可以执行组件版本升级方法,该装置可以采用硬件和/或软件的形式实现,该装置可配置于组件版本升级设备中。Figure 4 is a schematic diagram of the structure of a component version upgrade device provided in Embodiment 3 of the present invention. The embodiment of the present invention is applicable to the case of component version upgrade, the device can execute the component version upgrade method, the device can be implemented in the form of hardware and/or software, and the device can be configured in a component version upgrade device.

参见图4所示的组件版本升级装置,包括:组件信息获取模块401、节点更新模块402、代码生成模块403、更新信息获取模块404、比较结果获取模块405、适配器检测模块406、类型确定模块407和更新检测模块408。其中,Referring to the component version upgrade device shown in FIG4 , it includes: a component information acquisition module 401, a node update module 402, a code generation module 403, an update information acquisition module 404, a comparison result acquisition module 405, an adapter detection module 406, a type determination module 407 and an update detection module 408. Among them,

组件信息获取模块401,用于获取目标应用的待升级的目标组件,以及目标组件的目标版本号;The component information acquisition module 401 is used to acquire the target component to be upgraded of the target application and the target version number of the target component;

节点更新模块402,用于根据目标组件以及目标版本号生成目标组件的更新依赖配置,并在目标应用的项目文件中更新目标组件对应的节点;The node update module 402 is used to generate an update dependency configuration of the target component according to the target component and the target version number, and update the node corresponding to the target component in the project file of the target application;

代码生成模块403,用于根据目标组件以及目标版本号生成目标组件的更新调用代码;The code generation module 403 is used to generate the update calling code of the target component according to the target component and the target version number;

更新信息获取模块404,用于根据目标组件的更新调用代码,获取至少一个更新依赖类的更新信息;An update information acquisition module 404, used to acquire update information of at least one update dependent class according to the update calling code of the target component;

比较结果获取模块405,用于将各更新依赖类的更新信息与目标组件的相应适配器类进行比较,得到各更新依赖类的类比较结果;A comparison result acquisition module 405 is used to compare the update information of each update dependency class with the corresponding adapter class of the target component to obtain a class comparison result of each update dependency class;

适配器检测模块406,用于根据各更新依赖类的类比较结果,检测是否对目标组件的相应适配器类进行更新;The adapter detection module 406 is used to detect whether to update the corresponding adapter class of the target component according to the class comparison result of each update dependent class;

类型确定模块407,用于检测更新调用代码与目标组件的目标调用代码的差异,并确定差异类型;A type determination module 407, used to detect the difference between the update call code and the target call code of the target component, and determine the type of the difference;

更新检测模块408,用于根据差异和差异类型,检测是否对目标组件的目标调用代码进行更新。The update detection module 408 is used to detect whether to update the target calling code of the target component according to the difference and the difference type.

本发明实施例的技术方案,通过获取目标应用的待升级的目标组件,以及目标组件的目标版本号,生成目标组件的更新依赖配置,根据目标组件以及目标版本号生成目标组件的更新调用代码,获取至少一个更新依赖类的更新信息,将各更新依赖类的更新信息与目标组件的相应适配器类进行比较,得到各更新依赖类的类比较结果,检测是否对目标组件的相应适配器类进行更新,实现细粒度的类更新,细化了组件版本升级的操作,提升了组件版本升级的准确性,通过多维数据检测更新调用代码与目标组件的目标调用代码的差异,并确定差异类型,检测是否对目标组件的目标调用代码进行更新,可以针对不同的差异类型,判断是否进行更新,以及实现相应的更新操作,可以实现差异化更新,并且更新减少人为操作,降低更新的人工成本,提高了组件版本升级的效率。The technical solution of the embodiment of the present invention obtains the target component to be upgraded of the target application and the target version number of the target component, generates the update dependency configuration of the target component, generates the update calling code of the target component according to the target component and the target version number, obtains the update information of at least one update dependency class, compares the update information of each update dependency class with the corresponding adapter class of the target component, obtains the class comparison result of each update dependency class, detects whether to update the corresponding adapter class of the target component, implements fine-grained class update, refines the operation of component version upgrade, improves the accuracy of component version upgrade, detects the difference between the update calling code and the target calling code of the target component through multi-dimensional data, determines the difference type, detects whether to update the target calling code of the target component, can judge whether to update according to different difference types, and implements the corresponding update operation, can implement differentiated update, and reduces manual operation in the update, reduces the labor cost of the update, and improves the efficiency of the component version upgrade.

可选的,适配器检测模块406,具体用于:Optionally, the adapter detection module 406 is specifically configured to:

更新信息包括:类名、方法名和参数名;类比较结果包括类标识比较结果、方法标识比较结果和参数标识比较结果;根据各更新依赖类的类比较结果,检测各更新依赖类的标识变化数量;The update information includes: class name, method name and parameter name; the class comparison result includes class identification comparison result, method identification comparison result and parameter identification comparison result; according to the class comparison result of each update dependent class, the number of identification changes of each update dependent class is detected;

根据各更新依赖类的标识变化数量,确定各更新依赖类的变化类型;Determine the change type of each update dependency class according to the number of changes in the identification of each update dependency class;

针对各更新依赖类,在更新依赖类的变化类型为微小变化时,根据更新依赖类的更新调用代码,调整更新依赖类对应的适配器类中的参数;For each update dependency class, when the change type of the update dependency class is a minor change, according to the update calling code of the update dependency class, adjust the parameters in the adapter class corresponding to the update dependency class;

针对各更新依赖类,在更新依赖类的变化类型为中等变化时,根据更新依赖类的更新调用代码,生成新的适配器类,并替换更新依赖类对应的适配器类;For each update dependency class, when the change type of the update dependency class is a medium change, a new adapter class is generated according to the update call code of the update dependency class, and the adapter class corresponding to the update dependency class is replaced;

针对各更新依赖类,在更新依赖类的变化类型为重大变化时,生成目标组件的反编译代码,并根据更新依赖类的当前版本漏洞对编译代码进行修复。For each update dependency class, when the change type of the update dependency class is a major change, a decompiled code of the target component is generated, and the compiled code is repaired according to the current version vulnerability of the update dependency class.

可选的,更新检测模块408,具体用于:Optionally, the update detection module 408 is specifically used to:

在差异类型为方法删除时,在更新调用代码中提取更新方法传参;When the difference type is method deletion, extract the update method parameters in the update call code;

对各更新方法传参进行分类,得到各更新方法传参的参数类型;Classify the parameters passed by each update method to obtain the parameter type of each update method;

在更新调用代码中,为参数类型为非调用变量的更新方法传参建立相应变量,并将非调用变量的更新方法传参的参数值赋值给相应变量;In the update calling code, create corresponding variables for the update method whose parameter type is non-calling variables, and assign the parameter value of the update method of non-calling variables to the corresponding variables;

将相应变量替换并插入非调用变量的更新方法传参的位置处;Replace and insert the corresponding variable into the position where the update method of the non-calling variable passes the parameter;

在更新调用代码中,添加各适配器类对应的包标识和类标识的引用代码,得到新的代码,并替换目标组件的目标调用代码。In the update calling code, add the reference code of the package identifier and class identifier corresponding to each adapter class to obtain the new code, and replace the target calling code of the target component.

可选的,更新检测模块408,包括:Optionally, update detection module 408 includes:

代码调用单元,用于在差异类型为方法增加时,根据差异中至少一个新增的参数,生成调用目标组件的目标调用代码的备选代码;A code calling unit, for generating an alternative code for a target calling code of a calling target component according to at least one newly added parameter in the difference when the difference type is a method addition;

参数赋值单元,用于在备选代码中,将各新增的参数赋值为空;A parameter assignment unit, used to assign each newly added parameter to be empty in the alternative code;

输出数据获取单元,用于将以相同输入分别备选代码和目标调用代码中,得到备选代码的输出和目标调用代码的输出;An output data acquisition unit, used to obtain the output of the candidate code and the output of the target calling code by using the same input respectively;

测试结果获取单元,用于将备选代码的输出和目标调用代码的输出进行比较,得到单元测试结果;A test result acquisition unit, used to compare the output of the candidate code with the output of the target calling code to obtain a unit test result;

第一代码操作单元,用于在单元测试结果为一致时,不对目标组件的目标调用代码进行更新;A first code operation unit, configured to not update a target calling code of a target component when a unit test result is consistent;

第二代码操作单元,用于在单元测试结果为不一致时,检测各新增的参数是否存在相同意图的目标参数;The second code operation unit is used to detect whether each newly added parameter has a target parameter with the same intention when the unit test result is inconsistent;

方法生成单元,用于在不存在相同意图的目标参数时,在目标调用代码中,根据各新增的参数的参数类型,生成各新增的参数对应的更新方法传参;A method generation unit, used for generating, in the target calling code, an update method parameter transmission corresponding to each newly added parameter according to the parameter type of each newly added parameter when there is no target parameter with the same intention;

数据插入单元,用于在目标调用代码中,为参数类型为非调用变量的更新方法传参建立相应变量,并将非调用变量的更新方法传参的参数值赋值给相应变量,以及将相应变量替换并插入非调用变量的更新方法传参的位置处;A data insertion unit is used to establish a corresponding variable for the update method parameter of the non-calling variable in the target calling code, assign the parameter value of the update method parameter of the non-calling variable to the corresponding variable, and replace and insert the corresponding variable at the position of the update method parameter of the non-calling variable;

代码替换单元,用于在存在相同意图的目标参数时,在更新调用代码中采用目标参数的变量对新增的参数进行替换,并替换目标调用代码。The code replacement unit is used to replace the newly added parameters with the variables of the target parameters in the update calling code when there are target parameters with the same intention, and replace the target calling code.

可选的,第二代码操作单元,具体用于:Optionally, the second code operation unit is specifically used to:

在项目代码中,查询是否存在与各新增的参数的参数类型相同的目标参数;和/或In the project code, check whether there is a target parameter with the same parameter type as each newly added parameter; and/or

获取目标组件的升级数据包,以及目标组件的当前数据包;Obtain the upgrade data package of the target component and the current data package of the target component;

检测目标组件的升级数据包与当前数据包,检测各新增的参数是否存在相同调用链的目标参数。Check the upgrade data package and current data package of the target component, and check whether each newly added parameter has the target parameter of the same call chain.

可选的,组件版本升级装置,还包括:Optionally, the component version upgrading device further includes:

目标信息获取模块,用于在获取目标应用的待升级的目标组件,以及目标组件的目标版本号之前,获取需要自动升级的目标组件和当前版本号;A target information acquisition module is used to acquire a target component to be automatically upgraded and a current version number before acquiring a target component to be upgraded of a target application and a target version number of the target component;

节点更新模块,用于根据目标组件以及当前版本号生成目标组件的当前依赖配置,并在目标应用的项目文件中更新目标组件对应的节点;A node update module is used to generate the current dependency configuration of the target component according to the target component and the current version number, and update the node corresponding to the target component in the project file of the target application;

调用代码生成模块,用于根据目标组件以及当前版本号生成目标组件的第一调用代码;A calling code generation module, used to generate a first calling code of a target component according to the target component and the current version number;

当前信息获取模块,用于根据目标组件的第一调用代码,获取至少一个当前依赖类的当前信息;A current information acquisition module, used to acquire current information of at least one current dependent class according to a first calling code of the target component;

类创建模块,用于根据各依赖类的当前信息,在项目文件中创建各当前依赖类对应的适配器类,当前依赖类对应的适配器类继承当前依赖类;The class creation module is used to create the adapter class corresponding to each current dependent class in the project file according to the current information of each dependent class. The adapter class corresponding to the current dependent class inherits the current dependent class.

关系建立模块,用于在项目文件中建立项目文件与各当前依赖类的当前信息的对应关系;A relationship building module is used to establish a corresponding relationship between the project file and the current information of each current dependent class in the project file;

代码调整模块,用于在第一调用代码中提取当前方法传参,并根据当前方法传参对第一调用代码进行调整,得到第二调用代码;A code adjustment module is used to extract the current method parameters in the first calling code, and adjust the first calling code according to the current method parameters to obtain a second calling code;

标识添加模块,用于在第二调用代码中,添加各当前适配器类对应的包标识和类标识的引用代码,得到目标组件的目标调用代码。The identification adding module is used to add the reference code of the package identification and class identification corresponding to each current adapter class in the second calling code to obtain the target calling code of the target component.

可选的,组件版本升级装置,还包括:Optionally, the component version upgrading device further includes:

输出信息获取模块,用于在得到目标组件的目标调用代码之后,以相同输入分别输入到第一调用代码和目标调用代码中,得到第一调用代码的输出和目标调用代码的输出;An output information acquisition module is used to input the same input into the first calling code and the target calling code respectively after obtaining the target calling code of the target component, so as to obtain the output of the first calling code and the output of the target calling code;

代码确定模块,用于在第一调用代码的输出和目标调用代码的输出一致时,确定目标调用代码正确。The code determination module is used to determine that the target calling code is correct when the output of the first calling code is consistent with the output of the target calling code.

本发明实施例的技术方案中,所涉及的目标组件等的获取、存储和应用等,均符合相关法律法规的规定,且不违背公序良俗。In the technical solution of the embodiment of the present invention, the acquisition, storage and application of the target components involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

实施例四Embodiment 4

图5示出了可以用来实施本发明的实施例的组件版本升级设备500的结构示意图。组件版本升级设备旨在表示各种形式的数字计算机,诸如,膝上型计算机、台式计算机、工作台、个人数字助理、服务器、刀片式服务器、大型计算机、和其它适合的计算机。电子设备还可以表示各种形式的移动装置,诸如,个人数字处理、蜂窝电话、智能电话、可穿戴设备(如头盔、眼镜、手表等)和其它类似的计算装置。本文所示的部件、它们的连接和关系、以及它们的功能仅仅作为示例,并且不意在限制本文中描述的和/或者要求的本发明的实现。FIG5 shows a schematic diagram of a component version upgrade device 500 that can be used to implement an embodiment of the present invention. The component version upgrade device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and/or required herein.

如图5所示,组件版本升级设备500包括至少一个处理器501,以及与至少一个处理器501通信连接的存储器,如只读存储器(ROM)502、随机访问存储器(RAM)503等,其中,存储器存储有可被至少一个处理器执行的计算机程序,处理器501可以根据存储在只读存储器(ROM)502中的计算机程序或者从存储单元508加载到随机访问存储器(RAM)503中的计算机程序,来执行各种适当的动作和处理。在RAM 503中,还可存储组件版本升级设备500操作所需的各种程序和数据。处理器501、ROM 502以及RAM 503通过总线504彼此相连。输入/输出(I/O)接口505也连接至总线504。As shown in FIG5 , the component version upgrade device 500 includes at least one processor 501, and a memory connected to the at least one processor 501 in communication, such as a read-only memory (ROM) 502, a random access memory (RAM) 503, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 501 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 502 or the computer program loaded from the storage unit 508 to the random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the component version upgrade device 500 can also be stored. The processor 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to the bus 504.

组件版本升级设备500中的多个部件连接至I/O接口505,包括:输入单元506,例如键盘、鼠标等;输出单元507,例如各种类型的显示器、扬声器等;存储单元508,例如磁盘、光盘等;以及通信单元509,例如网卡、调制解调器、无线通信收发机等。通信单元509允许组件版本升级设备500通过诸如因特网的计算机网络和/或各种电信网络与其他设备交换信息/数据。Multiple components in the component version upgrade device 500 are connected to the I/O interface 505, including: an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a disk, an optical disk, etc.; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 509 allows the component version upgrade device 500 to exchange information/data with other devices through a computer network such as the Internet and/or various telecommunication networks.

处理器501可以是各种具有处理和计算能力的通用和/或专用处理组件。处理器501的一些示例包括但不限于中央处理单元(CPU)、图形处理单元(GPU)、各种专用的人工智能(AI)计算芯片、各种运行机器学习模型算法的处理器、数字信号处理器(DSP)、以及任何适当的处理器、控制器、微控制器等。处理器501执行上文所描述的各个方法和处理,例如组件版本升级方法。The processor 501 may be a variety of general and/or special processing components with processing and computing capabilities. Some examples of the processor 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 501 executes the various methods and processes described above, such as a component version upgrade method.

在一些实施例中,组件版本升级方法可被实现为计算机程序,其被有形地包含于计算机可读存储介质,例如存储单元508。在一些实施例中,计算机程序的部分或者全部可以经由ROM 502和/或通信单元509而被载入和/或安装到组件版本升级设备500上。当计算机程序加载到RAM 503并由处理器501执行时,可以执行上文描述的组件版本升级方法的一个或多个步骤。备选地,在其他实施例中,处理器501可以通过其他任何适当的方式(例如,借助于固件)而被配置为执行组件版本升级方法。In some embodiments, the component version upgrade method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 508. In some embodiments, part or all of the computer program may be loaded and/or installed on the component version upgrade device 500 via the ROM 502 and/or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the processor 501, one or more steps of the component version upgrade method described above may be performed. Alternatively, in other embodiments, the processor 501 may be configured to execute the component version upgrade method in any other appropriate manner (e.g., by means of firmware).

本文中以上描述的系统和技术的各种实施方式可以在数字电子电路系统、集成电路系统、现场可编程门阵列(FPGA)、专用集成电路(ASIC)、专用标准产品(ASSP)、芯片上系统的系统(SOC)、复杂可编程逻辑设备(CPLD)、计算机硬件、固件、软件、和/或它们的组合中实现。这些各种实施方式可以包括:实施在一个或者多个计算机程序中,该一个或者多个计算机程序可在包括至少一个可编程处理器的可编程系统上执行和/或解释,该可编程处理器可以是专用或者通用可编程处理器,可以从存储系统、至少一个输入装置、和至少一个输出装置接收数据和指令,并且将数据和指令传输至该存储系统、该至少一个输入装置、和该至少一个输出装置。Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and/or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

用于实施本发明的方法的计算机程序可以采用一个或多个编程语言的任何组合来编写。这些计算机程序可以提供给通用计算机、专用计算机或其他可编程数据处理装置的处理器,使得计算机程序当由处理器执行时使流程图和/或框图中所规定的功能/操作被实施。计算机程序可以完全在机器上执行、部分地在机器上执行,作为独立软件包部分地在机器上执行且部分地在远程机器上执行或完全在远程机器或服务器上执行。Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions/operations specified in the flow chart and/or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

在本发明的上下文中,计算机可读存储介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、装置或设备结合地使用的计算机程序。计算机可读存储介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的、或半导体系统、装置或设备,或者上述内容的任何合适组合。备选地,计算机可读存储介质可以是机器可读信号介质。机器可读存储介质的更具体示例会包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM或快闪存储器)、光纤、便捷式紧凑盘只读存储器(CD-ROM)、光学储存设备、磁储存设备、或上述内容的任何合适组合。In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

为了提供与用户的交互,可以在组件版本升级设备上实施此处描述的系统和技术,该组件版本升级设备具有:用于向用户显示信息的显示装置(例如,CRT(阴极射线管)或者LCD(液晶显示器)监视器);以及键盘和指向装置(例如,鼠标或者轨迹球),用户可以通过该键盘和该指向装置来将输入提供给组件版本升级设备。其它种类的装置还可以用于提供与用户的交互;例如,提供给用户的反馈可以是任何形式的传感反馈(例如,视觉反馈、听觉反馈、或者触觉反馈);并且可以用任何形式(包括声输入、语音输入或者、触觉输入)来接收来自用户的输入。To provide interaction with a user, the systems and techniques described herein may be implemented on a component version upgrade device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which a user can provide input to the component version upgrade device. Other types of devices may also be used to provide interaction with a user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

可以将此处描述的系统和技术实施在包括后台部件的计算系统(例如,作为数据服务器)、或者包括中间件部件的计算系统(例如,应用服务器)、或者包括前端部件的计算系统(例如,具有图形用户界面或者网络浏览器的用户计算机,用户可以通过该图形用户界面或者该网络浏览器来与此处描述的系统和技术的实施方式交互)、或者包括这种后台部件、中间件部件、或者前端部件的任何组合的计算系统中。可以通过任何形式或者介质的数字数据通信(例如,通信网络)来将系统的部件相互连接。通信网络的示例包括:局域网(LAN)、广域网(WAN)、区块链网络和互联网。The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

计算系统可以包括客户端和服务器。客户端和服务器一般远离彼此并且通常通过通信网络进行交互。通过在相应的计算机上运行并且彼此具有客户端-服务器关系的计算机程序来产生客户端和服务器的关系。服务器可以是云服务器,又称为云计算服务器或云主机,是云计算服务体系中的一项主机产品,以解决了传统物理主机与VPS(VirtualPrivate Server,虚拟专用服务器)服务中,存在的管理难度大,业务扩展性弱的缺陷。A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS (Virtual Private Server) services.

应该理解,可以使用上面所示的各种形式的流程,重新排序、增加或删除步骤。例如,本发明中记载的各步骤可以并行地执行也可以顺序地执行也可以不同的次序执行,只要能够实现本发明的技术方案所期望的结果,本文在此不进行限制。It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

上述具体实施方式,并不构成对本发明保护范围的限制。本领域技术人员应该明白的是,根据设计要求和其他因素,可以进行各种修改、组合、子组合和替代。任何在本发明的精神和原则之内所作的修改、等同替换和改进等,均应包含在本发明保护范围之内。The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (9)

1.一种组件版本升级方法,其特征在于,所述方法包括:1. A component version upgrade method, characterized in that the method comprises: 获取目标应用的待升级的目标组件,以及所述目标组件的目标版本号;Obtaining a target component to be upgraded of a target application and a target version number of the target component; 根据所述目标组件以及所述目标版本号生成所述目标组件的更新依赖配置,并在所述目标应用的项目文件中更新所述目标组件对应的节点;Generate an update dependency configuration of the target component according to the target component and the target version number, and update a node corresponding to the target component in the project file of the target application; 根据所述目标组件以及所述目标版本号生成所述目标组件的更新调用代码;Generate an update calling code for the target component according to the target component and the target version number; 根据所述目标组件的更新调用代码,获取至少一个更新依赖类的更新信息;Acquire update information of at least one update-dependent class according to the update calling code of the target component; 将各所述更新依赖类的更新信息与所述目标组件的相应适配器类进行比较,得到各所述更新依赖类的类比较结果;Compare the update information of each update-dependent class with the corresponding adapter class of the target component to obtain a class comparison result of each update-dependent class; 根据各所述更新依赖类的类比较结果,检测是否对所述目标组件的相应适配器类进行更新;According to the class comparison result of each update dependent class, detecting whether to update the corresponding adapter class of the target component; 检测所述更新调用代码与所述目标组件的目标调用代码的差异,并确定差异类型;Detecting a difference between the update calling code and the target calling code of the target component, and determining a difference type; 根据所述差异和所述差异类型,检测是否对所述目标组件的目标调用代码进行更新;According to the difference and the difference type, detecting whether to update the target calling code of the target component; 所述更新信息包括:类名、方法名和参数名;所述类比较结果包括类标识比较结果、方法标识比较结果和参数标识比较结果;The update information includes: class name, method name and parameter name; the class comparison result includes class identification comparison result, method identification comparison result and parameter identification comparison result; 所述根据各所述更新依赖类的类比较结果,检测是否对所述目标组件的相应适配器类进行更新,包括:The step of detecting whether to update the corresponding adapter class of the target component according to the class comparison result of each update dependent class includes: 根据各所述更新依赖类的类比较结果,检测各所述更新依赖类的标识变化数量;According to the class comparison result of each update-dependent class, detecting the number of changes in the identification of each update-dependent class; 根据各所述更新依赖类的标识变化数量,确定各所述更新依赖类的变化类型;Determining the change type of each update dependency class according to the number of changes in the identification of each update dependency class; 针对各所述更新依赖类,在所述更新依赖类的变化类型为微小变化时,根据所述更新依赖类的更新调用代码,调整所述更新依赖类对应的适配器类中的参数;For each of the update dependency classes, when the change type of the update dependency class is a minor change, adjusting the parameters in the adapter class corresponding to the update dependency class according to the update calling code of the update dependency class; 针对各所述更新依赖类,在所述更新依赖类的变化类型为中等变化时,根据所述更新依赖类的更新调用代码,生成新的适配器类,并替换所述更新依赖类对应的适配器类;For each of the update dependency classes, when the change type of the update dependency class is a medium change, a new adapter class is generated according to the update calling code of the update dependency class, and the adapter class corresponding to the update dependency class is replaced; 针对各所述更新依赖类,在所述更新依赖类的变化类型为重大变化时,生成所述目标组件的反编译代码,并根据所述更新依赖类的当前版本漏洞对所述编译代码进行修复。For each of the update dependency classes, when the change type of the update dependency class is a major change, a decompiled code of the target component is generated, and the compiled code is repaired according to a current version vulnerability of the update dependency class. 2.根据权利要求1所述的方法,其特征在于,所述根据所述差异和所述差异类型,检测是否对所述目标组件的目标调用代码进行更新,包括:2. The method according to claim 1, characterized in that the detecting whether to update the target calling code of the target component according to the difference and the difference type comprises: 在所述差异类型为方法删除时,在所述更新调用代码中提取更新方法传参;When the difference type is method deletion, extracting update method parameters in the update calling code; 对各所述更新方法传参进行分类,得到各所述更新方法传参的参数类型;Classifying the parameters passed by each of the update methods to obtain the parameter type of each of the update methods; 在所述更新调用代码中,为参数类型为非调用变量的更新方法传参建立相应变量,并将所述非调用变量的更新方法传参的参数值赋值给所述相应变量;In the update calling code, a corresponding variable is established for the update method parameter passing whose parameter type is a non-calling variable, and the parameter value of the update method parameter passing of the non-calling variable is assigned to the corresponding variable; 将所述相应变量替换并插入所述非调用变量的更新方法传参的位置处;The corresponding variable is replaced and inserted into the position where the update method of the non-calling variable passes the parameter; 在所述更新调用代码中,添加各所述适配器类对应的包标识和类标识的引用信息,得到新的代码,并替换所述目标组件的目标调用代码。In the update calling code, reference information of the package identifier and class identifier corresponding to each adapter class is added to obtain a new code, and the target calling code of the target component is replaced. 3.根据权利要求1所述的方法,其特征在于,所述根据所述差异和所述差异类型,检测是否对所述目标组件的目标调用代码进行更新,包括:3. The method according to claim 1, characterized in that the detecting whether to update the target calling code of the target component according to the difference and the difference type comprises: 在所述差异类型为方法增加时,根据所述差异中至少一个新增的参数,生成调用所述目标组件的目标调用代码的备选代码;When the difference type is method addition, generating an alternative code for a target calling code for calling the target component according to at least one newly added parameter in the difference; 在所述备选代码中,将各所述新增的参数赋值为空;In the alternative code, each of the newly added parameters is assigned a value of null; 将以相同输入分别所述备选代码和所述目标调用代码中,得到所述备选代码的输出和所述目标调用代码的输出;Using the same input to the candidate code and the target calling code respectively, to obtain the output of the candidate code and the output of the target calling code; 将所述备选代码的输出和所述目标调用代码的输出进行比较,得到单元测试结果;Compare the output of the candidate code with the output of the target calling code to obtain a unit test result; 在所述单元测试结果为一致时,不对所述目标组件的目标调用代码进行更新;When the unit test results are consistent, the target calling code of the target component is not updated; 在所述单元测试结果为不一致时,检测各所述新增的参数是否存在相同意图的目标参数;When the unit test results are inconsistent, detecting whether each of the newly added parameters has a target parameter with the same intention; 在所述新增的参数不存在相同意图的目标参数时,在所述目标调用代码中,根据所述新增的参数的参数类型,生成所述新增的参数对应的更新方法传参;When the newly added parameter does not have a target parameter with the same intention, in the target calling code, an update method parameter corresponding to the newly added parameter is generated according to the parameter type of the newly added parameter; 在所述目标调用代码中,为参数类型为非调用变量的更新方法传参建立相应变量,并将所述非调用变量的更新方法传参的参数值赋值给所述相应变量,以及将所述相应变量替换并插入所述非调用变量的更新方法传参的位置处;In the target calling code, a corresponding variable is established for the update method parameter passing of the non-calling variable whose parameter type is a non-calling variable, and the parameter value of the update method parameter passing of the non-calling variable is assigned to the corresponding variable, and the corresponding variable is replaced and inserted into the position of the update method parameter passing of the non-calling variable; 在所述新增的参数存在相同意图的目标参数时,在所述更新调用代码中采用所述目标参数的变量对所述新增的参数进行替换,并替换所述目标调用代码。When the newly added parameter has a target parameter with the same intention, the newly added parameter is replaced by a variable of the target parameter in the update calling code, and the target calling code is replaced. 4. 根据权利要求3所述的方法,其特征在于,检测各所述新增的参数是否存在相同意图的目标参数,包括:4. The method according to claim 3, characterized in that detecting whether each of the newly added parameters has a target parameter with the same intention comprises: 在项目代码中,查询是否存在与各所述新增的参数的参数类型相同的目标参数;和/或In the project code, query whether there is a target parameter of the same parameter type as each of the newly added parameters; and/or 获取所述目标组件的升级数据包,以及所述目标组件的当前数据包;Acquire an upgrade data packet of the target component and a current data packet of the target component; 检测所述目标组件的升级数据包与所述当前数据包,检测各所述新增的参数是否存在相同调用链的目标参数。The upgraded data packet of the target component and the current data packet are detected, and whether each of the newly added parameters has a target parameter of the same call chain. 5.根据权利要求1所述的方法,其特征在于,在获取目标应用的待升级的目标组件,以及所述目标组件的目标版本号之前,还包括:5. The method according to claim 1, characterized in that before obtaining the target component to be upgraded of the target application and the target version number of the target component, it also includes: 获取需要自动升级的所述目标组件和当前版本号;Obtain the target component that needs to be automatically upgraded and the current version number; 根据所述目标组件以及所述当前版本号生成所述目标组件的当前依赖配置,并在所述目标应用的项目文件中更新所述目标组件对应的节点;Generate a current dependency configuration of the target component according to the target component and the current version number, and update a node corresponding to the target component in a project file of the target application; 根据所述目标组件以及所述当前版本号生成所述目标组件的第一调用代码;Generate a first calling code of the target component according to the target component and the current version number; 根据所述目标组件的第一调用代码,获取至少一个当前依赖类的当前信息;According to the first calling code of the target component, obtaining current information of at least one current dependent class; 根据各所述依赖类的当前信息,在所述项目文件中创建各所述当前依赖类对应的适配器类,所述当前依赖类对应的适配器类继承所述当前依赖类;According to the current information of each dependent class, an adapter class corresponding to each current dependent class is created in the project file, and the adapter class corresponding to the current dependent class inherits the current dependent class; 在所述项目文件中建立所述项目文件与各所述当前依赖类的当前信息的对应关系;Establishing a correspondence between the project file and the current information of each of the current dependent classes in the project file; 在所述第一调用代码中提取当前方法传参,并根据所述当前方法传参对所述第一调用代码进行调整,得到第二调用代码;Extracting the current method parameter from the first calling code, and adjusting the first calling code according to the current method parameter to obtain a second calling code; 在所述第二调用代码中,添加各当前适配器类对应的包标识和类标识的引用代码,得到所述目标组件的目标调用代码。In the second calling code, reference codes of the package identifier and class identifier corresponding to each current adapter class are added to obtain the target calling code of the target component. 6.根据权利要求5所述的方法,其特征在于,在得到所述目标组件的目标调用代码之后,还包括:6. The method according to claim 5, characterized in that after obtaining the target calling code of the target component, it also includes: 以相同输入分别输入到所述第一调用代码和所述目标调用代码中,得到所述第一调用代码的输出和所述目标调用代码的输出;Input the same input into the first calling code and the target calling code respectively, to obtain the output of the first calling code and the output of the target calling code; 在所述第一调用代码的输出和所述目标调用代码的输出一致时,确定所述目标调用代码正确。When the output of the first calling code is consistent with the output of the target calling code, it is determined that the target calling code is correct. 7.一种组件版本升级装置,其特征在于,所述装置包括:7. A component version upgrade device, characterized in that the device comprises: 组件信息获取模块,用于获取目标应用的待升级的目标组件,以及所述目标组件的目标版本号;A component information acquisition module, used to acquire a target component to be upgraded of a target application and a target version number of the target component; 节点更新模块,用于根据所述目标组件以及所述目标版本号生成所述目标组件的更新依赖配置,并在所述目标应用的项目文件中更新所述目标组件对应的节点;A node update module, used to generate an update dependency configuration of the target component according to the target component and the target version number, and update a node corresponding to the target component in a project file of the target application; 代码生成模块,用于根据所述目标组件以及所述目标版本号生成所述目标组件的更新调用代码;A code generation module, used to generate an update calling code of the target component according to the target component and the target version number; 更新信息获取模块,用于根据所述目标组件的更新调用代码,获取至少一个更新依赖类的更新信息;An update information acquisition module, used to acquire update information of at least one update dependency class according to the update calling code of the target component; 比较结果获取模块,用于将各所述更新依赖类的更新信息与所述目标组件的相应适配器类进行比较,得到各所述更新依赖类的类比较结果;A comparison result acquisition module, used for comparing the update information of each update-dependent class with the corresponding adapter class of the target component to obtain a class comparison result of each update-dependent class; 适配器检测模块,用于根据各所述更新依赖类的类比较结果,检测是否对所述目标组件的相应适配器类进行更新;An adapter detection module, used to detect whether to update the corresponding adapter class of the target component according to the class comparison result of each update dependent class; 类型确定模块,用于检测所述更新调用代码与所述目标组件的目标调用代码的差异,并确定差异类型;A type determination module, used to detect the difference between the update calling code and the target calling code of the target component, and determine the type of the difference; 更新检测模块,用于根据所述差异和所述差异类型,检测是否对所述目标组件的目标调用代码进行更新;An update detection module, used for detecting whether to update the target calling code of the target component according to the difference and the difference type; 所述适配器检测模块,具体用于:The adapter detection module is specifically used for: 更新信息包括:类名、方法名和参数名;类比较结果包括类标识比较结果、方法标识比较结果和参数标识比较结果;根据各更新依赖类的类比较结果,检测各更新依赖类的标识变化数量;The update information includes: class name, method name and parameter name; the class comparison result includes class identification comparison result, method identification comparison result and parameter identification comparison result; according to the class comparison result of each update dependent class, the number of identification changes of each update dependent class is detected; 根据各更新依赖类的标识变化数量,确定各更新依赖类的变化类型;Determine the change type of each update dependency class according to the number of changes in the identification of each update dependency class; 针对各更新依赖类,在更新依赖类的变化类型为微小变化时,根据更新依赖类的更新调用代码,调整更新依赖类对应的适配器类中的参数;For each update dependency class, when the change type of the update dependency class is a minor change, according to the update calling code of the update dependency class, adjust the parameters in the adapter class corresponding to the update dependency class; 针对各更新依赖类,在更新依赖类的变化类型为中等变化时,根据更新依赖类的更新调用代码,生成新的适配器类,并替换更新依赖类对应的适配器类;For each update dependency class, when the change type of the update dependency class is a medium change, a new adapter class is generated according to the update call code of the update dependency class, and the adapter class corresponding to the update dependency class is replaced; 针对各更新依赖类,在更新依赖类的变化类型为重大变化时,生成目标组件的反编译代码,并根据更新依赖类的当前版本漏洞对编译代码进行修复。For each update dependency class, when the change type of the update dependency class is a major change, a decompiled code of the target component is generated, and the compiled code is repaired according to the current version vulnerability of the update dependency class. 8. 一种组件版本升级设备,其特征在于,所述组件版本升级设备包括:8. A component version upgrade device, characterized in that the component version upgrade device comprises: 至少一个处理器;以及at least one processor; and 与所述至少一个处理器通信连接的存储器;其中,a memory communicatively connected to the at least one processor; wherein, 所述存储器存储有可被所述至少一个处理器执行的计算机程序,所述计算机程序被所述至少一个处理器执行,以使所述至少一个处理器能够执行权利要求1-6中任一项所述的组件版本升级方法。The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the component version upgrade method according to any one of claims 1 to 6. 9.一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机指令,所述计算机指令用于使处理器执行时实现权利要求1-6中任一项所述的组件版本升级方法。9. A computer-readable storage medium, characterized in that the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the component version upgrade method according to any one of claims 1 to 6 when executed.
CN202411046666.0A 2024-08-01 2024-08-01 Component version upgrading method, device, equipment and medium Active CN118567699B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411046666.0A CN118567699B (en) 2024-08-01 2024-08-01 Component version upgrading method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411046666.0A CN118567699B (en) 2024-08-01 2024-08-01 Component version upgrading method, device, equipment and medium

Publications (2)

Publication Number Publication Date
CN118567699A CN118567699A (en) 2024-08-30
CN118567699B true CN118567699B (en) 2024-11-05

Family

ID=92478673

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411046666.0A Active CN118567699B (en) 2024-08-01 2024-08-01 Component version upgrading method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN118567699B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108572834A (en) * 2018-04-16 2018-09-25 腾讯科技(深圳)有限公司 A kind of upgrade method and device of browser
CN109739526A (en) * 2017-10-30 2019-05-10 北京京东尚科信息技术有限公司 Code update method and device

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5854932A (en) * 1995-08-17 1998-12-29 Microsoft Corporation Compiler and method for avoiding unnecessary recompilation
US6442753B1 (en) * 1997-08-28 2002-08-27 International Business Machines Corporation Apparatus and method for checking dependencies among classes in an object-oriented program
US7644402B1 (en) * 2004-03-17 2010-01-05 Sun Microsystems, Inc. Method for sharing runtime representation of software components across component loaders
CN110597531B (en) * 2019-08-05 2022-11-08 平安科技(深圳)有限公司 Distributed module upgrading method and device and storage medium
CN111625839A (en) * 2020-05-29 2020-09-04 深圳前海微众银行股份有限公司 Third-party component vulnerability detection method, device, equipment and computer storage medium
CN112306716A (en) * 2020-11-05 2021-02-02 中国平安财产保险股份有限公司 Message reminding method and related equipment
CN114721688A (en) * 2022-04-20 2022-07-08 北京字跳网络技术有限公司 SDK upgrading method and device and computer equipment
CN115291935A (en) * 2022-08-09 2022-11-04 中国平安人寿保险股份有限公司 Component updating method, component updating device, equipment and storage medium
CN115599436A (en) * 2022-10-20 2023-01-13 深圳万物安全科技有限公司(Cn) Information processing method, device, equipment and computer readable storage medium
CN117251189A (en) * 2023-09-22 2023-12-19 腾讯科技(深圳)有限公司 Script program upgrading method, script program upgrading device, computer equipment and storage medium
CN117493169A (en) * 2023-10-10 2024-02-02 浙江大学 A method, device, equipment and medium for detecting API behavior incompatibility between Java dependency library versions

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109739526A (en) * 2017-10-30 2019-05-10 北京京东尚科信息技术有限公司 Code update method and device
CN108572834A (en) * 2018-04-16 2018-09-25 腾讯科技(深圳)有限公司 A kind of upgrade method and device of browser

Also Published As

Publication number Publication date
CN118567699A (en) 2024-08-30

Similar Documents

Publication Publication Date Title
CN107688748B (en) Fragility Code Clones detection method and its device based on loophole fingerprint
CN111931181B (en) Software logic vulnerability detection method based on graph mining
CN115827487A (en) Knowledge graph construction and query method, device, equipment, storage medium and product
CN112860265A (en) Method and device for detecting operation abnormity of source code database
US11693635B1 (en) Automatic code reconfiguration based on function and subfunction analysis
CN115391785A (en) Method, device and equipment for detecting risks of software bugs
CN118567699B (en) Component version upgrading method, device, equipment and medium
US12147792B2 (en) Shrinking files based on function analysis
US12141577B2 (en) Symbol-matching between software versions
US20240231811A9 (en) Shrinking delta files based on function analysis
CN112948264A (en) Test task execution method, device, system, storage medium and electronic device
CN103559127A (en) Defect processing method and defect processor
US10540157B2 (en) Systems to remove object relational mappings from a software project
CN117389518A (en) Fine-grained software supply chain construction method for Python open source ecology
Nguyen et al. Interaction-based tracking of program entities for test case evolution
Nguyen et al. Using topic model to suggest fine-grained source code changes
CN115270136A (en) Binary group-based vulnerability clone detection system and method
WO2022047623A1 (en) Software information organization method and device, and computer-readable medium
US20230214506A1 (en) Auto generating build time policies from run time policies for shift left security
US11941380B1 (en) Automatic code reconfiguration based on function and subfunction analysis
CN118502814B (en) Software modification evaluation method, device, equipment and medium based on byte codes
CN118069507B (en) Regression testing quality assessment method and device based on code knowledge graph
US20250028514A1 (en) Automatic self-adapting application deployment for cloud applications
Wang et al. Automatic mapping of configuration options in software using static analysis
CN119150286A (en) Invalid API detection method and device, electronic equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20240830

Assignee: Hangzhou Haolian Intelligent Technology Co.,Ltd.

Assignor: Hangzhou new China and the big Polytron Technologies Inc.

Contract record no.: X2024980042943

Denomination of invention: A method, device, equipment, and medium for upgrading component versions

Granted publication date: 20241105

License type: Common License

Record date: 20241231

EE01 Entry into force of recordation of patent licensing contract