Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions controllers/artifact_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ func (c *ArtifactController) UpdateArtifact(ctx shared.Context) error {
// @Param assetSlug path string true "Asset slug"
// @Param assetVersionSlug path string true "Asset version slug"
// @Param artifactName path string true "Artifact name"
// @Success 200 {object} object
// @Produce application/json
// @Success 200 {object} object "CycloneDX BOM in JSON format"
// @Router /organizations/{organization}/projects/{projectSlug}/assets/{assetSlug}/refs/{assetVersionSlug}/artifacts/{artifactName}/sbom.json/ [get]
func (c *ArtifactController) SBOMJSON(ctx shared.Context) error {
assetVersion := shared.GetAssetVersion(ctx)
Expand Down Expand Up @@ -470,7 +471,8 @@ func (c *ArtifactController) SBOMJSON(ctx shared.Context) error {
// @Param assetSlug path string true "Asset slug"
// @Param assetVersionSlug path string true "Asset version slug"
// @Param artifactName path string true "Artifact name"
// @Success 200 {object} object
// @Produce application/xml
// @Success 200 {string} string "CycloneDX BOM in XML format"
// @Router /organizations/{organization}/projects/{projectSlug}/assets/{assetSlug}/refs/{assetVersionSlug}/artifacts/{artifactName}/sbom.xml/ [get]
func (c *ArtifactController) SBOMXML(ctx shared.Context) error {
assetVersion := shared.GetAssetVersion(ctx)
Expand All @@ -483,6 +485,7 @@ func (c *ArtifactController) SBOMXML(ctx shared.Context) error {
if err := sbom.ScopeToArtifact(artifact.ArtifactName); err != nil {
return echo.NewHTTPError(500, "could not scope sbom to artifact").WithInternal(err)
}
ctx.Response().Header().Set("Content-Type", "application/xml")
encoder := cdx.NewBOMEncoder(ctx.Response().Writer, cdx.BOMFileFormatXML).SetPretty(true).SetEscapeHTML(false)
return encoder.Encode(sbom.ToCycloneDX(ctxToBOMMetadata(ctx)))
}
Expand All @@ -496,14 +499,16 @@ func (c *ArtifactController) SBOMXML(ctx shared.Context) error {
// @Param assetSlug path string true "Asset slug"
// @Param assetVersionSlug path string true "Asset version slug"
// @Param artifactName path string true "Artifact name"
// @Success 200 {object} object
// @Produce application/xml
// @Success 200 {string} string "CycloneDX VEX in XML format"
// @Router /organizations/{organization}/projects/{projectSlug}/assets/{assetSlug}/refs/{assetVersionSlug}/artifacts/{artifactName}/vex.xml/ [get]
func (c *ArtifactController) VEXXML(ctx shared.Context) error {
sbom, err := c.buildVeX(ctx)
if err != nil {
return err
}

ctx.Response().Header().Set("Content-Type", "application/xml")
encoder := cdx.NewBOMEncoder(ctx.Response().Writer, cdx.BOMFileFormatXML).SetPretty(true).SetEscapeHTML(false)

return encoder.Encode(sbom.ToCycloneDX(ctxToBOMMetadata(ctx)))
Expand All @@ -518,7 +523,8 @@ func (c *ArtifactController) VEXXML(ctx shared.Context) error {
// @Param assetSlug path string true "Asset slug"
// @Param assetVersionSlug path string true "Asset version slug"
// @Param artifactName path string true "Artifact name"
// @Success 200 {object} object
// @Produce application/json
// @Success 200 {object} object "CycloneDX VEX in JSON format"
// @Router /organizations/{organization}/projects/{projectSlug}/assets/{assetSlug}/refs/{assetVersionSlug}/artifacts/{artifactName}/vex.json/ [get]
func (c *ArtifactController) VEXJSON(ctx shared.Context) error {
sbom, err := c.buildVeX(ctx)
Expand All @@ -541,7 +547,8 @@ func (c *ArtifactController) VEXJSON(ctx shared.Context) error {
// @Param assetSlug path string true "Asset slug"
// @Param assetVersionSlug path string true "Asset version slug"
// @Param artifactName path string true "Artifact name"
// @Success 200 {object} object
// @Produce application/json
// @Success 200 {object} object "OpenVEX document in JSON format"
// @Router /organizations/{organization}/projects/{projectSlug}/assets/{assetSlug}/refs/{assetVersionSlug}/artifacts/{artifactName}/openvex.json/ [get]
func (c *ArtifactController) OpenVEXJSON(ctx shared.Context) error {
vex, err := c.buildOpenVeX(ctx)
Expand Down Expand Up @@ -595,7 +602,8 @@ func (c *ArtifactController) buildVeX(ctx shared.Context) (*normalize.SBOMGraph,
// @Param assetSlug path string true "Asset slug"
// @Param assetVersionSlug path string true "Asset version slug"
// @Param artifactName path string true "Artifact name"
// @Success 200 {object} object
// @Produce application/pdf
// @Success 200 {string} string "Vulnerability report as PDF"
// @Router /organizations/{organization}/projects/{projectSlug}/assets/{assetSlug}/refs/{assetVersionSlug}/artifacts/{artifactName}/vulnerability-report.pdf/ [get]
func (c *ArtifactController) BuildVulnerabilityReportPDF(ctx shared.Context) error {
assetVersion := shared.GetAssetVersion(ctx)
Expand Down Expand Up @@ -816,7 +824,8 @@ func (c *ArtifactController) BuildVulnerabilityReportPDF(ctx shared.Context) err
// @Param assetSlug path string true "Asset slug"
// @Param assetVersionSlug path string true "Asset version slug"
// @Param artifactName path string true "Artifact name"
// @Success 200 {object} object
// @Produce application/pdf
// @Success 200 {string} string "SBOM as PDF"
// @Router /organizations/{organization}/projects/{projectSlug}/assets/{assetSlug}/refs/{assetVersionSlug}/artifacts/{artifactName}/sbom.pdf/ [get]
func (c *ArtifactController) BuildPDFFromSBOM(ctx shared.Context) error {
assetVersion := shared.GetAssetVersion(ctx)
Expand Down
23 changes: 23 additions & 0 deletions controllers/asset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,17 @@ func (a *AssetController) Update(ctx shared.Context) error {
return ctx.JSON(200, transformer.AssetModelToDetailsWithSecretsDTO(asset, members))
}

// @Summary Get asset config file
// @Tags Assets
// @Security CookieAuth
// @Security PATAuth
// @Param organization path string true "Organization slug"
// @Param projectSlug path string true "Project slug"
// @Param assetSlug path string true "Asset slug"
// @Param config-file path string true "Config file ID"
// @Produce text/plain
// @Success 200 {string} string "Config file content"
// @Router /organizations/{organization}/projects/{projectSlug}/assets/{assetSlug}/config-files/{config-file}/ [get]
func (a *AssetController) GetConfigFile(ctx shared.Context) error {
organization := shared.GetOrg(ctx)
project := shared.GetProject(ctx)
Expand All @@ -399,6 +410,18 @@ func (a *AssetController) GetConfigFile(ctx shared.Context) error {
return ctx.String(200, configContent.(string))
}

// @Summary Update asset config file
// @Tags Assets
// @Security CookieAuth
// @Security PATAuth
// @Param organization path string true "Organization slug"
// @Param projectSlug path string true "Project slug"
// @Param assetSlug path string true "Asset slug"
// @Param config-file path string true "Config file ID"
// @Param body body string true "Config file content"
// @Produce text/plain
// @Success 200 {string} string "Updated config file content"
// @Router /organizations/{organization}/projects/{projectSlug}/assets/{assetSlug}/config-files/{config-file}/ [put]
func (a *AssetController) UpdateConfigFile(ctx shared.Context) error {
asset := shared.GetAsset(ctx)
configID := ctx.Param("config-file")
Expand Down
10 changes: 5 additions & 5 deletions controllers/asset_version_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func NewAssetVersionController(
// @Param assetSlug path string true "Asset slug"
// @Param assetVersionSlug path string true "Asset version slug"
// @Success 200 {object} dtos.AssetVersionDTO
// @Router /organizations/{organization}/projects/{projectSlug}/assets/{assetSlug}/refs/{assetVersionSlug} [get]
// @Router /organizations/{organization}/projects/{projectSlug}/assets/{assetSlug}/refs/{assetVersionSlug}/ [get]
func (a *AssetVersionController) Read(ctx shared.Context) error {
assetVersion := shared.GetAssetVersion(ctx)
return ctx.JSON(200, transformer.AssetVersionModelToDTO(assetVersion))
Expand All @@ -79,7 +79,7 @@ func (a *AssetVersionController) Read(ctx shared.Context) error {
// @Param assetSlug path string true "Asset slug"
// @Param body body object{name=string,tag=bool,defaultBranch=bool} true "Request body"
// @Success 201 {object} dtos.AssetVersionDTO
// @Router /organizations/{organization}/projects/{projectSlug}/assets/{assetSlug}/refs [post]
// @Router /organizations/{organization}/projects/{projectSlug}/assets/{assetSlug}/refs/ [post]
func (a *AssetVersionController) Create(ctx shared.Context) error {
asset := shared.GetAsset(ctx)

Expand Down Expand Up @@ -115,7 +115,7 @@ func (a *AssetVersionController) Create(ctx shared.Context) error {
// @Param assetSlug path string true "Asset slug"
// @Param assetVersionSlug path string true "Asset version slug"
// @Success 200
// @Router /organizations/{organization}/projects/{projectSlug}/assets/{assetSlug}/refs/{assetVersionSlug} [delete]
// @Router /organizations/{organization}/projects/{projectSlug}/assets/{assetSlug}/refs/{assetVersionSlug}/ [delete]
func (a *AssetVersionController) Delete(ctx shared.Context) error {
assetVersion := shared.GetAssetVersion(ctx) //Get the asset provided in the context / URL
err := a.assetVersionRepository.Delete(ctx.Request().Context(), nil, &assetVersion) //Call delete on the returned assetVersion
Expand All @@ -133,8 +133,8 @@ func (a *AssetVersionController) Delete(ctx shared.Context) error {
// @Param organization path string true "Organization slug"
// @Param projectSlug path string true "Project slug"
// @Param assetSlug path string true "Asset slug"
// @Success 200 {array} []dtos.AssetVersionDTO
// @Router /organizations/{organization}/projects/{projectSlug}/assets/{assetSlug}/refs [get]
// @Success 200 {array} dtos.AssetVersionDTO
// @Router /organizations/{organization}/projects/{projectSlug}/assets/{assetSlug}/refs/ [get]
func (a *AssetVersionController) GetAssetVersionsByAssetID(ctx shared.Context) error {
asset := shared.GetAsset(ctx)

Expand Down
10 changes: 6 additions & 4 deletions controllers/org_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,9 @@ func (controller *OrgController) Metrics(ctx shared.Context) error {
// @Security PATAuth
// @Param organization path string true "Organization slug"
// @Param config-file path string true "Config file ID"
// @Success 200 {string} string
// @Router /organizations/{organization}/config-files/{config-file} [get]
// @Produce text/plain
// @Success 200 {string} string "Config file content"
// @Router /organizations/{organization}/config-files/{config-file}/ [get]
func (controller *OrgController) GetConfigFile(ctx shared.Context) error {
organization := shared.GetOrg(ctx)
configID := ctx.Param("config-file")
Expand All @@ -392,8 +393,9 @@ func (controller *OrgController) GetConfigFile(ctx shared.Context) error {
// @Param organization path string true "Organization slug"
// @Param config-file path string true "Config file ID"
// @Param body body string true "Config file content"
// @Success 200 {string} string
// @Router /organizations/{organization}/config-files/{config-file} [put]
// @Produce text/plain
// @Success 200 {string} string "Updated config file content"
// @Router /organizations/{organization}/config-files/{config-file}/ [put]
func (controller *OrgController) UpdateConfigFile(ctx shared.Context) error {
organization := shared.GetOrg(ctx)
configID := ctx.Param("config-file")
Expand Down
21 changes: 21 additions & 0 deletions controllers/project_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,16 @@ func (ProjectController *ProjectController) Update(c shared.Context) error {
return c.JSON(200, resp)
}

// @Summary Get project config file
// @Tags Projects
// @Security CookieAuth
// @Security PATAuth
// @Param organization path string true "Organization slug"
// @Param projectSlug path string true "Project slug"
// @Param config-file path string true "Config file ID"
// @Produce text/plain
// @Success 200 {string} string "Config file content"
// @Router /organizations/{organization}/projects/{projectSlug}/config-files/{config-file}/ [get]
func (ProjectController *ProjectController) GetConfigFile(ctx shared.Context) error {
organization := shared.GetOrg(ctx)
project := shared.GetProject(ctx)
Expand All @@ -445,6 +455,17 @@ func (ProjectController *ProjectController) GetConfigFile(ctx shared.Context) er
return ctx.String(200, configContent.(string))
}

// @Summary Update project config file
// @Tags Projects
// @Security CookieAuth
// @Security PATAuth
// @Param organization path string true "Organization slug"
// @Param projectSlug path string true "Project slug"
// @Param config-file path string true "Config file ID"
// @Param body body string true "Config file content"
// @Produce text/plain
// @Success 200 {string} string "Updated config file content"
// @Router /organizations/{organization}/projects/{projectSlug}/config-files/{config-file}/ [put]
func (ProjectController *ProjectController) UpdateConfigFile(ctx shared.Context) error {
project := shared.GetProject(ctx)
configID := ctx.Param("config-file")
Expand Down
Loading
Loading