From 5c15122495136a9c5ecc2d01c49c7fca1fead055 Mon Sep 17 00:00:00 2001 From: Anthony Mendonca <17821357+tmendonca28@users.noreply.github.com> Date: Wed, 1 Jan 2025 23:25:40 +0300 Subject: [PATCH 1/2] Integrate GenerateCoverageMatrices function into generate-docs workflow - Added a call to the GenerateCoverageMatrices function within generate-docs.go. Signed-off-by: Anthony Mendonca <17821357+tmendonca28@users.noreply.github.com> --- v2/tools/generate-docs.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/v2/tools/generate-docs.go b/v2/tools/generate-docs.go index cfbd1fb7..f1c79f77 100644 --- a/v2/tools/generate-docs.go +++ b/v2/tools/generate-docs.go @@ -28,6 +28,13 @@ func main() { os.Exit(1) } + // Generate HTML files for each platform + if err := GenerateCoverageMatrices(index, docsDirectory); err != nil { + fmt.Fprintln(os.Stderr, "Could not generate coverage matrices") + fmt.Fprintf(os.Stderr, "%v\n", err) + os.Exit(1) + } + // Write a single index file with all techniques. File is enconded in YAML. yamlIndex := filepath.Join(docsDirectory, "index.yaml") if err := GenerateYAML(yamlIndex, index); err != nil { From 4f088d3b1654ccc8d1b129ee2e74a4c1c33edaf9 Mon Sep 17 00:00:00 2001 From: Anthony Mendonca <17821357+tmendonca28@users.noreply.github.com> Date: Wed, 1 Jan 2025 23:28:47 +0300 Subject: [PATCH 2/2] Add GenerateCoverageMatrices function to produce HTML coverage matrices -Created generate-coverage-matrices.go in tools directory -Added logic to dynamically generate stylized HTML tables for each platform -Included in-line CSS for table styling and better readability Signed-off-by: Anthony Mendonca <17821357+tmendonca28@users.noreply.github.com> --- v2/tools/generate-coverage-matrices.go | 112 +++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 v2/tools/generate-coverage-matrices.go diff --git a/v2/tools/generate-coverage-matrices.go b/v2/tools/generate-coverage-matrices.go new file mode 100644 index 00000000..45043cd7 --- /dev/null +++ b/v2/tools/generate-coverage-matrices.go @@ -0,0 +1,112 @@ +package main + +import ( + "fmt" + "os" + "path/filepath" + "sort" + + "github.com/datadog/stratus-red-team/v2/pkg/stratus" +) + +func GenerateCoverageMatrices(index map[stratus.Platform]map[string][]*stratus.AttackTechnique, docsDirectory string) error { + // Process each platform in the index + for platform, tacticsMap := range index { + // Initialize the HTML content + htmlContent := fmt.Sprintf(` + + +
+%s | ", tactic) + } + htmlContent += "|
---|---|
%s | ", cell) + } else { + htmlContent += "" + } + } + htmlContent += " |