mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-08-15 21:40:09 +00:00
Extend container image name validator (#4480)
* Extend container image name validator The current validator allows certain invalid names (e.g. upper case), but disallows valid cases (such as ttl.sh/myimage). Improve the container image validator to support more valid options and at the same time disallow some of the invalid options. Note that this is not a complete/perfect validation still. A much much more sophisticated regex would be necessary to be 100% accurate. Also we format the string and replace {machine}/{arch} using Python format strings. In that regard the image format in Supervisor deviates from the Docker/OCI container image name format. * Use an actual invalid image name in config validation
This commit is contained in:
@ -49,7 +49,9 @@ RE_REGISTRY = re.compile(r"^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$")
|
||||
# pylint: disable=invalid-name
|
||||
network_port = vol.All(vol.Coerce(int), vol.Range(min=1, max=65535))
|
||||
wait_boot = vol.All(vol.Coerce(int), vol.Range(min=1, max=60))
|
||||
docker_image = vol.Match(r"^([a-zA-Z\-\.:\d{}]+/)*?([\-\w{}]+)/([\-\w{}]+)$")
|
||||
docker_image = vol.Match(
|
||||
r"^([a-z0-9][a-z0-9.\-]*(:[0-9]+)?/)*?([a-z0-9{][a-z0-9.\-_{}]*/)*?([a-z0-9{][a-z0-9.\-_{}]*)$"
|
||||
)
|
||||
uuid_match = vol.Match(r"^[0-9a-f]{32}$")
|
||||
sha256 = vol.Match(r"^[0-9a-f]{64}$")
|
||||
token = vol.Match(r"^[0-9a-f]{32,256}$")
|
||||
|
Reference in New Issue
Block a user