Skip to content

Feature/sdsk 1692#32359

Closed
Vladislav-Orobinskiy wants to merge 6 commits into
langgenius:mainfrom
kinoplan:feature/SDSK-1692
Closed

Feature/sdsk 1692#32359
Vladislav-Orobinskiy wants to merge 6 commits into
langgenius:mainfrom
kinoplan:feature/SDSK-1692

Conversation

@Vladislav-Orobinskiy

Copy link
Copy Markdown

Integration of custom RuBERT model for text classification

@dosubot dosubot Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Feb 16, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @Vladislav-Orobinskiy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates a new AI text classification feature, specifically a custom RuBERT model, into the system. It introduces a dedicated built-in tool provider and a classify_text tool that leverages an internal NeuroSD API to categorize text. The changes also include necessary Docker configuration updates to ensure the new tool and its API are properly mounted and accessible within the environment.

Highlights

  • New AI Classification Tool: A new built-in tool provider for AI text classification has been introduced, integrating with a NeuroSD API to categorize text.
  • Text Classification Functionality: A classify_text tool was added, enabling the system to use a neural network to classify text into service and type categories.
  • Docker Configuration Updates: The docker-compose.yaml was modified to mount the new AI classification tool, and squid.conf.template was updated to allow internal network access to the classification API.
  • GitHub Actions Workflow Exclusion: The .gitignore file was updated to prevent GitHub Actions workflow files from being tracked in the repository.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .gitignore
    • Added patterns to ignore GitHub Actions workflow files.
  • api/core/tools/builtin_tool/_position.yaml
    • Included ai_classification in the list of built-in tool positions.
  • api/core/tools/builtin_tool/providers/ai_classification/_assets/icon.svg
    • Added an SVG icon for the AI classification tool.
  • api/core/tools/builtin_tool/providers/ai_classification/ai_classification.py
    • Implemented the AIClassificationToolProvider class, which connects to a local NeuroSD classification API.
  • api/core/tools/builtin_tool/providers/ai_classification/ai_classification.yaml
    • Defined the metadata, labels, and description for the AI classification tool provider in multiple languages.
  • api/core/tools/builtin_tool/providers/ai_classification/tools/classify_text.py
    • Created the ClassifyTextTool for invoking the NeuroSD classification API to classify text.
  • api/core/tools/builtin_tool/providers/ai_classification/tools/classify_text.yaml
    • Configured the classify_text tool's identity, description, and parameters, including text and an optional api_url.
  • docker/docker-compose.yaml
    • Added volume mounts for the ai_classification tool provider directory and its _position.yaml file to the api service.
  • docker/ssrf_proxy/squid.conf.template
    • Defined an Access Control List (ACL) for the 172.17.0.1 IP address (classification API) and allowed HTTP access to it.
Ignored Files
  • Ignored by pattern: .github/workflows/** (21)
    • .github/workflows/api-tests.yml
    • .github/workflows/autofix.yml
    • .github/workflows/build-push.yml
    • .github/workflows/build.yml
    • .github/workflows/db-migration-test.yml
    • .github/workflows/deploy-agent-dev.yml
    • .github/workflows/deploy-dev.yml
    • .github/workflows/deploy-enterprise.yml
    • .github/workflows/deploy-hitl.yml
    • .github/workflows/docker-build.yml
    • .github/workflows/expose_service_ports.sh
    • .github/workflows/labeler.yml
    • .github/workflows/main-ci.yml
    • .github/workflows/semantic-pull-request.yml
    • .github/workflows/stale.yml
    • .github/workflows/style.yml
    • .github/workflows/tool-test-sdks.yaml
    • .github/workflows/translate-i18n-claude.yml
    • .github/workflows/trigger-i18n-sync.yml
    • .github/workflows/vdb-tests.yml
    • .github/workflows/web-tests.yml
Activity
  • No human activity recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dosubot dosubot Bot added the 💪 enhancement New feature or request label Feb 16, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new built-in tool for text classification using a custom RuBERT model, integrating with a local NeuroSD API. However, it introduces a significant Server-Side Request Forgery (SSRF) vulnerability. This is due to a user-configurable API URL in the tool's parameters and a global weakening of the SSRF proxy (Squid) configuration, which allows access to the host machine's IP address (172.17.0.1). This change affects all tools using the proxy, potentially exposing internal host services. Beyond this critical security concern, the implementation also presents opportunities to improve flexibility, robustness, and maintainability, specifically regarding hardcoded IP addresses, error handling, and internationalization for user-facing text.

Comment thread docker/ssrf_proxy/squid.conf.template Outdated
Comment on lines +23 to +25
acl classification_api dst 172.17.0.1
http_access allow allowed_domains
http_access allow classification_api

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

Allowing access to 172.17.0.1 (the default Docker bridge gateway/host IP) in the global SSRF proxy configuration significantly weakens the security posture of the entire Dify installation, enabling any tool using the proxy to reach host services and bypass SSRF protections. This hardcoded IP also reduces configuration flexibility. If access to the classification API is necessary via this IP, the ACL should be restricted to a specific port (e.g., 172.17.0.1:8000) instead of all safe ports. For improved flexibility, consider using an environment variable like ${CLASSIFICATION_API_HOST}.

Comment on lines +28 to +40
- name: api_url
type: string
required: false
default: http://172.17.0.1:8000
label:
en_US: API URL
zh_Hans: API地址
ru_RU: URL API
human_description:
en_US: The URL of the classification API (default uses Docker bridge gateway IP)
zh_Hans: 分类API的URL(默认使用Docker网桥网关IP)
ru_RU: URL API классификации (по умолчанию Docker bridge gateway IP)
form: form

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

The api_url parameter is user-configurable (form: form) and is used to construct the target URL for a network request. This allows an application developer to specify arbitrary URLs. When combined with the changes in the Squid proxy configuration (which now allows access to 172.17.0.1), this enables Server-Side Request Forgery (SSRF) against the host machine. An attacker could use this to probe internal services running on the host.

Comment on lines +47 to +56
api_url = tool_parameters.get("api_url", DEFAULT_API_URL).rstrip("/")
predict_url = f"{api_url}/predict"

try:
response = ssrf_proxy.post(
predict_url,
json={"text": text},
headers={"Content-Type": "application/json"},
timeout=CLASSIFICATION_TIMEOUT,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

The api_url parameter, which can be controlled by the user, is used here to construct predict_url without any validation. This URL is then passed to ssrf_proxy.post. Since the proxy configuration has been modified to allow the host IP 172.17.0.1, this tool can be used to perform SSRF attacks against the host machine.

from core.tools.entities.tool_entities import ToolInvokeMessage
from core.tools.errors import ToolInvokeError

DEFAULT_API_URL = "http://172.17.0.1:8000"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Hardcoding the DEFAULT_API_URL makes the application less flexible and harder to configure in different environments. It's recommended to source this value from the application's configuration, for example, using an environment variable. This would improve maintainability. You could add a new variable to your dify_config and use it here.

try:
error_detail = response.json().get("detail", response.text)
error_msg = f"{error_msg}: {error_detail}"
except Exception:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Catching a generic Exception is too broad and can mask other issues. It's better to catch a more specific exception. Since response.json() can raise a JSONDecodeError if the response is not valid JSON, you should catch that specifically. The import json statement is already present in the file.

Suggested change
except Exception:
except json.JSONDecodeError:

Comment on lines +80 to +84
formatted_text = (
f"Результат классификации:\n"
f"• Сервис: {service}\n"
f"• Тип: {type_name}"
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The formatted_text contains hardcoded Russian text. This is not ideal for internationalization. The project seems to support multiple languages (e.g., en_US, zh_Hans, ru_RU in YAML files). This text should be handled via an i18n mechanism to support all configured languages.

@crazywoola

Copy link
Copy Markdown
Member

For 3rd party models please submit a plugin to this repo instead https://github.com/langgenius/dify-plugins/pulls

@crazywoola crazywoola closed this Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💪 enhancement New feature or request size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants