Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove duplicate cves #211

Merged
merged 9 commits into from
Sep 5, 2021
Merged

Conversation

MaineK00n
Copy link
Collaborator

@MaineK00n MaineK00n commented Sep 3, 2021

What did you implement:

CVEs of "recent" and "modified" that were always brought at fetch time were duplicated with CVEs of years.
In the case of RDB, multiple CVEs were inserted, and multiple identical ones appeared in the response. Also, in the case of Redis, the data was overwritten, and old data may have appeared in the response.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

NVD

$ go-cve-dictionary.old fetch nvd --years 2021 --dbpath ./cve.old.sqlite
$ go-cve-dictionary.new fetch nvd --years 2021 --dbpath ./cve.new.sqlite

$ go-cve-dictionary.old server --dbpath ./cve.old.sqlite --port 1325
$ go-cve-dictionary.new server --dbpath ./cve.new.sqlite --port 1326

// upstream/master
$ curl http://127.0.0.1:1326/cves/CVE-2020-20349 | jq | grep "CveID"
  "CveID": "CVE-2020-20349",
      "CveID": "CVE-2020-20349",
      "CveID": "CVE-2020-20349",

// PR
$ curl http://127.0.0.1:1326/cves/CVE-2020-20349 | jq | grep "CveID"
  "CveID": "CVE-2020-20349",
      "CveID": "CVE-2020-20349",

JVN

$ go-cve-dictionary.old fetch jvn --years 2021 --dbpath ./cve.old.sqlite
$ go-cve-dictionary.new fetch jvn --years 2021 --dbpath ./cve.new.sqlite

$ go-cve-dictionary.old server --dbpath ./cve.old.sqlite --port 1325
$ go-cve-dictionary.new server --dbpath ./cve.new.sqlite --port 1326

// upstream/master
$ curl http://127.0.0.1:1326/cves/CVE-2020-35838 | jq | grep "ID"
  "CveID": "CVE-2020-35838",
      "CveID": "CVE-2020-35838",
      "JvnID": "JVNDB-2020-014893",
      "CveID": "CVE-2020-35838",
      "JvnID": "JVNDB-2020-014893",

// PR
$ curl http://127.0.0.1:1326/cves/CVE-2020-35838 | jq | grep "ID"
  "CveID": "CVE-2020-35838",
      "CveID": "CVE-2020-35838",
      "JvnID": "JVNDB-2020-014893",

Integration

$ make clean-integration && make build-integration
$ make fetch-rdb && make fetch-redis
$ make diff-server-rdb-redis

Checklist:

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

  • Write tests
  • Write documentation
  • Check that there aren't other open pull requests for the same issue/feature
  • Format your source code by make fmt
  • Pass the test by make test
  • Provide verification config / commands
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES

Reference

@MaineK00n MaineK00n self-assigned this Sep 3, 2021
@MaineK00n MaineK00n force-pushed the MaineK00n/fix-duplicate-insert branch from 0eced62 to c01cf55 Compare September 3, 2021 21:25
@MaineK00n MaineK00n changed the title [WIP] fix: remove duplicate cves fix: remove duplicate cves Sep 3, 2021
@MaineK00n MaineK00n requested a review from kotakanbe September 3, 2021 23:25
Copy link
Collaborator

@kotakanbe kotakanbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented, please check it out.

db/rdb.go Outdated Show resolved Hide resolved
db/rdb.go Outdated Show resolved Hide resolved
@MaineK00n MaineK00n requested a review from kotakanbe September 4, 2021 13:48
@kotakanbe kotakanbe merged commit 53194a8 into master Sep 5, 2021
@MaineK00n MaineK00n deleted the MaineK00n/fix-duplicate-insert branch September 6, 2021 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants