An implementation method and implementation component of an electron desktop application executing a script

CN115729646BActive Publication Date: 2026-09-15INSPUR QILU SOFTWARE IND
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211598289.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-14
Publication Date
2026-09-15
Estimated Expiration
2042-12-14

AI Technical Summary

Technical Problem

此操作不适用打包好的electron应用,所以需要引入提权组件,现有的提权组件主要有sudo-prompt、electron-sudo等组件,这些组件都是调用操作系统提供的提权通道,比如KDE图形界面默认内置/usr/bin/kdesudo,这些提权通道的缺陷是每执行一次脚本就需输入一次密码,界面样式跟随操作系统,个性化需求难实现,不可管理用户密码

Benefits of technology

[0031] This invention provides privilege escalation for Electron-based desktop applications, enabling flexible password management and personalized modification of password input fields. It also eliminates the need for administrator privileges to run the software, thus improving security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115729646B_ABST
    Figure CN115729646B_ABST
Patent Text Reader

Abstract

The application discloses an implementation method and implementation component of an electron desktop application execution script, relates to the technical field of desktop application programs, and has the implementation content including the following steps: downloading an electron desktop application which has been packaged, inputting an execution script of the electron desktop application into a script risk checking library and a script execution required permission library to judge whether the execution script conforms to a risk level and execution required permission which are configured and set; when the execution script conforms to the set risk level and the execution script is executed with administrator permission, calling an exec module after obtaining a password of a password input interface in a dialog box, judging whether the password is correct and the number of inputtable errors according to feedback information error, stdout and stderr of the exec module, returning a success state when execution is successful, returning an error state and information when execution is wrong, and processing by a developer himself / herself. The application can improve the safety degree, the convenience degree, the individualization degree and the operability of the execution script of the desktop application.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of desktop application technology, specifically to a method and components for implementing scripts in an Electron desktop application. Background Technology

[0002] In recent years, as China's position in globalization has become increasingly important, national information security has become a more prominent issue. To ensure national information security, the country has implemented a series of measures to promote domestic production. Domestic software and hardware manufacturers have also made significant progress, leading to a growing demand for Linux desktop software development. Among these, Electron and nwjs, based on Node.js, are popular among developers and users due to their ease of use, high development efficiency, and rich frameworks. During development, some functionalities require script execution. For example, when Electron calls a software installation command, the Node.js `exec` module needs to be imported to pass the command string. This command is often subject to system permission restrictions. When executing the script via shell, `sudo` needs to be added before the command. After execution, the administrator password needs to be entered in the console for successful password verification before the script can execute. This operation is not applicable to packaged Electron applications, so a privilege escalation component needs to be introduced. Existing privilege escalation components mainly include sudo-prompt, electron-sudo, etc. These components all call the privilege escalation channel provided by the operating system. For example, the KDE graphical interface has / usr / bin / kdesudo built in by default. The drawback of these privilege escalation channels is that a password needs to be entered every time the script is executed, the interface style follows the operating system, it is difficult to realize personalized needs, and user passwords cannot be managed. Summary of the Invention

[0003] This invention addresses the needs and shortcomings of current technological development by providing a method and components for implementing script execution in Electron desktop applications, thereby improving the security, convenience, personalization, and operability of script execution in desktop applications.

[0004] First, the present invention provides a method for implementing script execution in an Electron desktop application, and the technical solution adopted to solve the above-mentioned technical problems is as follows:

[0005] A method for executing scripts in an Electron desktop application includes the following steps:

[0006] Download the pre-packaged Electron desktop application, and pass the execution script of the Electron desktop application to the script risk verification library and the script execution permission library to determine whether the execution script meets the risk level and execution permission set in the configuration.

[0007] When the execution of the script meets the set risk level and is executed with normal user privileges, a success status will be returned if the execution is successful, and an error status and information will be returned if the execution fails, which will be handled by the developers themselves.

[0008] When the script execution meets the set risk level and is executed with administrator privileges, it retrieves the password from the password input interface in the dialog box and calls the exec module. Based on the error, stdout, and stderr feedback information from the exec module, it determines whether the password is correct and the number of incorrect attempts allowed. If the execution is successful, it returns a success status; otherwise, it returns an error status and information for developers to handle.

[0009] Optionally, the script risk verification library has conditions for low-risk scripts and conditions for high-risk scripts. If the passed-in execution script meets the conditions for low-risk scripts, the permission determination for script execution will continue. If the passed-in execution script meets the conditions for high-risk scripts, the execution will end directly.

[0010] The script execution permission library has settings for script types that require administrator privileges to run and script types that require regular user privileges to run. Scripts that require administrator privileges to run require a correct password to run, while scripts that require regular user privileges can run without a password.

[0011] Optionally, when the script is executed with administrator privileges, after the user successfully enters the password through the password input interface and the script is executed successfully, the password is stored in the cache, and the password can be retrieved directly from the cache the next time the script is executed;

[0012] When a user changes their password, the password input interface will pop up again the next time the script is executed to retrieve the user's password and update the password stored in the cache.

[0013] Optionally, when the script is executed with administrator privileges, select the password retention period on the password input screen;

[0014] The password retention period options on the password input interface include: do not save password, one day, three days, one week, one month, and permanent.

[0015] Optionally, the password input interface has built-in input boxes in ElementUI and Ant Design styles.

[0016] Secondly, the technical solution adopted by the implementation component for executing scripts in an Electron desktop application of the present invention to solve the above-mentioned technical problems is as follows:

[0017] An implementation component for executing scripts in an Electron desktop application, comprising:

[0018] A common JavaScript component for script execution, used to provide a unified interface for script execution;

[0019] The script risk verification library is configured with conditions for low-risk scripts and conditions for high-risk scripts to meet, and is used to identify the risk level set by the configuration based on the input execution script;

[0020] The script execution permission library is configured with the types of execution scripts that need to run with administrator privileges and the types of execution scripts that need to run with ordinary user privileges. It is used to identify the execution permissions that match the configuration based on the input execution script.

[0021] The privilege escalation management component is used to retrieve the password from the password input interface in the dialog box and then call the exec module. Based on the error, stdout, and stderr feedback information from the exec module, it determines whether the password is correct and the number of incorrect attempts allowed. If the execution is successful, it returns a success status; if an error occurs, it returns an error status and information, which are then handled by the developers.

[0022] Optionally, if the passed-in execution script meets the conditions for a low-risk script, the determination of the permissions required for script execution continues; if the passed-in execution script meets the conditions for a high-risk script, the execution ends directly.

[0023] Scripts run with administrator privileges require a correct password to execute, while scripts run with regular user privileges can be executed without a password.

[0024] Optionally, the script execution requires administrator privileges, as identified by the necessary permission libraries.

[0025] After the user successfully enters the password and the script is executed successfully, the password is stored in the cache through the privilege escalation management component. The next time the script is executed, the password can be retrieved directly from the cache.

[0026] When a user changes their password, a password input interface pops up the next time the script is executed. The privilege escalation management component retrieves the user's password again and updates the password stored in the cache.

[0027] Optionally, when the script is executed with administrator privileges, select the password retention period on the password input screen;

[0028] The password retention period options on the password input interface include: do not save password, one day, three days, one week, one month, and permanent.

[0029] Optionally, the password input interface has built-in input boxes in ElementUI and Ant Design styles.

[0030] The present invention provides a method and components for implementing script execution in an Electron desktop application, which have the following advantages compared with the prior art:

[0031] This invention provides privilege escalation for Electron-based desktop applications, enabling flexible password management and personalized modification of password input fields. It also eliminates the need for administrator privileges to run the software, thus improving security. Attached Figure Description

[0032] Appendix Figure 1 This describes the specific execution flow of the Electron desktop application execution script in this invention. Detailed Implementation

[0033] To make the technical solution, the technical problem solved, and the technical effect of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with specific embodiments.

[0034] Example 1:

[0035] This embodiment proposes a method for implementing script execution in an Electron desktop application, including the following steps:

[0036] In the script risk verification library, set the conditions for low-risk scripts to meet the conditions for high-risk scripts to meet the conditions. In the script execution permission library, set the types of execution scripts that need to run with administrator privileges and the types of execution scripts that need to run with ordinary user privileges.

[0037] Download the pre-packaged Electron desktop application, and pass the execution script of the Electron desktop application to the script risk verification library and the script execution permission library to determine whether the execution script meets the risk level and execution permission set in the configuration.

[0038] When the execution of the script meets the set risk level and is executed with normal user privileges, a success status will be returned if the execution is successful, and an error status and information will be returned if the execution fails, which will be handled by the developers themselves.

[0039] When the script execution meets the set risk level and is executed with administrator privileges, it retrieves the password from the password input interface in the dialog box and calls the exec module. Based on the error, stdout, and stderr feedback information from the exec module, it determines whether the password is correct and the number of incorrect attempts allowed. If the execution is successful, it returns a success status; otherwise, it returns an error status and information for developers to handle.

[0040] In this embodiment, the script risk verification library is set with conditions for low-risk scripts to meet the conditions for high-risk scripts to meet the conditions. When the input script meets the conditions for low-risk scripts to meet the conditions, the permission required for script execution is determined. When the input script meets the conditions for high-risk scripts to meet the conditions, the execution is terminated directly.

[0041] The script execution permission library has settings for script types that require administrator privileges to run and script types that require regular user privileges to run. Scripts that require administrator privileges to run require a correct password to run, while scripts that require regular user privileges can run without a password.

[0042] When the script is executed with administrator privileges, after the user successfully enters the password through the password input interface and the script is executed successfully, the password is stored in the cache. The next time the script is executed, the password can be retrieved directly from the cache.

[0043] When a user changes their password, the password input interface will pop up again the next time the script is executed to retrieve the user's password and update the password stored in the cache.

[0044] In this embodiment, when the script is executed with administrator privileges, the password retention period is selected on the password input interface;

[0045] The password retention period options on the password input interface include: do not save password, one day, three days, one week, one month, and permanent.

[0046] In this embodiment, the password input interface has built-in input boxes in the styles of ElementUI and Ant Design.

[0047] Example 2:

[0048] This embodiment proposes an implementation component for executing scripts in an Electron desktop application. This component executes scripts for a packaged Electron desktop application, including:

[0049] A common JavaScript component for script execution, used to provide a unified interface for script execution;

[0050] The script risk verification library is configured with conditions for low-risk scripts and conditions for high-risk scripts to meet, and is used to identify the risk level set by the configuration based on the input execution script;

[0051] The script execution permission library is configured with the types of execution scripts that need to run with administrator privileges and the types of execution scripts that need to run with ordinary user privileges. It is used to identify the execution permissions that match the configuration based on the input execution script.

[0052] The privilege escalation management component is used to retrieve the password from the password input interface in the dialog box and then call the exec module. Based on the error, stdout, and stderr feedback information from the exec module, it determines whether the password is correct and the number of incorrect attempts allowed. If the execution is successful, it returns a success status; if an error occurs, it returns an error status and information, which are then handled by the developers.

[0053] In this embodiment, if the passed-in execution script meets the conditions for a low-risk script, the determination of the permissions required for script execution continues; if the passed-in execution script meets the conditions for a high-risk script, the execution ends directly.

[0054] Scripts run with administrator privileges require a correct password to execute, while scripts run with regular user privileges can be executed without a password.

[0055] In this embodiment, the system identifies that the script needs to be executed with administrator privileges by using the permission library required for script execution.

[0056] After the user successfully enters the password and the script is executed successfully, the password is stored in the cache through the privilege escalation management component. The next time the script is executed, the password can be retrieved directly from the cache.

[0057] When a user changes their password, a password input interface pops up the next time the script is executed. The privilege escalation management component retrieves the user's password again and updates the password stored in the cache.

[0058] In this embodiment, when the script is executed with administrator privileges, the password retention period is selected on the password input interface;

[0059] The password retention period options on the password input interface include: do not save password, one day, three days, one week, one month, and permanent.

[0060] In this embodiment, the password input interface has built-in input boxes in the styles of ElementUI and Ant Design.

[0061] Combined with appendix Figure 1Based on the specific implementation process of this embodiment, taking the Linux system application store client software as an example, hereinafter referred to as the application store: ① During the development process, a common JS component for script execution is introduced. Since the application store runs on the Debian system, the application store needs to obtain the software installation package in deb format from the server. The application store needs to execute the command "dpkg -i package_name.deb", and pass this execution script to the script risk verification library and the script execution permission library to determine whether it meets the configured risk level (i.e., low risk) and needs to run this command with administrator privileges; ② When the script is executed, the application store pops up a password input interface. The user enters the password and clicks confirm. This password is passed to the exec module. Based on the error, stdout, and stderr feedback information from the exec module, it is determined whether the password is correct. If it is incorrect, the password input box will continue to pop up or a prompt will be given that the password is incorrect, reminding the user to enter the password again. If the password is correct, the script continues to execute. If the execution is successful, the developer is returned a success status and the information returned after successful execution. If the execution fails, the developer is returned a failure status and the information returned after failed execution; ③ After successful execution, the password retention period is selected on the password input interface and stored in the application store cache for use in the next script execution. Of course, if the script is passed to the script risk verification library and the script execution permission library and is determined to meet the configured risk level (i.e., low risk) and needs to be run with ordinary user privileges, the successful execution of the script will return a success status and the information returned after successful execution to the developer. If the script fails to execute, the failure status and the information returned after failure will be returned to the developer.

[0062] In summary, the implementation method and components for executing scripts in an Electron desktop application according to the present invention allow for flexible password management, personalized modification of password input boxes, and improved security by eliminating the need for administrator privileges to run the software.

[0063] The above specific examples illustrate the principles and implementation methods of the present invention in detail. These embodiments are merely for the purpose of helping to understand the core technical content of the present invention. Based on the above specific embodiments of the present invention, any improvements and modifications made to the present invention by those skilled in the art without departing from the principles of the present invention should fall within the patent protection scope of the present invention.

Claims

1. An implementation method of an electron desktop application execution script, characterized in that It includes the following steps: Download the pre-packaged Electron desktop application and pass its execution script to the script risk verification library and the script execution permission library to determine whether the execution script meets the configured risk level and required permissions. The script risk verification library has conditions for low-risk and high-risk scripts. If the passed-in execution script meets the low-risk script condition, the script execution permission determination continues; if it meets the high-risk script condition, execution ends directly. The script execution permission library has types of execution scripts that require administrator privileges and types that require ordinary user privileges. Execution scripts running with administrator privileges require a correct password to execute, while execution scripts running with ordinary user privileges do not require a password. When executing a script with administrator privileges, after the user successfully enters their password at the password input interface and the script executes successfully, the password is stored in the cache. The next time the script is executed, the password is retrieved directly from the cache. If the user changes their password, the password input interface pops up again during the next script execution to retrieve the user's password and update the password stored in the cache. When the execution of the script meets the set risk level and is executed with normal user privileges, a success status will be returned if the execution is successful, and an error status and information will be returned if the execution fails, which will be handled by the developers themselves. When the script execution meets the set risk level and is executed with administrator privileges, it retrieves the password from the password input interface in the dialog box and calls the exec module. Based on the error, stdout, and stderr feedback information from the exec module, it determines whether the password is correct and the number of incorrect attempts allowed. If the execution is successful, it returns a success status; otherwise, it returns an error status and information for developers to handle.

2. The method for implementing an Electron desktop application execution script according to claim 1, characterized in that, When the script is executed with administrator privileges, select the password retention period at the password input screen; The password retention period options on the password input interface include: do not save password, one day, three days, one week, one month, and permanent.

3. The method for implementing an Electron desktop application execution script according to claim 2, characterized in that, The password input interface has built-in input boxes in ElementUI and Ant Design styles.

4. A component for implementing script execution in an Electron desktop application, characterized in that... This component executes scripts for pre-packaged Electron desktop applications, including: A common JavaScript component for script execution, used to provide a unified interface for script execution; The script risk verification library is configured with conditions for low-risk scripts and conditions for high-risk scripts to meet, and is used to identify the risk level set by the configuration based on the input execution script; The script execution permission library is configured with the types of execution scripts that need to run with administrator privileges and the types of execution scripts that need to run with ordinary user privileges. It is used to identify the execution permissions that match the configuration based on the input execution script. The privilege escalation management component is used to retrieve the password from the password input interface in the dialog box and then call the exec module. Based on the error, stdout, and stderr feedback information from the exec module, it determines whether the password is correct and the number of incorrect attempts allowed. If the execution is successful, it returns a success status; if the execution fails, it returns an error status and information, which are handled by the developers themselves. If the passed-in execution script meets the conditions for a low-risk script, the system will continue to determine the permissions required for script execution. If the passed-in execution script meets the conditions for a high-risk script, the execution will terminate directly. Execution scripts running with administrator privileges require the correct password to execute, while execution scripts running with ordinary user privileges do not require a password to execute. By identifying the necessary permissions library for script execution, it is determined that the script requires administrator privileges to run. After the user successfully enters the password and the script is successfully executed, the privilege escalation management component stores the password in the cache. The next time the script is executed, the password can be directly retrieved from the cache. If the user changes the password, a password input interface will pop up the next time the script is executed. The privilege escalation management component will then retrieve the user's password again and update the password stored in the cache.

5. The implementation component for executing scripts in an Electron desktop application according to claim 4, characterized in that, When the script is executed with administrator privileges, select the password retention period at the password input screen; The password retention period options on the password input interface include: do not save password, one day, three days, one week, one month, and permanent.

6. The implementation component for executing scripts in an Electron desktop application according to claim 5, characterized in that, The password input interface has built-in input boxes in ElementUI and Ant Design styles.

Citation Information

Patent Citations

  • Permission application examination and approval method and authorization management platform

    CN107679749A

  • Cross-platform desktop application program development framework and method based on electron

    CN110275700A