mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-03-20 18:27:16 +01:00
see #2161 import wizard finished
This commit is contained in:
parent
0ed86de82a
commit
2e65d946da
@ -1,5 +1,9 @@
|
||||
2011-03-04 vadim <vadim@netcitadel.com>
|
||||
|
||||
* IC_NetworkZonesPage.cpp (setNetworkZones): see #2161 policy
|
||||
import wizard shows the page where user can set up network zones
|
||||
of interfaces if firewall platform was determined to be PIX.
|
||||
|
||||
* IC_PlatformWarningPage.cpp (initializePage): see #2161 "import
|
||||
workflow and automatic detection of firewall platform from the
|
||||
config file". When user imports existing firewall configuration,
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>14</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="WizardPage0">
|
||||
<layout class="QGridLayout">
|
||||
@ -2052,7 +2052,7 @@ Please enter the domain name below:</string>
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>:/Images/network_zone_dialog.png</pixmap>
|
||||
<pixmap resource="MainRes.qrc">:/Images/network_zone_dialog.png</pixmap>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
|
||||
@ -49,31 +49,26 @@ void IC_FirewallNamePage::initializePage()
|
||||
dynamic_cast<ImportFirewallConfigurationWizard*>(wizard())->
|
||||
getPlatform();
|
||||
|
||||
QString fileName = field("fileName").toString();
|
||||
QStringList *buf =
|
||||
dynamic_cast<ImportFirewallConfigurationWizard*>(wizard())->
|
||||
getBufferPtr();
|
||||
|
||||
qDebug() << "platform=" << platform;
|
||||
|
||||
if (platform == "pix" || platform == "ios_acl")
|
||||
{
|
||||
QFile cf(fileName);
|
||||
if (cf.open(QIODevice::ReadOnly ))
|
||||
QRegExp cisco_re("^hostname\\s+(\\S+)");
|
||||
|
||||
foreach(QString line, *buf)
|
||||
{
|
||||
QRegExp cisco_re("^hostname\\s+(\\S+)");
|
||||
|
||||
QTextStream stream(&cf);
|
||||
while (true)
|
||||
if (cisco_re.indexIn(line) > -1)
|
||||
{
|
||||
QString line = stream.readLine().trimmed();
|
||||
if (line.isNull()) break;
|
||||
|
||||
if (cisco_re.indexIn(line) > -1)
|
||||
{
|
||||
m_dialog->firewallName->setText(cisco_re.cap(1));
|
||||
break;
|
||||
}
|
||||
m_dialog->firewallName->setText(cisco_re.cap(1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
setCommitPage(true);
|
||||
emit completeChanged();
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,150 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2011 NetCitadel, LLC
|
||||
|
||||
Author: Vadim Kurland vadim@fwbuilder.org
|
||||
|
||||
This program is free software which we release under the GNU General Public
|
||||
License. You may redistribute and/or modify this program under the terms
|
||||
of that license as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
To get a copy of the GNU General Public License, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
#include "events.h"
|
||||
#include "FWBSettings.h"
|
||||
#include "FWWindow.h"
|
||||
#include "ProjectPanel.h"
|
||||
#include "networkZoneManager.h"
|
||||
|
||||
#include "IC_NetworkZonesPage.h"
|
||||
#include "ImportFirewallConfigurationWizard.h"
|
||||
|
||||
#include "fwbuilder/Interface.h"
|
||||
#include "fwbuilder/Firewall.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QList>
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
|
||||
IC_NetworkZonesPage::IC_NetworkZonesPage(QWidget *parent) :
|
||||
QWizardPage(parent),
|
||||
m_dialog(new Ui::IC_NetworkZonesPage_q)
|
||||
{
|
||||
m_dialog->setupUi(this);
|
||||
}
|
||||
|
||||
IC_NetworkZonesPage::~IC_NetworkZonesPage()
|
||||
{
|
||||
delete m_dialog;
|
||||
}
|
||||
|
||||
void IC_NetworkZonesPage::initializePage()
|
||||
{
|
||||
Firewall *fw =
|
||||
dynamic_cast<ImportFirewallConfigurationWizard*>(wizard())->getFirewall();
|
||||
|
||||
m_dialog->iface_nz_list->clear();
|
||||
|
||||
QStringList labels;
|
||||
labels << QObject::tr("Name") << QObject::tr("Label")
|
||||
<< QObject::tr("Address") << QObject::tr("Network Zone");
|
||||
m_dialog->iface_nz_list->setHorizontalHeaderLabels(labels);
|
||||
|
||||
NetworkZoneManager netzone_manager;
|
||||
netzone_manager.load(mw->activeProject()->db());
|
||||
|
||||
list<FWObject*> all_interfaces = fw->getByTypeDeep(Interface::TYPENAME);
|
||||
list<FWObject*>::iterator it;
|
||||
int row = 0;
|
||||
for (it=all_interfaces.begin(); it!=all_interfaces.end(); ++it)
|
||||
{
|
||||
Interface *iface = Interface::cast(*it);
|
||||
|
||||
m_dialog->iface_nz_list->insertRow(row);
|
||||
|
||||
QTableWidgetItem* itm;
|
||||
|
||||
itm = new QTableWidgetItem(iface->getName().c_str());
|
||||
itm->setFlags(itm->flags() & ~Qt::ItemIsEditable);
|
||||
m_dialog->iface_nz_list->setItem(row, 0, itm);
|
||||
|
||||
itm = new QTableWidgetItem(iface->getLabel().c_str());
|
||||
itm->setFlags(itm->flags() & ~Qt::ItemIsEditable);
|
||||
m_dialog->iface_nz_list->setItem(row, 1, itm);
|
||||
|
||||
QString addr_str;
|
||||
const InetAddr* addr = iface->getAddressPtr();
|
||||
if (addr) addr_str = addr->toString().c_str();
|
||||
|
||||
itm = new QTableWidgetItem(addr_str);
|
||||
itm->setFlags(itm->flags() & ~Qt::ItemIsEditable);
|
||||
m_dialog->iface_nz_list->setItem(row, 2, itm);
|
||||
|
||||
QComboBox *widget = new QComboBox();
|
||||
netzone_manager.packComboBox(widget, -1);
|
||||
m_dialog->iface_nz_list->setCellWidget(row, 3, widget);
|
||||
|
||||
row++;
|
||||
}
|
||||
|
||||
m_dialog->iface_nz_list->resizeColumnToContents(3);
|
||||
}
|
||||
|
||||
void IC_NetworkZonesPage::setNetworkZones()
|
||||
{
|
||||
Firewall *fw =
|
||||
dynamic_cast<ImportFirewallConfigurationWizard*>(wizard())->getFirewall();
|
||||
|
||||
// read and configure network zones
|
||||
list<FWObject*> all_interfaces = fw->getByTypeDeep(Interface::TYPENAME);
|
||||
list<FWObject*>::iterator it;
|
||||
for (it=all_interfaces.begin(); it!=all_interfaces.end(); ++it)
|
||||
{
|
||||
Interface *iface = Interface::cast(*it);
|
||||
|
||||
string network_zone_str_id = "";
|
||||
|
||||
QList<QTableWidgetItem*> ltwi =
|
||||
m_dialog->iface_nz_list->findItems( iface->getName().c_str(),
|
||||
Qt::MatchExactly );
|
||||
if ( ! ltwi.empty())
|
||||
{
|
||||
QTableWidgetItem *itm2 = ltwi[0];
|
||||
assert(itm2!=NULL);
|
||||
int row = itm2->row();
|
||||
QComboBox *cb = dynamic_cast<QComboBox*>(
|
||||
m_dialog->iface_nz_list->cellWidget(row, 3));
|
||||
assert(cb!=NULL);
|
||||
int network_zone_int_id =
|
||||
cb->itemData(cb->currentIndex(), Qt::UserRole).toInt();
|
||||
if (network_zone_int_id != 0)
|
||||
network_zone_str_id = FWObjectDatabase::getStringId(
|
||||
network_zone_int_id);
|
||||
else
|
||||
network_zone_str_id = "";
|
||||
}
|
||||
|
||||
// only set network zone if it is supported and is not
|
||||
// empty. See #2014
|
||||
if (!network_zone_str_id.empty())
|
||||
iface->setStr("network_zone", network_zone_str_id);
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2011 NetCitadel, LLC
|
||||
|
||||
Author: Vadim Kurland vadim@fwbuilder.org
|
||||
|
||||
This program is free software which we release under the GNU General Public
|
||||
License. You may redistribute and/or modify this program under the terms
|
||||
of that license as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
To get a copy of the GNU General Public License, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef NETWORKZONESPAGE_H
|
||||
#define NETWORKZONESPAGE_H
|
||||
|
||||
#include "ui_ic_networkzonespage_q.h"
|
||||
#include <QtGui/QWizardPage>
|
||||
|
||||
namespace Ui {
|
||||
class IC_NetworkZonesPage_q;
|
||||
}
|
||||
|
||||
class IC_NetworkZonesPage : public QWizardPage
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
Ui::IC_NetworkZonesPage_q *m_dialog;
|
||||
|
||||
public:
|
||||
explicit IC_NetworkZonesPage(QWidget *parent = 0);
|
||||
virtual ~IC_NetworkZonesPage();
|
||||
|
||||
virtual void initializePage();
|
||||
|
||||
void setNetworkZones();
|
||||
};
|
||||
|
||||
#endif // NETWORKZONESPAGE_H
|
||||
@ -86,19 +86,22 @@ void IC_PlatformWarningPage::initializePage()
|
||||
m_dialog->configFileBrowser->clear();
|
||||
m_dialog->platform->setText(tr("Unknown"));
|
||||
|
||||
QStringList buf;
|
||||
QStringList *buf =
|
||||
dynamic_cast<ImportFirewallConfigurationWizard*>(wizard())->
|
||||
getBufferPtr();
|
||||
|
||||
QTextStream stream(&cf);
|
||||
while (true)
|
||||
{
|
||||
QString line = stream.readLine().trimmed();
|
||||
if (line.isNull()) break;
|
||||
m_dialog->configFileBrowser->append(line);
|
||||
buf << line;
|
||||
*buf << line;
|
||||
}
|
||||
|
||||
bool iptables_c = false;
|
||||
|
||||
foreach (QString line, buf)
|
||||
foreach (QString line, *buf)
|
||||
{
|
||||
foreach (QRegExp re, pix_re)
|
||||
{
|
||||
@ -113,7 +116,7 @@ void IC_PlatformWarningPage::initializePage()
|
||||
{
|
||||
if (re.indexIn(line) > -1)
|
||||
{
|
||||
detectedPlatform = "ios_acl";
|
||||
detectedPlatform = "iosacl";
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -174,7 +177,7 @@ void IC_PlatformWarningPage::initializePage()
|
||||
platformOk = true;
|
||||
}
|
||||
|
||||
if (detectedPlatform == "ios_acl")
|
||||
if (detectedPlatform == "iosacl")
|
||||
{
|
||||
m_dialog->platform->setText(tr("Cisco Router IOS"));
|
||||
m_dialog->platformSpecificWarning->setText(
|
||||
|
||||
@ -23,19 +23,182 @@
|
||||
|
||||
|
||||
#include "global.h"
|
||||
#include "events.h"
|
||||
#include "FWBSettings.h"
|
||||
#include "FWWindow.h"
|
||||
#include "ProjectPanel.h"
|
||||
|
||||
#include "IC_ProgressPage.h"
|
||||
#include "ImporterThread.h"
|
||||
#include "ImportFirewallConfigurationWizard.h"
|
||||
|
||||
#include "fwbuilder/Policy.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QFileDialog>
|
||||
#include <QTextStream>
|
||||
#include <QtDebug>
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
bool fwbdebug_ic = true;
|
||||
|
||||
|
||||
IC_ProgressPage::IC_ProgressPage(QWidget *parent) : QWizardPage(parent)
|
||||
{
|
||||
m_dialog = new Ui::IC_ProgressPage_q;
|
||||
m_dialog->setupUi(this);
|
||||
importer = NULL;
|
||||
|
||||
QTextCursor cursor(m_dialog->importLog->textCursor());
|
||||
normal_format = cursor.charFormat();
|
||||
|
||||
error_format = normal_format;
|
||||
error_format.setForeground(QBrush(Qt::red));
|
||||
error_format.setAnchorHref("http://somewhere.com");
|
||||
error_format.setAnchor(true);
|
||||
// weight must be between 0 and 99. Qt 4.4.1 does not seem to mind if
|
||||
// it is >99 (just caps it) but older versions assert
|
||||
error_format.setProperty(QTextFormat::FontWeight, 99);
|
||||
|
||||
warning_format = normal_format;
|
||||
warning_format.setForeground(QBrush(Qt::blue));
|
||||
warning_format.setProperty(QTextFormat::FontWeight, 99);
|
||||
warning_format.setAnchor(true);
|
||||
warning_format.setAnchorHref("http://somewhere.com");
|
||||
}
|
||||
|
||||
int IC_ProgressPage::nextId () const
|
||||
{
|
||||
QString platform =
|
||||
dynamic_cast<ImportFirewallConfigurationWizard*>(wizard())->
|
||||
getPlatform();
|
||||
|
||||
if (platform == "pix")
|
||||
return ImportFirewallConfigurationWizard::Page_NetworkZones;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool IC_ProgressPage::validatePage()
|
||||
{
|
||||
if (fwbdebug_ic)
|
||||
qDebug() << "IC_ProgressPage::validatePage()"
|
||||
<< "importer=" << importer
|
||||
<< "isRunning=" << ((importer) ? importer->isRunning() : 0);
|
||||
|
||||
if (importer != NULL && importer->isRunning()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void IC_ProgressPage::importerDestroyed(QObject *obj)
|
||||
{
|
||||
if (fwbdebug_ic) qDebug() << "ND_ProgressPage::importerDestroyed() obj=" << obj;
|
||||
if (obj == importer) importer = NULL;
|
||||
}
|
||||
|
||||
void IC_ProgressPage::initializePage()
|
||||
{
|
||||
if (importer != NULL && importer->isRunning())
|
||||
{
|
||||
if (fwbdebug_ic)
|
||||
qDebug() << "ND_ProgressPage::initializePage()"
|
||||
<< "importer is still runnig; stopping";
|
||||
importer->stop();
|
||||
importer->wait();
|
||||
delete importer;
|
||||
}
|
||||
|
||||
m_dialog->importLog->clear();
|
||||
|
||||
QString platform =
|
||||
dynamic_cast<ImportFirewallConfigurationWizard*>(wizard())->
|
||||
getPlatform();
|
||||
QString firewallName = field("firewallName").toString();
|
||||
QStringList *buffer =
|
||||
dynamic_cast<ImportFirewallConfigurationWizard*>(wizard())->
|
||||
getBufferPtr();
|
||||
|
||||
importer = new ImporterThread(this,
|
||||
mw->getCurrentLib(),
|
||||
*buffer, platform, firewallName);
|
||||
connect(importer, SIGNAL(destroyed(QObject*)),
|
||||
this, SLOT(importerDestroyed(QObject*)));
|
||||
connect(importer, SIGNAL(finished()),
|
||||
this, SLOT(importerFinished()));
|
||||
|
||||
importer->start();
|
||||
}
|
||||
|
||||
void IC_ProgressPage::cleanupPage()
|
||||
{
|
||||
if (fwbdebug_ic) qDebug() << "IC_ProgressPage::cleanupPage()";
|
||||
disconnect(this, SLOT(logLine(QString)));
|
||||
disconnect(this, SLOT(importerFinished()));
|
||||
if (importer != NULL && importer->isRunning()) importer->wait();
|
||||
}
|
||||
|
||||
void IC_ProgressPage::importerFinished()
|
||||
{
|
||||
if (fwbdebug_ic) qDebug() << "IC_ProgressPage::importerFinished()";
|
||||
|
||||
Firewall *fw = importer->getFirewallObject();
|
||||
qApp->processEvents(); // to flush the log
|
||||
|
||||
dynamic_cast<ImportFirewallConfigurationWizard*>(wizard())->setFirewall(fw);
|
||||
|
||||
if (fw) // fw can be NULL if import was uncussessful
|
||||
{
|
||||
ProjectPanel *pp = mw->activeProject();
|
||||
QString filename = pp->getFileName();
|
||||
|
||||
QCoreApplication::postEvent(mw, new reloadObjectTreeEvent(filename));
|
||||
if (mw->isEditorVisible())
|
||||
QCoreApplication::postEvent(
|
||||
mw, new openObjectInEditorEvent(filename, fw->getId()));
|
||||
QCoreApplication::postEvent(
|
||||
mw, new showObjectInTreeEvent(filename, fw->getId()));
|
||||
|
||||
// Open first created Policy ruleset object
|
||||
FWObject *first_policy = fw->getFirstByType(Policy::TYPENAME);
|
||||
if (first_policy)
|
||||
QCoreApplication::postEvent(
|
||||
mw, new openRulesetEvent(filename, first_policy->getId()));
|
||||
}
|
||||
}
|
||||
|
||||
void IC_ProgressPage::logLine(const QString &buf)
|
||||
{
|
||||
if (buf.isEmpty()) return;
|
||||
|
||||
foreach(QString line, buf.trimmed().split("\n"))
|
||||
{
|
||||
QTextCharFormat format = normal_format;
|
||||
|
||||
if (line.contains("Parser error"))
|
||||
format = error_format;
|
||||
|
||||
if (line.contains("Parser warning"))
|
||||
format = warning_format;
|
||||
|
||||
if (line.contains("SNMP error, status 2 Timeout"))
|
||||
format = warning_format;
|
||||
|
||||
QString txt = line;
|
||||
while (!txt.isEmpty() && (txt.endsWith("\n") || txt.endsWith("\r")))
|
||||
txt.chop(1);
|
||||
|
||||
if (format == error_format || format == warning_format)
|
||||
format.setAnchorHref(txt);
|
||||
|
||||
QTextCursor cursor = m_dialog->importLog->textCursor();
|
||||
cursor.insertBlock();
|
||||
cursor.insertText(txt, format);
|
||||
}
|
||||
|
||||
m_dialog->importLog->ensureCursorVisible();
|
||||
|
||||
}
|
||||
|
||||
@ -63,12 +226,12 @@ void IC_ProgressPage::saveLog()
|
||||
{
|
||||
if (fwbdebug)
|
||||
{
|
||||
qDebug("Saving import log to file: %d chars",
|
||||
m_dialog->discoveryLog->toPlainText().length());
|
||||
qDebug("Saving crawler log to file: %d chars",
|
||||
m_dialog->importLog->toPlainText().length());
|
||||
qDebug("--------------------------------");
|
||||
}
|
||||
QTextStream strm(&f);
|
||||
QString txt = m_dialog->discoveryLog->toPlainText();
|
||||
QString txt = m_dialog->importLog->toPlainText();
|
||||
strm << txt << endl;
|
||||
if (fwbdebug)
|
||||
{
|
||||
|
||||
@ -26,18 +26,38 @@
|
||||
|
||||
#include "ui_ic_progresspage_q.h"
|
||||
|
||||
#include <QTextCharFormat>
|
||||
|
||||
class ImporterThread;
|
||||
|
||||
|
||||
class IC_ProgressPage : public QWizardPage
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
Ui::IC_ProgressPage_q *m_dialog;
|
||||
QTextCharFormat normal_format;
|
||||
QTextCharFormat error_format;
|
||||
QTextCharFormat warning_format;
|
||||
ImporterThread *importer;
|
||||
|
||||
public:
|
||||
IC_ProgressPage(QWidget *parent);
|
||||
virtual ~IC_ProgressPage() {}
|
||||
|
||||
virtual void initializePage();
|
||||
virtual void cleanupPage();
|
||||
virtual bool validatePage();
|
||||
|
||||
virtual int nextId () const;
|
||||
|
||||
|
||||
public slots:
|
||||
void saveLog();
|
||||
void logLine(const QString &line);
|
||||
void importerDestroyed(QObject*);
|
||||
void importerFinished();
|
||||
|
||||
};
|
||||
|
||||
#endif // IC_PROGRESSPAGE_H
|
||||
|
||||
@ -29,8 +29,10 @@
|
||||
#include "IC_FirewallNamePage.h"
|
||||
#include "IC_PlatformWarningPage.h"
|
||||
#include "IC_ProgressPage.h"
|
||||
#include "IC_NetworkZonesPage.h"
|
||||
|
||||
#include "fwbuilder/FWObject.h"
|
||||
#include "fwbuilder/Firewall.h"
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
@ -41,17 +43,30 @@ using namespace libfwbuilder;
|
||||
ImportFirewallConfigurationWizard::ImportFirewallConfigurationWizard(QWidget *parent) :
|
||||
QWizard(parent)
|
||||
{
|
||||
fw = NULL;
|
||||
|
||||
QPixmap pm;
|
||||
pm.load(":/Images/fwbuilder3-72x72.png");
|
||||
setPixmap(QWizard::LogoPixmap, pm);
|
||||
|
||||
setWindowTitle(tr("Import Firewall Configuration"));
|
||||
|
||||
addPage(new IC_FileNamePage(this));
|
||||
addPage(new IC_PlatformWarningPage(this));
|
||||
addPage(new IC_FirewallNamePage(this));
|
||||
addPage(new IC_ProgressPage(this));
|
||||
setPage(Page_FileName, new IC_FileNamePage(this));
|
||||
setPage(Page_Platform, new IC_PlatformWarningPage(this));
|
||||
setPage(Page_FirewallName, new IC_FirewallNamePage(this));
|
||||
setPage(Page_Progess, new IC_ProgressPage(this));
|
||||
setPage(Page_NetworkZones, new IC_NetworkZonesPage(this));
|
||||
|
||||
resize(700, 500);
|
||||
resize(600, 600);
|
||||
}
|
||||
|
||||
void ImportFirewallConfigurationWizard::accept()
|
||||
{
|
||||
qDebug() << "ImportFirewallConfigurationWizard::accept()";
|
||||
|
||||
if (platform == "pix" || platform == "fwsm")
|
||||
dynamic_cast<IC_NetworkZonesPage*>(
|
||||
page(Page_NetworkZones))->setNetworkZones();
|
||||
|
||||
QWizard::accept();
|
||||
}
|
||||
|
||||
@ -25,22 +25,38 @@
|
||||
#define __IMPORTFIREWALLCONFIGURATIONWIZARD_H_
|
||||
|
||||
#include <QWizard>
|
||||
#include <QStringList>
|
||||
|
||||
namespace libfwbuilder
|
||||
{
|
||||
class Firewall;
|
||||
};
|
||||
|
||||
|
||||
class ImportFirewallConfigurationWizard : public QWizard
|
||||
{
|
||||
Q_OBJECT;
|
||||
QString platform;
|
||||
QStringList buffer;
|
||||
libfwbuilder::Firewall *fw;
|
||||
|
||||
public:
|
||||
enum { Page_FileName, Page_Platform, Page_FirewallName,
|
||||
Page_Progess, Page_NetworkZones };
|
||||
|
||||
ImportFirewallConfigurationWizard(QWidget *parent);
|
||||
virtual ~ImportFirewallConfigurationWizard() {}
|
||||
|
||||
QString getPlatform() { return platform; }
|
||||
void setPlatform(const QString &s) { platform = s; }
|
||||
|
||||
QStringList* getBufferPtr() { return &buffer; }
|
||||
|
||||
libfwbuilder::Firewall* getFirewall() { return fw; }
|
||||
void setFirewall(libfwbuilder::Firewall* _fw) { fw = _fw; }
|
||||
|
||||
public slots:
|
||||
|
||||
virtual void accept();
|
||||
};
|
||||
|
||||
|
||||
|
||||
109
src/libgui/importFirewallConfigurationWizard/ImporterThread.cpp
Normal file
109
src/libgui/importFirewallConfigurationWizard/ImporterThread.cpp
Normal file
@ -0,0 +1,109 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2011 NetCitadel, LLC
|
||||
|
||||
Author: Vadim Kurland vadim@fwbuilder.org
|
||||
|
||||
This program is free software which we release under the GNU General Public
|
||||
License. You may redistribute and/or modify this program under the terms
|
||||
of that license as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
To get a copy of the GNU General Public License, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "ImporterThread.h"
|
||||
|
||||
#include "utils.h"
|
||||
#include "QThreadLogger.h"
|
||||
#include "IOSImporter.h"
|
||||
#include "IPTImporter.h"
|
||||
#include "PIXImporter.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QtDebug>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
|
||||
ImporterThread::ImporterThread(QWidget *ui,
|
||||
FWObject *lib,
|
||||
const QStringList &buffer,
|
||||
const QString &platform,
|
||||
const QString &firewallName)
|
||||
{
|
||||
this->lib = lib;
|
||||
this->ui = ui;
|
||||
this->buffer = buffer;
|
||||
this->platform = platform;
|
||||
this->firewallName = firewallName;
|
||||
importer = NULL;
|
||||
}
|
||||
|
||||
ImporterThread::~ImporterThread()
|
||||
{
|
||||
if (fwbdebug) qDebug() << "ImporterThread::~ImporterThread()";
|
||||
}
|
||||
|
||||
void ImporterThread::run()
|
||||
{
|
||||
QThreadLogger *logger = new QThreadLogger();
|
||||
connect(logger, SIGNAL(lineReady(QString)),
|
||||
this->ui, SLOT(logLine(QString)),
|
||||
Qt::QueuedConnection);
|
||||
|
||||
std::istringstream instream(buffer.join("\n").toStdString());
|
||||
|
||||
importer = NULL;
|
||||
|
||||
if (platform == "iosacl") importer = new IOSImporter(
|
||||
lib, instream, logger, firewallName.toUtf8().constData());
|
||||
|
||||
if (platform == "iptables") importer = new IPTImporter(
|
||||
lib, instream, logger, firewallName.toUtf8().constData());
|
||||
|
||||
if (platform == "pix") importer = new PIXImporter(
|
||||
lib, instream, logger, firewallName.toUtf8().constData());
|
||||
|
||||
if (importer)
|
||||
{
|
||||
try
|
||||
{
|
||||
importer->run();
|
||||
} catch(ImporterException &e)
|
||||
{
|
||||
*logger << e.toString() << "\n";
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
*logger << "Can not import configuration for platform "
|
||||
<< platform.toStdString() << "\n";
|
||||
}
|
||||
|
||||
fw = importer->finalize();
|
||||
|
||||
emit finished();
|
||||
|
||||
deleteLater(); // mark this object for destruction on the next run of event loop
|
||||
}
|
||||
|
||||
void ImporterThread::stop()
|
||||
{
|
||||
}
|
||||
|
||||
@ -0,0 +1,73 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2011 NetCitadel, LLC
|
||||
|
||||
Author: Vadim Kurland vadim@fwbuilder.org
|
||||
|
||||
This program is free software which we release under the GNU General Public
|
||||
License. You may redistribute and/or modify this program under the terms
|
||||
of that license as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
To get a copy of the GNU General Public License, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _IMPORTERTHREAD_H_
|
||||
#define _IMPORTERTHREAD_H_
|
||||
|
||||
#include "Importer.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QThread>
|
||||
#include <QStringList>
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
|
||||
namespace libfwbuilder
|
||||
{
|
||||
class FWObject;
|
||||
class Firewall;
|
||||
};
|
||||
|
||||
class ImporterThread : public QThread
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
libfwbuilder::FWObject *lib;
|
||||
Importer *importer;
|
||||
QStringList buffer;
|
||||
QString firewallName;
|
||||
QString platform;
|
||||
QWidget *ui;
|
||||
libfwbuilder::Firewall *fw;
|
||||
|
||||
public:
|
||||
ImporterThread(QWidget *ui,
|
||||
libfwbuilder::FWObject *lib,
|
||||
const QStringList &buffer,
|
||||
const QString &platform,
|
||||
const QString &firewallName);
|
||||
virtual ~ImporterThread();
|
||||
|
||||
void run();
|
||||
void stop();
|
||||
|
||||
libfwbuilder::Firewall* getFirewallObject() { return fw; }
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>IC_NetworkZonesPage_q</class>
|
||||
<widget class="QWizardPage" name="IC_NetworkZonesPage_q">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>580</width>
|
||||
<height>630</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>WizardPage</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label666_2">
|
||||
<property name="text">
|
||||
<string>Firewall Builder uses Network Zones to determine network topology. Each firewall interface must have a Network Zone configured. The Network Zone of an interface represents the set of IP networks that would be the source IP address of traffic arriving inbound on an interface.</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>If you do not set the Network Zone now you can update the Network Zone configuration after the firewall has been created by double-clicking on the network interface of the firewall object and then selecting the desired object from the Network Zone dropdown list.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../MainRes.qrc">:/Images/network_zone_dialog.png</pixmap>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QFrame" name="frame160_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>150</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_10">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QTableWidget" name="iface_nz_list">
|
||||
<property name="showGrid">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Label</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Address</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Security Level</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../MainRes.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@ -24,7 +24,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="discoveryLog">
|
||||
<widget class="QTextEdit" name="importLog">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
||||
@ -221,7 +221,9 @@ HEADERS += ../../config.h \
|
||||
importFirewallConfigurationWizard/IC_FirewallNamePage.h \
|
||||
importFirewallConfigurationWizard/IC_PlatformWarningPage.h \
|
||||
importFirewallConfigurationWizard/IC_ProgressPage.h \
|
||||
importFirewallConfigurationWizard/IC_NetworkZonesPage.h \
|
||||
importFirewallConfigurationWizard/ImportFirewallConfigurationWizard.h \
|
||||
importFirewallConfigurationWizard/ImporterThread.h \
|
||||
|
||||
|
||||
|
||||
@ -439,7 +441,9 @@ SOURCES += ProjectPanel.cpp \
|
||||
importFirewallConfigurationWizard/IC_FirewallNamePage.cpp \
|
||||
importFirewallConfigurationWizard/IC_PlatformWarningPage.cpp \
|
||||
importFirewallConfigurationWizard/IC_ProgressPage.cpp \
|
||||
importFirewallConfigurationWizard/IC_NetworkZonesPage.cpp \
|
||||
importFirewallConfigurationWizard/ImportFirewallConfigurationWizard.cpp \
|
||||
importFirewallConfigurationWizard/ImporterThread.cpp
|
||||
|
||||
|
||||
FORMS = FWBMainWindow_q.ui \
|
||||
@ -568,6 +572,7 @@ FORMS = FWBMainWindow_q.ui \
|
||||
importFirewallConfigurationWizard/ic_firewallnamepage_q.ui \
|
||||
importFirewallConfigurationWizard/ic_platformwarningpage_q.ui \
|
||||
importFirewallConfigurationWizard/ic_progresspage_q.ui \
|
||||
importFirewallConfigurationWizard/ic_networkzonespage_q.ui \
|
||||
|
||||
|
||||
# fwtransfer stuff.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user