Skip to content

Commit f1f162f

Browse files
Fix code scanning alert - Incomplete URL substring sanitization #4
- Closes #4 - Bump version: 0.1.10
1 parent ec9136e commit f1f162f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "platform_problem_monitoring_core"
7-
version = "0.1.9"
7+
version = "0.1.10"
88
description = "A tool for monitoring platform problems using Elasticsearch logs"
99
authors = [
1010
{name = "Platform Team"}

src/tests/test_step9_generate_email_bodies.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Tests for the step9_generate_email_bodies module."""
22

3+
import re
34
import tempfile
45
from pathlib import Path
56
from typing import Any, Dict
@@ -265,7 +266,10 @@ def test_generate_sample_links_html(self, sample_pattern: Dict[str, Any]) -> Non
265266
assert "Sample 1" in result
266267
assert "Sample 2" in result
267268
assert "Sample 3" in result
268-
assert "https://kibana.example.com" in result
269+
270+
# Use a more secure pattern matching approach
271+
href_pattern = re.compile(r'href=["\'](https://kibana\.example\.com[^"\']*)["\']')
272+
assert href_pattern.search(result) is not None, "URL not found in proper href attribute context"
269273

270274
def test_generate_pattern_list_html(self, sample_pattern: Dict[str, Any]) -> None:
271275
"""Test generate_pattern_list_html function."""
@@ -279,6 +283,11 @@ def test_generate_pattern_list_html(self, sample_pattern: Dict[str, Any]) -> Non
279283
assert str(sample_pattern["count"]) in html
280284
assert "Sample 1" in html
281285

286+
# More secure URL check in sample links
287+
if kibana_url:
288+
href_pattern = re.compile(r'href=["\'](https://kibana\.example\.com[^"\']*)["\']')
289+
assert href_pattern.search(html) is not None, "URL not found in proper href attribute context"
290+
282291
# Check dark mode HTML
283292
assert '<div class="pattern-item">' in dark_html
284293
assert sample_pattern["pattern"] in dark_html

0 commit comments

Comments
 (0)