diff options
author | Paul Duncan <pabs@pablotron.org> | 2022-03-19 00:16:51 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2022-03-19 00:16:51 -0400 |
commit | bc29bd5fa5e3c640c8a66d5428fd5e1ca60c4a26 (patch) | |
tree | d073f86c4efcdcd46bed47b575aba4b46c37588b /nvdmirror | |
parent | b05f3d64e419c1137a20eed5954a500560a1ff38 (diff) | |
download | cvez-bc29bd5fa5e3c640c8a66d5428fd5e1ca60c4a26.tar.bz2 cvez-bc29bd5fa5e3c640c8a66d5428fd5e1ca60c4a26.zip |
add nvdmirror/update.go and nvdmirror/updatetype_string.go
Diffstat (limited to 'nvdmirror')
-rw-r--r-- | nvdmirror/update.go | 33 | ||||
-rw-r--r-- | nvdmirror/updatetype_string.go | 28 |
2 files changed, 61 insertions, 0 deletions
diff --git a/nvdmirror/update.go b/nvdmirror/update.go new file mode 100644 index 0000000..871cd89 --- /dev/null +++ b/nvdmirror/update.go @@ -0,0 +1,33 @@ +package nvdmirror + +import ( + "encoding/json" +) + +//go:generate stringer -linecomment -type=UpdateType + +// update type +type UpdateType byte + +// Marshal UpdateType as JSON. +func (t UpdateType) MarshalJSON() ([]byte, error) { + return json.Marshal(t.String()) +} + +const ( + UpdateCveYear UpdateType = iota // cveyear + UpdateCveMeta // cvemeta + UpdateCpeMatch // cpematch + UpdateCpeDict // cpedict + UpdateCisaKevc // kevc + UpdateCweList // cwe +) + +// Syncronization update. +type Update struct { + Type UpdateType `json:"type"` // update type + Year int `json:"year,omitempty"` // CVE year (only used for cve years) + Meta string `json:"meta,omitempty"` // CVE meta type (only used for cve metas) + Url string `json:"url,omitempty"` // source URL + Path string `json:"path,omitempty"` // backing file +} diff --git a/nvdmirror/updatetype_string.go b/nvdmirror/updatetype_string.go new file mode 100644 index 0000000..2a81282 --- /dev/null +++ b/nvdmirror/updatetype_string.go @@ -0,0 +1,28 @@ +// Code generated by "stringer -linecomment -type=UpdateType"; DO NOT EDIT. + +package nvdmirror + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[UpdateCveYear-0] + _ = x[UpdateCveMeta-1] + _ = x[UpdateCpeMatch-2] + _ = x[UpdateCpeDict-3] + _ = x[UpdateCisaKevc-4] + _ = x[UpdateCweList-5] +} + +const _UpdateType_name = "cveyearcvemetacpematchcpedictkevccwe" + +var _UpdateType_index = [...]uint8{0, 7, 14, 22, 29, 33, 36} + +func (i UpdateType) String() string { + if i >= UpdateType(len(_UpdateType_index)-1) { + return "UpdateType(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _UpdateType_name[_UpdateType_index[i]:_UpdateType_index[i+1]] +} |