Skip to content

Commit 11f1d64

Browse files
ptgottravicious
andauthored
Add an audit event reference generator (#60290)
* Add an audit event reference generator Closes #5044 Closes #10350 This change adds a generator for audit event reference documentation based on Web UI audit event formatters and, if available, test fixtures. Previous attempts to generate an audit event reference drew from the Teleport source using `AuditEvent` declarations (#13615) and naming conventions (#38344), but inconsistencies within the source meant that the resulting generator was inadequate. The Web UI source files represent the most complete set of source data we have on audit event schemas. Implementation details: - If an event includes a fixture, use that as an example of its schema. For any event formatter with no test fixture, include the event, type, code, and description in the reference guide using data from the formatter, but don't include an example. - If one event type includes multiple possible codes, document each code in an H3 section. - Ignore instances of the same code beyond the first occurrence. Co-authored-by: Rafał Cieślak <[email protected]> * Get rid of `any` in types The events map did not define what types it stores, so TypeScript defaulted it to Map<any, any>. After adjusting this type, it turned out that there were many functions with worked on Event but were actually given ReferencePageEventData, so I changed their signatures too. Types usually start with upper case, hence ReferencePageEventData and not referencePageEventData. The `as` in `Object.keys(formatters) as Array<keyof Formatters>` was not necessary, as TypeScript correctly infers the type here. * Add more context to the README * Add shorthand command to build and gen reference * Check audit event reference docs in CI Add Make targets for running and checking the audit event reference docs. Add a step to the GitHub Actions job that runs Web UI linters to check the audit event reference docs. --------- Co-authored-by: Rafał Cieślak <[email protected]>
1 parent 0044cb8 commit 11f1d64

File tree

11 files changed

+8043
-1
lines changed

11 files changed

+8043
-1
lines changed

.github/workflows/lint.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,3 +334,8 @@ jobs:
334334
- name: Check icons
335335
# We have to add the current directory as a safe directory or else git commands will not work as expected.
336336
run: git config --global --add safe.directory $(realpath .) && make icons-up-to-date
337+
338+
- name: Check audit event reference docs
339+
# We have to add the current directory as a safe directory or else git commands will not work as expected.
340+
run: git config --global --add safe.directory $(realpath .) && make audit-event-reference-up-to-date
341+

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,8 +1982,24 @@ cli-docs-tsh:
19821982
$(BUILDDIR)/tshdocs help 2>docs/pages/reference/cli/tsh.mdx && \
19831983
rm $(BUILDDIR)/tshdocs
19841984

1985+
# audit-event-reference generates audit event reference docs using the Web UI
1986+
# source.
1987+
.PHONY: audit-event-reference
1988+
audit-event-reference:
1989+
pnpm run -C ./web/packages/teleport event-reference
1990+
1991+
# audit-event-reference-up-to-date ensures the audit event reference
1992+
# documentation reflects the Web UI source.
1993+
.PHONY: audit-event-reference-up-to-date
1994+
audit-event-reference-up-to-date: must-start-clean/host audit-event-reference
1995+
@if ! git diff --quiet; then \
1996+
./build.assets/please-run.sh "audit event reference docs" "make audit-event-reference"; \
1997+
exit 1; \
1998+
fi
1999+
19852000
.PHONY: gen-docs
19862001
gen-docs:
19872002
$(MAKE) -C integrations/terraform docs
19882003
$(MAKE) -C integrations/operator crd-docs
19892004
$(MAKE) -C examples/chart render-chart-ref
2005+
$(MAKE) audit-event-reference

0 commit comments

Comments
 (0)