Skip to content

Fix search bar IP validation when using ;maxDays parameter#5

Merged
devnomadic merged 3 commits into
mainfrom
copilot/fix-search-bar-maxdays-validation
Oct 14, 2025
Merged

Fix search bar IP validation when using ;maxDays parameter#5
devnomadic merged 3 commits into
mainfrom
copilot/fix-search-bar-maxdays-validation

Conversation

Copilot AI commented Oct 14, 2025

Copy link
Copy Markdown
Contributor

Issue

The search bar was failing with "Error during search: dns_bad_ip_address" when users entered an IP address with the optional ;maxDays parameter (e.g., 8.8.8.8;60). This prevented users from customizing the abuse report time range when searching cloud IP ranges.

Root Cause

The ValidateAndSearch() method in Pages/Home.razor was attempting to parse the raw user input directly with IPAddress.Parse() without first stripping the ;maxDays suffix. This caused the parser to fail since "8.8.8.8;60" is not a valid IP address format.

While the IsValidIPAddress() validation method correctly handled the semicolon separator, and the AbuseIPDBService.CheckIPAsync() method also properly parsed it, the cloud IP search functionality was missing this extraction step.

Solution

Added IP address extraction logic in the ValidateAndSearch() method to strip the ;maxDays suffix before parsing, matching the pattern already used elsewhere in the codebase:

// Extract just the IP address part (strip ;maxDays if present)
string actualIpAddress = ipAddress.Contains(';') 
    ? ipAddress.Split(';', 2)[0].Trim() 
    : ipAddress.Trim();

// Parse the entered IP address
IPAddress enteredIp = IPAddress.Parse(actualIpAddress);

Testing

The fix has been verified to work with all documented input formats:

  • 8.8.8.8 - Standard IP lookup (30 days of abuse reports)
  • 8.8.8.8;60 - Custom report age (60 days of history) - now works!
  • 2001:4860:4860::8888 - IPv6 addresses supported
  • 2001:4860:4860::8888;90 - IPv6 with custom maxDays - now works!

Both the "Search" button (cloud IP range lookup) and "Check IP Reputation" button (AbuseIPDB lookup) now handle the ;maxDays parameter correctly.

Impact

This is a minimal, surgical fix that adds only 5 lines of code to resolve the issue without affecting any other functionality.

Fixes #[issue_number]

Original prompt

This section details on the original issue you should resolve

<issue_title>Seach bar IP maxDay validation issue</issue_title>
<issue_description>The search bar returns "Error during search: dns_bad_ip_address" when parsing the ;maxDays parameter.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #4


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: devnomadic <14085319+devnomadic@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix maxDays validation issue in search bar Fix search bar IP validation when using ;maxDays parameter Oct 14, 2025
Copilot AI requested a review from devnomadic October 14, 2025 12:16
@devnomadic devnomadic marked this pull request as ready for review October 14, 2025 12:17
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying albatross with  Cloudflare Pages  Cloudflare Pages

Latest commit: bc11584
Status: ✅  Deploy successful!
Preview URL: https://1233489f.albatross-5kt.pages.dev
Branch Preview URL: https://copilot-fix-search-bar-maxda.albatross-5kt.pages.dev

View logs

@github-actions

github-actions Bot commented Oct 14, 2025

Copy link
Copy Markdown

🚀 PR Status Dashboard

📊 Workflow Status

CI: success (view)
Deploy: not deployed

🌐 Preview Environments

SPA Preview: https://copilot-fix-search-bar-maxdays-validation.albatross-5kt.pages.dev
Worker Preview: https://abuseipdb-preview.devnomadic.workers.dev

📝 PR Details

Branch: copilot/fix-search-bar-maxdays-validation
Commit: e880b08c
Author: @Copilot
Target: main
Last Updated: 2025-10-14T13:33:31.802Z


This comment is automatically updated by the PR Update workflow

* Initial plan

* Add copilot/* branch filter to CodeQL and CI workflows

Co-authored-by: devnomadic <14085319+devnomadic@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: devnomadic <14085319+devnomadic@users.noreply.github.com>
@devnomadic devnomadic merged commit ec36759 into main Oct 14, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Seach bar IP maxDay validation issue

2 participants