func()

in providers/idefense/schema/convert.go [28:88]


func (item *Vulnerability) Convert() (*nvd.NVDCVEFeedJSON10DefCVEItem, error) {
	lastModifiedDate, err := convertTime(item.LastModified)
	if err != nil {
		return nil, errors.Wrap(err, "can't convert last modified date")
	}
	publishedDate, err := convertTime(item.LastPublished)
	if err != nil {
		return nil, errors.Wrap(err, "can't convert published date")
	}

	configurations, err := item.makeConfigurations()
	if err != nil {
		return nil, errors.Wrap(err, "can't create configurations")
	}

	return &nvd.NVDCVEFeedJSON10DefCVEItem{
		CVE: &nvd.CVEJSON40{
			CVEDataMeta: &nvd.CVEJSON40CVEDataMeta{
				ID:       item.ID(),
				ASSIGNER: "idefense",
			},
			DataFormat:  "MITRE",
			DataType:    "CVE",
			DataVersion: cveDataVersion,
			Description: &nvd.CVEJSON40Description{
				DescriptionData: []*nvd.CVEJSON40LangString{
					{Lang: "en", Value: item.Description},
				},
			},
			Problemtype: &nvd.CVEJSON40Problemtype{
				ProblemtypeData: []*nvd.CVEJSON40ProblemtypeProblemtypeData{
					{
						Description: []*nvd.CVEJSON40LangString{
							{Lang: "en", Value: item.Cwe},
						},
					},
				},
			},
			References: item.makeReferences(),
		},
		Configurations: configurations,
		Impact: &nvd.NVDCVEFeedJSON10DefImpact{
			BaseMetricV2: &nvd.NVDCVEFeedJSON10DefImpactBaseMetricV2{
				CVSSV2: &nvd.CVSSV20{
					BaseScore:     item.Cvss2BaseScore,
					TemporalScore: item.Cvss2TemporalScore,
					VectorString:  item.Cvss2,
				},
			},
			BaseMetricV3: &nvd.NVDCVEFeedJSON10DefImpactBaseMetricV3{
				CVSSV3: &nvd.CVSSV30{
					BaseScore:     item.Cvss3BaseScore,
					TemporalScore: item.Cvss3TemporalScore,
					VectorString:  item.Cvss3,
				},
			},
		},
		LastModifiedDate: lastModifiedDate,
		PublishedDate:    publishedDate,
	}, nil
}