Detection rules landing page ignores frontmatter in index.md

Aperta Adatta ai principianti
#4,697 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp
Ambito
documentation

Direzione di ricerca

Inizia da DetectionRuleOverviewFile.GetMarkdown() in src/Elastic.Markdown/Extensions/DetectionRules/DetectionRuleFile.cs e verifica come può includere il frontmatter di SourceFile prima del Markdown generato. Leggi MarkdownFile.ProcessYamlFrontMatter per seguire come vengono analizzati questi metadati. Crea il docset con il frontmatter in docs/index.md e conferma che mapped_pages e le altre chiavi vengano applicate alla pagina iniziale generata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
C#
Stelle
25
Fork
44
Merge medio
17h 21m
PR unite (30g)
343

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di elastic/docs-builder

Tutte le issue di elastic/docs-builder

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.