Skip to content

Commit 2930ea0

Browse files
committed
handle SecurityOptions: null in docker response
1 parent e70b313 commit 2930ea0

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

pre_commit/languages/docker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def _is_rootless() -> bool: # pragma: win32 no cover
115115
return (
116116
# docker:
117117
# https://docs.docker.com/reference/api/engine/version/v1.48/#tag/System/operation/SystemInfo
118-
'name=rootless' in info.get('SecurityOptions', ()) or
118+
'name=rootless' in (info.get('SecurityOptions') or ()) or
119119
# podman:
120120
# https://docs.podman.io/en/latest/_static/api.html?version=v5.4#tag/system/operation/SystemInfoLibpod
121121
info['host']['security']['rootless']

tests/languages/docker_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ def test_docker_user_rootless(info_ret):
8989
(
9090
(0, b'{"SecurityOptions": ["name=cgroupns"]}', b''),
9191
(0, b'{"host": {"security": {"rootless": false}}}', b''),
92-
(0, b'{"respone_from_some_other_container_engine": true}', b''),
92+
(0, b'{"response_from_some_other_container_engine": true}', b''),
93+
(0, b'{"SecurityOptions": null}', b''),
9394
(1, b'', b''),
9495
),
9596
)

0 commit comments

Comments
 (0)