From: Sebastiaan van Stijn Date: Tue, 2 Jul 2019 11:21:04 +0000 (+0200) Subject: [PATCH] TestMaskSecretKeys: add more test-cases X-Git-Tag: archive/raspbian/18.09.1+dfsg1-7.1+rpi1+deb10u3^2~31 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b91a762e9b5e1c132f12462de674469949c9243d;p=docker.io.git [PATCH] TestMaskSecretKeys: add more test-cases Add tests for - case-insensitive matching of fields - recursive masking Signed-off-by: Sebastiaan van Stijn (cherry picked from commit db5f811216e70bcb4a10e477c1558d6c68f618c5) Signed-off-by: Tibor Vass (cherry picked from commit 18dac2cf32faeaada3bd4e8e2bffa576ad4329fe) Signed-off-by: Sebastiaan van Stijn Origin: upstream, https://github.com/docker/engine/pull/298 Gbp-Pq: Name cve-2019-13509-01-TestMaskSecretKeys-add-more-test-cases.patch --- diff --git a/engine/api/server/middleware/debug_test.go b/engine/api/server/middleware/debug_test.go index a64b73e0..3d78d7e0 100644 --- a/engine/api/server/middleware/debug_test.go +++ b/engine/api/server/middleware/debug_test.go @@ -23,7 +23,6 @@ func TestMaskSecretKeys(t *testing.T) { input: map[string]interface{}{"Data": "foo", "Name": "name", "Labels": map[string]interface{}{}}, expected: map[string]interface{}{"Data": "*****", "Name": "name", "Labels": map[string]interface{}{}}, }, - { path: "/secrets/create?key=val", input: map[string]interface{}{"Data": "foo", "Name": "name", "Labels": map[string]interface{}{}}, @@ -32,8 +31,13 @@ func TestMaskSecretKeys(t *testing.T) { { path: "/v1.30/some/other/path", input: map[string]interface{}{ - "password": "pass", + "password": "pass", + "secret": "secret", + "jointoken": "jointoken", + "unlockkey": "unlockkey", + "signingcakey": "signingcakey", "other": map[string]interface{}{ + "password": "pass", "secret": "secret", "jointoken": "jointoken", "unlockkey": "unlockkey", @@ -41,8 +45,13 @@ func TestMaskSecretKeys(t *testing.T) { }, }, expected: map[string]interface{}{ - "password": "*****", + "password": "*****", + "secret": "*****", + "jointoken": "*****", + "unlockkey": "*****", + "signingcakey": "*****", "other": map[string]interface{}{ + "password": "*****", "secret": "*****", "jointoken": "*****", "unlockkey": "*****", @@ -50,6 +59,21 @@ func TestMaskSecretKeys(t *testing.T) { }, }, }, + { + path: "/v1.30/some/other/path", + input: map[string]interface{}{ + "PASSWORD": "pass", + "other": map[string]interface{}{ + "PASSWORD": "pass", + }, + }, + expected: map[string]interface{}{ + "PASSWORD": "*****", + "other": map[string]interface{}{ + "PASSWORD": "*****", + }, + }, + }, } for _, testcase := range tests {