Exemple #1
0
func sync_entry(entry nvd.Entry, db *sql.DB, cwes nvd.CWE, ts tracker.Tracker) {
	entry.CWE.CWECatalog = &cwes
	// Completely new?
	if !util.Exists(db, entry.Id) {
		syslog.Noticef("Adding new CVE %s", entry.Id)
		id, err := ts.Add(entry)
		if err != nil {
			syslog.Errf("Unable to add %v to issue tracker: %v", entry.Id, err)
			return
		}
		// Add to database, too
		util.DB_Add(db, entry.Id, entry.Last_Modified, id)
		// Already existing, but modified?
	} else if !util.Modified_Matches(db, entry.Id, entry.Last_Modified) {
		syslog.Noticef("Modifying old CVE %s", entry.Id)
		ticketid := util.DB_TicketID(db, entry.Id)
		err := ts.Update(entry, ticketid)
		if err != nil {
			syslog.Errf("Unable to modify %v in issue tracker: %v", entry.Id, err)
			return
		}
		// Update to database, too
		util.DB_Update(db, entry.Id, entry.Last_Modified)
	}
}