File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
tests/container_hardening Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,11 @@ def test_bgp_dev(duthost):
13
13
"""
14
14
Test bgp container has no access to /dev/vda* or /dev/sda*
15
15
"""
16
- device = duthost .shell ("docker exec bgp bash -c 'df -h | grep /etc/hosts' | awk '{print $1}'" )['stdout' ]
16
+ cmd = duthost .shell ("docker exec bgp bash -c 'df -h | grep /etc/hosts' | awk '{print $1}'" )
17
+ rc , device = cmd ['rc' ], cmd ['stdout' ]
18
+ if rc != 0 :
19
+ pytest_assert (False , 'Failed to get the device name.' )
20
+ if not device .startswith ('/dev/' ):
21
+ pytest_assert (False , 'Invalid device {}.' .format (device ))
17
22
output = duthost .shell ("docker exec bgp bash -c 'ls {}'" .format (device ), module_ignore_errors = True )['stdout' ]
18
23
pytest_assert (not output , 'The partition {} exists.' .format (device ))
You can’t perform that action at this time.
0 commit comments