Skip to content

Commit

Permalink
Merge pull request #665 from swaschkut/main
Browse files Browse the repository at this point in the history
version 2.0.61
  • Loading branch information
swaschkut authored Oct 4, 2022
2 parents b67306c + 5f60102 commit 1050044
Show file tree
Hide file tree
Showing 16 changed files with 149 additions and 52 deletions.
17 changes: 14 additions & 3 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
CHANGELOG

2.0.60
2.0.61
UTIL:
* develop ssh-connector | introduce argument password
* type=rule actions=description-append | introduce $$current.name$$ a stringformular
* type=rule | introduce 'filter=(url.category.count ><=! NUMBER)'
* type=address | improve "help create-address" - improve also actions=display

BUGFIX:
* class Panorama/Pan/FawkesConf - save_to_file set indentingXmlIncreament to default without an encrease with +1
* type=device actions=sp_spg-create-bp:false | if no name argument is defined 'sp_spg-create-bp:[shared], sp-name' use predefined array
* class RulewithUserID - bugfix for known-user

GENERAL:
* improve classes BuckbeackConf / FawkesConf - to avoid creating XML node if not needed
* extend class Container/DeviceCloud/DeviceOnPrem with DataFilteringProfileStore


2.0.60 (20220926)
UTIL:
* develop ssh-connector | introduce argument password
* type=rule actions=description-append | introduce $$current.name$$ a stringformular


2.0.59 (20220924)
Expand Down
18 changes: 11 additions & 7 deletions lib/device-and-system-classes/BuckbeakConf.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,11 @@ public function load_from_domxml($xml)
$this->devicecloudroot = DH::findFirstElementOrCreate('device', $this->localhostroot);
$this->cloudroot = DH::findFirstElementOrCreate('cloud', $this->devicecloudroot);

$this->onpremroot = DH::findFirstElementOrCreate('on-prem', $this->devicecloudroot);
$this->onpremroot = DH::findFirstElement('on-prem', $this->devicecloudroot);

$this->snippetroot = DH::findFirstElementOrCreate('snippet', $this->localhostroot);

$tmp = DH::findFirstElementOrCreate('managed-devices', $this->localhostroot);
$tmp = DH::findFirstElement('managed-devices', $this->localhostroot);

//->devices/container
//
Expand Down Expand Up @@ -411,15 +411,19 @@ public function load_from_domxml($xml)
//
// loading onpremss
//
foreach( $this->onpremroot->childNodes as $node )
if( $this->onpremroot !== false )
{
if( $node->nodeType != XML_ELEMENT_NODE ) continue;
foreach( $this->onpremroot->childNodes as $node )
{
if( $node->nodeType != XML_ELEMENT_NODE ) continue;

$ldv = new DeviceOnPrem( $this );
$ldv = new DeviceOnPrem( $this );

$ldv->load_from_domxml( $node );
$this->onprems[] = $ldv;
$ldv->load_from_domxml( $node );
$this->onprems[] = $ldv;
}
}

//
// end of DeviceCloud
//
Expand Down
15 changes: 15 additions & 0 deletions lib/device-and-system-classes/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ class Container
/** @var SecurityProfileStore */
public $FileBlockingProfileStore = null;

/** @var SecurityProfileStore */
public $DataFilteringProfileStore = null;

/** @var SecurityProfileStore */
#public $AntiVirusProfileStore = null;

Expand Down Expand Up @@ -260,6 +263,9 @@ public function __construct($owner)
$this->FileBlockingProfileStore = new SecurityProfileStore($this, "FileBlockingProfile");
$this->FileBlockingProfileStore->name = 'FileBlocking';

$this->DataFilteringProfileStore = new SecurityProfileStore($this, "DataFilteringProfile");
$this->DataFilteringProfileStore->name = 'DataFiltering';

#$this->WildfireProfileStore = new SecurityProfileStore($this, "SecurityProfileWildFire");
#$this->WildfireProfileStore->name = 'WildFire';

Expand Down Expand Up @@ -476,6 +482,13 @@ public function load_from_domxml($xml)
$this->FileBlockingProfileStore->load_from_domxml($tmproot);
}

//
// DataFiltering Profile extraction
//
$tmproot = DH::findFirstElement('data-filtering', $this->securityProfilebaseroot);
if( $tmproot !== FALSE )
$this->DataFilteringProfileStore->load_from_domxml($tmproot);

//
// vulnerability Profile extraction
//
Expand Down Expand Up @@ -1158,6 +1171,8 @@ public function display_statistics()
$stdoutarray['custom URL objects']['total'] = $this->customURLProfileStore->count();
$stdoutarray['File-Blocking objects'] = array();
$stdoutarray['File-Blocking objects']['total'] = $this->FileBlockingProfileStore->count();
$stdoutarray['Data-Filtering objects'] = array();
$stdoutarray['Data-Filtering objects']['total'] = $this->DataFilteringProfileStore->count();
$stdoutarray['Decryption objects'] = array();
$stdoutarray['Decryption objects']['total'] = $this->DecryptionProfileStore->count();

Expand Down
17 changes: 16 additions & 1 deletion lib/device-and-system-classes/DeviceCloud.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class DeviceCloud
/** @var SecurityProfileStore */
public $FileBlockingProfileStore = null;

/** @var SecurityProfileStore */
public $DataFilteringProfileStore = null;

/** @var SecurityProfileStore */
#public $AntiVirusProfileStore = null;

Expand Down Expand Up @@ -255,6 +258,9 @@ public function __construct( $owner, Container $applicableDG = null)
$this->FileBlockingProfileStore = new SecurityProfileStore($this, "FileBlockingProfile");
$this->FileBlockingProfileStore->name = 'FileBlocking';

$this->DataFilteringProfileStore = new SecurityProfileStore($this, "DataFilteringProfile");
$this->DataFilteringProfileStore->name = 'DataFiltering';

#$this->WildfireProfileStore = new SecurityProfileStore($this, "SecurityProfileWildFire");
#$this->WildfireProfileStore->name = 'WildFire';

Expand Down Expand Up @@ -403,7 +409,7 @@ public function load_from_domxml($xml)
'securityProfileGroupStore',

'URLProfileStore', 'VirusAndWildfireProfileStore', 'FileBlockingProfileStore',
//'DataFilteringProfileStore',
'DataFilteringProfileStore',
'VulnerabilityProfileStore', 'AntiSpywareProfileStore',
//'WildfireProfileStore',
'DecryptionProfileStore', 'HipObjectsProfileStore',
Expand Down Expand Up @@ -564,6 +570,13 @@ public function load_from_domxml($xml)
$this->FileBlockingProfileStore->load_from_domxml($tmproot);
}

//
// DataFiltering Profile extraction
//
$tmproot = DH::findFirstElement('data-filtering', $this->securityProfilebaseroot);
if( $tmproot !== FALSE )
$this->DataFilteringProfileStore->load_from_domxml($tmproot);

//
// vulnerability Profile extraction
//
Expand Down Expand Up @@ -1011,6 +1024,8 @@ public function display_statistics()
$stdoutarray['custom URL objects']['total'] = $this->customURLProfileStore->count();
$stdoutarray['File-Blocking objects'] = array();
$stdoutarray['File-Blocking objects']['total'] = $this->FileBlockingProfileStore->count();
$stdoutarray['Data-Filtering objects'] = array();
$stdoutarray['Data-Filtering objects']['total'] = $this->DataFilteringProfileStore->count();
$stdoutarray['Decryption objects'] = array();
$stdoutarray['Decryption objects']['total'] = $this->DecryptionProfileStore->count();

Expand Down
17 changes: 16 additions & 1 deletion lib/device-and-system-classes/DeviceOnPrem.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class DeviceOnPrem
/** @var SecurityProfileStore */
public $FileBlockingProfileStore = null;

/** @var SecurityProfileStore */
public $DataFilteringProfileStore = null;

/** @var SecurityProfileStore */
#public $AntiVirusProfileStore = null;

Expand Down Expand Up @@ -259,6 +262,9 @@ public function __construct( $owner, Container $applicableDG = null)
$this->FileBlockingProfileStore = new SecurityProfileStore($this, "FileBlockingProfile");
$this->FileBlockingProfileStore->name = 'FileBlocking';

$this->DataFilteringProfileStore = new SecurityProfileStore($this, "DataFilteringProfile");
$this->DataFilteringProfileStore->name = 'DataFiltering';

#$this->WildfireProfileStore = new SecurityProfileStore($this, "SecurityProfileWildFire");
#$this->WildfireProfileStore->name = 'WildFire';

Expand Down Expand Up @@ -407,7 +413,7 @@ public function load_from_domxml($xml)
'securityProfileGroupStore',

'URLProfileStore', 'VirusAndWildfireProfileStore', 'FileBlockingProfileStore',
//'DataFilteringProfileStore',
'DataFilteringProfileStore',
'VulnerabilityProfileStore', 'AntiSpywareProfileStore',
//'WildfireProfileStore',
'DecryptionProfileStore', 'HipObjectsProfileStore',
Expand Down Expand Up @@ -568,6 +574,13 @@ public function load_from_domxml($xml)
$this->FileBlockingProfileStore->load_from_domxml($tmproot);
}

//
// DataFiltering Profile extraction
//
$tmproot = DH::findFirstElement('data-filtering', $this->securityProfilebaseroot);
if( $tmproot !== FALSE )
$this->DataFilteringProfileStore->load_from_domxml($tmproot);

//
// vulnerability Profile extraction
//
Expand Down Expand Up @@ -1015,6 +1028,8 @@ public function display_statistics()
$stdoutarray['custom URL objects']['total'] = $this->customURLProfileStore->count();
$stdoutarray['File-Blocking objects'] = array();
$stdoutarray['File-Blocking objects']['total'] = $this->FileBlockingProfileStore->count();
$stdoutarray['Data-Filtering objects'] = array();
$stdoutarray['Data-Filtering objects']['total'] = $this->DataFilteringProfileStore->count();
$stdoutarray['Decryption objects'] = array();
$stdoutarray['Decryption objects']['total'] = $this->DecryptionProfileStore->count();

Expand Down
19 changes: 11 additions & 8 deletions lib/device-and-system-classes/FawkesConf.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,11 @@ public function load_from_domxml($xml)
$this->devicecloudroot = DH::findFirstElementOrCreate('device', $this->localhostroot);
$this->cloudroot = DH::findFirstElementOrCreate('cloud', $this->devicecloudroot);

$this->onpremroot = DH::findFirstElementOrCreate('on-prem', $this->devicecloudroot);
$this->onpremroot = DH::findFirstElement('on-prem', $this->devicecloudroot);

$this->snippetroot = DH::findFirstElementOrCreate('snippet', $this->localhostroot);

$tmp = DH::findFirstElementOrCreate('managed-devices', $this->localhostroot);
$tmp = DH::findFirstElement('managed-devices', $this->localhostroot);

//->devices/container
//
Expand Down Expand Up @@ -413,14 +413,17 @@ public function load_from_domxml($xml)
//
// loading onpremss
//
foreach( $this->onpremroot->childNodes as $node )
if( $this->onpremroot !== false )
{
if( $node->nodeType != XML_ELEMENT_NODE ) continue;
foreach( $this->onpremroot->childNodes as $node )
{
if( $node->nodeType != XML_ELEMENT_NODE ) continue;

$ldv = new DeviceOnPrem( $this );
$ldv = new DeviceOnPrem( $this );

$ldv->load_from_domxml( $node );
$this->onprems[] = $ldv;
$ldv->load_from_domxml( $node );
$this->onprems[] = $ldv;
}
}
//
// end of DeviceCloud
Expand Down Expand Up @@ -521,7 +524,7 @@ public function save_to_file($fileName, $printMessage = TRUE, $lineReturn = TRUE

//Todo: swaschkut check
//$indentingXmlIncreament was 2 per default for Panroama
$xml = &DH::dom_to_xml($this->xmlroot, $indentingXml, $lineReturn, -1, $indentingXmlIncreament + 1);
$xml = &DH::dom_to_xml($this->xmlroot, $indentingXml, $lineReturn, -1, $indentingXmlIncreament);

$path_parts = pathinfo($fileName);
if (!is_dir($path_parts['dirname']))
Expand Down
2 changes: 1 addition & 1 deletion lib/device-and-system-classes/PANConf.php
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ public function save_to_file($fileName, $printMessage = TRUE, $lineReturn = TRUE
if( $printMessage )
PH::print_stdout( "Now saving PANConf to file '$fileName'...");

$xml = &DH::dom_to_xml($this->xmlroot, $indentingXml, $lineReturn, -1, $indentingXmlIncreament + 1);
$xml = &DH::dom_to_xml($this->xmlroot, $indentingXml, $lineReturn, -1, $indentingXmlIncreament);

$path_parts = pathinfo($fileName);
if (!is_dir($path_parts['dirname']))
Expand Down
2 changes: 1 addition & 1 deletion lib/device-and-system-classes/PanoramaConf.php
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@ public function save_to_file($fileName, $printMessage = TRUE, $lineReturn = TRUE

//Todo: swaschkut check
//$indentingXmlIncreament was 2 per default for Panroama
$xml = &DH::dom_to_xml($this->xmlroot, $indentingXml, $lineReturn, -1, $indentingXmlIncreament + 1);
$xml = &DH::dom_to_xml($this->xmlroot, $indentingXml, $lineReturn, -1, $indentingXmlIncreament);

$path_parts = pathinfo($fileName);
if (!is_dir($path_parts['dirname']))
Expand Down
2 changes: 1 addition & 1 deletion lib/misc-classes/PH.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function __construct($argv, $argc)

private static $library_version_major = 2;
private static $library_version_sub = 0;
private static $library_version_bugfix = 59;
private static $library_version_bugfix = 61;

//BASIC AUTH PAN-OS 7.1
public static $softwareupdate_key = "658d787f293e631196dac9fb29490f1cc1bb3827";
Expand Down
9 changes: 8 additions & 1 deletion lib/misc-classes/filters/filters-Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -3023,7 +3023,14 @@
'input' => 'input/panorama-8.0.xml'
)
);

RQuery::$defaultFilters['rule']['url.category.count']['operators']['>,<,=,!'] = array(
'eval' => "\$object->isSecurityRule() && \$object->urlCategoriescount() !operator! !value!",
'arg' => TRUE,
'ci' => array(
'fString' => '(%PROP% 1)',
'input' => 'input/panorama-8.0.xml'
)
);
RQuery::$defaultFilters['rule']['target']['operators']['is.any'] = array(
'Function' => function (RuleRQueryContext $context) {
return $context->object->target_isAny();
Expand Down
3 changes: 2 additions & 1 deletion lib/object-classes/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class Address
const TypeIpWildcard = 5;


static public $AddressTypes = array(self::TypeTmp => 'tmp',
static public $AddressTypes = array(
self::TypeTmp => 'tmp',
self::TypeIpNetmask => 'ip-netmask',
self::TypeIpRange => 'ip-range',
self::TypeFQDN => 'fqdn',
Expand Down
5 changes: 5 additions & 0 deletions lib/rule-classes/RuleWithUserID.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ function userID_loadUsersFromXml()
$this->_userIDType = self::__UserIDType_Known;
return;
}
if( $content == 'known-user' )
{
$this->_userIDType = self::__UserIDType_Known;
return;
}
if( $content == 'pre-logon' )
{
$this->_userIDType = self::__UserIDType_PreLogon;
Expand Down
5 changes: 5 additions & 0 deletions lib/rule-classes/SecurityRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,11 @@ public function urlCategories()
return $this->_urlCategories;
}

public function urlCategoriescount()
{
return count($this->_urlCategories);
}

public function urlCategoryIsAny()
{
return count($this->_urlCategories) == 0;
Expand Down
11 changes: 8 additions & 3 deletions utils/common/actions-address.php
Original file line number Diff line number Diff line change
Expand Up @@ -1812,8 +1812,8 @@
$tag_string = "tag: '".$toStringInline."'";
}

PH::print_stdout( $context->padding . "* " . get_class($object) . " '{$object->name()}' value: '{$object->value()}' desc: '{$object->description()}' IPcount: '{$object->getIPcount()}' $tag_string" );
PH::$JSON_TMP['sub']['object'][$object->name()]['type'] = get_class($object);
PH::print_stdout( $context->padding . "* " . get_class($object) . " '{$object->name()}' type: '{$object->type()}' value: '{$object->value()}' desc: '{$object->description()}' IPcount: '{$object->getIPcount()}' $tag_string" );
PH::$JSON_TMP['sub']['object'][$object->name()]['type'] = $object->type();
PH::$JSON_TMP['sub']['object'][$object->name()]['value'] = $object->value();
PH::$JSON_TMP['sub']['object'][$object->name()]['tag'] = $tag_string;
PH::$JSON_TMP['sub']['object'][$object->name()]['description'] = $object->description();
Expand Down Expand Up @@ -2626,7 +2626,12 @@
'args' => array(
'name' => array('type' => 'string', 'default' => '*nodefault*'),
'value' => array('type' => 'string', 'default' => '*nodefault*'),
'type' => array('type' => 'string', 'default' => '*nodefault*')
'type' => array(
'type' => 'string',
'default' => '*nodefault*',
'help' =>
implode( ", ", Address::$AddressTypes )
)
)
);

Expand Down
5 changes: 3 additions & 2 deletions utils/common/actions-device.php
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,7 @@
$ownerDocument = $sub->xmlroot->ownerDocument;

$force = false; // check about actions argument introduction
if( isset($context->arguments['sp-name']) )
if( isset($context->arguments['sp-name']) && $context->arguments['sp-name'] !== "*nodefault*" )
$nameArray = array("Outbound");
else
$nameArray = array("Alert-Only", "Outbound", "Inbound", "Internal", "Exception");
Expand All @@ -1713,7 +1713,8 @@
if( isset($context->arguments['sp-name']) )
{
$ironskilletName = $name;
$name = $context->arguments['sp-name'];
if( $context->arguments['sp-name'] !== "*nodefault*" )
$name = $context->arguments['sp-name'];
}
else
$ironskilletName = $name;
Expand Down
Loading

0 comments on commit 1050044

Please sign in to comment.