Skip to content

Commit 0626266

Browse files
committed
feat!(detector): relace go-msfdb with vuls2
Replace standalone go-msfdb FillWithMetasploit() with vuls2 EnrichVulnInfos pipeline. Metasploit data is now sourced from vuls-data-extracted-msf via BoltDB. - Extend enrich() to handle sourceTypes.Metasploit → vi.Metasploits - Remove detector/msf.go and all FillWithMetasploit() calls - Remove MetasploitConf from config and subcmds - Remove go-msfdb dependency (go.mod, dependabot.yml) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent afd0c4d commit 0626266

15 files changed

Lines changed: 25 additions & 319 deletions

File tree

.github/dependabot.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ updates:
4545
- "github.com/vulsio/go-cve-dictionary"
4646
- "github.com/vulsio/go-exploitdb"
4747
- "github.com/vulsio/go-kev"
48-
- "github.com/vulsio/go-msfdb"
4948
- "github.com/vulsio/gost"
5049
trivy:
5150
patterns:
@@ -62,7 +61,6 @@ updates:
6261
- "github.com/vulsio/go-cve-dictionary"
6362
- "github.com/vulsio/go-exploitdb"
6463
- "github.com/vulsio/go-kev"
65-
- "github.com/vulsio/go-msfdb"
6664
- "github.com/vulsio/gost"
6765
- "github.com/aquasecurity/trivy"
6866
- "github.com/aquasecurity/trivy-db"

config/config.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ type Config struct {
4141
CveDict GoCveDictConf `json:"cveDict,omitzero"`
4242
Gost GostConf `json:"gost,omitzero"`
4343
Exploit ExploitConf `json:"exploit,omitzero"`
44-
Metasploit MetasploitConf `json:"metasploit,omitzero"`
4544
KEVuln KEVulnConf `json:"kevuln,omitzero"`
4645
Cti CtiConf `json:"cti,omitzero"`
4746
Vuls2 Vuls2Conf `json:"vuls2,omitzero"`
@@ -191,7 +190,6 @@ func (c *Config) ValidateOnReport() bool {
191190
&Conf.CveDict,
192191
&Conf.Gost,
193192
&Conf.Exploit,
194-
&Conf.Metasploit,
195193
&Conf.KEVuln,
196194
&Conf.Cti,
197195
} {

config/tomlloader.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ func (c TOMLLoader) Load(pathToToml string) error {
4141
&Conf.CveDict,
4242
&Conf.Gost,
4343
&Conf.Exploit,
44-
&Conf.Metasploit,
4544
&Conf.KEVuln,
4645
&Conf.Cti,
4746
} {

config/vulnDictConf.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -227,33 +227,6 @@ func (cnf *GostConf) Init() {
227227
cnf.DebugSQL = Conf.DebugSQL
228228
}
229229

230-
// MetasploitConf is go-msfdb config
231-
type MetasploitConf struct {
232-
VulnDict
233-
}
234-
235-
const metasploitDBType = "METASPLOITDB_TYPE"
236-
const metasploitDBURL = "METASPLOITDB_URL"
237-
const metasploitDBPATH = "METASPLOITDB_SQLITE3_PATH"
238-
239-
// Init set options with the following priority.
240-
// 1. Environment variable
241-
// 2. config.toml
242-
func (cnf *MetasploitConf) Init() {
243-
cnf.Name = "metasploit"
244-
if os.Getenv(metasploitDBType) != "" {
245-
cnf.Type = os.Getenv(metasploitDBType)
246-
}
247-
if os.Getenv(metasploitDBURL) != "" {
248-
cnf.URL = os.Getenv(metasploitDBURL)
249-
}
250-
if os.Getenv(metasploitDBPATH) != "" {
251-
cnf.SQLite3Path = os.Getenv(metasploitDBPATH)
252-
}
253-
cnf.setDefault("go-msfdb.sqlite3")
254-
cnf.DebugSQL = Conf.DebugSQL
255-
}
256-
257230
// KEVulnConf is go-kev config
258231
type KEVulnConf struct {
259232
VulnDict

detector/detector.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,6 @@ func Detect(rs []models.ScanResult, dir string) ([]models.ScanResult, error) {
209209
}
210210
logging.Log.Infof("%s: %d PoC are detected", r.FormatServerName(), nExploitCve)
211211

212-
nMetasploitCve, err := FillWithMetasploit(&r, config.Conf.Metasploit, config.Conf.LogOpts)
213-
if err != nil {
214-
return nil, xerrors.Errorf("Failed to fill with metasploit: %w", err)
215-
}
216-
logging.Log.Infof("%s: %d exploits are detected", r.FormatServerName(), nMetasploitCve)
217-
218212
if err := FillWithKEVuln(&r, config.Conf.KEVuln, config.Conf.LogOpts); err != nil {
219213
return nil, xerrors.Errorf("Failed to fill with Known Exploited Vulnerabilities: %w", err)
220214
}

detector/msf.go

Lines changed: 0 additions & 250 deletions
This file was deleted.

detector/util.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func loadOneServerScanResult(jsonFile string) (*models.ScanResult, error) {
263263
}
264264

265265
// ValidateDBs checks if the databases are accessible and can be closed properly
266-
func ValidateDBs(cveConf config.GoCveDictConf, gostConf config.GostConf, exploitConf config.ExploitConf, metasploitConf config.MetasploitConf, kevulnConf config.KEVulnConf, ctiConf config.CtiConf, logOpts logging.LogOpts) error {
266+
func ValidateDBs(cveConf config.GoCveDictConf, gostConf config.GostConf, exploitConf config.ExploitConf, kevulnConf config.KEVulnConf, ctiConf config.CtiConf, logOpts logging.LogOpts) error {
267267
cvec, err := newGoCveDictClient(&cveConf, logOpts)
268268
if err != nil {
269269
return xerrors.Errorf("Failed to new CVE client. err: %w", err)
@@ -288,14 +288,6 @@ func ValidateDBs(cveConf config.GoCveDictConf, gostConf config.GostConf, exploit
288288
return xerrors.Errorf("Failed to close exploit DB. err: %w", err)
289289
}
290290

291-
metasploitc, err := newGoMetasploitDBClient(&metasploitConf, logOpts)
292-
if err != nil {
293-
return xerrors.Errorf("Failed to new metasploit client. err: %w", err)
294-
}
295-
if err := metasploitc.closeDB(); err != nil {
296-
return xerrors.Errorf("Failed to close metasploit DB. err: %w", err)
297-
}
298-
299291
kevulnc, err := newGoKEVulnDBClient(&kevulnConf, logOpts)
300292
if err != nil {
301293
return xerrors.Errorf("Failed to new KEVuln client. err: %w", err)

detector/vuls2/vuls2.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,29 @@ func enrich(sesh *session.Session, vim models.VulnInfos) error {
12191219
}
12201220

12211221
for sourceID, rootMap := range vm {
1222+
if sourceID == sourceTypes.Metasploit {
1223+
if len(vi.Metasploits) > 0 {
1224+
continue
1225+
}
1226+
for _, vulns := range rootMap {
1227+
for _, v := range vulns {
1228+
for _, m := range v.Content.Metasploit {
1229+
var urls []string
1230+
for _, r := range m.References {
1231+
urls = append(urls, r.URL)
1232+
}
1233+
vi.Metasploits = append(vi.Metasploits, models.Metasploit{
1234+
Name: m.FullName,
1235+
Title: m.Name,
1236+
Description: m.Description,
1237+
URLs: urls,
1238+
})
1239+
}
1240+
}
1241+
}
1242+
continue
1243+
}
1244+
12221245
cctype := enrichCveContentType(sourceID)
12231246
if cctype == models.Unknown {
12241247
continue

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ require (
5555
github.com/vulsio/go-cve-dictionary v0.16.0
5656
github.com/vulsio/go-exploitdb v0.7.0
5757
github.com/vulsio/go-kev v0.4.4
58-
github.com/vulsio/go-msfdb v0.4.4
5958
github.com/vulsio/gost v0.7.2
6059
go.etcd.io/bbolt v1.4.3
6160
golang.org/x/term v0.41.0

0 commit comments

Comments
 (0)