Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
0ac250a0
Unverified
Commit
0ac250a0
authored
Mar 07, 2024
by
Bowen Liang
Committed by
GitHub
Mar 07, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: check webhook key of Wecom tool in valid UUID form and fix typo (#2719)
parent
405a00bb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
5 deletions
+16
-5
wecom_group_bot.py
...ore/tools/provider/builtin/wecom/tools/wecom_group_bot.py
+5
-3
wecom.py
api/core/tools/provider/builtin/wecom/wecom.py
+2
-2
uuid_utils.py
api/core/tools/utils/uuid_utils.py
+9
-0
No files found.
api/core/tools/provider/builtin/wecom/tools/wecom_group_bot.py
View file @
0ac250a0
...
...
@@ -4,9 +4,10 @@ import httpx
from
core.tools.entities.tool_entities
import
ToolInvokeMessage
from
core.tools.tool.builtin_tool
import
BuiltinTool
from
core.tools.utils.uuid_utils
import
is_valid_uuid
class
Wecom
Repositories
Tool
(
BuiltinTool
):
class
Wecom
GroupBot
Tool
(
BuiltinTool
):
def
_invoke
(
self
,
user_id
:
str
,
tool_parameters
:
dict
[
str
,
Any
]
)
->
Union
[
ToolInvokeMessage
,
list
[
ToolInvokeMessage
]]:
"""
...
...
@@ -17,8 +18,9 @@ class WecomRepositoriesTool(BuiltinTool):
return
self
.
create_text_message
(
'Invalid parameter content'
)
hook_key
=
tool_parameters
.
get
(
'hook_key'
,
''
)
if
not
hook_key
:
return
self
.
create_text_message
(
'Invalid parameter hook_key'
)
if
not
is_valid_uuid
(
hook_key
):
return
self
.
create_text_message
(
f
'Invalid parameter hook_key ${hook_key}, not a valid UUID'
)
msgtype
=
'text'
api_url
=
'https://qyapi.weixin.qq.com/cgi-bin/webhook/send'
...
...
api/core/tools/provider/builtin/wecom/wecom.py
View file @
0ac250a0
from
core.tools.provider.builtin.wecom.tools.wecom_group_bot
import
Wecom
Repositories
Tool
from
core.tools.provider.builtin.wecom.tools.wecom_group_bot
import
Wecom
GroupBot
Tool
from
core.tools.provider.builtin_tool_provider
import
BuiltinToolProviderController
class
WecomProvider
(
BuiltinToolProviderController
):
def
_validate_credentials
(
self
,
credentials
:
dict
)
->
None
:
Wecom
Repositories
Tool
()
Wecom
GroupBot
Tool
()
pass
api/core/tools/utils/uuid_utils.py
0 → 100644
View file @
0ac250a0
import
uuid
def
is_valid_uuid
(
uuid_str
:
str
)
->
bool
:
try
:
uuid
.
UUID
(
uuid_str
)
return
True
except
Exception
:
return
False
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment