Skip to content

add endpoint custom documentation to generate-docs #389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 31, 2023

Conversation

ferullo
Copy link
Contributor

@ferullo ferullo commented Jul 17, 2023

Change Summary

This is a replacement PR for #334

This PR is the first of four chained PRs. I've broken them up to make them reviewable. The final goal is to document what fields are actually available in each Endpoint document type.

  1. (This PR) Add the code to read in new YAML documentation and render it in Markdown.
  2. Add minimal YAML documentation that defines all the document types add minimal custom_documentation files #390
  3. Update all YAML documentation to add content to custom_documentation files #391
  4. Render the YAML into pre-committed Markdown files add rendered custom_documentation #392

Please at least skim all four PRs because seeing them all will help understand this PR better. Notably, I have comments asking for feedback in the second PR that are relevant to this PR.

Release Target

This will ideally be backported into 8.9

@ferullo ferullo requested a review from a team as a code owner July 17, 2023 16:12
@@ -67,6 +69,11 @@ func generateDocs(options generateOptions) error {
}

for _, packageName := range packages {
err = renderCustomDocumentation(options, packageName)
if err != nil {
return errors.Wrapf(err, "rendering custom documentation failed (packageName: %s)", packageName)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does anyone have any ideas for a better conceptual name for this documentation than "custom documentation"?

Copy link
Contributor

Choose a reason for hiding this comment

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

"Detailed Documentation" ?

Copy link
Member

Choose a reason for hiding this comment

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

enumerated docs?

packeted docs? (or some other word to logically describe the grouping breakdown of the payload types. By OS / feature)

@elasticmachine
Copy link
Contributor

elasticmachine commented Jul 17, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-07-28T02:28:53.682+0000

  • Duration: 7 min 23 sec

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

for _, f := range event.doc.Fields.Endpoint {
detail, ok := event.doc.Fields.Details[f]
if ok {
f += "<br /><br />" + strings.TrimSpace(strings.ReplaceAll(detail.Description, "\n", " "))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

here is a relevant comment in another PRs that shows how this works.

https://github.com/elastic/endpoint-package/pull/391/files#r1265607445

}

type eventFields struct {
Endpoint []string `yaml:"endpoint"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't love this YAML key name (see comment in another PR here https://github.com/elastic/endpoint-package/pull/390/files#r1265610303)

@ferullo
Copy link
Contributor Author

ferullo commented Jul 17, 2023

@kevinlog can this PR's general approach be reviewed. If it looks good an LGTM would be nice. Without any requests for changes in this or any other PRs in this chain the only change I plan to make is to fill in all the "FILL ME IN" placeholders.

@kevinlog
Copy link
Contributor

Seeing failed make with the following message:

[2023-07-17T16:16:01.804Z] 2023/07/17 16:16:01 generating docs failed: rendering custom documentation failed (packageName: endpoint): failed to find custom documentation (path: custom_documentation/endpoint: Failed to list directory custom_documentation/endpoint/data_stream: open custom_documentation/endpoint/data_stream: no such file or directory

Jenkins: https://fleet-ci.elastic.co//blue/rest/organizations/jenkins/pipelines/endpoint-package-mbp/pipelines/PR-389/runs/1/steps/116/log/?start=0

From the read out, it looks like the custom_documentation is expecting there to be a data_stream of the same name?

@ferullo
Copy link
Contributor Author

ferullo commented Jul 17, 2023

The make failure is an artifact of me breaking this into four PRs. The final PR in the chain (#392) passes the same checks.

I plan to merge PR4 into PR3, then PR3 into PR2, then PR2 into this PR, then this PR into main when it comes time to merge. I have no problem with only receiving comments that say LGTM before that merge flow happens if you'd like. But once I do it it'll be a lot harder to review just these changes.

@@ -67,6 +69,11 @@ func generateDocs(options generateOptions) error {
}

for _, packageName := range packages {
err = renderCustomDocumentation(options, packageName)
if err != nil {
return errors.Wrapf(err, "rendering custom documentation failed (packageName: %s)", packageName)
Copy link
Member

Choose a reason for hiding this comment

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

enumerated docs?

packeted docs? (or some other word to logically describe the grouping breakdown of the payload types. By OS / feature)


**This documentation is still beta**

The subdirectories document all ECS fields that may exist in documents generated by Endpoint into
Copy link
Contributor

Choose a reason for hiding this comment

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

'document fields in documents' - phrasing is awkward

Comment on lines +107 to +108
low := strings.ToLower(_os)
if low != "linux" && low != "macos" && low != "windows" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not enforce strict casing for consistency?
(And does go have a cleaner "item in list" syntax?)

Suggested change
low := strings.ToLower(_os)
if low != "linux" && low != "macos" && low != "windows" {
if _os != "linux" && _os != "macos" && _os != "windows" {

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah. I see that you do enforce consistency later - on output.

Copy link
Contributor

@jdu2600 jdu2600 left a comment

Choose a reason for hiding this comment

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

LGTM - noting that I don't know enough go to know if this is good go

@paul-tavares paul-tavares removed their request for review July 26, 2023 13:51
ferullo and others added 2 commits July 27, 2023 19:09
* add minimal custom_documentation files

* fill in FILL ME IN

* add linux and macos unquarantine

* change heartbeat data stream type

* yam => yaml

* only credential access api events are non-diagnostic

* Apply suggestions from code review

Co-authored-by: Leszek Kubik <[email protected]>

* add content to custom_documentation files (#391)

* add content to custom_documentation files

* add macos endpoint_unquarantine fields

* linux endpoint unquarantine documentation

* add more malicous behavior fields on linux

* add more missing fields

* add a field

* switch to .* notation for malicious alert fields

* restore host.* fields

* add rendered custom_documentation (#392)

* add rendered custom_documentation

* re-render docs

* re-render

---------

Co-authored-by: Leszek Kubik <[email protected]>
@ferullo
Copy link
Contributor Author

ferullo commented Jul 28, 2023

I merged the 3 chained PRs into this. There were minor updates to firm up some of the fields enumerated. I'll merge this PR into main in a few hours unless I hear any objections.

@ferullo ferullo merged commit 8f04708 into main Jul 31, 2023
@ferullo ferullo deleted the endpoint-documentation-code branch July 31, 2023 16:34
@elasticmachine
Copy link
Contributor

Package endpoint - 8.10.0 containing this change is available at https://epr.elastic.co/search?package=endpoint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants