Interface calling detection method and device, equipment and storage medium
By scanning the target instruction information in the bytecode file, the source SDK of the sensitive API calls is automatically determined, which solves the problem of low detection efficiency caused by manual troubleshooting in the existing technology, and realizes efficient sensitive API detection.
Patent Information
- Application Number
- CN202411099912.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-09
- Publication Date
- 2024-11-19
AI Technical Summary
In the prior art, the method of detecting sensitive API calls in third-party SDKs requires manual inspection by developers or testers, resulting in poor detection results, time-consuming and labor-consuming, and it is impossible to directly determine the source of sensitive API calls.
By obtaining the bytecode file of the code file to be detected, scanning the target instructions matching the preset instruction set, obtaining the target instruction information, including the source path of the target instruction, automatically output the target instruction information, and determining the source SDK of the sensitive API call.
Without intruding into the code file to be detected, the source path of target instructions is automatically output, reducing the cost of manual detection, improving the detection efficiency and effectiveness of sensitive API calls, and avoiding economic losses.
Smart Images

Figure CN118981318A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to an interface call detection method, device, equipment and storage medium. Background Art
[0002] With the rapid development of mobile Internet and its integration into people's lives, the protection of sensitive information such as commercial secrets and personal privacy has become extremely important. Many applications (Application, APP) use third-party software development kits (Software Development Kit, SDK) during development. Some third-party SDKs may have risks, such as accessing device resources such as network, SMS, contacts, location and other sensitive information through sensitive application programming interfaces (Application Programming Interface, API), that is, sensitive APIs to operate these resources to achieve malicious purposes. Therefore, the detection of sensitive API calls in SDK is an important part of ensuring APP security. In related technologies, APP packages with integrated SDKs are usually decompiled to generate specific types of files (such as smali files) to detect whether there are sensitive API calls. However, this method cannot directly determine the source SDK of sensitive API calls, and requires developers or testers to further check risky SDKs, which is time-consuming and labor-intensive, resulting in poor detection of sensitive API calls. Summary of the invention
[0003] The embodiments of the present application provide a sensitive application programming interface information method, device and storage medium to automatically determine the source SDK of sensitive API calls and improve the detection effect of sensitive API calls.
[0004] In order to solve the above technical problems, this application is implemented as follows: In a first aspect, an embodiment of the present application provides an interface call detection method, comprising: Get the code file to be tested; Obtain the bytecode file generated in the process of compiling the code file to be detected based on JAVA; Scanning a target instruction matching a preset instruction set from a bytecode file, the preset instruction set being a set of preset instructions corresponding to sensitive application programming interface calls; When the target instruction is scanned, target instruction information associated with the target instruction is obtained from the bytecode file; Output target instruction information, the target instruction information includes the source path of the target instruction.
[0005] In a second aspect, the embodiment of the present application further provides an interface call detection device, including: A first acquisition module is used to acquire a code file to be detected; The second acquisition module is used to acquire the bytecode file generated in the process of compiling the code file to be detected; A scanning module, used for scanning a target instruction matching a preset instruction set from a bytecode file, wherein the preset instruction set includes a preset instruction for calling a sensitive application programming interface; A third acquisition module is used to acquire target instruction information associated with the target instruction from the bytecode file when the target instruction is scanned; The output module is used to output target instruction information, and the target instruction information includes the source path of the target instruction.
[0006] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the above method is implemented when the processor executes the computer program.
[0007] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores a computer program, and the computer program implements the above method when executed by a processor.
[0008] The interface call detection method provided in the embodiment of the present application obtains the code file to be detected, obtains the bytecode file generated in the process of compiling the code file to be detected, scans the target instruction matching the preset instruction set from the bytecode file, obtains the target instruction information associated with the target instruction from the bytecode file when the target instruction is scanned, and outputs the target instruction information, wherein the preset instruction set includes preset instructions for calling sensitive application programming interfaces, and the target instruction information includes the source path of the target instruction. The embodiment of the present application can scan the target instruction corresponding to the sensitive API call through the preset instruction set, and then obtain the situation of the sensitive API call, and can obtain the source path of the target instruction through the target instruction information associated with the target instruction, without the need for the user to manually locate the code file to be detected with the sensitive API call. In other words, the embodiment of the present application can automatically output the target instruction information including the source path of the target instruction without intruding the code file to be detected, thereby reducing the cost of manual detection of risks and hidden dangers such as sensitive APIs, greatly improving the detection efficiency and detection effect of sensitive API calls, and avoiding and reducing the economic losses of companies and users caused by sensitive API risks and hidden dangers. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0010] Figure 1 A flowchart of an interface call detection method provided in an embodiment of the present application; Figure 2 A working principle diagram of a sensitive application programming interface information method in a specific application example; Figure 3 A schematic diagram of the structure of an interface call detection device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0011] In order to make the technical problems, technical solutions and advantages to be solved by the application clearer, the following will be described in detail in conjunction with the accompanying drawings and specific embodiments. In the following description, specific details such as specific configurations and components are provided only to help fully understand the embodiments of the application. Therefore, it should be clear to those skilled in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the application. In addition, for clarity and brevity, the description of known functions and structures has been omitted.
[0012] Unless otherwise defined, the technical terms or scientific terms used in this application shall have the usual meanings understood by persons with ordinary skills in the field to which this application belongs. The words "first", "second" and similar words used in this application do not indicate any order, quantity or importance, but are only used to distinguish different components. Similarly, the words "one" or "an" and similar words do not indicate a quantitative limitation, but indicate the presence of at least one.
[0013] like Figure 1 As shown, an interface call detection method provided by an embodiment of the present application includes: Step 101, obtaining a code file to be detected; Step 102, obtaining a bytecode file generated during the process of compiling the code file to be detected; Step 103, scanning the bytecode file for target instructions that match a preset instruction set, where the preset instruction set includes preset instructions for calling a sensitive application programming interface; Step 104, when the target instruction is scanned, obtaining target instruction information associated with the target instruction from the bytecode file; Step 105, outputting target instruction information, where the target instruction information includes the source path of the target instruction.
[0014] The sensitive application programming interface (API) call detection method provided in the embodiment of the present application can be applied to electronic devices such as servers, personal computers, mobile terminals, etc., without specific limitation here. To simplify the description, the following mainly takes the electronic device as the execution subject as an example to introduce the method provided in the embodiment of the present application.
[0015] In step 101, the electronic device may obtain a code file to be detected. In some implementations, the code file to be detected may be a single or multiple software development kits (SDKs), or may be other types of engineering source codes, etc. In some examples, the SDK may be in a format such as aar or jar, which is not specifically limited here.
[0016] In some scenarios, the SDK may be provided by a third party, which may contain sensitive API calls. For example, API calls may be used to monitor sensitive information such as address books, phone calls, text messages, user privacy, and the International Mobile Equipment Identity (IMEI) of the device. If these sensitive API calls cannot be detected, user privacy information may be leaked, posing a huge security risk. The embodiments of the present application can detect these sensitive API calls.
[0017] The above-mentioned code file to be detected can be compiled. In some embodiments, the code file to be detected can belong to an Android project or an Android project. In the process of compiling the code file to be detected based on the JAVA language, a class file (.class files) can be generated. By compiling the class file, an executable file format (Dalvik Executable, dex) file can be obtained. Generally speaking, a class file represents a binary file compiled by a JAVA source program through a JAVA compiler and executed by a JAVA virtual machine (Java Virtual Machine, JVM). The bytecode file is the instruction format of the JVM operation, which is a readable bytecode instruction file, allowing users to clearly know the execution instructions displayed after the JAVA file is compiled into a class file.
[0018] In step 102, the process of the electronic device compiling the code file to be detected includes the process of compiling the class file to obtain the dex file, wherein the process of compiling the class file into the dex file can be called the project building stage, and the bytecode file can refer to the file obtained by compiling the class file.
[0019] Android's open source tool Gradle for automated project building provides a Transform API that can convert class files into bytecode files during the project building phase and perform operations on bytecode files, such as bytecode instrumentation technology. In some implementations, electronic devices can use bytecode instrumentation technology to perform operations on bytecode files, such as scanning, detection, or modification. Among them, bytecode instrumentation technology can be an operation class of the type AspectJ, ASM, ReDex, or Javassist, which is not specifically limited here.
[0020] In step 103, the electronic device may scan the target instructions matching the preset instruction set from the bytecode file, and the preset instruction set is a set of preset instructions corresponding to the sensitive application programming interface call. For ease of explanation, the preset instructions corresponding to the sensitive application programming interface call may be referred to as sensitive instructions. In this step, the preset instruction set may be a set of pre-set sensitive instructions. For example, in some embodiments, the sensitive instructions may be obtained by pre-compiling the code corresponding to the sensitive API call. During the compilation process, the corresponding preset bytecode file is obtained through bytecode plugging technology, and these preset bytecode files are included in the preset instruction set as sensitive instructions. A variety of different sensitive API calls may correspond to multiple sensitive instructions. Therefore, there may be multiple sensitive instructions in the preset instruction set.
[0021] When the electronic device scans the bytecode file, it can use the preset instruction set to scan the instruction file that is the same as or matches each sensitive instruction in the preset instruction set, that is, the target instruction mentioned above. When the target instruction exists, it can be considered that the instruction that meets the hit strategy is detected from the bytecode file.
[0022] In step 104, when the electronic device scans the target instruction, it can obtain the target instruction information associated with the target instruction through the bytecode file.
[0023] In addition to the target instructions, the bytecode file may also contain target instruction information of the target instruction management class, such as the file name, call location, file path, or number of lines of code corresponding to the target instruction. Through this target instruction information, on the one hand, it can be determined that there are sensitive API calls in the code file to be detected, and on the other hand, the source of the sensitive API call can be determined, such as which SDK it comes from.
[0024] In step 105, the electronic device can output target instruction information to prompt the user that there are sensitive API calls in the code file to be detected. For example, when the SDK is detected for sensitive API calls one by one, this prompt can let the user know that the SDK is at risk. At the same time, the electronic device reflects information such as the file path or the number of lines of code in the target instruction information, so that when multiple SDKs are detected, the specific SDK or code location that is at risk can be located. Accordingly, the above-mentioned file path or number of lines of code and other information can be considered as the source path of the target instruction, and the specific code file to be detected that contains sensitive API calls can be located through the source path of the target instruction included in the target instruction information. To a certain extent, the target instruction information can be considered as the detection result of sensitive API calls.
[0025] The interface call detection method provided in the embodiment of the present application obtains the code file to be detected, obtains the bytecode file generated in the process of compiling the code file to be detected, scans the target instruction matching the preset instruction set from the bytecode file, obtains the target instruction information associated with the target instruction from the bytecode file when the target instruction is scanned, and outputs the target instruction information, wherein the preset instruction set includes preset instructions for calling sensitive application programming interfaces, and the target instruction information includes the source path of the target instruction. The embodiment of the present application can scan the target instruction corresponding to the sensitive API call through the preset instruction set, and then obtain the situation of the sensitive API call, and can obtain the source path of the target instruction through the target instruction information associated with the target instruction, without the need for the user to manually locate the code file to be detected with the sensitive API call. In other words, the embodiment of the present application can automatically output the target instruction information including the source path of the target instruction without intruding the code file to be detected, thereby reducing the cost of manual detection of risks and hidden dangers such as sensitive APIs, greatly improving the detection efficiency and detection effect of sensitive API calls, and avoiding and reducing the economic losses of companies and users caused by sensitive API risks and hidden dangers.
[0026] In some implementations, the preset instruction set can be set according to actual needs. For example, the preset instructions can be sensitive instructions corresponding to traditional sensitive API calls, or API calls of interest set by the user. These API calls of interest can also be considered to belong to the preset instructions corresponding to the sensitive API calls mentioned in the above embodiments to some extent. It can be seen that the embodiments of the present application can greatly meet the user's personalized sensitive API call detection needs.
[0027] In some examples, the target instruction information includes at least one of the following: the file path of the target instruction, the class name of the class file corresponding to the target instruction, the source code file of the target instruction, the number of code lines corresponding to the target instruction, etc. The above target instruction information can better reflect the source path of the target instruction, and the output target instruction information can facilitate users to view the situation of sensitive API calls.
[0028] In some examples, the output target instruction information can be stored or displayed, and the electronic device can output different viewable files as needed. For example, if the target instruction is defined as a risk item, the electronic device can output a list of risk items in each SDK, or the electronic device can input the source SDK of each risk item, etc., to adapt to the different viewing needs of different users and improve the convenience of viewing results.
[0029] In some implementations, a dedicated sensitive API detection platform can be built, which can receive detection code files from, for example, an SDK, and run the interface call detection method provided in the embodiments of the present application. In other words, for a terminal device, it can be connected to the detection platform, and the SDK to be detected can be uploaded to the detection platform to realize sensitive API call detection. At this time, the terminal device and the detection platform can together constitute the above-mentioned electronic device.
[0030] In other implementations, the source code for implementing the sensitive API call scan may be imported into the code file to be detected. In this way, custom detection scanning strategies are supported and the default scanning items can be flexibly extended.
[0031] Optionally, step 103, scanning the target instruction matching the preset instruction set from the bytecode file, includes: Build a detection plug-in. In some examples, the detection plug-in is a Gradle plug-in designed in Groovy, which uses the Gradle Transform mechanism to scan the bytecode files generated in the process of compiling code files based on JAVA; Based on the detection plug-in, the target instructions that match the preset instruction set are scanned from the bytecode file.
[0032] As shown above, Android's open source project automation construction tool Gradle provides a Transform API, which can convert class files into bytecode files during the project construction phase and perform operations on bytecode files, such as bytecode instrumentation technology. In this embodiment, the electronic device can build a detection plug-in, which can scan the bytecode file with the help of the Transform API to obtain target instructions that match the preset instruction set.
[0033] In some implementations, when the access party application (Application, APP) has many historical SDKs and needs to perform comprehensive sensitive API call detection, the source code for implementing sensitive API call scanning can be imported into the Gradle detection plug-in, and the scanning process can be flexibly configured to quickly and conveniently access the sensitive API scanning mechanism for application.
[0034] Combined with some specific application examples, electronic devices can encapsulate all detection scanning logic, including sensitive API call detection, into a custom Gradle detection plug-in. The detection plug-in exposes the control of whether the detection logic is running, the detection strategy configuration, whether to terminate the build when the detection strategy is hit, the detection result storage path and other configuration switches through the Gradle Extension mechanism. A detection task will be automatically started inside the plug-in, and the task will be mounted to the Gradle build task tree. It is agreed that the task must be executed between the class file conversion dex task. When the detection scanning function needs to be enabled, the parameter passing method of the build platform can be manually modified or built. Use the build command gradlew clean assemble -PsafeScans=true or build the configuration file gradle.properties in the root directory of the project to add the safeScans=true property to enable the scanning function. In other words, in this application example, the detection scanning solution for sensitive API calls can be integrated into the build packaging script, so that the entire set of scanning technology can be automatically deployed and run.
[0035] In some application scenarios, the code file to be tested may be a single SDK. In this case, you can perform risk detection on a single SDK through different branches by building an Android project Git project of a Gradle plug-in for the function to be tested.
[0036] In other application scenarios, it may be necessary to simultaneously detect sensitive API calls for multiple code files to be detected, such as multiple SDKs. In this case, the electronic device can build multiple detection plug-ins to scan the bytecode files corresponding to the multiple code files to be detected through multiple detection plug-ins. In this way, the detection efficiency of sensitive API calls can be effectively improved.
[0037] As shown in the above embodiments, sensitive API detection can configure the detection scanning logic, and the configuration information can be reflected in the detection configuration information. When performing sensitive API detection, the electronic device can obtain the detection configuration information and then perform operations that match the detection configuration information.
[0038] For example, in an optional embodiment, outputting target instruction information includes: Get detection configuration information; When the detection configuration information indicates the first configuration, stop compiling the code file to be detected and output target instruction information; When the detection configuration information indicates the second configuration, the target instruction information is output when the compilation of the code file to be detected is completed.
[0039] That is to say, in this embodiment, when the electronic device scans the target instruction, it can choose to stop or continue compiling the code file to be detected according to the detection configuration information.
[0040] Specifically, when the detection configuration information indicates the first configuration, if the electronic device scans the target instruction, it can stop compiling the code to be detected and directly output the target instruction information, so as to avoid the user waiting for a long time for the compilation to be completed; when the detection configuration information indicates the second configuration, the electronic device can normally complete the compilation of the code to be detected, and after the compilation is completed, it uniformly outputs the target instruction information corresponding to each scanned target instruction, so as to facilitate the user to obtain all sensitive API call situations in the code file to be detected.
[0041] Optionally, output target instruction information, including: Obtain the preset instruction information storage path; The target instruction information is output to the instruction information storage path for storage.
[0042] In some examples, the instruction information storage path may be a default or user-set path, and may be directly included in the above-mentioned detection configuration information. When the electronic device scans the target instruction information, it may output the target instruction information to the instruction information storage path for storage, so that the user can view the target instruction information according to the instruction information storage path, thereby improving the convenience of viewing the results.
[0043] Optionally, output target instruction information, including: Call the preset instant messaging tool; The target instruction information is sent to the target object through the preset instant messaging tool.
[0044] In some embodiments, when a detection plug-in is used to detect sensitive API calls, a message differentiation mechanism can be customized and preset in the detection plug-in. This mechanism is compatible with instant messaging tools such as Feishu, Enterprise WeChat, and email currently used by the company. During the scanning process, if an internal operation abnormality occurs or the detection is completed, the developer will be promptly informed through the message distribution mechanism.
[0045] The above-mentioned message differentiation mechanism may include a variety of settings, such as the instant messaging tool to be called, and the target object to be sent through the instant messaging tool, etc. The message differentiation mechanism can be set by the user, and accordingly, the instant messaging tool to be called and the target object can be preset, and the electronic device can call the preset instant messaging tool to send the target instruction information to the target object, so that the electronic device can actively, timely and conveniently feedback the detection and scanning results to the users such as the access party developers.
[0046] Optionally, the above step 102, obtaining a bytecode file generated in the process of compiling the code file to be detected, includes: Obtain a set of class files generated in the process of compiling the code file to be detected based on JAVA; Filter class files that meet the preset rule class set from the class file set to obtain the target class file; Get the bytecode file obtained by compiling the target class file.
[0047] In this embodiment, the electronic device can generate multiple class files, such as the above-mentioned .class files, etc., in the process of compiling the code file to be detected based on JAVA, and these class files can constitute a class file set. Through default settings or real-time settings, etc., a preset rule class set can be obtained, and the preset rule class set can include multiple preset rule class files, such as class files that can obviously exclude API calls, etc.
[0048] The electronic device can filter out the class files in the class file set that meet the preset rule class set, and the remaining class files correspond to the target class files. These target class files are compiled to obtain bytecode files, and the target instructions are obtained and sensitive API calls are detected by scanning the bytecode files.
[0049] In this embodiment, by filtering class files that meet the preset rule class set, the compilation and scanning workload can be reduced and the efficiency of sensitive API call detection can be improved.
[0050] like Figure 2 As shown, Figure 2 The following is a working principle diagram of the sensitive application programming interface information method in a specific application example. The application example mainly includes two working modules, one is the Android project compilation module, and the other is the custom security scanning module.
[0051] Among them, when the Android project compilation module obtains the code file to be detected, such as SDK, it can start the normal compilation process and run the security detection scanning plug-in for sensitive API detection until the compilation is completed.
[0052] The custom security scanning module uses Gradle Plugin to build a security detection scanning plug-in. The security detection scanning plug-in can obtain the set of class files involved in the compilation, filter the set of classes that meet the rules, and obtain the above-mentioned target class files.
[0053] The security detection scanning plug-in is based on the Transform API technology. It internally intercepts the process of compiling and building bytecode files to convert to Dex files. It uses the bytecode operation framework, such as ASM, Javassist and other operation classes to traverse each instruction of each bytecode file. Based on the instruction hit retrieval rules (corresponding to the preset instruction set), it cyclically scans and detects the instructions that meet the instruction hit retrieval rules (corresponding to the target instructions) and assembles additional information (corresponding to the target instruction information), including the path, class name, method name or number of lines of code of the instructions that meet the instruction hit retrieval rules. If there is an abnormality in the detection process or the detection is completed, real-time feedback will be triggered to inform relevant personnel in time. When the detection is completed, the output results will be formatted to the specified path. When outputting data, the security detection scanning plug-in can manage data according to the customized configuration file to achieve multi-style data output.
[0054] Based on the implementation of the above application examples, the cost of manual detection of risks such as sensitive APIs can be greatly reduced. Automated detection can greatly improve the work efficiency of developers. Customized detection strategies allow developers to easily deal with various risk detections, avoid and reduce economic losses to companies and users due to risk items.
[0055] like Figure 3 As shown, the embodiment of the present application also provides an interface call detection device, including: The first acquisition module 301 is used to acquire the code file to be detected; The second acquisition module 302 is used to acquire the bytecode file generated in the process of compiling the code file to be detected; A scanning module 303, used to scan a target instruction matching a preset instruction set from a bytecode file, wherein the preset instruction set includes preset instructions for calling a sensitive application programming interface; The third acquisition module 304 is used to acquire target instruction information associated with the target instruction from the bytecode file when the target instruction is scanned; The output module 305 is used to output target instruction information, where the target instruction information includes the source path of the target instruction.
[0056] Optionally, the second acquisition module 302 may be specifically configured to: Obtain a set of class files generated in the process of compiling the code file to be detected based on JAVA; Filter class files that meet the preset rule class set from the class file set to obtain the target class file; Get the bytecode file obtained by compiling the target class file.
[0057] Optionally, the target instruction information includes at least one of the following: a file path of the target instruction, a class name of a class file corresponding to the target instruction, a source code file of the target instruction, and the number of code lines corresponding to the target instruction.
[0058] Optionally, the scanning module 303 may be specifically used for: Build detection plugins; Based on the detection plug-in, the target instructions that match the preset instruction set are scanned from the bytecode file.
[0059] Optionally, the scanning module 303 may also be used for: When there are multiple code files to be detected, multiple detection plug-ins are used to scan the bytecode files corresponding to the multiple code files to be detected respectively.
[0060] Optionally, the output module 305 may be specifically used for: Get detection configuration information; When the detection configuration information indicates the first configuration, stop compiling the code file to be detected and output target instruction information; When the detection configuration information indicates the second configuration, the target instruction information is output when the compilation of the code file to be detected is completed.
[0061] Optionally, the output module 305 may also be used to: Obtain the preset instruction information storage path; The target instruction information is output to the instruction information storage path for storage.
[0062] Optionally, the output module 305 may also be used to: Call the preset instant messaging tool; The target instruction information is sent to the target object through the preset instant messaging tool.
[0063] The interface call detection device provided in the embodiment of the present application is the device authority corresponding to the interface call detection method in the above embodiment. The method embodiment can be applied to the device embodiment and achieve the same technical effect, which will not be repeated here.
[0064] An embodiment of the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned interface call detection method when executing the computer program.
[0065] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned interface call detection method is implemented.
[0066] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0067] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0068] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0069] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as 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 devices or units, which can be electrical, mechanical or other forms.
[0070] 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.
[0071] 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.
[0072] If the integrated module / 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 present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. Computer-readable media may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc.
[0073] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. An interface call detection method, characterized in that: include: Get the code file to be tested; Obtaining a bytecode file generated during the process of compiling the code file to be detected; Scanning a target instruction matching a preset instruction set from the bytecode file, wherein the preset instruction set includes preset instructions for calling a sensitive application programming interface; When the target instruction is scanned, obtaining target instruction information associated with the target instruction from the bytecode file; The target instruction information is output, wherein the target instruction information includes a source path of the target instruction.
2. The method according to claim 1, characterized in that The step of obtaining the bytecode file generated in the process of compiling the code file to be detected includes: Obtain a set of class files generated in the process of compiling the code file to be detected based on JAVA; Filtering class files that meet the preset rule class set from the class file set to obtain target class files; Obtain a bytecode file obtained by compiling the target class file.
3. The method according to claim 1, characterized in that: The target instruction information includes at least one of the following: the file path of the target instruction, the class name of the class file corresponding to the target instruction, the source code file of the target instruction, and the number of code lines corresponding to the target instruction.
4. The method according to claim 1, characterized in that: The step of scanning the bytecode file for a target instruction that matches a preset instruction set includes: Build detection plugins; Based on the detection plug-in, scanning the bytecode file for target instructions matching a preset instruction set; The step of scanning the target instruction matching the preset instruction set from the bytecode file based on the detection plug-in includes: In the case that there are multiple code files to be detected, multiple detection plug-ins are used to scan the bytecode files corresponding to the multiple code files to be detected respectively.
5. The method according to claim 1, characterized in that The outputting the target instruction information includes: Get detection configuration information; When the detection configuration information indicates the first configuration, stop compiling the code file to be detected and output the target instruction information; When the detection configuration information indicates the second configuration, the target instruction information is output when the compilation of the code file to be detected is completed.
6. The method according to claim 1, characterized in that The outputting the target instruction information includes: Obtain the preset instruction information storage path; The target instruction information is output to the instruction information storage path for storage.
7. The method according to claim 1, characterized in that The outputting the target instruction information includes: Call the preset instant messaging tool; The target instruction information is sent to the target object via the preset instant messaging tool.
8. An interface call detection device, characterized in that: include: A first acquisition module is used to acquire a code file to be detected; The second acquisition module is used to acquire the bytecode file generated in the process of compiling the code file to be detected; A scanning module, used for scanning a target instruction matching a preset instruction set from the bytecode file, wherein the preset instruction set includes a preset instruction for calling a sensitive application programming interface; A third acquisition module is used to acquire target instruction information associated with the target instruction from the bytecode file when the target instruction is scanned; The output module is used to output target instruction information, and the target instruction information includes the source path of the target instruction.
9. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
