From 764c3a1e4f21c635c565cf5c20c480dbf48d1599 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 19 Jan 2010 16:48:54 +0100 Subject: unify "crash data, "crash info" and "crash report" data types. they are the same Signed-off-by: Denys Vlasenko --- lib/Plugins/Bugzilla.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'lib/Plugins/Bugzilla.cpp') diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index f963eb9..5fdaa75 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -32,8 +32,8 @@ struct ctx: public abrt_xmlrpc_conn { int32_t check_uuid_in_bugzilla(const char* component, const char* UUID); bool check_cc_and_reporter(uint32_t bug_id, const char* login); void add_plus_one_cc(uint32_t bug_id, const char* login); - uint32_t new_bug(const map_crash_report_t& pCrashReport); - void add_attachments(const char* bug_id_str, const map_crash_report_t& pCrashReport); + uint32_t new_bug(const map_crash_data_t& pCrashData); + void add_attachments(const char* bug_id_str, const map_crash_data_t& pCrashData); }; void ctx::login(const char* login, const char* passwd) @@ -278,22 +278,22 @@ int32_t ctx::check_uuid_in_bugzilla(const char* component, const char* UUID) return -1; } -uint32_t ctx::new_bug(const map_crash_report_t& pCrashReport) +uint32_t ctx::new_bug(const map_crash_data_t& pCrashData) { xmlrpc_env env; xmlrpc_env_init(&env); - std::string package = pCrashReport.find(FILENAME_PACKAGE)->second[CD_CONTENT]; - std::string component = pCrashReport.find(FILENAME_COMPONENT)->second[CD_CONTENT]; - std::string release = pCrashReport.find(FILENAME_RELEASE)->second[CD_CONTENT]; - std::string arch = pCrashReport.find(FILENAME_ARCHITECTURE)->second[CD_CONTENT]; - std::string uuid = pCrashReport.find(CD_UUID)->second[CD_CONTENT]; + std::string package = pCrashData.find(FILENAME_PACKAGE)->second[CD_CONTENT]; + std::string component = pCrashData.find(FILENAME_COMPONENT)->second[CD_CONTENT]; + std::string release = pCrashData.find(FILENAME_RELEASE)->second[CD_CONTENT]; + std::string arch = pCrashData.find(FILENAME_ARCHITECTURE)->second[CD_CONTENT]; + std::string uuid = pCrashData.find(CD_UUID)->second[CD_CONTENT]; std::string summary = "[abrt] crash in " + package; std::string status_whiteboard = "abrt_hash:" + uuid; std::string description = "abrt "VERSION" detected a crash.\n\n"; - description += make_description_bz(pCrashReport); + description += make_description_bz(pCrashData); std::string product; std::string version; @@ -346,15 +346,15 @@ uint32_t ctx::new_bug(const map_crash_report_t& pCrashReport) return bug_id; } -void ctx::add_attachments(const char* bug_id_str, const map_crash_report_t& pCrashReport) +void ctx::add_attachments(const char* bug_id_str, const map_crash_data_t& pCrashData) { xmlrpc_env env; xmlrpc_env_init(&env); xmlrpc_value* result = NULL; - map_crash_report_t::const_iterator it = pCrashReport.begin(); - for (; it != pCrashReport.end(); it++) + map_crash_data_t::const_iterator it = pCrashData.begin(); + for (; it != pCrashData.end(); it++) { const std::string &filename = it->first; const std::string &type = it->second[CD_TYPE]; @@ -404,7 +404,7 @@ CReporterBugzilla::CReporterBugzilla() : CReporterBugzilla::~CReporterBugzilla() {} -std::string CReporterBugzilla::Report(const map_crash_report_t& pCrashReport, +std::string CReporterBugzilla::Report(const map_crash_data_t& pCrashData, const map_plugin_settings_t& pSettings, const char *pArgs) { @@ -433,8 +433,8 @@ std::string CReporterBugzilla::Report(const map_crash_report_t& pCrashReport, NoSSLVerify = m_bNoSSLVerify; } - std::string component = pCrashReport.find(FILENAME_COMPONENT)->second[CD_CONTENT]; - std::string uuid = pCrashReport.find(CD_UUID)->second[CD_CONTENT]; + std::string component = pCrashData.find(FILENAME_COMPONENT)->second[CD_CONTENT]; + std::string uuid = pCrashData.find(CD_UUID)->second[CD_CONTENT]; try { ctx bz_server(BugzillaXMLRPC.c_str(), NoSSLVerify); @@ -462,8 +462,8 @@ std::string CReporterBugzilla::Report(const map_crash_report_t& pCrashReport, } update_client(_("Creating new bug...")); - bug_id = bz_server.new_bug(pCrashReport); - bz_server.add_attachments(to_string(bug_id).c_str(), pCrashReport); + bug_id = bz_server.new_bug(pCrashData); + bz_server.add_attachments(to_string(bug_id).c_str(), pCrashData); update_client(_("Logging out...")); bz_server.logout(); -- cgit From 9edadbfa15ed05a3e48158aad89e438a6f9a9e50 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 19 Jan 2010 21:02:05 +0100 Subject: use get_crash_data_item_content() more widely. -4k. Signed-off-by: Denys Vlasenko --- lib/Plugins/Bugzilla.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/Plugins/Bugzilla.cpp') diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index 5fdaa75..8a5a797 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -283,11 +283,11 @@ uint32_t ctx::new_bug(const map_crash_data_t& pCrashData) xmlrpc_env env; xmlrpc_env_init(&env); - std::string package = pCrashData.find(FILENAME_PACKAGE)->second[CD_CONTENT]; - std::string component = pCrashData.find(FILENAME_COMPONENT)->second[CD_CONTENT]; - std::string release = pCrashData.find(FILENAME_RELEASE)->second[CD_CONTENT]; - std::string arch = pCrashData.find(FILENAME_ARCHITECTURE)->second[CD_CONTENT]; - std::string uuid = pCrashData.find(CD_UUID)->second[CD_CONTENT]; + const std::string& package = get_crash_data_item_content(pCrashData, FILENAME_PACKAGE); + const std::string& component = get_crash_data_item_content(pCrashData, FILENAME_COMPONENT); + const std::string& release = get_crash_data_item_content(pCrashData, FILENAME_RELEASE); + const std::string& arch = get_crash_data_item_content(pCrashData, FILENAME_ARCHITECTURE); + const std::string& uuid = get_crash_data_item_content(pCrashData, CD_UUID); std::string summary = "[abrt] crash in " + package; std::string status_whiteboard = "abrt_hash:" + uuid; @@ -433,8 +433,8 @@ std::string CReporterBugzilla::Report(const map_crash_data_t& pCrashData, NoSSLVerify = m_bNoSSLVerify; } - std::string component = pCrashData.find(FILENAME_COMPONENT)->second[CD_CONTENT]; - std::string uuid = pCrashData.find(CD_UUID)->second[CD_CONTENT]; + const std::string& component = get_crash_data_item_content(pCrashData, FILENAME_COMPONENT); + const std::string& uuid = get_crash_data_item_content(pCrashData, CD_UUID); try { ctx bz_server(BugzillaXMLRPC.c_str(), NoSSLVerify); -- cgit From 562cb414ee83452749058c2c976019c663111e55 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 20 Jan 2010 16:42:17 +0100 Subject: split load_crash_data_from_debug_dump from DebugDumpToCrashReport We will need it elsewhere later Signed-off-by: Denys Vlasenko --- lib/Plugins/Bugzilla.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib/Plugins/Bugzilla.cpp') diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index 8a5a797..aafa019 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -442,12 +442,12 @@ std::string CReporterBugzilla::Report(const map_crash_data_t& pCrashData, update_client(_("Checking for duplicates...")); bug_id = bz_server.check_uuid_in_bugzilla(component.c_str(), uuid.c_str()); - update_client(_("Logging into bugzilla...")); if ((Login == "") && (Password == "")) { VERB3 log("Empty login and password"); throw CABRTException(EXCEP_PLUGIN, _("Empty login and password. Please check Bugzilla.conf")); } + update_client(_("Logging into bugzilla...")); bz_server.login(Login.c_str(), Password.c_str()); if (bug_id > 0) @@ -458,7 +458,9 @@ std::string CReporterBugzilla::Report(const map_crash_data_t& pCrashData, bz_server.add_plus_one_cc(bug_id, Login.c_str()); } bz_server.logout(); - return BugzillaURL + "/show_bug.cgi?id=" + to_string(bug_id); + BugzillaURL += "/show_bug.cgi?id="; + BugzillaURL += to_string(bug_id); + return BugzillaURL; } update_client(_("Creating new bug...")); @@ -475,12 +477,16 @@ std::string CReporterBugzilla::Report(const map_crash_data_t& pCrashData, if (bug_id > 0) { - return BugzillaURL + "/show_bug.cgi?id=" + to_string(bug_id); + BugzillaURL += "/show_bug.cgi?id="; + BugzillaURL += to_string(bug_id); + return BugzillaURL; } - return BugzillaURL + "/show_bug.cgi?id="; + BugzillaURL += "/show_bug.cgi?id="; + return BugzillaURL; } +//todo: make static map_plugin_settings_t CReporterBugzilla::parse_settings(const map_plugin_settings_t& pSettings) { map_plugin_settings_t plugin_settings; -- cgit From 6443695f275167adb123070daf2a6b6ecc0bb371 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 21 Jan 2010 02:56:53 +0100 Subject: abrtd: fix Report() dbus call gaping security holes We were blindly trusting the values passed to us Signed-off-by: Denys Vlasenko --- lib/Plugins/Bugzilla.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/Plugins/Bugzilla.cpp') diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index aafa019..f0e366b 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -287,7 +287,7 @@ uint32_t ctx::new_bug(const map_crash_data_t& pCrashData) const std::string& component = get_crash_data_item_content(pCrashData, FILENAME_COMPONENT); const std::string& release = get_crash_data_item_content(pCrashData, FILENAME_RELEASE); const std::string& arch = get_crash_data_item_content(pCrashData, FILENAME_ARCHITECTURE); - const std::string& uuid = get_crash_data_item_content(pCrashData, CD_UUID); + const std::string& uuid = get_crash_data_item_content(pCrashData, CD_DUPHASH); std::string summary = "[abrt] crash in " + package; std::string status_whiteboard = "abrt_hash:" + uuid; @@ -434,7 +434,7 @@ std::string CReporterBugzilla::Report(const map_crash_data_t& pCrashData, } const std::string& component = get_crash_data_item_content(pCrashData, FILENAME_COMPONENT); - const std::string& uuid = get_crash_data_item_content(pCrashData, CD_UUID); + const std::string& uuid = get_crash_data_item_content(pCrashData, CD_DUPHASH); try { ctx bz_server(BugzillaXMLRPC.c_str(), NoSSLVerify); -- cgit From 2afa768308a7f00f0f0d5c4a95f5b20e8c62ef39 Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Thu, 21 Jan 2010 17:54:57 +0100 Subject: fix double filled bug with same status_whiteboard(abrt hash) --- lib/Plugins/Bugzilla.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'lib/Plugins/Bugzilla.cpp') diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index aafa019..5dc4298 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -11,7 +11,9 @@ # include #endif -#define XML_RPC_SUFFIX "/xmlrpc.cgi" +#define XML_RPC_SUFFIX "/xmlrpc.cgi" +#define NEW_BUG -1 +#define MISSING_MEMBER -2 /* * TODO: npajkovs: better deallocation of xmlrpc value @@ -235,7 +237,7 @@ int32_t ctx::check_uuid_in_bugzilla(const char* component, const char* UUID) { xmlrpc_DECREF(result); xmlrpc_DECREF(bugs_member); - return -1; + return NEW_BUG; } xmlrpc_value* item = NULL; @@ -270,12 +272,20 @@ int32_t ctx::check_uuid_in_bugzilla(const char* component, const char* UUID) xmlrpc_DECREF(result); return bug_id; } + else + { + VERB3 log("Missing member 'bug_id'"); + } xmlrpc_DECREF(item); xmlrpc_DECREF(bugs_member); } + else + { + VERB3 log("Missing member 'bugs'"); + } xmlrpc_DECREF(result); - return -1; + return MISSING_MEMBER; } uint32_t ctx::new_bug(const map_crash_data_t& pCrashData) @@ -447,6 +457,7 @@ std::string CReporterBugzilla::Report(const map_crash_data_t& pCrashData, VERB3 log("Empty login and password"); throw CABRTException(EXCEP_PLUGIN, _("Empty login and password. Please check Bugzilla.conf")); } + update_client(_("Logging into bugzilla...")); bz_server.login(Login.c_str(), Password.c_str()); @@ -463,9 +474,12 @@ std::string CReporterBugzilla::Report(const map_crash_data_t& pCrashData, return BugzillaURL; } - update_client(_("Creating new bug...")); - bug_id = bz_server.new_bug(pCrashData); - bz_server.add_attachments(to_string(bug_id).c_str(), pCrashData); + if (bug_id == NEW_BUG) + { + update_client(_("Creating new bug...")); + bug_id = bz_server.new_bug(pCrashData); + bz_server.add_attachments(to_string(bug_id).c_str(), pCrashData); + } update_client(_("Logging out...")); bz_server.logout(); -- cgit From 8d1111b10cb9d60d867921739898b3b4aa17daba Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Thu, 21 Jan 2010 19:19:02 +0100 Subject: throw when some members are missing in xmlrpc response --- lib/Plugins/Bugzilla.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'lib/Plugins/Bugzilla.cpp') diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index 2fc2109..055e65f 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -125,6 +125,12 @@ bool ctx::check_cc_and_reporter(uint32_t bug_id, const char* login) return true; } } + else + { + VERB3 log("Missing member 'reporter'"); + xmlrpc_DECREF(result); + throw CABRTException(EXCEP_PLUGIN, _("Missing member 'bugs'")); + } xmlrpc_value* cc_member = NULL; xmlrpc_struct_find_value(&env, result, "cc", &cc_member); @@ -171,6 +177,12 @@ bool ctx::check_cc_and_reporter(uint32_t bug_id, const char* login) } xmlrpc_DECREF(cc_member); } + else + { + VERB3 log("Missing member 'bugs'"); + xmlrpc_DECREF(result); + throw CABRTException(EXCEP_PLUGIN, _("Missing member 'cc'")); + } xmlrpc_DECREF(result); return false; @@ -275,6 +287,8 @@ int32_t ctx::check_uuid_in_bugzilla(const char* component, const char* UUID) else { VERB3 log("Missing member 'bug_id'"); + xmlrpc_DECREF(result); + throw CABRTException(EXCEP_PLUGIN, _("Missing member 'bug_id'")); } xmlrpc_DECREF(item); xmlrpc_DECREF(bugs_member); @@ -282,6 +296,8 @@ int32_t ctx::check_uuid_in_bugzilla(const char* component, const char* UUID) else { VERB3 log("Missing member 'bugs'"); + xmlrpc_DECREF(result); + throw CABRTException(EXCEP_PLUGIN, _("Missing member 'bugs'")); } xmlrpc_DECREF(result); @@ -474,12 +490,9 @@ std::string CReporterBugzilla::Report(const map_crash_data_t& pCrashData, return BugzillaURL; } - if (bug_id == NEW_BUG) - { - update_client(_("Creating new bug...")); - bug_id = bz_server.new_bug(pCrashData); - bz_server.add_attachments(to_string(bug_id).c_str(), pCrashData); - } + update_client(_("Creating new bug...")); + bug_id = bz_server.new_bug(pCrashData); + bz_server.add_attachments(to_string(bug_id).c_str(), pCrashData); update_client(_("Logging out...")); bz_server.logout(); -- cgit From 4b54f9866f0dbdc859e300b0169b6ef504ee6c12 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 21 Jan 2010 21:05:15 +0100 Subject: Bugzilla: attach backtrace even if it is small Signed-off-by: Denys Vlasenko --- lib/Plugins/Bugzilla.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lib/Plugins/Bugzilla.cpp') diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index 055e65f..0197a7b 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -382,18 +382,19 @@ void ctx::add_attachments(const char* bug_id_str, const map_crash_data_t& pCrash map_crash_data_t::const_iterator it = pCrashData.begin(); for (; it != pCrashData.end(); it++) { - const std::string &filename = it->first; + const std::string &itemname = it->first; const std::string &type = it->second[CD_TYPE]; const std::string &content = it->second[CD_CONTENT]; - if (type == CD_TXT && content.length() > CD_TEXT_ATT_SIZE) - { + if (type == CD_TXT + && (content.length() > CD_TEXT_ATT_SIZE || itemname == FILENAME_BACKTRACE) + ) { char *encoded64 = encode_base64(content.c_str(), content.length()); // fails only when you write query. when it's done it never fails. xmlrpc_value* param = xmlrpc_build_value(&env, "(s{s:s,s:s,s:s,s:s})", bug_id_str, - "description", ("File: " + filename).c_str(), - "filename", filename.c_str(), + "description", ("File: " + itemname).c_str(), + "filename", itemname.c_str(), "contenttype", "text/plain", "data", encoded64 ); -- cgit