Page parameter processing method and device, electronic equipment and storage medium
By obtaining and freezing URL parameters and generating hidden protection parameters, the problem of URL link parameters in the browser is solved, and information security and cost reduction are achieved.
Patent Information
- Application Number
- CN202310546662.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-15
- Publication Date
- 2024-11-15
AI Technical Summary
When URL links in the browser are redirected, page parameters are easily tampered with. Current technologies such as server encryption and local storage also have problems with insecure information, resulting in increased development and maintenance costs.
By obtaining the URL parameters of the target page, determine whether there are variable parameters, freeze the parameter name and value as protection parameters, save it to global variables, and generate hidden protection parameters based on reset URL parameters, and send it to the user terminal to access the target page, avoiding Interact across technology stacks and servers to reduce development costs.
It effectively prevents tampering with URL link parameters, improves information security, reduces development and maintenance costs, realizes parameter protection in the browser, simplifies the length of URL links, and improves user experience.
Smart Images

Figure CN118964759A_ABST
Abstract
Description
Background Art
[0002] When a URL (Uniform Resource Locator) link jump is performed in a browser, the parameters required by the page are transmitted and displayed in the most direct way, that is, on the URL link, which may cause the problem of information tampering.
[0003] Using server-side encryption and other methods will also cause unnecessary requests, increasing the development and maintenance costs of requirements. Local storage technology and other technologies will still cause parameter information to be insecure and tampered with.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0005] The present disclosure provides a page parameter processing method, device, electronic device and computer-readable storage medium, which at least to a certain extent overcome the problem of page parameter tampering in the related art.
[0006] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.
[0007] According to one aspect of the present disclosure, a page parameter processing method is provided, including: obtaining a uniform resource locator URL parameter corresponding to a target page; determining whether the URL parameter has a variable parameter corresponding to the target page; in response to the variable parameter corresponding to the target page existing in the URL parameter, obtaining the parameter name and the parameter value corresponding to the parameter name from the URL parameter according to the parameter name in the variable parameter, and freezing the parameter name and the parameter value as a protection parameter; in response to the variable parameter corresponding to the target page not existing in the URL parameter, determining the URL parameter as a protection parameter; saving the protection parameter to a frozen global variable; generating a page parameter according to the target reset URL parameter and the frozen and saved protection parameter, and sending the page parameter to a user terminal so that the user terminal can access the target page according to the page parameter, wherein the target reset URL parameter is a URL parameter corresponding to the target page that hides the protection parameter.
[0008] In one embodiment of the present disclosure, it also includes: when the user visits the target page for the first time, saving the target reset URL parameters to local storage; when it is determined that the user refreshes the target page, obtaining the refresh reset URL parameters, wherein the refresh reset URL parameters are URL parameters of the hidden protection parameters corresponding to the refresh page; determining whether the refresh reset URL parameters are consistent with the target reset URL parameters; if so, sending the refresh reset URL parameters and the protection parameters called from the frozen global variables to the user so that the user can access the refresh page.
[0009] In one embodiment of the present disclosure, the method further includes: when it is monitored that the user exits the target page, the frozen global variable is reset to zero so that the frozen global variable stores a new target page.
[0010] In one embodiment of the present disclosure, it also includes: receiving the variable parameter based on an array parameter construction method.
[0011] In one embodiment of the present disclosure, the target reset URL parameter acquisition method includes: acquiring the routing parameters corresponding to the target page based on one or more browser path instructions; splicing the routing parameters to obtain the target reset URL parameters; acquiring the target reset URL parameters based on the reset browser instruction; the routing parameters include at least one of the following: protocol, port, domain name, path, anchor.
[0012] In one embodiment of the present disclosure, the URL parameter acquisition method includes: acquiring the URL string corresponding to the target page based on the browser path instruction; parsing the URL string to obtain the URL parameters; and acquiring the URL parameters based on a calling method.
[0013] In one embodiment of the present disclosure, the URL parameter acquisition method includes: acquiring the URL string corresponding to the target page based on the browser path instruction; disassembling the URL string to obtain one or more string arrays; and reorganizing the string array based on the ES6 function to generate the URL parameter.
[0014] In one embodiment of the present disclosure, it also includes: packaging any of the above methods into a plug-in through a software package manager.
[0015] According to another aspect of the present disclosure, a page parameter processing device is also provided, including:
[0016] The parameter acquisition module obtains the URL parameters corresponding to the target page;
[0017] A parameter determination module, determining whether the URL parameter contains variable parameters corresponding to the target page;
[0018] A first parameter determination module, in response to the variable parameter corresponding to the target page existing in the URL parameter, obtains the parameter name and the parameter value corresponding to the parameter name from the URL parameter according to the parameter name in the variable parameter, and freezes the parameter name and the parameter value as a protection parameter;
[0019] a second parameter determination module, in response to the absence of the variable parameter corresponding to the target page in the URL parameter, determining the URL parameter as a protection parameter;
[0020] A parameter storage module, storing the protection parameters to a frozen global variable;
[0021] The parameter generation module generates page parameters according to the target reset URL parameters and the frozen and saved protection parameters, and sends them to the user terminal so that the user terminal can access the target page according to the page parameters, wherein the target reset URL parameters are URL parameters of the hidden protection parameters corresponding to the target page.
[0022] According to another aspect of the present disclosure, an electronic device is provided, including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute any one of the above-mentioned page parameter processing methods by executing the executable instructions.
[0023] According to another aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, any one of the above page parameter processing methods is implemented.
[0024] The page parameter processing method, device, electronic device and computer-readable storage medium provided by the embodiments of the present disclosure obtain the uniform resource locator URL parameter corresponding to the target page; determine whether the URL parameter has a variable parameter corresponding to the target page; in response to the variable parameter corresponding to the target page in the URL parameter, obtain the parameter name and the parameter value corresponding to the parameter name from the URL parameter according to the parameter name in the variable parameter, and freeze the parameter name and the parameter value as a protection parameter; in response to the variable parameter corresponding to the target page not existing in the URL parameter, determine the URL parameter as a protection parameter; save the protection parameter to a frozen global variable; generate page parameters according to the target reset URL parameter and the frozen and saved protection parameter, and send them to the user terminal so that the user terminal can access the target page according to the page parameters, wherein the target reset URL parameter is the URL parameter of the hidden protection parameter corresponding to the target page; the method relies on the browser technology implementation, does not have the limitations caused by cross-technology stack, avoids interaction with the server, reduces development and maintenance costs, and prevents the page parameters from being tampered with due to the exposure of URL link parameters.
[0025] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0027] Figure 1 A flow chart of a page parameter processing method in an embodiment of the present disclosure is shown;
[0028] Figure 2 A flow chart of a page refresh processing method in an embodiment of the present disclosure is shown;
[0029] Figure 3 A flow chart of a method for obtaining target reset URL parameters in an embodiment of the present disclosure is shown;
[0030] Figure 4 A flow chart of a method for obtaining URL parameters in an embodiment of the present disclosure is shown;
[0031] Figure 5 A flowchart of another method for obtaining URL parameters in an embodiment of the present disclosure is shown;
[0032] Figure 6 A schematic diagram of a page parameter processing device in an embodiment of the present disclosure is shown;
[0033] Figure 7 A flow chart of another method for processing page parameters in an embodiment of the present disclosure is shown; and
[0034] Figure 8 A structural block diagram of an electronic device in an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0035] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the disclosure will be more comprehensive and complete and to fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
[0036] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0037] For ease of understanding, several terms involved in the present disclosure are explained below:
[0038] URL (Uniform Resource Locator) is a concise representation of the location and access method of resources obtained on the Internet. It is the address of standard resources on the Internet.
[0039] Rollup is a JavaScript module bundler that compiles small chunks of code into larger, more complex chunks of code.
[0040] The npm package manager is the standard package manager for Node.js.
[0041] Babel is a toolchain that converts code written in ES6 syntax into backward-compatible JavaScript syntax so that it can run in current and older versions of browser environments.
[0042] JavaScript is the web programming language.
[0043] The present exemplary implementation is described in detail below with reference to the accompanying drawings and embodiments.
[0044] First, a page parameter processing method is provided in an embodiment of the present disclosure, and the method can be executed by any electronic device with computing and processing capabilities.
[0045] Figure 1 A flow chart of a page parameter processing method in an embodiment of the present disclosure is shown as follows: Figure 1 As shown, the page parameter processing method provided in the embodiment of the present disclosure includes the following steps:
[0046] S102, obtaining the uniform resource locator URL parameter corresponding to the target page;
[0047] S104, determining whether the URL parameters contain variable parameters corresponding to the target page.
[0048] In one embodiment, a construction method based on an array parameter receives variable parameters; specifically, a construction method PreventModified(params) that can receive a parameter array is defined, that is, protected variable parameters are received through PreventModified(params), and based on the params parameter passing format of the routing library, parameters can be directly hidden on the URL link, preventing users from directly modifying parameter values on the URL.
[0049] It should be noted that array parameters are customized according to user needs; the array parameter construction method is a general method, which can be simply understood as receiving variable parameters passed in by the user, performing corresponding calculations on the received variable parameters in the function, and finally returning the calculation results.
[0050] S106, in response to the existence of a variable parameter corresponding to the target page in the URL parameter, obtain the parameter name and the parameter value corresponding to the parameter name from the URL parameter according to the parameter name in the variable parameter, and freeze the parameter name and the parameter value as a protection parameter.
[0051] In one embodiment, the number of URL parameters obtained is greater than or equal to the Params array parameters, and the two are compared to find the protection parameters that need to be protected; the protection parameters are user-defined Params array parameters, but the user only defines the parameter name, which needs to be compared with the URL parameters, and the parameter name that needs to be protected and the parameter value corresponding to the parameter are obtained from the URL parameters.
[0052] For example, if the URL parameter is http: / / www.aaa.com?name='bbb', then the URL link without variable parameters is http: / / www.aaa.com, and the variable parameters are: name='bbb'; the parameter name and parameter value obtained after comparing the variable parameters with the URL parameters are frozen and saved, that is, "name='bbb'" is frozen and saved.
[0053] S108, in response to the absence of variable parameters corresponding to the target page in the URL parameters, determining the URL parameters as protection parameters, and requiring that the URL parameters all be subjected to anti-tampering protection operations.
[0054] In one embodiment, navigator.serAgnt can be used to determine whether the current browser environment is IE11. If so, the URL string corresponding to the target page is obtained based on the browser path instruction, the URL string is parsed to obtain URL parameters, and the URL parameters are obtained based on the calling method, the URL parameter acquisition method; otherwise, the URL string corresponding to the target page is obtained based on the browser path instruction; the URL string is disassembled to obtain one or more string arrays; the string array is reorganized based on the ES6 function to generate URL parameters.
[0055] In one embodiment, a URL string corresponding to a target page is obtained based on a browser path instruction, the URL string is parsed to obtain URL parameters, and the URL parameters are obtained based on a calling method. When the URL parameter obtaining method fails to obtain the URL parameters, the URL string corresponding to the target page is obtained based on the browser path instruction; the URL string is disassembled to obtain one or more string arrays; and the string array is reorganized based on an ES6 function to generate URL parameters.
[0056] S110, saving the protection parameter to the frozen global variable.
[0057] In one embodiment, Object.freeze is used to create a frozen global variable frozenObj for storage, and the frozenObj storage is not allowed to be modified by the user.
[0058] In one embodiment, when it is monitored that the user exits the target page, the frozen global variable is reset to zero so that the frozen global variable stores the new target page.
[0059] S112, generating page parameters according to the target reset URL parameters and the frozen and saved protection parameters, and sending them to the user terminal so that the user terminal can access the target page according to the page parameters, wherein the target reset URL parameters are URL parameters of the hidden protection parameters corresponding to the target page.
[0060] In one embodiment, any of the above methods is packaged into a plug-in through a software package manager; JavaScript is used as the basic implementation language, and the Rollup packaging tool is used to implement the packaged output of the code, and finally the npm plug-in is released to facilitate any web browser front-end application to install and use at any time, truly realizing the function of preventing browser URL link parameters from being tampered with in zero steps, and ensuring the security of information.
[0061] In the above embodiment, the array parameter construction method is used to obtain and save the routing parameters, and the URL parameters are redefined to hide the routing parameters to achieve basic parameter information hiding and store them in the browser. The URL parameter tamper-proofing is completely dependent on the browser technology, and the URL link length can be minimized to avoid the problem of being restricted by the browser parameter length process. There are no limitations caused by cross-technology stacks, and interaction with the server is avoided, reducing development and maintenance costs.
[0062] Figure 2 A flow chart of a page refresh processing method in an embodiment of the present disclosure is shown as follows: Figure 2 As shown, the page refresh processing method provided in the embodiment of the present disclosure includes the following steps:
[0063] S202: When the user visits the target page for the first time, the target reset URL parameters are saved to local storage.
[0064] In one embodiment, the local storage may be WebStorage local storage, which may directly obtain the stored target reset URL parameters, thereby preventing the target reset URL parameters from being exposed on the URL link to prevent tampering and reduce interaction with the server.
[0065] S204: When it is determined that the user refreshes the target page, a refresh reset URL parameter is obtained.
[0066] The refresh reset URL parameters are URL parameters of the hidden protection parameters corresponding to the refresh page.
[0067] In one embodiment, the window.onLoad() method is used to monitor whether the user refreshes the target page. The method for obtaining the refresh reset URL parameter is the same as the method for obtaining the target reset URL parameter, which will not be described in detail here.
[0068] The window object represents the window opened in the browser. The window and window call methods involved are all provided by the browser.
[0069] S206, determining whether the refresh reset URL parameters are consistent with the target reset URL parameters.
[0070] S208, if yes, then sending the refresh reset URL parameter and the protection parameter called from the frozen global variable to the user so that the user can access the refresh page;
[0071] S210: Otherwise, the page parameters of the refreshed page are processed again according to the above page parameter processing method.
[0072] In the above embodiment, by determining whether the refresh reset URL parameter is consistent with the target reset URL parameter, various technologies provided by the browser itself are combined to solve some problems such as refreshing URL links, thereby further preventing malicious modification of URL link parameters.
[0073] Figure 3 A flow chart of a method for obtaining target reset URL parameters in an embodiment of the present disclosure is shown as follows: Figure 3 As shown, the target reset URL parameter acquisition method provided in the embodiment of the present disclosure includes the following steps:
[0074] S302: Obtain routing parameters corresponding to the target page based on one or more browser path instructions.
[0075] In one embodiment, the browser path instructions include but are not limited to: window.location.protocol, window.location.host, window.location.pathname, window.location.port, window.location.search, etc., and the corresponding routing parameters are obtained through one or more browser path instructions; the routing parameters include at least one of the following: protocol, port, domain name, path, anchor.
[0076] For example, use window.location.protocol to get the protocol corresponding to the current URL, window.location.host to get the domain name, and window.location.pathname to get the route name.
[0077] S304, concatenate the route parameters to obtain target reset URL parameters.
[0078] In one embodiment, the routing parameters of the current URL, such as the protocol, port, domain name, path name, anchor point, etc., are concatenated to obtain the target reset URL parameters.
[0079] S306: Obtain target reset URL parameters based on the browser reset instruction.
[0080] In one embodiment, the reset browser command window.location.repace(noParamsURL) is used to obtain the target reset URL parameters.
[0081] It should be noted that window.location.repace is a method provided by the browser to refresh the page, and noParamsURL is to redefine the selected parameters, so that the browser parameters can be changed again.
[0082] In the above embodiment, URL parameters are redefined to hide routing parameters to achieve basic parameter information hiding, which completely relies on various technologies provided by the browser itself to achieve URL parameter tamper-proofing, and can minimize the URL link length to avoid the problem of being limited by the browser parameter length process. At the same time, the URL link looks relatively concise, providing a better user experience.
[0083] Figure 4 A flow chart of a method for obtaining URL parameters in an embodiment of the present disclosure is shown as follows: Figure 4 As shown, the URL parameter acquisition method provided in the embodiment of the present disclosure includes the following steps:
[0084] S402, obtaining a URL string corresponding to a target page based on the browser path instruction.
[0085] In one embodiment, the URL string is obtained through a method provided by the browser window, that is, the browser path instruction window.location.search, for example, a URL string of "name='bbb'&sex=1" is obtained.
[0086] S404, parsing the URL character string to obtain URL parameters.
[0087] In one embodiment, the entries function provided by the URLSearchParams(string) construction method, ie, newURLSearchParams(string).entries(), parses the current URL string into an object that can be queried for key / value pairs.
[0088] S406, obtaining URL parameters based on the calling method.
[0089] In one embodiment, the Object.fromEntries() method is used to further parse the key / value pair object into an object from which the value can be directly obtained, that is, the URL parameter.
[0090] In the above embodiment, all parameters of the URL are obtained based on the JavaScript language combined with various native methods exposed by the browser, and the URL parameters are redefined to hide the routing parameters to achieve basic parameter information hiding. The URL parameter tamper-proofing is completely achieved by relying entirely on various technologies provided by the browser itself, thereby protecting the security of the program and providing users with a good user experience.
[0091] Figure 5 A flow chart of another method for obtaining URL parameters in an embodiment of the present disclosure is shown as follows: Figure 5 As shown, the URL parameter acquisition method provided in the embodiment of the present disclosure includes the following steps:
[0092] S502, obtaining a URL string corresponding to a target page based on a browser path instruction;
[0093] In one embodiment, the URL string is obtained through a method provided by the browser window, that is, the browser path instruction window.location.search, for example, a URL string of "name='bbb'&sex=1" is obtained.
[0094] S504, decomposing the URL string to obtain one or more string arrays;
[0095] In one embodiment, the slice, indexOf and split methods are used to decompose the URL string, and finally an array containing one or more strings is returned. For example, the URL string "name="bbb"&sex="1" is decomposed into "[name="bbb",sex="1]".
[0096] S506, reorganize the string array based on the ES6 function to generate URL parameters.
[0097] In one embodiment, the ES6 conversion related tools are configured to reassemble the string array through the Array.map() and split() methods, and finally return an object of queryable key / value pairs, namely, URL parameters.
[0098] In the above embodiment, JavaScript language is combined with various native methods exposed by the browser to obtain all parameters of the URL, and hidden routing parameters are redefined for the URL link to achieve the function of preventing browser URL link parameters from being tampered with. Compatibility issues are patched and repaired. At the same time, only a general method is exposed to the outside, which can be used with zero learning. Ultimately, the browser URL link parameters are prevented from being tampered with, the security of the program is protected, and a good user experience is provided to users.
[0099] Based on the same inventive concept, the present disclosure also provides a page parameter processing device, such as the following embodiment. Since the principle of solving the problem in the device embodiment is similar to that in the above method embodiment, the implementation of the device embodiment can refer to the implementation of the above method embodiment, and the repeated parts will not be repeated.
[0100] Figure 6 A schematic diagram of a page parameter processing device in an embodiment of the present disclosure is shown. Figure 6 As shown, the page parameter processing device 6 includes: a parameter acquisition module 601, a parameter judgment module 602, a first parameter determination module 603, a second parameter determination module 604, a parameter storage module 605 and a parameter generation module 606;
[0101] The parameter acquisition module 601 obtains the uniform resource locator URL parameter corresponding to the target page;
[0102] Parameter determination module 602, determines whether the URL parameters contain variable parameters corresponding to the target page;
[0103] The first parameter determination module 603, in response to the existence of a variable parameter corresponding to the target page in the URL parameter, obtains the parameter name and the parameter value corresponding to the parameter name from the URL parameter according to the parameter name in the variable parameter, and freezes the parameter name and the parameter value as a protection parameter;
[0104] The second parameter determination module 604, in response to the absence of a variable parameter corresponding to the target page in the URL parameter, determines the URL parameter as a protection parameter;
[0105] The parameter storage module 605 saves the protection parameters to the frozen global variables;
[0106] The parameter generation module 606 generates page parameters according to the target reset URL parameters and the frozen and saved protection parameters, and sends them to the user terminal so that the user terminal can access the target page according to the page parameters, wherein the target reset URL parameters are URL parameters of the hidden protection parameters corresponding to the target page.
[0107] In the above embodiment, a universal network interface based on a browser is provided to the Web front-end application. The good compatibility performance of the browser and the natural advantage of not having to cross the technology stack are utilized to hide the URL link parameters and store them in the browser, thereby fundamentally solving the problem of parameter tampering caused by the exposure of the URL link parameters, achieving a simple and secure browser URL link parameter tampering prevention effect, and minimizing the URL link length to avoid the problem of being restricted by the browser parameter length process. At the same time, the URL link looks relatively concise, providing a better user experience.
[0108] Figure 7 A flow chart of another method for processing page parameters in an embodiment of the present disclosure is shown. Figure 7 As shown, the page parameter processing method provided in the embodiment of the present disclosure includes the following steps:
[0109] S702, create a new project, install the Rollup packaging tool and configure the rollup.config.js file, configure the npm command to facilitate the installation and download of the required dependencies, install babel to solve the compatibility issues of some methods, and after configuring the tools required for the project, you can implement the main content details.
[0110] npm package manager: It is the standard package manager for Node.js. npm init creates a package.json file in the project. This file is mainly used to record the detailed information of the project. It will record the packages we will use in project development and the detailed information of the project in this project. The project may depend on one or more external dependency packages. Configure the relevant npm instructions to facilitate the installation and download of the required dependency packages.
[0111] In one embodiment, npm init -y is used to create a package locally, and configuration information is filled in. The configuration information includes all package dependency information. The package dependency information includes one or a combination of two or more of the package name, version, author, git repository address, keywords, and certificates. Finally, a package.json public configuration file is generated.
[0112] In one embodiment, the npm package manager installs the Rollup packaging tool and Babel, and creates a new rollup.config.js in the root directory. The rollup.config.js is used to configure the environment variables used in the script.
[0113] S704, define a construction method PreventModified(params) that can accept params (parameter array), and finally return a protected frozen object params parameter, and at the same time create a frozen global variable for subsequent storage of params parameter.
[0114] S706, obtaining all parameters on the URL link, first using the method provided by the browser window to obtain the query string, that is, window.location.search, the data structure of the final result obtained is similar to the string of "name='bbb'&sex=1".
[0115] S708, determining whether the browser is IE11.
[0116] First, you can use navigator.serAgnt to determine whether the current browser environment is IE11. If not, the method in S710 is used by default to obtain URL link parameters. If it is IE11, the method in S712 compatible with IE11 is used to obtain parameters.
[0117] S710, if not, use the entries function provided by the URLSearchParams(string) construction method, i.e. newURLSearchParams(string).entries() to parse the query string of the current URL link to provide access value, and finally parse the query parameters into an object. If you want to access this object, you also need to use the Object.fromEntries() method to further parse this object into an object that can directly obtain the value.
[0118] S712, if so, use window.location.search to get the query string first, then use slice, indexOf and split methods to disassemble the string, and finally return an array containing n strings, similar to [name = 'bbb', sex = 1], and finally use the Array.map() and split() methods provided in ES6 to recombine the array, and finally return an object of queryable key / value pairs. Because this project is configured with related tools for ES6 conversion, there is no compatibility issue with the map method.
[0119] S714, after obtaining all the parameters of the URL link, it is necessary to determine which parameters need to be tamper-proofed according to the params parameter obtained by the PreventModified(params) method, and determine whether the PreventModified method obtains an array parameter.
[0120] S716, the PreventModified method does not receive any parameters, and by default all parameters of the URL link need to be tamper-proofed.
[0121] S718, the PreventModified method obtains an array parameter, so it needs to traverse the array and URL parameter object to select the parameters that need to be protected against tampering, and return the final value.
[0122] S720, after obtaining the URL parameters that need to be protected, use Object.freeze to create a frozen global variable frozenObj for storage, and manually perform garbage collection before exiting the page, that is, set frozenObj to null, which will not affect the function of entering this page next time.
[0123] S722, after the acquisition and storage work is completed, the URL parameters on the URL link need to be hidden. First, you need to obtain the complete link except the Params parameter; use window.location.protocol to obtain the link of the current URL, window.location.host to obtain the domain name, and window.location.pathname to obtain the route name. Finally, splice them to obtain the final required URL link noParamsURL (without parameters). Next, we need to revisit the new URL link and use window.location.repace(noParamsURL) to hide the original parameters on the URL link.
[0124] S724, the parameters on the URL link must be carried only when they are needed by the page, so the operation of obtaining URL parameters from the URL link can now be directly obtained from the frozenObj object and used where needed. Because the frozenObj object is a frozen object, it is impossible to modify it in the code, which further protects the parameters.
[0125] In one embodiment, in order to further prevent malicious modification of URL link parameters, when entering a page for the first time, the current URL link noParamsURL needs to be saved locally using local LocalStorage storage;
[0126] Every time the current page is refreshed, the window.onLoad() method is used for monitoring. After the refresh is completed, if the current URL link is consistent with the local LocalStorage storage, even if the URL link parameters are modified, the frozen global variable frozenObj is still used. Otherwise, it is calculated again according to the above logic.
[0127] S726, finally the technical means of this solution is released as a universal npm plug-in, packaged and published on the npm official website, so that any web browser front-end application can be installed and used at any time, truly realizing the function of preventing browser URL link parameters from being tampered with in zero steps, and ensuring the security of information.
[0128] In one embodiment, the page parameter processing may be applied to a terminal device, which may be a variety of electronic devices, including but not limited to a smart phone, a tablet computer, a laptop computer, a desktop computer, and the like.
[0129] Optionally, the client of the application installed in different terminal devices is the same, or the client of the same type of application based on different operating systems. Based on the different terminal platforms, the specific form of the client of the application can also be different, for example, the application client can be a mobile client, a PC client, etc.
[0130] In the above embodiment, the URL link parameters are hidden and stored in the browser, which fundamentally solves the problem of parameter tampering caused by the exposure of URL link parameters. Rollup is used to compile and package the npm plug-in, which is lighter than other packaging tools. Developers can install and use it faster, which will not increase the size of the program and is lighter to use.
[0131] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as "circuits", "modules" or "systems".
[0132] Refer to the following Figure 8 The electronic device 800 according to this embodiment of the present disclosure is described. Figure 8 The electronic device 800 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0133] like Figure 8 As shown, the electronic device 800 is in the form of a general computing device. The components of the electronic device 800 may include but are not limited to: at least one processing unit 810, at least one storage unit 820, and a bus 830 connecting different system components (including the storage unit 820 and the processing unit 810).
[0134] The storage unit stores program codes, which can be executed by the processing unit 810, so that the processing unit 810 executes the steps described in the above “exemplary method” section of this specification according to various exemplary embodiments of the present disclosure.
[0135] For example, the processing unit 810 can execute the following steps of the above method embodiment: obtaining the uniform resource locator URL parameter corresponding to the target page; determining whether the URL parameter has a variable parameter corresponding to the target page; in response to the presence of the variable parameter corresponding to the target page in the URL parameter, obtaining the parameter name and the parameter value corresponding to the parameter name from the URL parameter according to the parameter name in the variable parameter, and freezing the parameter name and the parameter value as protection parameters; in response to the absence of the variable parameter corresponding to the target page in the URL parameter, determining the URL parameter as a protection parameter; saving the protection parameter to a frozen global variable; generating a page parameter according to the target reset URL parameter and the frozen and saved protection parameter, and sending it to the user terminal so that the user terminal accesses the target page according to the page parameter, wherein the target reset URL parameter is a URL parameter of the hidden protection parameter corresponding to the target page.
[0136] For example, the processing unit 810 can execute the following steps of the above method embodiment: when the user visits the target page for the first time, the target reset URL parameters are saved to local storage; when it is determined that the user refreshes the target page, the refresh reset URL parameters are obtained, wherein the refresh reset URL parameters are URL parameters of the hidden protection parameters corresponding to the refresh page; it is determined whether the refresh reset URL parameters are consistent with the target reset URL parameters; if so, the refresh reset URL parameters and the protection parameters called from the frozen global variables are sent to the user so that the user can access the refresh page.
[0137] For example, the processing unit 810 can execute the following steps of the above method embodiment: obtain the routing parameters corresponding to the target page based on one or more browser path instructions; splice the routing parameters to obtain the target reset URL parameters; obtain the target reset URL parameters based on the reset browser instruction.
[0138] The storage unit 820 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 8201 and / or a cache memory unit 8202 , and may further include a read-only memory unit (ROM) 8203 .
[0139] The storage unit 820 may also include a program / utility 8204 having a set (at least one) of program modules 8205, such program modules 8205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0140] Bus 830 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0141] The electronic device 800 may also communicate with one or more external devices 840 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 800, and / or communicate with any device that enables the electronic device 800 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 850. Furthermore, the electronic device 800 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 860. As shown, the network adapter 860 communicates with other modules of the electronic device 800 via a bus 830. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 800, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0142] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0143] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, which may be a readable signal medium or a readable storage medium. A program product capable of implementing the above method of the present disclosure is stored thereon. In some possible implementations, various aspects of the present disclosure may also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to cause the terminal device to execute the steps according to various exemplary implementations of the present disclosure described in the above “Exemplary Method” section of this specification.
[0144] For example, when the program product in the embodiment of the present disclosure is executed by a processor, the following steps are implemented: obtaining a uniform resource locator URL parameter corresponding to a target page; determining whether the URL parameter has a variable parameter corresponding to the target page; in response to the variable parameter corresponding to the target page existing in the URL parameter, obtaining the parameter name and the parameter value corresponding to the parameter name from the URL parameter according to the parameter name in the variable parameter, and freezing the parameter name and the parameter value as a protection parameter; in response to the variable parameter corresponding to the target page not existing in the URL parameter, determining the URL parameter as a protection parameter; saving the protection parameter to a frozen global variable; generating a page parameter according to the target reset URL parameter and the frozen and saved protection parameter, and sending the page parameter to a user terminal so that the user terminal can access the target page according to the page parameter, wherein the target reset URL parameter is a URL parameter corresponding to the target page that hides the protection parameter.
[0145] For example, the program product in the embodiment of the present disclosure implements the following steps when executed by a processor: when a user visits the target page for the first time, the target reset URL parameters are saved to local storage; when it is determined that the user refreshes the target page, the refresh reset URL parameters are obtained, wherein the refresh reset URL parameters are URL parameters of hidden protection parameters corresponding to the refresh page; it is determined whether the refresh reset URL parameters are consistent with the target reset URL parameters; if so, the refresh reset URL parameters and the protection parameters called from the frozen global variables are sent to the user so that the user can access the refresh page.
[0146] For example, when the program product in the embodiment of the present disclosure is executed by a processor, the method implements the following steps: obtaining routing parameters corresponding to the target page based on one or more browser path instructions; splicing the routing parameters to obtain target reset URL parameters; obtaining target reset URL parameters based on the reset browser instruction.
[0147] More specific examples of computer-readable storage media in the present disclosure may include, but are not limited to, an electrical connection having one or more conductors, 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), 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 foregoing.
[0148] In the present disclosure, a computer readable storage medium may include a data signal propagated in baseband or as part of a carrier wave, wherein a readable program code is carried. 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 readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0149] Alternatively, the program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0150] In a specific implementation, the program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).
[0151] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0152] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0153] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0154] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the appended claims.
Claims
1. A page parameter processing method, characterized in that: include: Get the uniform resource locator URL parameters corresponding to the target page; Determine whether the URL parameters contain variable parameters corresponding to the target page; In response to the variable parameter corresponding to the target page existing in the URL parameter, according to the parameter name in the variable parameter, the parameter name and the parameter value corresponding to the parameter name are obtained from the URL parameter, and the parameter name and the parameter value are frozen and determined as protection parameters; In response to the variable parameter corresponding to the target page not existing in the URL parameter, determining the URL parameter as a protection parameter; Saving the protection parameter to a frozen global variable; Page parameters are generated according to the target reset URL parameters and the frozen and saved protection parameters, and sent to the user terminal so that the user terminal can access the target page according to the page parameters, wherein the target reset URL parameters are URL parameters of the hidden protection parameters corresponding to the target page.
2. The page parameter processing method according to claim 1, characterized in that: Also includes: When the user visits the target page for the first time, the target reset URL parameters are saved to local storage; When it is determined that the user refreshes the target page, a refresh reset URL parameter is obtained, wherein the refresh reset URL parameter is a URL parameter of a hidden protection parameter corresponding to the refresh page; Determine whether the refresh reset URL parameters are consistent with the target reset URL parameters; If so, the refresh reset URL parameter and the protection parameter called from the frozen global variable are sent to the user so that the user can access the refresh page.
3. The page parameter processing method according to claim 1, characterized in that: Also includes: When it is monitored that the user exits the target page, the frozen global variable is reset to zero so that the frozen global variable stores a new target page.
4. The page parameter processing method according to claim 1, characterized in that: Also includes: The array parameter based construction method receives the variable parameters.
5. The page parameter processing method according to claim 2, characterized in that: The target reset URL parameter acquisition method includes: Obtaining routing parameters corresponding to the target page based on one or more browser path instructions; Concatenate the routing parameters to obtain the target reset URL parameters; Obtain the target reset URL parameter based on the reset browser instruction; The routing parameters include at least one of the following: protocol, port, domain name, path, anchor point.
6. The page parameter processing method according to claim 1, characterized in that: The obtaining of the URL parameter corresponding to the target page includes: Obtaining the URL string corresponding to the target page based on the browser path instruction; Parsing the URL string to obtain the URL parameters; The URL parameters are obtained based on the calling method.
7. The page parameter processing method according to claim 1, characterized in that: The obtaining of the URL parameter corresponding to the target page includes: Obtaining the URL string corresponding to the target page based on the browser path instruction; Decomposing the URL string to obtain one or more string arrays; The URL parameters are generated by reorganizing the string array based on the ES6 function.
8. The page parameter processing method according to claim 1, characterized in that: Also includes: The method according to any one of claims 1 to 7 is packaged into a plug-in through a software package manager.
9. A page parameter processing device, characterized in that: include: The parameter acquisition module obtains the URL parameters corresponding to the target page; A parameter determination module, determining whether the URL parameter contains variable parameters corresponding to the target page; A first parameter determination module, in response to the variable parameter corresponding to the target page existing in the URL parameter, obtains the parameter name and the parameter value corresponding to the parameter name from the URL parameter according to the parameter name in the variable parameter, and freezes the parameter name and the parameter value as a protection parameter; a second parameter determination module, in response to the absence of the variable parameter corresponding to the target page in the URL parameter, determining the URL parameter as a protection parameter; A parameter storage module, storing the protection parameters to a frozen global variable; The parameter generation module generates page parameters according to the target reset URL parameters and the frozen and saved protection parameters, and sends them to the user terminal so that the user terminal can access the target page according to the page parameters, wherein the target reset URL parameters are URL parameters of the hidden protection parameters corresponding to the target page.
10. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the page parameter processing method according to any one of claims 1 to 8 by executing the executable instructions.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the page parameter processing method according to any one of claims 1 to 8 is implemented.
