A component reference authenticity identification method and device based on SCA
By obtaining and storing the function signatures of third-party components in the SCA tool and judging component references in combination with the scanning results, the high cost and complexity problems brought about by SCA tool detection are solved, and the authenticity recognition of component references is realized, and project governance is reduced. cost.
Patent Information
- Application Number
- CN202411128482.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2044-08-16
AI Technical Summary
Existing SCA tools cause excessive cost and complexity in project governance when detecting third-party components, especially when dealing with deep component dependencies, require a lot of time and effort.
By obtaining the function signature in the package management center warehouse, storing it in the software component analysis knowledge base, and scanning and parsing the detection resources with SCA tools, determining whether the component is truly referenced, and generating component reference information, including reference status and source code line count .
It reduces the cost and complexity of user governance projects, improves the efficiency of identification of component reference authenticity, and reduces unnecessary analysis and processing burden.
Smart Images

Figure CN118642973B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software vulnerability detection, and in particular to a component reference authenticity identification method and device based on SCA. Background Art
[0002] With the rapid development of technology and the prevalence of open source culture, the extensive use of third-party components and open source libraries in software projects has become the norm, which has brought great convenience and efficiency improvement to software development, but also introduced complex security and compliance issues. In order to meet this challenge, Software Composition Analysis (SCA) tools came into being.
[0003] The SCA tool focuses on detecting and analyzing third-party components and open source libraries directly or indirectly referenced in software projects. It deeply scans the code base and build process to reveal all components used in the project and their version information, greatly enhancing the development team's ability to understand software components, so that potential security vulnerabilities, license compliance issues and other risks related to third-party components can be discovered and managed in a timely manner.
[0004] However, the breadth and depth of its scanning results also bring some challenges. Specifically, SCA scanning often reveals a large number of deep component dependencies, which include not only components directly introduced by users, but also other indirect components on which these components depend. This requires users to spend more time and energy to analyze and process component information that is not directly introduced by them, increasing the cost and complexity of project governance. Summary of the invention
[0005] The purpose of the present invention is to provide a component reference authenticity identification method and device based on SCA, so as to solve the problems of high project management cost and high complexity caused by using SCA tools to perform third-party component detection in the prior art.
[0006] To achieve the above objectives, this application adopts the following technical solutions:
[0007] The present invention provides a component reference authenticity identification method based on SCA, comprising the following steps:
[0008] Obtain the function signatures of all third-party components in the package management center repository, and store all the function signatures in the software component analysis knowledge base;
[0009] Using a software component analysis tool to perform a regular scan on the resources to be detected, and obtain the component names and version numbers of all called components in the resources to be detected;
[0010] Determine the file type of the resource to be detected, and select a file analysis method that matches the file type to parse the resource to be detected to obtain a list of third-party functions called by the resource;
[0011] Based on the function signature, component name, version number and third-party function list, it is determined whether each of the called components is actually referenced in the resource to be detected, and component reference information is generated according to the determination result.
[0012] Preferably, the file types include product files and source code files;
[0013] The knowledge base also stores the component name and version number of the third-party component corresponding to each function signature.
[0014] Preferably, determining the file type of the resource to be detected and selecting a file analysis method matching the file type to parse the resource to be detected includes:
[0015] When the resource to be detected is a product file, the product file is parsed using a bytecode analysis framework.
[0016] Preferably, the step of parsing the product file using a bytecode analysis framework includes:
[0017] Extracting the processing logic of the bytecode in the bytecode analysis framework and encapsulating the processing logic, wherein the processing logic includes a ClassVistor method for reading class information and a MethodVistor method for reading function information;
[0018] The encapsulated processing logic is statically run to perform bytecode-like reading and analysis on the product file to obtain signature information of each third-party function called by the product file.
[0019] Preferably, determining the file type of the resource to be detected and selecting a file analysis method matching the file type to parse the resource to be detected includes:
[0020] When the resource to be detected is a source code file, a custom static analysis engine is used to parse the source code file.
[0021] Preferably, the step of parsing the source code file using a custom static analysis engine includes:
[0022] Input the source code file into a custom static analysis engine and output a code property graph;
[0023] The code attribute graph is searched and queried to obtain signature information of each third-party function called by the source code file.
[0024] Preferably, judging whether each of the called components is actually referenced in the resource to be detected based on the function signature, component name, version number and third-party function list, and generating component reference information according to the judgment result, includes:
[0025] Match the component name and version number of each called component with the component name and version number of the third-party component corresponding to each function signature. If the match is successful, record the corresponding function signature as the target function signature.
[0026] The third-party function list is searched to determine whether it contains the target function signature. If it does, the called component is determined to be a third-party component that is actually referenced by the resource to be detected, and component reference information is generated. The component reference information includes the reference status, the corresponding source code line number, and the signature information of the third-party function.
[0027] A component reference authenticity identification device based on SCA, comprising:
[0028] A storage module is used to obtain the function signatures of all third-party components in the package management center warehouse and store all the function signatures in the software component analysis knowledge base;
[0029] A scanning module is used to perform a routine scan on the resources to be detected using a software component analysis tool to obtain the component names and version numbers of all called components in the resources to be detected;
[0030] An analysis module, used to determine the file type of the resource to be detected, and select a file analysis method that matches the file type to parse the resource to be detected to obtain a list of third-party functions called by the resource;
[0031] The judgment module is used to judge whether each of the called components is actually referenced in the resource to be detected based on the function signature, component name, version number and third-party function list, and generate component reference information according to the judgment result.
[0032] An electronic device comprises a memory and a processor, wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement a component reference authenticity identification method based on SCA as described in any one of the above.
[0033] A computer-readable storage medium storing a computer program, wherein the computer program enables a computer to implement any one of the above-mentioned component reference authenticity identification methods based on SCA when executed.
[0034] The present invention has the following beneficial effects:
[0035] This application stores the function signatures of third-party components that can be called externally in the SCA knowledge base, and then analyzes the source code / bytecode while the SCA tool scans the user source code / artifact. Then, the method / bytecode call used in the source code / bytecode is found in combination with the SCA tool scanning results (component name, version number), and compared with the function signatures of the third-party components stored in the SCA knowledge base. This can determine whether the components scanned by SCA are actually referenced in the user source code / artifact, thereby reducing the cost and complexity of user governance projects. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 It is a flow chart of a component reference authenticity identification method based on SCA provided by an embodiment of the present invention;
[0037] Figure 2 It is a structural diagram of a component reference authenticity identification device based on SCA provided by an embodiment of the present invention;
[0038] Figure 3 It is a schematic diagram of an electronic device for implementing an SCA-based component reference authenticity identification method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0039] To make the technical solution of the present invention clearer, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. The terms "first", "second", etc. in the claims and specification of the present application are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances. This is only to describe the distinction method adopted when describing objects with the same attributes in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that a process, method, system, product or device containing a series of units is not necessarily limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or devices.
[0040] In one embodiment, Figure 1 As shown, a component reference authenticity identification method based on SCA is provided, comprising the following steps:
[0041] S110, obtaining function signatures of all third-party components in the package management center warehouse, and storing all function signatures in the software component analysis knowledge base;
[0042] S120, using a software component analysis tool to perform a regular scan on the resources to be detected, and obtain component names and version numbers of all called components in the resources to be detected;
[0043] S130, determining the file type of the resource to be detected, and selecting a file analysis method that matches the file type to parse the resource to be detected to obtain a list of third-party functions called by the resource;
[0044] S140: Based on the function signature, component name, version number and third-party function list, determine whether each called component is actually referenced in the resources to be detected, and generate component reference information according to the determination result.
[0045] In this embodiment, the SCA knowledge base is first expanded. Specifically, the function signatures of third-party components are collected in the package management center warehouse, and all the collected function signatures of third-party components are stored in the SCA knowledge base, where the SCA knowledge base refers to a comprehensive knowledge resource including information about SCA technology, practices, tools, best practices, security vulnerability information, and license compatibility, and is intended to provide developers, security teams, compliance officers, etc. with detailed information about third-party components, libraries, and frameworks used in software projects, such as names, version numbers, license types, and known vulnerabilities. The package management center warehouse refers to a centralized system for storing and managing various software packages, library files, and dependencies. It plays an important role in software development, version control, and dependency management, and supports multiple programming languages and frameworks. Common package management center warehouses include the dependency central warehouse Maven CentralRepository corresponding to the Java language, the package registration center npm registry corresponding to the JavaScript language, and the software package index Python Package corresponding to the Python language. Index, etc. Third-party components include fastjson and jackson. Function signature is the identifier of the function, which consists of the function name and parameter type list. It is used to identify and distinguish different functions. For example, com.alibaba.fastjson.JSON.parseObject(java.lang.String) is a function signature in the fastjson component, where com.alibaba.fastjson.JSON refers to the JSON class under the com.alibaba.fastjson package in the Fastjson library. parseObject is a static method, which can also be called the function name, meaning that it can be called directly by the class name JSON without creating an instance of the JSON class. java.lang.String is the parameter type. The entire function signature indicates that the JSON class in the Fastjson library provides a static method parseObject, which accepts a JSON formatted string as input and returns a parsed Java object.
[0046] Next, use the SCA tool to perform a routine scan on the resources to be tested uploaded by the user. It should be noted here that routine scanning refers to the process of using the SCA tool to perform automated analysis and inspection on the resources to be tested, that is, the normal function of the SCA tool, so as to obtain the component names and version numbers of all called components in the resources to be tested, and all component names and version numbers are output in the form of (component name, version number) tuples.
[0047] While the SCA tool performs routine scanning on the resources to be detected, it will also determine the corresponding file analysis method based on the file type of the resources to be detected to determine the authenticity of component references. The file types of the resources to be detected include artifact files and source code files. Artifacts usually refer to various deliverables or products generated during software development and deployment, which may include source code, binary executable files, library files, container images, and software packages. In Java, artifact files are files with extensions such as .jar or .war, while source code files are uncompiled source code files, which have an extension of .java in Java. Therefore, if the uploaded resources to be detected are in the format of .jar or .war, they are determined to be artifact files. If the uploaded resources to be detected are in the format of .java, they are determined to be source code files.
[0048] When the resource to be detected is a product file, because the product file actually contains a .class bytecode binary file, the bytecode analysis framework will be used to parse it here to obtain the signature information of all third-party functions called by the product file, and then generate a third-party function list based on the signature information of all third-party functions called by it; when the resource to be detected is a source code file, it will be parsed using a custom static analysis engine to obtain the signature information of all third-party functions called by the source code file, and generate the corresponding third-party function list accordingly.
[0049] Finally, the component names and version numbers of all called components in the resource to be tested are compared with the component names and version numbers of the third-party components corresponding to the function signatures stored in the SCA knowledge base, and the comparison results are combined with the generated third-party function list to determine the third-party components that are actually referenced in the resource to be tested. Component reference information is then generated based on this and displayed on the SCA tool interface.
[0050] This embodiment stores the function signatures of third-party components that can be called externally in the SCA knowledge base, and then analyzes the source code / bytecode while the SCA tool scans the user source code / artifact. The method / bytecode call used in the source code / bytecode is found in combination with the SCA tool scanning results (component name, version number), and compared with the function signatures of the third-party components stored in the SCA knowledge base. This can determine whether the components scanned by SCA are actually referenced in the user source code / artifact.
[0051] In some embodiments, the artifact file is parsed using a bytecode analysis framework, including:
[0052] Extract the bytecode processing logic in the bytecode analysis framework and encapsulate the processing logic, which includes the ClassVistor method for reading class information and the MethodVistor method for reading function information;
[0053] The encapsulated processing logic is run statically to read and analyze the product file in the form of bytecode, and obtain the signature information of each third-party function called by the product file.
[0054] Traditional static analysis cannot process bytecode files, and the dynamic analysis environment is not suitable for conventional SCA scanning. Therefore, this embodiment proposes a product file analysis method that combines static analysis and dynamic analysis, that is, the bytecode processing framework ASM commonly used for dynamic analysis is applied to static analysis. In view of the fact that traditional ASM usually requires Java to be in a running state, it is improved here. Specifically, the processing logic of the bytecode in ASM is extracted, and the processing logic includes a ClassVistor method for reading class information and a MethodVistor method for reading function information. These methods are extracted and encapsulated, and then the encapsulated methods are statically run to parse the product file, so that the signature information of all third-party functions called in the product file can be obtained. For example, the signature information of the third-party function obtained is com.alibaba.fastjson.JSON.parseObject(java.lang.String). Of course, the third-party functions here are all valid call functions after deduplication. For example, there is a call to function a in file A and there is also a call to function a in file B. Only one call to function a is counted, and a third-party function list corresponding to the product file is generated accordingly. The third-party function list records the signature information of all third-party functions effectively called by the product file. This embodiment can accurately obtain the call list of third-party functions in the product file only through static analysis, thereby enhancing the analysis capability of the product file.
[0055] In some embodiments, the source code file is parsed using a custom static analysis engine, including:
[0056] Input the source code file into the custom static analysis engine and output the code property graph;
[0057] Search and query the code property graph to obtain the signature information of each third-party function called by the source code file.
[0058] Traditional static analysis requires lexical analysis, grammatical analysis, and semantic analysis of the source code to generate a code syntax tree. However, in this embodiment, when the resource to be detected is a source code file, the source code file is input into a custom static analysis engine developed based on the joern framework to directly obtain a code property graph. The custom static analysis engine is developed in the Java language and abstracts the code in the source code file. Specifically, a structure in the code, such as a statement or expression, is abstracted into a node, and the signature information is a part of each structure, i.e., a node. The relationship between these structures is abstracted into edges, and the call information is the edge. The execution path of each statement in the code is abstracted into a control flow, and the execution of a statement that depends on the data in another statement is abstracted into data dependency, and the signature information is analyzed using method in this process. Line marking, use call to mark the calling information, and finally integrate them to get the code attribute graph, without lexical analysis, syntax analysis and semantic analysis. The code attribute graph contains the signature information and calling information of all third-party functions called by the source code file. Therefore, by searching and querying the code attribute graph, the signature information, calling information and corresponding source code of each third-party function can be obtained. For example, the signature information of the third-party function obtained is com.alibaba.fastjson.JSON.parseObject(java.lang.String), and the user method that calls the third-party function determined by the mark of the calling information is com.xxx.xxx(java.lang.String), and a third-party function list is generated accordingly.
[0059] In some embodiments, based on the function signature, component name, version number and third-party function list, it is determined whether each called component is actually referenced in the resource to be detected, and component reference information is generated according to the determination result, including:
[0060] Match the component name and version number of each called component with the component name and version number of the third-party component corresponding to each function signature. If the match is successful, record the corresponding function signature as the target function signature.
[0061] The third-party function list is searched to determine whether it contains the target function signature. If it does, the called component is determined to be a third-party component that is actually referenced by the resource to be detected, and component reference information is generated. The component reference information includes the reference status, the corresponding source code line number, and the signature information of the third-party function.
[0062] Compare the component name and version number of each called component in the resource to be detected with the component name and version number of the third-party component corresponding to each function signature stored in the SCA knowledge base. If there is a match, the corresponding function signature is recorded as the target function signature, and the corresponding called component is the third-party component. For example, the component name and version number tuple corresponding to a called component is (Fastjson, 1.1.41). If the component name and version number tuple corresponding to a function signature stored in the SCA knowledge base is exactly the same as that of the third-party component, then the calling component is the third-party component, and its corresponding function signature is the target function signature. Then search for the target function signature in the third-party function list. If it is successfully found, the third-party component is in the resource to be detected. If the target function signature is com.alibaba.fastjson.JSON.parseObject(java.lang.String), the signature is searched in the third-party function list. If it is successfully found, it means that the corresponding third-party component is actually referenced in the resource to be detected. If it cannot be found, it means that the corresponding third-party component is not actually referenced. Then, the number of source code lines corresponding to each actually referenced third-party component and the signature information of the third-party function in the source code are obtained to generate component reference information. The component reference information also includes the reference status, that is, whether the third-party component is actually referenced by the resource to be detected, and is displayed on the interface of the SCA tool together with the component risk.
[0063] This embodiment adds a component reference authenticity judgment function to the conventional scanning of the SCA tool, so that the SCA tool can directly determine the third-party components introduced by the user, thereby reducing the cost and complexity of the user's project management.
[0064] In some embodiments, Figure 2 As shown, a component reference authenticity identification device based on SCA is provided, comprising:
[0065] A storage module is used to obtain the function signatures of all third-party components in the package management center warehouse and store all the function signatures in the software component analysis knowledge base;
[0066] A scanning module is used to perform a routine scan on the resources to be detected using a software component analysis tool to obtain the component names and version numbers of all called components in the resources to be detected;
[0067] An analysis module, used to determine the file type of the resource to be detected, and select a file analysis method that matches the file type to parse the resource to be detected to obtain a list of third-party functions called by the resource;
[0068] The judgment module is used to judge whether each of the called components is actually referenced in the resource to be detected based on the function signature, component name, version number and third-party function list, and generate component reference information according to the judgment result.
[0069] The above-mentioned device can execute the methods provided by all the aforementioned embodiments of the present invention, and has the corresponding functional modules and beneficial effects for executing the above-mentioned methods. For technical details not fully described in this embodiment, please refer to the methods provided by all the aforementioned embodiments of the present invention.
[0070] In some embodiments, Figure 3 As shown, a computer device is provided, including a memory, a processor and a computer program stored in the memory, and the processor executes the computer program to implement the steps of the above-mentioned SCA-based component reference authenticity identification method.
[0071] The computer device can be a server or a terminal. The computer device includes a processor, a memory, an input / output interface (I / O for short) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a component reference authenticity identification method based on SCA is implemented.
[0072] This embodiment further provides a computer-readable storage medium on which a computer program or instruction is stored. When the computer program or instruction is executed by a processor, the steps of the above-mentioned component reference authenticity identification method based on SCA are implemented.
[0073] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0074] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the patent of the present invention. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A component reference authenticity identification method based on SCA, It is characterized in that The following steps are involved: Obtain the function signatures of all third-party components in the package management center repository, and store all the function signatures in the software component analysis knowledge base; Using a software component analysis tool to perform a regular scan on the resources to be detected, and obtain the component names and version numbers of all called components in the resources to be detected; Determine the file type of the resource to be detected, and select a file analysis method that matches the file type to parse the resource to be detected to obtain a list of third-party functions called by the resource; Based on the function signature, component name, version number and third-party function list, determine whether each of the called components is actually referenced in the resource to be detected, and generate component reference information according to the determination result; Wherein, judging whether each of the called components is actually referenced in the resource to be detected based on the function signature, component name, version number and third-party function list, and generating component reference information according to the judgment result, includes: Match the component name and version number of each called component with the component name and version number of the third-party component corresponding to each function signature. If the match is successful, record the corresponding function signature as the target function signature. The third-party function list is searched to determine whether it contains the target function signature. If it does, the called component is determined to be a third-party component that is actually referenced by the resource to be detected, and component reference information is generated. The component reference information includes the reference status, the corresponding source code line number, and the signature information of the third-party function.
2. According to the SCA-based component reference authenticity identification method of claim 1, It is characterized in that The file types include product files and source code files; The knowledge base also stores the component name and version number of the third-party component corresponding to each function signature.
3. According to the SCA-based component reference authenticity identification method of claim 2, It is characterized in that The determining the file type of the resource to be detected and selecting a file analysis method matching the file type to parse the resource to be detected includes: When the resource to be detected is a product file, the product file is parsed using a bytecode analysis framework.
4. According to the SCA-based component reference authenticity identification method of claim 3, It is characterized in that The utilizing the bytecode analysis framework to parse the product file includes: Extracting the processing logic of the bytecode in the bytecode analysis framework and encapsulating the processing logic, wherein the processing logic includes a ClassVistor method for reading class information and a MethodVistor method for reading function information; The encapsulated processing logic is statically run to perform bytecode-like reading and analysis on the product file to obtain signature information of each third-party function called by the product file.
5. According to the SCA-based component reference authenticity identification method of claim 2, It is characterized in that The determining the file type of the resource to be detected and selecting a file analysis method matching the file type to parse the resource to be detected includes: When the resource to be detected is a source code file, a custom static analysis engine is used to parse the source code file.
6. The component reference authenticity identification method based on SCA according to claim 5, It is characterized in that The using a custom static analysis engine to parse the source code file includes: Input the source code file into a custom static analysis engine and output a code property graph; The code attribute graph is searched and queried to obtain signature information of each third-party function called by the source code file.
7. A component reference authenticity identification device based on SCA, It is characterized in that include: A storage module is used to obtain the function signatures of all third-party components in the package management center warehouse and store all the function signatures in the software component analysis knowledge base; A scanning module is used to perform a routine scan on the resources to be detected using a software component analysis tool to obtain the component names and version numbers of all called components in the resources to be detected; An analysis module, used to determine the file type of the resource to be detected, and select a file analysis method that matches the file type to parse the resource to be detected to obtain a list of third-party functions called by the resource; A judgment module, used to judge whether each of the called components is actually referenced in the resource to be detected based on the function signature, component name, version number and third-party function list, and generate component reference information according to the judgment result; Wherein, judging whether each of the called components is actually referenced in the resource to be detected based on the function signature, component name, version number and third-party function list, and generating component reference information according to the judgment result, includes: Match the component name and version number of each called component with the component name and version number of the third-party component corresponding to each function signature. If the match is successful, record the corresponding function signature as the target function signature. The third-party function list is searched to determine whether it contains the target function signature. If it does, the called component is determined to be a third-party component that is actually referenced by the resource to be detected, and component reference information is generated. The component reference information includes the reference status, the corresponding source code line number, and the signature information of the third-party function.
8. An electronic device, It is characterized in that It comprises a memory and a processor, wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement an SCA-based component reference authenticity identification method as described in any one of claims 1 to 6.
9. A computer-readable storage medium storing a computer program, It is characterized in that The computer program enables a computer to implement an SCA-based component reference authenticity identification method as claimed in any one of claims 1 to 6 when executed.
