Skip to content

Add extension hook points to all special usecases to inject themselves into docs build process#666

Merged
Mpdreamz merged 7 commits intomainfrom
feature/detection-rules-extension
Mar 4, 2025
Merged

Add extension hook points to all special usecases to inject themselves into docs build process#666
Mpdreamz merged 7 commits intomainfrom
feature/detection-rules-extension

Conversation

@Mpdreamz
Copy link
Member

@Mpdreamz Mpdreamz commented Mar 4, 2025

Implements detection-rules as an extension.

Extensions implement IDocsBuilderExtension and allows us to build specific use case extensions for teams by hooking into various places (TOC building/File scanning/rendering) while not injecting too much bespoke logic in our common building blocks.

Extensions are opt-in and can be enabled in docset.yml e.g:

extensions:
  - detection-rules

This particular one allows you to use a special detection_rules instruction to discover TOML detection rule set definition files as children.

toc:
  - file: index.md
    detection_rules: '../rules'

Copilot AI review requested due to automatic review settings March 4, 2025 09:16
@Mpdreamz Mpdreamz self-assigned this Mar 4, 2025
@Mpdreamz Mpdreamz requested a review from a team March 4, 2025 09:16
@Mpdreamz Mpdreamz changed the title feature/detection rules extension Add extension hook points to all special usecases to inject themselves into docs build process Mar 4, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR implements a new extension system for detection rules, moves configuration management for enabled extensions, and updates documentation to reflect these changes.

  • Introduces a DetectionRuleFile class and corresponding parser for detection rule TOML files.
  • Extracts extension handling into a dedicated EnabledExtensions class and registers new documentation builder extensions.
  • Updates navigation, configuration file parsing, and file scanning to integrate detection rules support.

Reviewed Changes

File Description
src/Elastic.Markdown/Extensions/DetectionRules/DetectionRuleFile.cs Adds detection rule file parsing and markdown generation for detection rules.
src/Elastic.Markdown/Extensions/DetectionRules/DetectionRule.cs Sets up the DetectionRule record and its TOML parser with required metadata.
src/Elastic.Markdown/IO/Configuration/EnabledExtensions.cs Introduces an extension configuration wrapper which handles enabled extensions.
docs/configure/content-set/extensions.md Updates documentation with configuration sample for detection rules extension.
Other files Integrates detection rules extensions into documentation navigation, file scanning, and build context.

Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/Elastic.Markdown/IO/Configuration/ConfigurationFile.cs:189

  • In the 'detection_rules' case of the ReadChildren method, the code appends '/{folder}' to the parentPath even though 'folder' is not guaranteed to have been initialized in this branch. Consider using a variable that holds the detection rules folder name or verify that 'folder' is set.
parentPath += $"/{folder}";

@Mpdreamz Mpdreamz merged commit a7281a8 into main Mar 4, 2025
8 checks passed
@Mpdreamz Mpdreamz deleted the feature/detection-rules-extension branch March 4, 2025 12:02
Mpdreamz added a commit that referenced this pull request Mar 4, 2025
…s into docs build process (#666)

* Move detection-rules support behind an extension system

* Move EnabledExtensions to Configuration

* add untracked files

* Add documentation for extensions

* Add more extensions points to isolate the DetectionRule extension further

* Isolate file scanning in DocumentationSet

* Do a ful parse
Mpdreamz added a commit that referenced this pull request Mar 4, 2025
* stage

* Simplify function

* ensure binary is named bootstrap

* add lambda docker build

* update lambda build

* Add `free-disk-space` input (#614)

* Add `free-disk-space` input

* Use exact commit

* Simply if check on Free Disk Space (#616)

* Default CurrentUrlPath to empty string while we investigate further (#618)

* Fix `free-disk-space` input attempt 2 (#617)

* Just compare with repository name for now (#619)

* Add update-reference-index action (#622)

* Update links-index.json whenever a PR get's closed (#623)

* Update links-index.json whenever we push a links.json (#624)

* Continue-on-error temporarily for validate-inbound-links (#627)

* docs-preview: Use `since_last_remote_commit: true` for changed-files action (#628)

* On ci skip if /docs folder has no docset.yml silently (#630)

* On ci skip if /docs folder has no docset.yml silently

* skip false not in finally

* Add log message

* Revert "docs-preview: Use `since_last_remote_commit: true` for changed-files …" (#629)

This reverts commit ed33817.

* Feature: allow the docs-build action to hint to subsequent steps to skip (#631)

* Set correct deployment status (#632)

* Optimize preview build to avoid checkout on pull_request* events (#633)

* Add `PrimaryNav` feature (#604)

* Add latest header design and adjust pages navigation

* Fix unintended merge changes

* fix

* Pass markdownparser to directive html renderer

* Change feature flag from UpperCamelCase to kebab-case

* Update docs/_docset.yml

* Refactor feature flags

---------

Co-authored-by: Martijn Laarman <Mpdreamz@gmail.com>

* Revert "Add `PrimaryNav` feature (#604)" (#635)

This reverts commit 8edd22a.

* Add smoke test (#637)

* Add smoke test

* fix

* Run free-disk-space action in security-docs (#639)

* Add `primary-nav` feature (#636)

* Add latest header design and adjust pages navigation

* Fix unintended merge changes

* fix

* Pass markdownparser to directive html renderer

* Change feature flag from UpperCamelCase to kebab-case

* Update docs/_docset.yml

* Refactor feature flags

* Fix case where targetUrl is null or empty

* Revert Commands.cs

* Don't fail-fast on matrix

* Handle the case where there is no root index.md file

* Fix

* test

* ok

* fix

* Fix

---------

Co-authored-by: Martijn Laarman <Mpdreamz@gmail.com>

* Inbound link checking, fully validate if found in links-index (#643)

* Add `landing-page-path` output and use it in preview workflow (#642)

* Add first-page-path output and use it in preview build workflow

* Refactor

* Add to test

* Fix smoke test

* Refactor

* Fix

* Fix smoke test

* Fix output name in usage and add output to action.yml

* Refactor smoke-tests

* Fix preview-build.yml (#644)

* Remove unused workflow (#646)

* Add validate command for single published repository (#648)

Update command to be rooted to `docs-assembler inbound-links <command>`

* Refactor link index command into dedicated LinkRegistry module (#649)

Moved the "create-index" command from InboundLinkCommands to a new LinkRegistryCommands class for better modularity and maintainability. Updated program registration to include the new LinkRegistryCommands module and renamed the command to "update" for clarity.

* Better error messages for cross_link errors (From `docs-builder` and `docs-assembler`) (#651)

* Ensure inbound links validation skips docset.yml declared repositories validation

* Add warning that link links to repository not in yet in the registry

* Add better errors to docs-builder to (link to links.json file)

* Add logging to git remote resolving (#652)

* Update cross-repo links syntax info (#654)

* If GITHUB_REPOSITORY is set use it verbatim (#655)

* Share inbound-links commands with `docs-builder` (#657)

* Fix `environment_url` in preview deployment (#658)

* Adjust links and wording in primary and secondary navigation (#659)

* Add mobile navigations (#662)

* Add mobile navigations

* Remove landing-page feature toggle

* Add extension hook points to all special usecases to inject themselves into docs build process (#666)

* Move detection-rules support behind an extension system

* Move EnabledExtensions to Configuration

* add untracked files

* Add documentation for extensions

* Add more extensions points to isolate the DetectionRule extension further

* Isolate file scanning in DocumentationSet

* Do a ful parse

* Rename binary to follow kebab-case convention

* Move lambda.DockerFile

* Update lambda.DockerFile

* Update README.md for publish-links-index-lambda with build instructions

* Update src/docs-lambda-index-publisher/lambda.DockerFile

Co-authored-by: Jan Calanog <jan.calanog@elastic.co>

---------

Co-authored-by: Jan Calanog <jan.calanog@elastic.co>
Co-authored-by: Liam Thompson <32779855+leemthompo@users.noreply.github.com>
@reakaleek reakaleek mentioned this pull request Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants