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
8cb86cc7
Commit
8cb86cc7
authored
Nov 19, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(IDS) add action to backend rule cache
parent
bd2ca802
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
rulecache.py
src/opnsense/scripts/suricata/lib/rulecache.py
+6
-3
No files found.
src/opnsense/scripts/suricata/lib/rulecache.py
View file @
8cb86cc7
...
@@ -43,7 +43,7 @@ class RuleCache(object):
...
@@ -43,7 +43,7 @@ class RuleCache(object):
def
__init__
(
self
):
def
__init__
(
self
):
# suricata rule settings, source directory and cache json file to use
# suricata rule settings, source directory and cache json file to use
self
.
cachefile
=
'
%
srules.sqlite'
%
rule_source_directory
self
.
cachefile
=
'
%
srules.sqlite'
%
rule_source_directory
self
.
_rule_fields
=
[
'sid'
,
'msg'
,
'classtype'
,
'rev'
,
'gid'
,
'source'
,
'enabled'
,
'reference'
]
self
.
_rule_fields
=
[
'sid'
,
'msg'
,
'classtype'
,
'rev'
,
'gid'
,
'source'
,
'enabled'
,
'reference'
,
'action'
]
self
.
_rule_defaults
=
{
'classtype'
:
'##none##'
}
self
.
_rule_defaults
=
{
'classtype'
:
'##none##'
}
@
staticmethod
@
staticmethod
...
@@ -67,6 +67,9 @@ class RuleCache(object):
...
@@ -67,6 +67,9 @@ class RuleCache(object):
record
=
{
'enabled'
:
True
,
'source'
:
filename
.
split
(
'/'
)[
-
1
]}
record
=
{
'enabled'
:
True
,
'source'
:
filename
.
split
(
'/'
)[
-
1
]}
if
rule
.
strip
()[
0
]
==
'#'
:
if
rule
.
strip
()[
0
]
==
'#'
:
record
[
'enabled'
]
=
False
record
[
'enabled'
]
=
False
record
[
'action'
]
=
rule
.
strip
()[
1
:]
.
split
(
' '
)[
0
]
.
replace
(
'#'
,
''
)
else
:
record
[
'action'
]
=
rule
.
strip
()
.
split
(
' '
)[
0
]
rule_metadata
=
rule
[
rule
.
find
(
'msg:'
):
-
1
]
rule_metadata
=
rule
[
rule
.
find
(
'msg:'
):
-
1
]
for
field
in
rule_metadata
.
split
(
';'
):
for
field
in
rule_metadata
.
split
(
';'
):
...
@@ -137,8 +140,8 @@ class RuleCache(object):
...
@@ -137,8 +140,8 @@ class RuleCache(object):
cur
=
db
.
cursor
()
cur
=
db
.
cursor
()
cur
.
execute
(
'CREATE TABLE stats (timestamp number, files number)'
)
cur
.
execute
(
'CREATE TABLE stats (timestamp number, files number)'
)
cur
.
execute
(
"""CREATE TABLE rules (sid number, msg TEXT, classtype TEXT,
cur
.
execute
(
"""CREATE TABLE rules (sid number, msg TEXT, classtype TEXT,
rev INTEGER, gid INTEGER,reference TEXT,
rev INTEGER, gid INTEGER,
reference TEXT,
enabled BOOLEAN,source TEXT)"""
)
enabled BOOLEAN,
action text,
source TEXT)"""
)
last_mtime
=
0
last_mtime
=
0
all_rule_files
=
self
.
list_local
()
all_rule_files
=
self
.
list_local
()
...
...
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