Skip to content
Open
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
9 changes: 5 additions & 4 deletions server/secops/secops_mcp/tools/security_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"""Security Operations MCP tools for security rules."""

import logging
from datetime import datetime, timedelta, timezone
from typing import Any, Dict, Optional

from secops_mcp.server import get_chronicle_client, server


# Configure logging
logger = logging.getLogger('secops-mcp')

Expand Down Expand Up @@ -555,11 +555,12 @@ async def test_rule(
chronicle = get_chronicle_client(project_id, customer_id, region)

# Define time range for testing
from datetime import datetime, timedelta, timezone
end_time = datetime.now(timezone.utc)
current_time = datetime.now(timezone.utc)
# Buffer back to the start of the current hour
end_time = current_time.replace(minute=0, second=0, microsecond=0) # Rounds down to the start of current hour
start_time = end_time - timedelta(hours=hours_back)

logger.info(f'Rule test time range: {start_time} to {end_time}')
logger.info(f'Rule test time range: {start_time} to {end_time} (buffered to start of current hour)')

# Test the rule
test_results = chronicle.run_rule_test(
Expand Down