mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-09-11 07:31:25 +02:00
fixed bug 2640: WhereUsed finds TagService and RuleSet objects referenced from rule actions
This commit is contained in:
@@ -180,7 +180,6 @@ QString FWObjectPropertiesFactory::getObjectProperties(FWObject *obj)
|
|||||||
FWObjectTypedChildIterator j = obj->findByType(IPv4::TYPENAME);
|
FWObjectTypedChildIterator j = obj->findByType(IPv4::TYPENAME);
|
||||||
for ( ; j!=j.end(); ++j)
|
for ( ; j!=j.end(); ++j)
|
||||||
{
|
{
|
||||||
IPv4 *intf = IPv4::cast(*j);
|
|
||||||
str << getObjectProperties(*j);
|
str << getObjectProperties(*j);
|
||||||
str << "<br>";
|
str << "<br>";
|
||||||
}
|
}
|
||||||
@@ -330,7 +329,6 @@ QString FWObjectPropertiesFactory::getObjectPropertiesDetailed(FWObject *obj,
|
|||||||
Interface::TYPENAME);
|
Interface::TYPENAME);
|
||||||
for ( ; j!=j.end(); ++j)
|
for ( ; j!=j.end(); ++j)
|
||||||
{
|
{
|
||||||
Interface *intf = Interface::cast(*j);
|
|
||||||
str += (*j)->getName().c_str();
|
str += (*j)->getName().c_str();
|
||||||
str += ": ";
|
str += ": ";
|
||||||
str += getObjectProperties(*j);
|
str += getObjectProperties(*j);
|
||||||
@@ -425,7 +423,6 @@ QString FWObjectPropertiesFactory::getObjectPropertiesDetailed(FWObject *obj,
|
|||||||
FWObjectTypedChildIterator j = obj->findByType(IPv4::TYPENAME);
|
FWObjectTypedChildIterator j = obj->findByType(IPv4::TYPENAME);
|
||||||
for ( ; j!=j.end(); ++j)
|
for ( ; j!=j.end(); ++j)
|
||||||
{
|
{
|
||||||
IPv4 *intf = IPv4::cast(*j);
|
|
||||||
str += getObjectProperties(*j);
|
str += getObjectProperties(*j);
|
||||||
str += "<br>";
|
str += "<br>";
|
||||||
}
|
}
|
||||||
@@ -558,22 +555,33 @@ QString FWObjectPropertiesFactory::getRuleActionProperties(PolicyRule *rule)
|
|||||||
{
|
{
|
||||||
switch (rule->getAction())
|
switch (rule->getAction())
|
||||||
{
|
{
|
||||||
case PolicyRule::Reject :
|
case PolicyRule::Reject:
|
||||||
par = ropt->getStr("action_on_reject").c_str();
|
par = ropt->getStr("action_on_reject").c_str();
|
||||||
break;
|
break;
|
||||||
case PolicyRule::Tag :
|
case PolicyRule::Tag:
|
||||||
par = rule->getTagValue().c_str();//ropt->getStr("tagvalue").c_str();
|
{
|
||||||
|
FWObject *tag_object = rule->getTagObject();
|
||||||
|
if (tag_object)
|
||||||
|
par = tag_object->getName().c_str();
|
||||||
|
else
|
||||||
|
par = rule->getTagValue().c_str();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case PolicyRule::Accounting :
|
case PolicyRule::Accounting :
|
||||||
par = ropt->getStr("rule_name_accounting").c_str();
|
par = ropt->getStr("rule_name_accounting").c_str();
|
||||||
break;
|
break;
|
||||||
case PolicyRule::Custom :
|
case PolicyRule::Custom:
|
||||||
par = ropt->getStr("custom_str").c_str();
|
par = ropt->getStr("custom_str").c_str();
|
||||||
break;
|
break;
|
||||||
case PolicyRule::Branch :
|
case PolicyRule::Branch:
|
||||||
par = rule->getBranch()->getName().c_str();//ropt->getStr("branch_name").c_str();
|
{
|
||||||
|
FWObject *branch_ruleset = rule->getBranch();
|
||||||
|
if (branch_ruleset)
|
||||||
|
par = branch_ruleset->getName().c_str();
|
||||||
|
// ropt->getStr("branch_name").c_str();
|
||||||
break;
|
break;
|
||||||
case PolicyRule::Classify :
|
}
|
||||||
|
case PolicyRule::Classify:
|
||||||
if (platform=="ipfw")
|
if (platform=="ipfw")
|
||||||
{
|
{
|
||||||
if (ropt->getInt("ipfw_classify_method") == DUMMYNETPIPE)
|
if (ropt->getInt("ipfw_classify_method") == DUMMYNETPIPE)
|
||||||
|
|||||||
@@ -633,6 +633,15 @@ void FWWindow::ensureObjectVisibleInRules(FWReference *obj)
|
|||||||
activeProject()->ensureObjectVisibleInRules(obj);
|
activeProject()->ensureObjectVisibleInRules(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make rule visible and highlight given column
|
||||||
|
*/
|
||||||
|
void FWWindow::ensureRuleIsVisible(Rule *rule, int col)
|
||||||
|
{
|
||||||
|
if (activeProject())
|
||||||
|
activeProject()->ensureRuleIsVisible(rule, col);
|
||||||
|
}
|
||||||
|
|
||||||
void FWWindow::updateRuleSetViewSelection()
|
void FWWindow::updateRuleSetViewSelection()
|
||||||
{
|
{
|
||||||
if (activeProject())
|
if (activeProject())
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ public slots:
|
|||||||
bool editingLibrary();
|
bool editingLibrary();
|
||||||
|
|
||||||
void ensureObjectVisibleInRules(libfwbuilder::FWReference *obj);
|
void ensureObjectVisibleInRules(libfwbuilder::FWReference *obj);
|
||||||
|
void ensureRuleIsVisible(libfwbuilder::Rule *rule, int col=0);
|
||||||
|
|
||||||
QString chooseNewFileName(const QString &fname,
|
QString chooseNewFileName(const QString &fname,
|
||||||
bool checkPresence, const QString &title);
|
bool checkPresence, const QString &title);
|
||||||
|
|||||||
@@ -78,7 +78,10 @@ using namespace std;
|
|||||||
using namespace libfwbuilder;
|
using namespace libfwbuilder;
|
||||||
|
|
||||||
|
|
||||||
FindWhereUsedWidget::FindWhereUsedWidget(QWidget*p, const char * n, Qt::WindowFlags f, bool f_mini) : QWidget(p)
|
FindWhereUsedWidget::FindWhereUsedWidget(QWidget*p,
|
||||||
|
const char * n,
|
||||||
|
Qt::WindowFlags f,
|
||||||
|
bool f_mini) : QWidget(p)
|
||||||
{
|
{
|
||||||
m_widget = new Ui::findWhereUsedWidget_q;
|
m_widget = new Ui::findWhereUsedWidget_q;
|
||||||
m_widget->setupUi(this);
|
m_widget->setupUi(this);
|
||||||
@@ -94,7 +97,6 @@ FindWhereUsedWidget::FindWhereUsedWidget(QWidget*p, const char * n, Qt::WindowFl
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//connect (m_widget->dropArea,SIGNAL(objectInserted()),this,SLOT(findFromDrop()));
|
|
||||||
connect (m_widget->dropArea,SIGNAL(objectDeleted()),this,SLOT(init()));
|
connect (m_widget->dropArea,SIGNAL(objectDeleted()),this,SLOT(init()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,7 +114,7 @@ void FindWhereUsedWidget::setShowObject(bool fl)
|
|||||||
void FindWhereUsedWidget::itemActivated(QTreeWidgetItem* item)
|
void FindWhereUsedWidget::itemActivated(QTreeWidgetItem* item)
|
||||||
{
|
{
|
||||||
FWObject *o;
|
FWObject *o;
|
||||||
o=mapping[item];
|
o = mapping[item];
|
||||||
|
|
||||||
if (flShowObject && o!=NULL)
|
if (flShowObject && o!=NULL)
|
||||||
{
|
{
|
||||||
@@ -139,7 +141,7 @@ void FindWhereUsedWidget::_find(FWObject *obj)
|
|||||||
resset.clear();
|
resset.clear();
|
||||||
|
|
||||||
|
|
||||||
mw->db()->findWhereUsed(obj,mw->db(),resset);
|
mw->db()->findWhereUsed(obj, mw->db(), resset);
|
||||||
|
|
||||||
set<FWObject*>::iterator i=resset.begin();
|
set<FWObject*>::iterator i=resset.begin();
|
||||||
QTreeWidgetItem *item;
|
QTreeWidgetItem *item;
|
||||||
@@ -156,11 +158,17 @@ void FindWhereUsedWidget::_find(FWObject *obj)
|
|||||||
r=NULL;
|
r=NULL;
|
||||||
rs=NULL;
|
rs=NULL;
|
||||||
|
|
||||||
if (findRef(object,o)==NULL) continue;
|
// if (findRef(object,o)==NULL) continue;
|
||||||
if (RuleElement::cast(o)!=NULL)
|
|
||||||
{
|
|
||||||
fw=o->getParent();
|
|
||||||
|
|
||||||
|
if (mw->isSystem(o) || RuleSet::cast(o) ||
|
||||||
|
Firewall::cast(o) || Library::cast(o)) continue;
|
||||||
|
|
||||||
|
c1 = QString::fromUtf8(o->getName().c_str());
|
||||||
|
c2 = tr("Type: ")+QString::fromUtf8(o->getTypeName().c_str());
|
||||||
|
|
||||||
|
if (RuleElement::cast(o)!=NULL || Rule::cast(o)!=NULL)
|
||||||
|
{
|
||||||
|
fw = o;
|
||||||
while (fw!=NULL && !Firewall::isA(fw))
|
while (fw!=NULL && !Firewall::isA(fw))
|
||||||
{
|
{
|
||||||
if (Rule::cast(fw))
|
if (Rule::cast(fw))
|
||||||
@@ -170,12 +178,11 @@ void FindWhereUsedWidget::_find(FWObject *obj)
|
|||||||
{
|
{
|
||||||
rs=RuleSet::cast(fw);
|
rs=RuleSet::cast(fw);
|
||||||
}
|
}
|
||||||
|
|
||||||
fw=fw->getParent();
|
fw=fw->getParent();
|
||||||
}
|
}
|
||||||
if (fw==NULL || r==NULL || rs==NULL) continue;
|
if (fw==NULL || r==NULL || rs==NULL) continue;
|
||||||
|
|
||||||
c1=QString::fromUtf8(fw->getName().c_str());
|
c1 = QString::fromUtf8(fw->getName().c_str());
|
||||||
|
|
||||||
if (NAT::isA(rs))
|
if (NAT::isA(rs))
|
||||||
{
|
{
|
||||||
@@ -191,25 +198,12 @@ void FindWhereUsedWidget::_find(FWObject *obj)
|
|||||||
c2=tr("Unknown rule set");
|
c2=tr("Unknown rule set");
|
||||||
}
|
}
|
||||||
c2+=tr("/Rule%1").arg(r->getPosition());
|
c2+=tr("/Rule%1").arg(r->getPosition());
|
||||||
|
|
||||||
} else if (
|
|
||||||
mw->isSystem(o) ||
|
|
||||||
Rule::cast(o) ||
|
|
||||||
RuleSet::cast(o) ||
|
|
||||||
Firewall::cast(o) ||
|
|
||||||
Library::cast(o))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
c1=QString::fromUtf8(o->getName().c_str());
|
|
||||||
c2=tr("Type: ")+QString::fromUtf8(o->getTypeName().c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FWObject *pixobj=(fw==NULL)?o:fw;
|
FWObject *pixobj=(fw==NULL)?o:fw;
|
||||||
|
|
||||||
QString icn_file = (":/Icons/"+pixobj->getTypeName()+"/icon-tree").c_str();
|
QString icn_file =
|
||||||
|
(":/Icons/"+pixobj->getTypeName()+"/icon-tree").c_str();
|
||||||
|
|
||||||
QPixmap pm;
|
QPixmap pm;
|
||||||
if ( ! QPixmapCache::find( icn_file, pm) )
|
if ( ! QPixmapCache::find( icn_file, pm) )
|
||||||
@@ -220,9 +214,9 @@ void FindWhereUsedWidget::_find(FWObject *obj)
|
|||||||
|
|
||||||
QStringList qsl;
|
QStringList qsl;
|
||||||
qsl << c1 << c2;
|
qsl << c1 << c2;
|
||||||
item=new QTreeWidgetItem(m_widget->resListView, qsl);
|
item = new QTreeWidgetItem(m_widget->resListView, qsl);
|
||||||
item->setIcon(0,QIcon(pm));
|
item->setIcon(0, QIcon(pm));
|
||||||
mapping[item]=o;
|
mapping[item] = o;
|
||||||
}
|
}
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
@@ -252,11 +246,14 @@ void FindWhereUsedWidget::showObject(FWObject* o)
|
|||||||
|
|
||||||
if (RuleElement::cast(o)!=NULL)
|
if (RuleElement::cast(o)!=NULL)
|
||||||
{
|
{
|
||||||
ref=findRef(object,o);
|
ref = findRef(object, o);
|
||||||
if (ref==NULL) return;
|
if (ref==NULL) return;
|
||||||
mw->activeProject()->openRuleSet(o->getParent()->getParent());
|
mw->activeProject()->openRuleSet(o->getParent()->getParent());
|
||||||
mw->clearManipulatorFocus();
|
mw->clearManipulatorFocus();
|
||||||
mw->ensureObjectVisibleInRules( ref );
|
mw->ensureObjectVisibleInRules( ref );
|
||||||
|
RuleSetView *rsv = mw->activeProject()->getCurrentRuleSetView();
|
||||||
|
rsv->selectRE( ref );
|
||||||
|
|
||||||
// mw->selectRules();
|
// mw->selectRules();
|
||||||
if (mw->isEditorVisible())
|
if (mw->isEditorVisible())
|
||||||
{
|
{
|
||||||
@@ -264,6 +261,23 @@ void FindWhereUsedWidget::showObject(FWObject* o)
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Rule::cast(o)!=NULL)
|
||||||
|
{
|
||||||
|
mw->activeProject()->openRuleSet(o->getParent());
|
||||||
|
mw->clearManipulatorFocus();
|
||||||
|
mw->ensureRuleIsVisible( Rule::cast(o) );
|
||||||
|
RuleSetView *rsv = mw->activeProject()->getCurrentRuleSetView();
|
||||||
|
rsv->selectRE( Rule::cast(o)->getPosition(),
|
||||||
|
rsv->getColByType(RuleSetView::Action));
|
||||||
|
|
||||||
|
if (mw->isEditorVisible())
|
||||||
|
{
|
||||||
|
mw->editObject( object );
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mw->unselectRules();
|
mw->unselectRules();
|
||||||
|
|
||||||
if (Group::cast(o)!=NULL)
|
if (Group::cast(o)!=NULL)
|
||||||
|
|||||||
+2
-2
@@ -10,11 +10,11 @@
|
|||||||
<file alias="Icons/Pipe">Icons/pipe_25.png</file>
|
<file alias="Icons/Pipe">Icons/pipe_25.png</file>
|
||||||
<file alias="Icons/Reject">Icons/reject_25.png</file>
|
<file alias="Icons/Reject">Icons/reject_25.png</file>
|
||||||
<file alias="Icons/Route">Icons/route_25.png</file>
|
<file alias="Icons/Route">Icons/route_25.png</file>
|
||||||
<file alias="Icons/Tag">Icons/tag_25.png</file>
|
<file alias="Icons/Tag">Icons/service-tag_25.png</file>
|
||||||
<file alias="Icons/Options">Icons/options_25.png</file>
|
<file alias="Icons/Options">Icons/options_25.png</file>
|
||||||
|
|
||||||
<file alias="Icons/Options-tree">Icons/options_16.png</file>
|
<file alias="Icons/Options-tree">Icons/options_16.png</file>
|
||||||
<file alias="Icons/Tag-tree">Icons/tag_16.png</file>
|
<file alias="Icons/Tag-tree">Icons/service-tag_16.png</file>
|
||||||
<file alias="Icons/Route-tree">Icons/route_16.png</file>
|
<file alias="Icons/Route-tree">Icons/route_16.png</file>
|
||||||
<file alias="Icons/Reject-tree">Icons/reject_16.png</file>
|
<file alias="Icons/Reject-tree">Icons/reject_16.png</file>
|
||||||
<file alias="Icons/Pipe-tree">Icons/pipe_16.png</file>
|
<file alias="Icons/Pipe-tree">Icons/pipe_16.png</file>
|
||||||
|
|||||||
@@ -624,6 +624,28 @@ void ProjectPanel::ensureObjectVisibleInRules(FWReference *obj)
|
|||||||
rsv->selectRE( obj );
|
rsv->selectRE( obj );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ensure rule is visible and highlight given column
|
||||||
|
*/
|
||||||
|
void ProjectPanel::ensureRuleIsVisible(Rule *rule, int col)
|
||||||
|
{
|
||||||
|
FWObject *p = rule;
|
||||||
|
|
||||||
|
while (p && RuleSet::cast(p)==NULL ) p=p->getParent();
|
||||||
|
if (p==NULL) return; // something is broken
|
||||||
|
|
||||||
|
RuleSetView *rsv = ruleSetViews[p];
|
||||||
|
|
||||||
|
if (rsv==NULL)
|
||||||
|
{
|
||||||
|
if (fwbdebug)
|
||||||
|
qDebug("ProjectPanel::ensureRuleIsVisible : orphan rule set found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_panel->ruleSets->setCurrentIndex(m_panel->ruleSets->indexOf(rsv));
|
||||||
|
rsv->selectRE( rule->getPosition(), col );
|
||||||
|
}
|
||||||
|
|
||||||
void ProjectPanel::updateRuleSetViewSelection()
|
void ProjectPanel::updateRuleSetViewSelection()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -241,6 +241,7 @@ public:
|
|||||||
|
|
||||||
void clearFirewallTabs();
|
void clearFirewallTabs();
|
||||||
void ensureObjectVisibleInRules(libfwbuilder::FWReference *obj);
|
void ensureObjectVisibleInRules(libfwbuilder::FWReference *obj);
|
||||||
|
void ensureRuleIsVisible(libfwbuilder::Rule *rule, int col=0);
|
||||||
|
|
||||||
libfwbuilder::FWObject* getVisibleFirewall() { return visibleFirewall; }
|
libfwbuilder::FWObject* getVisibleFirewall() { return visibleFirewall; }
|
||||||
RuleSetView* getRuleSetViews(libfwbuilder::FWObject *o)
|
RuleSetView* getRuleSetViews(libfwbuilder::FWObject *o)
|
||||||
|
|||||||
+29
-7
@@ -1319,6 +1319,20 @@ RuleSetView::REType RuleSetView::getColType(int col) const
|
|||||||
return i->second;
|
return i->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns column number for the given column type.
|
||||||
|
* Note that for some types this operation is ambiguous because we have
|
||||||
|
* several columns with the same type. In that case return the number
|
||||||
|
* of the first column that matches.
|
||||||
|
*/
|
||||||
|
int RuleSetView::getColByType(REType type) const
|
||||||
|
{
|
||||||
|
map<int,REType>::const_iterator i;
|
||||||
|
for (i=colTypes.begin(); i!=colTypes.end(); ++i)
|
||||||
|
if (i->second == type) return i->first;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString RuleSetView::objectText(RuleElement *re,FWObject *obj)
|
QString RuleSetView::objectText(RuleElement *re,FWObject *obj)
|
||||||
{
|
{
|
||||||
@@ -1929,7 +1943,13 @@ void RuleSetView::selectRE( int row, int col)
|
|||||||
if (row!=currentRow() || col!=currentColumn())
|
if (row!=currentRow() || col!=currentColumn())
|
||||||
{
|
{
|
||||||
selectedObject = NULL;
|
selectedObject = NULL;
|
||||||
updateCell(currentRow(),currentColumn());
|
|
||||||
|
setCurrentCell(row,col);
|
||||||
|
scrollTo( ruleModel->index(row,col),
|
||||||
|
QAbstractItemView::EnsureVisible);
|
||||||
|
updateCell(row,col);
|
||||||
|
|
||||||
|
// updateCell(currentRow(),currentColumn());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1948,12 +1968,14 @@ void RuleSetView::selectRE(libfwbuilder::FWReference *ref)
|
|||||||
int col;
|
int col;
|
||||||
for (col=0; col<ncols; ++col)
|
for (col=0; col<ncols; ++col)
|
||||||
if (re==getRE(r,col))
|
if (re==getRE(r,col))
|
||||||
{
|
{
|
||||||
setCurrentCell(row,col);
|
selectRE(row, col);
|
||||||
scrollTo( ruleModel->index(row,col), QAbstractItemView::EnsureVisible);
|
//setCurrentCell(row,col);
|
||||||
updateCell(row,col);
|
//scrollTo( ruleModel->index(row,col),
|
||||||
break;
|
// QAbstractItemView::EnsureVisible);
|
||||||
}
|
//updateCell(row,col);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RuleSetView::itemDoubleClicked(const QModelIndex & index)
|
void RuleSetView::itemDoubleClicked(const QModelIndex & index)
|
||||||
|
|||||||
@@ -446,6 +446,7 @@ class RuleSetView : public QTableView
|
|||||||
void openObjectInTree(libfwbuilder::FWObject *obj);
|
void openObjectInTree(libfwbuilder::FWObject *obj);
|
||||||
|
|
||||||
REType getColType(int col) const;
|
REType getColType(int col) const;
|
||||||
|
int getColByType(REType) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProjectPanel *m_project;
|
ProjectPanel *m_project;
|
||||||
|
|||||||
@@ -95,9 +95,8 @@ void findByObjectType(FWObject *o,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FWReference* findRef(FWObject *o,FWObject *p)
|
FWReference* findRef(FWObject *o, FWObject *p)
|
||||||
{
|
{
|
||||||
|
|
||||||
FWReference* ref=NULL;
|
FWReference* ref=NULL;
|
||||||
FWObject::iterator i=p->begin();
|
FWObject::iterator i=p->begin();
|
||||||
for(;i!=p->end();++i)
|
for(;i!=p->end();++i)
|
||||||
|
|||||||
Reference in New Issue
Block a user