Blame SOURCES/0190-bugzilla-don-t-report-private-problem-as-comment.patch

28bab8
From 6e11121e7ec10cd63e6bbaa8e996b883e9fe1ac2 Mon Sep 17 00:00:00 2001
28bab8
From: Matej Habrnal <mhabrnal@redhat.com>
28bab8
Date: Wed, 23 Mar 2016 17:11:56 +0100
28bab8
Subject: [PATCH] bugzilla: don't report private problem as comment
28bab8
28bab8
Before this patch reporter-bugzilla ignored the Private report request
28bab8
and added a public comment to a duplicate bug because it was assumed
28bab8
that the duplicate comment cannot contain anything security sensitive.
28bab8
28bab8
There are two problems with it. The assumption is invalid because the
28bab8
comment contains all one-line files including 'cmdline' and the reporter
28bab8
might added something private to the bug description.
28bab8
28bab8
Bugzilla comments can be made private but not all users have rights to
28bab8
do so. On the contrary, all users can set a group to a bug report.
28bab8
Hence, this commit teaches reporter-bugzilla to ask the user if he/she
28bab8
wants to open a new, private bug report and immediately close it as a
28bab8
duplicate of the original or terminate the reporting. The tool will ask
28bab8
the question only if the users wants to open a private report and a
28bab8
duplicate bug report is found.
28bab8
28bab8
Resolves: #1279453
28bab8
28bab8
Signed-off-by: Jakub Filak <jfilak@redhat.com>
28bab8
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
28bab8
---
28bab8
 src/plugins/reporter-bugzilla.c | 44 +++++++++++++++++++++++++++++++++++++++--
28bab8
 src/plugins/rhbz.c              | 23 +++++++++++++++++++++
28bab8
 src/plugins/rhbz.h              |  4 ++++
28bab8
 3 files changed, 69 insertions(+), 2 deletions(-)
28bab8
28bab8
diff --git a/src/plugins/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c
28bab8
index 941c91f..fbe7873 100644
28bab8
--- a/src/plugins/reporter-bugzilla.c
28bab8
+++ b/src/plugins/reporter-bugzilla.c
28bab8
@@ -907,6 +907,7 @@ int main(int argc, char **argv)
28bab8
     unsigned opts = parse_opts(argc, argv, program_options, program_usage_string);
28bab8
     argv += optind;
28bab8
 
28bab8
+    load_global_configuration();
28bab8
     export_abrt_envvars(0);
28bab8
 
28bab8
     map_string_t *settings = new_map_string();
28bab8
@@ -928,6 +929,8 @@ int main(int argc, char **argv)
28bab8
          */
28bab8
         /*free_map_string(settings);*/
28bab8
     }
28bab8
+    /* either we got Bugzilla_CreatePrivate from settings or -g was specified on cmdline */
28bab8
+    rhbz.b_create_private |= (opts & OPT_g);
28bab8
 
28bab8
     log_notice("Initializing XML-RPC library");
28bab8
     xmlrpc_env env;
28bab8
@@ -1189,8 +1192,38 @@ int main(int argc, char **argv)
28bab8
             }
28bab8
         }
28bab8
 
28bab8
-        if (existing_id < 0)
28bab8
+        if (existing_id < 0 || rhbz.b_create_private)
28bab8
         {
28bab8
+
28bab8
+            if (existing_id >= 0)
28bab8
+            {
28bab8
+                char *msg = xasprintf(_(
28bab8
+                "You have requested to make your data accessible only to a "
28bab8
+                "specific group and this bug is a duplicate of bug: "
28bab8
+                "%s/%u"
28bab8
+                " "
28bab8
+                "In case of bug duplicates a new comment is added to the "
28bab8
+                "original bug report but access to the comments cannot be "
28bab8
+                "restricted to a specific group."
28bab8
+                " "
28bab8
+                "Would you like to open a new bug report and close it as "
28bab8
+                "DUPLICATE of the original one?"
28bab8
+                " "
28bab8
+                "Otherwise, the bug reporting procedure will be terminated."),
28bab8
+                rhbz.b_bugzilla_url, existing_id);
28bab8
+
28bab8
+                int r = ask_yes_no(msg);
28bab8
+                free(msg);
28bab8
+
28bab8
+                if (r == 0)
28bab8
+                {
28bab8
+                    log(_("Logging out"));
28bab8
+                    rhbz_logout(client);
28bab8
+
28bab8
+                    exit(EXIT_CANCEL_BY_USER);
28bab8
+                }
28bab8
+            }
28bab8
+
28bab8
             /* Create new bug */
28bab8
             log(_("Creating a new bug"));
28bab8
 
28bab8
@@ -1205,7 +1238,7 @@ int main(int argc, char **argv)
28bab8
             int new_id = rhbz_new_bug(client,
28bab8
                     problem_data, rhbz.b_product, rhbz.b_product_version,
28bab8
                     summary, bzcomment,
28bab8
-                    (rhbz.b_create_private | (opts & OPT_g)), // either we got Bugzilla_CreatePrivate from settings or -g was specified on cmdline
28bab8
+                    rhbz.b_create_private,
28bab8
                     rhbz.b_private_groups
28bab8
                     );
28bab8
             free(bzcomment);
28bab8
@@ -1241,6 +1274,13 @@ int main(int argc, char **argv)
28bab8
             bz = new_bug_info();
28bab8
             bz->bi_status = xstrdup("NEW");
28bab8
             bz->bi_id = new_id;
28bab8
+
28bab8
+            if (existing_id >= 0)
28bab8
+            {
28bab8
+                log(_("Closing bug %i as duplicate of bug %i"), new_id, existing_id);
28bab8
+                rhbz_close_as_duplicate(client, new_id, existing_id, RHBZ_NOMAIL_NOTIFY);
28bab8
+            }
28bab8
+
28bab8
             goto log_out;
28bab8
         }
28bab8
 
28bab8
diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
28bab8
index bad9ed4..a227c62 100644
28bab8
--- a/src/plugins/rhbz.c
28bab8
+++ b/src/plugins/rhbz.c
28bab8
@@ -862,6 +862,29 @@ void rhbz_set_url(struct abrt_xmlrpc *ax, int bug_id, const char *url, int flags
28bab8
         xmlrpc_DECREF(result);
28bab8
 }
28bab8
 
28bab8
+void rhbz_close_as_duplicate(struct abrt_xmlrpc *ax, int bug_id,
28bab8
+                        int duplicate_bug,
28bab8
+                        int flags)
28bab8
+{
28bab8
+    func_entry();
28bab8
+
28bab8
+    const int nomail_notify = !!IS_NOMAIL_NOTIFY(flags);
28bab8
+    xmlrpc_value *result = abrt_xmlrpc_call(ax, "Bug.update", "{s:i,s:s,s:s,s:i,s:i}",
28bab8
+                              "ids", bug_id,
28bab8
+                              "status", "CLOSED",
28bab8
+                              "resolution", "DUPLICATE",
28bab8
+                              "dupe_of", duplicate_bug,
28bab8
+
28bab8
+                /* Undocumented argument but it works with Red Hat Bugzilla version 4.2.4-7
28bab8
+                 * and version 4.4.rc1.b02
28bab8
+                 */
28bab8
+                              "nomail", nomail_notify
28bab8
+    );
28bab8
+
28bab8
+    if (result)
28bab8
+        xmlrpc_DECREF(result);
28bab8
+}
28bab8
+
28bab8
 xmlrpc_value *rhbz_search_duphash(struct abrt_xmlrpc *ax,
28bab8
                         const char *product,
28bab8
                         const char *version,
28bab8
diff --git a/src/plugins/rhbz.h b/src/plugins/rhbz.h
28bab8
index 976d333..15e7699 100644
28bab8
--- a/src/plugins/rhbz.h
28bab8
+++ b/src/plugins/rhbz.h
28bab8
@@ -74,6 +74,10 @@ void rhbz_add_comment(struct abrt_xmlrpc *ax, int bug_id, const char *comment,
28bab8
 
28bab8
 void rhbz_set_url(struct abrt_xmlrpc *ax, int bug_id, const char *url, int flags);
28bab8
 
28bab8
+void rhbz_close_as_duplicate(struct abrt_xmlrpc *ax, int bug_id,
28bab8
+                             int duplicate_bug,
28bab8
+                             int flags);
28bab8
+
28bab8
 void *rhbz_bug_read_item(const char *memb, xmlrpc_value *xml, int flags);
28bab8
 
28bab8
 void rhbz_logout(struct abrt_xmlrpc *ax);
28bab8
-- 
28bab8
1.8.3.1
28bab8