- Home
- Plugins
- Security & Permissions
- dsh-aigc-label
dsh-aigc-label
lee2277-t/dsh-aigc-label
Write and check the AIGC implicit label that Chinese rules require on AI-generated content - the named AIGC property inside an Office file's docProps/custom.xml, carrying Label, ContentProducer and ProduceID. `aigc_label_write` stamps docx, xlsx and pptx and reads the property back to confirm it landed; `aigc_label_check` reports what a file currently carries. The producer code is never built in, because stamping a file with someone else's code misattributes where it came from - without one the write tool refuses rather than writing a half label.
Install
dsh plugin --profile web add github:lee2277-t/dsh-aigc-labelREADME
dsh-aigc-label
给 Office 产物写入 / 查验 AIGC 隐式标识。
为什么
国内对人工智能生成合成内容有标识要求(GB 45438-2025 /《人工智能生成合成内容标识办法》)。
隐式标识藏在 OOXML 包的 docProps/custom.xml 里——一条名为 AIGC 的自定义属性,值是紧凑 JSON。
Office 打开文件时看不见它,但检测侧读得到。这意味着一件事:你交付了一批文档, 它们到底带没带标识、字段全不全,光看界面是不知道的。
两个工具
aigc_label_check
aigc_label_check D:\deliverables
4 个 OOXML 文件 · 带完整标识 4 · 不完整 0 · 无标识 0
## 明细
✓ deck.pptx — 123456789012345678901234567 · d02db771bd18a32202ae14e0cd5f6103
✓ memo.docx — 123456789012345678901234567 · d02db771bd18a32202ae14e0cd5f6103
三种结果分开报:带完整标识、有标识但缺字段、无标识。不是可读 OOXML 的文件单独标出来。
aigc_label_write
aigc_label_write({ path, producer: "<你的 27 位编码>" })
写完自动读回校验,不一致就报失败——不写「应该成功了」。
两个刻意的取舍
1. 服务提供者编码不内置
ContentProducer 是接入方在备案链路里拿到的 27 位编码。插件里不预置任何人的编码,因为
写错编码等于把这份文件的来源指向了别的主体,比不写标识更糟。
没配置就拒绝写入,不猜、不生成一个看起来像的。
2. ReservedCode1/2 留空且不写进 JSON
规范把它定义为「用于保护内容、标识完整性的信息」,官方算法要接入单发放的私钥 + 密钥版本。私钥不能随插件分发到用户机器,所以本地链路算不出可验签的预留码。
填一个本地随机密钥加密、用完即弃的值,在构造上就不可能被任何人校验,只是让字段看起来非空。 留空更诚实,也不给检测侧制造「像是有效预留码」的假象。
代价写在报告里:如果检测侧按「四项齐全」判,本地产物会被判为标识不完整。
实现
- 手写 OOXML 包的读写:读中央目录取 part,改写后重新打包。不依赖任何 zip 库。
- 只改三个 part:
docProps/custom.xml、[Content_Types].xml、_rels/.rels。其余原样复制, 重算回填的缓存值、样式、图表都不受影响。 - 写入用临时文件 + 原子替换,中途失败不会留下半个损坏的交付物。
- 已有的其他自定义属性不动,
pid自动取下一个可用值。
验证
三个用 openpyxl / python-docx / python-pptx 生成的真实文件,打标后用同一批库重新打开:
✓ report.xlsx: 解析成功 · 10 part · Label=1 · Producer=12345678…
✓ memo.docx: 解析成功 · 18 part · Label=1 · Producer=12345678…
✓ deck.pptx: 解析成功 · 39 part · Label=1 · Producer=12345678…
同时校验:CRC 全部正确、[Content_Types].xml 已声明、_rels/.rels 已引用、
标识能被独立的 XML 解析器读出来。重复写入不会叠加属性。
安装
dsh plugin add github:Lee2277-t/dsh-aigc-label
配置
contentProducer: "" # 27 位编码,不填则拒绝写入
label: "1" # 1=属于生成合成,2=可能为,3=疑似为
extensions: [.docx, .xlsx, .pptx]
这个工具不做什么
- 不做显式标识。按规范,面向用户的界面或内容本身还要有可见提示,隐式标识不替代它。
- 不判断你的编码用得对不对(云端包与本地包各一个,不通用)。
- 不保证真实检测侧认可这份标识——本地算不出可验签的预留码,这一条明写在报告里。
许可
AGPL-3.0-only。
Related plugins
dsh-purge
hunyisage/dsh-purge
dsh-infinite-gen-4
minglink/dsh-infinite-gen-4
dsh-purge
mmparko/dsh-purge
cc-safety-net
kenryu42/cc-safety-net