Detection rules landing page ignores frontmatter in index.md

未关闭 适合新手
#4,697 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
csharp
领域
documentation

调研方向

从 src/Elastic.Markdown/Extensions/DetectionRules/DetectionRuleFile.cs 中的 DetectionRuleOverviewFile.GetMarkdown() 开始,检查如何在生成的 Markdown 前包含来自 SourceFile 的 frontmatter。阅读 MarkdownFile.ProcessYamlFrontMatter,了解这些元数据的解析方式。使用 docs/index.md 中的 frontmatter 构建 docset,并确认 mapped_pages 和其他键已应用于生成的着陆页。

由索引模型根据 Issue 内容生成。

描述

bug needs triage
What happened?

The detection rules extension builds the landing page of a detection rules docset, its index.md, from generated Markdown. It never reads the file's own contents. Because frontmatter is only read from the parsed document, any frontmatter in index.md is silently dropped, including mapped_pages.

  • DetectionRuleOverviewFile overrides GetMinimalParseDocumentAsync and GetParseDocumentAsync to parse the string returned by GetMarkdown(). That string starts with # Prebuilt detection rules reference and has no frontmatter.
  • MarkdownFile.ProcessYamlFrontMatter only reads frontmatter when the parsed document's first block is a YamlFrontMatterBlock. For this page it never is, so mapped_pages, description, and the other keys have no effect.

Impact: the Prebuilt detection rules reference can't list its 8.x equivalents (/guide/en/security/<version>/prebuilt-rules.html) in the version menu. That was requested in elastic/docs-content-internal#750.

How can we reproduce it?
  1. Add frontmatter to docs/index.md in elastic/detection-rules:
    ---
    mapped_pages:
      - https://www.elastic.co/guide/en/security/current/prebuilt-rules.html
    ---
    
  2. Build the docset.
  3. The generated reference/security/prebuilt-rules page has no legacy versions, and none of the frontmatter is applied.

Possible fix: in DetectionRuleOverviewFile.GetMarkdown(), put the frontmatter block from SourceFile, if there is one, in front of the generated Markdown. Both parser pipelines already call UseYamlFrontMatter(), so ProcessYamlFrontMatter would then pick it up.

Version or commit

main at e7b055b1c7426661455963a8aa007b5ef50f3da8

Related

elastic/detection-rules#7138 adds the mapped_pages frontmatter above. It takes effect once this is fixed.

主要语言
C#
星标
25
派生
44
平均合并
17 小时 21 分钟
30 天内合并 PR
343

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

elastic/docs-builder 的其他 Issue

查看 elastic/docs-builder 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。