Skip to content

fix(sanitize): prevent looksLikePromptInjection from being tree-shaken#191

Open
kbob3687-hub wants to merge 1 commit into
TencentCloud:mainfrom
kbob3687-hub:fix/158-prompt-injection-tree-shaking
Open

fix(sanitize): prevent looksLikePromptInjection from being tree-shaken#191
kbob3687-hub wants to merge 1 commit into
TencentCloud:mainfrom
kbob3687-hub:fix/158-prompt-injection-tree-shaking

Conversation

@kbob3687-hub

Copy link
Copy Markdown

Description | 描述

  1. Uncommented line 153 in src/utils/sanitize.ts to re-enable the looksLikePromptInjection call, restoring prompt injection detection.

  2. Verified that the bundler (tsdown) properly preserves the function inside the build artifact (dist/index.mjs).

  3. Added a build-time integration test src/utils/sanitize-tree-shaking.test.ts to assert that the function is not tree-shaken out of the final package.

  4. 取消了 src/utils/sanitize.ts 第 153 行的注释,恢复对 looksLikePromptInjection 的正常调用,修复了原本存在的 prompt 注入检测失效 bug。

  5. 确认在重新编译打包后,产物 dist/index.mjs 中已经正确保留并包含了该函数。

  6. 新增了构建验证测试 src/utils/sanitize-tree-shaking.test.ts,防止后续因打包工具 Tree-shaking 机制导致此函数再次丢失。

Related Issue | 关联 Issue

Fix #158

Change Type | 修改类型

  • Bug fix | Bug 修复
  • New feature | 新功能
  • Documentation update | 文档更新
  • Code optimization | 代码优化

Signed-off-by: xiaosuantongkk <kbob3687@gmail.com>
@Maxwell-Code07

Copy link
Copy Markdown
Collaborator

Good catch on the tree-shaking issue! The build-time integration test is a nice addition to prevent regression. We'll review it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[good first issue]🎯 security: prompt injection detection tree-shaken out of dist - v0.3.6 has zero injection detection

2 participants