Skip to content

Commit b4bd2ac

Browse files
authored
feat(detector/vuls2): open with Read Only Mode (#2180)
1 parent 1151a63 commit b4bd2ac

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

detector/vuls2/db.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import (
66
"path/filepath"
77
"time"
88

9-
"github.com/future-architect/vuls/config"
10-
"github.com/future-architect/vuls/logging"
119
"github.com/pkg/errors"
10+
bolt "go.etcd.io/bbolt"
1211
"golang.org/x/xerrors"
1312

13+
"github.com/future-architect/vuls/config"
14+
"github.com/future-architect/vuls/logging"
15+
1416
db "github.com/MaineK00n/vuls2/pkg/db/common"
1517
"github.com/MaineK00n/vuls2/pkg/db/fetch"
1618
)
@@ -40,8 +42,9 @@ func newDBConnection(vuls2Conf config.Vuls2Conf, noProgress bool) (db.DB, error)
4042
}
4143

4244
dbc, err := (&db.Config{
43-
Type: "boltdb",
44-
Path: vuls2Conf.Path,
45+
Type: "boltdb",
46+
Path: vuls2Conf.Path,
47+
Options: db.DBOptions{BoltDB: &bolt.Options{ReadOnly: true}},
4548
}).New()
4649
if err != nil {
4750
return nil, xerrors.Errorf("Failed to new vuls2 db connection. err: %w", err)
@@ -66,8 +69,9 @@ func shouldDownload(vuls2Conf config.Vuls2Conf, now time.Time) (bool, error) {
6669
}
6770

6871
dbc, err := (&db.Config{
69-
Type: "boltdb",
70-
Path: vuls2Conf.Path,
72+
Type: "boltdb",
73+
Path: vuls2Conf.Path,
74+
Options: db.DBOptions{BoltDB: &bolt.Options{ReadOnly: true}},
7175
}).New()
7276
if err != nil {
7377
return false, xerrors.Errorf("Failed to new vuls2 db connection. path: %s, err: %w", vuls2Conf.Path, err)

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/BurntSushi/toml v1.5.0
99
github.com/CycloneDX/cyclonedx-go v0.9.2
1010
github.com/MaineK00n/vuls-data-update v0.0.0-20241224035812-2450d4a4763f
11-
github.com/MaineK00n/vuls2 v0.0.1-alpha.0.20250116022438-98d2bd6a7bce
11+
github.com/MaineK00n/vuls2 v0.0.1-alpha.0.20250418035303-727e0a682b7a
1212
github.com/Ullaakut/nmap/v2 v2.2.2
1313
github.com/aquasecurity/trivy v0.61.0
1414
github.com/aquasecurity/trivy-db v0.0.0-20250311120810-59fdabb63644
@@ -289,7 +289,7 @@ require (
289289
github.com/prometheus/common v0.62.0 // indirect
290290
github.com/prometheus/procfs v0.15.1 // indirect
291291
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
292-
github.com/redis/rueidis v1.0.53 // indirect
292+
github.com/redis/rueidis v1.0.56 // indirect
293293
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
294294
github.com/rivo/uniseg v0.4.7 // indirect
295295
github.com/rubenv/sql-migrate v1.7.1 // indirect

go.sum

+6-6
Original file line numberDiff line numberDiff line change
@@ -682,8 +682,8 @@ github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapp
682682
github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk=
683683
github.com/MaineK00n/vuls-data-update v0.0.0-20241224035812-2450d4a4763f h1:mGsE8hE7Yb1db2XhLQIL9ueYAqwhkTJkChcS1mUZOMU=
684684
github.com/MaineK00n/vuls-data-update v0.0.0-20241224035812-2450d4a4763f/go.mod h1:X15skWJjHS02lyFsbyU0gXlfrLyOMBrhj7X7cJ876h8=
685-
github.com/MaineK00n/vuls2 v0.0.1-alpha.0.20250116022438-98d2bd6a7bce h1:p+mTWxB+0u/l5alE/gtXLtbQ3OOlVsSO6mUAmUGdmc8=
686-
github.com/MaineK00n/vuls2 v0.0.1-alpha.0.20250116022438-98d2bd6a7bce/go.mod h1:HxXNc6mW5rDqEnTMK66og7iRqag2ylsteW6C9MO9Rg8=
685+
github.com/MaineK00n/vuls2 v0.0.1-alpha.0.20250418035303-727e0a682b7a h1:eUcm08LzE5NT16Qxyh3iak+oaw8ClJYKEKAh0O78rVw=
686+
github.com/MaineK00n/vuls2 v0.0.1-alpha.0.20250418035303-727e0a682b7a/go.mod h1:nol+/GQ7O5ECHaohnNoW1qPSiKGHxiWmgl2PH8kPAR8=
687687
github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ=
688688
github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=
689689
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
@@ -1507,8 +1507,8 @@ github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
15071507
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
15081508
github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM=
15091509
github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
1510-
github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
1511-
github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
1510+
github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8=
1511+
github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlRPHzY=
15121512
github.com/open-policy-agent/opa v1.2.0 h1:88NDVCM0of1eO6Z4AFeL3utTEtMuwloFmWWU7dRV1z0=
15131513
github.com/open-policy-agent/opa v1.2.0/go.mod h1:30euUmOvuBoebRCcJ7DMF42bRBOPznvt0ACUMYDUGVY=
15141514
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
@@ -1581,8 +1581,8 @@ github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5X
15811581
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
15821582
github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E=
15831583
github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw=
1584-
github.com/redis/rueidis v1.0.53 h1:r3eT4bp7Nyt+kSldT2po/EO9YeawHfZDY9TJBrHRLD4=
1585-
github.com/redis/rueidis v1.0.53/go.mod h1:by+34b0cFXndxtYmPAHpoTHO5NkosDlBvhexoTURIxM=
1584+
github.com/redis/rueidis v1.0.56 h1:DwPjFIgas1OMU/uCqBELOonu9TKMYt3MFPq6GtwEWNY=
1585+
github.com/redis/rueidis v1.0.56/go.mod h1:g660/008FMYmAF46HG4lmcpcgFNj+jCjCAZUUM+wEbs=
15861586
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
15871587
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
15881588
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=

0 commit comments

Comments
 (0)