From cf8b37925d9059d127ac2dbf1504779817f915ff Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Tue, 23 Jul 2019 10:47:44 +0200 Subject: [PATCH] remove obsolete http secutiry settings (#41569) (#41738) --- src/legacy/server/http/secure_options.js | 41 ----------------- src/legacy/server/http/secure_options.test.js | 46 ------------------- 2 files changed, 87 deletions(-) delete mode 100644 src/legacy/server/http/secure_options.js delete mode 100644 src/legacy/server/http/secure_options.test.js diff --git a/src/legacy/server/http/secure_options.js b/src/legacy/server/http/secure_options.js deleted file mode 100644 index e8440a86280b3..0000000000000 --- a/src/legacy/server/http/secure_options.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import crypto from 'crypto'; -import { chain } from 'lodash'; - -const protocolMap = { - TLSv1: crypto.constants.SSL_OP_NO_TLSv1, - 'TLSv1.1': crypto.constants.SSL_OP_NO_TLSv1_1, - 'TLSv1.2': crypto.constants.SSL_OP_NO_TLSv1_2 -}; - -export default function (supportedProtocols) { - if (!supportedProtocols || !supportedProtocols.length) { - return null; - } - - return chain(protocolMap) - .omit(supportedProtocols) - .values() - .reduce(function (value, sum) { - return value | sum; - }, 0) - .value(); -} diff --git a/src/legacy/server/http/secure_options.test.js b/src/legacy/server/http/secure_options.test.js deleted file mode 100644 index 1374b9dd8667b..0000000000000 --- a/src/legacy/server/http/secure_options.test.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import secureOptions from './secure_options'; -import crypto from 'crypto'; - -const constants = crypto.constants; - -describe('secure_options', function () { - it('allows null', function () { - expect(secureOptions(null)).toBe(null); - }); - - it ('allows an empty array', function () { - expect(secureOptions([])).toBe(null); - }); - - it ('removes TLSv1 if we only support TLSv1.1 and TLSv1.2', function () { - expect(secureOptions(['TLSv1.1', 'TLSv1.2'])).toBe(constants.SSL_OP_NO_TLSv1); - }); - - it ('removes TLSv1.1 and TLSv1.2 if we only support TLSv1', function () { - expect(secureOptions(['TLSv1'])).toBe(constants.SSL_OP_NO_TLSv1_1 | constants.SSL_OP_NO_TLSv1_2); - }); - - it ('removes TLSv1 and TLSv1.1 if we only support TLSv1.2', function () { - expect(secureOptions(['TLSv1.2'])).toBe(constants.SSL_OP_NO_TLSv1 | constants.SSL_OP_NO_TLSv1_1); - }); - -});