[PR #8045] feat: add database tool #25910

Closed
opened 2026-02-21 20:29:37 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/8045

State: closed
Merged: No


Checklist:

Important

Please review the checklist below before submitting your pull request.

  • Please open an issue before creating a PR or link to an existing issue
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Description

Previous related PR and discussions:
https://github.com/langgenius/dify/pull/5439
https://github.com/langgenius/dify/pull/5468
https://github.com/langgenius/dify/pull/5513

It seems the core problem is how to makesure the safety of this db tool. I think we can resolve this by these ways:

  1. Don't let user config db connection in the frontend. the db server always only can be accessed by the api server in a product environment. If we allow users to configure on the front end, it might be possible for brute force attacks or data interception through default db credentials.
  2. Use a readonly database account for this tool.
  3. Use the forbidden keyword list to check user's sql string. And for the user who want to store some structured data temporary, they can use sqlite and allow insert data.
  4. Log the SQL query and update the forbidden keywords regularly

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update, included: Dify Document
  • Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
  • Dependency upgrade

Testing Instructions

test locally

20240906144550

  • Test A
  • Test B
**Original Pull Request:** https://github.com/langgenius/dify/pull/8045 **State:** closed **Merged:** No --- # Checklist: > [!IMPORTANT] > Please review the checklist below before submitting your pull request. - [ ] Please open an issue before creating a PR or link to an existing issue - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods # Description Previous related PR and discussions: https://github.com/langgenius/dify/pull/5439 https://github.com/langgenius/dify/pull/5468 https://github.com/langgenius/dify/pull/5513 It seems the core problem is how to makesure the safety of this db tool. I think we can resolve this by these ways: 1. Don't let user config db connection in the frontend. the db server always only can be accessed by the api server in a product environment. If we allow users to configure on the front end, it might be possible for brute force attacks or data interception through default db credentials. 2. Use a readonly database account for this tool. 3. Use the forbidden keyword list to check user's sql string. And for the user who want to store some structured data temporary, they can use sqlite and allow insert data. 4. Log the SQL query and update the forbidden keywords regularly ## Type of Change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [ ] Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement - [ ] Dependency upgrade # Testing Instructions test locally ![20240906144550](https://github.com/user-attachments/assets/2ab9eddb-08f9-4d35-9a0a-230b14ae247b) - [ ] Test A - [ ] Test B
yindo added the pull-request label 2026-02-21 20:29:37 -05:00
yindo closed this issue 2026-02-21 20:29:40 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#25910