Skip to content

Add wildcard patterns to the ignored suggestions - #214

Merged
frederikvig merged 2 commits into
masterfrom
feature/ignore-patterns
Nov 7, 2026
Merged

frederikvig merged 2 commits into
masterfrom
feature/ignore-patterns

Conversation

@frederikvig

@frederikvig frederikvig commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Closes #197.

What it does

The Ignored tab gets a field for adding a pattern with * as the wildcard, such as /api/*, *.php, /*/admin or https://example.com/api/*. A url matching one isn't logged as a suggestion, and adding one removes the suggestions already logged for those urls.

Decisions worth checking

  • A pattern only stops suggestions. It's checked last in CustomRedirectCollection.Find, so a redirect or regex redirect that applies to a url keeps working, and a broad filter can't break anything that redirects today. This differs slightly from an ignored url without a wildcard, which also stops a shorter redirect from applying to it. That behavior is unchanged.
  • No new column or state. A pattern is an ignored row with a * in it. That avoids a database change, but an ignored row with a literal * that's saved already becomes a pattern. The worst that can do is stop some suggestions, never a redirect.
  • Patterns matching everything aren't patterns. That's /*, https://example.com/* and anything else with only wildcards and slashes in the path. Bots request /* literally, and with LogWithHostname on it's logged with the host, so such a row can be saved already, and it would silently stop all suggestions after an upgrade. A row with an encoded %2A is a literal url too.
  • Where a pattern matches. One starting with http compares to the whole url, including the scheme, and any other to the path and query, so *.com* can't match every request through the host. http*://example.com/api/* covers both schemes.
  • * is the only wildcard. FileSystemName.MatchesSimpleExpression does the matching, as it's built in and doesn't backtrack, which matters as it runs on unmatched requests. It treats ? as a wildcard and \ as an escape, and ? can't be escaped, so both are swapped for private use characters on either side before matching.
  • The form only takes patterns, and refuses one saved as a redirect or deleted url. Saving replaces a row with the same old url, so it would silently remove the redirect. Plain urls can still be ignored from the Suggestions tab.

ISuggestionRepository.DeleteMatching is a default interface method, so a class implementing the interface keeps compiling. IgnoredModel takes an ISuggestionService.

Testing

  • Unit tests: 342/342 and 82/82, with 55 new test cases in IgnorePatternTests.
  • Against SQL Server in the sandbox, with the real form: 73 checks, 0 failed, both with LogWithHostname off and on. They cover:
    • refused values, including whole urls matching everything and one over 2000 characters
    • a pattern saved as a redirect being refused, with the redirect left in place
    • which suggestions get removed and kept, including _, %, [ and ? in a pattern, upper case, hosts, and words that are only in the host
    • new requests being logged or not, including whole url patterns and the scheme
    • a redirect, its child and a regex redirect under a pattern
    • saved /* and %2A rows not acting as patterns
    • unignoring, after which urls are logged again
    • deleting all ignored rows
  • In Chrome: adding a valid pattern and a refused one with the Enter key, including the confirmation and the validation message. That was before the review's changes. Ignored.cshtml hasn't changed since, and the sandbox checks cover the new refusals.

Limits

  • *.php doesn't match /login.php?a=b, as a * only matches where it's written. *.php* does. I left this, as a plain rule is easier to explain than a special case for the query string.
  • Clicking Ignore on a suggestion with a literal *, such as /wp-*.php, creates a pattern and removes the other suggestions matching it. The confirmation doesn't mention this.
  • A suggestion stored in another form than the pattern stays in the list, but isn't logged again. A pattern naming a host doesn't remove suggestions logged without one, and an encoded /a%20b isn't removed by /a b*. This is in the README.
  • An ignored url without a wildcard (/api) still logs its children (/api/x). I left that alone, as changing it would stop suggestions on existing sites without anyone asking for it.
  • The form accepts patterns that can never match, such as *://example.com/*, as it doesn't start with http.
  • A request for the literal text of a pattern (/a/*) can't use a shorter redirect, as the row is also an ordinary ignored row. That needs a request containing a literal *.
  • A leading wildcard on a very large suggestions table can hit the command timeout. SqlDataExecutor logs that and the page still reports success, so the old suggestions stay. New ones are still stopped.
  • A request already waiting in the log buffer when a pattern is added can still be saved as a suggestion.
  • Not tested with two instances, but patterns are ordinary rows going through the same update and reload as any other redirect.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GUDE6qHSSrhDDLNMCQ5suJ

frederikvig and others added 2 commits November 7, 2026 08:51
An ignored url only stopped that exact url being logged, so a section of a
site had to be ignored one url at a time, or with a regex in the code.

A row with a * in it is now a pattern, which can be added on the Ignored tab.
It's checked after everything else, so it only stops suggestions and never a
redirect that applies to the url. /* isn't a pattern, as bots request it
literally, so a row like that can be saved already and would stop all
suggestions. Adding a pattern also removes the suggestions already logged
for it.

Closes #197

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GUDE6qHSSrhDDLNMCQ5suJ
The guard against patterns matching everything only looked at the whole
string, so https://example.com/* got past it, which with LogWithHostname on
is how a request for /* gets logged. A ? acted as a wildcard, so /?* matched
nearly everything while deleting suggestions took it literally. And a pattern
starting with * could match on the scheme or host.

A pattern starting with http now compares to the whole url and any other to
the path and query, * is the only wildcard, and a row with an encoded %2A is
a literal url. The form also refuses a pattern saved as a redirect, which
saving would have replaced, and one longer than the column.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GUDE6qHSSrhDDLNMCQ5suJ
@frederikvig
frederikvig merged commit dd292c0 into master Nov 7, 2026
1 check passed
@frederikvig
frederikvig deleted the feature/ignore-patterns branch November 7, 2026 19:37
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.

Feature Request: Support wildcard patterns in ignore filters

1 participant