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
487a9a69
Commit
487a9a69
authored
Jun 23, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(ids) write yaml file for installed rules
parent
0cd3480d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
installRules.py
src/opnsense/scripts/suricata/installRules.py
+11
-0
No files found.
src/opnsense/scripts/suricata/installRules.py
View file @
487a9a69
...
@@ -38,6 +38,7 @@ RuleCache = rulecache.RuleCache()
...
@@ -38,6 +38,7 @@ RuleCache = rulecache.RuleCache()
rule_config_fn
=
(
'
%
s../rules.config'
%
RuleCache
.
rule_source_dir
)
rule_config_fn
=
(
'
%
s../rules.config'
%
RuleCache
.
rule_source_dir
)
rule_target_dir
=
(
'
%
s../opnsense.rules'
%
RuleCache
.
rule_source_dir
)
rule_target_dir
=
(
'
%
s../opnsense.rules'
%
RuleCache
.
rule_source_dir
)
rule_yaml_list
=
(
'
%
s../installed_rules.yaml'
%
RuleCache
.
rule_source_dir
)
# parse OPNsense rule config
# parse OPNsense rule config
rule_updates
=
{}
rule_updates
=
{}
...
@@ -56,6 +57,7 @@ if not os.path.exists(rule_target_dir):
...
@@ -56,6 +57,7 @@ if not os.path.exists(rule_target_dir):
os
.
mkdir
(
rule_target_dir
,
0o755
)
os
.
mkdir
(
rule_target_dir
,
0o755
)
# install ruleset
# install ruleset
all_installed_files
=
[]
for
filename
in
RuleCache
.
listLocal
():
for
filename
in
RuleCache
.
listLocal
():
output_data
=
[]
output_data
=
[]
for
rule_info_record
in
RuleCache
.
listRules
(
filename
=
filename
):
for
rule_info_record
in
RuleCache
.
listRules
(
filename
=
filename
):
...
@@ -79,4 +81,13 @@ for filename in RuleCache.listLocal():
...
@@ -79,4 +81,13 @@ for filename in RuleCache.listLocal():
output_data
.
append
(
rule
)
output_data
.
append
(
rule
)
# write data to file
# write data to file
all_installed_files
.
append
(
filename
.
split
(
'/'
)[
-
1
])
open
(
'
%
s/
%
s'
%
(
rule_target_dir
,
filename
.
split
(
'/'
)[
-
1
]),
'wb'
)
.
write
(
'
\n
'
.
join
(
output_data
))
open
(
'
%
s/
%
s'
%
(
rule_target_dir
,
filename
.
split
(
'/'
)[
-
1
]),
'wb'
)
.
write
(
'
\n
'
.
join
(
output_data
))
# flush all written rule filenames into yaml file
with
open
(
rule_yaml_list
,
'wb'
)
as
f_out
:
f_out
.
write
(
'
%
YAML 1.1
\n
'
)
f_out
.
write
(
'---
\n
'
)
f_out
.
write
(
'rule-files:
\n
'
)
for
installed_file
in
all_installed_files
:
f_out
.
write
(
' -
%
s
\n
'
%
installed_file
)
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