Go to file
Ryan Nowak 80861f1da9
Fix use of precedence in endpoint routing DFA (#20801)
* Fix use of precedence in endpoint routing DFA

Fixes: #18677
Fixes: #16579

This is a change to how sorting is use when building endpoint routing's graph of
nodes that is eventually transformed into the route table. There were
bugs in how this was done that made it incompatible in some niche
scenarios both with previous implementations and how we describe the
features in the abstract.

There are a wide array of cases that might have been impacted by this
bug because routing is a pattern language. Generally the bugs will involve a
catch-all, and some something that changes ordering of templates.

Issue #18677 has the simplest repro for this, the following templates
would not behave as expected:

```
a/{*b}
{a}/{b}
```

One would expect any URL Path starting with `/a` to match the first
route, but that's not what happens.

---

The root cause of this bug was an issue in how the algorithm used to be
build the DFA was designed. Specifically that it uses a BFS to build the
graph, and it uses an up-front one-time sort of endpoints in order to
drive that BFS.

The building of the graph has the expectation that at each level, we
will process **all** literal segments (`/a`) and then **all** parameter
segments (`/{a}`) and then **all** catch-all segments (`/{*a}`). Routing
defines a concept called *precedence* that defines the *conceptual*
order in while segments types are ordered.

So there are two problems:

- We sort based on criteria other than precedence (#16579)
- We can't rely on a one-time sort, it needs to be done at each level
(#18677)

---

The fix is to repeat the sort operation at each level and use precedence
as the only key for sorting (as dictated by the graph building algo).

We do a sort of the matches of each node *after* building the
precedence-based part of the DFA, based on the full sorting criteria, to
maintain compatibility.

* Add test
2020-04-21 22:48:27 -07:00
.azure/pipelines Get off the hosted ubuntu linux queue due to disk space limitations 2020-04-17 13:46:10 -07:00
.config
.github Disable the sync action in forks (#19934) 2020-03-19 12:34:04 -07:00
.vscode
docs Adding an area-ownership document (#20108) 2020-03-24 14:44:32 -07:00
eng Update dependencies from https://github.com/dotnet/efcore build 20200421.3 (#21069) 2020-04-21 22:49:41 +00:00
src Fix use of precedence in endpoint routing DFA (#20801) 2020-04-21 22:48:27 -07:00
.editorconfig
.gitattributes
.gitignore Adding reference to MessagePackAnalyzer to check for MsgPack001 / MsgPack002 (Banned API) (#19989) 2020-03-19 16:05:45 -07:00
.gitmodules
.vsconfig Add .vsconfig files in root and beside slns 2020-03-31 14:25:44 -07:00
CODE-OF-CONDUCT.md Link Code of Conduct 2020-04-02 19:51:30 -07:00
CONTRIBUTING.md More updates docs (#20513) 2020-04-03 22:09:36 +00:00
Directory.Build.props Merge branch 'master' into johluo/remove-extensions-deps 2020-04-06 11:17:56 -07:00
Directory.Build.targets Merge branch 'master' into merge/release/3.1-to-master 2020-03-27 10:24:36 -07:00
LICENSE.txt
NuGet.config Update dependencies from https://github.com/dotnet/efcore build 20200331.5 (#20399) 2020-04-01 07:16:57 +00:00
README.md Update README.md (#20486) 2020-04-03 16:00:27 +00:00
SECURITY.md
THIRD-PARTY-NOTICES.txt
activate.ps1
activate.sh
build.cmd
build.ps1
build.sh
clean.cmd
clean.ps1
clean.sh
dockerbuild.sh
global.json [release/3.1] Update dependencies from dotnet/arcade (#20815) 2020-04-14 19:58:09 +00:00
restore.cmd
restore.sh
startvs.cmd

README.md

ASP.NET Core

ASP.NET Core is an open-source and cross-platform framework for building modern cloud based internet connected applications, such as web apps, IoT apps and mobile backends. ASP.NET Core apps run on .NET Core, a free, cross-platform and open-source application runtime. It was architected to provide an optimized development framework for apps that are deployed to the cloud or run on-premises. It consists of modular components with minimal overhead, so you retain flexibility while constructing your solutions. You can develop and run your ASP.NET Core apps cross-platform on Windows, Mac and Linux. Learn more about ASP.NET Core.

Get Started

Follow the Getting Started instructions in the ASP.NET Core docs.

Also check out the .NET Homepage for released versions of .NET, getting started guides, and learning resources.

See the Issue Management Policies document for more information on how we handle incoming issues.

How to Engage, Contribute, and Give Feedback

Some of the best ways to contribute are to try things out, file issues, join in design conversations, and make pull-requests.

Reporting security issues and bugs

Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) secure@microsoft.com. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter.

These are some other repos for related projects:

Code of conduct

See CODE-OF-CONDUCT