diff --git a/apps/terminal/applets/chrome/ChangeLog b/apps/terminal/applets/chrome/ChangeLog new file mode 100644 index 000000000..7a03e6949 --- /dev/null +++ b/apps/terminal/applets/chrome/ChangeLog @@ -0,0 +1,3 @@ +# 2023-07-06 Version 0.5 +## 功能更新 + - 增加匿名用户的支持,如果账号是匿名用户,username 和 secret 则为空 diff --git a/apps/terminal/applets/chrome/README.md b/apps/terminal/applets/chrome/README.md index 068682bfb..991b0c3bb 100644 --- a/apps/terminal/applets/chrome/README.md +++ b/apps/terminal/applets/chrome/README.md @@ -5,3 +5,6 @@ - Chrome 和 ChromeDriver 版本要匹配 - Driver [下载地址](https://chromedriver.chromium.org/downloads) +## ChangeLog + +一些重要的更新记录参考 [ChangeLog](./ChangeLog.md) diff --git a/apps/terminal/applets/chrome/app.py b/apps/terminal/applets/chrome/app.py index 9cc452590..47cce8844 100644 --- a/apps/terminal/applets/chrome/app.py +++ b/apps/terminal/applets/chrome/app.py @@ -135,6 +135,14 @@ class WebAPP(object): self.account = account self.platform = platform self._steps = list() + # 确保 account_username 和 account_secret 不为 None + self._account_username = account.username if account.username else '' + self._account_secret = account.secret if account.secret else '' + + # 如果是匿名账号,account_username 和 account_secret 为空 + if account.username == "@ANON": + self._account_username = '' + self._account_secret = '' extra_data = self.asset.spec_info autofill_type = extra_data.autofill @@ -153,23 +161,22 @@ class WebAPP(object): for item in steps: val = item.value if val: - val = val.replace("{USERNAME}", self.account.username) - val = val.replace("{SECRET}", self.account.secret) + val = val.replace("{USERNAME}", self._account_username) + val = val.replace("{SECRET}", self._account_secret) item.value = val self._steps.append(item) def _default_custom_steps(self, spec_info) -> list: - account = self.account - default_steps = [ + return [ Step({ "step": 1, - "value": account.username, + "value": self._account_username, "target": spec_info.username_selector, "command": "type" }), Step({ "step": 2, - "value": account.secret, + "value": self._account_secret, "target": spec_info.password_selector, "command": "type" }), @@ -180,7 +187,6 @@ class WebAPP(object): "command": "click" }) ] - return default_steps def execute(self, driver: webdriver.Chrome) -> bool: if not self.asset.address: diff --git a/apps/terminal/applets/chrome/manifest.yml b/apps/terminal/applets/chrome/manifest.yml index 4c66515b6..0fd511f58 100644 --- a/apps/terminal/applets/chrome/manifest.yml +++ b/apps/terminal/applets/chrome/manifest.yml @@ -1,6 +1,6 @@ name: chrome display_name: "{{ 'Chrome Browser' | trans }}" -version: 0.4 +version: 0.5 comment: "{{ 'Chrome Browser Open URL Page Address' | trans }}" author: JumpServer Team exec_type: python