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
5c20dd7a
Commit
5c20dd7a
authored
Jan 29, 2016
by
Ad Schellevis
Committed by
Franco Fichtner
Jan 31, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(ids) obey configured output filename is source is different
(cherry picked from commit
585e1b10
)
parent
014c65b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
downloader.py
src/opnsense/scripts/suricata/lib/downloader.py
+3
-2
rule-updater.py
src/opnsense/scripts/suricata/rule-updater.py
+3
-1
No files found.
src/opnsense/scripts/suricata/lib/downloader.py
View file @
5c20dd7a
...
@@ -62,18 +62,19 @@ class Downloader(object):
...
@@ -62,18 +62,19 @@ class Downloader(object):
output
.
append
(
line
)
output
.
append
(
line
)
return
'
\n
'
.
join
(
output
)
return
'
\n
'
.
join
(
output
)
def
download
(
self
,
proto
,
url
,
input_filter
):
def
download
(
self
,
proto
,
url
,
filename
,
input_filter
):
""" download ruleset file
""" download ruleset file
:param proto: protocol (http,https)
:param proto: protocol (http,https)
:param url: download url
:param url: download url
:param filename: target filename
:param input_filter: filter to use on received data before save
:param input_filter: filter to use on received data before save
"""
"""
if
proto
in
(
'http'
,
'https'
):
if
proto
in
(
'http'
,
'https'
):
frm_url
=
url
.
replace
(
'//'
,
'/'
)
.
replace
(
':/'
,
'://'
)
frm_url
=
url
.
replace
(
'//'
,
'/'
)
.
replace
(
':/'
,
'://'
)
req
=
requests
.
get
(
url
=
frm_url
)
req
=
requests
.
get
(
url
=
frm_url
)
if
req
.
status_code
==
200
:
if
req
.
status_code
==
200
:
target_filename
=
(
'
%
s/
%
s'
%
(
self
.
_target_dir
,
frm_url
.
split
(
'/'
)[
-
1
]))
.
replace
(
'//'
,
'/'
)
try
:
try
:
target_filename
=
'
%
s/
%
s'
%
(
self
.
_target_dir
,
filename
)
save_data
=
self
.
filter
(
req
.
text
,
input_filter
)
save_data
=
self
.
filter
(
req
.
text
,
input_filter
)
open
(
target_filename
,
'wb'
)
.
write
(
save_data
)
open
(
target_filename
,
'wb'
)
.
write
(
save_data
)
except
IOError
:
except
IOError
:
...
...
src/opnsense/scripts/suricata/rule-updater.py
View file @
5c20dd7a
...
@@ -62,6 +62,7 @@ if __name__ == '__main__':
...
@@ -62,6 +62,7 @@ if __name__ == '__main__':
else
:
else
:
enabled_rulefiles
[
section
.
strip
()][
'filter'
]
=
""
enabled_rulefiles
[
section
.
strip
()][
'filter'
]
=
""
# download / remove rules
# download / remove rules
md
=
metadata
.
Metadata
()
md
=
metadata
.
Metadata
()
dl
=
downloader
.
Downloader
(
target_dir
=
rule_source_directory
)
dl
=
downloader
.
Downloader
(
target_dir
=
rule_source_directory
)
...
@@ -77,4 +78,5 @@ if __name__ == '__main__':
...
@@ -77,4 +78,5 @@ if __name__ == '__main__':
pass
pass
else
:
else
:
input_filter
=
enabled_rulefiles
[
rule
[
'filename'
]][
'filter'
]
input_filter
=
enabled_rulefiles
[
rule
[
'filename'
]][
'filter'
]
dl
.
download
(
proto
=
download_proto
,
url
=
rule
[
'url'
],
input_filter
=
input_filter
)
dl
.
download
(
proto
=
download_proto
,
url
=
rule
[
'url'
],
filename
=
rule
[
'filename'
],
input_filter
=
input_filter
)
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