Code scanning method and device, storage medium and electronic device

By generating an object code scanner to parse and process the object code file, the problem of low flexibility in code scanning products in the prior art is solved, and customized code scanning and product generation are realized.

CN119166160BActive Publication Date: 2025-05-09ALIBABA CLOUD COMPUTING CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411686779.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-22
Publication Date
2025-05-09
Estimated Expiration
2044-11-22

AI Technical Summary

Technical Problem

Existing code scanning products can only identify specific products, resulting in low flexibility in code scanning and cannot meet users' personalized needs.

Method used

By determining the object code file to be scanned, and generating the object code scanner based on the product requirement information and the programming language information of the object code file, the customization and analysis processing of the code file is realized to generate the corresponding target product.

Benefits of technology

It improves the flexibility of code scanning and can customize scanning products according to the specific needs of users, solving the problem of low flexibility of code scanning products in the prior art.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119166160B_ABST
    Figure CN119166160B_ABST
Patent Text Reader

Abstract

The present application discloses a code scanning method and device, a storage medium and an electronic device, and relates to the field of data processing technology, wherein the method comprises: determining a target code file to be scanned; obtaining a target code scanner based on product requirement information and programming language information corresponding to the target code file, wherein the product requirement information at least includes description information of the product output after scanning the code file; parsing the target code file through the target code scanner to obtain a target product corresponding to the product requirement information. The present application solves the technical problem that the code scanning product in the related art can only identify specific products, resulting in relatively low flexibility of code scanning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a code scanning method and device, a storage medium, and an electronic device. Background Art

[0002] In modern enterprises, the rapid development of information technology and the wave of digital transformation have made enterprises face increasingly complex application systems and huge data assets. As task requirements continue to change, enterprises need to adapt flexibly and quickly deliver powerful applications and efficient data processing capabilities. However, enterprises often have multiple different systems, which may differ in design, implementation, and data management, resulting in information silos, data duplication, and increased maintenance difficulties. Therefore, how to effectively understand and manage these diverse applications and their components is crucial to the successful operation of enterprises.

[0003] In this context, it has become a very important technical means to generate system metadata by scanning application code and identifying the technical elements such as domain models, data models, APIs, and related computing and storage resources contained therein. With its high efficiency and accuracy, this technology provides enterprises with a comprehensive and clear application view, helping them to sort out the functional modules of each system and the organizational structure of data in complex task environments. However, the code scanning products in the existing technology only provide the function of scanning and identifying specific products for specific content input, and users cannot realize personalized needs through existing product solutions.

[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0005] The embodiments of the present application provide a code scanning method and device, a storage medium and an electronic device to at least solve the technical problem that code scanning products in related technologies can only identify specific products, resulting in relatively low flexibility of code scanning.

[0006] According to one aspect of an embodiment of the present application, a code scanning method is provided, comprising: determining a target code file to be scanned; obtaining a target code scanner based on product requirement information and programming language information corresponding to the target code file, wherein the product requirement information at least includes description information of a product output after scanning the code file; and parsing the target code file by the target code scanner to obtain a target product corresponding to the product requirement information.

[0007] Furthermore, determining the target code file to be scanned includes: obtaining filtering requirement information, wherein the filtering requirement information includes at least: file name suffix information and / or characteristic content identification information in the code file; inputting the filtering requirement information into a first frame corresponding to the code filter through a code filtering interface to obtain a target code filter; and scanning the initial code file through the target code filter to obtain the target code file.

[0008] Furthermore, based on the product requirement information and the programming language information corresponding to the target code file, obtaining the target code scanner includes: matching the product requirement information, the programming language information and the description information of multiple code scanners to obtain a matching result; if the matching result indicates that there is a match between the target description information and the product requirement information and the programming language information, then determining the target code scanner based on the code scanner corresponding to the target description information; if the matching result indicates that there is no match between the target description information and the product requirement information and the programming language information, then generating the target code scanner based on the product requirement information, the programming language information and the template of the code scanner.

[0009] Furthermore, before parsing the target code file through the target code scanner to obtain the target product corresponding to the product requirement information, the method also includes: parsing the target code file through a syntax parser to obtain an initial abstract syntax tree corresponding to the target code file; screening the initial abstract syntax tree through a model identifier determiner to obtain a target abstract syntax tree; parsing the target code file through the target code scanner to obtain the target product corresponding to the product requirement information includes: parsing the target abstract syntax tree through the target code scanner to obtain the target product.

[0010] Furthermore, before the initial abstract syntax tree is screened by a model identifier judge to obtain a target abstract syntax tree, the method also includes: obtaining model identification information, wherein the model identification information includes at least: a model identification type, a model identification position and a value corresponding to the model identification; and inputting the model identification information into a second frame corresponding to the model identifier judge through a model identification interface to obtain the model identifier judge.

[0011] Furthermore, the target abstract syntax tree is parsed by the target code scanner to obtain the target product, including: parsing the target abstract syntax tree by the target code scanner to obtain an initial product; determining whether a format type corresponding to the initial product is the same as a format type in the product requirement information; if the format type corresponding to the initial product is different from the format type in the product requirement information, performing format conversion on the initial product based on the format type in the product requirement information by a format converter to obtain the target product.

[0012] Furthermore, after parsing the target code file through the target code scanner to obtain the target product corresponding to the product requirement information, the method also includes: filtering the target product based on the file information required by the target system through a product filter to obtain filtered product information, wherein the target system is the application system of the target product; and outputting the filtered product information to the target location corresponding to the location information of the target system call file through a content outputter.

[0013] According to another aspect of an embodiment of the present application, a code scanning device is also provided, including: a first determination unit, used to determine a target code file to be scanned; a second determination unit, used to obtain a target code scanner based on product requirement information and programming language information corresponding to the target code file, wherein the product requirement information at least includes description information of the product output after scanning the code file; and a processing unit, used to parse and process the target code file through the target code scanner to obtain a target product corresponding to the product requirement information.

[0014] Furthermore, the first determination unit includes: an acquisition module, used to obtain filtering requirement information, wherein the filtering requirement information at least includes: file name suffix information and / or characteristic content identification information in the code file; an input module, used to input the filtering requirement information into the first frame corresponding to the code filter through the code filtering interface to obtain the target code filter; a scanning module, used to scan the initial code file through the target code filter to obtain the target code file.

[0015] Furthermore, the second determination unit includes: a matching module, which is used to match the product requirement information, the programming language information and the description information of multiple code scanners to obtain a matching result; a determination module, which is used to determine the target code scanner based on the code scanner corresponding to the target description information if the matching result indicates that there is a match between the target description information and the product requirement information and the programming language information; and a generation module, which is used to generate the target code scanner based on the product requirement information, the programming language information and the template of the code scanner if the matching result indicates that there is no match between the target description information and the product requirement information and the programming language information.

[0016] Furthermore, the device also includes: a parsing unit, which is used to parse the target code file through the target code scanner to obtain the target product corresponding to the product requirement information, and then parse the target code file through a syntax parser to obtain an initial abstract syntax tree corresponding to the target code file; a screening unit, which is used to screen the initial abstract syntax tree through a model identifier determiner to obtain a target abstract syntax tree; the processing unit includes: a processing module, which is used to parse the target abstract syntax tree through the target code scanner to obtain the target product.

[0017] Furthermore, the device also includes: an acquisition unit, used to obtain model identification information before filtering the initial abstract syntax tree through a model identification judge to obtain a target abstract syntax tree, wherein the model identification information at least includes: a model identification type, a model identification position and a value corresponding to the model identification; an input unit, used to input the model identification information into a second frame corresponding to the model identification judge through a model identification interface to obtain the model identification judge.

[0018] Furthermore, the processing module includes: a parsing submodule, used to parse the target abstract syntax tree through the target code scanner to obtain an initial product; a judgment submodule, used to judge whether the format type corresponding to the initial product is the same as the format type in the product requirement information; a conversion submodule, used to convert the format of the initial product based on the format type in the product requirement information through a format converter to obtain the target product if the format type corresponding to the initial product is different from the format type in the product requirement information.

[0019] Furthermore, the device also includes: a filtering unit, which is used to filter the target product based on the file information required by the target system through a product filter after parsing the target code file through the target code scanner to obtain the target product corresponding to the product requirement information, so as to obtain filtered product information, wherein the target system is an application system of the target product; and an output unit, which is used to output the filtered product information to the target location corresponding to the location information of the target system call file through a content outputter.

[0020] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is further provided, wherein the computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the storage medium is located is controlled to execute any one of the above-mentioned code scanning methods.

[0021] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, comprising a memory storing an executable program; and a processor for running the program, wherein the program executes any one of the above-mentioned code scanning methods when running.

[0022] According to another aspect of an embodiment of the present invention, a computer program product is further provided. The computer program product includes a stored computer program. When the computer program is executed by a processor, any one of the above code scanning methods is implemented.

[0023] In an embodiment of the present application, a target code file to be scanned is determined; a target code scanner is obtained based on product requirement information and programming language information corresponding to the target code file, wherein the product requirement information at least includes description information of the product output after scanning the code file; the target code file is parsed and processed by the target code scanner to obtain a target product corresponding to the product requirement information, and the purpose of customizing the scanned product is achieved through the target code scanner corresponding to the product requirement information and the programming language information, thereby achieving the technical effect of improving the flexibility of code scanning, and further solving the technical problem in the related art that the code scanning product can only identify specific products, resulting in relatively low flexibility of code scanning. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0025] Figure 1 is a hardware structure block diagram of a computer terminal provided according to Embodiment 1 of the present application;

[0026] Figure 2This is the process of the code scanning method provided in Example 1 of this application Figure 1 ;

[0027] Figure 3 This is the process of the code scanning method provided in Example 1 of this application Figure 2 ;

[0028] Figure 4 This is the process of the code scanning method provided in Example 1 of this application Figure 3 ;

[0029] Figure 5 This is the process of the code scanning method provided in Example 1 of this application Figure 4 ;

[0030] Figure 6 is a schematic diagram of a code scanning device provided according to Embodiment 1 of the present application;

[0031] Figure 7 It is a structural block diagram of an electronic device provided according to Embodiment 3 of the present application. DETAILED DESCRIPTION

[0032] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0033] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application 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 interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0034] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following explanations:

[0035] Code scanning: Read and understand the code through the application, and identify various design elements contained in the code, including models, API (Application Programming Interface), etc.

[0036] 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, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards in the relevant regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0037] Example 1

[0038] According to an embodiment of the present application, a code scanning method is also provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0039] The method embodiment provided in the first embodiment of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computer terminal (or mobile device) for implementing a code scanning method. Figure 1 As shown, the computer terminal (or mobile device) 10 may include a processor set 102 (the processor set 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA, and the processor set 102 may include a processor set, Figure 1 102a, 102b, ..., 102n are used to illustrate), a memory 104 for storing data, and a transmission module 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0040] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10 (or mobile device). As involved in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0041] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the code scanning method in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, the above-mentioned code scanning method is realized. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0042] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0043] The display may be a touch screen type liquid crystal display, which may enable a user to interact with a user interface of the computer terminal 10 (or mobile device).

[0044] Under the above operating environment, this application provides Figure 2 The code scanning method shown. Figure 2 This is the process of the code scanning method according to Example 1 of the present application Figure 1 The method comprises:

[0045] Step S201, determining the target code file to be scanned.

[0046] Optionally, by scanning the application code to generate metadata (for example, domain models, data models, APIs, and related computing and storage resources and other technical elements), it is possible to identify dependencies between systems, reduce integration distances, and reduce implementation risks. At the same time, clear APIs and data models also provide an important basis for building new systems. Against the above background, the present application proposes a code scanning method. First, a project directory is selected: that is, a source code project directory to be scanned is given. It should be noted that the source code project directory includes all source codes, and then the target code file to be scanned is determined from all source codes. In an optional embodiment, the above-mentioned target code file can be obtained by filtering all source codes, for example, filtering all source codes based on the file name suffix.

[0047] Step S202, obtaining a target code scanner based on product requirement information and programming language information corresponding to the target code file, wherein the product requirement information at least includes description information of the product output after scanning the code file.

[0048] Optionally, obtain the product requirement information required by the user, for example, parse a Java class to analyze the domain model and data model it represents. Among them, the domain model and the data model are the product requirement information. Obtain the programming language information corresponding to the target code file, for example, Java, Python, etc. According to the corresponding product requirement information and programming language information, determine the corresponding target code scanner. For example, multiple code scanners can be established according to the task requirements, and then a more suitable initial code scanner can be selected from the multiple code scanners according to the product requirement information and the programming language information, and then the initial code scanner can be fine-tuned to obtain the above-mentioned target code scanner.

[0049] For example, if the product requirement information corresponding to the user is the architecture model metadata in the target code file, then the corresponding target code scanner may be an architecture model code scanner.

[0050] Step S203, parsing the target code file through a target code scanner to obtain a target product corresponding to the product requirement information.

[0051] Optionally, the target code file is scanned and parsed by a target code scanner to obtain a target product corresponding to the product requirement information.

[0052] In summary, users can customize the code scanner through the code scanning method provided by this application, and independently control the analysis and processing logic of the code content through the acquired source code content. For example, by understanding the model behind a certain specific code logic (such as process, state machine, domain, and data object, etc.), the technical problem that the code scanning products in the related technology can only identify specific products, resulting in relatively low flexibility of code scanning, is solved. By customizing the output of code scanning, the flexibility of code scanning is improved.

[0053] In order to improve the flexibility of code scanning, in the code scanning method provided in Example 1 of the present application, determining the target code file to be scanned includes: obtaining filtering requirement information, wherein the filtering requirement information at least includes: file name suffix information and / or characteristic content identification information in the code file; inputting the filtering requirement information into the first frame corresponding to the code filter through the code filtering interface to obtain the target code filter; scanning the initial code file through the target code filter to obtain the target code file.

[0054] Optionally, the user's filtering requirement information is received through the code filtering interface. It should be noted that the filtering requirement information may include but is not limited to file name suffix information and / or characteristic content identification information in the code file. For example, the file name suffixes of interest include: .java suffix, .xml suffix, .properties suffix. The characteristic content identifiers in the file content of interest include: Java code files containing main function declarations, XML files containing Maven's pom files, and properties configuration files containing spring boot configuration tags.

[0055] The filtering requirement information is input into the first frame corresponding to the code filter through the code filtering interface, and then the corresponding target code filter is obtained. Finally, the initial code file is filtered and scanned by the target code filter to obtain the target code file. For example, the code filter can be a Java code filter with a .java suffix, an XML file filter with a .xml suffix, a configuration file filter with a .properties suffix, etc.

[0056] It should be noted that the first framework corresponding to the above-mentioned code filter can be a Spring component with a rough framework for intercepting requests and responses. The filtering requirement information is added to the Spring component so that the component knows what kind of code needs to be intercepted.

[0057] It should be noted that the initial code file can be a source code project directory, which contains all the source codes of a project.

[0058] Through the above steps, the customized code scanning range is realized to obtain the corresponding code filter, thereby improving the flexibility of code filtering. When scanning the code, the user can also flexibly choose which codes to scan, and through code filtering, the scanning range of the source code can be effectively narrowed, thereby improving the processing efficiency of the subsequent target code scanner.

[0059] How to obtain the target code scanner is crucial. Therefore, in the code scanning method provided in Example 1 of the present application, based on the product requirement information and the programming language information corresponding to the target code file, obtaining the target code scanner includes: matching the product requirement information, the programming language information and the description information of multiple code scanners to obtain a matching result; if the matching result indicates that there is a match between the target description information and the product requirement information and the programming language information, then determining the target code scanner based on the code scanner corresponding to the target description information; if the matching result indicates that there is no match between the target description information and the product requirement information and the programming language information, then generating the target code scanner based on the product requirement information, the programming language information and the template of the code scanner.

[0060] Optionally, description information of multiple code scanners currently in the system is obtained. It should be noted that the description information may include what the input and output of the code scanner correspond to, and information about programming languages ​​that the code scanner can process.

[0061] The similarity of the product requirement information, programming language information and the description information of multiple code scanners is then calculated to obtain multiple similarities, and the matching results are determined based on the similarities. For example, when there is description information with a similarity higher than a threshold, the matching result is determined to indicate that there is a match between the target description information and the product requirement information and the programming language information. If there is no description information with a similarity higher than the threshold, the matching result is determined to indicate that there is no match between the target description information and the product requirement information and the programming language information.

[0062] If the matching result indicates that the target description information matches the product requirement information and the programming language information, the code scanner corresponding to the target description information is directly determined as the target code scanner. If the matching result indicates that the target description information does not match the product requirement information and the programming language information, the target code scanner is generated based on the product requirement information, the programming language information and the template of the code scanner.

[0063] For example, the corresponding code scanning and analysis code is written based on the product requirement information and programming language information, and then the code scanning and analysis code is inserted into the template of the code scanner to obtain the target code scanner. It should be noted that the output of the code scanner is a collection of several products, which can be one or more.

[0064] The matching results can be used to quickly select the corresponding code scanner as the target code scanner. If there is no matching code processor, the corresponding target code scanner can be generated through the code scanner template and the required product requirement information and programming language information, thereby realizing the user's personalized needs and improving the flexibility of code scanning.

[0065] In order to improve the accuracy of code scanning, in the code scanning method provided in Example 1 of the present application, before parsing the target code file through the target code scanner to obtain the target product corresponding to the product requirement information, the method also includes: parsing the target code file through the syntax parser to obtain an initial abstract syntax tree corresponding to the target code file; screening the initial abstract syntax tree through the model identifier determiner to obtain a target abstract syntax tree; parsing the target code file through the target code scanner to obtain the target product corresponding to the product requirement information includes: parsing the target abstract syntax tree through the target code scanner to obtain the target product.

[0066] Optionally, before the target code file is parsed by the target code scanner, the target code file is first parsed by the syntax parser to obtain the AST (i.e., the initial abstract syntax tree) corresponding to the target code file. The parsing process of the syntax parser includes: decomposing the source code in the target code file into a series of lexical unit sequences, such as keywords, identifiers, numbers, operators, etc. Then, according to the defined grammar rules, the lexical unit sequence is converted into AST.

[0067] After obtaining the initial abstract syntax tree, users can customize the model identifiers of interest, thereby ignoring the AST complete parsing of irrelevant codes, that is, the initial abstract syntax tree is screened by the model identifier judger to obtain the target abstract syntax tree. Finally, the target abstract syntax tree is parsed by the target code scanner to obtain the target product.

[0068] It should be noted that the code scanner can have two types of input: (1) a single AST model (i.e. the target abstract syntax tree mentioned above): for example, only a JavaAST; (2) a module scope content, a model set of several ASTs of a specified type: for example, all java ASTs under module a, all javaasts containing the main function in the entire project scope, and all pom asts. The output of the code scanner is a collection of several products, which can be one or more. For example, for the same JavaAST, the metadata model of the application service and the standard specification model of the API can be analyzed.

[0069] It should be noted that the filtering process of the model identifier judge is the same as the filtering process type of the target code filter. The user can set the required feature content identification information and suffix information in the AST, and then filter the initial abstract syntax tree based on this information to obtain the target abstract syntax tree.

[0070] The model identification judger can filter out some irrelevant AST complete parsing, thereby improving the processing efficiency of the subsequent target code scanner in parsing the target abstract syntax tree.

[0071] In the code scanning method provided in Example 1 of the present application, a customized model identification judger is obtained through the following steps: obtaining model identification information, wherein the model identification information includes at least: a model identification type, a model identification position and a value corresponding to the model identification; and inputting the model identification information into a second frame corresponding to the model identification judger through a model identification interface to obtain the model identification judger.

[0072] Optionally, the model identification information set by the user is received through the model identification interface. It should be noted that the model identification information includes at least: the model identification type, the model identification position and the value corresponding to the model identification. For example, the type of identification: such as annotations (Annotation) of Java source code, comment tags (@xxx in Javadoc), certain specific tags in XML, etc.; the position of the identification: such as annotations or comment tags in Java source code, which may be in the class, interface, method, parameter or attribute, etc.; the value of the identification: such as the specific annotation name, the name of the comment tag, etc. The model identification information is input into the second frame corresponding to the model identification judge through the model identification interface to obtain the model identification judge. The irrelevant information that cannot be filtered out in the code filter stage can be filtered out through the model identification judge, so that the code information that the user is more concerned about can be directly processed in the subsequent process, thereby improving the efficiency of code scanning.

[0073] It should be noted that the second framework corresponding to the above-mentioned model identifier judger can also be a Spring component with a rough framework for intercepting requests and responses. The feature content identification information and suffix information in the AST required for setting are added to the Spring component, so that the component knows what kind of code needs to be intercepted, and then obtains the above-mentioned target syntax tree.

[0074] In the code scanning method provided in Example 1 of the present application, a target abstract syntax tree is parsed by a target code scanner to obtain a target product, including: parsing the target abstract syntax tree by a target code scanner to obtain an initial product; determining whether a format type corresponding to the initial product is the same as a format type in product requirement information; if the format type corresponding to the initial product is different from the format type in the product requirement information, performing format conversion on the initial product based on the format type in the product requirement information by a format converter to obtain a target product.

[0075] Optionally, in the actual application process, the scanned product may sometimes need to be converted into a mode. Usually, the existing scanner parses into format A, and finally requires format B. If the cost of developing a scanner for format B is high, therefore, in the code scanning method provided in Example 1 of the present application, the target abstract syntax tree is parsed by the target code scanner to obtain the target product, including: first, the target abstract syntax tree is parsed by the target code scanner to obtain the initial product, and then it is determined whether the format type corresponding to the initial product is the same as the format type in the product requirement information. For example, the format corresponding to the initial product is yaml, and the format type in the product requirement information is json, then a json format converter of OAS is customized, and then the format converter is used to convert the format of the initial product based on the format type in the product requirement information to obtain the target product. The format converter can avoid the problem of developing a scanner due to format problems, thereby improving the efficiency of code scanning.

[0076] After the target code file is parsed and processed by the target code scanner to obtain the target product corresponding to the product requirement information, in the code scanning method provided in Example 1 of the present application, the method also includes the following steps: filtering the target product based on the file information required by the target system through the product filter to obtain filtered product information, wherein the target system is the application system of the target product; outputting the filtered product information to the target location corresponding to the location information of the target system call file through the content outputter.

[0077] Optionally, determine the target system to which the target product is to be applied, and then obtain a product filter based on the file information required by the target system. For example, the file information may be the file name suffix and the characteristic content identifier in the file content. Filter the target product through the product filter to obtain the filtered product information. Then, a content outputter may be obtained based on the location information of the target system call file, and the file save location information may be set in the content outputter, for example, the output result file may be saved to a specified location on the disk; the output result file may be saved to a specified cloud storage space; and the output result metamodel may be reported to a specified system (if BizWorks is used, the model metadata obtained by code scanning may be reported to the metadata warehouse of the modeling platform for management). Finally, the filtered product information may be output to the target location corresponding to the location information of the target system call file through the content outputter.

[0078] In an optional embodiment, the flowchart of code scanning is as follows Figure 3 As shown, it includes: selecting the project directory: that is, giving the source code project directory to be scanned, the directory contains all the source codes to be scanned; filtering the scan range: filtering (screening) all the contents in the project directory, and not processing the contents that are not of interest. Scanning: Based on the filtered source code content, scan each code unit (usually a source code file) to identify the call model and technical model contained therein. Forming product content: generating target content based on the scan results; product output: outputting the product content to the target location, usually including: generating files in a specific format, storing them in a specific database, and reporting them to the target system through API calls; obtaining and using scan products.

[0079] like Figure 3 As shown in the figure, users can control the scope of code scanning through custom code filters, such as scanning only Java code, or including all configuration files, Mavenpom files, etc.; scanning all codes in the project directory, or only codes in a subdirectory or a specific package path.

[0080] Users can use custom code scanners to independently control the analysis and processing logic of code content through the acquired source code content. For example, they can understand the model behind a certain code logic (such as process, state machine, domain, and data object, etc.). Users can use custom model identifier judgers to expand the recognition of some specific specifications and identifiers within the organization. For example, the organization's standard application layer transaction boundary control services are all annotated with @AppSvc, or all have AppSvc as the suffix; users can use custom format converters to control the specific format of output products, such as whether the OAS of API metadata is presented in yaml or json format. Users can use custom product filters to control whether specific outputs (such as documents, images, metadata, console output, etc.) are produced, thereby improving operating efficiency according to actual needs. Users can use custom content outputters to control the output location (directory, database, or report to the metadata warehouse through API).

[0081] In an optional embodiment, the flowchart of code scanning is as follows Figure 4 As shown, the source code is input into the code filter. The code filter is used to perform preliminary filtering on various source code files in the source code project, and only processes those source codes that need attention, thereby improving the scanning efficiency. After all, the syntax analysis of each file consumes computing power, and the content that is not of concern is directly ignored.

[0082] The framework scans the basic information of all source code files, and combines built-in or user-customized code filters to ignore files that are not of interest, leaving only files of interest after filtering. The basic definition of the filter is relatively simple. You only need to implement the filter interface of the framework and implement an interface: return the file name suffix of interest. (Example: for example, Java code filter with .java suffix, XML file filter with .xml suffix, configuration file filter with .properties suffix); the filter can also implement another advanced interface: return the characteristic content identifier in the content of the file of interest, so as to further subdivide the code files filtered by the file name suffix (for example, Java code files containing main function declarations, XML files containing Maven pom files, and properties configuration files containing springboot configuration tags).

[0083] After obtaining the filtered code files, these source code files are parsed into the corresponding abstract syntax tree (AST) model by the corresponding syntax parser. In the process of parsing into the final AST model, users can customize the model identifiers of interest, thereby ignoring the complete AST parsing of irrelevant codes. (Essentially, it is also filtering, the purpose is to save unnecessary computing power as much as possible and make the scanning process more efficient) The identification of this identifier requires a summary model formed based on the preliminary AST parsing results.

[0084] The model identifier judger implements the interface provided by the framework and returns three pieces of information: the type of identifier: such as annotations in Java source code, comment tags (@xxx in Javadoc), certain specific tags in XML, etc.; the location of the identifier: such as annotations or comment tags in Java source code, which may be in classes, interfaces, methods, parameters, or attributes; the value of the identifier: such as the specific annotation name, the name of the comment tag, etc.

[0085] After obtaining the final AST model, it is processed by the code scanner, which is the core logic of the scan. Users can customize their own code scanner. The input is the complete AST model, and the output is the target content analyzed by the scanning logic based on the AST. For example, parsing a Java class analyzes the domain model and data model it represents.

[0086] Defining a code scanner also implements the interface provided by the framework. The core method of the interface is: the input is the complete AST model of the current code syntax parsing result; the output is the content of the product (usually a string containing a specific model in a specific format). It should be noted that the code scanner has two types of input: a single AST model: for example, only for a Java AST; a module scope content, a model collection of several ASTs of a specified type: for example, all Java ASTs under module a, all Java ASTs containing the main function within the entire project, and ASTs of all poms. The output of the code scanner is a collection of several products, which can be one or more. For example, for the same Java AST, the metadata model of the application service and the standard specification model of the API can be analyzed.

[0087] like Figure 4 As shown, the code scanner may include an application service model code scanner, an architecture model code scanner, and an engineering module model code scanner. The application service model code scanner may output API model metadata in the Open API specification standard yaml format and application service model metadata (json format). The architecture model code scanner may output architecture model metadata; the engineering module model code scanner may output engineering module model metadata (IDEA xml format).

[0088] After obtaining the initial product through the code scanner, it may be necessary to perform a schema conversion. Therefore, a format converter can be customized according to the needs. For example, an OAS json format converter can be customized to convert yaml to json. Finally, the product artifact required by the user is obtained.

[0089] In an optional embodiment, after obtaining the product, a flowchart of the corresponding processing process to improve the use efficiency of the product is as follows: Figure 5 As shown, the product filter is similar to the code filter, and the definition is relatively simple. You only need to implement the filter interface of the framework and implement an interface: return the file name suffix to be output. (Example: such as .json suffix, .yaml suffix); the filter can also implement another advanced interface: return the characteristic content identifier in the file content to be output, so as to further subdivide the product file filtered by the file name suffix (Example: the yaml product is a file with a certain suffix of the OAS definition file containing a certain content). Output: refers to the process of synchronizing the scan results to an external system for its use.

[0090] Users can customize their own scan result outputters to synchronize the metasystem in the output file content to a specific target system. For example, a customized outputter can save the output result file to a specified location on the disk; a customized outputter can save the output result file to a specified cloud storage space; a customized outputter can report the output result metamodel to a specified system (for BizWorks applications, the model metadata obtained from code scanning can be reported to the metadata warehouse of the modeling platform for management).

[0091] In the code scanning method provided in Example 1 of the present application, a target code file to be scanned is determined; a target code scanner is obtained based on product requirement information and programming language information corresponding to the target code file, wherein the product requirement information at least includes description information of the product output after scanning the code file; the target code file is parsed and processed by the target code scanner to obtain a target product corresponding to the product requirement information, and the purpose of customizing the scanned product is achieved through the target code scanner corresponding to the product requirement information and the programming language information, thereby achieving the technical effect of improving the flexibility of code scanning, and further solving the technical problem that the code scanning product in the related art can only identify specific products, resulting in relatively low flexibility of code scanning.

[0092] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

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

[0094] Example 2

[0095] According to an embodiment of the present application, a code scanning device for implementing the above-mentioned code scanning method is also provided. Figure 6 As shown, the device includes: a first determining unit 601, a second determining unit 602 and a processing unit 603.

[0096] A first determining unit 601 is used to determine a target code file to be scanned;

[0097] A second determining unit 602 is configured to obtain a target code scanner based on product requirement information and programming language information corresponding to the target code file, wherein the product requirement information at least includes description information of the product output after scanning the code file;

[0098] The processing unit 603 is used to parse the target code file through the target code scanner to obtain the target product corresponding to the product requirement information.

[0099] In the code scanning device provided in the embodiment of the present application, the target code file to be scanned is determined by the first determination unit 601; the second determination unit 602 obtains the target code scanner based on the product requirement information and the programming language information corresponding to the target code file, wherein the product requirement information at least includes the description information of the product output after scanning the code file; the processing unit 603 parses and processes the target code file through the target code scanner to obtain the target product corresponding to the product requirement information, thereby solving the technical problem that the code scanning product in the related art can only identify specific products, resulting in relatively low flexibility of code scanning. Through the target code scanner corresponding to the product requirement information and the programming language information, the purpose of customized scanning products is achieved, thereby achieving the technical effect of improving the flexibility of code scanning.

[0100] Optionally, in the code scanning device provided in the embodiment of the present application, the first determination unit includes: an acquisition module, used to acquire filtering requirement information, wherein the filtering requirement information includes at least: file name suffix information and / or characteristic content identification information in the code file; an input module, used to input the filtering requirement information into the first frame corresponding to the code filter through the code filtering interface to obtain a target code filter; and a scanning module, used to scan the initial code file through the target code filter to obtain a target code file.

[0101] Optionally, in the code scanning device provided in the embodiment of the present application, the second determination unit includes: a matching module, which is used to match the product requirement information, programming language information and description information of multiple code scanners to obtain a matching result; a determination module, which is used to determine the target code scanner based on the code scanner corresponding to the target description information if the matching result indicates that there is a match between the target description information and the product requirement information and the programming language information; and a generation module, which is used to generate the target code scanner based on the product requirement information, programming language information and a template of the code scanner if the matching result indicates that there is no match between the target description information and the product requirement information and the programming language information.

[0102] Optionally, in the code scanning device provided in the embodiment of the present application, the device also includes: a parsing unit, which is used to parse the target code file through a target code scanner to obtain an initial abstract syntax tree corresponding to the target code file before obtaining the target product corresponding to the product requirement information; a screening unit, which is used to screen the initial abstract syntax tree through a model identifier determiner to obtain a target abstract syntax tree; the processing unit includes: a processing module, which is used to parse the target abstract syntax tree through the target code scanner to obtain the target product.

[0103] Optionally, in the code scanning device provided in the embodiment of the present application, the device also includes: an acquisition unit, used to obtain model identification information before filtering the initial abstract syntax tree through the model identification judge to obtain the target abstract syntax tree, wherein the model identification information includes at least: the model identification type, the model identification position and the value corresponding to the model identification; an input unit, used to input the model identification information into the second frame corresponding to the model identification judge through the model identification interface to obtain the model identification judge.

[0104] Optionally, in the code scanning device provided in the embodiment of the present application, the processing module includes: a parsing submodule, used to parse the target abstract syntax tree through the target code scanner to obtain an initial product; a judgment submodule, used to judge whether the format type corresponding to the initial product is the same as the format type in the product requirement information; a conversion submodule, used to convert the format of the initial product based on the format type in the product requirement information through a format converter to obtain a target product if the format type corresponding to the initial product is different from the format type in the product requirement information.

[0105] Optionally, in the code scanning device provided in the embodiment of the present application, the device also includes: a filtering unit, which is used to filter the target product based on the file information required by the target system through a product filter after parsing the target code file through the target code scanner to obtain the target product corresponding to the product requirement information, so as to obtain filtered product information, wherein the target system is the application system of the target product; and an output unit, which is used to output the filtered product information to the target location corresponding to the location information of the target system call file through a content outputter.

[0106] It should be noted that the first determination unit 601, the second determination unit 602 and the processing unit 603 described above correspond to steps S201 to S203 in the first embodiment, and the three units and the corresponding steps implement the same examples and application scenarios, but are not limited to the contents disclosed in the first embodiment. It should be noted that the above modules, as part of the device, can be run in the computer terminal 10 provided in the first embodiment.

[0107] It should be noted that the preferred implementation scheme involved in the above embodiments of the present application is the same as the scheme provided in Example 1, as well as the application scenario and implementation process, but is not limited to the scheme provided in Example 1.

[0108] Example 3

[0109] The embodiment of the present application may provide an electronic device, which may be any electronic device in an electronic device terminal group. Optionally, in this embodiment, the electronic device may also be replaced by a terminal device such as a mobile terminal.

[0110] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.

[0111] In this embodiment, the above-mentioned electronic device can execute the program code of the following steps in the code scanning method: determine the target code file to be scanned; obtain a target code scanner based on product requirement information and programming language information corresponding to the target code file, wherein the product requirement information at least includes description information of the product output after scanning the code file; parse and process the target code file through the target code scanner to obtain a target product corresponding to the product requirement information.

[0112] The above-mentioned electronic device can execute the program code of the following steps in the code scanning method: determining the target code file to be scanned includes: obtaining filtering requirement information, wherein the filtering requirement information at least includes: file name suffix information and / or characteristic content identification information in the code file; inputting the filtering requirement information into the first frame corresponding to the code filter through the code filtering interface to obtain the target code filter; scanning the initial code file through the target code filter to obtain the target code file.

[0113] The above-mentioned electronic device can execute the program code of the following steps in the code scanning method: based on the product requirement information and the programming language information corresponding to the target code file, obtaining the target code scanner includes: matching the product requirement information, the programming language information and the description information of multiple code scanners to obtain a matching result; if the matching result indicates that there is a match between the target description information and the product requirement information and the programming language information, then determining the target code scanner based on the code scanner corresponding to the target description information; if the matching result indicates that there is no match between the target description information and the product requirement information and the programming language information, then generating the target code scanner based on the product requirement information, the programming language information and the template of the code scanner.

[0114] The above-mentioned electronic device can execute the program code of the following steps in the code scanning method: before parsing the target code file through the target code scanner to obtain the target product corresponding to the product requirement information, the method also includes: parsing the target code file through the syntax parser to obtain the initial abstract syntax tree corresponding to the target code file; screening the initial abstract syntax tree through the model identifier judger to obtain the target abstract syntax tree; parsing the target code file through the target code scanner to obtain the target product corresponding to the product requirement information includes: parsing the target abstract syntax tree through the target code scanner to obtain the target product.

[0115] The above-mentioned electronic device can execute the program code of the following steps in the code scanning method: before the initial abstract syntax tree is screened by the model identification judge to obtain the target abstract syntax tree, the method also includes: obtaining model identification information, wherein the model identification information at least includes: model identification type, model identification position and value corresponding to the model identification; inputting the model identification information into the second frame corresponding to the model identification judge through the model identification interface to obtain the model identification judge.

[0116] The above-mentioned electronic device can execute the program code of the following steps in the code scanning method: parsing the target abstract syntax tree through the target code scanner to obtain the target product includes: parsing the target abstract syntax tree through the target code scanner to obtain the initial product; judging whether the format type corresponding to the initial product is the same as the format type in the product requirement information; if the format type corresponding to the initial product is different from the format type in the product requirement information, then converting the format of the initial product based on the format type in the product requirement information through the format converter to obtain the target product.

[0117] The above-mentioned electronic device can execute the program code of the following steps in the code scanning method: after parsing the target code file through the target code scanner to obtain the target product corresponding to the product requirement information, the method also includes: filtering the target product based on the file information required by the target system through the product filter to obtain the filtered product information, wherein the target system is the application system of the target product; outputting the filtered product information to the target position corresponding to the location information of the target system call file through the content outputter.

[0118] Optionally, Figure 7 is a structural block diagram of an electronic device according to an embodiment of the present application. Figure 7 As shown, the electronic device 70 may include: one or more ( Figure 7 Only one is shown in the figure) processor 702, memory 704. The electronic device 70 may also include a storage controller, through which the memory 704 is controlled and managed; the electronic device 70 may also include a peripheral interface, through which the radio frequency module, audio module and display screen are connected.

[0119] Among them, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the code scanning method and device in the embodiment of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, realizing the above-mentioned code scanning method. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the electronic device 70 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0120] The processor can call the information and application stored in the memory through the transmission device to execute the following steps: determine the target code file to be scanned; obtain the target code scanner based on the product requirement information and the programming language information corresponding to the target code file, wherein the product requirement information at least includes the description information of the product output after scanning the code file; parse the target code file through the target code scanner to obtain the target product corresponding to the product requirement information.

[0121] Optionally, the processor may also execute the following program code steps: determining the target code file to be scanned includes: obtaining filtering requirement information, wherein the filtering requirement information includes at least: file name suffix information and / or characteristic content identification information in the code file; inputting the filtering requirement information into the first frame corresponding to the code filter through the code filtering interface to obtain the target code filter; scanning the initial code file through the target code filter to obtain the target code file.

[0122] Optionally, the processor may also execute the program code of the following steps: based on the product requirement information and the programming language information corresponding to the target code file, obtaining the target code scanner includes: matching the product requirement information, the programming language information and the description information of multiple code scanners to obtain a matching result; if the matching result indicates that there is a match between the target description information and the product requirement information and the programming language information, then determining the target code scanner based on the code scanner corresponding to the target description information; if the matching result indicates that there is no match between the target description information and the product requirement information and the programming language information, then generating the target code scanner based on the product requirement information, the programming language information and the template of the code scanner.

[0123] Optionally, the processor may also execute the program code of the following steps: before parsing the target code file through the target code scanner to obtain the target product corresponding to the product requirement information, the method also includes: parsing the target code file through the syntax parser to obtain the initial abstract syntax tree corresponding to the target code file; screening the initial abstract syntax tree through the model identifier judger to obtain the target abstract syntax tree; parsing the target code file through the target code scanner to obtain the target product corresponding to the product requirement information includes: parsing the target abstract syntax tree through the target code scanner to obtain the target product.

[0124] Optionally, the processor may also execute the program code of the following steps: before filtering the initial abstract syntax tree through the model identifier judge to obtain the target abstract syntax tree, the method also includes: obtaining model identification information, wherein the model identification information includes at least: model identification type, model identification position and value corresponding to the model identification; inputting the model identification information into the second frame corresponding to the model identifier judge through the model identification interface to obtain the model identifier judge.

[0125] Optionally, the processor may also execute the program code of the following steps: parsing the target abstract syntax tree through a target code scanner to obtain a target product, including: parsing the target abstract syntax tree through a target code scanner to obtain an initial product; determining whether the format type corresponding to the initial product is the same as the format type in the product requirement information; if the format type corresponding to the initial product is different from the format type in the product requirement information, converting the format of the initial product based on the format type in the product requirement information through a format converter to obtain a target product.

[0126] Optionally, the processor may also execute the program code of the following steps: after parsing the target code file through the target code scanner to obtain the target product corresponding to the product requirement information, the method further includes: filtering the target product based on the file information required by the target system through the product filter to obtain the filtered product information, wherein the target system is the application system of the target product; and outputting the filtered product information to the target location corresponding to the location information of the target system call file through the content outputter.

[0127] It can be understood by those skilled in the art that Figure 7 The structure shown is for illustration only, and the electronic device 70 may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID), a PAD, or other terminal devices. Figure 7The structure of the electronic device is not limited. Figure 7 More or fewer components (such as network interfaces, display devices, etc.) shown in, or with Figure 7 Different configurations are shown.

[0128] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0129] Example 4

[0130] An embodiment of the present application further provides a computer-readable storage medium. Optionally, in this embodiment, the computer program product may be used to store the program code executed by the code scanning method provided in the first embodiment.

[0131] Example 5

[0132] The embodiment of the present application further provides a computer program product. Optionally, in this embodiment, the computer program product can be used to store the program code executed by the code scanning method provided in the first embodiment.

[0133] Optionally, in this embodiment, the computer program product may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group.

[0134] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0135] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0136] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0137] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0138] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0139] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc., which can store program code.

[0140] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A code scanning method, characterized in that: include: Determine the target code file to be scanned; Based on the product requirement information and the programming language information corresponding to the target code file, a target code scanner is obtained, wherein the product requirement information at least includes description information of the product output after scanning the code file; The target code file is parsed by the target code scanner to obtain a target product corresponding to the product requirement information; Wherein, the product output after scanning the code file is the metadata of the target code file; Based on the product requirement information and the programming language information corresponding to the target code file, obtaining the target code scanner includes: Matching the product requirement information, the programming language information, and description information of multiple code scanners to obtain a matching result; If the matching result indicates that there is a match between the target description information and the product requirement information and the programming language information, determining the target code scanner according to the code scanner corresponding to the target description information; If the matching result indicates that there is no target description information that matches the product requirement information and the programming language information, the target code scanner is generated according to the product requirement information, the programming language information and a template of the code scanner.

2. The method according to claim 1, characterized in that: Determine the target code files to be scanned include: Acquire filtering requirement information, wherein the filtering requirement information at least includes: file name suffix information and / or characteristic content identification information in the code file; Inputting the filtering requirement information into a first frame corresponding to the code filter through a code filtering interface to obtain a target code filter; The target code file is obtained by scanning the initial code file through the target code filter.

3. The method according to claim 1, characterized in that: Before the target code file is parsed by the target code scanner to obtain the target product corresponding to the product requirement information, the method further includes: Parsing the target code file by a syntax parser to obtain an initial abstract syntax tree corresponding to the target code file; The initial abstract syntax tree is screened by a model identification judger to obtain a target abstract syntax tree; The target code file is parsed by the target code scanner to obtain the target product corresponding to the product requirement information, including: The target abstract syntax tree is parsed by the target code scanner to obtain the target product.

4. The method according to claim 3, characterized in that Before the initial abstract syntax tree is screened by the model identification determiner to obtain the target abstract syntax tree, the method further includes: Acquire model identification information, wherein the model identification information at least includes: model identification type, model identification position and value corresponding to the model identification; The model identification information is input into a second frame corresponding to the model identification determiner through a model identification interface to obtain the model identification determiner.

5. The method according to claim 3, characterized in that: The target code scanner is used to parse the target abstract syntax tree to obtain the target product, including: Parsing the target abstract syntax tree by the target code scanner to obtain an initial product; Determining whether the format type corresponding to the initial product is the same as the format type in the product requirement information; If the format type corresponding to the initial product is different from the format type in the product requirement information, the format of the initial product is converted based on the format type in the product requirement information by a format converter to obtain the target product.

6. The method according to any one of claims 1 to 5, characterized in that After the target code file is parsed by the target code scanner to obtain the target product corresponding to the product requirement information, the method further includes: Filtering the target product based on file information required by a target system through a product filter to obtain filtered product information, wherein the target system is an application system of the target product; The filtered product information is output to a target location corresponding to the location information of the target system call file through a content output device.

7. A code scanning device, characterized in that: include: A first determining unit, used to determine a target code file to be scanned; A second determining unit, configured to obtain a target code scanner based on product requirement information and programming language information corresponding to the target code file, wherein the product requirement information at least includes description information of a product output after scanning the code file; A processing unit, configured to parse the target code file through the target code scanner to obtain a target product corresponding to the product requirement information; Wherein, the product output after scanning the code file is the metadata of the target code file; The second determination unit includes: a matching module, which is used to match the product requirement information, the programming language information and the description information of multiple code scanners to obtain a matching result; a determination module, which is used to determine the target code scanner based on the code scanner corresponding to the target description information if the matching result indicates that there is a match between the target description information and the product requirement information and the programming language information; and a generation module, which is used to generate the target code scanner based on the product requirement information, the programming language information and the template of the code scanner if the matching result indicates that there is no match between the target description information and the product requirement information and the programming language information.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the storage medium is located is controlled to execute the code scanning method according to any one of claims 1 to 6.

9. An electronic device, characterized in that: include: A memory storing an executable program; A processor, configured to run the program, wherein the program executes the code scanning method according to any one of claims 1 to 6 when running.

10. A computer program product, characterized in that The computer program product comprises a stored computer program, and when the computer program is executed by a processor, the code scanning method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Code quality control method and device, computer equipment and storage medium

    CN110928780A

  • Code review method and device

    CN116775483A