In DeepSeek Harness (DSH), agents frequently access the file system to execute tasks. If files contain sensitive words or违规内容, the provider’s content moderation mechanism may directly reject requests (HTTP 400). Once this content enters the conversation history, every subsequent request will carry it, causing the entire session to be blocked. The dsh-file-shield plugin prevents sensitive content from entering conversations at the source by intercepting access to specified files or directories before tool execution.
Features and Principles¶
dsh-file-shield is a plugin maintained by Yazzyk. It blocks agents from reading, editing, searching, and writing to specified files or directories. When an agent attempts to access a blocked path, the tool call is rejected before execution, and the model receives a permission error instead of the file content.
- Interception point: The plugin intervenes at the
tools/pre-executestage, returningdeny, which causes the tool body not to execute. - Error feedback: The model receives an error like
Error: Access to "/path/to/file" is blocked by deployment policy. - Shell command handling: The plugin performs static analysis on shell command text, parsing path arguments for interception. It supports intercepting
workdirandcommandparameters forbashandpwshtools, and filters blocked paths from search results. - Output filtering: For tools like
grepandglob, the plugin removes paths matching rules from results and only returns unblocked content.
Limitations¶
- Shell obfuscation: The plugin defends through static analysis of command text and cannot intercept all obfuscation methods. For example, operations exploiting semantic differences such as variable concatenation (
cat $p),base64 -d, and command substitution ($(...)) may bypass static checks. - Host-side reads: Does not intercept host-side read operations that do not go through the tool layer, such as skill loading and
@filereferences. - Case sensitivity: The default
matchCaseisfalse. For case-insensitive file systems, short relative rules may cause false positives. - Extra tools: File-reading tools not recognized by this plugin need to be supported by configuring
extraPathArgsandextraCommandArgs.
Installation¶
Use the official installation command to add the plugin to the specified profile:
dsh plugin --profile <profile> add github:Yazzyk/dsh-file-shield
Configuration¶
Web GUI Configuration¶
- Navigate to the Plugins page in the Web GUI.
- Click Installed.
- Find
dsh-file-shieldand enter its configuration page. - Select files or directories on the page, or directly enter paths and glob patterns.
- Click Save, and the rules will be written to the profile’s
config.denyfield.
cordis.patch.yml Configuration¶
You can also configure deny rule lists in the profile’s cordis.patch.yml. Glob patterns (such as **/*.pem) or literal paths are supported.
- insert:
- id: file-shield
name: dsh-file-shield
config:
deny:
- '**/.env'
- '**/.env.*'
- '**/*.pem'
- '~/.dsh/.credentials.yaml'
matchCase: false
| Field | Default Value | Description |
|---|---|---|
deny |
[] |
List of rules. An empty list means no content is blocked. |
matchCase |
false |
Whether to match case-sensitively. |
extraPathArgs |
{} |
Specify path parameter names for custom file-reading tools from other plugins. |
extraCommandArgs |
{} |
Specify command parameter names for custom shell tools from other plugins. |
Ecosystem and Links¶
This plugin follows the MIT license. The DSH ecosystem emphasizes “everything is a plugin”, and this plugin is a community contribution.
- GitHub Repository: https://github.com/Yazzyk/dsh-file-shield
- Community Directory: https://www.skillhub.cn/plugins/Yazzyk/dsh-file-shield