summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorZdenek Prikryl <zprikryl@redhat.com>2009-07-31 12:14:02 +0200
committerZdenek Prikryl <zprikryl@redhat.com>2009-07-31 12:14:02 +0200
commit429a25ab4642d69046ba0dbeb2c8cd2483993926 (patch)
treeada8d9a8fc0d44e56039aed7f260523617799be9 /lib
parent5d4007c22e67b3d68a2bb19ef28970408133c572 (diff)
downloadabrt-429a25ab4642d69046ba0dbeb2c8cd2483993926.tar.gz
abrt-429a25ab4642d69046ba0dbeb2c8cd2483993926.tar.xz
abrt-429a25ab4642d69046ba0dbeb2c8cd2483993926.zip
added new option do bugzilla plugin.
NoSSLVerify enables/disables certificate verification.
Diffstat (limited to 'lib')
-rw-r--r--lib/Plugins/Bugzilla.GTKBuilder12
-rw-r--r--lib/Plugins/Bugzilla.conf2
-rw-r--r--lib/Plugins/Bugzilla.cpp68
-rw-r--r--lib/Plugins/Bugzilla.h7
4 files changed, 71 insertions, 18 deletions
diff --git a/lib/Plugins/Bugzilla.GTKBuilder b/lib/Plugins/Bugzilla.GTKBuilder
index 0e8d0d38..6d3bb4c3 100644
--- a/lib/Plugins/Bugzilla.GTKBuilder
+++ b/lib/Plugins/Bugzilla.GTKBuilder
@@ -102,6 +102,18 @@
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="conf_NoSSLVerify">
+ <property name="label" translatable="yes">No SSL verify</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="position">1</property>
diff --git a/lib/Plugins/Bugzilla.conf b/lib/Plugins/Bugzilla.conf
index 24947fec..8c2bcdf0 100644
--- a/lib/Plugins/Bugzilla.conf
+++ b/lib/Plugins/Bugzilla.conf
@@ -1,5 +1,7 @@
# Bugzilla URL
BugzillaURL = https://bugzilla.redhat.com/xmlrpc.cgi
+# yes means that ssl certificates will not be checked
+NoSSLVerify = no
# your login has to exist, if you don have anyone, please create one
Login =
# your password
diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp
index be913d53..07398355 100644
--- a/lib/Plugins/Bugzilla.cpp
+++ b/lib/Plugins/Bugzilla.cpp
@@ -9,16 +9,45 @@
#include <string.h>
CReporterBugzilla::CReporterBugzilla() :
- m_sBugzillaURL("https://bugzilla.redhat.com/xmlrpc.cgi")
+ m_sBugzillaURL("https://bugzilla.redhat.com/xmlrpc.cgi"),
+ m_bNoSSLVerify(false),
+ m_pXmlrpcTransport(NULL),
+ m_pXmlrpcClient(NULL),
+ m_pCarriageParm(NULL)
+{}
+
+CReporterBugzilla::~CReporterBugzilla()
+{}
+#include <iostream>
+void CReporterBugzilla::NewXMLRPCClient()
{
- m_pXmlrpcTransport = new xmlrpc_c::clientXmlTransport_curl();
+ std::cout << "m_bNoSSLVerify: " << m_bNoSSLVerify << std::endl;
+ m_pXmlrpcTransport = new xmlrpc_c::clientXmlTransport_curl(
+ xmlrpc_c::clientXmlTransport_curl::constrOpt()
+ .no_ssl_verifyhost(m_bNoSSLVerify)
+ .no_ssl_verifypeer(m_bNoSSLVerify)
+ );
m_pXmlrpcClient = new xmlrpc_c::client_xml(m_pXmlrpcTransport);
+ m_pCarriageParm = new xmlrpc_c::carriageParm_curl0(m_sBugzillaURL);
}
-CReporterBugzilla::~CReporterBugzilla()
+void CReporterBugzilla::DeleteXMLRPCClient()
{
- delete m_pXmlrpcTransport;
- delete m_pXmlrpcClient;
+ if (m_pCarriageParm != NULL)
+ {
+ delete m_pCarriageParm;
+ m_pCarriageParm = NULL;
+ }
+ if (m_pXmlrpcClient != NULL)
+ {
+ delete m_pXmlrpcClient;
+ m_pXmlrpcClient = NULL;
+ }
+ if (m_pXmlrpcTransport != NULL)
+ {
+ delete m_pXmlrpcTransport;
+ m_pXmlrpcTransport = NULL;
+ }
}
PRInt32 CReporterBugzilla::Base64Encode_cb(void *arg, const char *obuf, PRInt32 size)
@@ -166,7 +195,7 @@ void CReporterBugzilla::GetProductAndVersion(const std::string& pRelease,
}
}
-void CReporterBugzilla::NewBug(const map_crash_report_t& pCrashReport)
+std::string CReporterBugzilla::NewBug(const map_crash_report_t& pCrashReport)
{
xmlrpc_c::paramList paramList;
map_xmlrpc_params_t bugParams;
@@ -177,10 +206,10 @@ void CReporterBugzilla::NewBug(const map_crash_report_t& pCrashReport)
std::string release = pCrashReport.find(FILENAME_RELEASE)->second[CD_CONTENT];;
std::string product;
std::string version;
+ std::stringstream bugId;
CreateNewBugDescription(pCrashReport, description);
GetProductAndVersion(release, product, version);
-
bugParams["product"] = xmlrpc_c::value_string(product);
bugParams["component"] = xmlrpc_c::value_string(component);
bugParams["version"] = xmlrpc_c::value_string(version);
@@ -196,16 +225,15 @@ void CReporterBugzilla::NewBug(const map_crash_report_t& pCrashReport)
{
rpc->call(m_pXmlrpcClient, m_pCarriageParm);
ret = xmlrpc_c::value_struct(rpc->getResult());
- std::stringstream ss;
- ss << xmlrpc_c::value_int(ret["id"]);
- comm_layer_inner_debug("New bug id: " + ss.str());
- AddAttachments(ss.str(), pCrashReport);
+ bugId << xmlrpc_c::value_int(ret["id"]);
+ comm_layer_inner_debug("New bug id: " + bugId.str());
+ comm_layer_inner_status("New bug id: " + bugId.str());
}
catch (std::exception& e)
{
throw CABRTException(EXCEP_PLUGIN, std::string("CReporterBugzilla::NewBug(): ") + e.what());
}
-
+ return bugId.str();
}
void CReporterBugzilla::AddAttachments(const std::string& pBugId, const map_crash_report_t& pCrashReport)
@@ -238,6 +266,7 @@ void CReporterBugzilla::AddAttachments(const std::string& pBugId, const map_cras
attchmentInBase64Printable += m_sAttchmentInBase64[ii];
}
}
+
paramList.add(xmlrpc_c::value_string(pBugId));
attachmentParams["description"] = xmlrpc_c::value_string("File: " + it->first);
attachmentParams["filename"] = xmlrpc_c::value_string(it->first);
@@ -266,8 +295,10 @@ void CReporterBugzilla::Report(const map_crash_report_t& pCrashReport, const std
std::string package = pCrashReport.find(FILENAME_PACKAGE)->second[CD_CONTENT];
std::string component = package.substr(0, package.rfind("-", package.rfind("-")-1));
std::string uuid = pCrashReport.find(CD_UUID)->second[CD_CONTENT];
+ std::string bugId;
comm_layer_inner_status("Logging into bugzilla...");
- m_pCarriageParm = new xmlrpc_c::carriageParm_curl0(m_sBugzillaURL);
+
+ NewXMLRPCClient();
try
{
Login();
@@ -275,17 +306,18 @@ void CReporterBugzilla::Report(const map_crash_report_t& pCrashReport, const std
if (!CheckUUIDInBugzilla(component, uuid))
{
comm_layer_inner_status("Creating new bug...");
- NewBug(pCrashReport);
+ bugId = NewBug(pCrashReport);
+ AddAttachments(bugId, pCrashReport);
}
comm_layer_inner_status("Logging out...");
Logout();
}
catch (CABRTException& e)
{
- delete m_pCarriageParm;
+ DeleteXMLRPCClient();
throw CABRTException(EXCEP_PLUGIN, std::string("CReporterBugzilla::Report(): ") + e.what());
}
- delete m_pCarriageParm;
+ DeleteXMLRPCClient();
}
void CReporterBugzilla::LoadSettings(const std::string& pPath)
@@ -305,4 +337,8 @@ void CReporterBugzilla::LoadSettings(const std::string& pPath)
{
m_sPassword = settings["Password"];
}
+ if (settings.find("NoSSLVerify")!= settings.end())
+ {
+ m_bNoSSLVerify = settings["NoSSLVerify"] == "yes";
+ }
}
diff --git a/lib/Plugins/Bugzilla.h b/lib/Plugins/Bugzilla.h
index cc01153d..fe23cdca 100644
--- a/lib/Plugins/Bugzilla.h
+++ b/lib/Plugins/Bugzilla.h
@@ -12,11 +12,13 @@ class CReporterBugzilla : public CReporter
private:
typedef std::map<std::string, xmlrpc_c::value> map_xmlrpc_params_t;
+ void NewXMLRPCClient();
+ void DeleteXMLRPCClient();
static PRInt32 Base64Encode_cb(void *arg, const char *obuf, PRInt32 size);
void Login();
void Logout();
bool CheckUUIDInBugzilla(const std::string& pComponent, const std::string& pUUID);
- void NewBug(const map_crash_report_t& pCrashReport);
+ std::string NewBug(const map_crash_report_t& pCrashReport);
void AddAttachments(const std::string& pBugId, const map_crash_report_t& pCrashReport);
void CreateNewBugDescription(const map_crash_report_t& pCrashReport,
std::string& pDescription);
@@ -31,6 +33,7 @@ class CReporterBugzilla : public CReporter
std::string m_sLogin;
std::string m_sPassword;
std::string m_sAttchmentInBase64;
+ bool m_bNoSSLVerify;
public:
CReporterBugzilla();
@@ -43,7 +46,7 @@ class CReporterBugzilla : public CReporter
PLUGIN_INFO(REPORTER,
CReporterBugzilla,
"Bugzilla",
- "0.0.1",
+ "0.0.2",
"Check if a bug isn't already reported in a bugzilla "
"and if not, report it.",
"zprikryl@redhat.com",