Abnormal code positioning method and device, computer device and readable storage medium
By acquiring target scenario data and mapping relationships of web applications, abnormal code blocks on web pages can be located, solving the problem of low timeliness in anomaly detection in web applications and enabling rapid location and maintenance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- IND BANK CO
- Filing Date
- 2023-04-14
- Publication Date
- 2026-06-23
AI Technical Summary
When page display errors occur in web applications, it is difficult to quickly locate the problem, resulting in low timeliness of error detection, especially when no logs are printed to the console.
By acquiring target scenario data of the target web application, we test whether the web page is abnormal, obtain the web address, and use the mapping relationship between the web address and the source code block to locate and output the location of the abnormal code block, including scanning and comparing multiple target code blocks.
It improves the accuracy and timeliness of anomaly detection, enabling rapid location of code blocks that cause abnormal webpage display, thus preventing display anomalies in web applications.
Smart Images

Figure CN116501626B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to an exception code location method, apparatus, computer device, readable storage medium, and computer program product. Background Technology
[0002] Currently, in order to meet a user's certain business needs, it is necessary to integrate the page corresponding to the business needs into a JavaScript-based front-end web application so that the user can fulfill the business needs by accessing the web page in the web application.
[0003] However, when displaying web pages, abnormal page display may occur; however, since no logs are printed on the console provided by the web application, it is difficult to quickly locate the problem, which makes it impossible for maintenance personnel to know the cause of the abnormal page display, resulting in low timeliness of anomaly detection. Summary of the Invention
[0004] Therefore, it is necessary to provide an anomaly code localization method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can improve the timeliness of anomaly detection in response to the above-mentioned technical problems.
[0005] Firstly, this application provides a method for locating abnormal codes, the method comprising:
[0006] Obtain the target scenario data corresponding to the target service business to be integrated into the target web application;
[0007] When testing the target scenario data, and determining that the target webpage corresponding to the target service business is displayed abnormally in the target webpage application, the target webpage address of the target webpage is obtained from the target webpage application.
[0008] Based on the first target mapping relationship between web page address and source code block, obtain the source code block corresponding to the target web page address under the target service business;
[0009] Obtain multiple target code blocks corresponding to the source code block;
[0010] When an anomaly is detected in at least one of the plurality of target code blocks, an alarm message is output, the alarm message including the code location of the at least one code block.
[0011] In one embodiment, obtaining the source code block corresponding to the target webpage address under the target service business based on the first target mapping relationship between the webpage address and the source code block includes:
[0012] Based on the first target mapping relationship between web page addresses and source code blocks, when it is determined, according to the first target mapping relationship and the target web page address, that a source code block matching the target web page address corresponds to multiple web page addresses, a second target mapping relationship between the web page address, the routing address, and the source code block is obtained; the multiple web page addresses include the target web page address.
[0013] Based on the second target mapping relationship and the target webpage address, obtain the source code block corresponding to the target webpage address under the target service business.
[0014] In one embodiment, the method further includes:
[0015] When it is determined, based on the first target mapping relationship and the target webpage address, that the source code block matching the target webpage address does not correspond to a webpage address other than the target webpage address, the source code block corresponding to the target webpage address under the target service business is obtained based on the first target mapping relationship and the target webpage address.
[0016] In one embodiment, obtaining the source code block corresponding to the target webpage address under the target service business based on the first target mapping relationship between the webpage address and the source code block includes:
[0017] Obtain the first routing mapping relationship between the web page address and the route address, and the second routing mapping relationship between the route address and the source code block;
[0018] Based on the first routing mapping relationship and the second routing mapping relationship, a first target mapping relationship between the web page address and the source code block is obtained;
[0019] Based on the first target mapping relationship and the target webpage address, obtain the source code block corresponding to the target webpage address under the target service business.
[0020] In one embodiment, obtaining the multiple target code blocks corresponding to the source code block includes:
[0021] Based on preset code statements, find the code blocks associated with the source code block to obtain the plurality of target code blocks;
[0022] The detection of an anomaly in at least one of the plurality of target code blocks includes:
[0023] Scan each target code block line by line;
[0024] The scan result of each target code block is compared with a preset abnormal segment. If the scan result of at least one of the target code blocks matches the preset abnormal segment, it is determined that at least one of the target code blocks is abnormal.
[0025] In one embodiment, detecting an anomaly in at least one of the plurality of target code blocks includes:
[0026] The multiple target code blocks are tested based on the target scene data;
[0027] If the input data corresponding to the target scene data is inconsistent with the preset data input of the multiple target code blocks, it is determined that at least one of the multiple target code blocks is abnormal.
[0028] Secondly, this application provides an anomaly code location device, the device comprising:
[0029] The data acquisition module is used to acquire target scenario data corresponding to the target service business to be integrated into the target web application;
[0030] The webpage address acquisition module is used to acquire the target webpage address of the target webpage from the target webpage application when testing the target scenario data and determining that the target webpage corresponding to the target service business is displayed abnormally in the target webpage application.
[0031] The source code block acquisition module is used to obtain the source code block corresponding to the target webpage address under the target service business based on the first target mapping relationship between the webpage address and the source code block;
[0032] The target code block acquisition module is used to acquire multiple target code blocks corresponding to the source code block;
[0033] The alert module is used to output an alarm message when it is determined that at least one of the plurality of target code blocks has an anomaly. The alarm message includes the code location of the at least one code block.
[0034] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0035] Obtain the target scenario data corresponding to the target service business to be integrated into the target web application;
[0036] When testing the target scenario data, and determining that the target webpage corresponding to the target service business is displayed abnormally in the target webpage application, the target webpage address of the target webpage is obtained from the target webpage application.
[0037] Based on the first target mapping relationship between web page address and source code block, obtain the source code block corresponding to the target web page address under the target service business;
[0038] Obtain multiple target code blocks corresponding to the source code block;
[0039] When an anomaly is detected in at least one of the plurality of target code blocks, an alarm message is output, the alarm message including the code location of the at least one code block.
[0040] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0041] Obtain the target scenario data corresponding to the target service business to be integrated into the target web application;
[0042] When testing the target scenario data, and determining that the target webpage corresponding to the target service business is displayed abnormally in the target webpage application, the target webpage address of the target webpage is obtained from the target webpage application.
[0043] Based on the first target mapping relationship between web page address and source code block, obtain the source code block corresponding to the target web page address under the target service business;
[0044] Obtain multiple target code blocks corresponding to the source code block;
[0045] When an anomaly is detected in at least one of the plurality of target code blocks, an alarm message is output, the alarm message including the code location of the at least one code block.
[0046] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0047] Obtain the target scenario data corresponding to the target service business to be integrated into the target web application;
[0048] When testing the target scenario data, and determining that the target webpage corresponding to the target service business is displayed abnormally in the target webpage application, the target webpage address of the target webpage is obtained from the target webpage application.
[0049] Based on the first target mapping relationship between web page address and source code block, obtain the source code block corresponding to the target web page address under the target service business;
[0050] Obtain multiple target code blocks corresponding to the source code block;
[0051] When an anomaly is detected in at least one of the plurality of target code blocks, an alarm message is output, the alarm message including the code location of the at least one code block.
[0052] The aforementioned anomaly code localization method, apparatus, computer equipment, storage medium, and computer program product, by acquiring target scenario data corresponding to the target service business to be integrated into the target web application, enable testing of the target scenario data to determine whether the target web page corresponding to the target service business displays abnormally in the target web application after the target service business is integrated, thereby improving the availability of service business integration into the web application; when it is determined that the target web page corresponding to the target service business displays abnormally in the web application, the target web page address of the target web page is obtained from the target web application, thereby obtaining the target web page address where the web page displays abnormally, improving the accuracy of anomaly detection; furthermore, based on the first target mapping relationship between the web page address and the source code block, the target web page address corresponding to the target service business is obtained. When retrieving source code blocks and obtaining multiple target code blocks corresponding to those blocks, the system detects at least one target code block. If an anomaly is detected in at least one of the target code blocks, an alarm is output, including the code location of at least one block. This allows for rapid identification of the code block causing the display anomaly, improving the timeliness of anomaly detection. Even if no logs are printed on the console provided by the web application, the code block causing the display anomaly has been maintained based on the target scenario data before the target service is integrated into the target web application. Therefore, display anomalies on the target web application can be avoided after the target service is integrated into the target web application. Attached Figure Description
[0053] Figure 1 This is a diagram illustrating the application environment of an exception code location method in one embodiment.
[0054] Figure 2 This is a flowchart illustrating an exception code location method in one embodiment;
[0055] Figure 3This is a flowchart illustrating the process of obtaining the source code block corresponding to the target webpage address under the target service business based on the first target mapping relationship between the webpage address and the source code block in one embodiment.
[0056] Figure 4 This is a flowchart illustrating the process of obtaining the source code block corresponding to the target webpage address under the target service business based on the first target mapping relationship between the webpage address and the source code block in another embodiment.
[0057] Figure 5 This is a flowchart illustrating the process of detecting an anomaly in at least one of a plurality of target code blocks in one embodiment.
[0058] Figure 6 This is a flowchart illustrating the process of detecting an anomaly in at least one of a plurality of target code blocks in another embodiment;
[0059] Figure 7 This is a flowchart illustrating the exception code location method in another embodiment;
[0060] Figure 8 This is a structural block diagram of an exception code locator in one embodiment;
[0061] Figure 9 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0062] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0063] The exception code location method provided in this application embodiment can be applied to, for example, Figure 1In the application environment shown, the abnormal code location system 100 includes a processor 102 and a target web application 104. A detection device 106 is connected to the target web application 104. Specifically, the processor 102 acquires target scene data corresponding to the target service business to be connected to the target web application. When the processor 102 tests the target scene data and determines that the target web page corresponding to the target service business is displaying abnormally in the target web application, the detection device 106 can detect the abnormality. Thus, the processor 102 can obtain the target web page address from the target web application. Furthermore, based on the first target mapping relationship between the web page address and the source code block, the processor 102 can obtain the source code block corresponding to the target web page address under the target service business. It also acquires multiple target code blocks corresponding to the source code block. When an abnormality is detected in at least one of the multiple target code blocks, an alarm message is output. The alarm message includes the code location of at least one code block, thereby achieving rapid location of the abnormal code block causing the web page to display abnormally.
[0064] In one embodiment, such as Figure 2 As shown, an exception code location method is provided, which can be applied to... Figure 1 Taking processor 102 as an example, the following steps are included:
[0065] S202, Obtain the target scenario data corresponding to the target service business to be integrated into the target web application.
[0066] The target service business refers to the service business provided after the SaaS tenant connects to the target web application. The target web application is an application software operated via a web browser on the internet or an enterprise intranet. For example, the target service business could refer to a lifestyle service business primarily focused on hairdressing services. Specifically, this could include services such as store management, employee management, customer management, store operation activities, and card sales and redemption. The target scenario data is related to the type of service provided after the SaaS tenant connects to the target web application. For example, if the target service business refers to a lifestyle service business primarily focused on hairdressing services, then the target scenario data could include employee management-related data, specifically employee names, ages, and contact information.
[0067] S204, When testing the target scenario data and determining that the target webpage corresponding to the target service business is displayed abnormally in the target webpage application, obtain the target webpage address of the target webpage from the target webpage application.
[0068] When the scenario data corresponding to a service business is different, the web page displayed in the web application will also be different; it can be understood that different service businesses can be deployed in the same web application; for example, life service businesses mainly focused on hairdressing services, tourism service businesses mainly focused on entertainment, and other types of service businesses can all be deployed in the same web application.
[0069] Specifically, in this embodiment, by testing the target scene data, it can be determined whether the target webpage corresponding to the target service is displayed abnormally in the target webpage application; if it is determined that the target webpage corresponding to the target service is displayed abnormally in the target webpage application, since the detection device in the target webpage application can detect the abnormality, the processor can obtain the target webpage address of the target webpage from the target webpage application.
[0070] The phrase "whether the target webpage displays abnormally in the target webpage application" refers to at least one of the following situations: the target webpage cannot be displayed in the target webpage application, or the target webpage displays a white screen in the target webpage application within a preset time. The reason why the target webpage cannot be displayed may be due to loading issues other than network requests such as APIs. The reason why the target webpage displays a white screen may be due to non-network issues. The specific reasons can be adjusted according to the actual application scenario, and will not be elaborated here.
[0071] S206, Based on the first target mapping relationship between web page address and source code block, obtain the source code block corresponding to the target web page address under the target service business.
[0072] The source code block corresponding to the target webpage address refers to the entry code block associated with the display of the target webpage. If all code blocks associated with the display of the target webpage are obtained, then a corresponding association search needs to be performed based on the entry code block.
[0073] S208, retrieve multiple target code blocks corresponding to the source code block.
[0074] Among them, multiple target code blocks refer to all code blocks associated with the display of the target webpage. By detecting multiple target code blocks, abnormal code can be located, thereby enabling the maintenance of the abnormal target webpage and preventing the recurrence of the abnormal display of the target webpage.
[0075] It should be noted that the target webpage application involves scripts such as Hyper Text Markup Language (HTML), Cascading Style Sheets (CSS), and JavaScript. Since most of the reasons for abnormal webpage display are due to JavaScript script issues, such as improper data processing within the script or failure to consider compatibility, this embodiment detects the source code block corresponding to the target webpage address and other code blocks associated with the source code block (i.e., multiple target code blocks).
[0076] S210, when an anomaly is detected in at least one of the multiple target code blocks, an alarm message is output, which includes the code location of at least one code block.
[0077] The alarm information is used to notify maintenance personnel that the target webpage is displaying abnormally due to an anomaly in at least one corresponding target code block. The alarm information can include the code location of at least one code block, thereby helping maintenance personnel to quickly locate the code block that is malfunctioning. Specifically, the alarm information can be output to the maintenance terminal or to the user terminal of the maintenance personnel.
[0078] In some embodiments, the alarm information may also include an alarm level. By setting the alarm level, maintenance personnel can be prompted to prioritize the detection of abnormal code blocks. Specifically, if the number of abnormal target code blocks is greater than or equal to a first threshold, the alarm level is a level one alarm; if the number of abnormal target code blocks is less than the first threshold but greater than or equal to a second threshold, the alarm level is a level two alarm; and if the number of abnormal target code blocks is less than the second threshold, the alarm level is a level three alarm.
[0079] In some embodiments, alarm information may also include code snippets or screen captures of the abnormal code block for maintenance personnel to view.
[0080] In some embodiments, the alarm information may further include the target webpage address of the target webpage that displays an abnormality, so that maintenance personnel can further determine whether the target webpage displays an abnormality by opening the target webpage address; if the target webpage does not display an abnormality, it can be determined that the detection device connected to the target webpage application needs maintenance.
[0081] The specific content of the alarm information can be set according to the actual application scenario, and this embodiment does not impose specific limitations.
[0082] In summary, Figure 2In the illustrated embodiment, by acquiring target scenario data corresponding to the target service business to be integrated into the target web application, testing the target scenario data allows for the determination of whether the target web page corresponding to the target service business displays abnormally in the target web application after integration, thus improving the availability of service business integration into the web application. When it is determined that the target web page corresponding to the target service business displays abnormally in the target web application, the target web page address of the target web page is obtained from the target web application, thereby obtaining the target web page address where the web page displays abnormally, improving the accuracy of anomaly detection. Furthermore, based on the first target mapping relationship between the web page address and the source code block, the source code block corresponding to the target web page address under the target service business is obtained, and the source code block is acquired. When dealing with multiple target code blocks, by detecting at least one target code block and outputting an alarm message when at least one of the target code blocks is found to be abnormal, the alarm message includes the code location of at least one code block. This allows for quick location of the code block causing the display abnormality of the target webpage from the perspective of the code block used to display the target webpage, improving the timeliness of anomaly detection. Even if no logs are printed on the console provided by the web application, the code block causing the display abnormality of the target webpage has been maintained based on the target scenario data corresponding to the target service business before the target service business is integrated into the target web application. Therefore, the situation where the target webpage displays abnormalities after the target service business is integrated into the target web application can be avoided.
[0083] In one embodiment, such as Figure 3 The diagram illustrates a process for obtaining the source code block corresponding to the target webpage address under a target service business based on a first target mapping relationship between webpage address and source code block. This method is then applied to... Figure 1 Taking processor 102 as an example, the following steps are included:
[0084] S302, based on the first target mapping relationship between web page address and source code block, when it is determined that multiple web page addresses match the source code block corresponding to the target web page address according to the first target mapping relationship and the target web page address, the second target mapping relationship between the web page address, the routing address and the source code block is obtained; the multiple web page addresses include the target web page address.
[0085] For example, based on the first target mapping relationship between web page address and source code block, if the target web page address matches source code block 1; but based on the first target mapping relationship between web page address and source code block, source code block 1 also corresponds to other web page addresses besides the target web page address, then source code block 1 is not determined as the source code block corresponding to the target web page address under the target service business. Instead, the second target mapping relationship between web page address, routing address and source code block is obtained to ensure the accuracy of obtaining the source code block corresponding to the web page address.
[0086] S304. Based on the second target mapping relationship and the target webpage address, obtain the source code block corresponding to the target webpage address under the target service business.
[0087] The second target mapping relationship refers to the correspondence between web page address, route address and source code block. This correspondence can avoid the situation where a source code block matching a web page address corresponds to multiple web page addresses, thus improving the accuracy of obtaining the source code block corresponding to the web page address.
[0088] In summary, based on Figure 3 The method shown, when it is determined that the source code block matching the target webpage address also corresponds to other webpage addresses besides the target webpage address based on the first target mapping relationship and the target webpage address, improves the accuracy of determining the source code block corresponding to the webpage address by introducing the second target mapping relationship, so that the webpage address and the corresponding source code block are in one-to-one correspondence.
[0089] In one embodiment, when it is determined, based on the first target mapping relationship and the target webpage address, that the source code block matching the target webpage address does not correspond to a webpage address other than the target webpage address, the source code block corresponding to the target webpage address under the target service business is obtained based on the first target mapping relationship and the target webpage address. This allows for rapid retrieval of the source code block corresponding to the webpage address, thereby improving the efficiency of code block anomaly detection.
[0090] In one embodiment, such as Figure 4 The diagram illustrates a process for obtaining the source code block corresponding to the target webpage address under a target service business based on a first target mapping relationship between webpage address and source code block. This method is then applied to... Figure 1 Taking processor 102 as an example, the following steps are included:
[0091] S402, obtain the first routing mapping relationship between the web page address and the route address, and the second routing mapping relationship between the route address and the source code block.
[0092] S404, based on the first and second routing mapping relationships, obtains the first target mapping relationship between the web page address and the source code block.
[0093] S406, Based on the first target mapping relationship and the target webpage address, obtain the source code block corresponding to the target webpage address under the target service business.
[0094] In summary, by setting the first target mapping relationship based on the first and second routing mapping relationships, it is possible to find the source code block corresponding to the target webpage address by matching the route address of the target webpage address when the target webpage address is determined, thereby accurately obtaining the source code block corresponding to the webpage address.
[0095] In one embodiment, such as Figure 5 The diagram illustrates a process for detecting an anomaly in at least one of multiple target code blocks, and how this method is applied to... Figure 1 Taking processor 102 as an example, the following steps are included:
[0096] S502, based on preset code statements, queries the code blocks associated with the source code block to obtain multiple target code blocks.
[0097] The preset code statements can include import, require, and other code statements. By using import, require, and other code statements, you can find code blocks associated with source code blocks and obtain multiple target code blocks. In this way, you can obtain all code blocks associated with the target webpage.
[0098] S504 scans each target code block line by line.
[0099] Specifically, a pre-set scanning program can be used to scan each target code block line by line.
[0100] S506, compare the scan result of each target code block with the preset abnormal segment. If the scan result of at least one of the multiple target code blocks matches the preset abnormal segment, determine that at least one of the multiple target code blocks has an abnormality.
[0101] Among them, the preset exception fragments are pre-set exception fragments, which can include historical exception fragments or common exception fragments evolved from historical exception fragments; specifically, preset exception fragments can include runtime method disorder exceptions, etc.; runtime method disorder exceptions refer to the inconsistency between the type of a variable set in the code block and the usage method corresponding to that value; for example, the code block defines the variable 'a' as a number, but uses string methods, such as the slice method in JavaScript, which causes the code block to be unable to perform the corresponding calculation process based on the variable 'a'.
[0102] In summary, through Figure 5The method shown can, when a code block associated with a source code block is found based on a preset code statement, scan each target code block line by line and compare the scan result of each target code block with a preset abnormal segment. If the scan result of at least one of the multiple target code blocks matches the preset abnormal segment, and it is determined that at least one of the multiple target code blocks has an anomaly, an alarm message is output. Since the alarm message includes the code location of at least one code block, the code block that causes the display anomaly of the target webpage can be quickly located from the perspective of the code block used to display the target webpage, thus improving the timeliness of anomaly detection.
[0103] In one embodiment, such as Figure 6 The diagram illustrates a process for detecting an anomaly in at least one of multiple target code blocks, and how this method is applied to... Figure 1 Taking processor 102 as an example, the following steps are included:
[0104] S602 tests multiple target code blocks based on target scenario data.
[0105] S604, if the input data corresponding to the target scene data in multiple target code blocks is inconsistent with the preset data input of multiple target code blocks, it is determined that at least one code block among the multiple target code blocks has an abnormality.
[0106] For example, if the input data corresponding to the target scene data is 'a', when 'a' is input into the target code block, it is found that the preset data input required by the target code block is 'a', 'b', and 'c'. It can be seen that the input of the target scene data in the target code block is inconsistent with the preset data input of the target code block. Therefore, it can be determined that the target code block is an abnormal code block.
[0107] In summary, through Figure 6 The method described above tests multiple target code blocks based on target scene data. By comparing the input data corresponding to the target scene data in the multiple target code blocks with the preset data input of the multiple target code blocks, the abnormal code blocks can be filtered out if the two are inconsistent. In this way, when outputting alarm information, since the alarm information includes the code position of at least one code block, the code block causing the display abnormality of the target webpage can be quickly located from the perspective of the code block used to display the target webpage, thus improving the timeliness of anomaly detection.
[0108] In conjunction with the above, in one embodiment, such as Figure 7 The diagram illustrates a method for locating exception codes, and demonstrates how this method can be applied to... Figure 1Taking processor 102 as an example, the following steps are included:
[0109] S702, Obtain the target scenario data corresponding to the target service business to be integrated into the target web application.
[0110] S704, When testing the target scenario data and determining that the target webpage corresponding to the target service business is displayed abnormally in the target webpage application, obtain the target webpage address of the target webpage from the target webpage application.
[0111] S706 retrieves the mapping relationship between web page addresses, route addresses, and source code blocks.
[0112] S708: Based on the mapping relationship and the target webpage address, obtain the source code block corresponding to the target webpage address under the target service business.
[0113] S710, based on preset code statements, scans each target code block line by line when it finds multiple target code blocks associated with the source code block.
[0114] S712, compare the scan result of each target code block with the preset abnormal segment. If the scan result of at least one of the multiple target code blocks matches the preset abnormal segment, determine that at least one of the multiple target code blocks has an abnormality.
[0115] S714 outputs alarm information, which includes the code location of at least one code block and a code segment of at least one code block.
[0116] The specific content of S702-S714 can be found in the aforementioned description and will not be repeated here.
[0117] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0118] Based on the same inventive concept, this application also provides an exception code location device for implementing the exception code location method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in one or more exception code location device embodiments provided below can be found in the limitations of the exception code location method described above, and will not be repeated here.
[0119] In one embodiment, such as Figure 8 As shown, an exception code location device is provided, including: a data acquisition module 802, a webpage address acquisition module 804, a source code block acquisition module 806, a target code block acquisition module 808, and a prompting module 810, wherein:
[0120] The data acquisition module 802 is used to acquire target scenario data corresponding to the target service business to be integrated into the target web application.
[0121] The webpage address acquisition module 804 is used to obtain the target webpage address from the target webpage application when testing the target scenario data and determining that the target webpage corresponding to the target service business is displayed abnormally in the target webpage application.
[0122] The source code block acquisition module 806 is used to obtain the source code block corresponding to the target webpage address under the target service business based on the first target mapping relationship between the webpage address and the source code block.
[0123] The target code block acquisition module 808 is used to acquire multiple target code blocks corresponding to the source code block.
[0124] The prompt module 810 is used to output alarm information when it is determined that at least one of the multiple target code blocks has an exception. The alarm information includes the code location of at least one code block.
[0125] In one embodiment, the source code block acquisition module is further configured to: based on a first target mapping relationship between a webpage address and a source code block, when it is determined, according to the first target mapping relationship and the target webpage address, that a source code block matching the target webpage address corresponds to multiple webpage addresses, acquire a second target mapping relationship between the webpage address, the routing address, and the source code block; the multiple webpage addresses include the target webpage address; and acquire the source code block corresponding to the target webpage address under the target service business according to the second target mapping relationship and the target webpage address.
[0126] In one embodiment, the source code block acquisition module is further configured to: when it is determined, based on the first target mapping relationship and the target webpage address, that the source code block matching the target webpage address does not correspond to a webpage address other than the target webpage address, obtain the source code block corresponding to the target webpage address under the target service business based on the first target mapping relationship and the target webpage address.
[0127] In one embodiment, the source code block acquisition module is further configured to: acquire a first routing mapping relationship between a webpage address and a routing address, and a second routing mapping relationship between a routing address and a source code block; based on the first routing mapping relationship and the second routing mapping relationship, acquire a first target mapping relationship between a webpage address and a source code block; and acquire the source code block corresponding to the target webpage address under the target service business according to the first target mapping relationship and the target webpage address.
[0128] In one embodiment, the target code block acquisition module is further configured to: search for code blocks associated with the source code block based on preset code statements to obtain multiple target code blocks; the prompting module is further configured to: scan each target code block line by line when a code block associated with the source code block is found; compare the scanning result of each target code block with a preset abnormal segment; if the scanning result of at least one of the multiple target code blocks matches the preset abnormal segment, determine that at least one of the multiple target code blocks has an abnormality.
[0129] In one embodiment, the prompting module is further configured to: test multiple target code blocks based on target scene data; if the input of the input data corresponding to the target scene data in the multiple target code blocks is inconsistent with the preset data input of the multiple target code blocks, determine that at least one code block among the multiple target code blocks is abnormal.
[0130] Each module in the aforementioned exception code location device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0131] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 9As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores: a first target mapping relationship between web page addresses and source code blocks; a second target mapping relationship between web page addresses, routing addresses, and source code blocks; a first routing mapping relationship between web page addresses and routing addresses; and a second routing mapping relationship between routing addresses and source code blocks. The network interface is used for communication with external terminals via a network connection. When executed by the processor, the computer program implements an exception code location method.
[0132] Those skilled in the art will understand that Figure 9 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0133] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to perform the following steps: acquiring target scene data corresponding to a target service business to be accessed in a target web application; when testing the target scene data and determining that the target web page corresponding to the target service business displays abnormally in the target web application, acquiring the target web page address of the target web page from the target web application; obtaining the source code block corresponding to the target web page address under the target service business based on a first target mapping relationship between the web page address and the source code block; acquiring multiple target code blocks corresponding to the source code block; when an anomaly is detected in at least one of the multiple target code blocks, outputting alarm information, the alarm information including the code location of at least one code block.
[0134] In one embodiment, when the processor executes the computer program, it further implements the following steps: based on a first target mapping relationship between web page addresses and source code blocks, when it is determined, according to the first target mapping relationship and the target web page address, that a source code block matching the target web page address corresponds to multiple web page addresses, a second target mapping relationship is obtained between the web page address, the routing address, and the source code block; the multiple web page addresses include the target web page address; and according to the second target mapping relationship and the target web page address, the source code block corresponding to the target web page address under the target service business is obtained.
[0135] In one embodiment, when the processor executes the computer program, it further implements the following steps: when it is determined, based on the first target mapping relationship and the target webpage address, that the source code block matching the target webpage address does not correspond to a webpage address other than the target webpage address, the source code block corresponding to the target webpage address under the target service business is obtained based on the first target mapping relationship and the target webpage address.
[0136] In one embodiment, when the processor executes the computer program, it further performs the following steps: obtaining a first routing mapping relationship between a webpage address and a routing address, and a second routing mapping relationship between a routing address and a source code block; obtaining a first target mapping relationship between a webpage address and a source code block based on the first routing mapping relationship and the second routing mapping relationship; and obtaining the source code block corresponding to the target webpage address under the target service business according to the first target mapping relationship and the target webpage address.
[0137] In one embodiment, when the processor executes the computer program, it further performs the following steps: based on preset code statements, it searches for code blocks associated with source code blocks to obtain multiple target code blocks; when a code block associated with a source code block is found, it scans each target code block line by line; it compares the scan result of each target code block with a preset abnormal segment, and if the scan result of at least one of the multiple target code blocks matches the preset abnormal segment, it determines that at least one of the multiple target code blocks has an abnormality.
[0138] In one embodiment, when the processor executes the computer program, it further performs the following steps: testing multiple target code blocks based on target scene data; if the input of the input data corresponding to the target scene data in the multiple target code blocks is inconsistent with the preset data input of the multiple target code blocks, it is determined that at least one of the multiple target code blocks is abnormal.
[0139] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, it performs the following steps: acquiring target scene data corresponding to a target service business to be accessed in a target web application; when testing the target scene data and determining that the target web page corresponding to the target service business displays abnormally in the target web application, acquiring the target web page address of the target web page from the target web application; based on a first target mapping relationship between the web page address and the source code block, obtaining the source code block corresponding to the target web page address under the target service business; acquiring multiple target code blocks corresponding to the source code block; when an anomaly is detected in at least one of the multiple target code blocks, outputting alarm information, the alarm information including the code location of at least one code block.
[0140] In one embodiment, when the computer program is executed by the processor, it further implements the following steps: based on a first target mapping relationship between a webpage address and a source code block, when it is determined, according to the first target mapping relationship and the target webpage address, that a source code block matching the target webpage address corresponds to multiple webpage addresses, a second target mapping relationship is obtained between the webpage address, the routing address, and the source code block; the multiple webpage addresses include the target webpage address; and according to the second target mapping relationship and the target webpage address, the source code block corresponding to the target webpage address under the target service business is obtained.
[0141] In one embodiment, when the computer program is executed by the processor, it further implements the following steps: when it is determined, based on the first target mapping relationship and the target webpage address, that the source code block matching the target webpage address does not correspond to a webpage address other than the target webpage address, the source code block corresponding to the target webpage address under the target service business is obtained based on the first target mapping relationship and the target webpage address.
[0142] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: obtaining a first routing mapping relationship between a webpage address and a routing address, and a second routing mapping relationship between a routing address and a source code block; obtaining a first target mapping relationship between a webpage address and a source code block based on the first routing mapping relationship and the second routing mapping relationship; and obtaining the source code block corresponding to the target webpage address under the target service business according to the first target mapping relationship and the target webpage address.
[0143] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: based on preset code statements, it searches for code blocks associated with source code blocks to obtain multiple target code blocks; when a code block associated with a source code block is found, it scans each target code block line by line; it compares the scan result of each target code block with a preset abnormal segment, and if the scan result of at least one of the multiple target code blocks matches the preset abnormal segment, it determines that at least one of the multiple target code blocks has an abnormality.
[0144] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: testing multiple target code blocks based on target scene data; if the input of the input data corresponding to the target scene data in the multiple target code blocks is inconsistent with the preset data input of the multiple target code blocks, it is determined that at least one of the multiple target code blocks is abnormal.
[0145] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps: acquiring target scenario data corresponding to a target service business to be accessed in a target web application; when testing the target scenario data and determining that the target web page corresponding to the target service business displays abnormally in the target web application, acquiring the target web page address of the target web page from the target web application; based on a first target mapping relationship between the web page address and source code blocks, obtaining the source code block corresponding to the target web page address under the target service business; acquiring multiple target code blocks corresponding to the source code block; when an anomaly is detected in at least one of the multiple target code blocks, outputting alarm information, the alarm information including the code location of at least one code block.
[0146] In one embodiment, when the computer program is executed by the processor, it further implements the following steps: based on a first target mapping relationship between a webpage address and a source code block, when it is determined, according to the first target mapping relationship and the target webpage address, that a source code block matching the target webpage address corresponds to multiple webpage addresses, a second target mapping relationship is obtained between the webpage address, the routing address, and the source code block; the multiple webpage addresses include the target webpage address; and according to the second target mapping relationship and the target webpage address, the source code block corresponding to the target webpage address under the target service business is obtained.
[0147] In one embodiment, when the computer program is executed by the processor, it further implements the following steps: when it is determined, based on the first target mapping relationship and the target webpage address, that the source code block matching the target webpage address does not correspond to a webpage address other than the target webpage address, the source code block corresponding to the target webpage address under the target service business is obtained based on the first target mapping relationship and the target webpage address.
[0148] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: obtaining a first routing mapping relationship between a webpage address and a routing address, and a second routing mapping relationship between a routing address and a source code block; obtaining a first target mapping relationship between a webpage address and a source code block based on the first routing mapping relationship and the second routing mapping relationship; and obtaining the source code block corresponding to the target webpage address under the target service business according to the first target mapping relationship and the target webpage address.
[0149] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: based on preset code statements, it searches for code blocks associated with source code blocks to obtain multiple target code blocks; when a code block associated with a source code block is found, it scans each target code block line by line; it compares the scan result of each target code block with a preset abnormal segment, and if the scan result of at least one of the multiple target code blocks matches the preset abnormal segment, it determines that at least one of the multiple target code blocks has an abnormality.
[0150] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: testing multiple target code blocks based on target scene data; if the input of the input data corresponding to the target scene data in the multiple target code blocks is inconsistent with the preset data input of the multiple target code blocks, it is determined that at least one of the multiple target code blocks is abnormal.
[0151] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0152] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0153] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0154] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for locating exception codes, characterized in that, The method includes: Obtain the target scenario data corresponding to the target service business to be integrated into the target web application; When testing the target scenario data, and determining that the target webpage corresponding to the target service business is displayed abnormally in the target webpage application, the target webpage address of the target webpage is obtained from the target webpage application. Based on the first target mapping relationship between web page address and source code block, obtain the source code block corresponding to the target web page address under the target service business; Obtain multiple target code blocks corresponding to the source code block; When an anomaly is detected in at least one of the plurality of target code blocks, an alarm message is output, the alarm message including the code location of the at least one code block; The step of obtaining the source code block corresponding to the target webpage address under the target service business based on the first target mapping relationship between the webpage address and the source code block includes: Based on the first target mapping relationship between web page addresses and source code blocks, when it is determined, according to the first target mapping relationship and the target web page address, that a source code block matching the target web page address corresponds to multiple web page addresses, a second target mapping relationship between the web page address, the routing address, and the source code block is obtained; the multiple web page addresses include the target web page address. Based on the second target mapping relationship and the target webpage address, obtain the source code block corresponding to the target webpage address under the target service business.
2. The method according to claim 1, characterized in that, The method further includes: When it is determined, based on the first target mapping relationship and the target webpage address, that the source code block matching the target webpage address does not correspond to a webpage address other than the target webpage address, the source code block corresponding to the target webpage address under the target service business is obtained based on the first target mapping relationship and the target webpage address.
3. The method according to claim 1, characterized in that, The method further includes: Obtain the first routing mapping relationship between the web page address and the route address, and the second routing mapping relationship between the route address and the source code block; Based on the first routing mapping relationship and the second routing mapping relationship, a first target mapping relationship between the web page address and the source code block is obtained; Based on the first target mapping relationship and the target webpage address, obtain the source code block corresponding to the target webpage address under the target service business.
4. The method according to claim 1, characterized in that, The step of obtaining multiple target code blocks corresponding to the source code block includes: Based on preset code statements, find the code blocks associated with the source code block to obtain the plurality of target code blocks; The detection of an anomaly in at least one of the plurality of target code blocks includes: Scan each target code block line by line; The scan result of each target code block is compared with a preset abnormal segment. If the scan result of at least one of the target code blocks matches the preset abnormal segment, it is determined that at least one of the target code blocks is abnormal.
5. The method according to claim 1, characterized in that, The detection of an anomaly in at least one of the plurality of target code blocks includes: The multiple target code blocks are tested based on the target scene data; If the input data corresponding to the target scene data is inconsistent with the preset data input of the multiple target code blocks, it is determined that at least one of the multiple target code blocks is abnormal.
6. An anomaly code location device, characterized in that, The device includes: The data acquisition module is used to acquire target scenario data corresponding to the target service business to be integrated into the target web application; The webpage address acquisition module is used to acquire the target webpage address of the target webpage from the target webpage application when testing the target scenario data and determining that the target webpage corresponding to the target service business is displayed abnormally in the target webpage application. The source code block acquisition module is used to obtain the source code block corresponding to the target webpage address under the target service business based on the first target mapping relationship between the webpage address and the source code block; The target code block acquisition module is used to acquire multiple target code blocks corresponding to the source code block; The prompting module is used to output alarm information when it is determined that at least one of the plurality of target code blocks has an anomaly. The alarm information includes the code location of the at least one code block. The source code block acquisition module is further configured to, based on a first target mapping relationship between a webpage address and a source code block, when it is determined, according to the first target mapping relationship and the target webpage address, that a source code block matching the target webpage address corresponds to multiple webpage addresses, acquire a second target mapping relationship between the webpage address, the routing address, and the source code block; the multiple webpage addresses include the target webpage address; and, according to the second target mapping relationship and the target webpage address, obtain the source code block corresponding to the target webpage address under the target service business.
7. The apparatus according to claim 6, characterized in that, The source code block acquisition module is also used for: When it is determined, based on the first target mapping relationship and the target webpage address, that the source code block matching the target webpage address does not correspond to a webpage address other than the target webpage address, the source code block corresponding to the target webpage address under the target service business is obtained based on the first target mapping relationship and the target webpage address.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.