shellbags: make the registry traversal injectable so the malformed-record recovery path is testable
维护者通常 3 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 48/100
- Issue 类型
- 重构
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- cpp
调研方向
Start in the shellbags traversal: parseShellbags() and parseRegistry() call queryKey() directly, and parseShellData() is where the malformed-record exception is thrown. Thread a QueryKeyFunc through both, with genShellbags() passing the real queryKey and an empty function falling back to it. Done when a test with an injected layout (valid parent, malformed child, valid sibling) shows the sibling row present, the child and its descendants absent, and the sibling path correct.
由索引模型根据 Issue 内容生成。
描述
Context
During the #9286 review, @mike-myers-aapl approved with a note inviting a follow-up: the malformed-record recovery added in that PR (the try/catch around parseShellData with build_shellbag.resize(depth) + continue) is untested, because parseShellbags()/parseRegistry() call queryKey() against the live registry — a regression test that actually fails without the recovery would first need the traversal to take an injectable key source.
Why the recovery path matters
parseShellbags() recurses over registry keys; for each key it calls parseShellData() on attacker-controlled record bytes and then recurses into the child path. The recovery added in #9286 means a malformed record must (a) not abort the whole shellbags query, (b) not leave a partial path behind for its descendants, and (c) let siblings keep the correct path (build_shellbag.resize(depth) runs before continue, and the recursion is inside the try). None of that is currently exercised by a test.
Proposed design
Thread a key-source function through the traversal:
using QueryKeyFunc = std::function<void(const std::string& path, QueryData& results)>;
void parseShellbags(const std::string& path,
std::vector<std::string>& build_shellbag,
QueryData& results,
const std::string& sid,
const std::string& source,
const QueryKeyFunc& query_key_func);
void parseRegistry(const std::string& full_path,
const std::string& sid,
QueryData& results,
const std::string& source,
const QueryKeyFunc& query_key_func);
genShellbags() passes the real queryKey; an empty QueryKeyFunc falls back to it, so existing callers are unchanged. guidLookup() keeps hitting the live registry — in a test its misses fall back to the GUID string via guidNameOrSentinel(), which is harmless for traversal assertions.
The regression test this unlocks
An injected key source returns a controlled layout: a valid parent (a real shellbag record, e.g. the network-share record the existing shellitem tests use), a malformed child whose parseShellData() throws (a nonempty record shorter than four characters, per the review discussion), and a valid sibling. Assertions:
- traversal continues past the malformed child (the sibling's row exists);
- the malformed child contributes no row and its descendants are skipped;
- the sibling's path contains exactly the expected parent and sibling components (the depth restoration held).
Without the #9286 recovery the thrown exception escapes the traversal and the assertions cannot pass, so the test genuinely fails on the pre-fix code.
Happy to take this up as a follow-up PR if the shape works for maintainers — or to adapt to a different injection style (template parameter, keyed interface class) if that fits the codebase better.
- 主要语言
- C++
- 星标
- 23.8k
- 派生
- 2.7k
- 平均合并
- 6 天 11 小时
- 30 天内合并 PR
- 69
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
osquery/osquery 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 3 天内回复
-
usb_devices: usb_address and usb_port are wrong for bus/device numbers 8–99 on Linux (zero-padded udev values parsed as octal)可能已有人在做 @mjatin2007 于 6 天前认领。 未关闭Linux virtual tables
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 3 天内回复
-
Update the expired Slack invite link in README可能重新可做 @ayushkrsingh946 于 40 天前认领,目前没有进行中的 PR。 未关闭maintainer task
难度 1/5 1 小时以内 新手友好度 68/100
osquery/osquery#9215 · 4 条评论 ·
维护者通常 3 天内回复
-
fix(docs): debugging guide incorrectly says invalid configuration blocks daemon startup可能已有人在做 @nightcityblade 于 54 天前认领。 未关闭configuration documentation
难度 2/5 1-3 小时 新手友好度 72/100
osquery/osquery#9143 · 1 条评论 ·
维护者通常 3 天内回复
-
scheduled_tasks.hidden returns the task's Enabled state instead of Hidden (Windows)可能已有人在做 @a-bonfim-tech 于 67 天前认领。 未关闭bug triage virtual tables Windows
难度 2/5 1-3 小时 新手友好度 86/100
维护者通常 3 天内回复
相似的 Issue
-
Make the HTTP server's keep-alive and headers timeouts configurable可能已有人在做 @mattgodbolt 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
compiler-explorer/compiler-explorer#9902 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
Nixtla/statsforecast#1371 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
[Bug]: pip install -U cudaq-qec fails with a conflict that names cudaq-qec itself可能已有人在做 @fedonman 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
task
难度 2/5 1-3 小时 新手友好度 76/100
SparseLinearAlgebra/spla#316 · 1 条评论 ·
维护者通常 1 天内回复