JavaScript file processing method and device and computer readable medium
By obfuscating JavaScript script files in CDN node devices, the problems of high professional capabilities and high workload of operation and maintenance personnel are solved, efficiency and security are improved, and the impact on the performance of the source site is avoided.
Patent Information
- Application Number
- CN202411375040.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-01-14
AI Technical Summary
In the prior art, website operation and maintenance personnel need to have high professional capabilities and programming capabilities to manually obfuscate JavaScript script files, resulting in large workloads, high error rates, and may put pressure on the performance of the source site.
By receiving the client's resource acquisition request in the CDN node device, obtaining and obfuscating the JavaScript script file of the source station and sending it to the client, avoiding the operation and maintenance personnel from directly obfuscating and reducing the use of the source station's computing resources.
It reduces the workload and error rate of operation and maintenance personnel, improves access and processing efficiency, reduces the impact on the performance of the source site, and realizes effective protection of JavaScript script files.
Smart Images

Figure CN119312296A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information technology, and in particular to a JavaScript script file processing method, device and computer-readable medium. Background Art
[0002] JavaScript is an advanced scripting language that has been widely used in Web application development. It is often used to add a variety of dynamic functions to web pages to provide users with a smoother and more beautiful browsing experience. JavaScript script files are generally used for scripts that can be executed during the website loading process or for automatically rendering content. Most website operation and maintenance personnel will directly use plain text JavaScript script files on the website. After hackers and crawler developers request access to these plain text JavaScript script files from the website, they can easily interpret and analyze the execution logic, and then further exploit the vulnerabilities to further damage or crawl the website.
[0003] In order to solve the security problem that plain text JavaScript scripts can be easily interpreted and exploited, the solution in the prior art is that the website operation and maintenance personnel manually obfuscate these plain text JavaScript script files, and then replace the obfuscated JavaScript script files with the plain text JavaScript script files in the source site. In this way, even if hackers or crawler developers obtain these JavaScript script files, since these JavaScript script files are obfuscated and not plain text JavaScript script files, it is difficult to directly interpret the execution logic therein, thereby protecting the security of the website.
[0004] Although this solution can solve the problem to a certain extent, it still has the following disadvantages: 1. It requires high professional ability of the website operation and maintenance personnel, who need to have a certain level of security awareness and programming ability, and can manually confuse the relevant JavaScript script files. 2. The number of JavaScript script files on large websites is very large, and some may rely on third-party JavaScript script files. If all obfuscation is done manually, the workload is huge and prone to errors. 3. If the obfuscation process is performed by the source station, it will bring additional load to the computing resources of the source station, causing certain performance pressure. Summary of the invention
[0005] One purpose of the present application is to provide a JavaScript script file processing method, device and computer-readable medium, at least to solve the problems in the prior art of high professional ability requirements for operation and maintenance personnel, large workload, high error rate, and possible pressure on source station performance.
[0006] To solve the above problems, an embodiment of the present application provides a JavaScript script file processing method, the method comprising:
[0007] The CDN node device receives a resource acquisition request from a client device;
[0008] The CDN node device obtains a first JavaScript script file from the source site according to the resource acquisition request;
[0009] The CDN node device performs obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file;
[0010] The CDN node device sends the second JavaScript script file to the client device.
[0011] The embodiment of the present application further provides a CDN node device for processing JavaScript script files, the CDN node device comprising:
[0012] A request acquisition module, used for receiving a resource acquisition request from a client device;
[0013] A resource acquisition module, configured to acquire a first JavaScript script file from a source station according to the resource acquisition request;
[0014] A resource processing module, used for performing obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file;
[0015] A resource response module is used to send the second JavaScript script file to the client device.
[0016] In addition, an embodiment of the present application also provides a computing device, which includes a memory for storing computer program instructions and a processor for executing computer program instructions, wherein when the computer program instructions are executed by the processor, the device is triggered to execute the JavaScript script file processing method.
[0017] The embodiment of the present application also provides a computer-readable medium on which computer program instructions are stored. The computer program instructions can be executed by a processor to implement the JavaScript script file processing method.
[0018] Compared with the prior art, in the JavaScript script file processing scheme provided in the embodiment of the present application, the CDN node device receives a resource acquisition request from the client device, obtains a first JavaScript script file from the source station according to the resource acquisition request, and then performs obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file, and then sends the second JavaScript script file to the client device. In this scheme, the obfuscation processing is performed by the CDN node device during the resource access process. Even if the source station uses a plain text JavaScript script file, the client device will obtain the processed JavaScript script file. Therefore, the operation and maintenance personnel do not need to have relevant security awareness and programming capabilities, and can also protect the JavaScript script files of the website, which can effectively reduce the workload of the operation and maintenance personnel and is not prone to errors. Moreover, since the obfuscation processing is performed by the CDN node device, it does not need to occupy the computing resources of the source station, so it will not affect the performance of the source station, and can effectively improve the access efficiency and processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 A schematic diagram of a processing flow of a JavaScript script file processing method provided in an embodiment of the present application;
[0020] Figure 2 A schematic diagram of a processing process for implementing a web page resource acquisition request interaction using the solution of an embodiment of the present application;
[0021] Figure 3 This is a processing flow chart of a CDN node device in an interaction process in an embodiment of the present application;
[0022] Figure 4 A schematic diagram of the structure of a CDN node device for processing JavaScript script files provided in an embodiment of the present application;
[0023] Figure 5 A schematic diagram of the structure of a computing device for implementing IP transparent transmission in an embodiment of the present application. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are 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.
[0025] In a typical configuration of the present application, the terminal and the equipment of the service network each include one or more processors (CPU), input / output interface, network interface and memory.
[0026] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0027] Computer readable media include permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, modules of programs or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission medium that can be used to store information that can be accessed by a computing device.
[0028] The embodiment of the present application provides a JavaScript script file processing method, in which a CDN (Content Delivery Network) node device processes a JavaScript script file during a resource acquisition request processing process. After receiving a resource acquisition request from a client device, the CDN node device acquires a first JavaScript script file from a source station according to the resource acquisition request, and then performs an obfuscation process on the first JavaScript script file to obtain a second JavaScript script file, and then sends the second JavaScript script file to the client device. In this solution, the obfuscation process is performed by the CDN node device during the resource access process. Even if the source station uses a plain text JavaScript script file, the client device will obtain the processed JavaScript script file. Therefore, the operation and maintenance personnel do not need to have relevant security awareness and programming capabilities, and can also protect the JavaScript script files of the website, which can effectively reduce the workload of the operation and maintenance personnel and is not prone to errors. Moreover, since the obfuscation process is performed by the CDN node device, it does not need to occupy the computing resources of the source station, so it will not affect the performance of the source station, and can effectively improve the access efficiency and processing efficiency.
[0029] In an actual scenario, the specific implementation of the CDN node device that executes the method may include, but is not limited to, a network host, a single network server, a server concentrated with multiple network servers, or a server in a distributed cloud network. The distributed cloud network described herein is composed of a large number of hosts or network servers based on cloud computing. The distributed cloud network may be an edge cloud network, which can be based on the core of cloud computing technology and the capabilities of edge computing, and is a cloud computing platform built on edge infrastructure to form an elastic cloud platform with comprehensive computing, network, storage, security, application and other capabilities at the edge. It should be noted that the embodiments of the present application do not limit the specific type of distributed network, and any network with a distributed architecture consisting of multiple computing devices is applicable to the present application.
[0030] Figure 1 The processing flow of a JavaScript script file processing method provided in an embodiment of the present application is shown, which at least includes the following processing steps:
[0031] Step S101: A CDN node device receives a resource acquisition request from a client device.
[0032] When a client device accesses a web page through a browser, it needs to request the source site to obtain various resources in the web page, including JavaScript script files, and load these resources in the browser after obtaining them, so that the complete web page content can be presented to the user. In the above process, the CDN node device can receive a resource acquisition request for obtaining these resources from the client device. For example, when the browser of the client device accesses the web page web1, it needs to load a certain resource res1 therein. If the resource res1 is not cached locally on the client device, the client device will initiate a resource acquisition request req1 to the CDN node device, requesting to obtain the resource res1. Correspondingly, the CDN node device will obtain the resource acquisition request req1 from the client device.
[0033] Step S102: The CDN node device obtains a first JavaScript script file from the source site according to the resource acquisition request.
[0034] Taking the previous scenario as an example, for the resource acquisition request req1, if the resource requested is a JavaScript script file, the CDN node device can obtain the first JavaScript script file from the source station according to the resource acquisition request req1. In the actual scenario, taking the transmission protocol of the HTTP protocol as an example, the CDN node device can determine the specific resource obtained in this processing process according to the content type field in the resource response content returned by the source station.
[0035] Therefore, in an embodiment of the present application, when the CDN node device obtains the first JavaScript script file from the source station according to the resource acquisition request, it can first obtain the resource response content from the source station according to the resource acquisition request, and then determine whether the resource file in the resource response content is the first JavaScript script file according to the content type field in the resource response content. Taking the aforementioned scenario as an example, after receiving the resource acquisition request req1 from the client device, the CDN node device can send the request to the source station, so that the source station returns the corresponding resource response content according to the resource acquisition request req1. If the HTTP protocol is used in this embodiment to complete the resource sending process, the Content-type field in the HTTP response header of the resource response content will contain information about the resource content type. If the content of the Content-type field is application / javascript or text / javascript, it means that the resource response content is the first JavaScript script. If the content of the Content-type field is other, it means that the resource response content is not a JavaScript script, but a resource file of other content types.
[0036] Step S103: the CDN node device performs obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file, wherein the first JavaScript script file refers to the JavaScript script file before the current obfuscation processing, and the second JavaScript script file refers to the JavaScript script file obtained after the current obfuscation processing of the first JavaScript script file.
[0037] In some embodiments of the present application, the control platform of the CDN node device can provide the user with a setting option of whether to enable the obfuscation function, allowing the user to control whether to enable the obfuscation function for JavaScript script files on the CDN node device as needed. Therefore, when the CDN node device processes the resource response content returned according to the resource acquisition request, it can first determine whether to enable the automatic processing mechanism. The automatic processing mechanism is a mechanism for obfuscating JavaScript script files. Therefore, when the judgment result is yes, the CDN node device can perform obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file. When the judgment result is no, it means that the user has not enabled the function of obfuscating JavaScript script files. At this time, the CDN node device does not need to perform obfuscation processing on the first JavaScript script file, and directly returns the first JavaScript script file to the client device. This allows users to control the obfuscation function more conveniently and improves the flexibility of the solution.
[0038] When performing obfuscation processing, you can use a preset obfuscation algorithm or use existing obfuscation tools, such as UglifyJS, JScrambler, Obfuscator, Babili, etc. In actual scenarios, you can choose the specific method of obfuscation processing as needed. For example, when better access performance is needed, you can choose an obfuscation algorithm or obfuscation tool with better performance. When a better obfuscation effect is needed, you can choose an obfuscation algorithm or obfuscation tool with an obfuscation effect to process the first JavaScript script file. In actual scenarios, the control platform of the CDN node device can also provide users with setting options for obfuscation algorithms or obfuscation tools, so that users can more conveniently select or set the algorithm or tool used for obfuscation processing, so that the interactive experience is better.
[0039] In some embodiments of the present application, in order to further improve security, when the CDN node device performs obfuscation processing on the first JavaScript script file to obtain the second JavaScript script file, it can adopt a multiple obfuscation method, that is, use a variety of different obfuscation algorithms or obfuscation tools to perform multiple obfuscation processing on the first JavaScript script file, so as to further improve security, so that the possibility of the obfuscated second JavaScript script file being interpreted and analyzed by hackers or crawler developers to further reduce the execution logic. For example, in this embodiment, the user can pre-set three compatible obfuscation tools, and when the first JavaScript script file is obfuscated, the multiple obfuscation method can be adopted, and the three obfuscation tools can be used in sequence to process the first JavaScript script file, so that the difficulty of cracking the execution logic of the second JavaScript script file obtained will be greatly reduced, thereby effectively ensuring the security of the JavaScript script file of the source station.
[0040] In actual scenarios, since the resource file requested by the resource acquisition request is not necessarily a JavaScript script file, but may also be a resource file of other content types, after the CDN node device determines whether the resource file in the resource response content is the first JavaScript script file based on the content type field in the resource response content, the CDN node device can, when it determines that the resource file in the resource response content is the first JavaScript script file, perform obfuscation processing on the first JavaScript script file to obtain the second JavaScript script file. When the resource file in the resource response content is not the first JavaScript script file, the CDN node device does not perform obfuscation processing on the resource file, but directly sends the resource file to the client device, thereby ensuring the compatibility of this solution, and can be compatible with normal CDN acceleration services, avoiding affecting the functions of normal CDN acceleration services.
[0041] Step S104: The CDN node device sends the second JavaScript script file to the client device.
[0042] When the resource file obtained by the CDN node device is a JavaScript script file, and the JavaScript script file is obfuscated to obtain the corresponding second JavaScript script file, the CDN node device can normally respond to the user's resource acquisition request and send the obfuscated second JavaScript script file to the client device. Since the obfuscated JavaScript script file still retains the syntax and structure of the programming language, the browser can rely on the syntax rules and structure of the JavaScript code to parse and execute. Therefore, the obfuscated JavaScript script file will only reduce readability and prevent hackers or crawler developers from interpreting and analyzing the execution logic therein, but for the browser, it can still be executed normally and will not affect normal users' normal browsing of the web page.
[0043] In this solution, the obfuscation processing is performed by the CDN node device during the resource access process. Even if the source site uses plain text JavaScript script files, the client device will obtain the processed JavaScript script files. Therefore, the operation and maintenance personnel do not need to have relevant security awareness and programming skills, and can also protect the JavaScript script files of the website, which can effectively reduce the workload of the operation and maintenance personnel and is not prone to errors. In addition, since the obfuscation processing is performed by the CDN node device, it does not need to occupy the computing resources of the source site, so it will not affect the performance of the source site, and can effectively improve the access efficiency and processing efficiency.
[0044] In order to further improve the response speed of the CDN node device and achieve higher request processing performance, in some embodiments of the present application, the CDN node device may cache a second JavaScript script file corresponding to the first JavaScript script file in a local storage space after obfuscating the first JavaScript script file to obtain a second JavaScript script file.
[0045] After the CDN node device receives a resource acquisition request from a client device, it can first search in the local storage space, and determine whether the second JavaScript script file corresponding to the first JavaScript script file has been cached in the local storage space according to the resource acquisition request. If it has been cached, the CDN node device can obtain the second JavaScript script file from the local storage space and send the second JavaScript script file to the client device, without having to initiate a resource acquisition request to the source site to obtain the first JavaScript script, and then perform obfuscation again to generate the second JavaScript script file. Only when the second JavaScript script file corresponding to the first JavaScript script file is not cached in the local storage space of the CDN node device, the second JavaScript script file is returned to the client device by executing the aforementioned steps S102 to S104. In this way, the resource overhead and time of obtaining resources from the source site and performing obfuscation processing can be effectively reduced, and the response speed of the CDN node device to resource acquisition requests can be improved.
[0046] In some embodiments of the present application, when the CDN node device obfuscates the first JavaScript script file to obtain the second JavaScript script file, it can first determine whether the first JavaScript script file has been obfuscated. If the first JavaScript script file has not been obfuscated, the CDN node device can obfuscate the first JavaScript script file to obtain the second JavaScript script file; conversely, if the first JavaScript script file has been obfuscated, the CDN node device directly sends the first JavaScript script file to the client device without obfuscating it again. In this way, the CDN node device can return the requested JavaScript script file to the client device more quickly, thereby improving the overall performance of the solution.
[0047] In other embodiments of the present application, for the first JavaScript script file that has been obfuscated, another processing method can be adopted, that is, the first JavaScript script file is subjected to secondary obfuscation processing to obtain the second JavaScript script file obtained by the secondary obfuscation processing. Therefore, in this embodiment, when the CDN node device performs obfuscation processing on the first JavaScript script file to obtain the second JavaScript script file, it can also first determine whether the first JavaScript script file has been obfuscated. If the first JavaScript script file has not been obfuscated, the CDN node device can perform obfuscation processing on the first JavaScript script file to obtain the second JavaScript script file; conversely, if the first JavaScript script file has been obfuscated, the CDN node device will perform secondary obfuscation processing on the first JavaScript script file to obtain the second JavaScript script file obtained by the secondary obfuscation processing. In this way, the already obfuscated JavaScript script file will also be subjected to secondary obfuscation processing, which is conducive to improving security and reducing the possibility of the JavaScript script file being interpreted and analyzed for execution logic. It is more suitable for scenarios with high requirements for JavaScript script logic confidentiality.
[0048] Because in actual scenarios, the CDN node device can use different obfuscation algorithms when obfuscating the first JavaScript script file. For the same first JavaScript script file, different second JavaScript scripts will be obtained after obfuscation based on different obfuscation algorithms, and when different types of client devices parse the second JavaScript scripts generated by different obfuscation algorithms, the parsing efficiency may be different. For example, when using client devices with different browser versions to parse the second JavaScript scripts generated by different obfuscation algorithms, the time spent will be different. The shorter the time, the better the performance of the corresponding obfuscation algorithm, and the higher the overall processing efficiency.
[0049] Therefore, in order to ensure that a more suitable second JavaScript script is provided to the client device and improve processing efficiency, when the CDN node obfuscates the first JavaScript script file to obtain the second JavaScript script file, it can determine the corresponding preferred obfuscation algorithm based on the client type of the client device that initiates the resource acquisition request, and then use the preferred obfuscation algorithm to obfuscate the first JavaScript script file to obtain the second JavaScript script file, thereby making the overall efficiency of the solution higher and the performance better.
[0050] Among them, the client type can be used to indicate the type of the client device. In this embodiment, UA (User Agent) information can be used to indicate the type of the client device. This information can be used to distinguish the browser version used by the client device, such as Mozilla / 5.0, Chrome / 12.0.742.122, Safari / 534.30 and other browser version information. For example, for a client device using the Mozilla / 5.0 browser, the CDN node can first determine the preferred obfuscation algorithm suitable for the client type, such as obfuscation algorithm ALG1, and then use the obfuscation algorithm ALG1 to obfuscate the first JavaScript script file to obtain the second JavaScript script file. For another example, for a client device using the Chrome / 12.0.742.122 browser, the CDN node can first determine the preferred obfuscation algorithm suitable for the client type, such as obfuscation algorithm ALG2, and then use the obfuscation algorithm ALG2 to obfuscate the first JavaScript script file to obtain the second JavaScript script file. Therefore, this solution can use a more appropriate obfuscation algorithm to generate corresponding second JavaScript script files for different types of client devices, so that the client devices have higher parsing efficiency when parsing their respective second JavaScript script files, thereby effectively improving processing performance.
[0051] In order to more accurately determine the obfuscation algorithms suitable for different client types, in the scheme of the embodiment of the present application, the method of determining the corresponding preferred obfuscation algorithm according to the client type of the client device that initiates the resource acquisition request includes: the CDN node device obtains information indicating the preferred obfuscation algorithms corresponding to different client types, and the information is obtained by counting and summarizing the performance data of different client types when parsing the second JavaScript script file to obtain the best obfuscation algorithm relationship corresponding to each client type. For example, the information indicating the preferred obfuscation algorithms corresponding to different client types can be in the form of a mapping table, which includes various different client types and their corresponding preferred obfuscation algorithms. The CDN node device can use the client type to query the mapping table to determine the preferred obfuscation algorithm suitable for the client type.
[0052] In some embodiments of the present application, information indicating preferred obfuscation algorithms corresponding to different client types can be obtained by statistics based on the response link tracking information of the second JavaScript script file generated by the solution of the present application. For example, after the CDN node device obtains the second JavaScript script file through obfuscation processing and sends it to the client device, it can obtain the response link tracking information of the second JavaScript script file. The response link tracking information is used to represent the performance information when the client device parses the second JavaScript script file.
[0053] Then, the CDN node device determines the preferred obfuscation algorithm corresponding to different client types based on the response link tracking information of the second JavaScript script file, the client type of the client device that initiates the resource acquisition request, and the obfuscation algorithm used when obfuscating the second JavaScript script file for different client types, and uses this as information for indicating the preferred obfuscation algorithm corresponding to different client types.
[0054] For example, in this embodiment, the response link tracking information may specifically be the duration of the second JavaScript script file parsed by the client device after obfuscation. After receiving the resource acquisition request from the client device, the CDN node may record the IP information of the client device that initiated the resource acquisition request as the identification of the client device, and may also obtain the client type of the client device.
[0055] When the CDN node responds to the second JavaScript script file (i.e., sends the second JavaScript script file to the client device), the time difference between subsequent requests for other pages initiated by the client device based on the second JavaScript script file can be counted. The time difference can be used as the time length for the client device to parse the obfuscated second JavaScript script file, i.e., the response link tracking information in this embodiment.
[0056] The CDN node device can perform data analysis based on the statistically obtained response link tracking information, combined with the client type of the client device that initiated the resource acquisition request, and the obfuscation algorithm used when obfuscating the second JavaScript script file for different client types. For a certain type of client device, the better the performance represented by the response link tracking information, the more suitable the obfuscation algorithm used for this obfuscation is for this type of client device. This can be used to analyze and determine the preferred obfuscation algorithm corresponding to different client types. Taking the following 6 groups of sample data corresponding to client devices with the same UA information as an example, two different obfuscation algorithms ALG1 and ALG2 were used respectively. The response link tracking information uses the length of time the client device takes to parse the obfuscated second JavaScript script file. The specific data is as follows:
[0057] Data 1: Obfuscation algorithm ALG1, parsing time 800ms,
[0058] Data 2: Obfuscation algorithm ALG1, parsing time 1600ms,
[0059] Data 3: Obfuscation algorithm ALG1, parsing time 12000ms,
[0060] Data 4: Obfuscation algorithm ALG2, parsing time 3000ms,
[0061] Data 5: Obfuscation algorithm ALG2, parsing time 4400ms,
[0062] Data 6: Obfuscation algorithm ALG2, parsing time 4000ms.
[0063] Therefore, it can be calculated that for this type of client device, when the first obfuscation algorithm ALG1 is used, the average parsing time of the client device parsing the obfuscated second JavaScript script file is 1200ms, and when the second obfuscation algorithm ALG2 is used, the average parsing time of the client device parsing the obfuscated second JavaScript script file is 3800ms. It can be seen that for this type of client device, when the first obfuscation algorithm ALG1 is used, the client device takes a shorter time to parse the second JavaScript script file, so the performance is better, and the obfuscation algorithm ALG1 can be determined as the preferred obfuscation algorithm corresponding to this type of client.
[0064] Here, those skilled in the art should understand that the number and specific content of the sample data used in the above embodiments are for example only. In actual scenarios, a larger number of sample data can be used for statistical analysis to obtain more accurate results. In addition, the above statistical analysis determines the processing process of the preferred obfuscation algorithm corresponding to different client types, which can also be implemented in a big data center on the cloud. That is, after obtaining the response link tracking information, the CDN node can upload the response link tracking information of the second JavaScript script file to the big data center for analysis, aggregate the performance information of the analysis of the client device with the same UA information, thereby analyzing the preferred obfuscation algorithm for different UA information, and providing it to the CDN node, so that the CDN node can select a preferred obfuscation algorithm with better performance according to the UA information of the client device before obfuscating the first JavaScript script file in the subsequent processing process, thereby obtaining a second JavaScript script file that is more suitable for the client device.
[0065] Figure 2 The process of implementing the interaction of web page resource acquisition request by using the solution of the embodiment of the present application is shown, wherein the interaction between the client device 100, the CDN node device 200 and the source station 300 mainly includes four steps, which are as follows:
[0066] Step S201: The browser of the client device accesses a web page and initiates a resource acquisition request to the CDN node device, requesting to obtain a JavaScript script file in the web page.
[0067] Step S202: The CDN node device requests the source site to obtain the original JavaScript script file.
[0068] Step S203: The source station sends the original JavaScript script file (ie, the first JavaScript script file) to the CDN node device according to the request of the CDN node device.
[0069] Step S204, the CDN node device uses an obfuscation tool such as Obfuscator to obfuscate the original JavaScript script file, obtain an obfuscated JavaScript script file (i.e., a second JavaScript script file), and send it to the client device. Since the obfuscated JavaScript script file still retains the syntax and structure of the programming language, the browser can dynamically interpret the execution principle, so the obfuscated JavaScript script file can still run normally in the browser.
[0070] The specific process of CDN node equipment in the above interaction process is as follows: Figure 3As shown, the following processing steps are included:
[0071] Step S301, after receiving the resource acquisition request initiated by the client device, the CDN node device can first determine whether the required resource file has been cached locally through the cache index. If so, execute step S305 and return it directly to the client device; if not, continue to execute step S302.
[0072] In step S302, after receiving the requested resource response content from the source station, the CDN node device determines whether the automatic processing mechanism is enabled based on the configuration information of the CDN service. If so, the Content-type field in the HTTP response header of the resource response content is obtained, and step S303 is continued. If not, step S305 is executed to directly return the resource file in the resource response content to the client device.
[0073] Step S303, parse the Content-type field to determine whether the resource file in the resource response content is a JavaScript script file. In this embodiment, if the content of the Content-type field is application / javascript or text / javascript, it indicates that it is a JavaScript script file, and continue to step S304. If it is other content, it indicates that it is not a JavaScript script file, and step S305 is executed to directly return the resource file to the client device.
[0074] Step S304, obfuscate the JavaScript script file and cache it in the local storage space to facilitate the cache index query in step S301.
[0075] Step S305: sending the resource file to the client device.
[0076] Therefore, by adopting the above solution, the website's operation and maintenance personnel do not need to have programming skills to use the obfuscation function of the JavaScript script file, and the entire processing process is automatically identified and obfuscated by the CDN node device. For the website's operation and maintenance personnel, there is no need to pay attention to whether the website has plain text JavaScript script files. All JavaScript script files can be automatically obfuscated by turning on the automatic processing mechanism when configuring the CDN acceleration service. At the same time, the obfuscation process will not affect the performance of the source station, but release the computing load of the obfuscation process to the CDN network, and because the CDN network has caching capabilities, it can greatly improve access efficiency and obfuscation efficiency.
[0077] In addition, the embodiment of the present application also provides a CDN node device for processing JavaScript script files, and the structure of the CDN node device is as follows: Figure 4 As shown, it at least includes a request acquisition module 410, a resource acquisition module 420, a resource processing module 430 and a resource response module 440. Among them, the request acquisition module 410 is used to receive a resource acquisition request from a client device; the resource acquisition module 420 is used to obtain a first JavaScript script file from an origin station according to the resource acquisition request; the resource processing module 430 is used to perform obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file; and the resource response module 440 is used to send the second JavaScript script file to the client device.
[0078] In addition, the present application also provides a computing device, the structure of which is as follows: Figure 5 As shown, it includes a memory 510 for storing computer program instructions and a processor 520 for executing computer program instructions, wherein when the computer program instructions are executed by the processor, the processor is triggered to execute the JavaScript script file processing method.
[0079] The methods and / or embodiments in the embodiments of the present application may be implemented as computer software programs. For example, the embodiments of the present disclosure include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program code for executing the method shown in the flowchart. When the computer program is executed by the processing unit, the above functions defined in the method of the present application are executed.
[0080] It should be noted that the computer-readable medium described in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device.
[0081] In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, device, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0082] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0083] The flow chart or block diagram in the accompanying drawings shows the possible architecture, function and operation of the equipment, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated system for hardware that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0084] As another aspect, the embodiments of the present application further provide a computer-readable medium, which may be included in the device described in the above embodiments; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more computer program instructions, which may be executed by a processor to implement the steps of the methods and / or technical solutions of the above multiple embodiments of the present application.
[0085] In addition, an embodiment of the present application also provides a computer program, which is stored in a computer device, so that the computer device executes the JavaScript script file processing method.
[0086] It should be noted that the present application can be implemented in software and / or a combination of software and hardware, for example, can be implemented using an application specific integrated circuit (ASIC), a general purpose computer or any other similar hardware device. In certain embodiments, the software program of the present application can be executed by a processor to implement the above steps or functions. Similarly, the software program of the present application (including related data structures) can be stored in a computer-readable recording medium, for example, a RAM memory, a magnetic or optical drive or a floppy disk and similar devices. In addition, some steps or functions of the present application can be implemented using hardware, for example, as a circuit that cooperates with a processor to perform each step or function.
[0087] It is obvious to those skilled in the art that the present application is not limited to the details of the above exemplary embodiments, and that the present application can be implemented in other specific forms without departing from the spirit or basic features of the present application. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present application is limited by the attached claims rather than the above description, so it is intended to include all changes that fall within the meaning and scope of the equivalent elements of the claims in the present application. Any figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the device claim can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
Claims
1. A JavaScript script file processing method, characterized in that: The method comprises: The CDN node device receives a resource acquisition request from a client device; The CDN node device obtains a first JavaScript script file from the source site according to the resource acquisition request; The CDN node device performs obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file; The CDN node device sends the second JavaScript script file to the client device.
2. The method according to claim 1, characterized in that The CDN node device performs obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file, including: The CDN node device determines whether to start the automatic processing mechanism; When the judgment result is yes, the CDN node device performs obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file.
3. The method according to claim 1, characterized in that The CDN node device obtains the corresponding first JavaScript script file from the source station according to the resource acquisition request, including: The CDN node device obtains the resource response content from the source station according to the resource acquisition request; The CDN node device determines, according to the content type field in the resource response content, whether the resource file in the resource response content is a first JavaScript script file; The CDN node device performs obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file, including: When the CDN node device determines that the resource file in the resource response content is a first JavaScript script file, the CDN node device performs obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file.
4. The method according to claim 3, characterized in that The method further comprises: When the CDN node device determines that the resource file in the resource response content is not the first JavaScript script file, the CDN node device directly sends the resource file to the client device.
5. The method according to claim 3, characterized in that: After the CDN node device performs obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file, the method further includes: The CDN node device caches a second JavaScript script file corresponding to the first JavaScript script file in a local storage space; After the CDN node device receives the resource acquisition request from the client device, the method further includes: The CDN node device determines, according to the resource acquisition request, whether a second JavaScript script file corresponding to the first JavaScript script file has been cached in the local storage space; If it has been cached, the CDN node device obtains the second JavaScript script file from the local storage space and sends the second JavaScript script file to the client device.
6. The method according to claim 1, characterized in that The CDN node device performs obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file, including: The CDN node device determines whether the first JavaScript script file has been obfuscated; If the first JavaScript script file has not been obfuscated, the CDN node device performs obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file; If the obfuscation process has been performed, the CDN node device directly sends the first JavaScript script file to the client device.
7. The method according to claim 1, characterized in that The CDN node device performs obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file, including: The CDN node device determines whether the first JavaScript script file has been obfuscated; If the first JavaScript script file has not been obfuscated, the CDN node device performs obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file; If the first JavaScript script file has been obfuscated, the CDN node device performs secondary obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file.
8. The method according to claim 1, characterized in that The CDN node device performs obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file, including: The CDN node device performs multiple obfuscation processes on the first JavaScript script file to obtain a second JavaScript script file.
9. The method according to claim 1, characterized in that: The CDN node device performs obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file, including: The CDN node device determines a corresponding preferred obfuscation algorithm according to the client type of the client device that initiates the resource acquisition request; The CDN node device uses the preferred obfuscation algorithm to perform obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file.
10. The method according to claim 9, characterized in that Determining the corresponding preferred obfuscation algorithm according to the client type of the client device that initiates the resource acquisition request includes: The CDN node device obtains information indicating preferred obfuscation algorithms corresponding to different client types, where the information is obtained by counting and summarizing performance data of different client types when parsing the second JavaScript script file to obtain the best obfuscation algorithm relationship corresponding to each client type.
11. A CDN node device for processing JavaScript script files, characterized in that: The CDN node device includes: A request acquisition module, used for receiving a resource acquisition request from a client device; A resource acquisition module, configured to acquire a first JavaScript script file from a source station according to the resource acquisition request; A resource processing module, used for performing obfuscation processing on the first JavaScript script file to obtain a second JavaScript script file; A resource response module is used to send the second JavaScript script file to the client device.
12. A computing device comprising a memory for storing computer program instructions and a processor for executing the computer program instructions, wherein: When the computer program instructions are executed by the processor, the device is triggered to execute the method according to any one of claims 1 to 10.
13. A computer readable medium having computer program instructions stored thereon, the computer program instructions being executable by a processor to implement the method according to any one of claims 1 to 10.