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
4 changes: 2 additions & 2 deletions pytest_splunk_addon/addon_parser/props_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def _get_extract_fields(self, name: str, value: str):
yield field

# If SOURCE_KEY is used in EXTRACT, generate the test for the same.
regex_for_source_key = r"(?:(?i)in\s+(\w+))\s*$"
regex_for_source_key = r"(?i)(?:in\s+(\w+))\s*$"
extract_source_key = re.search(regex_for_source_key, value, re.MULTILINE)
if extract_source_key:
LOGGER.info(f"Found a source key in {name}")
Expand Down Expand Up @@ -260,7 +260,7 @@ def _get_fieldalias_fields(self, name: str, value: str):
"""
regex = (
r"(\"(?:\\\"|[^\"])*\"|\'(?:\\\'|[^\'])*\'|[^\s,]+)"
r"\s+(?i)(?:as(?:new)?)\s+"
r"\s+(?:as(?:new)?)\s+"
r"(\"(?:\\\"|[^\"])*\"|\'(?:\\\'|[^\'])*\'|[^\s,]+)"
)
fields_tuples = re.findall(regex, value, re.IGNORECASE)
Expand Down
6 changes: 3 additions & 3 deletions pytest_splunk_addon/sample_generation/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def apply(self, events):
.replace(".", "-")
)
host_split = host.split("-")
if re.match("\d+", host_split[-1]):
if re.match(r"\d+", host_split[-1]):
host = "-".join(host_split[:-1])
new_event.metadata["host"] = "{}-{}".format(
host, event_host_count
Expand Down Expand Up @@ -327,7 +327,7 @@ def replace(self, sample, token_count):
float_match = re.match(r"[Ff]loat\[(-?[\d\.]+):(-?[\d\.]+)\]", self.replacement)
if float_match:
lower_limit, upper_limit = float_match.groups()
precision = re.search("\[-?\d+\.?(\d*):", self.replacement).group(1)
precision = re.search(r"\[-?\d+\.?(\d*):", self.replacement).group(1)
if not precision:
precision = str(1)
for _ in range(token_count):
Expand Down Expand Up @@ -681,7 +681,7 @@ def replace(self, sample, token_count):
yield self.token
for _ in range(token_count):
random_time = datetime.fromtimestamp(
randint(earliest_in_epoch, latest_in_epoch)
randint(int(earliest_in_epoch), int(latest_in_epoch))
)
if timezone_time in ["local", '"local"', "'local'"]:
random_time = random_time.replace(tzinfo=timezone.utc).astimezone(
Expand Down
2 changes: 1 addition & 1 deletion pytest_splunk_addon/sample_generation/sample_stanza.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

LOGGER = logging.getLogger("pytest-splunk-addon")

TIMEZONE_REX = "((\+1[0-2])|(-1[0-4])|[+|-][0][0-9])([0-5][0-9])"
TIMEZONE_REX = r"((\+1[0-2])|(-1[0-4])|[+|-][0][0-9])([0-5][0-9])"
BULK_EVENT_COUNT = 250

token_value = namedtuple("token_value", ["key", "value"])
Expand Down
2 changes: 1 addition & 1 deletion pytest_splunk_addon/splunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ def docker_ip():
if not docker_host:
return "127.0.0.1"

match = re.match("^tcp://(.+?):\d+$", docker_host)
match = re.match(r"^tcp://(.+?):\d+$", docker_host)
if not match:
raise ValueError('Invalid value for DOCKER_HOST: "%s".' % (docker_host,))
return match.group(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_ingestor_can_be_obtained(
ingestor_helper.get_event_ingestor(ingest_method, "ingest_meta_data")
== expected_output
)
assert ingestors_mocks[expected_output].has_calls("ingest_meta_data")
ingestors_mocks[expected_output].assert_called_with("ingest_meta_data")


@pytest.mark.parametrize(
Expand Down
Loading