Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
730d291e
Commit
730d291e
authored
Nov 07, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(IDS) merge model changes from master
parent
93427baf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
57 deletions
+48
-57
SettingsController.php
...c/app/controllers/OPNsense/IDS/Api/SettingsController.php
+12
-57
M1_0_0.php
...pnsense/mvc/app/models/OPNsense/IDS/Migrations/M1_0_0.php
+36
-0
No files found.
src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php
View file @
730d291e
...
...
@@ -29,10 +29,9 @@
namespace
OPNsense\IDS\Api
;
use
\Phalcon\Filter
;
use
\OPNsense\Base\ApiControllerBase
;
use
\OPNsense\Base\Api
MutableModel
ControllerBase
;
use
\OPNsense\Base\Filters\QueryFilter
;
use
\OPNsense\Core\Backend
;
use
\OPNsense\IDS\IDS
;
use
\OPNsense\Core\Config
;
use
\OPNsense\Base\UIModelGrid
;
...
...
@@ -40,24 +39,23 @@ use \OPNsense\Base\UIModelGrid;
* Class SettingsController Handles settings related API actions for the IDS module
* @package OPNsense\IDS
*/
class
SettingsController
extends
ApiControllerBase
class
SettingsController
extends
Api
MutableModel
ControllerBase
{
/**
* @var null|IDS IDS model to share across some methods (see getModel)
*/
private
$idsModel
=
null
;
static
protected
$internalModelName
=
'ids'
;
static
protected
$internalModelClass
=
'\OPNsense\IDS\IDS'
;
/**
* get ids model
* @return null|IDS
* @return array plain model settings (non repeating items)
*/
p
ublic
function
getModel
()
p
rotected
function
getModelNodes
()
{
if
(
$this
->
idsModel
==
null
)
{
$this
->
idsModel
=
new
IDS
();
$settingsNodes
=
array
(
'general'
);
$result
=
array
();
$mdlIDS
=
$this
->
getModel
();
foreach
(
$settingsNodes
as
$key
)
{
$result
[
$key
]
=
$mdlIDS
->
$key
->
getNodes
();
}
return
$this
->
idsModel
;
return
$result
;
}
/**
...
...
@@ -464,49 +462,6 @@ class SettingsController extends ApiControllerBase
return
$result
;
}
/**
* retrieve IDS settings
* @return array IDS settings
*/
public
function
getAction
()
{
// define list of configurable settings
$settingsNodes
=
array
(
'general'
);
$result
=
array
();
if
(
$this
->
request
->
isGet
())
{
$mdlIDS
=
$this
->
getModel
();
$result
[
'ids'
]
=
array
();
foreach
(
$settingsNodes
as
$key
)
{
$result
[
'ids'
][
$key
]
=
$mdlIDS
->
$key
->
getNodes
();
}
}
return
$result
;
}
/**
* update IDS settings
* @return array status
*/
public
function
setAction
()
{
$result
=
array
(
"result"
=>
"failed"
);
if
(
$this
->
request
->
isPost
())
{
// load model and update with provided data
$mdlIDS
=
$this
->
getModel
();
$mdlIDS
->
setNodes
(
$this
->
request
->
getPost
(
"ids"
));
$validations
=
$mdlIDS
->
validate
(
null
,
"ids."
);
if
(
count
(
$validations
))
{
$result
[
'validations'
]
=
$validations
;
}
else
{
$mdlIDS
->
serializeToConfig
();
Config
::
getInstance
()
->
save
();
$result
[
"result"
]
=
"saved"
;
}
}
return
$result
;
}
/**
* search user defined rules
* @return array list of found user rules
...
...
src/opnsense/mvc/app/models/OPNsense/IDS/Migrations/M1_0_0.php
0 → 100644
View file @
730d291e
<?php
/**
* Copyright (C) 2016 Deciso B.V.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace
OPNsense\IDS\Migrations
;
use
OPNsense\Base\BaseModelMigration
;
class
M1_0_0
extends
BaseModelMigration
{
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment