Skip to content
Open
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
18 changes: 0 additions & 18 deletions base/database/setup.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package database

import (
"app/base/models"
"app/base/utils"
"fmt"
"time"
Expand All @@ -23,7 +22,6 @@ var (
DB *gorm.DB
DBReadReplica *gorm.DB
OtherAdvisoryTypes []string
AdvisoryTypes map[int]string
globalPgConfig map[DBMode]PostgreSQLConfig = make(map[DBMode]PostgreSQLConfig)
)

Expand Down Expand Up @@ -172,20 +170,4 @@ func loadAdditionalParamsFromDB() {
if err != nil {
panic(err)
}

// Load AdvisoryTypes
var types []models.AdvisoryType

err = DB.Table("advisory_type").
Select("id, name").
Scan(&types).Error
utils.LogDebug("advisory_types", types, "Advisory types loaded from DB")
if err != nil {
panic(err)
}

AdvisoryTypes = make(map[int]string)
for _, at := range types {
AdvisoryTypes[at.ID] = at.Name
}
}
5 changes: 3 additions & 2 deletions base/database/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package database

import (
"app/base/utils"
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

func TestDBCheck(t *testing.T) {
Expand All @@ -15,5 +16,5 @@ func TestAdditionalParams(t *testing.T) {
utils.SkipWithoutDB(t)
Configure()

assert.True(t, len(AdvisoryTypes) == 5)
assert.True(t, len(OtherAdvisoryTypes) == 2)
}
7 changes: 4 additions & 3 deletions base/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"time"

"github.com/lib/pq"
"gorm.io/datatypes"
)

type RhAccount struct {
Expand Down Expand Up @@ -261,10 +262,10 @@ type AdvisoryMetadata struct {
ModifiedDate *time.Time
URL *string
SeverityID *int
PackageData []byte
CveList []byte
PackageData datatypes.JSONSlice[string] `gorm:"type:jsonb"`
CveList datatypes.JSONSlice[string] `gorm:"type:jsonb"`
RebootRequired bool
ReleaseVersions []byte
ReleaseVersions datatypes.JSONSlice[string] `gorm:"type:jsonb"`
Synced bool
}

Expand Down
34 changes: 17 additions & 17 deletions base/vmaas/vmaas.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,23 +210,23 @@ type ErrataResponse struct {
}

type ErrataResponseErrataList struct {
Updated string `json:"updated,omitempty"`
Severity string `json:"severity,omitempty"`
ReferenceList *[]string `json:"reference_list,omitempty"`
Issued string `json:"issued,omitempty"`
Description string `json:"description,omitempty"`
Solution *string `json:"solution,omitempty"`
Summary string `json:"summary,omitempty"`
URL *string `json:"url,omitempty"`
Synopsis string `json:"synopsis,omitempty"`
CveList *[]string `json:"cve_list,omitempty"`
BugzillaList *[]string `json:"bugzilla_list,omitempty"`
PackageList []string `json:"package_list,omitempty"`
SourcePackageList *[]string `json:"source_package_list,omitempty"`
Type string `json:"type,omitempty"`
ThirdParty *bool `json:"third_party,omitempty"`
RequiresReboot bool `json:"requires_reboot,omitempty"`
ReleaseVersions *[]string `json:"release_versions,omitempty"`
Updated string `json:"updated,omitempty"`
Severity string `json:"severity,omitempty"`
ReferenceList []string `json:"reference_list,omitempty"`
Issued string `json:"issued,omitempty"`
Description string `json:"description,omitempty"`
Solution *string `json:"solution,omitempty"`
Summary string `json:"summary,omitempty"`
URL *string `json:"url,omitempty"`
Synopsis string `json:"synopsis,omitempty"`
CveList []string `json:"cve_list,omitempty"`
BugzillaList []string `json:"bugzilla_list,omitempty"`
PackageList []string `json:"package_list,omitempty"`
SourcePackageList []string `json:"source_package_list,omitempty"`
Type string `json:"type,omitempty"`
ThirdParty *bool `json:"third_party,omitempty"`
RequiresReboot bool `json:"requires_reboot,omitempty"`
ReleaseVersions []string `json:"release_versions,omitempty"`
}

type PkgListRequest struct {
Expand Down
71 changes: 71 additions & 0 deletions docs/v3/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,20 @@
"type": "integer"
}
},
{
"name": "filter[severity_name]",
"in": "query",
"description": "Filter",
"schema": {
"type": "string",
"enum": [
"Low",
"Medium",
"High",
"Critical"
]
}
},
{
"name": "filter[installable_systems]",
"in": "query",
Expand Down Expand Up @@ -659,6 +673,20 @@
"type": "integer"
}
},
{
"name": "filter[severity_name]",
"in": "query",
"description": "Filter",
"schema": {
"type": "string",
"enum": [
"Low",
"Medium",
"High",
"Critical"
]
}
},
{
"name": "filter[applicable_systems]",
"in": "query",
Expand Down Expand Up @@ -1698,6 +1726,20 @@
"minimum": 1,
"type": "integer"
}
},
{
"name": "filter[severity_name]",
"in": "query",
"description": "Filter",
"schema": {
"type": "string",
"enum": [
"Low",
"Medium",
"High",
"Critical"
]
}
}
],
"responses": {
Expand Down Expand Up @@ -4806,6 +4848,20 @@
"minimum": 1,
"type": "integer"
}
},
{
"name": "filter[severity_name]",
"in": "query",
"description": "Filter",
"schema": {
"type": "string",
"enum": [
"Low",
"Medium",
"High",
"Critical"
]
}
}
],
"responses": {
Expand Down Expand Up @@ -6071,6 +6127,9 @@
"severity": {
"type": "integer"
},
"severity_name": {
"type": "string"
},
"synopsis": {
"type": "string"
}
Expand Down Expand Up @@ -6161,6 +6220,9 @@
"severity": {
"type": "integer"
},
"severity_name": {
"type": "string"
},
"solution": {
"type": "string"
},
Expand Down Expand Up @@ -6242,6 +6304,9 @@
"severity": {
"type": "integer"
},
"severity_name": {
"type": "string"
},
"synopsis": {
"type": "string"
}
Expand Down Expand Up @@ -6791,6 +6856,9 @@
"severity": {
"type": "integer"
},
"severity_name": {
"type": "string"
},
"status": {
"type": "string"
},
Expand Down Expand Up @@ -6859,6 +6927,9 @@
"severity": {
"type": "integer"
},
"severity_name": {
"type": "string"
},
"status": {
"type": "string"
},
Expand Down
24 changes: 3 additions & 21 deletions evaluator/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package evaluator

import (
"app/base"
"app/base/database"
"app/base/models"
"app/base/mqueue"
ntf "app/base/notification"
Expand Down Expand Up @@ -32,35 +31,18 @@ func getUnnotifiedAdvisories(tx *gorm.DB, accountID int, newAdvs SystemAdvisoryM
advIDs = append(advIDs, a.AdvisoryID)
}

var advNames []string
err := tx.Table("advisory_account_data as acd").
Select("am.name").
Select("am.id as advisory_id, am.name as advisory_name, at.name as advisory_type, am.synopsis").
Joins("inner join advisory_metadata am on am.id = acd.advisory_id").
Joins("inner join advisory_type at on at.id = am.advisory_type_id").
Where("acd.rh_account_id = ? AND acd.advisory_id IN (?)"+
"AND acd.notified IS NULL AND acd.systems_installable > 0", accountID, advIDs).
Order("am.name ASC").
Scan(&advNames).Error
Scan(&unAdvs).Error
if err != nil {
return nil, errors.Wrap(err, "querying unnotified advisories from DB failed")
}

if len(advNames) == 0 {
return nil, nil
}

for _, n := range advNames {
if a, ok := newAdvs[n]; ok {
unAdvs = append(
unAdvs,
ntf.Advisory{
AdvisoryID: a.AdvisoryID,
AdvisoryName: a.Advisory.Name,
AdvisoryType: database.AdvisoryTypes[a.Advisory.AdvisoryTypeID],
Synopsis: a.Advisory.Synopsis,
})
}
}

return unAdvs, nil
}

Expand Down
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ require (

require (
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260209202127-80ab13bee0bf.1 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down Expand Up @@ -69,6 +70,7 @@ require (
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.30.1 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/goccy/go-yaml v1.19.2 // indirect
github.com/gorilla/securecookie v1.1.2 // indirect
Expand Down Expand Up @@ -134,6 +136,8 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20260226221140-a57be14db171 // indirect
google.golang.org/protobuf v1.36.11 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/datatypes v1.2.7 // indirect
gorm.io/driver/mysql v1.5.6 // indirect
)

replace github.com/segmentio/kafka-go v0.4.49 => github.com/MichaelMraka/kafka-go v0.0.0-20251014134425-230b5408c208
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260209202127-80ab13bee0bf.1 h1:PMmTMyvHScV9Mn8wc6ASge9uRcHy0jtqPd+fM35LmsQ=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260209202127-80ab13bee0bf.1/go.mod h1:tvtbpgaVXZX4g6Pn+AnzFycuRK3MOz5HJfEGeEllXYM=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0=
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
Expand Down Expand Up @@ -111,6 +113,9 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.30.1 h1:f3zDSN/zOma+w6+1Wswgd9fLkdwy06ntQJp0BBvFG0w=
github.com/go-playground/validator/v10 v10.30.1/go.mod h1:oSuBIQzuJxL//3MelwSLD5hc2Tu889bF0Idm9Dg26cM=
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM=
github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
Expand Down Expand Up @@ -467,8 +472,13 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/datatypes v1.2.7 h1:ww9GAhF1aGXZY3EB3cJPJ7//JiuQo7DlQA7NNlVaTdk=
gorm.io/datatypes v1.2.7/go.mod h1:M2iO+6S3hhi4nAyYe444Pcb0dcIiOMJ7QHaUXxyiNZY=
gorm.io/driver/mysql v1.5.6 h1:Ld4mkIickM+EliaQZQx3uOJDJHtrd70MxAUqWqlx3Y8=
gorm.io/driver/mysql v1.5.6/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM=
gorm.io/driver/postgres v1.6.0 h1:2dxzU8xJ+ivvqTRph34QX+WrRaJlmfyPqXmoGVjMBa4=
gorm.io/driver/postgres v1.6.0/go.mod h1:vUw0mrGgrTK+uPHEhAdV4sfFELrByKVGnaVRkXDhtWo=
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
gorm.io/gorm v1.31.1 h1:7CA8FTFz/gRfgqgpeKIBcervUn3xSyPUmr6B2WXJ7kg=
gorm.io/gorm v1.31.1/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
Expand Down
Loading
Loading