Tighten UDS addr validation and sockname prefixes
- add `is_valid` and `sockpath.resolve()` asserts in `get_rando_addr()` for the `'uds'` case plus an explicit `UDSAddress` type annotation. - rename no-runtime sockname prefixes from `'<unknown-actor>'`/`'root'` to `'no_runtime_root'`/`'no_runtime_actor'` with a proper if/else branch in `UDSAddress.get_random()`. (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-codens_aware
parent
99577b719a
commit
52e8fb43ee
|
|
@ -61,7 +61,11 @@ def get_rando_addr(
|
||||||
# NOTE, file-name uniqueness (no-collisions) will be based on
|
# NOTE, file-name uniqueness (no-collisions) will be based on
|
||||||
# the runtime-directory and root (pytest-proc's) pid.
|
# the runtime-directory and root (pytest-proc's) pid.
|
||||||
case 'uds':
|
case 'uds':
|
||||||
testrun_reg_addr = addr_type.get_random().unwrap()
|
from tractor.ipc._uds import UDSAddress
|
||||||
|
addr: UDSAddress = addr_type.get_random()
|
||||||
|
assert addr.is_valid
|
||||||
|
assert addr.sockpath.resolve()
|
||||||
|
testrun_reg_addr = addr.unwrap()
|
||||||
|
|
||||||
# XXX, as sanity it should never the same as the default for the
|
# XXX, as sanity it should never the same as the default for the
|
||||||
# host-singleton registry actor.
|
# host-singleton registry actor.
|
||||||
|
|
|
||||||
|
|
@ -197,9 +197,11 @@ class UDSAddress(
|
||||||
# sockname: str = '.'.join(actor.uid) + f'@{pid}'
|
# sockname: str = '.'.join(actor.uid) + f'@{pid}'
|
||||||
# -[ ] CURRENTLY using `.` BREAKS TEST SUITE tho..
|
# -[ ] CURRENTLY using `.` BREAKS TEST SUITE tho..
|
||||||
else:
|
else:
|
||||||
prefix: str = '<unknown-actor>'
|
|
||||||
if is_root_process():
|
if is_root_process():
|
||||||
prefix: str = 'root'
|
prefix: str = 'no_runtime_root'
|
||||||
|
else:
|
||||||
|
prefix: str = 'no_runtime_actor'
|
||||||
|
|
||||||
sockname: str = f'{prefix}@{pid}'
|
sockname: str = f'{prefix}@{pid}'
|
||||||
|
|
||||||
sockpath: Path = Path(f'{sockname}.sock')
|
sockpath: Path = Path(f'{sockname}.sock')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue