Repository navigation
Close backend validation coverage gaps #1431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Elliot (theelliotm)
merged 5 commits into
main
from
user/emichlin/close-test-coverage-gaps
Oct 7, 2026
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
350566f
Close test coverage gaps
theelliotm 8d0865d
MacOS tests now hold on to sockets
theelliotm fc80874
IsolationSession: record repeated-deprovision staleness as a known gap
theelliotm 419b63a
Add --noproxy option to curl commands in scripts
theelliotm 853eefb
Merge remote-tracking branch 'origin' into user/emichlin/close-test-cβ¦
theelliotm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "$schema": "../../schemas/stable/mxc-config.schema.1.0.0.json", | ||
| "version": "1.0.0", | ||
| "containment": "seatbelt", | ||
| "process": { | ||
| "commandLine": "echo FS_PARENT_ENTRIES=$(ls {{TESTDIR}}/rw | tr '\\n' ','); (ls {{TESTDIR}}/rw/nested >/dev/null 2>&1 && echo FS_DENIED_LIST_SUCCEEDED); (/usr/bin/stat -f %z {{TESTDIR}}/rw/nested/secret.txt >/dev/null 2>&1 && echo FS_DENIED_STAT_SUCCEEDED); (rm {{TESTDIR}}/rw/nested/secret.txt 2>/dev/null && echo FS_DENIED_DELETE_SUCCEEDED); (mv {{TESTDIR}}/rw/nested/secret.txt {{TESTDIR}}/rw/moved.txt 2>/dev/null && echo FS_DENIED_RENAME_SUCCEEDED); echo FS_PROBE_DONE", | ||
| "timeout": 10000 | ||
| }, | ||
| "filesystem": { | ||
| "readwritePaths": ["{{TESTDIR}}/rw"], | ||
| "deniedPaths": ["{{TESTDIR}}/rw/nested"] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "$schema": "../../schemas/stable/mxc-config.schema.1.0.0.json", | ||
| "version": "1.0.0", | ||
| "containment": "seatbelt", | ||
| "process": { | ||
| "commandLine": "/usr/bin/python3 -c \"import socket\ndef probe(tag, path, op):\n s = socket.socket(socket.AF_UNIX)\n try:\n getattr(s, op)(path)\n print(tag + '_SUCCEEDED')\n except OSError as e:\n print(tag + '_REFUSED', e.errno)\n s.close()\nprobe('UNIX_GRANTED_CONNECT', '{{TESTDIR}}/rw/open/agent.sock', 'connect')\nprobe('UNIX_DENIED_CONNECT', '{{TESTDIR}}/rw/nested/agent.sock', 'connect')\nprobe('UNIX_DENIED_BIND', '{{TESTDIR}}/rw/nested/new.sock', 'bind')\nprint('UNIX_PROBE_DONE')\"", | ||
| "timeout": 20000 | ||
| }, | ||
| "filesystem": { | ||
| "readonlyPaths": ["{{DEVDIR}}"], | ||
| "readwritePaths": ["{{TESTDIR}}/rw"], | ||
| "deniedPaths": ["{{TESTDIR}}/rw/nested"] | ||
| }, | ||
| "network": { | ||
| "egress": { "default": "allow" }, | ||
| "ingress": { "default": "allow", "hostLoopback": "allow" } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "$schema": "../../schemas/stable/mxc-config.schema.1.0.0.json", | ||
| "version": "1.0.0", | ||
| "containment": "seatbelt", | ||
| "process": { | ||
| "commandLine": "(echo denied > {{TESTDIR}}/rw/nested/written.txt && echo FS_NESTED_DENIED_WRITE_SUCCEEDED); (echo denied > {{TESTDIR}}/rw/sibling.txt && echo FS_RW_WRITE_CREATED); echo FS_PROBE_DONE", | ||
| "timeout": 10000 | ||
| }, | ||
| "filesystem": { | ||
| "readwritePaths": ["{{TESTDIR}}/rw"], | ||
| "deniedPaths": ["{{TESTDIR}}/rw/nested"] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "$schema": "../../schemas/stable/mxc-config.schema.1.0.0.json", | ||
| "version": "1.0.0", | ||
| "containment": "seatbelt", | ||
| "process": { | ||
| "commandLine": "(cat {{TESTDIR}}/alias/secret.txt && echo PATH_ALIAS_DENIED_READ_SUCCEEDED); (echo x > {{TESTDIR}}/alias/d.txt && echo PATH_ALIAS_DENIED_WRITE_SUCCEEDED); echo PATH_PROBE_DONE", | ||
| "timeout": 10000 | ||
| }, | ||
| "filesystem": { | ||
| "deniedPaths": ["{{TESTDIR_TMP}}/alias"], | ||
| "readonlyPaths": ["{{TESTDIR}}/alias"], | ||
| "readwritePaths": ["{{TESTDIR}}/./alias/"] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "$schema": "../../schemas/stable/mxc-config.schema.1.0.0.json", | ||
| "version": "1.0.0", | ||
| "containerId": "wslc-network-bridged", | ||
| "containment": "wslc", | ||
| "process": { | ||
| "commandLine": "python3 -c \"import socket\ns = socket.socket(); s.settimeout(8)\ntry:\n s.connect(('1.1.1.1', 443)); print('NET_EGRESS_REACHED')\nexcept OSError as e:\n print('NET_EGRESS_BLOCKED', e.errno)\nprint('NET_PROBE_DONE')\"" | ||
| }, | ||
| "network": { | ||
| "egress": { "default": "allow" }, | ||
| "ingress": { "default": "allow", "hostLoopback": "allow" } | ||
| }, | ||
| "wslc": { | ||
| "image": "python:3.12-alpine" | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
tests/configs/wslc_network_egress_deny_rules_rejected.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "$schema": "../../schemas/stable/mxc-config.schema.1.0.0.json", | ||
| "version": "1.0.0", | ||
| "containerId": "wslc-network-egress-deny-rules-rejected", | ||
| "containment": "wslc", | ||
| "process": { | ||
| "commandLine": "echo WSLC_EGRESS_RULES_SHOULD_NOT_RUN" | ||
| }, | ||
| "network": { | ||
| "egress": { | ||
| "default": "allow", | ||
| "deny": [{ "to": [{ "cidr": "10.0.0.0/8" }] }] | ||
| }, | ||
| "ingress": { "default": "allow", "hostLoopback": "allow" } | ||
| }, | ||
| "wslc": { | ||
| "image": "alpine:latest" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "$schema": "../../schemas/stable/mxc-config.schema.1.0.0.json", | ||
| "version": "1.0.0", | ||
| "containerId": "wslc-network-egress-rules-rejected", | ||
| "containment": "wslc", | ||
| "process": { | ||
| "commandLine": "echo WSLC_EGRESS_RULES_SHOULD_NOT_RUN" | ||
| }, | ||
| "network": { | ||
| "egress": { | ||
| "default": "deny", | ||
| "allow": [{ "to": [{ "cidr": "1.1.1.1/32" }], "ports": [{ "port": 443, "protocol": "tcp" }] }] | ||
| }, | ||
| "ingress": { "default": "deny", "hostLoopback": "deny" } | ||
| }, | ||
| "wslc": { | ||
| "image": "alpine:latest" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
tests/configs/wslc_network_proxy_credentials_rejected.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "$schema": "../../schemas/stable/mxc-config.schema.1.0.0.json", | ||
| "version": "1.0.0", | ||
| "containerId": "wslc-network-proxy-credentials-rejected", | ||
| "containment": "wslc", | ||
| "process": { | ||
| "commandLine": "echo WSLC_PROXY_CREDENTIALS_SHOULD_NOT_RUN", | ||
| "env": ["MXC_PROBE=1"] | ||
| }, | ||
| "network": { | ||
| "egress": { "default": "allow" }, | ||
| "ingress": { "default": "allow", "hostLoopback": "allow" } | ||
| }, | ||
| "runtimeConfig": { | ||
| "networkProxy": "http://proxyuser:s3cr3t@127.0.0.1:8888" | ||
| }, | ||
| "wslc": { | ||
| "image": "alpine:latest" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
| # | ||
| # LoopbackAnchor.ps1 β host-side loopback HTTP anchor for IsolationSession | ||
| # network tests. | ||
| # | ||
| # An isolated session is a separate OS logon session on the same machine, so a | ||
| # host loopback listener is reachable from inside it. Anchoring the positive | ||
| # network oracle here keeps it hermetic: it asserts the session's network | ||
| # posture rather than the runner's outbound internet access. | ||
|
|
||
| # Binds an ephemeral loopback port and serves a fixed body from a background | ||
| # runspace, so the caller can stay blocked on a sandbox exec while the | ||
| # contained process connects back. Returns $null if the port cannot be bound. | ||
| function Start-LoopbackAnchor { | ||
| # Bind port 0 and read back what the OS assigned, rather than reserving a | ||
| # port up front and re-binding it: another process can take the port in | ||
| # between, and the anchor then answers on a socket nobody can reach. | ||
| $listener = [System.Net.Sockets.TcpListener]::new([System.Net.IPAddress]::Loopback, 0) | ||
| try { | ||
| $listener.Start() | ||
| } catch { | ||
| return $null | ||
| } | ||
| $port = $listener.LocalEndpoint.Port | ||
| $ps = [PowerShell]::Create() | ||
| [void]$ps.AddScript({ | ||
| param($l) | ||
| $body = 'MXC-ISO-LOOPBACK-ANCHOR' | ||
| $response = [Text.Encoding]::ASCII.GetBytes( | ||
| "HTTP/1.1 200 OK`r`nContent-Type: text/plain`r`nContent-Length: $($body.Length)`r`nConnection: close`r`n`r`n$body") | ||
| while ($true) { | ||
| try { | ||
| $client = $l.AcceptTcpClient() | ||
| $stream = $client.GetStream() | ||
| # Read whatever request line the client sent before replying; | ||
| # curl will not report success if the peer resets first. | ||
| $stream.ReadTimeout = 2000 | ||
| $buf = New-Object byte[] 1024 | ||
| try { [void]$stream.Read($buf, 0, $buf.Length) } catch {} | ||
| $stream.Write($response, 0, $response.Length) | ||
| $stream.Flush() | ||
| $client.Close() | ||
| } catch { break } | ||
| } | ||
| }).AddArgument($listener) | ||
| $handle = $ps.BeginInvoke() | ||
| return [pscustomobject]@{ | ||
| Port = $port | ||
| Url = "http://127.0.0.1:$port/" | ||
| Body = 'MXC-ISO-LOOPBACK-ANCHOR' | ||
| Stop = { | ||
| try { $listener.Stop() } catch {} | ||
| try { [void]$ps.EndInvoke($handle) } catch {} | ||
| try { $ps.Dispose() } catch {} | ||
| }.GetNewClosure() | ||
| } | ||
| } | ||
|
|
||
| function Stop-LoopbackAnchor { | ||
| param($Anchor) | ||
| if ($null -eq $Anchor) { return } | ||
| & $Anchor.Stop | ||
| } | ||
|
|
||
| # Command line that fetches the anchor from inside a sandbox. | ||
| # | ||
| # Deliberately a bare curl rather than a `&& echo REACHED || echo BLOCKED` | ||
| # token pair: the one-shot runner invokes wxc-exec with --debug, which echoes | ||
| # the command line, so any verdict token spelled here would appear in the | ||
| # captured output whether or not the probe ran. The anchor's response body | ||
| # cannot be echoed that way, which makes it the only honest oracle -- and | ||
| # curl's non-zero exit on a failed connect covers the negative side. | ||
| function Get-LoopbackAnchorCommand { | ||
| param( | ||
| [Parameter(Mandatory)][string]$Url, | ||
| [int]$TimeoutSec = 15 | ||
| ) | ||
| $curl = Join-Path $env:SystemRoot 'System32\curl.exe' | ||
| "$curl --silent --show-error --fail --max-time $TimeoutSec $Url" | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.