Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request for upstream PR #1

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a7da753
Don't use tempfile.NamedTemporaryFile()
henridf Nov 8, 2020
820c282
use shutil.move instead of os.rename
henridf Nov 9, 2020
98a4c39
Revert "Don't use tempfile.NamedTemporaryFile()"
henridf Dec 1, 2020
0b10a83
Fix file writing for Windows
henridf Dec 1, 2020
1f9cfa5
github-ci: remove CentOS 6 build
jasonish Jan 27, 2021
726c121
github-ci: fix MacOS test
jasonish Jan 27, 2021
fa8fb27
fix: fix --no-merge option
jasonish Feb 15, 2021
019400c
changelog: update
jasonish Feb 17, 2021
518b61c
doc: remove --merged option
jasonish Feb 23, 2021
50e857f
version: 1.2.1
jasonish Feb 23, 2021
884d0c9
version: 1.3.0dev0
jasonish Apr 13, 2021
7fafdca
HTTP BasicAuth support.
e-cite Feb 25, 2021
b9b5ef1
tests: add integration test for --http-header
jasonish Apr 13, 2021
6ce306a
travis-ci: remove, appears they haven't been building
jasonish Apr 13, 2021
07f69af
github-ci: add fedora 33, remove fedora 31 (eol)
jasonish Apr 13, 2021
f199285
github-ci: add Ubuntu 20.04
jasonish Apr 13, 2021
c68baf1
changelog: update
jasonish Apr 13, 2021
7e472b5
conf: allow no-test in configuration file
jasonish May 18, 2021
9364b5a
testing: remove python 3.5, add python 3.8
jasonish May 18, 2021
5829e0b
changelog: update
jasonish May 18, 2021
74c3e6d
Use HTTP-Headers for checksum request
itbane Jul 16, 2021
720ec56
tests: fix checksum test for new argument type
jasonish Oct 7, 2021
a120096
Allow more characters in the custom headers
JacobRoed Sep 22, 2021
eebba20
changelog: update
jasonish Oct 7, 2021
e8f7715
doc: fix formatting error
jasonish Oct 7, 2021
947a4dd
Doc: Improve documentation of Suricata reload.
e-cite Jul 26, 2021
fd3b36d
index: allow custom url for embedded index update
jasonish Oct 28, 2021
2e08c36
integration tests: format
jasonish Dec 29, 2021
f3d6d1b
tests: add integration tests for multiple modifications
jasonish Dec 29, 2021
a4694f7
Fix multiple modifications not having an affect.
jasonish Dec 29, 2021
ba4dc11
Fix counter accuracy.
jasonish Dec 29, 2021
6eb0ac2
changelog: update
jasonish Jan 5, 2022
00d1b73
trivial typo in comment
atz Nov 18, 2021
1ea7327
logging: Improve flowbit logs
Riju19 Oct 16, 2020
edb88e5
doc: add --show-advanced to common options
TharushiJay Oct 17, 2020
afe9257
help output: hide advanced options behind a flag
TharushiJay Oct 15, 2020
cb2df52
Add warning to update sources if no index found
TharushiJay Oct 8, 2020
39a2624
changelog: update
jasonish Jan 7, 2022
6f6d8dc
github-ci: convert centos 8 build to almalinux 8
jasonish Mar 28, 2022
8159187
github-ci: update fedora tests to f34 and f35
jasonish Mar 28, 2022
099754b
checkversions: fix wrong version checks
inashivb Dec 29, 2021
353dd22
changelog: add fix for issue 4373
jasonish Mar 28, 2022
4fb4ea4
Merge pull request #1 from brimdata/fix-windows
joba-1 Apr 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 32 additions & 34 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ on:

jobs:

centos-8:
name: CentOS 8
alma-8:
name: AlmaLinux 8
runs-on: ubuntu-latest
container: centos:8
container: almalinux:8
steps:
- run: |
yum -y install \
Expand Down Expand Up @@ -54,58 +54,58 @@ jobs:
- name: Python 3 integration tests
run: PYTHONPATH=. python3 ./tests/integration_tests.py

centos-6:
name: CentOS 6
fedora-34:
name: Fedora 34
runs-on: ubuntu-latest
container: centos:6
container: fedora:34
steps:
- run: yum -y install epel-release
- run: |
yum -y install \
python34-pytest \
python34-yaml
- uses: actions/checkout@v1
python3 \
python3-pytest \
python3-pyyaml
- uses: actions/checkout@v2

- name: Python 3 unit tests
run: PYTHONPATH=. py.test-3
run: PYTHONPATH=. pytest-3
- name: Python 3 integration tests
run: PYTHONPATH=. python3 ./tests/integration_tests.py

fedora-31:
name: Fedora 31
fedora-35:
name: Fedora 35
runs-on: ubuntu-latest
container: fedora:31
container: fedora:35
steps:
- run: |
yum -y install \
python2-pytest \
python2-pyyaml \
python3 \
python3-pytest \
python3-pyyaml
- uses: actions/checkout@v1

- name: Python 2 unit tests
run: PYTHONPATH=. pytest-2
- name: Python 2 integration tests
run: PYTHONPATH=. python2 ./tests/integration_tests.py
- uses: actions/checkout@v2

- name: Python 3 unit tests
run: PYTHONPATH=. pytest-3
- name: Python 3 integration tests
run: PYTHONPATH=. python3 ./tests/integration_tests.py

fedora-32:
name: Fedora 32
ubuntu-2004:
name: Ubuntu 20.04
runs-on: ubuntu-latest
container: fedora:32
container: ubuntu:20.04
steps:
- run: apt update
- run: |
yum -y install \
python3 \
apt -y install \
python-pytest \
python-yaml \
python3-pytest \
python3-pyyaml
- uses: actions/checkout@v2
python3-yaml
- uses: actions/checkout@v1

- name: Python 2 unit tests
run: PYTHONPATH=. pytest
- name: Python 2 integration tests
run: PYTHONPATH=. python2 ./tests/integration_tests.py

- name: Python 3 unit tests
run: PYTHONPATH=. pytest-3
Expand Down Expand Up @@ -213,10 +213,8 @@ jobs:
runs-on: macos-latest
steps:
- run: brew install python
- run: pip install PyYAML
- run: pip install pytest
- run: pip3 install PyYAML
- run: pip3 install pytest
- uses: actions/checkout@v1
- run: PYTHONPATH=. pytest
- run: PYTHONPATH=. python ./tests/integration_tests.py


- run: PYTHONPATH=. python3 ./tests/integration_tests.py
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Change Log

## unreleased
- Be consistent about warning about old index. The index won't be automatically
updated now in some cases and not in others. Instead opt to never
auto-update: https://redmine.openinfosecfoundation.org/issues/3249
- Better flowbit resolution logging in verbose mode
https://redmine.openinfosecfoundation.org/issues/3205
- Hide advanced command line options from help output:
https://redmine.openinfosecfoundation.org/issues/3974
- Fix multiple modifications to a rule:
https://redmine.openinfosecfoundation.org/issues/4259
- Allow spaces in custom HTTP headers. Redmine issue
https://redmine.openinfosecfoundation.org/issues/4362
- Fix "no-test" when set in configuration file:
https://redmine.openinfosecfoundation.org/issues/4493
- Allow more custom characters in custom http header to allow for more
of the base64 character set:
https://redmine.openinfosecfoundation.org/issues/4701
- Send custom HTTP headers with check for remote checksum file:
https://redmine.openinfosecfoundation.org/issues/4001
- Fix "check-versions" where the running Suricata is newer than what the index
knows about: https://redmine.openinfosecfoundation.org/issues/4373

## 1.2.1 - 2021-02-23
- Fix --no-merge. Redmine issue
https://redmine.openinfosecfoundation.org/issues/4324.

## 1.2.0 - 2020-10-05
- Documentation updates.

Expand Down
10 changes: 10 additions & 0 deletions doc/add-source.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ Options
as a custom API key. Example::

add-source --http-header "X-API-Key: 1234"

HTTP basic authentication can be achieved by setting the HTTP Basic
Authentication header with ``base64(user1:password1)``. Example::

add-source --http-header "Authorization: Basic dXNlcjE6cGFzc3dvcmQx"

HTTP Bearer authentication can be used by setting the HTTP Bearer Authentication header
with a OAuth2 token containing printable ASCII characters. Example::

add-source --http-header "Auhorization: Bearer NjA2MTUOTAx?D+wOm4U/vpXQy0xhl!hSaR7#ENVpK59"

.. option:: --no-checksum

Expand Down
5 changes: 5 additions & 0 deletions doc/common-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,8 @@
.. option:: --user-agent <string>

Set a custom user agent string for HTTP requests.

.. option:: -s, --show-advanced

Show advanced options.

3 changes: 2 additions & 1 deletion doc/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ This command will:

.. note:: Suricata-Update is also capable of triggering a rule reload,
but doing so requires some extra configuration that will be
covered later.
covered later. See the documentation of
:command:`--reload-command=<command>` for more details.

Configure Suricata to Load Suricata-Update Managed Rules
========================================================
Expand Down
23 changes: 16 additions & 7 deletions doc/update.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ Options
be due to just recently downloaded, or the remote checksum matching
the cached copy.

.. option:: --merged=<filename>

Write a single file containing all rules. This can be used in
addition to ``--output`` or instead of ``--output``.

.. option:: --no-merge

Do not merge the rules into a single rule file.
Expand Down Expand Up @@ -158,12 +153,26 @@ Options
.. option:: --reload-command=<command>

A command to run after the rules have been updated; will not run if
no change to the output files was made. For example::
no change to the output files was made. For example::

--reload-command='sudo kill -USR2 $(cat /var/run/suricata.pid)'
--reload-command='sudo kill -USR2 $(pidof suricata)'

will tell Suricata to reload its rules.

Furthermore the reload can be triggered using the Unix socket of Suricata.

Blocking reload (with Suricata waiting for the reload to finish)::

--reload-command='sudo suricatasc -c reload-rules'

Non blocking reload (without restarting Suricata)::

--reload-command='sudo suricatasc -c ruleset-reload-nonblocking'

See the Suricata documentation on `Rule Reloads
<https://suricata.readthedocs.io/en/latest/rule-management/rule-reload.html>`_
for more information.

.. option:: --no-reload

Disable Suricata rule reload.
Expand Down
22 changes: 21 additions & 1 deletion suricata/update/commands/checkversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@
logger = logging.getLogger()


def is_gt(v1, v2):
if v1.full == v2.full:
return False

if v1.major < v2.major:
return False
elif v1.major > v2.major:
return True

if v1.minor < v2.minor:
return False
elif v1.minor > v2.minor:
return True

if v1.patch < v2.patch:
return False

return True


def register(parser):
parser.set_defaults(func=check_version)

Expand All @@ -42,7 +62,7 @@ def check_version(suricata_version):
logger.error("Recommended version was not parsed properly")
sys.exit(1)
# In case index is out of date
if float(suricata_version.short) > float(recommended.short):
if is_gt(suricata_version, recommended):
return
# Evaluate if the installed version is present in index
upgrade_version = version["suricata"].get(suricata_version.short)
Expand Down
2 changes: 1 addition & 1 deletion suricata/update/commands/disablesource.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ def disable_source():
logger.warning("Source %s is not enabled.", name)
return 0
logger.debug("Renaming %s to %s.disabled.", filename, filename)
os.rename(filename, "%s.disabled" % (filename))
shutil.move(filename, "%s.disabled" % (filename))
logger.info("Source %s has been disabled", name)
2 changes: 1 addition & 1 deletion suricata/update/commands/enablesource.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def enable_source():
disabled_source_filename = sources.get_disabled_source_filename(name)
if os.path.exists(disabled_source_filename):
logger.info("Re-enabling previously disabled source for %s.", name)
os.rename(disabled_source_filename, enabled_source_filename)
shutil.move(disabled_source_filename, enabled_source_filename)
update_params = True

if not os.path.exists(sources.get_index_filename()):
Expand Down
9 changes: 3 additions & 6 deletions suricata/update/commands/listsources.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from suricata.update import config
from suricata.update import sources
from suricata.update import util
from suricata.update.commands.updatesources import update_sources
from suricata.update import exceptions

logger = logging.getLogger()
Expand Down Expand Up @@ -72,11 +71,9 @@ def list_sources():

free_only = config.args().free
if not sources.source_index_exists(config):
logger.info("No source index found, running update-sources")
try:
update_sources()
except exceptions.ApplicationError as err:
logger.warning("%s: will use bundled index.", err)
logger.warning("Source index does not exist, will use bundled one.")
logger.warning("Please run suricata-update update-sources.")

index = sources.load_source_index(config)
for name, source in index.get_sources().items():
is_not_free = source.get("subscribe-url")
Expand Down
2 changes: 2 additions & 0 deletions suricata/update/configs/update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ ignore:

# Provide a command to reload the Suricata rules.
# May be overrided by the --reload-command command line option.
# See the documentation of --reload-command for the different options
# to reload Suricata rules.
#reload-command: sudo systemctl reload suricata

# Remote rule sources. Simply a list of URLs.
Expand Down
8 changes: 7 additions & 1 deletion suricata/update/data/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# 02110-1301, USA.

import os.path
import sys

try:
from urllib2 import urlopen
Expand All @@ -23,11 +24,16 @@

import yaml

DEFAULT_URL = "https://raw.githubusercontent.com/oisf/suricata-intel-index/master/index.yaml"

def embed_index():
"""Embed a copy of the index as a Python source file. We can't use a
datafile yet as there is no easy way to do with distutils."""
if len(sys.argv) > 1:
url = sys.argv[1]
else:
url = DEFAULT_URL
dist_filename = os.path.join(os.path.dirname(__file__), "index.py")
url = "https://raw.githubusercontent.com/oisf/suricata-intel-index/master/index.yaml"
response = urlopen(url)
index = yaml.safe_load(response.read())

Expand Down
Loading