Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

代码中的一个安全问题 #52

Closed
LittleSong2024 opened this issue Oct 26, 2024 · 1 comment
Closed

代码中的一个安全问题 #52

LittleSong2024 opened this issue Oct 26, 2024 · 1 comment
Labels
bug Something isn't working enhancement New feature or request

Comments

@LittleSong2024
Copy link
Contributor

在“app/view/main_window.py”源文件中的__init__函数(50行)的读取配置文件部分使用了eval函数,这并不安全,建议使用json.loads或者ast.literal_eval等安全的加载方式作为替代

    def __init__(self):
        super().__init__()
        self.initWindow()

        # create sub interface
        self.taskInterface = TaskInterface(self)
        self.settingInterface = SettingInterface(self)
        # self.debugInterface = DebugInterface(self)

        # add items to navigation interface
        self.initNavigation()

        # 设置背景特效
        self.applyBackgroundEffectByCfg()

        # 创建检测主题色更改线程
        self.themeChangedListener = ThemeChangedListener(self)
        self.themeChangedListener.themeChanged.connect(self.toggleTheme)
        self.themeChangedListener.start()

        # 创建未完成的任务
        historyFile = Path("{}/Ghost Downloader 记录文件".format(cfg.appPath))
        # 未完成任务记录文件格式示例: [{"url": "xxx", "fileName": "xxx", "filePath": "xxx", "blockNum": x, "status": "xxx"}]
        if historyFile.exists():
            with open(historyFile, 'r', encoding='utf-8') as f:
                unfinishedTaskInfo = f.readlines()
                logger.debug(f"Unfinished Task is following:{unfinishedTaskInfo}")
                for i in unfinishedTaskInfo:
                    if i:  # 避免空行
                        # i = eval(i)  # <===========
                        # i = ast.literal_eval(i) <==========
                        # i = json.loads(i)  <===========
                        signalBus.addTaskSignal.emit(i['url'], i['filePath'], i['blockNum'], i['fileName'], i["status"], True)
        else:
            historyFile.touch()

        # 启动浏览器扩展服务器
        self.browserExtensionServer = None

        if cfg.enableBrowserExtension.value == True:
            self.runBrowserExtensionServer()

        # 创建托盘
        self.tray = CustomSystemTrayIcon(self)
        self.tray.show()

        # 检查更新
        if cfg.checkUpdateAtStartUp.value == True:
            checkUpdate(self)

        self.splashScreen.finish()
@XiaoYouChR
Copy link
Owner

感谢 Issue!亟待修复

@XiaoYouChR XiaoYouChR added bug Something isn't working enhancement New feature or request labels Oct 27, 2024
XiaoYouChR added a commit that referenced this issue Nov 3, 2024
XiaoYouChR added a commit that referenced this issue Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants