Sanitization requires color, which parses every record
还没有人认领这个 Issue。
- #420 来自 @kskalski —— 已关闭,未合并
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 52/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- rust
调研方向
从 src/writer/mod.rs:134 开始,跟踪禁用颜色时 AutoStream 的路径,经过 sanitization 和 anstyle-parse 处理。复现所述 benchmark,然后验证 C0 和 DEL 字节会被中和,同时 newline 和 tab 保持不变,颜色路径不受影响,并且合法的非 ASCII 输入会按照所选行为进行处理。
由索引模型根据 Issue 内容生成。
描述
Problem
With styling disabled, AutoStream still walks every record through anstyle-parse's VT state machine, roughly doubling per-record cost even for builds emitting no styling.
Target::Stderr → /dev/null, 161-byte records, 500k iterations, release + LTO, 8 interleaved rounds:
| ns/record | |
|---|---|
with color |
596 |
without color |
302 |
Turning off just auto-color doesn't avoid it — WriteStyle::Auto then collapses to Never (src/writer/mod.rs:134), making the parse unconditional. Only dropping color entirely removes the parser.
However dropping color also removes sanitization, as the two share a code path, so untrusted input then reaches the reader's terminal verbatim:
Note: deactivating the build-time feature
coloris not a mitigation as that
removes all ANSI escape code stripping fromenv_logger.
Neither configuration avoids both. The coupling isn't required though: without color there is no styling emitted, so nothing needs parsing, only payload bytes need neutralizing.
Proposal
Escape C0 and DEL as \xNN when color is off, sparing \n and \t.
- 319 ns/record measured, so sanitizing costs ~17 ns over the unsafe build today
colorpath untouched, no behavior change for anyone using it- differs from the strip it replaces in both directions:
- stricter on
\r, VT and FF, whichanstreampasses through - more permissive on raw C1 and stray continuation bytes, which
anstreamdrops (matching it there needs full UTF-8 validation — ~20 lines, free for ASCII records, ~+40 ns/record for records with legitimate non-ASCII)
- stricter on
- 主要语言
- Rust
- 星标
- 1.1k
- 派生
- 150
- 平均合并
- 3 分钟
- 30 天内合并 PR
- 2
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rust-cli/env_logger 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 45/100
rust-cli/env_logger#379 · 5 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
rust-cli/env_logger#369 ·
-
难度 4/5 3-5 天 新手友好度 35/100
rust-cli/env_logger#367 · 1 条评论 ·
-
refactor the crate to separate the provided configurable formater and the optional custom formatter未关闭
难度 5/5 一周以上 新手友好度 35/100
rust-cli/env_logger#365 · 10 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
rust-cli/env_logger#364 · 11 条评论 · 2 个 reaction ·
查看 rust-cli/env_logger 的全部 Issue
相似的 Issue
-
agent:triaged bug bughunt pm:bundler priority:p1
难度 2/5 1-3 小时 新手友好度 70/100
SocketDev/socket-patch#1573 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
bytecodealliance/rustix#1706 · 1 条评论 ·
维护者通常 11 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
-
难度 2/5 1-3 小时 新手友好度 72/100
wormhole-foundation/wormhole#5062 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复