Skip to content

feat: first approach advisory-tab#2183

Open
juliankepka wants to merge 11 commits into
mainfrom
feat/advisory
Open

feat: first approach advisory-tab#2183
juliankepka wants to merge 11 commits into
mainfrom
feat/advisory

Conversation

@juliankepka

@juliankepka juliankepka commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

@juliankepka juliankepka marked this pull request as ready for review June 29, 2026 09:55
Comment thread database/migrations/20260623101120_add_advisory_table.up.sql Outdated
Comment thread controllers/advisory_controller.go Outdated
Comment thread controllers/advisory_controller.go Outdated
Comment thread controllers/advisory_controller.go Outdated
Comment thread controllers/advisory_controller.go Outdated
Comment thread database/repositories/advisory_repository.go Outdated
Comment thread database/repositories/advisory_repository.go Outdated
Comment thread database/repositories/advisory_repository.go Outdated
Comment thread router/advisory_router.go
Comment thread services/advisory_service.go Outdated
@seb-kw

seb-kw commented Jul 1, 2026

Copy link
Copy Markdown
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.

Copilot AI review requested due to automatic review settings July 1, 2026 12:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_packages tables/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 thread services/csaf_service.go
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)
}
Comment thread shared/common_interfaces.go Outdated
Comment thread shared/common_interfaces.go Outdated
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 thread services/csaf_service.go
Comment on lines +1459 to +1461
now := time.Now()
cveID := fmt.Sprintf("DGSA-%d-%d", now.Year(), advisory.ID)

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.

Publish own security advisories

4 participants