Skip to content

Commit 1bf3902

Browse files
committed
adds uid and gid flags to docker-compose.yaml, fixes linting, fixes tests by readding BeforeSave hook
1 parent a128275 commit 1bf3902

4 files changed

Lines changed: 11 additions & 4 deletions

File tree

database/models/cve_model.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/l3montree-dev/devguard/dtos"
1111
"gorm.io/datatypes"
12+
"gorm.io/gorm"
1213
)
1314

1415
type Severity string
@@ -65,6 +66,13 @@ func (cve CVE) TableName() string {
6566
return "cves"
6667
}
6768

69+
func (cve *CVE) BeforeSave(tx *gorm.DB) error {
70+
if cve.ID == 0 {
71+
cve.ID = cve.CalculateHash()
72+
}
73+
return nil
74+
}
75+
6876
// calculate the hash for the cve solely based on the cve-id using md5 for compatibility with the postgresql database
6977
func (cve CVE) CalculateHash() int64 {
7078
return CalculateHashForCVE(cve.CVE)
@@ -93,4 +101,3 @@ func (cve CVE) GetReferences() ([]cveReference, error) {
93101
}
94102
return refs, nil
95103
}
96-

database/models/exploit_model.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ func (e Exploit) CalculateContentHash() int64 {
5858
return int64(u & 0x7fffffffffffffff)
5959
}
6060

61-
func (m Exploit) TableName() string {
61+
func (e Exploit) TableName() string {
6262
return "exploits"
6363
}

docker-compose-try-it.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ services:
3131
volumes:
3232
- postgres:/var/lib/postgresql/data
3333
- ./initdb.sql:/docker-entrypoint-initdb.d/init.sql
34-
tmpfs: /run/postgresql
34+
tmpfs: /run/postgresql:rw,uid=999,gid=999
3535
networks:
3636
- devguard-local
3737

docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ services:
1313
volumes:
1414
- postgres:/var/lib/postgresql/data
1515
- ./initdb.sql:/docker-entrypoint-initdb.d/init.sql
16-
tmpfs: /run/postgresql
16+
tmpfs: /run/postgresql:rw,uid=999,gid=999
1717
# command: ["postgres", "-c", "log_statement=all"] # enable to log all queries into the log
1818

1919

0 commit comments

Comments
 (0)