11"""Tests for the step9_generate_email_bodies module."""
22
3+ import re
34import tempfile
45from pathlib import Path
56from 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