From 70a2bdef07df3d1e9b423b37cfc8afa4ef4e3816 Mon Sep 17 00:00:00 2001 From: "John L. Whiteman" Date: Wed, 29 Apr 2015 14:25:54 -0700 Subject: [PATCH] jira: Added check to prevent dups for same session Signed-off-by: John L. Whiteman --- src/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 1e4fe4a..87f5cf0 100644 --- a/src/main.c +++ b/src/main.c @@ -459,6 +459,7 @@ bool track_bugs(const gchar *auto_bug_template) autofree(gchar) *cve_url = NULL; struct cve_entry_t *cve_entry = NULL; bool ret = true; + GHashTable *no_dup_ids = NULL; if (self == NULL || self->cdb == NULL) { return false; @@ -478,10 +479,11 @@ bool track_bugs(const gchar *auto_bug_template) if (!get_jira_issues(jira_search_json, &jira_issues)) { return false; } + no_dup_ids = g_hash_table_new(g_str_hash, g_str_equal); cves = g_hash_table_get_values(self->cdb); for (cve=cves; cve; cve=cve->next) { cve_entry = cve->data; - if (!get_jira_issue(jira_issues, cve_entry->id)) { + if (!get_jira_issue(jira_issues, cve_entry->id) && !g_hash_table_contains(no_dup_ids, cve_entry->id)) { cve_url = g_strdup_printf("https://cve.mitre.org/cgi-bin/cvename.cgi?name=%s", cve_entry->id); printf("Adding to bug database: %s\n -%s\n", cve_entry->id, cve_url); @@ -500,9 +502,11 @@ bool track_bugs(const gchar *auto_bug_template) if (!ret) { break; } + g_hash_table_insert(no_dup_ids, cve_entry->id, cve_entry->id); } } g_list_free(cves); + g_hash_table_destroy(no_dup_ids); free_jira_issues(&jira_issues); if (!ret) { printf("Error: Aborting adding CVEs to bug database due to errors\n");