Enhance supported patterns to include ** matching multilevel of subdomains#42871
Enhance supported patterns to include ** matching multilevel of subdomains#42871pjablonski123 wants to merge 1 commit intocilium:mainfrom
Conversation
…mains.
pkg/fqdn: Adding ** matchpattern
The ** in matchpattern allows a short notation of multilevel subdomains
Instead of the rules with listed subdomains:
rules:
dns:
- matchPattern: '*.cluster.local'
- matchPattern: '*.*.cluster.local'
- matchPattern: '*.*.*.cluster.local'
- matchPattern: '*.*.*.*.cluster.local'
- matchPattern: '*.*.*.*.*.cluster.local'
- matchPattern: '*.*.*.*.*.*.cluster.local'
- matchPattern: '*.*.*.*.*.*.*.cluster.local'
- matchPattern: '*.*.*.*.*.*.*.*.cluster.local'
egress:
- toFQDNs:
- matchPattern: '*.cilium.io'
- matchPattern: '*.*.cilium.io'
- matchPattern: '*.*.*.cilium.io'
- matchPattern: '*.*.*.*.cilium.io'
- matchPattern: '*.*.*.*.*.cilium.io'
- matchPattern: '*.*.*.*.*.*.cilium.io'
- matchPattern: '*.*.*.*.*.*.*.cilium.io'
- matchPattern: '*.*.*.*.*.*.*.*.cilium.io'
the following policy can be used in a simpler form:
rules:
dns:
- matchPattern: '**.cluster.local'
egress:
- toFQDNs:
- matchPattern: '**.cilium.io'
Changelog:
Modified the code and added tests.
Updated language.rst.
Updated matchpattern.go.
Added and updated doc files.
Updated language.rst with a security note.
Double asterisk is allowed at the beginning of the domain only.
Signed-off-by: Piotr Jablonski <[email protected]>
```release-note
The ** in matchpattern allows a short notation of multilevel subdomains,
eg. **.cilium.io matches a.cilium.io, a.b.cilium.io, a.b.c.cilium.io, etc.
This feature can break current configuration if a double asterisk was used inside of FQDN, eg. cil**.io
Before this enhancement two or more directly adjacent asterisks meant the same - a single asterisk, eg. cil**.io == cil*.io
The correct usage of the asterisk before this enhancement should be a single presence between other characters, eg. c*m.io, *.cil*.io
With this enhancement the correct usage of the single asterisk does not change
A double asterisk must be at the beginning of the FQDN string only, eg. **.cilium.io
The single and double asterisk can be present in the same FQDN if they are separated by a dot directly or indirectly, eg. **.*lium.io, **.cili*.io
```
|
Let's review security concerns and address them to push this PR forward. @TheBeeZee Did you consider potential security flaws of adding ** to the network policy syntax? |
| * ``**`` within a domain allows 0 or more valid DNS subdomains and characters, including | ||
| ``.`` separator. ``**.cilium.io`` will match ``sub1.cilium.io`` as well as ``sub2.sub1.cilium.io``. | ||
| * ``**`` alone matches all names, and inserts all cached DNS IPs into this rule. |
There was a problem hiding this comment.
non-blocking nit: It's slightly more correct to use the term label here, since each period-separated part of a domain/host name is called that.
| * ``**`` within a domain allows 0 or more valid DNS subdomains and characters, including | |
| ``.`` separator. ``**.cilium.io`` will match ``sub1.cilium.io`` as well as ``sub2.sub1.cilium.io``. | |
| * ``**`` alone matches all names, and inserts all cached DNS IPs into this rule. | |
| * ``**`` within a domain allows 0 or more valid DNS labels to the left, including | |
| ``.`` separator. ``**.cilium.io`` will match ``sub1.cilium.io`` as well as ``sub2.sub1.cilium.io``. | |
| * ``**`` alone matches all names, and inserts all cached DNS IPs into this rule. |
|
It looks like this branch is based on a 2 years old |
|
This pull request has been automatically marked as stale because it |
|
This pull request has not seen any activity since it was marked stale. |
Reopening PR #28690