diff --git a/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php index 66fccec01..971ed8ad9 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php @@ -650,4 +650,73 @@ class SettingsController extends ApiMutableModelControllerBase { return $this->toggleBase("userDefinedRules.rule", $uuid, $enabled); } + + /** + * Search policy + * @return array list of found user rules + * @throws \ReflectionException when not bound to model + */ + public function searchPolicyAction() + { + return $this->searchBase("policies.policy", array("enabled", "prio", "description"), "description"); + } + + /** + * Update policy + * @param string $uuid internal id + * @return array save result + validation output + * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \ReflectionException when not bound to model + */ + public function setPolicyAction($uuid) + { + return $this->setBase("policy", "policies.policy", $uuid); + } + + /** + * Add new policy + * @return array save result + validation output + * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \ReflectionException when not bound to model + */ + public function addPolicyAction() + { + return $this->addBase("policy", "policies.policy"); + } + + /** + * Get properties of a policy + * @param null|string $uuid user rule internal id + * @return array user defined properties + * @throws \ReflectionException when not bound to model + */ + public function getPolicyAction($uuid = null) + { + return $this->getBase("policy", "policies.policy", $uuid); + } + + /** + * Delete policy item + * @param string $uuid user rule internal id + * @return array save status + * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \ReflectionException when not bound to model + */ + public function delPolicyAction($uuid) + { + return $this->delBase("policies.policy", $uuid); + } + + /** + * Toggle policy by uuid (enable/disable) + * @param $uuid user defined rule internal id + * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle + * @return array save result + * @throws \Phalcon\Validation\Exception when field validations fail + * @throws \ReflectionException when not bound to model + */ + public function togglePolicyAction($uuid, $enabled = null) + { + return $this->toggleBase("policies.policy", $uuid, $enabled); + } } diff --git a/src/opnsense/mvc/app/controllers/OPNsense/IDS/PolicyController.php b/src/opnsense/mvc/app/controllers/OPNsense/IDS/PolicyController.php new file mode 100644 index 000000000..168a7c114 --- /dev/null +++ b/src/opnsense/mvc/app/controllers/OPNsense/IDS/PolicyController.php @@ -0,0 +1,44 @@ +view->formDialogPolicy = $this->getForm("dialogPolicy"); + $this->view->pick('OPNsense/IDS/policy'); + } +} diff --git a/src/opnsense/mvc/app/controllers/OPNsense/IDS/forms/dialogPolicy.xml b/src/opnsense/mvc/app/controllers/OPNsense/IDS/forms/dialogPolicy.xml new file mode 100644 index 000000000..0cc53076b --- /dev/null +++ b/src/opnsense/mvc/app/controllers/OPNsense/IDS/forms/dialogPolicy.xml @@ -0,0 +1,38 @@ +
diff --git a/src/opnsense/mvc/app/models/OPNsense/IDS/FieldTypes/PolicyContentField.php b/src/opnsense/mvc/app/models/OPNsense/IDS/FieldTypes/PolicyContentField.php new file mode 100644 index 000000000..d603a3f8f --- /dev/null +++ b/src/opnsense/mvc/app/models/OPNsense/IDS/FieldTypes/PolicyContentField.php @@ -0,0 +1,68 @@ +configdRun("ids list rulemetadata"); + $data = json_decode($response, true); + if (!empty($data)) { + foreach ($data as $prop => $values) { + foreach ($values as $value) { + $item_key = "{$prop}.{$value}"; + self::$internalStaticOptionList[$item_key] = $value; + } + } + } + } + $this->internalOptionList = self::$internalStaticOptionList; + } +} diff --git a/src/opnsense/mvc/app/models/OPNsense/IDS/IDS.xml b/src/opnsense/mvc/app/models/OPNsense/IDS/IDS.xml index ad3e9714a..d669792e9 100644 --- a/src/opnsense/mvc/app/models/OPNsense/IDS/IDS.xml +++ b/src/opnsense/mvc/app/models/OPNsense/IDS/IDS.xml @@ -25,6 +25,52 @@ +| {{ lang._('Enabled') }} | +{{ lang._('Priority') }} | +{{ lang._('Description') }} | +{{ lang._('Commands') }} | +{{ lang._('ID') }} | +
|---|---|---|---|---|
| + | + + + | +