feat: risk templates as templateable objects#363
Conversation
Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
There was a problem hiding this comment.
Pull request overview
Adds “templateable” risk templates by introducing a label schema + dedupe label keys, and supporting Go-template rendering for key risk template fields. This extends the risk-template system so a single template can generate multiple distinct risks (e.g., per CVE) and dynamically render titles/statements from evidence labels.
Changes:
- Add
label-schemaanddedupe-label-keysto risk templates (DB model + service validation + API + SDK). - Add templated fields (
*-template) for title/statement/likelihood-hint/impact-hint and render them in the risk evidence worker. - Update migrations/tests and regenerate Swagger docs to reflect the expanded API surface.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/types/types.go | Extends SDK RiskTemplate type with template fields, dedupe keys, and label schema. |
| internal/tests/migrate.go | Includes new label schema model in test migrator up/down. |
| internal/service/worker/risk_evidence_worker_test.go | Adds coverage for dedupe key computation and template rendering into created risks. |
| internal/service/worker/risk_evidence_worker.go | Implements label-based dedupe keys and template rendering when creating risks. |
| internal/service/relational/templates/template_renderer.go | Exposes template rendering helper for cross-package use. |
| internal/service/relational/templates/risk_template_service_test.go | Adds tests for create/update/batch upsert with label schema + templates and validation cases. |
| internal/service/relational/templates/risk_template_service.go | Adds payload fields, persistence, replacement semantics, and validation for schema/dedupe/template references. |
| internal/service/relational/templates/models.go | Adds DB columns for templated fields/dedupe keys and new risk_template_label_schema_fields model. |
| internal/service/migrator.go | Adds new model to global migrate up/down ordering. |
| internal/api/handler/templates/risk_template.go | Wires new request/response fields for risk template CRUD + batch upsert. |
| docs/swagger.yaml | Documents new request/response fields and schema definitions. |
| docs/swagger.json | Generated Swagger JSON update for the new fields. |
| docs/docs.go | Embedded Swagger docs updated accordingly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.