feat: first approach advisory-tab#2183
Open
juliankepka wants to merge 11 commits into
Open
Conversation
timbastin
requested changes
Jun 29, 2026
Member
|
Pls ensure to cross-check for “Withdraw” functionality. So that users can withdraw a published advisory (the OSV should be able to handle this too). An unpublished draft advisory should be deletable. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces first-pass support for publishing DevGuard-managed security advisories by adding database persistence, CRUD API plumbing, and CSAF report generation for advisory-based documents (DGSA).
Changes:
- Adds
advisories+affected_packagestables/models and a GORM repository/service layer for CRUD operations. - Exposes new advisory CRUD endpoints under the asset version router (
/advisory/...) and wires controller/providers. - Extends CSAF generation/serving flow to support advisory-backed CSAF documents (DGSA).
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| transformer/advisory_transformer.go | Maps advisory create/update DTOs into DB models (including affected packages). |
| shared/common_interfaces.go | Adds AdvisoryService/AdvisoryRepository interfaces and CSAF service extension for advisory reports. |
| services/providers.go | Registers AdvisoryService with Fx DI. |
| services/csaf_service.go | Adds CSAF document generation for advisory-backed reports (DGSA). |
| services/advisory_service.go | Service wrapper delegating advisory CRUD to repository. |
| router/providers.go | Registers AdvisoryRouter with Fx DI. |
| router/advisory_router.go | Adds asset-version-scoped routes for advisory CRUD. |
| dtos/advisory_dto.go | Defines advisory request/response DTOs and affected-package DTO. |
| database/repositories/providers.go | Registers AdvisoryRepository with Fx DI. |
| database/repositories/advisory_repository.go | Implements advisory CRUD + paged listing with GORM. |
| database/models/advisory_model.go | Adds Advisory and AffectedPackage DB models and many-to-many relation. |
| database/migrations/20260623101120_add_advisory_table.up.sql | Creates advisories, affected_packages, and join table schema. |
| controllers/providers.go | Registers AdvisoryController with Fx DI. |
| controllers/csaf_controller.go | Extends CSAF serving endpoint to support DGSA/advisory reports. |
| controllers/advisory_controller.go | Implements advisory CRUD HTTP handlers. |
| cmd/devguard/main.go | Invokes the new AdvisoryRouter to activate routes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1488
to
+1491
| summaryText := utils.OrDefault(utils.EmptyThenNil(advisory.Description), advisory.Title) | ||
| if summaryText == "" { | ||
| summaryText = fmt.Sprintf("Security advisory %s.", cveID) | ||
| } |
Comment on lines
+513
to
+517
| parsedID := strings.TrimSuffix(cveID[strings.LastIndex(cveID, "-")+1:], ".json") | ||
| id, err := strconv.ParseInt(parsedID, 10, 64) | ||
| if err != nil { | ||
| return fmt.Errorf("ungültige advisory ID %q aus %q: %w", parsedID, cveID, err) | ||
| } |
Comment on lines
+77
to
+87
| advisory, err := controller.advisoryService.ReadAdvisory(ctx.Request().Context(), nil, parsedID) | ||
|
|
||
| if err != nil { | ||
| if errors.Is(err, gorm.ErrRecordNotFound) { | ||
| return echo.NewHTTPError(404, "advisory not found").WithInternal(err) | ||
| } | ||
| return echo.NewHTTPError(500, "could not get any data").WithInternal(err) | ||
| } | ||
|
|
||
| return ctx.JSON(200, advisory) | ||
| } |
Comment on lines
+101
to
+111
| advisory, err := controller.advisoryService.ReadAdvisory(ctx.Request().Context(), nil, parsedID) | ||
| if err != nil { | ||
| if errors.Is(err, gorm.ErrRecordNotFound) { | ||
| return echo.NewHTTPError(404, "advisory not found").WithInternal(err) | ||
| } | ||
| return echo.NewHTTPError(500, "could not get any data").WithInternal(err) | ||
| } | ||
|
|
||
| advisory = transformer.AdvisoryUpdateRequestToModel(req, advisory) | ||
| advisory.AssetID = shared.GetAsset(ctx).ID | ||
|
|
Comment on lines
+121
to
+135
| func (controller *AdvisoryController) Delete(ctx shared.Context) error { | ||
| advisoryID := ctx.Param("id") | ||
| parsedID, err := strconv.ParseInt(advisoryID, 10, 64) | ||
| if err != nil { | ||
| return echo.NewHTTPError(400, "invalid id provided") | ||
| } | ||
|
|
||
| err = controller.advisoryService.Delete(ctx.Request().Context(), nil, parsedID) | ||
|
|
||
| if err != nil { | ||
| return echo.NewHTTPError(500, "could not remove name").WithInternal(err) | ||
| } | ||
|
|
||
| return ctx.NoContent(200) | ||
| } |
| Description string `json:"description" gorm:"type:text;column:description"` | ||
| AffectedPackages []AffectedPackage `json:"affectedPackages" gorm:"many2many:advisories_affected_packages;foreignKey:ID;joinForeignKey:advisory_id;References:ID;joinReferences:affected_package_id;constraint:OnDelete:CASCADE"` | ||
| Severity string `json:"severity" gorm:"type:text;column:severity"` | ||
| VectorString string `json:"vectorstring" gorm:"type:text;column:vector_string"` |
Comment on lines
+23
to
+27
| Ecosystem string `json:"ecosystem" gorm:"type:text;column:ecosystem"` | ||
| PackageName string `json:"packagename" gorm:"type:text;column:package_name"` | ||
| SemverIntroduced *string `json:"semverStart" gorm:"type:semver;index"` | ||
| SemverFixed *string `json:"semverEnd" gorm:"type:semver;index"` | ||
| Advisory []Advisory `json:"advisory" gorm:"many2many:advisories_affected_packages;constraint:OnDelete:CASCADE"` |
Comment on lines
+1459
to
+1461
| now := time.Now() | ||
| cveID := fmt.Sprintf("DGSA-%d-%d", now.Year(), advisory.ID) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2168 together with l3montree-dev/devguard-web#792