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
566f2b4b
Commit
566f2b4b
authored
Jun 26, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(ids) sanitize query strings
parent
0a5f2f2b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
4 deletions
+18
-4
ServiceController.php
...vc/app/controllers/OPNsense/IDS/Api/ServiceController.php
+6
-1
SettingsController.php
...c/app/controllers/OPNsense/IDS/Api/SettingsController.php
+12
-3
No files found.
src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/ServiceController.php
View file @
566f2b4b
...
...
@@ -29,6 +29,7 @@
namespace
OPNsense\IDS\Api
;
use
\Phalcon\Filter
;
use
\OPNsense\Base\Filters\QueryFilter
;
use
\OPNsense\Base\ApiControllerBase
;
use
\OPNsense\Core\Backend
;
use
\OPNsense\IDS\IDS
;
...
...
@@ -162,13 +163,17 @@ class ServiceController extends ApiControllerBase
{
if
(
$this
->
request
->
isPost
())
{
$this
->
sessionClose
();
// create filter to sanitize input data
$filter
=
new
Filter
();
$filter
->
add
(
'query'
,
new
QueryFilter
());
// fetch query parameters
$itemsPerPage
=
$this
->
request
->
getPost
(
'rowCount'
,
'int'
,
9999
);
$currentPage
=
$this
->
request
->
getPost
(
'current'
,
'int'
,
1
);
if
(
$this
->
request
->
getPost
(
'searchPhrase'
,
'string'
,
''
)
!=
""
)
{
$searchPhrase
=
'alert,src_ip/"*'
.
$this
->
request
->
getPost
(
'searchPhrase'
,
'string'
,
''
)
.
'*"'
;
$filterTag
=
$filter
->
sanitize
(
$this
->
request
->
getPost
(
'searchPhrase'
),
"query"
);
$searchPhrase
=
'alert,src_ip/"*'
.
$filterTag
.
'*"'
;
}
else
{
$searchPhrase
=
''
;
}
...
...
src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php
View file @
566f2b4b
...
...
@@ -28,7 +28,9 @@
*/
namespace
OPNsense\IDS\Api
;
use
\Phalcon\Filter
;
use
\OPNsense\Base\ApiControllerBase
;
use
\OPNsense\Base\Filters\QueryFilter
;
use
\OPNsense\Core\Backend
;
use
\OPNsense\IDS\IDS
;
use
\OPNsense\Core\Config
;
...
...
@@ -62,6 +64,10 @@ class SettingsController extends ApiControllerBase
{
if
(
$this
->
request
->
isPost
())
{
$this
->
sessionClose
();
// create filter to sanitize input data
$filter
=
new
Filter
();
$filter
->
add
(
'query'
,
new
QueryFilter
());
// fetch query parameters
$itemsPerPage
=
$this
->
request
->
getPost
(
'rowCount'
,
'int'
,
9999
);
...
...
@@ -80,20 +86,22 @@ class SettingsController extends ApiControllerBase
if
(
$sortStr
!=
''
)
{
$sortStr
.=
','
;
}
$sortStr
.=
$
sortKey
.
' '
.
$sortOrd
.
' '
;
$sortStr
.=
$
filter
->
sanitize
(
$sortKey
,
"query"
)
.
' '
.
$sortOrd
.
' '
;
}
}
else
{
$sortStr
=
'sid'
;
}
if
(
$this
->
request
->
getPost
(
'searchPhrase'
,
'string'
,
''
)
!=
""
)
{
$searchPhrase
=
'msg,classtype,source,sid/"%'
.
$this
->
request
->
getPost
(
'searchPhrase'
,
'string'
,
''
)
.
'"'
;
$searchTag
=
$filter
->
sanitize
(
$this
->
request
->
getPost
(
'searchPhrase'
),
"query"
);
$searchPhrase
=
'msg,classtype,source,sid/"*'
.
$searchTag
.
'"'
;
}
else
{
$searchPhrase
=
''
;
}
// add filter for classtype
if
(
$this
->
request
->
getPost
(
"classtype"
,
"string"
,
''
)
!=
""
)
{
$searchPhrase
.=
"classtype/"
.
$this
->
request
->
getPost
(
"classtype"
,
"string"
,
''
)
.
' '
;
$searchTag
=
$filter
->
sanitize
(
$this
->
request
->
getPost
(
'classtype'
),
"query"
);
$searchPhrase
.=
"classtype/"
.
$searchTag
.
' '
;
}
// request list of installed rules
...
...
@@ -114,6 +122,7 @@ class SettingsController extends ApiControllerBase
$result
[
'rowCount'
]
=
count
(
$result
[
'rows'
]);
$result
[
'total'
]
=
$data
[
'total_rows'
];
$result
[
'parameters'
]
=
$data
[
'parameters'
];
$result
[
'current'
]
=
(
int
)
$currentPage
;
return
$result
;
}
else
{
...
...
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