vulsio / go-exploitdb

Tool for searching Exploits from Exploit Databases, etc.
MIT License
249 stars 56 forks source link

feat(rdb): delete only records that match the ExploitType to be fetched #48

Closed MaineK00n closed 3 years ago

MaineK00n commented 3 years ago

What did you implement:

With this PR, only the records that match the ExploitType to be fetched will be deleted. In other words, ExploitType: OffensiveSecurity/GitHub/AwesomePoc can exist at the same time.

Type of change

How Has This Been Tested?

$ go-exploitdb fetch exploitdb
$ go-exploitdb fetch awesomepoc
$ go-exploitdb fetch exploitdb

$ sqlite3 go-exploitdb.sqlite3
SQLite version 3.31.1 2020-01-27 19:55:54
Enter ".help" for usage hints.

// The data from the first fetch of exploitdb has been deleted, and the data from awesomepoc has been added to the top.
sqlite> select id, exploit_type from exploits LIMIT 5;
id|exploit_type
46788|AwesomePoc
46789|AwesomePoc
46790|AwesomePoc
46791|AwesomePoc
46792|AwesomePoc

// Of course, the data from Exploitdb is inserted at the end.
sqlite> select id, exploit_type from exploits ORDER By id desc LIMIT 5;
id|exploit_type
94397|OffensiveSecurity
94396|OffensiveSecurity
94395|OffensiveSecurity
94394|OffensiveSecurity
94393|OffensiveSecurity

$ go-exploitdb fetch githubrepos

$ sqlite3 go-exploitdb.sqlite3
SQLite version 3.31.1 2020-01-27 19:55:54
Enter ".help" for usage hints.
sqlite> select DISTINCT exploit_type from exploits;
exploit_type
AwesomePoc
OffensiveSecurity
GitHub

Checklist:

You don't have to satisfy all of the following.

Is this ready for review?: YES

Reference