English | 简体中文
A native privacy filter plugin for CLIProxyAPI. It intercepts model requests, detects sensitive text, and redacts it before the request is forwarded to an upstream provider.
AI learners and builders can join the Linux.do community: linux.do.
This project uses packyme/privacy-filter for the core filtering logic and adapts it to the CPA plugin ABI from router-for-me/CLIProxyAPI.
When CLIProxyAPI receives a request, this plugin scans supported text fields before the request leaves the local process. If sensitive content is found, the request body is rewritten with redacted placeholders.
Typical use cases:
rules/gitleaks.tomlmessages and input request bodiesmakeClone and build the plugin:
git clone https://github.com/rheodev/cpa-plugin-privacyfilter.git
cd cpa-plugin-privacyfilter
make build
The default build writes the shared library to the repository root:
privacyfilter.soprivacyfilter.dylibprivacyfilter.dllBuild for a specific platform:
GOOS=linux GOARCH=amd64 make build
GOOS=darwin GOARCH=arm64 make build
GOOS=windows GOARCH=amd64 make build
Use BUILD_DIR to place build output elsewhere:
BUILD_DIR=dist make build
Place the shared library in your CLIProxyAPI plugin directory. The gitleaks rules are embedded in the binary, so no extra files are required:
privacyfilter/
└── privacyfilter.so # or privacyfilter.dylib / privacyfilter.dll
Then enable the privacyfilter plugin in CLIProxyAPI.
Plugin metadata:
privacyfilterRequestInterceptorrheodevThe plugin is configured inside CLIProxyAPI's main config file (config.yaml).
Under plugins.configs.<id>, the host-owned fields (enabled, priority) are
consumed by CLIProxyAPI, and the remaining YAML subtree is passed to the plugin
verbatim.
Enable the plugin:
plugins:
enabled: true
dir: "plugins"
configs:
privacyfilter:
enabled: true
Enable with custom rules:
plugins:
enabled: true
dir: "plugins"
configs:
privacyfilter:
enabled: true
gitleaks_toml: "" # Empty uses embedded rules (or rules/gitleaks.toml sidecar)
skip_models:
- gpt-4
skip_formats:
- openai
Plugin fields:
| Field | Type | Default | Description |
|---|---|---|---|
gitleaks_toml | string | "" | Custom gitleaks rule file path. Relative paths are resolved from the plugin directory. |
skip_models | array | [] | Models that should skip redaction. |
skip_formats | array | [] | Source formats that should skip redaction. |
When gitleaks_toml is empty and no rules/gitleaks.toml sidecar file exists,
the plugin uses the rules embedded in the binary at build time.
The plugin runs for both before-auth and after-auth request interception hooks, then parses the JSON body:
skip_models and skip_formats.messages first, then falls back to input.Supported request shapes include:
{
"model": "gpt-4",
"messages": [
{
"role": "user",
"content": "Email me at user@example.com"
}
]
}
{
"model": "gpt-4",
"input": "My GitHub token is ghp_xxx"
}
Built-in rules are embedded into the shared library at build time from:
rules/gitleaks.toml
At runtime the plugin resolves rules in this order:
gitleaks_toml config value, if setrules/gitleaks.toml sidecar next to the shared libraryUpdate embedded rules and rebuild:
make update-rules
make build
You can also set gitleaks_toml to use your own rule file:
gitleaks_toml: custom/gitleaks.toml
Relative paths are resolved from the plugin directory.
Common commands:
go test ./...
make build
make clean
Main files:
main.go Plugin metadata and build entry
abi.go CLIProxyAPI plugin ABI adapter
interceptor.go Request interception and redaction logic
config.go YAML configuration parsing
rules/gitleaks.toml Built-in detection rules
Dependency note:
privacyfilter => github.com/packyme/privacy-filter
8 commits
Hacker News (1)
Go
91.2%
Shell
5.5%
Makefile
3.3%
English | 简体中文
A native privacy filter plugin for CLIProxyAPI. It intercepts model requests, detects sensitive text, and redacts it before the request is forwarded to an upstream provider.
AI learners and builders can join the Linux.do community: linux.do.
This project uses packyme/privacy-filter for the core filtering logic and adapts it to the CPA plugin ABI from router-for-me/CLIProxyAPI.
When CLIProxyAPI receives a request, this plugin scans supported text fields before the request leaves the local process. If sensitive content is found, the request body is rewritten with redacted placeholders.
Typical use cases:
rules/gitleaks.tomlmessages and input request bodiesmakeClone and build the plugin:
git clone https://github.com/rheodev/cpa-plugin-privacyfilter.git
cd cpa-plugin-privacyfilter
make build
The default build writes the shared library to the repository root:
privacyfilter.soprivacyfilter.dylibprivacyfilter.dllBuild for a specific platform:
GOOS=linux GOARCH=amd64 make build
GOOS=darwin GOARCH=arm64 make build
GOOS=windows GOARCH=amd64 make build
Use BUILD_DIR to place build output elsewhere:
BUILD_DIR=dist make build
Place the shared library in your CLIProxyAPI plugin directory. The gitleaks rules are embedded in the binary, so no extra files are required:
privacyfilter/
└── privacyfilter.so # or privacyfilter.dylib / privacyfilter.dll
Then enable the privacyfilter plugin in CLIProxyAPI.
Plugin metadata:
privacyfilterRequestInterceptorrheodevThe plugin is configured inside CLIProxyAPI's main config file (config.yaml).
Under plugins.configs.<id>, the host-owned fields (enabled, priority) are
consumed by CLIProxyAPI, and the remaining YAML subtree is passed to the plugin
verbatim.
Enable the plugin:
plugins:
enabled: true
dir: "plugins"
configs:
privacyfilter:
enabled: true
Enable with custom rules:
plugins:
enabled: true
dir: "plugins"
configs:
privacyfilter:
enabled: true
gitleaks_toml: "" # Empty uses embedded rules (or rules/gitleaks.toml sidecar)
skip_models:
- gpt-4
skip_formats:
- openai
Plugin fields:
| Field | Type | Default | Description |
|---|---|---|---|
gitleaks_toml | string | "" | Custom gitleaks rule file path. Relative paths are resolved from the plugin directory. |
skip_models | array | [] | Models that should skip redaction. |
skip_formats | array | [] | Source formats that should skip redaction. |
When gitleaks_toml is empty and no rules/gitleaks.toml sidecar file exists,
the plugin uses the rules embedded in the binary at build time.
The plugin runs for both before-auth and after-auth request interception hooks, then parses the JSON body:
skip_models and skip_formats.messages first, then falls back to input.Supported request shapes include:
{
"model": "gpt-4",
"messages": [
{
"role": "user",
"content": "Email me at user@example.com"
}
]
}
{
"model": "gpt-4",
"input": "My GitHub token is ghp_xxx"
}
Built-in rules are embedded into the shared library at build time from:
rules/gitleaks.toml
At runtime the plugin resolves rules in this order:
gitleaks_toml config value, if setrules/gitleaks.toml sidecar next to the shared libraryUpdate embedded rules and rebuild:
make update-rules
make build
You can also set gitleaks_toml to use your own rule file:
gitleaks_toml: custom/gitleaks.toml
Relative paths are resolved from the plugin directory.
Common commands:
go test ./...
make build
make clean
Main files:
main.go Plugin metadata and build entry
abi.go CLIProxyAPI plugin ABI adapter
interceptor.go Request interception and redaction logic
config.go YAML configuration parsing
rules/gitleaks.toml Built-in detection rules
Dependency note:
privacyfilter => github.com/packyme/privacy-filter
Hacker News (1)
8 commits
Go
91.2%
Shell
5.5%
Makefile
3.3%