Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions tests/test_cisco_asa.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
# Apr 15 2017 00:22:42 192.168.12.1 : %ASA-3-710003: TCP access denied by ACL from 179.236.133.160/8949 to outside:72.142.18.38/23
@pytest.mark.addons("cisco")
def test_cisco_asa_traditional(
record_property, setup_splunk, setup_sc4s
record_property, get_host_key, setup_splunk, setup_sc4s
):
host = f"{shortuuid.ShortUUID().random(length=5).lower()}-{shortuuid.ShortUUID().random(length=5).lower()}"
host = f"asa-{get_host_key}"

dt = datetime.datetime.now(datetime.timezone.utc)
_, bsd, _, _, _, _, epoch = time_operations(dt)
Expand Down Expand Up @@ -155,8 +155,8 @@ def test_cisco_asa_traditional_nohost(

# <166>2018-06-27T12:17:46Z asa : %ASA-3-710003: TCP access denied by ACL from 179.236.133.160/8949 to outside:72.142.18.38/23
@pytest.mark.addons("cisco")
def test_cisco_asa_rfc5424(record_property, setup_splunk, setup_sc4s):
host = f"{shortuuid.ShortUUID().random(length=5).lower()}-{shortuuid.ShortUUID().random(length=5).lower()}"
def test_cisco_asa_rfc5424(record_property, get_host_key, setup_splunk, setup_sc4s):
host = f"asa-{get_host_key}"

# Get UTC-based 'dt' time structure
dt = datetime.datetime.now(datetime.timezone.utc)
Expand Down Expand Up @@ -190,8 +190,8 @@ def test_cisco_asa_rfc5424(record_property, setup_splunk, setup_sc4s):

# <118>2020-02-04T11:00:54Z %FTD-6-430003: DeviceUUID: 90e14378-2081-11e8-a7fa-d34972ba379f, AccessControlRuleAction: Allow, SrcIP: 75.150.94.75, DstIP: 172.30.0.2, SrcPort: 59698, DstPort: 8027, Protocol: tcp, IngressInterface: Outside2, EgressInterface: DMZ, IngressZone: Outside, EgressZone: DMZ, ACPolicy: Rapid7 5525X, AccessControlRuleName: Allow MDM - Out to DMZ, Prefilter Policy: Default Prefilter Policy, User: No Authentication Required, ConnectionDuration: 600, InitiatorPackets: 0, ResponderPackets: 0, InitiatorBytes: 31, ResponderBytes: 0, NAPPolicy: Balanced Security and Connectivity
@pytest.mark.addons("cisco")
def test_cisco_ftd(record_property, setup_splunk, setup_sc4s):
host = f"{shortuuid.ShortUUID().random(length=5).lower()}-{shortuuid.ShortUUID().random(length=5).lower()}"
def test_cisco_ftd(record_property, get_host_key, setup_splunk, setup_sc4s):
host = f"ftd-{get_host_key}"

# Get UTC-based 'dt' time structure
dt = datetime.datetime.now(datetime.timezone.utc)
Expand Down
6 changes: 2 additions & 4 deletions tests/test_cisco_fwsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# Use of this source code is governed by a BSD-2-clause-style
# license that can be found in the LICENSE-BSD2 file or at
# https://opensource.org/licenses/BSD-2-Clause
import shortuuid

from jinja2 import Environment, select_autoescape
import pytest

Expand All @@ -19,9 +17,9 @@
# Apr 15 2017 00:22:42 192.168.12.1 : %FWSM-6-106100: access-list outside-access-in ##permission## ##transport## outside/XXX.XXX.XXX.XXX(##port_1##) -> inside/XXX.XXX.XXX.XXX(9997) hit-cnt 1 (first hit) [0xe0ba389d, 0x0]
@pytest.mark.addons("cisco")
def test_cisco_fwsm_traditional(
record_property, setup_splunk, setup_sc4s
record_property, get_host_key, setup_splunk, setup_sc4s
):
host = f"{shortuuid.ShortUUID().random(length=5).lower()}-{shortuuid.ShortUUID().random(length=5).lower()}"
host = f"fwsm-{get_host_key}"

dt = datetime.datetime.now(datetime.timezone.utc)
_, bsd, _, _, _, _, epoch = time_operations(dt)
Expand Down
30 changes: 18 additions & 12 deletions tests/test_cisco_ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
env = Environment(autoescape=select_autoescape(default_for_string=False))


@pytest.fixture
def cisco_host_key(get_host_key):
# The Cisco parser skips hostname candidates that start with four or more digits.
return f"ios-{get_host_key}"


# 30: foo: 6340004: *Mar 4 11:45:20: %SEC-6-IPACCESSLOGP: list INET-BLOCK permitted tcp 192.168.20.252(55244) -> 10.54.3.178(44818), 1 packet
# 30: foo: *Apr 29 13:58:46.000001: %SYS-6-LOGGINGHOST_STARTSTOP: Logging to host 192.168.1.239 stopped - CLI initiated
# 30: foo: *Apr 29 13:58:46.411: %SYS-6-LOGGINGHOST_START STOP: Logging to host 192.168.1.239 stopped - CLI initiated
Expand Down Expand Up @@ -189,8 +195,8 @@ def adjust_epoch_by_timezone_context(epoch, abbr):

@pytest.mark.parametrize("event", testdata)
@pytest.mark.addons("cisco")
def test_cisco_ios(record_property, get_host_key, setup_splunk, setup_sc4s, event):
host = get_host_key
def test_cisco_ios(record_property, cisco_host_key, setup_splunk, setup_sc4s, event):
host = cisco_host_key

dt = datetime.datetime.now(datetime.timezone.utc)
iso, bsd, time, _, _, tzname, epoch = time_operations(dt)
Expand Down Expand Up @@ -236,9 +242,9 @@ def test_cisco_ios(record_property, get_host_key, setup_splunk, setup_sc4s, even
@pytest.mark.parametrize("event", testdata_badtime)
@pytest.mark.addons("cisco")
def test_cisco_ios_badtime(
record_property, get_host_key, setup_splunk, setup_sc4s, event
record_property, cisco_host_key, setup_splunk, setup_sc4s, event
):
host = get_host_key
host = cisco_host_key

dt = datetime.datetime.now(datetime.timezone.utc)
iso, bsd, time, _, _, tzname, epoch = time_operations(dt)
Expand Down Expand Up @@ -283,9 +289,9 @@ def test_cisco_ios_badtime(
@pytest.mark.parametrize("event", testdata_uptime)
@pytest.mark.addons("cisco")
def test_cisco_ios_uptime(
record_property, get_host_key, setup_splunk, setup_sc4s, event
record_property, cisco_host_key, setup_splunk, setup_sc4s, event
):
host = get_host_key
host = cisco_host_key

mt = env.from_string(event + "\n")
message = mt.render(mark="<166>", seq=20, host=host)
Expand All @@ -307,8 +313,8 @@ def test_cisco_ios_uptime(


@pytest.mark.addons("cisco")
def test_cisco_nx_os_soup(record_property, get_host_key, setup_splunk, setup_sc4s):
host = get_host_key
def test_cisco_nx_os_soup(record_property, cisco_host_key, setup_splunk, setup_sc4s):
host = cisco_host_key

dt = datetime.datetime.now(datetime.timezone.utc)
_, bsd, time, date, tzoffset, _, epoch = time_operations(dt)
Expand Down Expand Up @@ -341,8 +347,8 @@ def test_cisco_nx_os_soup(record_property, get_host_key, setup_splunk, setup_sc4

# <187>364241: May 19 16:58:44.814 GMT: %ADJ-3-RESOLVE_REQ: Adj resolve request: Failed to resolve 1.1.1.1 Vlan1
@pytest.mark.addons("cisco")
def test_cisco_nx_os_soup2(record_property, get_host_key, setup_splunk, setup_sc4s):
host = get_host_key
def test_cisco_nx_os_soup2(record_property, cisco_host_key, setup_splunk, setup_sc4s):
host = cisco_host_key

dt = datetime.datetime.now(datetime.timezone.utc)
_, bsd, time, date, tzoffset, _, epoch = time_operations(dt)
Expand Down Expand Up @@ -586,8 +592,8 @@ def test_cisco_ios_xr_hostname_with_underscore(

@pytest.mark.parametrize("event", testdata_timezone)
@pytest.mark.addons("cisco")
def test_cisco_ios_tz(record_property, get_host_key, setup_splunk, setup_sc4s, event):
host = get_host_key
def test_cisco_ios_tz(record_property, cisco_host_key, setup_splunk, setup_sc4s, event):
host = cisco_host_key

dt = datetime.datetime.now(datetime.timezone.utc)
iso, bsd, time, _, _, tzname, epoch = time_operations(dt)
Expand Down
6 changes: 2 additions & 4 deletions tests/test_cisco_pix.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# Use of this source code is governed by a BSD-2-clause-style
# license that can be found in the LICENSE-BSD2 file or at
# https://opensource.org/licenses/BSD-2-Clause
import shortuuid

from jinja2 import Environment, select_autoescape
import pytest

Expand All @@ -19,9 +17,9 @@
# Apr 15 2017 00:22:42 192.168.12.1 : %FWSM-6-106100: access-list outside-access-in ##permission## ##transport## outside/XXX.XXX.XXX.XXX(##port_1##) -> inside/XXX.XXX.XXX.XXX(9997) hit-cnt 1 (first hit) [0xe0ba389d, 0x0]
@pytest.mark.addons("cisco")
def test_cisco_pix_traditional(
record_property, setup_splunk, setup_sc4s
record_property, get_host_key, setup_splunk, setup_sc4s
):
host = f"{shortuuid.ShortUUID().random(length=5).lower()}-{shortuuid.ShortUUID().random(length=5).lower()}"
host = f"pix-{get_host_key}"

dt = datetime.datetime.now(datetime.timezone.utc)
_, bsd, _, _, _, _, epoch = time_operations(dt)
Expand Down
5 changes: 2 additions & 3 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,8 @@ def test_metrics(record_property, setup_splunk, setup_sc4s):
assert result_count != 0


def test_tz_guess(record_property, setup_splunk, setup_sc4s):

host = f"{shortuuid.ShortUUID().random(length=5).lower()}-{shortuuid.ShortUUID().random(length=5).lower()}"
def test_tz_guess(record_property, get_host_key, setup_splunk, setup_sc4s):
host = f"test-host-{get_host_key}"

dt = datetime.datetime.now(datetime.timezone.utc)
_, bsd, time, date, tzoffset, _, epoch = time_operations(dt)
Expand Down
Loading