aboutsummaryrefslogtreecommitdiff
path: root/internal/feed/feed.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/feed/feed.go')
-rw-r--r--internal/feed/feed.go39
1 files changed, 3 insertions, 36 deletions
diff --git a/internal/feed/feed.go b/internal/feed/feed.go
index c013877..cf0fd2d 100644
--- a/internal/feed/feed.go
+++ b/internal/feed/feed.go
@@ -4,8 +4,6 @@ import (
"encoding/json"
"fmt"
// "strconv"
- "regexp"
- "time"
)
const (
@@ -40,37 +38,6 @@ const (
// TODO: parse cpe
-// partial timestamp
-type PartialTime time.Time
-
-var partialTimeRe = regexp.MustCompile("\\A\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}Z\\z")
-
-// Unmarshal partial timestamp from JSON.
-func (me *PartialTime) UnmarshalJSON(b []byte) error {
- // decode string, check for error
- var s string
- if err := json.Unmarshal(b, &s); err != nil {
- return err
- }
-
- // match partial string regex
- if !partialTimeRe.MatchString(s) {
- return fmt.Errorf("invalid partial time string: %s", s)
- }
-
- // correct string suffix
- s = s[0:16] + ":00Z"
-
- // unmarshal time
- var t time.Time
- if err := t.UnmarshalText([]byte(s)); err != nil {
- return err
- }
-
- // return success
- return nil
-}
-
// Configuration node boolean operator.
type NodeOp int
@@ -666,10 +633,10 @@ type Item struct {
Impact Impact `json:"impact"`
// item published date
- PublishedDate PartialTime `json:"publishedDate"`
+ PublishedDate Time `json:"publishedDate"`
// last modification date
- LastModifiedDate PartialTime `json:"lastModifiedDate"`
+ LastModifiedDate Time `json:"lastModifiedDate"`
}
// NVD feed
@@ -687,7 +654,7 @@ type Feed struct {
NumCVEs uint64 `json:"CVE_data_numberOfCVEs,string"`
// data timestamp
- Timestamp PartialTime `json:"CVE_data_timestamp"`
+ Timestamp Time `json:"CVE_data_timestamp"`
// CVE items
Items []Item `json:"CVE_Items"`