Resource file integrity detection method and device, electronic equipment and storage medium
By extracting string information and analyzing resource file for the target application Mach-O file, generating a resource name list and comparing it, the problem of not being able to detect resource file integrity in the prior art is solved, and resource file integrity detection is realized in the case of no passive code, avoiding online problems caused by resource deficiency.
Patent Information
- Application Number
- CN202411698641.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-03-18
AI Technical Summary
The prior art has problems that cannot detect non-UI-level and cannot detect missing resource files when detecting resource files integrity, especially in the absence of source code.
By extracting string information on the Mach-O file of the target application, obtaining a string collection, and filtering non-resource information and integrating resource information, a first resource name list associated with the resource list range of the target application is generated. At the same time, by analyzing the resource file of the target application, a second resource name list matching the resource file reference situation of the target application is determined, and the integrity of the resource file is detected based on the comparison situation of the two.
It realizes the verification of the missing resource files of the target application through information comparison, and can promptly check problems caused by resource deficiency during the R&D stage, and conduct resource integrity testing before application testing to avoid losses caused by online problems.
Smart Images

Figure CN119645804A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a resource file integrity detection method, device, electronic device and storage medium. Background Art
[0002] In the process of application development, we often encounter the situation of missing resource files. For example, under the mac / ios operating system, there are missing images, bundle files, json files, plist files, html files, css files, ttf files, or resource files are accidentally deleted but it is difficult to detect. For example, some third-party SDKs (Software Development Kits) provided by external parties can only see dynamic / static library files, and cannot directly understand the resource calls in their code.
[0003] Due to missing resource files, usually no errors or warnings are generated during compilation. If it is not a particularly conspicuous resource (such as image resources), it is difficult to find its missing during the test process. If the application is directly submitted for review and released online at this time, some potential and major online problems may occur due to missing files. Therefore, in order to reduce the occurrence of this situation, the application needs to perform a resource file detection before submission for review.
[0004] In the prior art, the following two methods are usually used to detect resource files:
[0005] 1. Manual or automated testing to perform regression testing on all functions within the application.
[0006] 2. Analyze the application source code, extract all resource file lists through code features, and list all local resource file lists through file scanning. Compare the two lists to determine whether there are any missing files.
[0007] For the first method, whether it is automated testing or manual testing, the problems that can be found are only at the UI (User Interface) level, and non-UI problems cannot be detected.
[0008] For the second method, since the source code needs to be analyzed, detection cannot be performed if the source code is not available. Summary of the invention
[0009] In view of the above problems, embodiments of the present application provide a resource file integrity detection method, device, electronic device, and storage medium that overcome the above problems or at least partially solve the above problems.
[0010] In a first aspect, an embodiment of the present application provides a resource file integrity detection method, comprising:
[0011] Extract string information from the Mach-O file of the target application and obtain a string set;
[0012] Performing non-resource information filtering and resource information integration on the string set to generate a first resource name list associated with a resource list range of the target application;
[0013] Performing resource file analysis on the target application to determine a second resource name list that matches resource file references of the target application;
[0014] Based on the comparison between the first resource name list and the second resource name list, the resource file integrity of the target application is detected.
[0015] In a second aspect, an embodiment of the present application provides a resource file integrity detection device, comprising:
[0016] The acquisition module is used to extract string information from the Mach-O file of the target application and obtain a string set;
[0017] A generating module, configured to perform non-resource information filtering and resource information integration on the string set, and generate a first resource name list associated with a resource list range of the target application;
[0018] A determination module, configured to perform resource file analysis on the target application and determine a second resource name list matching the resource file references of the target application;
[0019] A detection module is used to detect the integrity of the resource file of the target application based on the comparison between the first resource name list and the second resource name list.
[0020] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the resource file integrity detection method as described in the first aspect above.
[0021] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the resource file integrity detection method described in the first aspect above are implemented.
[0022] The technical solution of the embodiment of the present application can determine the first resource name list associated with the resource list range by extracting string information from the Mach-O file of the target application to obtain a string set, filtering the string set and aggregating the first resource name list; determine the second resource name list by analyzing the resource file of the target application, and analyze the actual resource name list that matches the resource file reference situation of the target application based on directly scanning the resource file; after determining the first resource name list and the second resource name list, identify the resource integrity of the target application based on the comparison between the two, so as to verify whether there is a missing resource file in the target application through information comparison, and then timely troubleshoot problems caused by missing resources in the research and development stage, and perform resource integrity detection before the application is tested, so as to timely discover problems and avoid losses caused by online problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 A schematic diagram showing a resource file integrity detection method provided in an embodiment of the present application;
[0024] Figure 2 A flowchart showing an implementation of generating a first resource name list provided in an embodiment of the present application;
[0025] Figure 3 A flowchart showing an implementation of determining a second resource name list provided in an embodiment of the present application;
[0026] Figure 4 A schematic diagram showing a resource file integrity detection device provided in an embodiment of the present application;
[0027] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0028] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are 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 are within the scope of protection of this application.
[0029] It should be understood that the "one embodiment" or "an embodiment" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. The multiple in the embodiments of the present application can include two and more than two.
[0030] In the various embodiments of the present application, it should be understood that the size of the serial numbers of the following processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0031] Before introducing the resource file integrity detection solution provided by this application, the Mach-O file is first introduced. Mach-O is a file format on Mac and iOS, similar to the PE (Portable Executable) format on Windows and the elf format (Executable and Linking Format) on Linux. The C, C++, Swift, and OC written by the technicians are finally compiled and linked to generate Mach-O executable files. Mach-O files are binary byte streams grouped in data blocks, which contain meta information such as byte order, CPU (Central Processing Unit) type, data block size, etc. Mach-O files contain three areas: one is Header, which saves some basic information of Mach-O, including platform, file type, number of instructions, total instruction size, dyld mark Flags, etc. The second is Load Commands, which follows the Header. This part of data will be used to determine the memory distribution when loading Mach-O files, and it will guide the system kernel loader and dynamic linker. The third is Data. The specific data of each segment is stored here, including specific codes, data, etc.
[0032] For Mach-O files, the relevant segment information is listed as follows:
[0033] (1)__TEXT__cstring: includes read-only C-style strings after deduplication, all strings that appear in OC / Swift code (excluding Chinese characters), and implicitly output strings.
[0034] (2)__TEXT__ustring: a Chinese character string encoded in utf-8.
[0035] (3)__DATA__cfstring: OC string, which stores only the pointer address of the string, pointing to the string in __TEXT__cstring.
[0036] In actual project development, some third-party SDKs are often connected. A single SDK usually contains multiple .frameworks and multiple resource files. If the developer downloads incomplete information or only needs part of the .framework, the corresponding resource files will be missed. In the application development process, there are other forms of missing resource files, such as accidental deletion of resource files. When a resource file is missing, there may not be any prompts during the APP compilation process. Even if some abnormal situations are found during testing, it is sometimes difficult to find out which resource files are missing and cause the problem. The resource file detection method in the prior art has the problem that non-UI problems cannot be detected or missing source code cannot be detected. Based on this, the embodiment of the present application performs resource calls on the Mach-O files in the APP, analyzes the resource files in the actual package, and compares the two to perform resource file missing detection to identify the integrity of the resource files and avoid some potential problems caused by resource missing.
[0037] The following is an introduction to the resource file integrity detection method provided by the embodiment of the present application. Figure 1 As shown, the following steps are included:
[0038] Step 101: Extract string information from the Mach-O file of the target application to obtain a string set.
[0039] In the embodiment of the present application, when there is no target application source code but only a compiled Mach-O binary file, the corresponding Mach-O file of the target application is extracted, and the string in the __TEXT__cstring segment in the Mach-O file is analyzed to obtain a string set.
[0040] When obtaining a string set, the specific operation may be: for the main binary Mach-O file in the target application, extract its __TEXT__cstring through the xcrun otool-v-s__TEXT__cstring XXXAPP instruction, and then analyze the string in the __TEXT__cstring segment to obtain the string set corresponding to the target application.
[0041] Step 102: Perform non-resource information filtering and resource information integration on the string set to generate a first resource name list associated with the resource list range of the target application.
[0042] After obtaining the string set corresponding to the target application, non-resource information filtering and resource information integration are performed on the content in the string set, so as to minimize the scope of the string set as much as possible through a series of filtering and same-type string aggregation operations, implement string filtering and aggregation based on resource characteristics, and generate a first resource name list associated with the resource list range of the target application and including multiple resource names.
[0043] It should be noted that the string set includes all strings corresponding to the __TEXT__cstring segment. The initial string set is obtained by performing binary file analysis on the target application, and the range of the string set is narrowed by filtering strings not related to the resource file and aggregating strings of the same type (associated with the resource file) to obtain the first resource name list (such as L1) associated with the resource list range.
[0044] Step 103: Analyze the resource files of the target application to determine a second resource name list that matches the resource file references of the target application.
[0045] For the target application, the second resource name list (such as L2) matching the resource file reference of the target application is analyzed by directly scanning the resource file. Specifically, the Assets.car file and other resource files in the target application are analyzed, and the actual resource name list corresponding to the target application is obtained by aggregating the resource names corresponding to the resource files.
[0046] Among them, the .car file is generated by compiling the resources in Apple's .xcassets folder and packaged into the application installation package with the name of Assets.car. By analyzing the resource files in the target application (including Assets.car and some other resource files in parallel, such as .bundle, .json, .plist files, etc.), the actual resource name list corresponding to the resource files referenced by the target application can be determined by directly scanning the resource files.
[0047] Step 104: Based on the comparison between the first resource name list and the second resource name list, detect the integrity of the resource file of the target application.
[0048] After filtering and aggregating the initial string set to determine the first resource name list and determining the second resource name list based on scanning the resource file, the first resource name list and the second resource name list are compared, and the resource integrity of the target application is identified based on the comparison between the two, so as to verify whether there is any missing resource file in the target application by comparing the resource names.
[0049] Among them, the first resource name list can be regarded as determined by Mach-O binary file analysis, and the second resource name list is determined by directly scanning the resource file analysis. There are differences between the two. Usually, the first resource name list contains the second resource name list. Therefore, by comparing the first resource name list and the second resource name list, it is possible to identify whether there are missing resource files in the target application and then verify the resource integrity of the target application.
[0050] The above implementation scheme of the present application can determine the first resource name list associated with the resource list range by extracting string information from the Mach-O file of the target application to obtain a string set, filtering the string set and aggregating the first resource name list; determine the second resource name list by analyzing the resource file of the target application, and analyze the actual resource name list that matches the resource file reference situation of the target application based on directly scanning the resource file; after determining the first resource name list and the second resource name list, identify the resource integrity of the target application based on the comparison between the two, so as to verify whether there is a missing resource file in the target application through information comparison, and then timely troubleshoot problems caused by missing resources in the research and development stage, and perform resource integrity detection before the application is tested to find problems in time and avoid losses caused by online problems.
[0051] The following describes the process of generating the first resource name list. The string set is extracted from the compiled Mach-O file based on the extraction instruction, and the string set includes class names, method names, and string constants. Among them, the class name, method name, and string constant all belong to the string corresponding to the __TEXT__cstring segment.
[0052] When filtering the non-resource information and integrating the resource information of the string set to generate a first resource name list associated with the resource list range of the target application, the method includes:
[0053] Filter the class names and method names in the string collection;
[0054] Filter non-resource reference string constants in the string collection;
[0055] Merge resource reference string constants corresponding to .bundle format resource names at the same directory level;
[0056] A first resource name list is generated based on the information retained after filtering and merging in the string set, and the first resource name list includes all resource names corresponding to the resource list range of the target application.
[0057] When filtering a string set, it is necessary to filter the class name and method name in the string set. When filtering the class name, the class name list in __TEXT__objc_classname is extracted through the otool command, and the class name list is filtered in the string set. When filtering the method name, the method name list in __TEXT__objc_methname is extracted through the otool command, and the method name list is filtered in the string set. Among them, _TEXT__cstring, __TEXT__objc_classname and __TEXT__objc_methname belong to three parallel segments, and these three segments can analyze three lists, and the content of one list includes the content of the other two lists. Specifically: for _TEXT__cstring, its corresponding list includes class name, method name, and string constant; for __TEXT__objc_classname, its corresponding list includes class name; for __TEXT__objc_methname, its corresponding list includes method name. When obtaining a string set, the class name, method name, and string constant can be obtained by directly analyzing the binary file.
[0058] When filtering a string set, you also need to filter the non-resource reference string constants in the string set. When filtering non-resource reference string constants, you can filter the string constants that contain spaces, special characters, and named using specific business naming rules in the string set; and filter the non-resource reference string constants that contain resource names in .bundle format.
[0059] Resource file names generally do not include spaces. If a text output in the code includes spaces, you can filter based on the spaces; that is, filter the string constants that include spaces in the string set. Normal resource file names will not contain special characters such as %{}<>? ^\[]:=,! $&'*|~". For the log output of some objects, if the log contains the above special characters, you can filter based on the special characters; that is, filter the string constants that include special characters in the string set. Resource files are usually not named using specific business naming rules. For string constants named using specific business naming rules, such as notification names that generally end with Notification, you can filter based on the naming situation; that is, filter the string constants that are named using specific business naming rules in the string set.
[0060] When filtering non-resource reference string constants, you also need to consider non-resource reference string constants that contain resource names in .bundle format. .bundle is a file format in iPhone applications. It is a resource package used to store various resource files required by the application, such as images, audio, video, text files, etc.; for .bundle files, they can be dynamically loaded and accessed when the application is running. For non-resource reference string constants that contain resource names in .bundle format, such as printing information that contains resource names in .bundle format, since this situation does not belong to reference resources, even if it contains resource names in .bundle format, it still belongs to non-resource reference string constants, so it needs to be filtered.
[0061] The above content introduces the process of filtering non-resource information for a string collection. When integrating resource information for a string collection, it is necessary to merge the resource reference string constants corresponding to the .bundle format resource name at the same directory level to aggregate them to the root .bundle level. As an example, the string constant corresponding to A.bundle / xxxx.png is merged with the string constant corresponding to A.bundle / yyyy.png to obtain the string constant corresponding to A.bundle, where A.bundle is the directory name and xxxx.png is the resource name. After merging, they can be aggregated to the root .bundle level to determine the .bundle format resource name.
[0062] After filtering non-resource information and integrating resource information of the string set, a first resource name list is generated based on the information retained after filtering and merging in the string set. The generated first resource name list includes all resource names corresponding to the resource list range of the target application.
[0063] The above implementation scheme, after determining the string set, filters the class names and method names in the string set, filters the non-resource reference string constants in the string set, and merges the resource reference string constants corresponding to the .bundle format resource names at the same directory level, so as to filter the strings that are not related to the resource files and aggregate the strings of the same type (associated with the resource files), thereby narrowing the scope of the string set and obtaining the first resource name list associated with the resource list scope.
[0064] The following describes a specific implementation process for determining the resource list range to generate the first resource name list. Figure 2 As shown:
[0065] Step 201 : For the main binary Mach-O file in the target application, extract __TEXT__cstring through the xcrun otool -v -s__TEXT__cstring XXXAPP instruction to obtain a string set.
[0066] Step 202: Filter the class names in the string set.
[0067] Step 203: Filter the method names in the string collection.
[0068] Step 204: Filter the string constants that include spaces, the string constants that include special characters, and the string constants that are named using a specific business naming rule in the string set.
[0069] Step 205: Filter the non-resource reference string constants that contain resource names in the .bundle format in the string collection.
[0070] Step 206: Merge the resource reference string constants corresponding to the .bundle format resource names at the same directory level.
[0071] Step 207: Generate a first resource name list based on the information retained after filtering and merging in the string set.
[0072] In the above implementation process, the strings in the __TEXT__cstring segment are analyzed, and the range of the string set is minimized as much as possible through a series of filtering and same-type string aggregation operations, so as to achieve filtering and aggregation processing and generate a first resource name list associated with the resource list range of the target application.
[0073] The following is an introduction to the solution for generating the second resource name list. When analyzing the resource file of the target application and determining the second resource name list that matches the resource file reference of the target application, it includes:
[0074] Extracting a first resource file in the target application and obtaining a first list corresponding to the first resource file, wherein the first resource file is a .car resource file, and the first list includes resource names corresponding to the compiled first resource file;
[0075] Analyze a second resource file in the target application that is different from the first resource file, and generate a second list corresponding to the second resource file, the second list including resource names corresponding to the second resource file;
[0076] The first list and the second list are aggregated to generate a second resource name list, where the second resource name list includes resource names corresponding to all resource files referenced by the target application.
[0077] When analyzing the resource files of the target application, first extract the Assets.car file (the first resource file) in the target application, which is a resource file generated after the resources in the Apple .xcassets folder are compiled, containing fragmentation information, mainly image files. The CARExtractor tool can be used to obtain the resource name list in the .car file to determine the first list including resource names corresponding to the first resource file.
[0078] Then, a second resource file different from the first resource file in the target application is analyzed, and a second list corresponding to the second resource file is generated by analyzing the second resource file. The second list includes resource names corresponding to the second resource file.
[0079] Optionally, when analyzing a second resource file in the target application that is different from the first resource file and generating a second list corresponding to the second resource file, the method includes:
[0080] Traversing the directory information of the target application to obtain a first file name list corresponding to the resource files in the .bundle format of the target application;
[0081] Traverse the json files, configuration files, user interface UI files, animated image files, font files and audio and video files of the target application to generate a second file name list. The json file stores business data.
[0082] Traverse the image files of the target application and generate a third file name list;
[0083] Aggregate the first file name list, the second file name list, and the third file name list to generate a second list corresponding to the second resource file;
[0084] The second resource file includes files corresponding to the first file name list, the second file name list, and the third file name list, respectively.
[0085] When analyzing the second resource file, other resource files other than the .car resource file are analyzed as appropriate. The second resource file includes .bundle files, .json, .plist, .nib, .gif, .ttf and other resource files, and png files.
[0086] For .bundle files, traverse the directory information of the target application to obtain the first file name list corresponding to all .bundle files. For resource files such as json files, configuration files, user interface UI files, animated image files, font files, and audio and video files, they do not have suffixes when called by code. By traversing the json files (used to store business data), configuration files, user interface UI files, animated image files, font files, and audio and video files of the target application and deleting the suffixes, a second file name list is generated. For image files directly placed in the APP package, they may or may not contain @2x, @3x when called by code. Therefore, when traversing these files, it is necessary to add resource names that contain and do not contain @2x, @3x suffixes to the list to construct a third file name list.
[0087] After determining the first file name list, the second file name list and the third file name list by analyzing other resource files other than the .car resource file (the first resource file), the first file name list, the second file name list and the third file name list are aggregated to generate a second list including resource names corresponding to the second resource file.
[0088] After determining the first list corresponding to the first resource file and the second list corresponding to the second resource file, the first list and the second list are aggregated to generate a second resource name list including resource names corresponding to all resource files referenced by the target application, thereby determining the actual resource name list corresponding to the resource files referenced by the target application based on directly scanning the resource files.
[0089] The above implementation scheme determines the first list corresponding to the first resource file and the second list corresponding to the second resource file based on resource file scanning, aggregates the first list and the second list, and generates a second resource name list related to the resource file reference situation of the target application, thereby realizing the method of directly scanning the resource files to determine the actual resource name list corresponding to the resource files referenced by the target application.
[0090] The following describes the process of determining the second resource name list through a specific implementation process. Figure 3 As shown:
[0091] Step 301: extract the .car resource file in the target application and obtain the first list corresponding to the .car resource file.
[0092] Step 302: traverse the directory information of the target application to obtain a first file name list corresponding to all .bundle files.
[0093] Step 303: traverse the json files, configuration files, user interface UI files, animated image files, font files, and audio and video files of the target application to generate a second file name list.
[0094] Step 304: traverse the image files of the target application and generate a third file name list.
[0095] Step 305: Aggregate the first file name list, the second file name list, and the third file name list to generate a second list corresponding to the second resource file.
[0096] Step 306: Aggregate the first list and the second list to generate a second resource name list.
[0097] In the above implementation process, the first list corresponding to the .car resource file (first resource file) and the second list corresponding to the second resource file are determined by scanning the resource file, and the second resource name list is generated by list aggregation, so as to determine the actual resource name list by directly scanning the resource file.
[0098] In an embodiment of the present application, when detecting the integrity of the resource file of the target application based on the comparison between the first resource name list and the second resource name list, the process includes:
[0099] The first resource name list and the second resource name list are compared, and a difference set list representing the missing resource files is determined based on the comparison results; after the difference set list is manually verified, a target difference set list is obtained; in response to the target difference set list being non-empty, it is determined that the resource files of the target application are missing.
[0100] After obtaining the first resource name list and the second resource name list and comparing the two, determine the difference list of the first resource name list and the second resource name list based on the comparison, specifically: calculate the difference between the first resource name list L1 and the second resource name list L2, and determine the difference list ΔL. Then analyze the difference list ΔL, where the difference list ΔL is the resource name list corresponding to the resource files that may be missing, and provide the difference list ΔL to the R&D personnel for further confirmation. For example, if the difference list ΔL contains the resource name corresponding to the .bundle file, it means that the target application lacks the specified .bundle file, and other information in the difference list ΔL can be further confirmed manually to avoid misjudgment. It is also possible to directly provide the difference list ΔL to the R&D personnel for confirmation.
[0101] After the difference list ΔL is provided to the R&D personnel and manually verified, the target difference list is obtained, and the content in the target difference list is less than or equal to the content in the difference list ΔL, that is, after the difference list ΔL is provided to the R&D personnel, the R&D personnel can delete some content in the difference list ΔL to determine the target difference list, or the R&D personnel can directly determine the difference list ΔL as the target difference list after analysis. After determining the target difference list, in response to the target difference list being in a non-empty state, it is determined that there are missing resource files in the target application, and which resource files are specifically missing in the target application can be determined based on the resource names in the target difference list.
[0102] Wherein, when it is determined that the resource file of the target application is missing, the resource file of the target application is supplemented based on the target difference set list to repair the resource file of the target application.
[0103] When the target difference list is not empty, it is determined that there are missing resource files in the target application, and because the resource names in the target difference list indicate which resource files are missing in the target application, the resource files of the target application can be supplemented based on the target difference list to repair the resource files of the target application through the supplementation of the resource files.
[0104] In the above implementation scheme, the difference set list determined based on the first resource name list and the second resource name list is manually verified, and the target difference set list is determined after the verification. It is determined based on the target difference set list whether there are any missing resource files in the target application, and when there are any missing resource files in the target application, the resource files of the target application are repaired. This can timely troubleshoot problems caused by missing resources and avoid losses caused by online problems.
[0105] The present application embodiment provides a resource file integrity detection device, such as Figure 4 As shown, including:
[0106] The acquisition module 401 is used to extract string information from the Mach-O file of the target application to obtain a string set;
[0107] A generating module 402, configured to perform non-resource information filtering and resource information integration on the string set, and generate a first resource name list associated with a resource list range of the target application;
[0108] A determination module 403 is used to analyze resource files of the target application and determine a second resource name list that matches the resource file references of the target application;
[0109] The detection module 404 is used to detect the integrity of the resource file of the target application based on the comparison between the first resource name list and the second resource name list.
[0110] Optionally, the string set includes a class name, a method name, and a string constant, and the string set is extracted from a compiled Mach-O file based on an extraction instruction;
[0111] The generation module comprises:
[0112] A first filtering submodule, used to filter the class names and method names in the string set;
[0113] A second filtering submodule, used for filtering non-resource reference string constants in the string set;
[0114] The merging submodule is used to merge resource reference string constants corresponding to the .bundle format resource names at the same directory level;
[0115] A generating submodule is used to generate the first resource name list based on the information retained after filtering and merging in the string set, wherein the first resource name list includes all resource names corresponding to the resource list range of the target application.
[0116] Optionally, the second filtering submodule is further used for:
[0117] Filtering the string constants that include spaces, the string constants that include special characters, and the string constants that are named using a specific business naming rule in the string set;
[0118] Filters non-resource reference string constants that contain resource names in .bundle format.
[0119] Optionally, the determining module includes:
[0120] An extraction and acquisition submodule, used to extract a first resource file in the target application and obtain a first list corresponding to the first resource file, wherein the first resource file is a .car resource file, and the first list includes resource names corresponding to the compiled first resource file;
[0121] An analysis and generation submodule, configured to analyze a second resource file in the target application that is different from the first resource file, and generate a second list corresponding to the second resource file, wherein the second list includes resource names corresponding to the second resource file;
[0122] The aggregation generation submodule is used to aggregate the first list and the second list to generate the second resource name list, where the second resource name list includes resource names corresponding to all resource files referenced by the target application.
[0123] Optionally, the analysis generation submodule is further used for:
[0124] Traversing the directory information of the target application, obtaining a first file name list corresponding to the resource files in the .bundle format of the target application;
[0125] Traversing the json file, configuration file, user interface UI file, animated image file, font file and audio and video file of the target application to generate a second file name list, wherein the json file stores business data;
[0126] Traversing the image files of the target application to generate a third file name list;
[0127] Aggregate the first file name list, the second file name list, and the third file name list to generate a second list corresponding to the second resource file;
[0128] The second resource file includes files corresponding to the first file name list, the second file name list, and the third file name list, respectively.
[0129] Optionally, the detection module includes:
[0130] A comparison and determination submodule, used for comparing the first resource name list with the second resource name list, and determining a difference set list representing the missing resource file based on the comparison result;
[0131] An acquisition submodule, used for acquiring a target difference set list after the difference set list is manually verified;
[0132] The determination submodule is configured to determine that the resource file of the target application is missing in response to the target difference set list being non-empty.
[0133] Optionally, when determining that the resource file of the target application is missing, the device further includes:
[0134] A supplement and repair module is used to supplement resource files of the target application based on the target difference set list to repair the resource files of the target application.
[0135] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0136] An embodiment of the present application also provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned resource file integrity detection method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0137] For example, Figure 5FIG. 1 shows a schematic diagram of the physical structure of an electronic device. Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other via the communication bus 540. The processor 510 may call the logic instructions in the memory 530, and the processor 510 is used to execute each process of the resource file integrity detection method of the embodiment of the present application, which will not be described one by one here.
[0138] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application.
[0139] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, each process of the resource file integrity detection method embodiment described above is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0140] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0141] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an 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, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0142] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
[0143] 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 in the present application 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.
[0144] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0145] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, 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, 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.
[0146] 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.
[0147] 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.
[0148] If the functions are implemented in the form of software functional units and sold or used as independent products, they 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 the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks, or optical disks.
[0149] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A resource file integrity detection method, characterized in that: include: Extract string information from the Mach-O file of the target application and obtain a string set; Performing non-resource information filtering and resource information integration on the string set to generate a first resource name list associated with a resource list range of the target application; Performing resource file analysis on the target application to determine a second resource name list that matches resource file references of the target application; Based on the comparison between the first resource name list and the second resource name list, the resource file integrity of the target application is detected.
2. The method according to claim 1, characterized in that The string set includes a class name, a method name, and a string constant, and the string set is extracted from a compiled Mach-O file based on an extraction instruction; The step of filtering the string set with non-resource information and integrating resource information to generate a first resource name list associated with the resource list range of the target application includes: Filter the class names and method names in the string set; Filtering non-resource reference string constants in the string set; Merge resource reference string constants corresponding to .bundle format resource names at the same directory level; The first resource name list is generated based on the information retained after filtering and merging in the string set, and the first resource name list includes all resource names corresponding to the resource list range of the target application.
3. The method according to claim 2, characterized in that The filtering of the non-resource reference string constants in the string set includes: Filtering the string constants that include spaces, the string constants that include special characters, and the string constants that are named using a specific business naming rule in the string set; Filters non-resource reference string constants that contain resource names in .bundle format.
4. The method according to claim 1, characterized in that: The performing resource file analysis on the target application to determine a second resource name list matching the resource file reference situation of the target application includes: Extracting a first resource file in the target application and obtaining a first list corresponding to the first resource file, wherein the first resource file is a .car resource file, and the first list includes resource names corresponding to the compiled first resource file; Analyze a second resource file in the target application that is different from the first resource file, and generate a second list corresponding to the second resource file, wherein the second list includes resource names corresponding to the second resource file; The first list and the second list are aggregated to generate the second resource name list, where the second resource name list includes resource names corresponding to all resource files referenced by the target application.
5. The method according to claim 4, characterized in that The analyzing a second resource file in the target application that is different from the first resource file to generate a second list corresponding to the second resource file includes: Traversing the directory information of the target application, obtaining a first file name list corresponding to the resource files in the .bundle format of the target application; Traversing the json file, configuration file, user interface UI file, animated image file, font file and audio and video file of the target application to generate a second file name list, wherein the json file stores business data; Traversing the image files of the target application to generate a third file name list; Aggregate the first file name list, the second file name list, and the third file name list to generate a second list corresponding to the second resource file; The second resource file includes files corresponding to the first file name list, the second file name list, and the third file name list, respectively.
6. The method according to claim 1, characterized in that The detecting the resource file integrity of the target application based on the comparison between the first resource name list and the second resource name list includes: Compare the first resource name list with the second resource name list, and determine a difference set list representing missing resource files based on the comparison result; After the difference set list is manually verified, obtaining a target difference set list; In response to the target difference set list being non-empty, it is determined that the resource file of the target application is missing.
7. The method according to claim 6, characterized in that When determining that the resource file of the target application is missing, the method further includes: The resource files of the target application are supplemented based on the target difference set list to repair the resource files of the target application.
8. A resource file integrity detection device, characterized in that: include: The acquisition module is used to extract string information from the Mach-O file of the target application and obtain a string set; A generating module, configured to perform non-resource information filtering and resource information integration on the string set, and generate a first resource name list associated with a resource list range of the target application; A determination module, configured to perform resource file analysis on the target application and determine a second resource name list matching the resource file references of the target application; A detection module is used to detect the integrity of the resource file of the target application based on the comparison between the first resource name list and the second resource name list.
9. An electronic device, characterized in that: The method comprises a processor, a memory and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the resource file integrity detection method as claimed in any one of claims 1 to 7 when executed by the processor.
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 steps of the resource file integrity detection method according to any one of claims 1 to 7 are implemented.