diff --git a/README.md b/README.md index a7c4082..23cde2a 100644 --- a/README.md +++ b/README.md @@ -187,7 +187,7 @@ I0820 09:16:29.316352 1197925 cve.go:311] downloading data file "https://static. ### vulndb -vulndb is a command line tool to manage NVD-like vulnerability databases, backed by MySQL. +*vulndb* is a command line tool to manage NVD-like vulnerability databases, backed by MySQL. Supports NVD CVE JSON 1.0 feeds. Data is versioned, organized by provider names and grouped by vendor, custom, and snoozes datasets: diff --git a/cmd/vulndb/customcmd.go b/cmd/vulndb/customcmd.go index 5b09305..b554242 100644 --- a/cmd/vulndb/customcmd.go +++ b/cmd/vulndb/customcmd.go @@ -49,7 +49,7 @@ The database supports multiple providers, and for each provider there should be an owner (a unixname or other form of ID). Each import requires setting the --provider and --owner flags. -File schema: https://csrc.nist.gov/schema/nvd/feed/0.1/nvd_cve_feed_json_0.1_beta.schema +File schema: https://csrc.nist.gov/schema/nvd/feed/1.0/nvd_cve_feed_json_1.0.schema `, Run: func(cmd *cobra.Command, args []string) { if len(args) != 1 { diff --git a/cmd/vulndb/vendorcmd.go b/cmd/vulndb/vendorcmd.go index 0af67aa..3fee750 100644 --- a/cmd/vulndb/vendorcmd.go +++ b/cmd/vulndb/vendorcmd.go @@ -51,7 +51,7 @@ The database supports multiple providers, and for each provider there should be an owner (a unixname or other form of ID). Each import requires setting the --provider and --owner flags. -File schema: https://csrc.nist.gov/schema/nvd/feed/0.1/nvd_cve_feed_json_0.1_beta.schema +File schema: https://csrc.nist.gov/schema/nvd/feed/1.0/nvd_cve_feed_json_1.0.schema `, Run: func(cmd *cobra.Command, args []string) { if len(args) == 0 { diff --git a/vulndb/custom.go b/vulndb/custom.go index 7f07487..cab5e68 100644 --- a/vulndb/custom.go +++ b/vulndb/custom.go @@ -131,7 +131,7 @@ func (o CustomDataExporter) condition() *sqlutil.QueryConditionSet { return cond } -// CSV exports data to w. +// CSV writes custom data records to w. func (o CustomDataExporter) CSV(ctx context.Context, w io.Writer, header bool) error { fields := []string{ "owner", @@ -192,7 +192,7 @@ func (o CustomDataExporter) CSV(ctx context.Context, w io.Writer, header bool) e return nil } -// JSON exports NVD CVE JSON to w. +// JSON writes NVD CVE JSON to w. func (o CustomDataExporter) JSON(ctx context.Context, w io.Writer, indent string) error { q := sqlutil.Select( "cve_id", diff --git a/vulndb/schema.go b/vulndb/schema.go index df59c18..1454070 100644 --- a/vulndb/schema.go +++ b/vulndb/schema.go @@ -1,17 +1,3 @@ -// Copyright (c) Facebook, Inc. and its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package vulndb import ( @@ -42,4 +28,4 @@ func SchemaSQL() []string { } // b64SchemaSQL is auto-generated from schema.sql. -var b64SchemaSQL = []string{"RFJPUCBUQUJMRSBJRiBFWElTVFMKCWBzbm9vemVgLAoJYGN1c3RvbV9kYXRhYCwKCWB2ZW5kb3JfZGF0YWAsCglgdmVuZG9yYAo7Cg==", "U0VUIHNxbF9tb2RlID0gJyc7Cg==", "Q1JFQVRFIFRBQkxFIGB2ZW5kb3JgICgKCWB2ZXJzaW9uYCAgSU5UICAgICAgICAgTk9UIE5VTEwgQVVUT19JTkNSRU1FTlQgQ09NTUVOVCAnSUQgb2YgdGhlIGRhdGFzZXQnLAoJYHRzYCAgICAgICBUSU1FU1RBTVAgICBOT1QgTlVMTCAgQ09NTUVOVCAnVGltZSBvZiB0aGUgZGF0YXNldCBpbXBvcnQnLAoJYHJlYWR5YCAgICBCT09MICAgICAgICBOT1QgTlVMTCAgQ09NTUVOVCAnSW5kaWNhdGVzIHRoZSBkYXRhc2V0IGlzIHJlYWR5IHRvIHVzZScsCglgb3duZXJgICAgIFZBUkNIQVIoNjQpIE5PVCBOVUxMICB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WBvd25lcmAgICAgIFZBUkNIQVIoNjQpICBOT1QgTlVMTCBDT01NRU5UICdQb2ludCBvZiBjb250YWN0IGZvciBzbm9vemUnLAoJYGNvbGxlY3RvcmAgdmFyY2hhcig2NCkgIE5PVCBOVUxMIENPTU1FTlQgJ1VuaXF1ZSBuYW1lIG9mIHRoZSBkYXRhIGNvbGxlY3RvcicsCglgcHJvdmlkZXJgICBWQVJDSEFSKDMyKSAgTk9UIE5VTEwgQ09NTUVOVCAnU2hvcnQgbmFtZSBvZiBkYXRhIHByb3ZpZGVyJywKCWBjdmVfaWRgICAgIFZBUkNIQVIoMTI4KSBOT1QgTlVMTCBDT01NRU5UICdDb21tb24gVnVsbmVyYWJpbGl0eSBhbmQgRXhwb3N1cmUgSUQnLAoJYGRlYWRsaW5lYCAgVElNRVNUQU1QICAgICAgICBOVUxMIENPTU1FTlQgJ1RpbWVzdGFtcCBvZiBzbm9vemUgZXhwaXJhdGlvbicgREVGQVVMVCBDVVJSRU5UX1RJTUVTVEFNUCwKCWBtZXRhZGF0YWAgIEJMT0IgICAgICAgICAgICAgTlVMTCBDT01NRU5UICdPcGFxdWUgbWV0YWRhdGEgZm9yIHNub296ZSBtYW5hZ2VtZW50JywKCVBSSU1BUlkgS0VZIChgcHJvdmlkZXJgLCBgY3ZlX2lkYCkKKQpFTkdJTkUgSW5ub0RCCkRFRkFVTFQgQ0hBUkFDVEVSIFNFVCB1dGY4bWI0CkNPTU1FTlQgJ1Z1bG5lcmFiaWxpdHkgcmVjb3JkcyB0byBpZ25vcmUgZm9yIGEgcGVyaW9kIG9mIHRpbWUnCjsK"} diff --git a/vulndb/schema.sql b/vulndb/schema.sql index 2bc5311..171d7e6 100644 --- a/vulndb/schema.sql +++ b/vulndb/schema.sql @@ -19,8 +19,6 @@ DROP TABLE IF EXISTS `vendor` ; -SET sql_mode = ''; - CREATE TABLE `vendor` ( `version` INT NOT NULL AUTO_INCREMENT COMMENT 'ID of the dataset', `ts` TIMESTAMP NOT NULL COMMENT 'Time of the dataset import', diff --git a/vulndb/snooze.go b/vulndb/snooze.go index 9d22834..98651c5 100644 --- a/vulndb/snooze.go +++ b/vulndb/snooze.go @@ -92,7 +92,7 @@ type SnoozeGetter struct { FilterCVEs []string } -// CSV returns data from the database. +// CSV writes snooze records to w. func (s SnoozeGetter) CSV(ctx context.Context, w io.Writer, header bool) error { r := sqlutil.NewRecordType(SnoozeRecord{}) q := sqlutil.Select( diff --git a/vulndb/summary.go b/vulndb/summary.go index 614dd58..401389a 100644 --- a/vulndb/summary.go +++ b/vulndb/summary.go @@ -70,7 +70,7 @@ func (exp SummaryExporter) SummaryRecords(ctx context.Context) ([]SummaryRecord, return records, nil } -// CSV exports data to w. +// CSV writes summary records to w. func (exp SummaryExporter) CSV(ctx context.Context, w io.Writer, header bool) error { records, err := exp.SummaryRecords(ctx) if err != nil { diff --git a/vulndb/vendor.go b/vulndb/vendor.go index 3a6f171..25d9869 100644 --- a/vulndb/vendor.go +++ b/vulndb/vendor.go @@ -230,7 +230,7 @@ func (v VendorDataExporter) condition() *sqlutil.QueryConditionSet { return cond } -// CSV exports data to w. +// CSV writes vendor data records to w. func (v VendorDataExporter) CSV(ctx context.Context, w io.Writer, header bool) error { q := sqlutil.Select( "vendor.version AS version", @@ -306,7 +306,7 @@ func (v VendorDataExporter) CSV(ctx context.Context, w io.Writer, header bool) e return nil } -// JSON exports NVD CVE JSON to w. +// JSON writes NVD CVE JSON to w. func (v VendorDataExporter) JSON(ctx context.Context, w io.Writer, indent string) error { q := sqlutil.Select( "cve_id", @@ -361,9 +361,12 @@ func (v VendorDataExporter) JSON(ctx context.Context, w io.Writer, indent string // VendorDataTrimmer is a helper for trimming vendor data. // +// It deletes all versions but the latest. +// // Deleting would be easier in common scenarions, but we have some hard // constraints: // +// * Vendor data is versioned // * No foreign key between vendor_data and vendor tables // * MySQL in safe mode forbids deleting from SELECT queries, wants values // * Must keep the binlog smaller than 500M, not enough for the NVD database @@ -372,9 +375,9 @@ func (v VendorDataExporter) JSON(ctx context.Context, w io.Writer, indent string // // * Select versions from the vendor table based on the provided settings // * Operate on vendor records with ready=true or older versions -// * By default, delete all versions but the latest for each provider +// * By default, delete all versions but the latest, for each provider // * Delete from vendor table first, effectively making data records orphans -// * Delete any orphan records from vendor_data, effectively crow sourcing deletions +// * Delete any orphan records from vendor_data, effectively crowd sourcing deletions // * Delete data in chunks, keeping binlog small // // Deletion operations are expensive.