diff --git a/.eslintrc.js b/.eslintrc.js index 59d585b9d355bd..ba94036b0f50bc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -85,6 +85,7 @@ module.exports = { 'comma-style': 'error', 'computed-property-spacing': 'error', 'constructor-super': 'error', + 'default-case-last': 'error', 'dot-location': ['error', 'property'], 'dot-notation': 'error', 'eol-last': 'error', @@ -273,6 +274,7 @@ module.exports = { functions: false, variables: false, }], + 'no-useless-backreference': 'error', 'no-useless-call': 'error', 'no-useless-catch': 'error', 'no-useless-concat': 'error', diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index f0ee528a0f4e0f..9b4ebca75c86ca 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -70,4 +70,4 @@ jobs: - name: Lint Python run: | make lint-py-build || true - NODE=$(which node) make lint lint-py + NODE=$(which node) make lint-py diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index d63627f1f0cc78..bec9884f6c837c 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -20,4 +20,4 @@ jobs: - name: Build run: make build-ci -j2 V=1 - name: Test - run: make run-ci -j2 V=1 + run: make run-ci -j2 V=1 TEST_CI_ARGS="-p dots" diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml index 51dfc3d245e01c..b9794bde31b45a 100644 --- a/.github/workflows/test-macos.yml +++ b/.github/workflows/test-macos.yml @@ -20,4 +20,4 @@ jobs: - name: Build run: make build-ci -j8 V=1 - name: Test - run: make run-ci -j8 V=1 + run: make run-ci -j8 V=1 TEST_CI_ARGS="-p dots" diff --git a/.mailmap b/.mailmap index 15962df50bdb94..4a73a2b352a2e7 100644 --- a/.mailmap +++ b/.mailmap @@ -23,6 +23,7 @@ Amery 子丶言 Amit Bendor Anatoli Papirovski Andreas Offenhaeuser anoff +Andrew Hughes Andy Bettisworth Angel Stoyanov atstojanov Anna Henningsen @@ -250,6 +251,7 @@ Masato Ohba Matheus Marchini Matheus Marchini Matheus Marchini +Matheus Marchini Matt Lang matt-in-a-hat Matt Reed matthewreed26 Matteo Collina @@ -408,6 +410,7 @@ Travis Meisenheimer Trevor Burnham Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Tyler Larson +Ujjwal Sharma Viktor Karpov vitkarpov Vincent Voyer Vladimir de Turckheim diff --git a/AUTHORS b/AUTHORS index 539f311a0dcb9f..e6af564013f31a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -2945,5 +2945,81 @@ Chris Oyler Jesper Ek Luciano jens-cappelle +bruce-one +Jason Macgowan +Vincent Dhennin +Alex Zherdev +Jeny +Tchoupinax +Sebastien Ahkrin +Michael Lehenbauer +Harendra Singh +Sam Foxman +Marek Łabuz +Reza Fatahi +Priyanka Kore +Jan-Philip Gehrcke +Maël Nison +qualitymanifest +Rosen Penev +Jeremy Albright +Giovanni Campagna +Donggeon Lim +Tim Costa +rene.herrmann +Derek Lewis +Kirill Ponomarev +Soar <58918356+soar-beep@users.noreply.github.com> +Tadao Iseki +Diego Lafuente +Andrew Kuzmenko +David Newman +Andrey Hohutkin +A. Volgin +Chris Osborn +stephank +Taylor Zane Glaeser +sutangu +Santosh Yadav +kresimirfranin +Colin Grant <43424668+GKJCJG@users.noreply.github.com> +Ryan Schmidt +Ronald J Kimball +Vighnesh Raut +SpaceRacet5w2A6l0I <59487396+SpaceRacet5w2A6l0I@users.noreply.github.com> +Alexander Wang +carterbancroft +Egor Pavlov +Parker Bjur +Yakov Litvin +Eran Levin +Alexander Smarus +kenzo-spaulding <51864231+kenzo-spaulding@users.noreply.github.com> +Rusty Conover +aaccttrr +ConorDavenport +Dylan Coakley +Steffen +Conor ONeill +tsabolov +Swagat Konchada +Yuhanun Citgez +Danielle Adams +Andrey Pechkurov +Jeff +simon +Eric Eastwood +unknown +zfx <502545703@qq.com> +Vita Batrla +André Draszik +ProdipRoy89 +Andrew Neitsch +RamanandPatil +forfun414 +David Gilbertson +Sergey Zelenov +Eric Bickle +Joe Pea # Generated by tools/update-authors.js diff --git a/BUILDING.md b/BUILDING.md index cb1960db7445cf..9b0211db7e259e 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -28,6 +28,7 @@ file a new issue. * [Running Coverage](#running-coverage) * [Building the documentation](#building-the-documentation) * [Building a debug build](#building-a-debug-build) + * [Building an ASAN build](#building-an-asan-build) * [Troubleshooting Unix and macOS builds](#troubleshooting-unix-and-macos-builds) * [Windows](#windows) * [Prerequisites](#prerequisites) @@ -496,6 +497,22 @@ $ gdb /opt/node-debug/node core.node.8.1535359906 $ backtrace ``` +#### Building an ASAN build + +[ASAN](https://github.com/google/sanitizers) can help detect various memory +related bugs. ASAN builds are currently only supported on linux. +If you want to check it on Windows or macOS or you want a consistent toolchain +on Linux, you can try [Docker](https://www.docker.com/products/docker-desktop) + (using an image like `gengjiawen/node-build:2020-02-14`). + +The `--debug` is not necessary and will slow down build and testing, but it can +show clear stacktrace if ASAN hits an issue. + +``` console +$ ./configure --debug --enable-asan && make -j4 +$ make test-only +``` + #### Troubleshooting Unix and macOS builds Stale builds can sometimes result in `file not found` errors while building. @@ -544,7 +561,6 @@ Optional requirements for compiling for Windows 10 on ARM (ARM64): * Windows 10 SDK 10.0.17763.0 or newer ##### Option 2: Automated install with Boxstarter - A [Boxstarter](https://boxstarter.org/) script can be used for easy setup of Windows systems with all the required prerequisites for Node.js development. @@ -555,7 +571,7 @@ packages: Unix tools added to the `PATH`. * [Python 3.x](https://chocolatey.org/packages/python) and [legacy Python](https://chocolatey.org/packages/python2) -* [Visual Studio 2017 Build Tools](https://chocolatey.org/packages/visualstudio2017buildtools) +* [Visual Studio 2019 Build Tools](https://chocolatey.org/packages/visualstudio2019buildtools) with [Visual C++ workload](https://chocolatey.org/packages/visualstudio2017-workload-vctools) * [NetWide Assembler](https://chocolatey.org/packages/nasm) diff --git a/CHANGELOG.md b/CHANGELOG.md index 828df1e1ffcdef..826d8b9c3ad7d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,8 @@ release. -12.16.2
+12.16.3
+12.16.2
12.16.1
12.16.0
12.15.0
diff --git a/GOVERNANCE.md b/GOVERNANCE.md index 5048a700340617..b54f2e81b14d54 100644 --- a/GOVERNANCE.md +++ b/GOVERNANCE.md @@ -7,7 +7,7 @@ * [Technical Steering Committee](#technical-steering-committee) * [TSC Meetings](#tsc-meetings) * [Collaborator Nominations](#collaborator-nominations) - * [Onboarding](#./onboarding) + * [Onboarding](#onboarding) * [Consensus Seeking Process](#consensus-seeking-process) diff --git a/Makefile b/Makefile index 88166da2a84cd8..3e27af2c7673bb 100644 --- a/Makefile +++ b/Makefile @@ -292,7 +292,7 @@ v8: tools/make-v8.sh $(V8_ARCH).$(BUILDTYPE_LOWER) $(V8_BUILD_OPTIONS) .PHONY: jstest -jstest: build-addons build-js-native-api-tests build-node-api-tests ## Runs addon tests and JS tests +jstest: build-addons build-abort-tests build-js-native-api-tests build-node-api-tests ## Runs addon tests and JS tests $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) \ --skip-tests=$(CI_SKIP_TESTS) \ $(CI_JS_SUITES) \ @@ -316,6 +316,7 @@ test: all ## Runs default tests, linters, and builds docs. $(MAKE) -s tooltest $(MAKE) -s test-doc $(MAKE) -s build-addons + $(MAKE) -s build-abort-tests $(MAKE) -s build-js-native-api-tests $(MAKE) -s build-node-api-tests $(MAKE) -s cctest @@ -324,6 +325,7 @@ test: all ## Runs default tests, linters, and builds docs. .PHONY: test-only test-only: all ## For a quick test, does not run linter or build docs. $(MAKE) build-addons + $(MAKE) build-abort-tests $(MAKE) build-js-native-api-tests $(MAKE) build-node-api-tests $(MAKE) cctest @@ -333,6 +335,7 @@ test-only: all ## For a quick test, does not run linter or build docs. # Used by `make coverage-test` test-cov: all $(MAKE) build-addons + $(MAKE) build-abort-tests $(MAKE) build-js-native-api-tests $(MAKE) build-node-api-tests $(MAKE) cctest @@ -452,6 +455,31 @@ test/node-api/.buildstamp: $(ADDONS_PREREQS) \ # TODO(bnoordhuis) Force rebuild after gyp or node-gyp update. build-node-api-tests: | $(NODE_EXE) test/node-api/.buildstamp +ABORT_BINDING_GYPS := \ + $(filter-out test/abort/??_*/binding.gyp, \ + $(wildcard test/abort/*/binding.gyp)) + +ABORT_BINDING_SOURCES := \ + $(filter-out test/abort/??_*/*.c, $(wildcard test/abort/*/*.c)) \ + $(filter-out test/abort/??_*/*.cc, $(wildcard test/abort/*/*.cc)) \ + $(filter-out test/abort/??_*/*.h, $(wildcard test/abort/*/*.h)) + +# Implicitly depends on $(NODE_EXE), see the build-node-api-tests rule for rationale. +test/abort/.buildstamp: $(ADDONS_PREREQS) \ + $(ABORT_BINDING_GYPS) $(ABORT_BINDING_SOURCES) \ + src/node_api.h src/node_api_types.h src/js_native_api.h \ + src/js_native_api_types.h src/js_native_api_v8.h src/js_native_api_v8_internals.h + @$(call run_build_addons,"$$PWD/test/abort",$@) + +.PHONY: build-abort-tests +# .buildstamp needs $(NODE_EXE) but cannot depend on it +# directly because it calls make recursively. The parent make cannot know +# if the subprocess touched anything so it pessimistically assumes that +# .buildstamp is out of date and need a rebuild. +# Just goes to show that recursive make really is harmful... +# TODO(bnoordhuis) Force rebuild after gyp or node-gyp update. +build-abort-tests: | $(NODE_EXE) test/abort/.buildstamp + BENCHMARK_NAPI_BINDING_GYPS := $(wildcard benchmark/napi/*/binding.gyp) BENCHMARK_NAPI_BINDING_SOURCES := \ @@ -472,12 +500,14 @@ clear-stalled: echo $${PS_OUT} | xargs kill -9; \ fi -test-build: | all build-addons build-js-native-api-tests build-node-api-tests +test-build: | all build-addons build-abort-tests build-js-native-api-tests build-node-api-tests test-build-js-native-api: all build-js-native-api-tests test-build-node-api: all build-node-api-tests +test-build-abort: all build-abort-tests + .PHONY: test-all test-all: test-build ## Run default tests with both Debug and Release builds. $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=debug,release @@ -490,7 +520,7 @@ test-all-suites: | clear-stalled test-build bench-addons-build doc-only ## Run a $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) test/* # CI_* variables should be kept synchronized with the ones in vcbuild.bat -CI_NATIVE_SUITES ?= addons js-native-api node-api +CI_NATIVE_SUITES ?= addons js-native-api node-api abort CI_JS_SUITES ?= default ifeq ($(node_use_openssl), false) CI_DOC := doctool @@ -502,7 +532,7 @@ endif # Build and test addons without building anything else # Related CI job: node-test-commit-arm-fanned test-ci-native: LOGLEVEL := info -test-ci-native: | test/addons/.buildstamp test/js-native-api/.buildstamp test/node-api/.buildstamp +test-ci-native: | test/addons/.buildstamp test/js-native-api/.buildstamp test/node-api/.buildstamp test/abort/.buildstamp $(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \ --mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \ $(TEST_CI_ARGS) $(CI_NATIVE_SUITES) @@ -524,7 +554,7 @@ test-ci-js: | clear-stalled .PHONY: test-ci # Related CI jobs: most CI tests, excluding node-test-commit-arm-fanned test-ci: LOGLEVEL := info -test-ci: | clear-stalled build-addons build-js-native-api-tests build-node-api-tests doc-only +test-ci: | clear-stalled build-addons build-abort-tests build-js-native-api-tests build-node-api-tests doc-only out/Release/cctest --gtest_output=xml:out/junit/cctest.xml $(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \ --mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \ @@ -599,6 +629,7 @@ test-doc: doc-only lint ## Builds, lints, and verifies the docs. else \ $(PYTHON) tools/test.py $(PARALLEL_ARGS) doctool; \ fi + $(NODE) tools/doc/checkLinks.js . test-known-issues: all $(PYTHON) tools/test.py $(PARALLEL_ARGS) known_issues @@ -628,8 +659,17 @@ test-node-api-clean: $(RM) -r test/node-api/*/build $(RM) test/node-api/.buildstamp +.PHONY: test-abort +test-abort: test-build-abort + $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) test-abort + +.PHONY: test-abort-clean +test-abort-clean: + $(RM) -r test/abort/*/build + $(RM) test/abort/.buildstamp + .PHONY: test-addons -test-addons: test-build test-js-native-api test-node-api +test-addons: test-build test-js-native-api test-node-api test-abort $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) addons .PHONY: test-addons-clean @@ -639,6 +679,7 @@ test-addons-clean: $(RM) test/addons/.buildstamp test/addons/.docbuildstamp $(MAKE) test-js-native-api-clean $(MAKE) test-node-api-clean + $(MAKE) test-abort-clean test-async-hooks: $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) async-hooks @@ -647,6 +688,7 @@ test-with-async-hooks: $(MAKE) build-addons $(MAKE) build-js-native-api-tests $(MAKE) build-node-api-tests + $(MAKE) build-abort-tests $(MAKE) cctest NODE_TEST_WITH_ASYNC_HOOKS=1 $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) \ $(CI_JS_SUITES) \ @@ -738,7 +780,7 @@ out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets run-npm-ci = $(PWD)/$(NPM) ci LINK_DATA = out/doc/apilinks.json -VERSIONS_DATA = out/doc/previous-versions.json +VERSIONS_DATA = out/previous-doc-versions.json gen-api = tools/doc/generate.js --node-version=$(FULLVERSION) \ --apilinks=$(LINK_DATA) $< --output-directory=out/doc/api \ --versions-file=$(VERSIONS_DATA) @@ -770,6 +812,7 @@ docopen: $(apidocs_html) .PHONY: docclean docclean: $(RM) -r out/doc + $(RM) "$(VERSIONS_DATA)" RAWVER=$(shell $(PYTHON) tools/getnodeversion.py) VERSION=v$(RAWVER) @@ -1187,9 +1230,9 @@ lint-md-build: $(warning "Deprecated no-op target 'lint-md-build'") ifeq ("$(wildcard tools/.mdlintstamp)","") - LINT_MD_NEWER = +LINT_MD_NEWER = else - LINT_MD_NEWER = -newer tools/.mdlintstamp +LINT_MD_NEWER = -newer tools/.mdlintstamp endif LINT_MD_TARGETS = doc src lib benchmark test tools/doc tools/icu $(wildcard *.md) diff --git a/README.md b/README.md index fa1b2962dd95a2..8ed51a91375928 100644 --- a/README.md +++ b/README.md @@ -157,16 +157,22 @@ For information about the governance of the Node.js project, see **Anatoli Papirovski** <apapirovski@mac.com> (he/him) * [BethGriggs](https://github.com/BethGriggs) - **Beth Griggs** <Bethany.Griggs@uk.ibm.com> (she/her) +* [BridgeAR](https://github.com/BridgeAR) - +**Ruben Bridgewater** <ruben@bridgewater.de> (he/him) * [ChALkeR](https://github.com/ChALkeR) - **Сковорода Никита Андреевич** <chalkerx@gmail.com> (he/him) * [cjihrig](https://github.com/cjihrig) - **Colin Ihrig** <cjihrig@gmail.com> (he/him) +* [codebytere](https://github.com/codebytere) - +**Shelley Vohr** <codebytere@gmail.com> (she/her) * [danbev](https://github.com/danbev) - **Daniel Bevenius** <daniel.bevenius@gmail.com> (he/him) * [fhinkel](https://github.com/fhinkel) - **Franziska Hinkelmann** <franziska.hinkelmann@gmail.com> (she/her) * [gabrielschulhof](https://github.com/gabrielschulhof) - **Gabriel Schulhof** <gabriel.schulhof@intel.com> +* [gireeshpunathil](https://github.com/gireeshpunathil) - +**Gireesh Punathil** <gpunathi@in.ibm.com> (he/him) * [jasnell](https://github.com/jasnell) - **James M Snell** <jasnell@gmail.com> (he/him) * [joyeecheung](https://github.com/joyeecheung) - @@ -175,6 +181,8 @@ For information about the governance of the Node.js project, see **Matteo Collina** <matteo.collina@gmail.com> (he/him) * [mhdawson](https://github.com/mhdawson) - **Michael Dawson** <michael_dawson@ca.ibm.com> (he/him) +* [mmarchini](https://github.com/mmarchini) - +**Matheus Marchini** <mat@mmarchini.me> * [MylesBorins](https://github.com/MylesBorins) - **Myles Borins** <myles.borins@gmail.com> (he/him) * [sam-github](https://github.com/sam-github) - @@ -198,8 +206,6 @@ For information about the governance of the Node.js project, see **Jeremiah Senkpiel** <fishrock123@rocketmail.com> (he/they) * [gibfahn](https://github.com/gibfahn) - **Gibson Fahnestock** <gibfahn@gmail.com> (he/him) -* [gireeshpunathil](https://github.com/gireeshpunathil) - -**Gireesh Punathil** <gpunathi@in.ibm.com> (he/him) * [indutny](https://github.com/indutny) - **Fedor Indutny** <fedor.indutny@gmail.com> * [isaacs](https://github.com/isaacs) - @@ -265,8 +271,6 @@ For information about the governance of the Node.js project, see **Сковорода Никита Андреевич** <chalkerx@gmail.com> (he/him) * [cjihrig](https://github.com/cjihrig) - **Colin Ihrig** <cjihrig@gmail.com> (he/him) -* [claudiorodriguez](https://github.com/claudiorodriguez) - -**Claudio Rodriguez** <cjrodr@yahoo.com> * [codebytere](https://github.com/codebytere) - **Shelley Vohr** <codebytere@gmail.com> (she/her) * [danbev](https://github.com/danbev) - @@ -289,6 +293,8 @@ For information about the governance of the Node.js project, see **Franziska Hinkelmann** <franziska.hinkelmann@gmail.com> (she/her) * [Fishrock123](https://github.com/Fishrock123) - **Jeremiah Senkpiel** <fishrock123@rocketmail.com> (he/they) +* [Flarna](https://github.com/Flarna) - +**Gerhard Stöbich** <deb2001-github@yahoo.de> (he/they) * [gabrielschulhof](https://github.com/gabrielschulhof) - **Gabriel Schulhof** <gabriel.schulhof@intel.com> * [gdams](https://github.com/gdams) - @@ -307,14 +313,12 @@ For information about the governance of the Node.js project, see **Guy Bedford** <guybedford@gmail.com> (he/him) * [hashseed](https://github.com/hashseed) - **Yang Guo** <yangguo@chromium.org> (he/him) +* [himself65](https://github.com/himself65) - +**Zeyu Yang** <himself65@outlook.com> (he/him) * [hiroppy](https://github.com/hiroppy) - **Yuta Hiroto** <hello@hiroppy.me> (he/him) -* [iarna](https://github.com/iarna) - -**Rebecca Turner** <me@re-becca.org> * [indutny](https://github.com/indutny) - **Fedor Indutny** <fedor.indutny@gmail.com> -* [italoacasas](https://github.com/italoacasas) - -**Italo A. Casas** <me@italoacasas.com> (he/him) * [JacksonTian](https://github.com/JacksonTian) - **Jackson Tian** <shyvo1987@gmail.com> * [jasnell](https://github.com/jasnell) - @@ -347,12 +351,12 @@ For information about the governance of the Node.js project, see **Matteo Collina** <matteo.collina@gmail.com> (he/him) * [mhdawson](https://github.com/mhdawson) - **Michael Dawson** <michael_dawson@ca.ibm.com> (he/him) +* [mildsunrise](https://github.com/mildsunrise) - +**Alba Mendez** <me@alba.sh> (she/her) * [misterdjules](https://github.com/misterdjules) - **Julien Gilli** <jgilli@nodejs.org> * [mmarchini](https://github.com/mmarchini) - **Matheus Marchini** <mat@mmarchini.me> -* [MoonBall](https://github.com/MoonBall) - -**Chen Gang** <gangc.cxy@foxmail.com> * [mscdex](https://github.com/mscdex) - **Brian White** <mscdex@mscdex.net> * [MylesBorins](https://github.com/MylesBorins) - @@ -407,8 +411,6 @@ For information about the governance of the Node.js project, see **Tiancheng "Timothy" Gu** <timothygu99@gmail.com> (he/him) * [tniessen](https://github.com/tniessen) - **Tobias Nießen** <tniessen@tnie.de> -* [trevnorris](https://github.com/trevnorris) - -**Trevor Norris** <trev.norris@gmail.com> * [trivikr](https://github.com/trivikr) - **Trivikram Kamat** <trivikr.dev@gmail.com> * [Trott](https://github.com/Trott) - @@ -444,6 +446,8 @@ For information about the governance of the Node.js project, see **Calvin Metcalf** <calvin.metcalf@gmail.com> * [chrisdickinson](https://github.com/chrisdickinson) - **Chris Dickinson** <christopher.s.dickinson@gmail.com> +* [claudiorodriguez](https://github.com/claudiorodriguez) - +**Claudio Rodriguez** <cjrodr@yahoo.com> * [DavidCai1993](https://github.com/DavidCai1993) - **David Cai** <davidcai1993@yahoo.com> (he/him) * [eljefedelrodeodeljefe](https://github.com/eljefedelrodeodeljefe) - @@ -454,12 +458,16 @@ For information about the governance of the Node.js project, see **Daniel Wang** <wangyang0123@gmail.com> * [glentiki](https://github.com/glentiki) - **Glen Keane** <glenkeane.94@gmail.com> (he/him) +* [iarna](https://github.com/iarna) - +**Rebecca Turner** <me@re-becca.org> * [imran-iq](https://github.com/imran-iq) - **Imran Iqbal** <imran@imraniqbal.org> * [imyller](https://github.com/imyller) - **Ilkka Myller** <ilkka.myller@nodefield.com> * [isaacs](https://github.com/isaacs) - **Isaac Z. Schlueter** <i@izs.me> +* [italoacasas](https://github.com/italoacasas) - +**Italo A. Casas** <me@italoacasas.com> (he/him) * [jasongin](https://github.com/jasongin) - **Jason Ginchereau** <jasongin@microsoft.com> * [jbergstroem](https://github.com/jbergstroem) - @@ -486,6 +494,8 @@ For information about the governance of the Node.js project, see **Mikeal Rogers** <mikeal.rogers@gmail.com> * [monsanto](https://github.com/monsanto) - **Christopher Monsanto** <chris@monsan.to> +* [MoonBall](https://github.com/MoonBall) - +**Chen Gang** <gangc.cxy@foxmail.com> * [not-an-aardvark](https://github.com/not-an-aardvark) - **Teddy Katz** <teddy.katz@gmail.com> (he/him) * [Olegas](https://github.com/Olegas) - @@ -520,6 +530,8 @@ For information about the governance of the Node.js project, see **Christian Tellnes** <christian@tellnes.no> * [thlorenz](https://github.com/thlorenz) - **Thorsten Lorenz** <thlorenz@gmx.de> +* [trevnorris](https://github.com/trevnorris) - +**Trevor Norris** <trev.norris@gmail.com> * [tunniclm](https://github.com/tunniclm) - **Mike Tunnicliffe** <m.j.tunnicliffe@gmail.com> * [vkurchatkin](https://github.com/vkurchatkin) - diff --git a/android-configure b/android-configure index 59f0a40c1ac214..a7cb2b9c8b4a78 100755 --- a/android-configure +++ b/android-configure @@ -8,29 +8,39 @@ # modules with npm. Also, don't forget to set the arch in npm config using # 'npm config set arch=' +if [ $# -ne 3 ]; then + echo "$0 should have 3 parameters: ndk_path, target_arch and sdk_version" + exit 1 +fi + +NDK_PATH=$1 +ARCH="$2" +ANDROID_SDK_VERSION=$3 -if [ -z "$2" ]; then - ARCH=arm -else - ARCH="$2" +if [ $ANDROID_SDK_VERSION -lt 23 ]; then + echo "$ANDROID_SDK_VERSION should equal or later than 23(Android 6.0)" fi CC_VER="4.9" + case $ARCH in arm) - DEST_CPU="$ARCH" - SUFFIX="$ARCH-linux-androideabi" - TOOLCHAIN_NAME="$SUFFIX" + DEST_CPU="arm" + TOOLCHAIN_NAME="armv7-linux-androideabi" ;; x86) DEST_CPU="ia32" - SUFFIX="i686-linux-android" - TOOLCHAIN_NAME="$ARCH" + TOOLCHAIN_NAME="i686-linux-android" ;; x86_64) - DEST_CPU="ia32" - SUFFIX="$ARCH-linux-android" - TOOLCHAIN_NAME="$ARCH" + DEST_CPU="x64" + TOOLCHAIN_NAME="x86_64-linux-android" + ARCH="x64" + ;; + arm64|aarch64) + DEST_CPU="arm64" + TOOLCHAIN_NAME="aarch64-linux-android" + ARCH="arm64" ;; *) echo "Unsupported architecture provided: $ARCH" @@ -38,36 +48,31 @@ case $ARCH in ;; esac -NDK_PATH=$1 -function make_toolchain { - $NDK_PATH/build/tools/make-standalone-toolchain.sh \ - --toolchain=$TOOLCHAIN_NAME-$CC_VER \ - --arch=$ARCH \ - --install-dir=$TOOLCHAIN \ - --platform=android-21 -} +HOST_OS="linux" +HOST_ARCH="x86_64" +export CC_host=$(which gcc) +export CXX_host=$(which g++) -export TOOLCHAIN=$PWD/android-toolchain -if [ -d "$TOOLCHAIN" ]; then - read -r -p "NDK toolchain already exists. Replace it? [y/N]" response - case "$response" in - [Yy]) - rm -rf "$TOOLCHAIN" - make_toolchain - esac -else - make_toolchain +host_gcc_version=$($CC_host --version | grep gcc | awk '{print $NF}') +major=$(echo $host_gcc_version | awk -F . '{print $1}') +minor=$(echo $host_gcc_version | awk -F . '{print $2}') +if [ -z $major ] || [ -z $minor ] || [ $major -lt 6 ] || [ $major -eq 6 -a $minor -lt 3 ]; then + echo "host gcc $host_gcc_version is too old, need gcc 6.3.0" + exit 1 fi + +SUFFIX="$TOOLCHAIN_NAME$ANDROID_SDK_VERSION" +TOOLCHAIN=$NDK_PATH/toolchains/llvm/prebuilt/$HOST_OS-$HOST_ARCH + export PATH=$TOOLCHAIN/bin:$PATH -export AR=$TOOLCHAIN/bin/$SUFFIX-ar -export CC=$TOOLCHAIN/bin/$SUFFIX-gcc -export CXX=$TOOLCHAIN/bin/$SUFFIX-g++ -export LINK=$TOOLCHAIN/bin/$SUFFIX-g++ +export CC=$TOOLCHAIN/bin/$SUFFIX-clang +export CXX=$TOOLCHAIN/bin/$SUFFIX-clang++ + GYP_DEFINES="target_arch=$ARCH" GYP_DEFINES+=" v8_target_arch=$ARCH" GYP_DEFINES+=" android_target_arch=$ARCH" -GYP_DEFINES+=" host_os=linux OS=android" +GYP_DEFINES+=" host_os=$HOST_OS OS=android" export GYP_DEFINES if [ -f "configure" ]; then @@ -75,5 +80,6 @@ if [ -f "configure" ]; then --dest-cpu=$DEST_CPU \ --dest-os=android \ --without-snapshot \ - --openssl-no-asm + --openssl-no-asm \ + --cross-compiling fi diff --git a/benchmark/async_hooks/gc-tracking.js b/benchmark/async_hooks/gc-tracking.js index 030b5f8e1934f8..4a59a5a4b655c5 100644 --- a/benchmark/async_hooks/gc-tracking.js +++ b/benchmark/async_hooks/gc-tracking.js @@ -1,11 +1,12 @@ 'use strict'; const common = require('../common.js'); -const { AsyncResource } = require('async_hooks'); +const { createHook, AsyncResource } = require('async_hooks'); const bench = common.createBenchmark(main, { n: [1e6], method: [ 'trackingEnabled', + 'trackingEnabledWithDestroyHook', 'trackingDisabled', ] }, { @@ -30,6 +31,14 @@ function main({ n, method }) { } endAfterGC(n); break; + case 'trackingEnabledWithDestroyHook': + createHook({ destroy: () => {} }).enable(); + bench.start(); + for (let i = 0; i < n; i++) { + new AsyncResource('foobar'); + } + endAfterGC(n); + break; case 'trackingDisabled': bench.start(); for (let i = 0; i < n; i++) { diff --git a/common.gypi b/common.gypi index 38a22fc5f1ddd6..fd3c4738baea1c 100644 --- a/common.gypi +++ b/common.gypi @@ -29,16 +29,12 @@ 'openssl_fips%': '', - # Some STL containers (e.g. std::vector) do not preserve ABI compatibility - # between debug and non-debug mode. - 'disable_glibcxx_debug': 1, - # Don't use ICU data file (icudtl.dat) from V8, we use our own. 'icu_use_data_file_flag%': 0, # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.34', + 'v8_embedder_string': '-node.35', ##### V8 defaults for Node.js ##### @@ -430,6 +426,15 @@ '-Wl,-brtl', ], }, { # else it's `AIX` + # Disable the following compiler warning: + # + # warning: visibility attribute not supported in this + # configuration; ignored [-Wattributes] + # + # This is gcc complaining about __attribute((visibility("default")) + # in static library builds. Legitimate but harmless and it drowns + # out more relevant warnings. + 'cflags': [ '-Wno-attributes' ], 'ldflags': [ '-Wl,-blibpath:/usr/lib:/lib:/opt/freeware/lib/pthread/ppc64', ], @@ -442,6 +447,10 @@ 'defines': [ '_GLIBCXX_USE_C99_MATH' ], 'libraries': [ '-llog' ], }], + ['_toolset=="host"', { + 'cflags': [ '-pthread' ], + 'ldflags': [ '-pthread' ], + }], ], }], ['OS=="mac"', { diff --git a/configure.py b/configure.py index 5c1360615de6b3..af20d6108e48ac 100755 --- a/configure.py +++ b/configure.py @@ -574,7 +574,7 @@ parser.add_option('--enable-asan', action='store_true', dest='enable_asan', - help='build with asan') + help='compile for Address Sanitizer to find memory bugs') parser.add_option('--enable-static', action='store_true', @@ -815,13 +815,19 @@ def check_compiler(o): return ok, is_clang, clang_version, gcc_version = try_check_compiler(CXX, 'c++') + version_str = ".".join(map(str, clang_version if is_clang else gcc_version)) + print_verbose('Detected %sC++ compiler (CXX=%s) version: %s' % + ('clang ' if is_clang else '', CXX, version_str)) if not ok: warn('failed to autodetect C++ compiler version (CXX=%s)' % CXX) elif clang_version < (8, 0, 0) if is_clang else gcc_version < (6, 3, 0): warn('C++ compiler (CXX=%s, %s) too old, need g++ 6.3.0 or clang++ 8.0.0' % - (CXX, ".".join(map(str, clang_version if is_clang else gcc_version)))) + (CXX, version_str)) ok, is_clang, clang_version, gcc_version = try_check_compiler(CC, 'c') + version_str = ".".join(map(str, clang_version if is_clang else gcc_version)) + print_verbose('Detected %sC compiler (CC=%s) version: %s' % + ('clang ' if is_clang else '', CC, version_str)) if not ok: warn('failed to autodetect C compiler version (CC=%s)' % CC) elif not is_clang and gcc_version < (4, 2, 0): @@ -829,7 +835,7 @@ def check_compiler(o): # do for the C bits. However, we might as well encourage people to upgrade # to a version that is not completely ancient. warn('C compiler (CC=%s, %s) too old, need gcc 4.2 or clang 3.2' % - (CC, ".".join(map(str, gcc_version)))) + (CC, version_str)) o['variables']['llvm_version'] = get_llvm_version(CC) if is_clang else '0.0' diff --git a/deps/acorn-plugins/acorn-class-fields/package.json b/deps/acorn-plugins/acorn-class-fields/package.json index 4df166ba19fa4a..550511399f248d 100644 --- a/deps/acorn-plugins/acorn-class-fields/package.json +++ b/deps/acorn-plugins/acorn-class-fields/package.json @@ -1,68 +1,36 @@ { - "_from": "acorn-class-fields", - "_id": "acorn-class-fields@0.3.1", - "_inBundle": false, - "_integrity": "sha512-X/8hSJuregAnrvfV1Y80VJNfeJx1uhw7yskOwvL631ygYeCGVLPumCnnPDHYZ8acV3ytHhg53K171H3tAemgiw==", - "_location": "/acorn-class-fields", - "_phantomChildren": {}, - "_requested": { - "type": "tag", - "registry": true, - "raw": "acorn-class-fields", - "name": "acorn-class-fields", - "escapedName": "acorn-class-fields", - "rawSpec": "", - "saveSpec": null, - "fetchSpec": "latest" - }, - "_requiredBy": [ - "#USER", - "/" - ], - "_resolved": "https://registry.npmjs.org/acorn-class-fields/-/acorn-class-fields-0.3.1.tgz", - "_shasum": "032ce47a9688a71d4713ee366fadcb7fefaea9e0", - "_spec": "acorn-class-fields", - "_where": "/home/ruben/repos/node/node", - "bugs": { - "url": "https://github.com/acornjs/acorn-class-fields/issues" - }, - "bundleDependencies": false, + "name": "acorn-class-fields", + "description": "Support for class fields in acorn", + "homepage": "https://github.com/acornjs/acorn-class-fields", "contributors": [ - { - "name": "Adrian Heine", - "email": "mail@adrianheine.de" - } + "Adrian Heine " ], - "dependencies": { - "acorn-private-class-elements": "^0.1.1" - }, - "deprecated": false, - "description": "Support for class fields in acorn", - "devDependencies": { - "acorn": "^6.1.0", - "eslint": "^5.13.0", - "eslint-plugin-node": "^8.0.1", - "mocha": "^5.2.0", - "test262": "git+https://github.com/tc39/test262.git#33a306d1026b72227eb50a918db19ada16f12b3d", - "test262-parser-runner": "^0.5.0" - }, "engines": { "node": ">=4.8.2" }, - "homepage": "https://github.com/acornjs/acorn-class-fields", - "license": "MIT", - "name": "acorn-class-fields", - "peerDependencies": { - "acorn": "^6.0.0" - }, "repository": { "type": "git", - "url": "git+https://github.com/acornjs/acorn-class-fields.git" + "url": "https://github.com/acornjs/acorn-class-fields" }, + "license": "MIT", "scripts": { - "lint": "eslint -c .eslintrc.json .", "test": "mocha", - "test:test262": "node run_test262.js" + "test:test262": "node run_test262.js", + "lint": "eslint -c .eslintrc.json ." }, - "version": "0.3.1" -} + "peerDependencies": { + "acorn": "^6.0.0" + }, + "version": "0.3.1", + "devDependencies": { + "acorn": "^6.1.0", + "eslint": "^5.13.0", + "eslint-plugin-node": "^8.0.1", + "mocha": "^5.2.0", + "test262": "git+https://github.com/tc39/test262.git#33a306d1026b72227eb50a918db19ada16f12b3d", + "test262-parser-runner": "^0.5.0" + }, + "dependencies": { + "acorn-private-class-elements": "^0.1.1" + } +} \ No newline at end of file diff --git a/deps/acorn-plugins/acorn-numeric-separator/package.json b/deps/acorn-plugins/acorn-numeric-separator/package.json index bf3615e6b7e7ea..cc0c52a65d2dfe 100644 --- a/deps/acorn-plugins/acorn-numeric-separator/package.json +++ b/deps/acorn-plugins/acorn-numeric-separator/package.json @@ -1,65 +1,33 @@ { - "_from": "acorn-numeric-separator", - "_id": "acorn-numeric-separator@0.3.0", - "_inBundle": false, - "_integrity": "sha512-g9FikQZHwG/P1Xs+dDzecqagmGBbU4b8OF4UbDQK8Wr8apwuFGG1c7KiaFxC4ClYU8D7zNl60vzqOCUuhKM3kA==", - "_location": "/acorn-numeric-separator", - "_phantomChildren": {}, - "_requested": { - "type": "tag", - "registry": true, - "raw": "acorn-numeric-separator", - "name": "acorn-numeric-separator", - "escapedName": "acorn-numeric-separator", - "rawSpec": "", - "saveSpec": null, - "fetchSpec": "latest" - }, - "_requiredBy": [ - "#USER", - "/" - ], - "_resolved": "https://registry.npmjs.org/acorn-numeric-separator/-/acorn-numeric-separator-0.3.0.tgz", - "_shasum": "15e2f9a698bbec83a339a70a7026ab1d9d257de2", - "_spec": "acorn-numeric-separator", - "_where": "/home/ruben/repos/node/node", - "bugs": { - "url": "https://github.com/acornjs/acorn-numeric-separator/issues" - }, - "bundleDependencies": false, + "name": "acorn-numeric-separator", + "description": "Support for numeric separators in acorn", + "homepage": "https://github.com/acornjs/acorn-numeric-separator", "contributors": [ - { - "name": "Adrian Heine", - "email": "mail@adrianheine.de" - } + "Adrian Heine " ], - "deprecated": false, - "description": "Support for numeric separators in acorn", - "devDependencies": { - "acorn": "^6.0.0", - "eslint": "^5.5.0", - "eslint-plugin-node": "^8.0.1", - "mocha": "^6.0.2", - "test262": "git+https://github.com/tc39/test262.git#de567d3aa5de4eaa11e00131d26b9fe77997dfb0", - "test262-parser-runner": "^0.5.0" - }, "engines": { "node": ">=4.8.2" }, - "homepage": "https://github.com/acornjs/acorn-numeric-separator", - "license": "MIT", - "name": "acorn-numeric-separator", - "peerDependencies": { - "acorn": "^6.0.0" - }, "repository": { "type": "git", - "url": "git+https://github.com/acornjs/acorn-numeric-separator.git" + "url": "https://github.com/acornjs/acorn-numeric-separator" }, + "license": "MIT", "scripts": { - "lint": "eslint -c .eslintrc.json .", "test": "mocha", - "test:test262": "node run_test262.js" + "test:test262": "node run_test262.js", + "lint": "eslint -c .eslintrc.json ." + }, + "peerDependencies": { + "acorn": "^6.0.0" }, - "version": "0.3.0" -} + "version": "0.3.0", + "devDependencies": { + "acorn": "^6.0.0", + "eslint": "^5.5.0", + "eslint-plugin-node": "^8.0.1", + "mocha": "^6.0.2", + "test262": "git+https://github.com/tc39/test262.git#de567d3aa5de4eaa11e00131d26b9fe77997dfb0", + "test262-parser-runner": "^0.5.0" + } +} \ No newline at end of file diff --git a/deps/acorn-plugins/acorn-private-class-elements/CHANGELOG.md b/deps/acorn-plugins/acorn-private-class-elements/CHANGELOG.md index 5b49344b7ac5b6..6d4854429aacfa 100644 --- a/deps/acorn-plugins/acorn-private-class-elements/CHANGELOG.md +++ b/deps/acorn-plugins/acorn-private-class-elements/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.0 (2020-03-07) + +* Mark as compatible with acorn v7 + ## 0.1.1 (2019-02-09) * Add \_branch() method diff --git a/deps/acorn-plugins/acorn-private-class-elements/index.js b/deps/acorn-plugins/acorn-private-class-elements/index.js index 90f2b704371c9f..1f40bda9baa2eb 100644 --- a/deps/acorn-plugins/acorn-private-class-elements/index.js +++ b/deps/acorn-plugins/acorn-private-class-elements/index.js @@ -1,8 +1,8 @@ "use strict" const acorn = require('internal/deps/acorn/acorn/dist/acorn') -if (acorn.version.indexOf("6.") != 0 || acorn.version.indexOf("6.0.") == 0) { - throw new Error(`acorn-private-class-elements requires acorn@^6.1.0, not ${acorn.version}`) +if (acorn.version.indexOf("6.") != 0 && acorn.version.indexOf("6.0.") == 0 && acorn.version.indexOf("7.") != 0) { + throw new Error(`acorn-private-class-elements requires acorn@^6.1.0 or acorn@7.0.0, not ${acorn.version}`) } const tt = acorn.tokTypes const TokenType = acorn.TokenType diff --git a/deps/acorn-plugins/acorn-private-class-elements/package.json b/deps/acorn-plugins/acorn-private-class-elements/package.json index cd43012dc79884..b8b652a1e9e2f3 100644 --- a/deps/acorn-plugins/acorn-private-class-elements/package.json +++ b/deps/acorn-plugins/acorn-private-class-elements/package.json @@ -1,63 +1,30 @@ { - "_from": "acorn-private-class-elements@^0.1.1", - "_id": "acorn-private-class-elements@0.1.1", - "_inBundle": false, - "_integrity": "sha512-bZpmSnaOsK3jkF7J8xaLJ05f008vapPX+XliIv8+jjkclvDR+M4OnTHLhFnCCSeJ0fMwRKjbY+BXsglSNpVZtw==", - "_location": "/acorn-private-class-elements", - "_phantomChildren": {}, - "_requested": { - "type": "range", - "registry": true, - "raw": "acorn-private-class-elements@^0.1.1", - "name": "acorn-private-class-elements", - "escapedName": "acorn-private-class-elements", - "rawSpec": "^0.1.1", - "saveSpec": null, - "fetchSpec": "^0.1.1" - }, - "_requiredBy": [ - "/acorn-class-fields" - ], - "_resolved": "https://registry.npmjs.org/acorn-private-class-elements/-/acorn-private-class-elements-0.1.1.tgz", - "_shasum": "85209cb5791ab84fde2362cb208fa51e7679bcdc", - "_spec": "acorn-private-class-elements@^0.1.1", - "_where": "/home/ruben/repos/node/node/node_modules/acorn-class-fields", - "bugs": { - "url": "https://github.com/acornjs/acorn-private-class-elements/issues" - }, - "bundleDependencies": false, + "name": "acorn-private-class-elements", + "description": "Helpers for supporting private class methods and fields in acorn", + "homepage": "https://github.com/acornjs/acorn-private-class-elements", "contributors": [ - { - "name": "Adrian Heine", - "email": "mail@adrianheine.de" - } + "Adrian Heine " ], - "dependencies": { - "mocha": "^5.2.0" - }, - "deprecated": false, - "description": "Helpers for supporting private class methods and fields in acorn", - "devDependencies": { - "acorn": "^6.1.0", - "eslint": "^5.13.0", - "eslint-plugin-node": "^8.0.1" - }, "engines": { "node": ">=4.8.2" }, - "homepage": "https://github.com/acornjs/acorn-private-class-elements", - "license": "MIT", - "name": "acorn-private-class-elements", - "peerDependencies": { - "acorn": "^6.1.0" - }, "repository": { "type": "git", - "url": "git+https://github.com/acornjs/acorn-private-class-elements.git" + "url": "https://github.com/acornjs/acorn-private-class-elements" }, + "license": "MIT", "scripts": { - "lint": "eslint -c .eslintrc.json .", - "test": "mocha" + "test": "mocha", + "lint": "eslint -c .eslintrc.json ." + }, + "peerDependencies": { + "acorn": "^6.1.0 || ^7.0.0" }, - "version": "0.1.1" -} + "version": "0.2.0", + "devDependencies": { + "acorn": "^7.0.0", + "eslint": "^6.8.0", + "eslint-plugin-node": "^11.0.0", + "mocha": "^7.1.0" + } +} \ No newline at end of file diff --git a/deps/acorn-plugins/acorn-private-methods/package.json b/deps/acorn-plugins/acorn-private-methods/package.json index d25c611316019f..e7b91592aaa9b9 100644 --- a/deps/acorn-plugins/acorn-private-methods/package.json +++ b/deps/acorn-plugins/acorn-private-methods/package.json @@ -1,43 +1,30 @@ { - "_from": "acorn-private-methods", - "_id": "acorn-private-methods@0.3.0", - "_inBundle": false, - "_integrity": "sha512-+gWTjSA+13lsv1mwCPosSrLzEyghYtWgrr/1Ck7i7Pu5iK7Ke0hOgw3IW1RUxhc4qS2QTQBQx2+qHYqsa4Qlqw==", - "_location": "/acorn-private-methods", - "_phantomChildren": {}, - "_requested": { - "type": "tag", - "registry": true, - "raw": "acorn-private-methods", - "name": "acorn-private-methods", - "escapedName": "acorn-private-methods", - "rawSpec": "", - "saveSpec": null, - "fetchSpec": "latest" - }, - "_requiredBy": [ - "#USER", - "/" - ], - "_resolved": "https://registry.npmjs.org/acorn-private-methods/-/acorn-private-methods-0.3.0.tgz", - "_shasum": "a5a9f8cd83d175bc138fa22592fababd0afda35d", - "_spec": "acorn-private-methods", - "_where": "/home/ruben/repos/node/node", - "bugs": { - "url": "https://github.com/acornjs/acorn-private-methods/issues" - }, - "bundleDependencies": false, + "name": "acorn-private-methods", + "description": "Support for private methods in acorn", + "homepage": "https://github.com/acornjs/acorn-private-methods", "contributors": [ - { - "name": "Adrian Heine", - "email": "mail@adrianheine.de" - } + "Adrian Heine " ], + "engines": { + "node": ">=4.8.2" + }, + "repository": { + "type": "git", + "url": "https://github.com/acornjs/acorn-private-methods" + }, + "license": "MIT", + "scripts": { + "test": "mocha", + "test:test262": "node run_test262.js", + "lint": "eslint -c .eslintrc.json ." + }, + "peerDependencies": { + "acorn": "^6.1.0" + }, "dependencies": { "acorn-private-class-elements": "^0.1.0" }, - "deprecated": false, - "description": "Support for private methods in acorn", + "version": "0.3.0", "devDependencies": { "acorn": "^6.1.0", "eslint": "^5.13.0", @@ -45,24 +32,5 @@ "mocha": "^5.2.0", "test262": "git+https://github.com/tc39/test262.git#33a306d1026b72227eb50a918db19ada16f12b3d", "test262-parser-runner": "^0.5.0" - }, - "engines": { - "node": ">=4.8.2" - }, - "homepage": "https://github.com/acornjs/acorn-private-methods", - "license": "MIT", - "name": "acorn-private-methods", - "peerDependencies": { - "acorn": "^6.1.0" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/acornjs/acorn-private-methods.git" - }, - "scripts": { - "lint": "eslint -c .eslintrc.json .", - "test": "mocha", - "test:test262": "node run_test262.js" - }, - "version": "0.3.0" -} + } +} \ No newline at end of file diff --git a/deps/acorn-plugins/acorn-static-class-features/package.json b/deps/acorn-plugins/acorn-static-class-features/package.json index ff9ff30c05911b..066223d9965df5 100644 --- a/deps/acorn-plugins/acorn-static-class-features/package.json +++ b/deps/acorn-plugins/acorn-static-class-features/package.json @@ -1,68 +1,36 @@ { - "_from": "acorn-static-class-features", - "_id": "acorn-static-class-features@0.2.0", - "_inBundle": false, - "_integrity": "sha512-46IooHSRsvgSi+t36Wx9iPfF9BKFKVDcAWELXVqvKHmZogSCk11iUCi2FiZmLeTaM0hlJ3EYDyYiVmHRUGPzWA==", - "_location": "/acorn-static-class-features", - "_phantomChildren": {}, - "_requested": { - "type": "tag", - "registry": true, - "raw": "acorn-static-class-features", - "name": "acorn-static-class-features", - "escapedName": "acorn-static-class-features", - "rawSpec": "", - "saveSpec": null, - "fetchSpec": "latest" - }, - "_requiredBy": [ - "#USER", - "/" - ], - "_resolved": "https://registry.npmjs.org/acorn-static-class-features/-/acorn-static-class-features-0.2.0.tgz", - "_shasum": "8a12b0b280b2e067e268fdbb14116a5b02affd71", - "_spec": "acorn-static-class-features", - "_where": "/home/ruben/repos/node/node", - "bugs": { - "url": "https://github.com/acornjs/acorn-static-class-features/issues" - }, - "bundleDependencies": false, + "name": "acorn-static-class-features", + "description": "Support for static class features in acorn", + "homepage": "https://github.com/acornjs/acorn-static-class-features", "contributors": [ - { - "name": "Adrian Heine", - "email": "mail@adrianheine.de" - } + "Adrian Heine " ], - "dependencies": { - "acorn-private-class-elements": "^0.1.0" - }, - "deprecated": false, - "description": "Support for static class features in acorn", - "devDependencies": { - "acorn": "^6.1.0", - "eslint": "^5.13.0", - "eslint-plugin-node": "^8.0.1", - "mocha": "^5.2.0", - "test262": "git+https://github.com/tc39/test262.git#33a306d1026b72227eb50a918db19ada16f12b3d", - "test262-parser-runner": "^0.5.0" - }, "engines": { "node": ">=4.8.2" }, - "homepage": "https://github.com/acornjs/acorn-static-class-features", - "license": "MIT", - "name": "acorn-static-class-features", - "peerDependencies": { - "acorn": "^6.1.0" - }, "repository": { "type": "git", - "url": "git+https://github.com/acornjs/acorn-static-class-features.git" + "url": "https://github.com/acornjs/acorn-static-class-features" }, + "license": "MIT", "scripts": { - "lint": "eslint -c .eslintrc.json .", "test": "mocha", - "test:test262": "node run_test262.js" + "test:test262": "node run_test262.js", + "lint": "eslint -c .eslintrc.json ." + }, + "peerDependencies": { + "acorn": "^6.1.0" }, - "version": "0.2.0" -} + "version": "0.2.0", + "devDependencies": { + "acorn": "^6.1.0", + "eslint": "^5.13.0", + "eslint-plugin-node": "^8.0.1", + "mocha": "^5.2.0", + "test262": "git+https://github.com/tc39/test262.git#33a306d1026b72227eb50a918db19ada16f12b3d", + "test262-parser-runner": "^0.5.0" + }, + "dependencies": { + "acorn-private-class-elements": "^0.1.1" + } +} \ No newline at end of file diff --git a/deps/acorn/acorn-walk/CHANGELOG.md b/deps/acorn/acorn-walk/CHANGELOG.md index c02dbd7dda8417..89114970bbeae4 100644 --- a/deps/acorn/acorn-walk/CHANGELOG.md +++ b/deps/acorn/acorn-walk/CHANGELOG.md @@ -1,3 +1,21 @@ +## 7.1.1 (2020-02-13) + +### Bug fixes + +Clean up the type definitions to actually work well with the main parser. + +## 7.1.0 (2020-02-11) + +### New features + +Add a TypeScript definition file for the library. + +## 7.0.0 (2017-08-12) + +### New features + +Support walking `ImportExpression` nodes. + ## 6.2.0 (2017-07-04) ### New features diff --git a/deps/acorn/acorn-walk/dist/walk.js b/deps/acorn/acorn-walk/dist/walk.js index 398a0032f4bb65..7aaab9ce824f60 100644 --- a/deps/acorn/acorn-walk/dist/walk.js +++ b/deps/acorn/acorn-walk/dist/walk.js @@ -34,7 +34,7 @@ // An ancestor walk keeps an array of ancestor nodes (including the // current node) and passes them to the callback as third parameter // (and also as state parameter when no other state is present). - function ancestor(node, visitors, baseVisitor, state) { + function ancestor(node, visitors, baseVisitor, state, override) { var ancestors = []; if (!baseVisitor) { baseVisitor = base ; }(function c(node, st, override) { @@ -44,7 +44,7 @@ baseVisitor[type](node, st, c); if (found) { found(node, st || ancestors, ancestors); } if (isNew) { ancestors.pop(); } - })(node, state); + })(node, state, override); } // A recursive walk is one where your functions override the default @@ -416,7 +416,10 @@ } c(node.source, st, "Expression"); }; - base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.Literal = base.Import = ignore; + base.ImportExpression = function (node, st, c) { + c(node.source, st, "Expression"); + }; + base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.Literal = ignore; base.TaggedTemplateExpression = function (node, st, c) { c(node.tag, st, "Expression"); diff --git a/deps/acorn/acorn-walk/package.json b/deps/acorn/acorn-walk/package.json index 239e6c729aedfe..a66ca892ced577 100644 --- a/deps/acorn/acorn-walk/package.json +++ b/deps/acorn/acorn-walk/package.json @@ -3,8 +3,9 @@ "description": "ECMAScript (ESTree) AST walker", "homepage": "https://github.com/acornjs/acorn", "main": "dist/walk.js", + "types": "dist/walk.d.ts", "module": "dist/walk.mjs", - "version": "6.2.0", + "version": "7.1.1", "engines": {"node": ">=0.4.0"}, "maintainers": [ { diff --git a/deps/acorn/acorn/CHANGELOG.md b/deps/acorn/acorn/CHANGELOG.md index f94f23ccf295b0..32f5ce8f3bb4bf 100644 --- a/deps/acorn/acorn/CHANGELOG.md +++ b/deps/acorn/acorn/CHANGELOG.md @@ -1,3 +1,47 @@ +## 7.1.1 (2020-03-01) + +### Bug fixes + +Treat `\8` and `\9` as invalid escapes in template strings. + +Allow unicode escapes in property names that are keywords. + +Don't error on an exponential operator expression as argument to `await`. + +More carefully check for valid UTF16 surrogate pairs in regexp validator. + +## 7.1.0 (2019-09-24) + +### Bug fixes + +Disallow trailing object literal commas when ecmaVersion is less than 5. + +### New features + +Add a static `acorn` property to the `Parser` class that contains the entire module interface, to allow plugins to access the instance of the library that they are acting on. + +## 7.0.0 (2019-08-13) + +### Breaking changes + +Changes the node format for dynamic imports to use the `ImportExpression` node type, as defined in [ESTree](https://github.com/estree/estree/blob/master/es2020.md#importexpression). + +Makes 10 (ES2019) the default value for the `ecmaVersion` option. + +## 6.3.0 (2019-08-12) + +### New features + +`sourceType: "module"` can now be used even when `ecmaVersion` is less than 6, to parse module-style code that otherwise conforms to an older standard. + +## 6.2.1 (2019-07-21) + +### Bug fixes + +Fix bug causing Acorn to treat some characters as identifier characters that shouldn't be treated as such. + +Fix issue where setting the `allowReserved` option to `"never"` allowed reserved words in some circumstances. + ## 6.2.0 (2019-07-04) ### Bug fixes @@ -8,9 +52,9 @@ Disallow binding `let` in patterns. ### New features -Support bigint syntax with `ecmaVersion` >= 10. +Support bigint syntax with `ecmaVersion` >= 11. -Support dynamic `import` syntax with `ecmaVersion` >= 10. +Support dynamic `import` syntax with `ecmaVersion` >= 11. Upgrade to Unicode version 12. diff --git a/deps/acorn/acorn/README.md b/deps/acorn/acorn/README.md index fa372ee6821bab..585f2736fc05b5 100644 --- a/deps/acorn/acorn/README.md +++ b/deps/acorn/acorn/README.md @@ -52,9 +52,10 @@ Options can be provided by passing a second argument, which should be an object containing any of these fields: - **ecmaVersion**: Indicates the ECMAScript version to parse. Must be - either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018) or 10 (2019, partial - support). This influences support for strict mode, the set of - reserved words, and support for new syntax features. Default is 9. + either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018), 10 (2019) or 11 + (2020, partial support). This influences support for strict mode, + the set of reserved words, and support for new syntax features. + Default is 10. **NOTE**: Only 'stage 4' (finalized) ECMAScript features are being implemented by Acorn. Other proposed new features can be implemented @@ -64,6 +65,9 @@ an object containing any of these fields: either `"script"` or `"module"`. This influences global strict mode and parsing of `import` and `export` declarations. + **NOTE**: If set to `"module"`, then static `import` / `export` syntax + will be valid, even if `ecmaVersion` is less than 6. + - **onInsertedSemicolon**: If given a callback, that callback will be called whenever a missing semicolon is inserted by the parser. The callback will be given the character offset of the point where the diff --git a/deps/acorn/acorn/dist/acorn.js b/deps/acorn/acorn/dist/acorn.js index dcb091fd4fe3d9..e2b33179c789c7 100644 --- a/deps/acorn/acorn/dist/acorn.js +++ b/deps/acorn/acorn/dist/acorn.js @@ -20,6 +20,7 @@ var keywords = { 5: ecma5AndLessKeywords, + "5module": ecma5AndLessKeywords + " export import", 6: ecma5AndLessKeywords + " const class extends export import super" }; @@ -32,9 +33,8 @@ // are only applied when a character is found to actually have a // code point above 128. // Generated by `bin/generate-identifier-regex.js`. - - var nonASCIIidentifierStartChars = "aab5bac0-d6d8-f6f8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08bd\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fef\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7c6\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab67\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; - var nonASCIIidentifierChars = "\u200c\u200db7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"; + var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08bd\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fef\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7c6\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab67\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; + var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"; var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); @@ -320,8 +320,8 @@ // either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018), or 10 // (2019). This influences support for strict mode, the set of // reserved words, and support for new syntax features. The default - // is 9. - ecmaVersion: 9, + // is 10. + ecmaVersion: 10, // `sourceType` indicates the mode the code should be parsed in. // Can be either `"script"` or `"module"`. This influences global // strict mode and parsing of `import` and `export` declarations. @@ -468,9 +468,9 @@ var Parser = function Parser(options, input, startPos) { this.options = options = getOptions(options); this.sourceFile = options.sourceFile; - this.keywords = wordsRegexp(keywords[options.ecmaVersion >= 6 ? 6 : 5]); + this.keywords = wordsRegexp(keywords[options.ecmaVersion >= 6 ? 6 : options.sourceType === "module" ? "5module" : 5]); var reserved = ""; - if (!options.allowReserved) { + if (options.allowReserved !== true) { for (var v = options.ecmaVersion;; v--) { if (reserved = reservedWords[v]) { break } } if (options.sourceType === "module") { reserved += " await"; } @@ -755,9 +755,7 @@ } } this.adaptDirectivePrologue(node.body); this.next(); - if (this.options.ecmaVersion >= 6) { - node.sourceType = this.options.sourceType; - } + node.sourceType = this.options.sourceType; return this.finishNode(node, "Program") }; @@ -1886,9 +1884,11 @@ if (this.options.ecmaVersion >= 6) { if (name === "__proto__" && kind === "init") { if (propHash.proto) { - if (refDestructuringErrors && refDestructuringErrors.doubleProto < 0) { refDestructuringErrors.doubleProto = key.start; } - // Backwards-compat kludge. Can be removed in version 6.0 - else { this.raiseRecoverable(key.start, "Redefinition of __proto__ property"); } + if (refDestructuringErrors) { + if (refDestructuringErrors.doubleProto < 0) + { refDestructuringErrors.doubleProto = key.start; } + // Backwards-compat kludge. Can be removed in version 6.0 + } else { this.raiseRecoverable(key.start, "Redefinition of __proto__ property"); } } propHash.proto = true; } @@ -1953,12 +1953,11 @@ else { this.exprAllowed = false; } } - var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1, oldShorthandAssign = -1; + var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1; if (refDestructuringErrors) { oldParenAssign = refDestructuringErrors.parenthesizedAssign; oldTrailingComma = refDestructuringErrors.trailingComma; - oldShorthandAssign = refDestructuringErrors.shorthandAssign; - refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.shorthandAssign = -1; + refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1; } else { refDestructuringErrors = new DestructuringErrors; ownDestructuringErrors = true; @@ -1973,8 +1972,11 @@ var node = this.startNodeAt(startPos, startLoc); node.operator = this.value; node.left = this.type === types.eq ? this.toAssignable(left, false, refDestructuringErrors) : left; - if (!ownDestructuringErrors) { DestructuringErrors.call(refDestructuringErrors); } - refDestructuringErrors.shorthandAssign = -1; // reset because shorthand default was used correctly + if (!ownDestructuringErrors) { + refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.doubleProto = -1; + } + if (refDestructuringErrors.shorthandAssign >= node.left.start) + { refDestructuringErrors.shorthandAssign = -1; } // reset because shorthand default was used correctly this.checkLVal(left); this.next(); node.right = this.parseMaybeAssign(noIn); @@ -1984,7 +1986,6 @@ } if (oldParenAssign > -1) { refDestructuringErrors.parenthesizedAssign = oldParenAssign; } if (oldTrailingComma > -1) { refDestructuringErrors.trailingComma = oldTrailingComma; } - if (oldShorthandAssign > -1) { refDestructuringErrors.shorthandAssign = oldShorthandAssign; } return left }; @@ -2089,8 +2090,8 @@ pp$3.parseExprSubscripts = function(refDestructuringErrors) { var startPos = this.start, startLoc = this.startLoc; var expr = this.parseExprAtom(refDestructuringErrors); - var skipArrowSubscripts = expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")"; - if (this.checkExpressionErrors(refDestructuringErrors) || skipArrowSubscripts) { return expr } + if (expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")") + { return expr } var result = this.parseSubscripts(expr, startPos, startLoc); if (refDestructuringErrors && result.type === "MemberExpression") { if (refDestructuringErrors.parenthesizedAssign >= result.start) { refDestructuringErrors.parenthesizedAssign = -1; } @@ -2114,7 +2115,7 @@ if (computed || this.eat(types.dot)) { var node = this.startNodeAt(startPos, startLoc); node.object = base; - node.property = computed ? this.parseExpression() : this.parseIdent(true); + node.property = computed ? this.parseExpression() : this.parseIdent(this.options.allowReserved !== "never"); node.computed = !!computed; if (computed) { this.expect(types.bracketR); } base = this.finishNode(node, "MemberExpression"); @@ -2123,7 +2124,7 @@ this.yieldPos = 0; this.awaitPos = 0; this.awaitIdentPos = 0; - var exprList = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8 && base.type !== "Import", false, refDestructuringErrors); + var exprList = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors); if (maybeAsyncArrow && !this.canInsertSemicolon() && this.eat(types.arrow)) { this.checkPatternErrors(refDestructuringErrors, false); this.checkYieldAwaitInDefaultParams(); @@ -2141,16 +2142,6 @@ var node$1 = this.startNodeAt(startPos, startLoc); node$1.callee = base; node$1.arguments = exprList; - if (node$1.callee.type === "Import") { - if (node$1.arguments.length !== 1) { - this.raise(node$1.start, "import() requires exactly one argument"); - } - - var importArg = node$1.arguments[0]; - if (importArg && importArg.type === "SpreadElement") { - this.raise(importArg.start, "... is not allowed in import()"); - } - } base = this.finishNode(node$1, "CallExpression"); } else if (this.type === types.backQuote) { var node$2 = this.startNodeAt(startPos, startLoc); @@ -2185,7 +2176,7 @@ // super [ Expression ] // super . IdentifierName // SuperCall: - // super Arguments + // super ( Arguments ) if (this.type !== types.dot && this.type !== types.bracketL && this.type !== types.parenL) { this.unexpected(); } return this.finishNode(node, "Super") @@ -2262,8 +2253,8 @@ return this.parseTemplate() case types._import: - if (this.options.ecmaVersion > 10) { - return this.parseDynamicImport() + if (this.options.ecmaVersion >= 11) { + return this.parseExprImport() } else { return this.unexpected() } @@ -2273,13 +2264,34 @@ } }; - pp$3.parseDynamicImport = function() { + pp$3.parseExprImport = function() { var node = this.startNode(); - this.next(); - if (this.type !== types.parenL) { + this.next(); // skip `import` + switch (this.type) { + case types.parenL: + return this.parseDynamicImport(node) + default: this.unexpected(); } - return this.finishNode(node, "Import") + }; + + pp$3.parseDynamicImport = function(node) { + this.next(); // skip `(` + + // Parse node.source. + node.source = this.parseMaybeAssign(); + + // Verify ending. + if (!this.eat(types.parenR)) { + var errorPos = this.start; + if (this.eat(types.comma) && this.eat(types.parenR)) { + this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()"); + } else { + this.unexpected(errorPos); + } + } + + return this.finishNode(node, "ImportExpression") }; pp$3.parseLiteral = function(value) { @@ -2377,6 +2389,7 @@ var empty$1 = []; pp$3.parseNew = function() { + if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword new"); } var node = this.startNode(); var meta = this.parseIdent(true); if (this.options.ecmaVersion >= 6 && this.eat(types.dot)) { @@ -2389,12 +2402,12 @@ { this.raiseRecoverable(node.start, "new.target can only be used in functions"); } return this.finishNode(node, "MetaProperty") } - var startPos = this.start, startLoc = this.startLoc; + var startPos = this.start, startLoc = this.startLoc, isImport = this.type === types._import; node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true); - if (this.options.ecmaVersion > 10 && node.callee.type === "Import") { - this.raise(node.callee.start, "Cannot use new with import(...)"); + if (isImport && node.callee.type === "ImportExpression") { + this.raise(startPos, "Cannot use new with import()"); } - if (this.eat(types.parenL)) { node.arguments = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8 && node.callee.type !== "Import", false); } + if (this.eat(types.parenL)) { node.arguments = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8, false); } else { node.arguments = empty$1; } return this.finishNode(node, "NewExpression") }; @@ -2459,7 +2472,7 @@ while (!this.eat(types.braceR)) { if (!first) { this.expect(types.comma); - if (this.afterTrailingComma(types.braceR)) { break } + if (this.options.ecmaVersion >= 5 && this.afterTrailingComma(types.braceR)) { break } } else { first = false; } var prop = this.parseProperty(isPattern, refDestructuringErrors); @@ -2581,7 +2594,7 @@ prop.computed = false; } } - return prop.key = this.type === types.num || this.type === types.string ? this.parseExprAtom() : this.parseIdent(true) + return prop.key = this.type === types.num || this.type === types.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never") }; // Initialize empty function node. @@ -2761,7 +2774,6 @@ pp$3.parseIdent = function(liberal, isBinding) { var node = this.startNode(); - if (liberal && this.options.allowReserved === "never") { liberal = false; } if (this.type === types.name) { node.name = this.value; } else if (this.type.keyword) { @@ -2778,7 +2790,7 @@ } else { this.unexpected(); } - this.next(); + this.next(!!liberal); this.finishNode(node, "Identifier"); if (!liberal) { this.checkUnreserved(node); @@ -2810,7 +2822,7 @@ var node = this.startNode(); this.next(); - node.argument = this.parseMaybeUnary(null, true); + node.argument = this.parseMaybeUnary(null, false); return this.finishNode(node, "AwaitExpression") }; @@ -3123,9 +3135,12 @@ // #table-binary-unicode-properties var ecma9BinaryProperties = "ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS"; + var ecma10BinaryProperties = ecma9BinaryProperties + " Extended_Pictographic"; + var ecma11BinaryProperties = ecma10BinaryProperties; var unicodeBinaryProperties = { 9: ecma9BinaryProperties, - 10: ecma9BinaryProperties + " Extended_Pictographic" + 10: ecma10BinaryProperties, + 11: ecma11BinaryProperties }; // #table-unicode-general-category-values @@ -3133,9 +3148,12 @@ // #table-unicode-script-values var ecma9ScriptValues = "Adlam Adlm Ahom Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb"; + var ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd"; + var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho"; var unicodeScriptValues = { 9: ecma9ScriptValues, - 10: ecma9ScriptValues + " Dogra Dogr Elymaic Elym Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Old_Sogdian Sogo Sogdian Sogd Wancho Wcho" + 10: ecma10ScriptValues, + 11: ecma11ScriptValues }; var data = {}; @@ -3155,13 +3173,14 @@ } buildUnicodeData(9); buildUnicodeData(10); + buildUnicodeData(11); var pp$8 = Parser.prototype; var RegExpValidationState = function RegExpValidationState(parser) { this.parser = parser; this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : ""); - this.unicodeProperties = data[parser.options.ecmaVersion >= 10 ? 10 : parser.options.ecmaVersion]; + this.unicodeProperties = data[parser.options.ecmaVersion >= 11 ? 11 : parser.options.ecmaVersion]; this.source = ""; this.flags = ""; this.start = 0; @@ -3202,7 +3221,8 @@ if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) { return c } - return (c << 10) + s.charCodeAt(i + 1) - 0x35FDC00 + var next = s.charCodeAt(i + 1); + return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c }; RegExpValidationState.prototype.nextIndex = function nextIndex (i) { @@ -3211,8 +3231,9 @@ if (i >= l) { return l } - var c = s.charCodeAt(i); - if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) { + var c = s.charCodeAt(i), next; + if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l || + (next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) { return i + 1 } return i + 2 @@ -3303,7 +3324,7 @@ if (state.eat(0x29 /* ) */)) { state.raise("Unmatched ')'"); } - if (state.eat(0x5D /* [ */) || state.eat(0x7D /* } */)) { + if (state.eat(0x5D /* ] */) || state.eat(0x7D /* } */)) { state.raise("Lone quantifier brackets"); } } @@ -3992,7 +4013,7 @@ if (state.eat(0x5B /* [ */)) { state.eat(0x5E /* ^ */); this.regexp_classRanges(state); - if (state.eat(0x5D /* [ */)) { + if (state.eat(0x5D /* ] */)) { return true } // Unreachable since it threw "unterminated regular expression" error before. @@ -4040,7 +4061,7 @@ } var ch = state.current(); - if (ch !== 0x5D /* [ */) { + if (ch !== 0x5D /* ] */) { state.lastIntValue = ch; state.advance(); return true @@ -4219,7 +4240,9 @@ // Move to the next token - pp$9.next = function() { + pp$9.next = function(ignoreEscapeSequenceInKeyword) { + if (!ignoreEscapeSequenceInKeyword && this.type.keyword && this.containsEsc) + { this.raiseRecoverable(this.start, "Escape sequence in keyword " + this.type.keyword); } if (this.options.onToken) { this.options.onToken(new Token(this)); } @@ -4638,7 +4661,6 @@ if (!startsWithDot && this.readInt(10) === null) { this.raise(start, "Invalid number"); } var octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48; if (octal && this.strict) { this.raise(start, "Invalid number"); } - if (octal && /[89]/.test(this.input.slice(start, this.pos))) { octal = false; } var next = this.input.charCodeAt(this.pos); if (!octal && !startsWithDot && this.options.ecmaVersion >= 11 && next === 110) { var str$1 = this.input.slice(start, this.pos); @@ -4647,6 +4669,7 @@ if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); } return this.finishToken(types.num, val$1) } + if (octal && /[89]/.test(this.input.slice(start, this.pos))) { octal = false; } if (next === 46 && !octal) { // '.' ++this.pos; this.readInt(10); @@ -4821,6 +4844,18 @@ case 10: // ' \n' if (this.options.locations) { this.lineStart = this.pos; ++this.curLine; } return "" + case 56: + case 57: + if (inTemplate) { + var codePos = this.pos - 1; + + this.invalidStringToken( + codePos, + "Invalid escape sequence in template string" + ); + + return null + } default: if (ch >= 48 && ch <= 55) { var octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0]; @@ -4900,7 +4935,6 @@ var word = this.readWord1(); var type = types.name; if (this.keywords.test(word)) { - if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword " + word); } type = keywords$1[word]; } return this.finishToken(type, word) @@ -4908,7 +4942,29 @@ // Acorn is a tiny, fast JavaScript parser written in JavaScript. - var version = "6.2.0"; + var version = "7.1.0"; + + Parser.acorn = { + Parser: Parser, + version: version, + defaultOptions: defaultOptions, + Position: Position, + SourceLocation: SourceLocation, + getLineInfo: getLineInfo, + Node: Node, + TokenType: TokenType, + tokTypes: types, + keywordTypes: keywords$1, + TokContext: TokContext, + tokContexts: types$1, + isIdentifierChar: isIdentifierChar, + isIdentifierStart: isIdentifierStart, + Token: Token, + isNewLine: isNewLine, + lineBreak: lineBreak, + lineBreakG: lineBreakG, + nonASCIIwhitespace: nonASCIIwhitespace + }; // The main exported interface (under `self.acorn` when in the // browser) is a `parse` function that takes a code string and diff --git a/deps/acorn/acorn/package.json b/deps/acorn/acorn/package.json index 446e6b065bb3aa..6a8f036073a2ab 100644 --- a/deps/acorn/acorn/package.json +++ b/deps/acorn/acorn/package.json @@ -3,8 +3,9 @@ "description": "ECMAScript parser", "homepage": "https://github.com/acornjs/acorn", "main": "dist/acorn.js", + "types": "dist/acorn.d.ts", "module": "dist/acorn.mjs", - "version": "6.2.0", + "version": "7.1.1", "engines": {"node": ">=0.4.0"}, "maintainers": [ { diff --git a/deps/cares/cares.gyp b/deps/cares/cares.gyp index 0b5cd02c21dde1..02b2774c02683e 100644 --- a/deps/cares/cares.gyp +++ b/deps/cares/cares.gyp @@ -52,7 +52,9 @@ 'src/ares_fds.c', 'src/ares_free_hostent.c', 'src/ares_free_string.c', + 'src/ares_freeaddrinfo.c', 'src/ares_getenv.h', + 'src/ares_getaddrinfo.c', 'src/ares_gethostbyaddr.c', 'src/ares_gethostbyname.c', 'src/ares__get_hostent.c', @@ -70,6 +72,7 @@ 'src/ares_nowarn.c', 'src/ares_nowarn.h', 'src/ares_options.c', + 'src/ares__parse_into_addrinfo.c', 'src/ares_parse_aaaa_reply.c', 'src/ares_parse_a_reply.c', 'src/ares_parse_mx_reply.c', @@ -84,9 +87,11 @@ 'src/ares_process.c', 'src/ares_query.c', 'src/ares__read_line.c', + 'src/ares__readaddrinfo.c', 'src/ares_search.c', 'src/ares_send.c', 'src/ares_setup.h', + 'src/ares__sortaddrinfo.c', 'src/ares_strcasecmp.c', 'src/ares_strcasecmp.h', 'src/ares_strdup.c', diff --git a/deps/cares/config/android/ares_config.h b/deps/cares/config/android/ares_config.h index 1a5265a5098d3c..50c8114396b0fd 100644 --- a/deps/cares/config/android/ares_config.h +++ b/deps/cares/config/android/ares_config.h @@ -128,7 +128,7 @@ #define HAVE_GETNAMEINFO 1 /* Define to 1 if you have the getservbyport_r function. */ -#define HAVE_GETSERVBYPORT_R 1 +/* #undef HAVE_GETSERVBYPORT_R */ /* Define to 1 if you have the `gettimeofday' function. */ #define HAVE_GETTIMEOFDAY 1 diff --git a/deps/cares/include/ares.h b/deps/cares/include/ares.h index 06f60b33304b80..91dc754dfb6a18 100644 --- a/deps/cares/include/ares.h +++ b/deps/cares/include/ares.h @@ -135,6 +135,9 @@ extern "C" { /* More error codes */ #define ARES_ECANCELLED 24 /* introduced in 1.7.0 */ +/* More ares_getaddrinfo error codes */ +#define ARES_ESERVICE 25 /* introduced in 1.?.0 */ + /* Flag values */ #define ARES_FLAG_USEVC (1 << 0) #define ARES_FLAG_PRIMARY (1 << 1) @@ -192,6 +195,8 @@ extern "C" { #define ARES_AI_V4MAPPED (1 << 4) #define ARES_AI_ALL (1 << 5) #define ARES_AI_ADDRCONFIG (1 << 6) +#define ARES_AI_NOSORT (1 << 7) +#define ARES_AI_ENVHOSTS (1 << 8) /* Reserved for future use */ #define ARES_AI_IDN (1 << 10) #define ARES_AI_IDN_ALLOW_UNASSIGNED (1 << 11) @@ -278,6 +283,8 @@ struct hostent; struct timeval; struct sockaddr; struct ares_channeldata; +struct ares_addrinfo; +struct ares_addrinfo_hints; typedef struct ares_channeldata *ares_channel; @@ -306,6 +313,11 @@ typedef int (*ares_sock_config_callback)(ares_socket_t socket_fd, int type, void *data); +typedef void (*ares_addrinfo_callback)(void *arg, + int status, + int timeouts, + struct ares_addrinfo *res); + CARES_EXTERN int ares_library_init(int flags); CARES_EXTERN int ares_library_init_mem(int flags, @@ -369,6 +381,15 @@ CARES_EXTERN void ares_set_socket_configure_callback(ares_channel channel, CARES_EXTERN int ares_set_sortlist(ares_channel channel, const char *sortstr); +CARES_EXTERN void ares_getaddrinfo(ares_channel channel, + const char* node, + const char* service, + const struct ares_addrinfo_hints* hints, + ares_addrinfo_callback callback, + void* arg); + +CARES_EXTERN void ares_freeaddrinfo(struct ares_addrinfo* ai); + /* * Virtual function set to have user-managed socket IO. * Note that all functions need to be defined, and when @@ -558,6 +579,44 @@ struct ares_soa_reply { unsigned int minttl; }; +/* + * Similar to addrinfo, but with extra ttl and missing canonname. + */ +struct ares_addrinfo_node { + int ai_ttl; + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + ares_socklen_t ai_addrlen; + struct sockaddr *ai_addr; + struct ares_addrinfo_node *ai_next; +}; + +/* + * alias - label of the resource record. + * name - value (canonical name) of the resource record. + * See RFC2181 10.1.1. CNAME terminology. + */ +struct ares_addrinfo_cname { + int ttl; + char *alias; + char *name; + struct ares_addrinfo_cname *next; +}; + +struct ares_addrinfo { + struct ares_addrinfo_cname *cnames; + struct ares_addrinfo_node *nodes; +}; + +struct ares_addrinfo_hints { + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; +}; + /* ** Parse the buffer, starting at *abuf and of length alen bytes, previously ** obtained from an ares_search call. Put the results in *host, if nonnull. diff --git a/deps/cares/include/ares_version.h b/deps/cares/include/ares_version.h index 3fe5b00a1171c2..7758a48148a804 100644 --- a/deps/cares/include/ares_version.h +++ b/deps/cares/include/ares_version.h @@ -3,15 +3,15 @@ #define ARES__VERSION_H /* This is the global package copyright */ -#define ARES_COPYRIGHT "2004 - 2018 Daniel Stenberg, ." +#define ARES_COPYRIGHT "2004 - 2020 Daniel Stenberg, ." #define ARES_VERSION_MAJOR 1 -#define ARES_VERSION_MINOR 15 +#define ARES_VERSION_MINOR 16 #define ARES_VERSION_PATCH 0 #define ARES_VERSION ((ARES_VERSION_MAJOR<<16)|\ (ARES_VERSION_MINOR<<8)|\ (ARES_VERSION_PATCH)) -#define ARES_VERSION_STR "1.15.0" +#define ARES_VERSION_STR "1.16.0" #if (ARES_VERSION >= 0x010700) # define CARES_HAVE_ARES_LIBRARY_INIT 1 diff --git a/deps/cares/src/README.md b/deps/cares/src/README.md index 93c1f5f812de4c..148338f9e18081 100644 --- a/deps/cares/src/README.md +++ b/deps/cares/src/README.md @@ -2,9 +2,10 @@ c-ares ====== [![Build Status](https://travis-ci.org/c-ares/c-ares.svg?branch=master)](https://travis-ci.org/c-ares/c-ares) -[![Windows Build Status](https://ci.appveyor.com/api/projects/status/03i7151772eq3wn3/branch/master?svg=true)](https://ci.appveyor.com/project/c-ares/c-ares) +[![Windows Build Status](https://ci.appveyor.com/api/projects/status/aevgc5914tm72pvs/branch/master?svg=true)](https://ci.appveyor.com/project/c-ares/c-ares/branch/master) [![Coverage Status](https://coveralls.io/repos/c-ares/c-ares/badge.svg?branch=master&service=github)](https://coveralls.io/github/c-ares/c-ares?branch=master) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/291/badge)](https://bestpractices.coreinfrastructure.org/projects/291) +[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/c-ares.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:c-ares) [![Releases](https://coderelease.io/badge/c-ares/c-ares)](https://coderelease.io/github/repository/c-ares/c-ares) This is c-ares, an asynchronous resolver library. It is intended for diff --git a/deps/cares/src/RELEASE-NOTES b/deps/cares/src/RELEASE-NOTES index 62276fdf4e38c6..0d8573ae8dd933 100644 --- a/deps/cares/src/RELEASE-NOTES +++ b/deps/cares/src/RELEASE-NOTES @@ -1,43 +1,85 @@ -c-ares version 1.15.0 +c-ares version 1.16.0 Changes: - o Add ares_init_options() configurability for path to resolv.conf file [1] - o Ability to exclude building of tools (adig, ahost, acountry) in CMake [3] - o Android: Support for domain search suffix [4] - o Report ARES_ENOTFOUND for .onion domain names as per RFC7686. [13] + o Introduction of ares_getaddrinfo() API which provides similar output + (including proper sorting as per RFC 6724) to the system native API, but + utilizes different data structures in order to provide additional information + such as TTLs and all aliases. Please reference the respective man pages for + usage details. [3] [4] [5] [7] [8] [13] [14] [15] [16] [17] [22] + o Parse SOA records from ns_t_any response [29] [30] + o CMake: Provide c-ares version in package export file [24] + o CMake: Add CPACK functionality for DEB and RPM [28] + o CMake: Generate PDB files during build [33] [34] + o CMake: Support manpage installation [37] [38] Bug fixes: - o AIX build fix for trying to include both nameser_compat.h and - onameser_compat.h [2] - o Windows: Improve DNS suffixes extracting from WinNT registry [5] - o Fix modern GCC warnings [6] - o Apply the IPv6 server blacklist to all nameserver sources, not just Windows - [7] - o Fix warnings emitted by MSVC when using -W4 [8] - o Prevent changing name servers while queries are outstanding [9] - o Harden and rationalize c-ares timeout computation [10] - o Distribute ares_android.h [11] - o ares_set_servers_csv() on failure should not leave channel in a bad state - [12] - o Add missing docs to distribution + o Fix bad expectation in IPv6 localhost test. [1] [2] + o AutoTools: use XC_CHECK_BUILD_FLAGS instead of XC_CHECK_USER_FLAGS to prevent + complaints about CPPFLAGS in CFLAGS. [6] + o Fix .onion handling + o Command line usage was out of date for adig and ahost. [18] + o Typos in manpages [19] [20] + o If ares_getenv is defined, it must return a value on all platforms [21] + o If /etc/resolv.conf has invalid lookup values, use the defaults. [23] + o Tests: Separate live tests from SetServers* tests as only live tests should + require internet access. [25] + o ares_gethostbyname() should return ENODATA if no valid A or AAAA record is + found, but a CNAME was found. [26] [27] + o CMake: Rework library function checking to prevent unintended linking with + system libraries that aren't needed. [31] [32] + o Due to use of inet_addr() it was not possible to return 255.255.255.255 from + ares_gethostbyname(). [35] [36] + o CMake: Fix building of tests on Windows Thanks go to these friendly people for their efforts and contributions: - @afalin, Andi Schnebinger, Ben Noordhuis, Brad House, Brad Spencer, - David Hotham, @flyingdutchman23, John Schember, Ruslan Baratov, - Sarat Addepalli, Tobias Nießen (11 contributors) + Abhishek Arya (@inferno-chromium), Adam Majer (@AdamMajer), + Andrew Selivanov (@ki11roy), Ben Noordhuis (@bnoordhuis), + Brad House (@bradh352), Christian Ammer (@ChristianAmmer), Dan Noé (@dnoe), + Daniel Stenberg (@bagder), Darrin Cullop (@dwcullop), + Dron Rathore (@DronRathore), Fabrice Fontaine (@ffontaine), + Gregor Jasny (@gjasny), @kedixa, Khaidi Chu (@XadillaX), + Kyle Edwards (@KyleFromKitware), @lifenjoiner, Michal Rostecki (@mrostecki), + Peter Eisentraut (@petere), Piotr Pietraszkiewicz (@ppietrasa), + Stephen Bryant (@bf-bryants), @tjwalton, Vy Nguyen (@oontvoo) + (22 contributors) References to bug reports and discussions on issues: - [1] = https://github.com/c-ares/c-ares/issues/220 - [2] = https://github.com/c-ares/c-ares/issues/224 - [3] = https://github.com/c-ares/c-ares/issues/200 - [4] = https://github.com/c-ares/c-ares/issues/207 - [5] = https://github.com/c-ares/c-ares/pull/202 - [6] = https://github.com/c-ares/c-ares/pull/201 - [7] = https://github.com/c-ares/c-ares/pull/193 - [8] = https://github.com/c-ares/c-ares/pull/192 - [9] = https://github.com/c-ares/c-ares/pull/191 + [1] = https://github.com/c-ares/c-ares/pull/227 + [2] = https://github.com/c-ares/c-ares/issues/85 + [3] = https://github.com/c-ares/c-ares/pull/112 + [4] = https://github.com/c-ares/c-ares/pull/233 + [5] = https://github.com/c-ares/c-ares/pull/234 + [6] = https://github.com/c-ares/c-ares/pull/236 + [7] = https://github.com/c-ares/c-ares/pull/235 + [8] = https://github.com/c-ares/c-ares/pull/239 + [9] = https://github.com/c-ares/c-ares/pull/241 [10] = https://github.com/c-ares/c-ares/pull/187 - [11] = https://c-ares.haxx.se/mail/c-ares-archive-2018-04/0000.shtml - [12] = https://c-ares.haxx.se/mail/c-ares-archive-2018-03/0000.shtml - [13] = https://github.com/c-ares/c-ares/issues/196 + [11] = https://github.com/c-ares/c-ares/pull/252 + [12] = https://github.com/c-ares/c-ares/issues/251 + [13] = https://github.com/c-ares/c-ares/pull/258 + [14] = https://github.com/c-ares/c-ares/pull/257 + [15] = https://github.com/c-ares/c-ares/pull/262 + [16] = https://github.com/c-ares/c-ares/pull/264 + [17] = https://github.com/c-ares/c-ares/pull/265 + [18] = https://github.com/c-ares/c-ares/pull/256 + [19] = https://github.com/c-ares/c-ares/pull/269 + [20] = https://github.com/c-ares/c-ares/pull/275 + [21] = https://github.com/c-ares/c-ares/pull/279 + [22] = https://github.com/c-ares/c-ares/pull/290 + [23] = https://github.com/c-ares/c-ares/pull/274 + [24] = https://github.com/c-ares/c-ares/pull/296 + [25] = https://github.com/c-ares/c-ares/pull/299 + [26] = https://github.com/c-ares/c-ares/pull/304 + [27] = https://github.com/c-ares/c-ares/issues/303 + [28] = https://github.com/c-ares/c-ares/pull/283 + [29] = https://github.com/c-ares/c-ares/pull/103 + [30] = https://github.com/c-ares/c-ares/issues/102 + [31] = https://github.com/c-ares/c-ares/pull/310 + [32] = https://github.com/c-ares/c-ares/issues/307 + [33] = https://github.com/c-ares/c-ares/pull/311 + [34] = https://github.com/c-ares/c-ares/issues/245 + [35] = https://github.com/c-ares/c-ares/issues/309 + [36] = https://github.com/c-ares/c-ares/pull/312 + [37] = https://github.com/c-ares/c-ares/issues/297 + [38] = https://github.com/c-ares/c-ares/pull/314 diff --git a/deps/cares/src/ares__close_sockets.c b/deps/cares/src/ares__close_sockets.c index f07904e8735bcd..0477174e3e1187 100644 --- a/deps/cares/src/ares__close_sockets.c +++ b/deps/cares/src/ares__close_sockets.c @@ -48,14 +48,14 @@ void ares__close_sockets(ares_channel channel, struct server_state *server) if (server->tcp_socket != ARES_SOCKET_BAD) { SOCK_STATE_CALLBACK(channel, server->tcp_socket, 0, 0); - ares__socket_close(channel, server->tcp_socket); + ares__close_socket(channel, server->tcp_socket); server->tcp_socket = ARES_SOCKET_BAD; server->tcp_connection_generation = ++channel->tcp_connection_generation; } if (server->udp_socket != ARES_SOCKET_BAD) { SOCK_STATE_CALLBACK(channel, server->udp_socket, 0, 0); - ares__socket_close(channel, server->udp_socket); + ares__close_socket(channel, server->udp_socket); server->udp_socket = ARES_SOCKET_BAD; } } diff --git a/deps/cares/src/ares__get_hostent.c b/deps/cares/src/ares__get_hostent.c index d2f95034934708..367f39037b168c 100644 --- a/deps/cares/src/ares__get_hostent.c +++ b/deps/cares/src/ares__get_hostent.c @@ -138,8 +138,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host) addr.addrV4.s_addr = INADDR_NONE; if ((family == AF_INET) || (family == AF_UNSPEC)) { - addr.addrV4.s_addr = inet_addr(txtaddr); - if (addr.addrV4.s_addr != INADDR_NONE) + if (ares_inet_pton(AF_INET, txtaddr, &addr.addrV4) > 0) { /* Actual network address family and length. */ addr.family = AF_INET; diff --git a/deps/cares/src/ares__parse_into_addrinfo.c b/deps/cares/src/ares__parse_into_addrinfo.c new file mode 100644 index 00000000000000..b0801632b4008f --- /dev/null +++ b/deps/cares/src/ares__parse_into_addrinfo.c @@ -0,0 +1,266 @@ +/* Copyright (C) 2019 by Andrew Selivanov + * + * Permission to use, copy, modify, and distribute this + * software and its documentation for any purpose and without + * fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting + * documentation, and that the name of M.I.T. not be used in + * advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" + * without express or implied warranty. + */ + +#include "ares_setup.h" + +#ifdef HAVE_NETINET_IN_H +# include +#endif +#ifdef HAVE_NETDB_H +# include +#endif +#ifdef HAVE_ARPA_INET_H +# include +#endif +#ifdef HAVE_ARPA_NAMESER_H +# include +#else +# include "nameser.h" +#endif +#ifdef HAVE_ARPA_NAMESER_COMPAT_H +# include +#endif + +#ifdef HAVE_STRINGS_H +# include +#endif + +#ifdef HAVE_LIMITS_H +# include +#endif + +#include "ares.h" +#include "ares_dns.h" +#include "ares_private.h" + +int ares__parse_into_addrinfo2(const unsigned char *abuf, + int alen, + char **question_hostname, + struct ares_addrinfo *ai) +{ + unsigned int qdcount, ancount; + int status, i, rr_type, rr_class, rr_len, rr_ttl; + int got_a = 0, got_aaaa = 0, got_cname = 0; + long len; + const unsigned char *aptr; + char *hostname, *rr_name = NULL, *rr_data; + struct ares_addrinfo_cname *cname, *cnames = NULL; + struct ares_addrinfo_node *node, *nodes = NULL; + struct sockaddr_in *sin; + struct sockaddr_in6 *sin6; + + *question_hostname = NULL; + + /* Give up if abuf doesn't have room for a header. */ + if (alen < HFIXEDSZ) + return ARES_EBADRESP; + + /* Fetch the question and answer count from the header. */ + qdcount = DNS_HEADER_QDCOUNT(abuf); + ancount = DNS_HEADER_ANCOUNT(abuf); + if (qdcount != 1) + return ARES_EBADRESP; + + + /* Expand the name from the question, and skip past the question. */ + aptr = abuf + HFIXEDSZ; + status = ares__expand_name_for_response(aptr, abuf, alen, question_hostname, &len); + if (status != ARES_SUCCESS) + return status; + if (aptr + len + QFIXEDSZ > abuf + alen) + { + return ARES_EBADRESP; + } + + hostname = *question_hostname; + + aptr += len + QFIXEDSZ; + + /* Examine each answer resource record (RR) in turn. */ + for (i = 0; i < (int)ancount; i++) + { + /* Decode the RR up to the data field. */ + status = ares__expand_name_for_response(aptr, abuf, alen, &rr_name, &len); + if (status != ARES_SUCCESS) + { + rr_name = NULL; + goto failed_stat; + } + + aptr += len; + if (aptr + RRFIXEDSZ > abuf + alen) + { + status = ARES_EBADRESP; + goto failed_stat; + } + rr_type = DNS_RR_TYPE(aptr); + rr_class = DNS_RR_CLASS(aptr); + rr_len = DNS_RR_LEN(aptr); + rr_ttl = DNS_RR_TTL(aptr); + aptr += RRFIXEDSZ; + if (aptr + rr_len > abuf + alen) + { + status = ARES_EBADRESP; + goto failed_stat; + } + + if (rr_class == C_IN && rr_type == T_A + && rr_len == sizeof(struct in_addr) + && strcasecmp(rr_name, hostname) == 0) + { + got_a = 1; + if (aptr + sizeof(struct in_addr) > abuf + alen) + { /* LCOV_EXCL_START: already checked above */ + status = ARES_EBADRESP; + goto failed_stat; + } /* LCOV_EXCL_STOP */ + + node = ares__append_addrinfo_node(&nodes); + if (!node) + { + status = ARES_ENOMEM; + goto failed_stat; + } + + sin = ares_malloc(sizeof(struct sockaddr_in)); + if (!sin) + { + status = ARES_ENOMEM; + goto failed_stat; + } + memset(sin, 0, sizeof(struct sockaddr_in)); + memcpy(&sin->sin_addr.s_addr, aptr, sizeof(struct in_addr)); + sin->sin_family = AF_INET; + + node->ai_addr = (struct sockaddr *)sin; + node->ai_family = AF_INET; + node->ai_addrlen = sizeof(struct sockaddr_in); + + node->ai_ttl = rr_ttl; + + status = ARES_SUCCESS; + } + else if (rr_class == C_IN && rr_type == T_AAAA + && rr_len == sizeof(struct ares_in6_addr) + && strcasecmp(rr_name, hostname) == 0) + { + got_aaaa = 1; + if (aptr + sizeof(struct ares_in6_addr) > abuf + alen) + { /* LCOV_EXCL_START: already checked above */ + status = ARES_EBADRESP; + goto failed_stat; + } /* LCOV_EXCL_STOP */ + + node = ares__append_addrinfo_node(&nodes); + if (!node) + { + status = ARES_ENOMEM; + goto failed_stat; + } + + sin6 = ares_malloc(sizeof(struct sockaddr_in6)); + if (!sin6) + { + status = ARES_ENOMEM; + goto failed_stat; + } + + memset(sin6, 0, sizeof(struct sockaddr_in6)); + memcpy(&sin6->sin6_addr.s6_addr, aptr, sizeof(struct ares_in6_addr)); + sin6->sin6_family = AF_INET6; + + node->ai_addr = (struct sockaddr *)sin6; + node->ai_family = AF_INET6; + node->ai_addrlen = sizeof(struct sockaddr_in6); + + node->ai_ttl = rr_ttl; + + status = ARES_SUCCESS; + } + + if (rr_class == C_IN && rr_type == T_CNAME) + { + got_cname = 1; + status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data, + &len); + if (status != ARES_SUCCESS) + { + goto failed_stat; + } + + /* Decode the RR data and replace the hostname with it. */ + /* SA: Seems wrong as it introduses order dependency. */ + hostname = rr_data; + + cname = ares__append_addrinfo_cname(&cnames); + if (!cname) + { + status = ARES_ENOMEM; + ares_free(rr_data); + goto failed_stat; + } + cname->ttl = rr_ttl; + cname->alias = rr_name; + cname->name = rr_data; + } + else + { + ares_free(rr_name); + } + + + aptr += rr_len; + if (aptr > abuf + alen) + { /* LCOV_EXCL_START: already checked above */ + status = ARES_EBADRESP; + goto failed_stat; + } /* LCOV_EXCL_STOP */ + } + + if (status == ARES_SUCCESS) + { + ares__addrinfo_cat_nodes(&ai->nodes, nodes); + if (got_cname) + { + ares__addrinfo_cat_cnames(&ai->cnames, cnames); + return status; + } + else if (got_a == 0 && got_aaaa == 0) + { + /* the check for naliases to be zero is to make sure CNAME responses + don't get caught here */ + status = ARES_ENODATA; + } + } + + return status; + +failed_stat: + ares_free(rr_name); + ares__freeaddrinfo_cnames(cnames); + ares__freeaddrinfo_nodes(nodes); + return status; +} + +int ares__parse_into_addrinfo(const unsigned char *abuf, + int alen, + struct ares_addrinfo *ai) +{ + int status; + char *question_hostname; + status = ares__parse_into_addrinfo2(abuf, alen, &question_hostname, ai); + ares_free(question_hostname); + return status; +} diff --git a/deps/cares/src/ares__readaddrinfo.c b/deps/cares/src/ares__readaddrinfo.c new file mode 100644 index 00000000000000..dd3abe2e9f8778 --- /dev/null +++ b/deps/cares/src/ares__readaddrinfo.c @@ -0,0 +1,260 @@ +/* Copyright (C) 2019 by Andrew Selivanov + * + * Permission to use, copy, modify, and distribute this + * software and its documentation for any purpose and without + * fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting + * documentation, and that the name of M.I.T. not be used in + * advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" + * without express or implied warranty. + */ + +#include "ares_setup.h" + +#ifdef HAVE_NETINET_IN_H +# include +#endif +#ifdef HAVE_NETDB_H +# include +#endif +#ifdef HAVE_ARPA_INET_H +# include +#endif + +#include "ares.h" +#include "ares_inet_net_pton.h" +#include "ares_nowarn.h" +#include "ares_private.h" + +#define MAX_ALIASES 40 + +int ares__readaddrinfo(FILE *fp, + const char *name, + unsigned short port, + const struct ares_addrinfo_hints *hints, + struct ares_addrinfo *ai) +{ + char *line = NULL, *p, *q; + char *txtaddr, *txthost, *txtalias; + char *aliases[MAX_ALIASES]; + unsigned int i, alias_count; + int status; + size_t linesize; + ares_sockaddr addr; + struct ares_addrinfo_cname *cname = NULL, *cnames = NULL; + struct ares_addrinfo_node *node = NULL, *nodes = NULL; + int match_with_alias, match_with_canonical; + int want_cname = hints->ai_flags & ARES_AI_CANONNAME; + + /* Validate family */ + switch (hints->ai_family) { + case AF_INET: + case AF_INET6: + case AF_UNSPEC: + break; + default: + return ARES_EBADFAMILY; + } + + + while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS) + { + match_with_alias = 0; + match_with_canonical = 0; + alias_count = 0; + /* Trim line comment. */ + p = line; + while (*p && (*p != '#')) + p++; + *p = '\0'; + + /* Trim trailing whitespace. */ + q = p - 1; + while ((q >= line) && ISSPACE(*q)) + q--; + *++q = '\0'; + + /* Skip leading whitespace. */ + p = line; + while (*p && ISSPACE(*p)) + p++; + if (!*p) + /* Ignore line if empty. */ + continue; + + /* Pointer to start of IPv4 or IPv6 address part. */ + txtaddr = p; + + /* Advance past address part. */ + while (*p && !ISSPACE(*p)) + p++; + if (!*p) + /* Ignore line if reached end of line. */ + continue; + + /* Null terminate address part. */ + *p = '\0'; + + /* Advance to host name */ + p++; + while (*p && ISSPACE(*p)) + p++; + if (!*p) + /* Ignore line if reached end of line. */ + continue; /* LCOV_EXCL_LINE: trailing whitespace already stripped */ + + /* Pointer to start of host name. */ + txthost = p; + + /* Advance past host name. */ + while (*p && !ISSPACE(*p)) + p++; + + /* Pointer to start of first alias. */ + txtalias = NULL; + if (*p) + { + q = p + 1; + while (*q && ISSPACE(*q)) + q++; + if (*q) + txtalias = q; + } + + /* Null terminate host name. */ + *p = '\0'; + + /* Find out if host name matches with canonical host name. */ + if (strcasecmp(txthost, name) == 0) + { + match_with_canonical = 1; + } + + /* Find out if host name matches with one of the aliases. */ + while (txtalias) + { + p = txtalias; + while (*p && !ISSPACE(*p)) + p++; + q = p; + while (*q && ISSPACE(*q)) + q++; + *p = '\0'; + if (strcasecmp(txtalias, name) == 0) + { + match_with_alias = 1; + if (!want_cname) + break; + } + if (alias_count < MAX_ALIASES) + { + aliases[alias_count++] = txtalias; + } + txtalias = *q ? q : NULL; + } + + /* Try next line if host does not match. */ + if (!match_with_alias && !match_with_canonical) + { + continue; + } + + /* + * Convert address string to network address for the requested families. + * Actual address family possible values are AF_INET and AF_INET6 only. + */ + if ((hints->ai_family == AF_INET) || (hints->ai_family == AF_UNSPEC)) + { + addr.sa4.sin_port = htons(port); + if (ares_inet_pton(AF_INET, txtaddr, &addr.sa4.sin_addr) > 0) + { + node = ares__append_addrinfo_node(&nodes); + if(!node) + { + goto enomem; + } + + node->ai_family = addr.sa.sa_family = AF_INET; + node->ai_addrlen = sizeof(sizeof(addr.sa4)); + node->ai_addr = ares_malloc(sizeof(addr.sa4)); + if (!node->ai_addr) + { + goto enomem; + } + memcpy(node->ai_addr, &addr.sa4, sizeof(addr.sa4)); + } + } + if ((hints->ai_family == AF_INET6) || (hints->ai_family == AF_UNSPEC)) + { + addr.sa6.sin6_port = htons(port); + if (ares_inet_pton(AF_INET6, txtaddr, &addr.sa6.sin6_addr) > 0) + { + node = ares__append_addrinfo_node(&nodes); + if (!node) + { + goto enomem; + } + + node->ai_family = addr.sa.sa_family = AF_INET6; + node->ai_addrlen = sizeof(sizeof(addr.sa6)); + node->ai_addr = ares_malloc(sizeof(addr.sa6)); + if (!node->ai_addr) + { + goto enomem; + } + memcpy(node->ai_addr, &addr.sa6, sizeof(addr.sa6)); + } + } + if (!node) + /* Ignore line if invalid address string for the requested family. */ + continue; + + if (want_cname) + { + for (i = 0; i < alias_count; ++i) + { + cname = ares__append_addrinfo_cname(&cnames); + if (!cname) + { + goto enomem; + } + cname->alias = ares_strdup(aliases[i]); + cname->name = ares_strdup(txthost); + } + /* No aliases, cname only. */ + if(!alias_count) + { + cname = ares__append_addrinfo_cname(&cnames); + if (!cname) + { + goto enomem; + } + cname->name = ares_strdup(txthost); + } + } + } + + /* Last read failed. */ + if (status == ARES_ENOMEM) + { + goto enomem; + } + + /* Free line buffer. */ + ares_free(line); + + ares__addrinfo_cat_cnames(&ai->cnames, cnames); + ares__addrinfo_cat_nodes(&ai->nodes, nodes); + + return node ? ARES_SUCCESS : ARES_ENOTFOUND; + +enomem: + ares_free(line); + ares__freeaddrinfo_cnames(cnames); + ares__freeaddrinfo_nodes(nodes); + return ARES_ENOMEM; +} diff --git a/deps/cares/src/ares__sortaddrinfo.c b/deps/cares/src/ares__sortaddrinfo.c new file mode 100644 index 00000000000000..7a90270a2a6b92 --- /dev/null +++ b/deps/cares/src/ares__sortaddrinfo.c @@ -0,0 +1,494 @@ +/* + * Original file name getaddrinfo.c + * Lifted from the 'Android Bionic' project with the BSD license. + */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * Copyright (C) 2018 The Android Open Source Project + * Copyright (C) 2019 by Andrew Selivanov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "ares_setup.h" + +#ifdef HAVE_NETINET_IN_H +# include +#endif +#ifdef HAVE_NETDB_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif + +#include +#include + +#include "ares.h" +#include "ares_private.h" + +struct addrinfo_sort_elem +{ + struct ares_addrinfo_node *ai; + int has_src_addr; + ares_sockaddr src_addr; + int original_order; +}; + +#define ARES_IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f) + +#define ARES_IPV6_ADDR_SCOPE_NODELOCAL 0x01 +#define ARES_IPV6_ADDR_SCOPE_INTFACELOCAL 0x01 +#define ARES_IPV6_ADDR_SCOPE_LINKLOCAL 0x02 +#define ARES_IPV6_ADDR_SCOPE_SITELOCAL 0x05 +#define ARES_IPV6_ADDR_SCOPE_ORGLOCAL 0x08 +#define ARES_IPV6_ADDR_SCOPE_GLOBAL 0x0e + +#define ARES_IN_LOOPBACK(a) ((((long int)(a)) & 0xff000000) == 0x7f000000) + +/* RFC 4193. */ +#define ARES_IN6_IS_ADDR_ULA(a) (((a)->s6_addr[0] & 0xfe) == 0xfc) + +/* These macros are modelled after the ones in . */ +/* RFC 4380, section 2.6 */ +#define ARES_IN6_IS_ADDR_TEREDO(a) \ + ((*(const unsigned int *)(const void *)(&(a)->s6_addr[0]) == ntohl(0x20010000))) +/* RFC 3056, section 2. */ +#define ARES_IN6_IS_ADDR_6TO4(a) \ + (((a)->s6_addr[0] == 0x20) && ((a)->s6_addr[1] == 0x02)) +/* 6bone testing address area (3ffe::/16), deprecated in RFC 3701. */ +#define ARES_IN6_IS_ADDR_6BONE(a) \ + (((a)->s6_addr[0] == 0x3f) && ((a)->s6_addr[1] == 0xfe)) + +static int get_scope(const struct sockaddr *addr) +{ + if (addr->sa_family == AF_INET6) + { + const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *)addr; + if (IN6_IS_ADDR_MULTICAST(&addr6->sin6_addr)) + { + return ARES_IPV6_ADDR_MC_SCOPE(&addr6->sin6_addr); + } + else if (IN6_IS_ADDR_LOOPBACK(&addr6->sin6_addr) || + IN6_IS_ADDR_LINKLOCAL(&addr6->sin6_addr)) + { + /* + * RFC 4291 section 2.5.3 says loopback is to be treated as having + * link-local scope. + */ + return ARES_IPV6_ADDR_SCOPE_LINKLOCAL; + } + else if (IN6_IS_ADDR_SITELOCAL(&addr6->sin6_addr)) + { + return ARES_IPV6_ADDR_SCOPE_SITELOCAL; + } + else + { + return ARES_IPV6_ADDR_SCOPE_GLOBAL; + } + } + else if (addr->sa_family == AF_INET) + { + const struct sockaddr_in *addr4 = (const struct sockaddr_in *)addr; + unsigned long int na = ntohl(addr4->sin_addr.s_addr); + if (ARES_IN_LOOPBACK(na) || /* 127.0.0.0/8 */ + (na & 0xffff0000) == 0xa9fe0000) /* 169.254.0.0/16 */ + { + return ARES_IPV6_ADDR_SCOPE_LINKLOCAL; + } + else + { + /* + * RFC 6724 section 3.2. Other IPv4 addresses, including private + * addresses and shared addresses (100.64.0.0/10), are assigned global + * scope. + */ + return ARES_IPV6_ADDR_SCOPE_GLOBAL; + } + } + else + { + /* + * This should never happen. + * Return a scope with low priority as a last resort. + */ + return ARES_IPV6_ADDR_SCOPE_NODELOCAL; + } +} + +static int get_label(const struct sockaddr *addr) +{ + if (addr->sa_family == AF_INET) + { + return 4; + } + else if (addr->sa_family == AF_INET6) + { + const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *)addr; + if (IN6_IS_ADDR_LOOPBACK(&addr6->sin6_addr)) + { + return 0; + } + else if (IN6_IS_ADDR_V4MAPPED(&addr6->sin6_addr)) + { + return 4; + } + else if (ARES_IN6_IS_ADDR_6TO4(&addr6->sin6_addr)) + { + return 2; + } + else if (ARES_IN6_IS_ADDR_TEREDO(&addr6->sin6_addr)) + { + return 5; + } + else if (ARES_IN6_IS_ADDR_ULA(&addr6->sin6_addr)) + { + return 13; + } + else if (IN6_IS_ADDR_V4COMPAT(&addr6->sin6_addr)) + { + return 3; + } + else if (IN6_IS_ADDR_SITELOCAL(&addr6->sin6_addr)) + { + return 11; + } + else if (ARES_IN6_IS_ADDR_6BONE(&addr6->sin6_addr)) + { + return 12; + } + else + { + /* All other IPv6 addresses, including global unicast addresses. */ + return 1; + } + } + else + { + /* + * This should never happen. + * Return a semi-random label as a last resort. + */ + return 1; + } +} + +/* + * Get the precedence for a given IPv4/IPv6 address. + * RFC 6724, section 2.1. + */ +static int get_precedence(const struct sockaddr *addr) +{ + if (addr->sa_family == AF_INET) + { + return 35; + } + else if (addr->sa_family == AF_INET6) + { + const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *)addr; + if (IN6_IS_ADDR_LOOPBACK(&addr6->sin6_addr)) + { + return 50; + } + else if (IN6_IS_ADDR_V4MAPPED(&addr6->sin6_addr)) + { + return 35; + } + else if (ARES_IN6_IS_ADDR_6TO4(&addr6->sin6_addr)) + { + return 30; + } + else if (ARES_IN6_IS_ADDR_TEREDO(&addr6->sin6_addr)) + { + return 5; + } + else if (ARES_IN6_IS_ADDR_ULA(&addr6->sin6_addr)) + { + return 3; + } + else if (IN6_IS_ADDR_V4COMPAT(&addr6->sin6_addr) || + IN6_IS_ADDR_SITELOCAL(&addr6->sin6_addr) || + ARES_IN6_IS_ADDR_6BONE(&addr6->sin6_addr)) + { + return 1; + } + else + { + /* All other IPv6 addresses, including global unicast addresses. */ + return 40; + } + } + else + { + return 1; + } +} + +/* + * Find number of matching initial bits between the two addresses a1 and a2. + */ +static int common_prefix_len(const struct in6_addr *a1, + const struct in6_addr *a2) +{ + const char *p1 = (const char *)a1; + const char *p2 = (const char *)a2; + unsigned i; + for (i = 0; i < sizeof(*a1); ++i) + { + int x, j; + if (p1[i] == p2[i]) + { + continue; + } + x = p1[i] ^ p2[i]; + for (j = 0; j < CHAR_BIT; ++j) + { + if (x & (1 << (CHAR_BIT - 1))) + { + return i * CHAR_BIT + j; + } + x <<= 1; + } + } + return sizeof(*a1) * CHAR_BIT; +} + +/* + * Compare two source/destination address pairs. + * RFC 6724, section 6. + */ +static int rfc6724_compare(const void *ptr1, const void *ptr2) +{ + const struct addrinfo_sort_elem *a1 = (const struct addrinfo_sort_elem *)ptr1; + const struct addrinfo_sort_elem *a2 = (const struct addrinfo_sort_elem *)ptr2; + int scope_src1, scope_dst1, scope_match1; + int scope_src2, scope_dst2, scope_match2; + int label_src1, label_dst1, label_match1; + int label_src2, label_dst2, label_match2; + int precedence1, precedence2; + int prefixlen1, prefixlen2; + + /* Rule 1: Avoid unusable destinations. */ + if (a1->has_src_addr != a2->has_src_addr) + { + return a2->has_src_addr - a1->has_src_addr; + } + + /* Rule 2: Prefer matching scope. */ + scope_src1 = get_scope(&a1->src_addr.sa); + scope_dst1 = get_scope(a1->ai->ai_addr); + scope_match1 = (scope_src1 == scope_dst1); + + scope_src2 = get_scope(&a2->src_addr.sa); + scope_dst2 = get_scope(a2->ai->ai_addr); + scope_match2 = (scope_src2 == scope_dst2); + + if (scope_match1 != scope_match2) + { + return scope_match2 - scope_match1; + } + + /* Rule 3: Avoid deprecated addresses. */ + + /* Rule 4: Prefer home addresses. */ + + /* Rule 5: Prefer matching label. */ + label_src1 = get_label(&a1->src_addr.sa); + label_dst1 = get_label(a1->ai->ai_addr); + label_match1 = (label_src1 == label_dst1); + + label_src2 = get_label(&a2->src_addr.sa); + label_dst2 = get_label(a2->ai->ai_addr); + label_match2 = (label_src2 == label_dst2); + + if (label_match1 != label_match2) + { + return label_match2 - label_match1; + } + + /* Rule 6: Prefer higher precedence. */ + precedence1 = get_precedence(a1->ai->ai_addr); + precedence2 = get_precedence(a2->ai->ai_addr); + if (precedence1 != precedence2) + { + return precedence2 - precedence1; + } + + /* Rule 7: Prefer native transport. */ + + /* Rule 8: Prefer smaller scope. */ + if (scope_dst1 != scope_dst2) + { + return scope_dst1 - scope_dst2; + } + + /* Rule 9: Use longest matching prefix. */ + if (a1->has_src_addr && a1->ai->ai_addr->sa_family == AF_INET6 && + a2->has_src_addr && a2->ai->ai_addr->sa_family == AF_INET6) + { + const struct sockaddr_in6 *a1_src = &a1->src_addr.sa6; + const struct sockaddr_in6 *a1_dst = + (const struct sockaddr_in6 *)a1->ai->ai_addr; + const struct sockaddr_in6 *a2_src = &a2->src_addr.sa6; + const struct sockaddr_in6 *a2_dst = + (const struct sockaddr_in6 *)a2->ai->ai_addr; + prefixlen1 = common_prefix_len(&a1_src->sin6_addr, &a1_dst->sin6_addr); + prefixlen2 = common_prefix_len(&a2_src->sin6_addr, &a2_dst->sin6_addr); + if (prefixlen1 != prefixlen2) + { + return prefixlen2 - prefixlen1; + } + } + + /* + * Rule 10: Leave the order unchanged. + * We need this since qsort() is not necessarily stable. + */ + return a1->original_order - a2->original_order; +} + +/* + * Find the source address that will be used if trying to connect to the given + * address. + * + * Returns 1 if a source address was found, 0 if the address is unreachable, + * and -1 if a fatal error occurred. If 0 or 1, the contents of src_addr are + * undefined. + */ +static int find_src_addr(ares_channel channel, + const struct sockaddr *addr, + struct sockaddr *src_addr) +{ + int sock; + int ret; + ares_socklen_t len; + + switch (addr->sa_family) + { + case AF_INET: + len = sizeof(struct sockaddr_in); + break; + case AF_INET6: + len = sizeof(struct sockaddr_in6); + break; + default: + /* No known usable source address for non-INET families. */ + return 0; + } + + sock = ares__open_socket(channel, addr->sa_family, SOCK_DGRAM, IPPROTO_UDP); + if (sock == -1) + { + if (errno == EAFNOSUPPORT) + { + return 0; + } + else + { + return -1; + } + } + + do + { + ret = ares__connect_socket(channel, sock, addr, len); + } + while (ret == -1 && errno == EINTR); + + if (ret == -1) + { + ares__close_socket(channel, sock); + return 0; + } + + if (getsockname(sock, src_addr, &len) == -1) + { + ares__close_socket(channel, sock); + return -1; + } + ares__close_socket(channel, sock); + return 1; +} + +/* + * Sort the linked list starting at sentinel->ai_next in RFC6724 order. + * Will leave the list unchanged if an error occurs. + */ +int ares__sortaddrinfo(ares_channel channel, struct ares_addrinfo_node *list_sentinel) +{ + struct ares_addrinfo_node *cur; + int nelem = 0, i; + int has_src_addr; + struct addrinfo_sort_elem *elems; + + cur = list_sentinel->ai_next; + while (cur) + { + ++nelem; + cur = cur->ai_next; + } + elems = (struct addrinfo_sort_elem *)ares_malloc( + nelem * sizeof(struct addrinfo_sort_elem)); + if (!elems) + { + return ARES_ENOMEM; + } + + /* + * Convert the linked list to an array that also contains the candidate + * source address for each destination address. + */ + for (i = 0, cur = list_sentinel->ai_next; i < nelem; ++i, cur = cur->ai_next) + { + assert(cur != NULL); + elems[i].ai = cur; + elems[i].original_order = i; + has_src_addr = find_src_addr(channel, cur->ai_addr, &elems[i].src_addr.sa); + if (has_src_addr == -1) + { + ares_free(elems); + return ARES_ENOTFOUND; + } + elems[i].has_src_addr = has_src_addr; + } + + /* Sort the addresses, and rearrange the linked list so it matches the sorted + * order. */ + qsort((void *)elems, nelem, sizeof(struct addrinfo_sort_elem), + rfc6724_compare); + + list_sentinel->ai_next = elems[0].ai; + for (i = 0; i < nelem - 1; ++i) + { + elems[i].ai->ai_next = elems[i + 1].ai; + } + elems[nelem - 1].ai->ai_next = NULL; + + ares_free(elems); + return ARES_SUCCESS; +} \ No newline at end of file diff --git a/deps/cares/src/ares_android.c b/deps/cares/src/ares_android.c index bf77131b58cf84..5b00b8065c56b9 100644 --- a/deps/cares/src/ares_android.c +++ b/deps/cares/src/ares_android.c @@ -360,8 +360,6 @@ char *ares_get_android_search_domains_list(void) jstring domains = NULL; const char *domain; int res; - size_t i; - size_t cnt = 0; char *domain_list = NULL; int need_detatch = 0; diff --git a/deps/cares/src/ares_freeaddrinfo.c b/deps/cares/src/ares_freeaddrinfo.c new file mode 100644 index 00000000000000..128f5daec4d39f --- /dev/null +++ b/deps/cares/src/ares_freeaddrinfo.c @@ -0,0 +1,57 @@ + +/* Copyright 1998 by the Massachusetts Institute of Technology. + * Copyright (C) 2019 by Andrew Selivanov + * + * Permission to use, copy, modify, and distribute this + * software and its documentation for any purpose and without + * fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting + * documentation, and that the name of M.I.T. not be used in + * advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" + * without express or implied warranty. + */ + +#include "ares_setup.h" + +#ifdef HAVE_NETDB_H +# include +#endif + +#include "ares.h" +#include "ares_private.h" + +void ares__freeaddrinfo_cnames(struct ares_addrinfo_cname *head) +{ + struct ares_addrinfo_cname *current; + while (head) + { + current = head; + head = head->next; + ares_free(current->alias); + ares_free(current->name); + ares_free(current); + } +} + +void ares__freeaddrinfo_nodes(struct ares_addrinfo_node *head) +{ + struct ares_addrinfo_node *current; + while (head) + { + current = head; + head = head->ai_next; + ares_free(current->ai_addr); + ares_free(current); + } +} + +void ares_freeaddrinfo(struct ares_addrinfo *ai) +{ + ares__freeaddrinfo_cnames(ai->cnames); + ares__freeaddrinfo_nodes(ai->nodes); + ares_free(ai); +} diff --git a/deps/cares/src/ares_getaddrinfo.c b/deps/cares/src/ares_getaddrinfo.c new file mode 100644 index 00000000000000..8265e4afc20f60 --- /dev/null +++ b/deps/cares/src/ares_getaddrinfo.c @@ -0,0 +1,764 @@ + +/* Copyright 1998, 2011, 2013 by the Massachusetts Institute of Technology. + * Copyright (C) 2017 - 2018 by Christian Ammer + * Copyright (C) 2019 by Andrew Selivanov + * + * Permission to use, copy, modify, and distribute this + * software and its documentation for any purpose and without + * fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting + * documentation, and that the name of M.I.T. not be used in + * advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" + * without express or implied warranty. + */ + +#include "ares_setup.h" + +#ifdef HAVE_GETSERVBYNAME_R +# if !defined(GETSERVBYNAME_R_ARGS) || \ + (GETSERVBYNAME_R_ARGS < 4) || (GETSERVBYNAME_R_ARGS > 6) +# error "you MUST specifiy a valid number of arguments for getservbyname_r" +# endif +#endif + +#ifdef HAVE_NETINET_IN_H +# include +#endif +#ifdef HAVE_NETDB_H +# include +#endif +#ifdef HAVE_ARPA_INET_H +# include +#endif +#ifdef HAVE_ARPA_NAMESER_H +# include +#else +# include "nameser.h" +#endif +#ifdef HAVE_ARPA_NAMESER_COMPAT_H +# include +#endif + +#ifdef HAVE_STRINGS_H +#include +#endif +#include + +#ifdef HAVE_LIMITS_H +#include +#endif + +#include "ares.h" +#include "bitncmp.h" +#include "ares_private.h" + +#ifdef WATT32 +#undef WIN32 +#endif +#ifdef WIN32 +# include "ares_platform.h" +#endif + +struct host_query +{ + ares_channel channel; + char *name; + unsigned short port; /* in host order */ + ares_addrinfo_callback callback; + void *arg; + struct ares_addrinfo_hints hints; + int sent_family; /* this family is what was is being used */ + int timeouts; /* number of timeouts we saw for this request */ + const char *remaining_lookups; /* types of lookup we need to perform ("fb" by + default, file and dns respectively) */ + struct ares_addrinfo *ai; /* store results between lookups */ + int remaining; /* number of DNS answers waiting for */ + int next_domain; /* next search domain to try */ +}; + +static const struct ares_addrinfo_hints default_hints = { + 0, /* ai_flags */ + AF_UNSPEC, /* ai_family */ + 0, /* ai_socktype */ + 0, /* ai_protocol */ +}; + +static const struct ares_addrinfo_cname empty_addrinfo_cname = { + INT_MAX, /* ttl */ + NULL, /* alias */ + NULL, /* name */ + NULL, /* next */ +}; + +static const struct ares_addrinfo_node empty_addrinfo_node = { + 0, /* ai_ttl */ + 0, /* ai_flags */ + 0, /* ai_family */ + 0, /* ai_socktype */ + 0, /* ai_protocol */ + 0, /* ai_addrlen */ + NULL, /* ai_addr */ + NULL /* ai_next */ +}; + +static const struct ares_addrinfo empty_addrinfo = { + NULL, /* cnames */ + NULL /* nodes */ +}; + +/* forward declarations */ +static void host_callback(void *arg, int status, int timeouts, + unsigned char *abuf, int alen); +static int as_is_first(const struct host_query *hquery); +static int next_dns_lookup(struct host_query *hquery); + +struct ares_addrinfo_cname *ares__malloc_addrinfo_cname() +{ + struct ares_addrinfo_cname *cname = ares_malloc(sizeof(struct ares_addrinfo_cname)); + if (!cname) + return NULL; + + *cname = empty_addrinfo_cname; + return cname; +} + +struct ares_addrinfo_cname *ares__append_addrinfo_cname(struct ares_addrinfo_cname **head) +{ + struct ares_addrinfo_cname *tail = ares__malloc_addrinfo_cname(); + struct ares_addrinfo_cname *last = *head; + if (!last) + { + *head = tail; + return tail; + } + + while (last->next) + { + last = last->next; + } + + last->next = tail; + return tail; +} + +void ares__addrinfo_cat_cnames(struct ares_addrinfo_cname **head, + struct ares_addrinfo_cname *tail) +{ + struct ares_addrinfo_cname *last = *head; + if (!last) + { + *head = tail; + return; + } + + while (last->next) + { + last = last->next; + } + + last->next = tail; +} + +struct ares_addrinfo *ares__malloc_addrinfo() +{ + struct ares_addrinfo *ai = ares_malloc(sizeof(struct ares_addrinfo)); + if (!ai) + return NULL; + + *ai = empty_addrinfo; + return ai; +} + +struct ares_addrinfo_node *ares__malloc_addrinfo_node() +{ + struct ares_addrinfo_node *node = + ares_malloc(sizeof(struct ares_addrinfo_node)); + if (!node) + return NULL; + + *node = empty_addrinfo_node; + return node; +} + +/* Allocate new addrinfo and append to the tail. */ +struct ares_addrinfo_node *ares__append_addrinfo_node(struct ares_addrinfo_node **head) +{ + struct ares_addrinfo_node *tail = ares__malloc_addrinfo_node(); + struct ares_addrinfo_node *last = *head; + if (!last) + { + *head = tail; + return tail; + } + + while (last->ai_next) + { + last = last->ai_next; + } + + last->ai_next = tail; + return tail; +} + +void ares__addrinfo_cat_nodes(struct ares_addrinfo_node **head, + struct ares_addrinfo_node *tail) +{ + struct ares_addrinfo_node *last = *head; + if (!last) + { + *head = tail; + return; + } + + while (last->ai_next) + { + last = last->ai_next; + } + + last->ai_next = tail; +} + +/* Resolve service name into port number given in host byte order. + * If not resolved, return 0. + */ +static unsigned short lookup_service(const char *service, int flags) +{ + const char *proto; + struct servent *sep; +#ifdef HAVE_GETSERVBYNAME_R + struct servent se; + char tmpbuf[4096]; +#endif + + if (service) + { + if (flags & ARES_NI_UDP) + proto = "udp"; + else if (flags & ARES_NI_SCTP) + proto = "sctp"; + else if (flags & ARES_NI_DCCP) + proto = "dccp"; + else + proto = "tcp"; +#ifdef HAVE_GETSERVBYNAME_R + memset(&se, 0, sizeof(se)); + sep = &se; + memset(tmpbuf, 0, sizeof(tmpbuf)); +#if GETSERVBYNAME_R_ARGS == 6 + if (getservbyname_r(service, proto, &se, (void *)tmpbuf, sizeof(tmpbuf), + &sep) != 0) + sep = NULL; /* LCOV_EXCL_LINE: buffer large so this never fails */ +#elif GETSERVBYNAME_R_ARGS == 5 + sep = + getservbyname_r(service, proto, &se, (void *)tmpbuf, sizeof(tmpbuf)); +#elif GETSERVBYNAME_R_ARGS == 4 + if (getservbyname_r(service, proto, &se, (void *)tmpbuf) != 0) + sep = NULL; +#else + /* Lets just hope the OS uses TLS! */ + sep = getservbyname(service, proto); +#endif +#else + /* Lets just hope the OS uses TLS! */ +#if (defined(NETWARE) && !defined(__NOVELL_LIBC__)) + sep = getservbyname(service, (char *)proto); +#else + sep = getservbyname(service, proto); +#endif +#endif + return (sep ? ntohs((unsigned short)sep->s_port) : 0); + } + return 0; +} + +/* If the name looks like an IP address or an error occured, + * fake up a host entry, end the query immediately, and return true. + * Otherwise return false. + */ +static int fake_addrinfo(const char *name, + unsigned short port, + const struct ares_addrinfo_hints *hints, + struct ares_addrinfo *ai, + ares_addrinfo_callback callback, + void *arg) +{ + struct ares_addrinfo_cname *cname; + struct ares_addrinfo_node *node; + ares_sockaddr addr; + size_t addrlen; + int result = 0; + int family = hints->ai_family; + if (family == AF_INET || family == AF_INET6 || family == AF_UNSPEC) + { + /* It only looks like an IP address if it's all numbers and dots. */ + int numdots = 0, valid = 1; + const char *p; + for (p = name; *p; p++) + { + if (!ISDIGIT(*p) && *p != '.') + { + valid = 0; + break; + } + else if (*p == '.') + { + numdots++; + } + } + + memset(&addr, 0, sizeof(addr)); + + /* if we don't have 3 dots, it is illegal + * (although inet_pton doesn't think so). + */ + if (numdots != 3 || !valid) + result = 0; + else + result = + (ares_inet_pton(AF_INET, name, &addr.sa4.sin_addr) < 1 ? 0 : 1); + + if (result) + { + family = addr.sa.sa_family = AF_INET; + addr.sa4.sin_port = htons(port); + addrlen = sizeof(addr.sa4); + } + } + + if (family == AF_INET6 || family == AF_UNSPEC) + { + result = + (ares_inet_pton(AF_INET6, name, &addr.sa6.sin6_addr) < 1 ? 0 : 1); + addr.sa6.sin6_family = AF_INET6; + addr.sa6.sin6_port = htons(port); + addrlen = sizeof(addr.sa6); + } + + if (!result) + return 0; + + node = ares__malloc_addrinfo_node(); + if (!node) + { + ares_freeaddrinfo(ai); + callback(arg, ARES_ENOMEM, 0, NULL); + return 1; + } + + ai->nodes = node; + + node->ai_addr = ares_malloc(addrlen); + if (!node->ai_addr) + { + ares_freeaddrinfo(ai); + callback(arg, ARES_ENOMEM, 0, NULL); + return 1; + } + + node->ai_addrlen = (unsigned int)addrlen; + node->ai_family = addr.sa.sa_family; + if (addr.sa.sa_family == AF_INET) + memcpy(node->ai_addr, &addr.sa4, sizeof(addr.sa4)); + else + memcpy(node->ai_addr, &addr.sa6, sizeof(addr.sa6)); + + if (hints->ai_flags & ARES_AI_CANONNAME) + { + cname = ares__append_addrinfo_cname(&ai->cnames); + if (!cname) + { + ares_freeaddrinfo(ai); + callback(arg, ARES_ENOMEM, 0, NULL); + return 1; + } + + /* Duplicate the name, to avoid a constness violation. */ + cname->name = ares_strdup(name); + if (!cname->name) + { + ares_freeaddrinfo(ai); + callback(arg, ARES_ENOMEM, 0, NULL); + return 1; + } + } + + callback(arg, ARES_SUCCESS, 0, ai); + return 1; +} + +static void end_hquery(struct host_query *hquery, int status) +{ + struct ares_addrinfo_node sentinel; + struct ares_addrinfo_node *next; + if (status == ARES_SUCCESS) + { + if (!(hquery->hints.ai_flags & ARES_AI_NOSORT)) + { + sentinel.ai_next = hquery->ai->nodes; + ares__sortaddrinfo(hquery->channel, &sentinel); + hquery->ai->nodes = sentinel.ai_next; + } + next = hquery->ai->nodes; + /* Set port into each address (resolved separately). */ + while (next) + { + if (next->ai_family == AF_INET) + { + ((struct sockaddr_in *)next->ai_addr)->sin_port = htons(hquery->port); + } + else + { + ((struct sockaddr_in6 *)next->ai_addr)->sin6_port = htons(hquery->port); + } + next = next->ai_next; + } + } + else + { + /* Clean up what we have collected by so far. */ + ares_freeaddrinfo(hquery->ai); + hquery->ai = NULL; + } + + hquery->callback(hquery->arg, status, hquery->timeouts, hquery->ai); + ares_free(hquery->name); + ares_free(hquery); +} + +static int file_lookup(struct host_query *hquery) +{ + FILE *fp; + int error; + int status; + const char *path_hosts = NULL; + + if (hquery->hints.ai_flags & ARES_AI_ENVHOSTS) + { + path_hosts = getenv("CARES_HOSTS"); + } + + if (!path_hosts) + { +#ifdef WIN32 + char PATH_HOSTS[MAX_PATH]; + win_platform platform; + + PATH_HOSTS[0] = '\0'; + + platform = ares__getplatform(); + + if (platform == WIN_NT) + { + char tmp[MAX_PATH]; + HKEY hkeyHosts; + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, + &hkeyHosts) == ERROR_SUCCESS) + { + DWORD dwLength = MAX_PATH; + RegQueryValueEx(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp, + &dwLength); + ExpandEnvironmentStrings(tmp, PATH_HOSTS, MAX_PATH); + RegCloseKey(hkeyHosts); + } + } + else if (platform == WIN_9X) + GetWindowsDirectory(PATH_HOSTS, MAX_PATH); + else + return ARES_ENOTFOUND; + + strcat(PATH_HOSTS, WIN_PATH_HOSTS); + path_hosts = PATH_HOSTS; + +#elif defined(WATT32) + const char *PATH_HOSTS = _w32_GetHostsFile(); + + if (!PATH_HOSTS) + return ARES_ENOTFOUND; +#endif + path_hosts = PATH_HOSTS; + } + + fp = fopen(path_hosts, "r"); + if (!fp) + { + error = ERRNO; + switch (error) + { + case ENOENT: + case ESRCH: + return ARES_ENOTFOUND; + default: + DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", error, + strerror(error))); + DEBUGF(fprintf(stderr, "Error opening file: %s\n", path_hosts)); + return ARES_EFILE; + } + } + status = ares__readaddrinfo(fp, hquery->name, hquery->port, &hquery->hints, hquery->ai); + fclose(fp); + return status; +} + +static void next_lookup(struct host_query *hquery, int status) +{ + switch (*hquery->remaining_lookups) + { + case 'b': + /* DNS lookup */ + if (next_dns_lookup(hquery)) + break; + hquery->remaining_lookups++; + next_lookup(hquery, status); + break; + + case 'f': + /* Host file lookup */ + if (file_lookup(hquery) == ARES_SUCCESS) + { + end_hquery(hquery, ARES_SUCCESS); + break; + } + hquery->remaining_lookups++; + next_lookup(hquery, status); + break; + default: + /* No lookup left */ + end_hquery(hquery, status); + break; + } +} + +static void host_callback(void *arg, int status, int timeouts, + unsigned char *abuf, int alen) +{ + struct host_query *hquery = (struct host_query*)arg; + int addinfostatus = ARES_SUCCESS; + hquery->timeouts += timeouts; + hquery->remaining--; + + if (status == ARES_SUCCESS) + { + addinfostatus = ares__parse_into_addrinfo(abuf, alen, hquery->ai); + } + else if (status == ARES_EDESTRUCTION) + { + end_hquery(hquery, status); + } + + if (!hquery->remaining) + { + if (addinfostatus != ARES_SUCCESS) + { + /* error in parsing result e.g. no memory */ + end_hquery(hquery, addinfostatus); + } + else if (hquery->ai->nodes) + { + /* at least one query ended with ARES_SUCCESS */ + end_hquery(hquery, ARES_SUCCESS); + } + else if (status == ARES_ENOTFOUND) + { + next_lookup(hquery, status); + } + else + { + end_hquery(hquery, status); + } + } + + /* at this point we keep on waiting for the next query to finish */ +} + +void ares_getaddrinfo(ares_channel channel, + const char* name, const char* service, + const struct ares_addrinfo_hints* hints, + ares_addrinfo_callback callback, void* arg) +{ + struct host_query *hquery; + unsigned short port = 0; + int family; + struct ares_addrinfo *ai; + + if (!hints) + { + hints = &default_hints; + } + + family = hints->ai_family; + + /* Right now we only know how to look up Internet addresses + and unspec means try both basically. */ + if (family != AF_INET && + family != AF_INET6 && + family != AF_UNSPEC) + { + callback(arg, ARES_ENOTIMP, 0, NULL); + return; + } + + if (ares__is_onion_domain(name)) + { + callback(arg, ARES_ENOTFOUND, 0, NULL); + return; + } + + if (service) + { + if (hints->ai_flags & ARES_AI_NUMERICSERV) + { + port = (unsigned short)strtoul(service, NULL, 0); + if (!port) + { + callback(arg, ARES_ESERVICE, 0, NULL); + return; + } + } + else + { + port = lookup_service(service, 0); + if (!port) + { + port = (unsigned short)strtoul(service, NULL, 0); + if (!port) + { + callback(arg, ARES_ESERVICE, 0, NULL); + return; + } + } + } + } + + ai = ares__malloc_addrinfo(); + if (!ai) + { + callback(arg, ARES_ENOMEM, 0, NULL); + return; + } + + if (fake_addrinfo(name, port, hints, ai, callback, arg)) + { + return; + } + + /* Allocate and fill in the host query structure. */ + hquery = ares_malloc(sizeof(struct host_query)); + if (!hquery) + { + ares_freeaddrinfo(ai); + callback(arg, ARES_ENOMEM, 0, NULL); + return; + } + + hquery->name = ares_strdup(name); + if (!hquery->name) + { + ares_free(hquery); + ares_freeaddrinfo(ai); + callback(arg, ARES_ENOMEM, 0, NULL); + return; + } + + hquery->port = port; + hquery->channel = channel; + hquery->hints = *hints; + hquery->sent_family = -1; /* nothing is sent yet */ + hquery->callback = callback; + hquery->arg = arg; + hquery->remaining_lookups = channel->lookups; + hquery->timeouts = 0; + hquery->ai = ai; + hquery->next_domain = -1; + hquery->remaining = 0; + + /* Start performing lookups according to channel->lookups. */ + next_lookup(hquery, ARES_ECONNREFUSED /* initial error code */); +} + +static int next_dns_lookup(struct host_query *hquery) +{ + char *s = NULL; + int is_s_allocated = 0; + int status; + + /* if next_domain == -1 and as_is_first is true, try hquery->name */ + if (hquery->next_domain == -1) + { + if (as_is_first(hquery)) + { + s = hquery->name; + } + hquery->next_domain = 0; + } + + /* if as_is_first is false, try hquery->name at last */ + if (!s && hquery->next_domain == hquery->channel->ndomains) { + if (!as_is_first(hquery)) + { + s = hquery->name; + } + hquery->next_domain++; + } + + if (!s && hquery->next_domain < hquery->channel->ndomains) + { + status = ares__cat_domain( + hquery->name, + hquery->channel->domains[hquery->next_domain++], + &s); + if (status == ARES_SUCCESS) + { + is_s_allocated = 1; + } + } + + if (s) + { + switch (hquery->hints.ai_family) + { + case AF_INET: + hquery->remaining += 1; + ares_query(hquery->channel, s, C_IN, T_A, host_callback, hquery); + break; + case AF_INET6: + hquery->remaining += 1; + ares_query(hquery->channel, s, C_IN, T_AAAA, host_callback, hquery); + break; + case AF_UNSPEC: + hquery->remaining += 2; + ares_query(hquery->channel, s, C_IN, T_A, host_callback, hquery); + ares_query(hquery->channel, s, C_IN, T_AAAA, host_callback, hquery); + break; + default: break; + } + if (is_s_allocated) + { + ares_free(s); + } + return 1; + } + else + { + assert(!hquery->ai->nodes); + return 0; + } +} + +static int as_is_first(const struct host_query* hquery) +{ + char* p; + int ndots = 0; + for (p = hquery->name; *p; p++) + { + if (*p == '.') + { + ndots++; + } + } + return ndots >= hquery->channel->ndots; +} diff --git a/deps/cares/src/ares_getenv.c b/deps/cares/src/ares_getenv.c index 1b2e85d2bee9c5..f6e4dc29526218 100644 --- a/deps/cares/src/ares_getenv.c +++ b/deps/cares/src/ares_getenv.c @@ -22,9 +22,7 @@ char *ares_getenv(const char *name) { -#ifdef _WIN32_WCE return NULL; -#endif } #endif diff --git a/deps/cares/src/ares_gethostbyname.c b/deps/cares/src/ares_gethostbyname.c index 8187746bb14c7f..ecd03e79310c63 100644 --- a/deps/cares/src/ares_gethostbyname.c +++ b/deps/cares/src/ares_gethostbyname.c @@ -211,6 +211,13 @@ static void host_callback(void *arg, int status, int timeouts, if (host && channel->nsort) sort6_addresses(host, channel->sortlist, channel->nsort); } + if (status == ARES_SUCCESS && host && host->h_addr_list[0] == NULL) + { + /* The query returned something but had no A/AAAA record + (even after potentially retrying AAAA with A) + so we should treat this as an error */ + status = ARES_ENODATA; + } end_hquery(hquery, status, host); } else if ((status == ARES_ENODATA || status == ARES_EBADRESP || @@ -267,12 +274,12 @@ static int fake_hostent(const char *name, int family, } /* if we don't have 3 dots, it is illegal - * (although inet_addr doesn't think so). + * (although inet_pton doesn't think so). */ if (numdots != 3 || !valid) result = 0; else - result = ((in.s_addr = inet_addr(name)) == INADDR_NONE ? 0 : 1); + result = (ares_inet_pton(AF_INET, name, &in) < 1 ? 0 : 1); if (result) family = AF_INET; @@ -346,10 +353,6 @@ static int file_lookup(const char *name, int family, struct hostent **host) int status; int error; - /* Per RFC 7686, reject queries for ".onion" domain names with NXDOMAIN. */ - if (ares__is_onion_domain(name)) - return ARES_ENOTFOUND; - #ifdef WIN32 char PATH_HOSTS[MAX_PATH]; win_platform platform; @@ -387,6 +390,11 @@ static int file_lookup(const char *name, int family, struct hostent **host) return ARES_ENOTFOUND; #endif + /* Per RFC 7686, reject queries for ".onion" domain names with NXDOMAIN. */ + if (ares__is_onion_domain(name)) + return ARES_ENOTFOUND; + + fp = fopen(PATH_HOSTS, "r"); if (!fp) { diff --git a/deps/cares/src/ares_init.c b/deps/cares/src/ares_init.c index c2c00d65237072..dffa518171b29c 100644 --- a/deps/cares/src/ares_init.c +++ b/deps/cares/src/ares_init.c @@ -1543,8 +1543,6 @@ static int init_by_resolv_conf(ares_channel channel) #elif defined(ANDROID) || defined(__ANDROID__) unsigned int i; - char propname[PROP_NAME_MAX]; - char propvalue[PROP_VALUE_MAX]=""; char **dns_servers; char *domains; size_t num_servers; @@ -1587,6 +1585,8 @@ static int init_by_resolv_conf(ares_channel channel) * We'll only run this if we don't have any dns servers * because this will get the same ones (if it works). */ if (status != ARES_EOF) { + char propname[PROP_NAME_MAX]; + char propvalue[PROP_VALUE_MAX]=""; for (i = 1; i <= MAX_DNS_PROPERTIES; i++) { snprintf(propname, sizeof(propname), "%s%u", DNS_PROP_NAME_PREFIX, i); if (__system_property_get(propname, propvalue) < 1) { @@ -2024,6 +2024,7 @@ static int config_lookup(ares_channel channel, const char *str, { char lookups[3], *l; const char *vqualifier p; + int found; if (altbindch == NULL) altbindch = bindch; @@ -2034,17 +2035,21 @@ static int config_lookup(ares_channel channel, const char *str, */ l = lookups; p = str; + found = 0; while (*p) { if ((*p == *bindch || *p == *altbindch || *p == *filech) && l < lookups + 2) { if (*p == *bindch || *p == *altbindch) *l++ = 'b'; else *l++ = 'f'; + found = 1; } while (*p && !ISSPACE(*p) && (*p != ',')) p++; while (*p && (ISSPACE(*p) || (*p == ','))) p++; } + if (!found) + return ARES_ENOTINITIALIZED; *l = '\0'; channel->lookups = ares_strdup(lookups); return (channel->lookups) ? ARES_SUCCESS : ARES_ENOMEM; @@ -2418,9 +2423,9 @@ static int ip_addr(const char *ipbuf, ares_ssize_t len, struct in_addr *addr) if (len > 15) return -1; - addr->s_addr = inet_addr(ipbuf); - if (addr->s_addr == INADDR_NONE && strcmp(ipbuf, "255.255.255.255") != 0) + if (ares_inet_pton(AF_INET, ipbuf, addr) < 1) return -1; + return 0; } diff --git a/deps/cares/src/ares_ipv6.h b/deps/cares/src/ares_ipv6.h index b0017f16c79d20..fdbc21fe8f9fa5 100644 --- a/deps/cares/src/ares_ipv6.h +++ b/deps/cares/src/ares_ipv6.h @@ -32,6 +32,13 @@ struct sockaddr_in6 }; #endif +typedef union +{ + struct sockaddr sa; + struct sockaddr_in sa4; + struct sockaddr_in6 sa6; +} ares_sockaddr; + #ifndef HAVE_STRUCT_ADDRINFO struct addrinfo { diff --git a/deps/cares/src/ares_parse_a_reply.c b/deps/cares/src/ares_parse_a_reply.c index 0422bd3828a765..920ba24af42129 100644 --- a/deps/cares/src/ares_parse_a_reply.c +++ b/deps/cares/src/ares_parse_a_reply.c @@ -1,5 +1,6 @@ /* Copyright 1998 by the Massachusetts Institute of Technology. + * Copyright (C) 2019 by Andrew Selivanov * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without @@ -50,215 +51,164 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen, struct hostent **host, struct ares_addrttl *addrttls, int *naddrttls) { - unsigned int qdcount, ancount; - int status, i, rr_type, rr_class, rr_len, rr_ttl, naddrs; - int cname_ttl = INT_MAX; /* the TTL imposed by the CNAME chain */ - int naliases; - long len; - const unsigned char *aptr; - char *hostname, *rr_name, *rr_data, **aliases; - struct in_addr *addrs; - struct hostent *hostent; - const int max_addr_ttls = (addrttls && naddrttls) ? *naddrttls : 0; - - /* Set *host to NULL for all failure cases. */ - if (host) - *host = NULL; - /* Same with *naddrttls. */ - if (naddrttls) - *naddrttls = 0; + struct ares_addrinfo ai; + struct ares_addrinfo_node *next; + struct ares_addrinfo_cname *next_cname; + char **aliases = NULL; + char *question_hostname = NULL; + struct hostent *hostent = NULL; + struct in_addr *addrs = NULL; + int naliases = 0, naddrs = 0, alias = 0, i; + int cname_ttl = INT_MAX; + int status; + + memset(&ai, 0, sizeof(ai)); + + status = ares__parse_into_addrinfo2(abuf, alen, &question_hostname, &ai); + if (status != ARES_SUCCESS) + { + ares_free(question_hostname); - /* Give up if abuf doesn't have room for a header. */ - if (alen < HFIXEDSZ) - return ARES_EBADRESP; + if (naddrttls) + { + *naddrttls = 0; + } - /* Fetch the question and answer count from the header. */ - qdcount = DNS_HEADER_QDCOUNT(abuf); - ancount = DNS_HEADER_ANCOUNT(abuf); - if (qdcount != 1) - return ARES_EBADRESP; + return status; + } - /* Expand the name from the question, and skip past the question. */ - aptr = abuf + HFIXEDSZ; - status = ares__expand_name_for_response(aptr, abuf, alen, &hostname, &len); - if (status != ARES_SUCCESS) - return status; - if (aptr + len + QFIXEDSZ > abuf + alen) + hostent = ares_malloc(sizeof(struct hostent)); + if (!hostent) { - ares_free(hostname); - return ARES_EBADRESP; + goto enomem; } - aptr += len + QFIXEDSZ; - if (host) + next = ai.nodes; + while (next) { - /* Allocate addresses and aliases; ancount gives an upper bound for - both. */ - addrs = ares_malloc(ancount * sizeof(struct in_addr)); - if (!addrs) + if (next->ai_family == AF_INET) { - ares_free(hostname); - return ARES_ENOMEM; - } - aliases = ares_malloc((ancount + 1) * sizeof(char *)); - if (!aliases) - { - ares_free(hostname); - ares_free(addrs); - return ARES_ENOMEM; + ++naddrs; } + next = next->ai_next; } - else + + next_cname = ai.cnames; + while (next_cname) { - addrs = NULL; - aliases = NULL; + if(next_cname->alias) + ++naliases; + next_cname = next_cname->next; } - naddrs = 0; - naliases = 0; - - /* Examine each answer resource record (RR) in turn. */ - for (i = 0; i < (int)ancount; i++) + aliases = ares_malloc((naliases + 1) * sizeof(char *)); + if (!aliases) { - /* Decode the RR up to the data field. */ - status = ares__expand_name_for_response(aptr, abuf, alen, &rr_name, &len); - if (status != ARES_SUCCESS) - break; - aptr += len; - if (aptr + RRFIXEDSZ > abuf + alen) - { - ares_free(rr_name); - status = ARES_EBADRESP; - break; - } - rr_type = DNS_RR_TYPE(aptr); - rr_class = DNS_RR_CLASS(aptr); - rr_len = DNS_RR_LEN(aptr); - rr_ttl = DNS_RR_TTL(aptr); - aptr += RRFIXEDSZ; - if (aptr + rr_len > abuf + alen) - { - ares_free(rr_name); - status = ARES_EBADRESP; - break; - } + goto enomem; + } - if (rr_class == C_IN && rr_type == T_A - && rr_len == sizeof(struct in_addr) - && strcasecmp(rr_name, hostname) == 0) + if (naliases) + { + next_cname = ai.cnames; + while (next_cname) { - if (addrs) - { - if (aptr + sizeof(struct in_addr) > abuf + alen) - { /* LCOV_EXCL_START: already checked above */ - ares_free(rr_name); - status = ARES_EBADRESP; - break; - } /* LCOV_EXCL_STOP */ - memcpy(&addrs[naddrs], aptr, sizeof(struct in_addr)); - } - if (naddrs < max_addr_ttls) - { - struct ares_addrttl * const at = &addrttls[naddrs]; - if (aptr + sizeof(struct in_addr) > abuf + alen) - { /* LCOV_EXCL_START: already checked above */ - ares_free(rr_name); - status = ARES_EBADRESP; - break; - } /* LCOV_EXCL_STOP */ - memcpy(&at->ipaddr, aptr, sizeof(struct in_addr)); - at->ttl = rr_ttl; - } - naddrs++; - status = ARES_SUCCESS; + if(next_cname->alias) + aliases[alias++] = strdup(next_cname->alias); + if(next_cname->ttl < cname_ttl) + cname_ttl = next_cname->ttl; + next_cname = next_cname->next; } + } - if (rr_class == C_IN && rr_type == T_CNAME) - { - /* Record the RR name as an alias. */ - if (aliases) - aliases[naliases] = rr_name; - else - ares_free(rr_name); - naliases++; + aliases[alias] = NULL; - /* Decode the RR data and replace the hostname with it. */ - status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data, - &len); - if (status != ARES_SUCCESS) - break; - ares_free(hostname); - hostname = rr_data; + hostent->h_addr_list = ares_malloc((naddrs + 1) * sizeof(char *)); + if (!hostent->h_addr_list) + { + goto enomem; + } - /* Take the min of the TTLs we see in the CNAME chain. */ - if (cname_ttl > rr_ttl) - cname_ttl = rr_ttl; - } - else - ares_free(rr_name); + for (i = 0; i < naddrs + 1; ++i) + { + hostent->h_addr_list[i] = NULL; + } - aptr += rr_len; - if (aptr > abuf + alen) - { /* LCOV_EXCL_START: already checked above */ - status = ARES_EBADRESP; - break; - } /* LCOV_EXCL_STOP */ + if (ai.cnames) + { + hostent->h_name = strdup(ai.cnames->name); + ares_free(question_hostname); } + else + { + hostent->h_name = question_hostname; + } + + hostent->h_aliases = aliases; + hostent->h_addrtype = AF_INET; + hostent->h_length = sizeof(struct in_addr); - if (status == ARES_SUCCESS && naddrs == 0 && naliases == 0) - /* the check for naliases to be zero is to make sure CNAME responses - don't get caught here */ - status = ARES_ENODATA; - if (status == ARES_SUCCESS) + if (naddrs) { - /* We got our answer. */ - if (naddrttls) + addrs = ares_malloc(naddrs * sizeof(struct in_addr)); + if (!addrs) { - const int n = naddrs < max_addr_ttls ? naddrs : max_addr_ttls; - for (i = 0; i < n; i++) - { - /* Ensure that each A TTL is no larger than the CNAME TTL. */ - if (addrttls[i].ttl > cname_ttl) - addrttls[i].ttl = cname_ttl; - } - *naddrttls = n; + goto enomem; } - if (aliases) - aliases[naliases] = NULL; - if (host) + + i = 0; + next = ai.nodes; + while (next) { - /* Allocate memory to build the host entry. */ - hostent = ares_malloc(sizeof(struct hostent)); - if (hostent) + if (next->ai_family == AF_INET) { - hostent->h_addr_list = ares_malloc((naddrs + 1) * sizeof(char *)); - if (hostent->h_addr_list) + hostent->h_addr_list[i] = (char *)&addrs[i]; + memcpy(hostent->h_addr_list[i], + &(((struct sockaddr_in *)next->ai_addr)->sin_addr), + sizeof(struct in_addr)); + if (naddrttls && i < *naddrttls) { - /* Fill in the hostent and return successfully. */ - hostent->h_name = hostname; - hostent->h_aliases = aliases; - hostent->h_addrtype = AF_INET; - hostent->h_length = sizeof(struct in_addr); - for (i = 0; i < naddrs; i++) - hostent->h_addr_list[i] = (char *) &addrs[i]; - hostent->h_addr_list[naddrs] = NULL; - if (!naddrs && addrs) - ares_free(addrs); - *host = hostent; - return ARES_SUCCESS; + if (next->ai_ttl > cname_ttl) + addrttls[i].ttl = cname_ttl; + else + addrttls[i].ttl = next->ai_ttl; + + memcpy(&addrttls[i].ipaddr, + &(((struct sockaddr_in *)next->ai_addr)->sin_addr), + sizeof(struct in_addr)); } - ares_free(hostent); + ++i; } - status = ARES_ENOMEM; + next = next->ai_next; } - } - if (aliases) + if (i == 0) + { + ares_free(addrs); + } + } + + if (host) + { + *host = hostent; + } + else { - for (i = 0; i < naliases; i++) - ares_free(aliases[i]); - ares_free(aliases); + ares_free_hostent(hostent); } - ares_free(addrs); - ares_free(hostname); - return status; + + if (naddrttls) + { + *naddrttls = naddrs; + } + + ares__freeaddrinfo_cnames(ai.cnames); + ares__freeaddrinfo_nodes(ai.nodes); + return ARES_SUCCESS; + +enomem: + ares_free(aliases); + ares_free(hostent); + ares__freeaddrinfo_cnames(ai.cnames); + ares__freeaddrinfo_nodes(ai.nodes); + ares_free(question_hostname); + return ARES_ENOMEM; } diff --git a/deps/cares/src/ares_parse_aaaa_reply.c b/deps/cares/src/ares_parse_aaaa_reply.c index 5b38bb571e1d65..d39e138d4c3304 100644 --- a/deps/cares/src/ares_parse_aaaa_reply.c +++ b/deps/cares/src/ares_parse_aaaa_reply.c @@ -1,6 +1,7 @@ /* Copyright 1998 by the Massachusetts Institute of Technology. * Copyright 2005 Dominick Meglio + * Copyright (C) 2019 by Andrew Selivanov * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without @@ -52,213 +53,165 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen, struct hostent **host, struct ares_addr6ttl *addrttls, int *naddrttls) { - unsigned int qdcount, ancount; - int status, i, rr_type, rr_class, rr_len, rr_ttl, naddrs; - int cname_ttl = INT_MAX; /* the TTL imposed by the CNAME chain */ - int naliases; - long len; - const unsigned char *aptr; - char *hostname, *rr_name, *rr_data, **aliases; - struct ares_in6_addr *addrs; - struct hostent *hostent; - const int max_addr_ttls = (addrttls && naddrttls) ? *naddrttls : 0; - - /* Set *host to NULL for all failure cases. */ - if (host) - *host = NULL; - /* Same with *naddrttls. */ - if (naddrttls) - *naddrttls = 0; + struct ares_addrinfo ai; + struct ares_addrinfo_node *next; + struct ares_addrinfo_cname *next_cname; + char **aliases = NULL; + char *question_hostname = NULL; + struct hostent *hostent = NULL; + struct ares_in6_addr *addrs = NULL; + int naliases = 0, naddrs = 0, alias = 0, i; + int cname_ttl = INT_MAX; + int status; + + memset(&ai, 0, sizeof(ai)); + + status = ares__parse_into_addrinfo2(abuf, alen, &question_hostname, &ai); + if (status != ARES_SUCCESS) + { + ares_free(question_hostname); - /* Give up if abuf doesn't have room for a header. */ - if (alen < HFIXEDSZ) - return ARES_EBADRESP; + if (naddrttls) + { + *naddrttls = 0; + } - /* Fetch the question and answer count from the header. */ - qdcount = DNS_HEADER_QDCOUNT(abuf); - ancount = DNS_HEADER_ANCOUNT(abuf); - if (qdcount != 1) - return ARES_EBADRESP; + return status; + } - /* Expand the name from the question, and skip past the question. */ - aptr = abuf + HFIXEDSZ; - status = ares__expand_name_for_response(aptr, abuf, alen, &hostname, &len); - if (status != ARES_SUCCESS) - return status; - if (aptr + len + QFIXEDSZ > abuf + alen) + hostent = ares_malloc(sizeof(struct hostent)); + if (!hostent) { - ares_free(hostname); - return ARES_EBADRESP; + goto enomem; } - aptr += len + QFIXEDSZ; - /* Allocate addresses and aliases; ancount gives an upper bound for both. */ - if (host) + next = ai.nodes; + while (next) { - addrs = ares_malloc(ancount * sizeof(struct ares_in6_addr)); - if (!addrs) + if(next->ai_family == AF_INET6) { - ares_free(hostname); - return ARES_ENOMEM; - } - aliases = ares_malloc((ancount + 1) * sizeof(char *)); - if (!aliases) - { - ares_free(hostname); - ares_free(addrs); - return ARES_ENOMEM; + ++naddrs; } + next = next->ai_next; } - else + + next_cname = ai.cnames; + while (next_cname) { - addrs = NULL; - aliases = NULL; + if(next_cname->alias) + ++naliases; + next_cname = next_cname->next; } - naddrs = 0; - naliases = 0; - /* Examine each answer resource record (RR) in turn. */ - for (i = 0; i < (int)ancount; i++) + aliases = ares_malloc((naliases + 1) * sizeof(char *)); + if (!aliases) { - /* Decode the RR up to the data field. */ - status = ares__expand_name_for_response(aptr, abuf, alen, &rr_name, &len); - if (status != ARES_SUCCESS) - break; - aptr += len; - if (aptr + RRFIXEDSZ > abuf + alen) - { - ares_free(rr_name); - status = ARES_EBADRESP; - break; - } - rr_type = DNS_RR_TYPE(aptr); - rr_class = DNS_RR_CLASS(aptr); - rr_len = DNS_RR_LEN(aptr); - rr_ttl = DNS_RR_TTL(aptr); - aptr += RRFIXEDSZ; - if (aptr + rr_len > abuf + alen) - { - ares_free(rr_name); - status = ARES_EBADRESP; - break; - } + goto enomem; + } - if (rr_class == C_IN && rr_type == T_AAAA - && rr_len == sizeof(struct ares_in6_addr) - && strcasecmp(rr_name, hostname) == 0) + if (naliases) + { + next_cname = ai.cnames; + while (next_cname) { - if (addrs) - { - if (aptr + sizeof(struct ares_in6_addr) > abuf + alen) - { /* LCOV_EXCL_START: already checked above */ - ares_free(rr_name); - status = ARES_EBADRESP; - break; - } /* LCOV_EXCL_STOP */ - memcpy(&addrs[naddrs], aptr, sizeof(struct ares_in6_addr)); - } - if (naddrs < max_addr_ttls) - { - struct ares_addr6ttl * const at = &addrttls[naddrs]; - if (aptr + sizeof(struct ares_in6_addr) > abuf + alen) - { /* LCOV_EXCL_START: already checked above */ - ares_free(rr_name); - status = ARES_EBADRESP; - break; - } /* LCOV_EXCL_STOP */ - memcpy(&at->ip6addr, aptr, sizeof(struct ares_in6_addr)); - at->ttl = rr_ttl; - } - naddrs++; - status = ARES_SUCCESS; + if(next_cname->alias) + aliases[alias++] = strdup(next_cname->alias); + if(next_cname->ttl < cname_ttl) + cname_ttl = next_cname->ttl; + next_cname = next_cname->next; } + } - if (rr_class == C_IN && rr_type == T_CNAME) - { - /* Record the RR name as an alias. */ - if (aliases) - aliases[naliases] = rr_name; - else - ares_free(rr_name); - naliases++; + aliases[alias] = NULL; - /* Decode the RR data and replace the hostname with it. */ - status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data, - &len); - if (status != ARES_SUCCESS) - break; - ares_free(hostname); - hostname = rr_data; + hostent->h_addr_list = ares_malloc((naddrs + 1) * sizeof(char *)); + if (!hostent->h_addr_list) + { + goto enomem; + } - /* Take the min of the TTLs we see in the CNAME chain. */ - if (cname_ttl > rr_ttl) - cname_ttl = rr_ttl; - } - else - ares_free(rr_name); + for (i = 0; i < naddrs + 1; ++i) + { + hostent->h_addr_list[i] = NULL; + } - aptr += rr_len; - if (aptr > abuf + alen) - { /* LCOV_EXCL_START: already checked above */ - status = ARES_EBADRESP; - break; - } /* LCOV_EXCL_STOP */ + if (ai.cnames) + { + hostent->h_name = strdup(ai.cnames->name); + ares_free(question_hostname); } + else + { + hostent->h_name = question_hostname; + } + + hostent->h_aliases = aliases; + hostent->h_addrtype = AF_INET6; + hostent->h_length = sizeof(struct ares_in6_addr); - /* the check for naliases to be zero is to make sure CNAME responses - don't get caught here */ - if (status == ARES_SUCCESS && naddrs == 0 && naliases == 0) - status = ARES_ENODATA; - if (status == ARES_SUCCESS) + if (naddrs) { - /* We got our answer. */ - if (naddrttls) + addrs = ares_malloc(naddrs * sizeof(struct ares_in6_addr)); + if (!addrs) { - const int n = naddrs < max_addr_ttls ? naddrs : max_addr_ttls; - for (i = 0; i < n; i++) - { - /* Ensure that each A TTL is no larger than the CNAME TTL. */ - if (addrttls[i].ttl > cname_ttl) - addrttls[i].ttl = cname_ttl; - } - *naddrttls = n; + goto enomem; } - if (aliases) - aliases[naliases] = NULL; - if (host) + + i = 0; + next = ai.nodes; + while (next) { - /* Allocate memory to build the host entry. */ - hostent = ares_malloc(sizeof(struct hostent)); - if (hostent) + if(next->ai_family == AF_INET6) { - hostent->h_addr_list = ares_malloc((naddrs + 1) * sizeof(char *)); - if (hostent->h_addr_list) + hostent->h_addr_list[i] = (char*)&addrs[i]; + memcpy(hostent->h_addr_list[i], + &(((struct sockaddr_in6 *)next->ai_addr)->sin6_addr), + sizeof(struct ares_in6_addr)); + if (naddrttls && i < *naddrttls) { - /* Fill in the hostent and return successfully. */ - hostent->h_name = hostname; - hostent->h_aliases = aliases; - hostent->h_addrtype = AF_INET6; - hostent->h_length = sizeof(struct ares_in6_addr); - for (i = 0; i < naddrs; i++) - hostent->h_addr_list[i] = (char *) &addrs[i]; - hostent->h_addr_list[naddrs] = NULL; - if (!naddrs && addrs) - ares_free(addrs); - *host = hostent; - return ARES_SUCCESS; + if(next->ai_ttl > cname_ttl) + addrttls[i].ttl = cname_ttl; + else + addrttls[i].ttl = next->ai_ttl; + + memcpy(&addrttls[i].ip6addr, + &(((struct sockaddr_in6 *)next->ai_addr)->sin6_addr), + sizeof(struct ares_in6_addr)); } - ares_free(hostent); + ++i; } - status = ARES_ENOMEM; + next = next->ai_next; } + + if (i == 0) + { + ares_free(addrs); + } + } + + if (host) + { + *host = hostent; } - if (aliases) + else { - for (i = 0; i < naliases; i++) - ares_free(aliases[i]); - ares_free(aliases); + ares_free_hostent(hostent); } - ares_free(addrs); - ares_free(hostname); - return status; + + if (naddrttls) + { + *naddrttls = naddrs; + } + + ares__freeaddrinfo_cnames(ai.cnames); + ares__freeaddrinfo_nodes(ai.nodes); + return ARES_SUCCESS; + +enomem: + ares_free(aliases); + ares_free(hostent); + ares__freeaddrinfo_cnames(ai.cnames); + ares__freeaddrinfo_nodes(ai.nodes); + ares_free(question_hostname); + return ARES_ENOMEM; } diff --git a/deps/cares/src/ares_parse_soa_reply.c b/deps/cares/src/ares_parse_soa_reply.c index 35af0a75c00451..d72eeb94148e27 100644 --- a/deps/cares/src/ares_parse_soa_reply.c +++ b/deps/cares/src/ares_parse_soa_reply.c @@ -48,8 +48,8 @@ ares_parse_soa_reply(const unsigned char *abuf, int alen, long len; char *qname = NULL, *rr_name = NULL; struct ares_soa_reply *soa = NULL; - int qdcount, ancount; - int status; + int qdcount, ancount, qclass; + int status, i, rr_type, rr_class, rr_len; if (alen < HFIXEDSZ) return ARES_EBADRESP; @@ -57,8 +57,12 @@ ares_parse_soa_reply(const unsigned char *abuf, int alen, /* parse message header */ qdcount = DNS_HEADER_QDCOUNT(abuf); ancount = DNS_HEADER_ANCOUNT(abuf); - if (qdcount != 1 || ancount != 1) + + if (qdcount != 1) + return ARES_EBADRESP; + if (ancount == 0) return ARES_EBADRESP; + aptr = abuf + HFIXEDSZ; /* query name */ @@ -67,67 +71,112 @@ ares_parse_soa_reply(const unsigned char *abuf, int alen, goto failed_stat; aptr += len; + qclass = DNS_QUESTION_TYPE(aptr); + /* skip qtype & qclass */ if (aptr + QFIXEDSZ > abuf + alen) goto failed; aptr += QFIXEDSZ; - /* rr_name */ - status = ares__expand_name_for_response(aptr, abuf, alen, &rr_name, &len); - if (status != ARES_SUCCESS) - goto failed_stat; - aptr += len; - - /* skip rr_type, rr_class, rr_ttl, rr_rdlen */ - if (aptr + RRFIXEDSZ > abuf + alen) + /* qclass of SOA with multiple answers */ + if (qclass == T_SOA && ancount > 1) goto failed; - aptr += RRFIXEDSZ; - /* allocate result struct */ - soa = ares_malloc_data(ARES_DATATYPE_SOA_REPLY); - if (!soa) + /* examine all the records, break and return if found soa */ + for (i = 0; i < ancount; i++) + { + rr_name = NULL; + status = ares__expand_name_for_response (aptr, abuf, alen, &rr_name, &len); + if (status != ARES_SUCCESS) + { + ares_free(rr_name); + goto failed_stat; + } + + aptr += len; + if ( aptr + RRFIXEDSZ > abuf + alen ) { - status = ARES_ENOMEM; + ares_free(rr_name); + status = ARES_EBADRESP; goto failed_stat; } + rr_type = DNS_RR_TYPE( aptr ); + rr_class = DNS_RR_CLASS( aptr ); + rr_len = DNS_RR_LEN( aptr ); + aptr += RRFIXEDSZ; + if (aptr + rr_len > abuf + alen) + { + ares_free(rr_name); + status = ARES_EBADRESP; + goto failed_stat; + } + if ( rr_class == C_IN && rr_type == T_SOA ) + { + /* allocate result struct */ + soa = ares_malloc_data(ARES_DATATYPE_SOA_REPLY); + if (!soa) + { + ares_free(rr_name); + status = ARES_ENOMEM; + goto failed_stat; + } + + /* nsname */ + status = ares__expand_name_for_response(aptr, abuf, alen, &soa->nsname, + &len); + if (status != ARES_SUCCESS) + { + ares_free(rr_name); + goto failed_stat; + } + aptr += len; + + /* hostmaster */ + status = ares__expand_name_for_response(aptr, abuf, alen, + &soa->hostmaster, &len); + if (status != ARES_SUCCESS) + { + ares_free(rr_name); + goto failed_stat; + } + aptr += len; + + /* integer fields */ + if (aptr + 5 * 4 > abuf + alen) + { + ares_free(rr_name); + goto failed; + } + soa->serial = DNS__32BIT(aptr + 0 * 4); + soa->refresh = DNS__32BIT(aptr + 1 * 4); + soa->retry = DNS__32BIT(aptr + 2 * 4); + soa->expire = DNS__32BIT(aptr + 3 * 4); + soa->minttl = DNS__32BIT(aptr + 4 * 4); + + ares_free(qname); + ares_free(rr_name); + + *soa_out = soa; + + return ARES_SUCCESS; + } + aptr += rr_len; - /* nsname */ - status = ares__expand_name_for_response(aptr, abuf, alen, &soa->nsname, &len); - if (status != ARES_SUCCESS) - goto failed_stat; - aptr += len; - - /* hostmaster */ - status = ares__expand_name_for_response(aptr, abuf, alen, &soa->hostmaster, &len); - if (status != ARES_SUCCESS) - goto failed_stat; - aptr += len; - - /* integer fields */ - if (aptr + 5 * 4 > abuf + alen) - goto failed; - soa->serial = DNS__32BIT(aptr + 0 * 4); - soa->refresh = DNS__32BIT(aptr + 1 * 4); - soa->retry = DNS__32BIT(aptr + 2 * 4); - soa->expire = DNS__32BIT(aptr + 3 * 4); - soa->minttl = DNS__32BIT(aptr + 4 * 4); - - ares_free(qname); - ares_free(rr_name); - - *soa_out = soa; - - return ARES_SUCCESS; + ares_free(rr_name); + if (aptr > abuf + alen) + goto failed_stat; + } + /* no SOA record found */ + status = ARES_EBADRESP; + goto failed_stat; failed: status = ARES_EBADRESP; failed_stat: - ares_free_data(soa); + if (soa) + ares_free_data(soa); if (qname) ares_free(qname); - if (rr_name) - ares_free(rr_name); return status; } - diff --git a/deps/cares/src/ares_private.h b/deps/cares/src/ares_private.h index 1990f6902fc75e..2ee54e5ecd8e21 100644 --- a/deps/cares/src/ares_private.h +++ b/deps/cares/src/ares_private.h @@ -355,11 +355,51 @@ int ares__expand_name_for_response(const unsigned char *encoded, char **s, long *enclen); void ares__init_servers_state(ares_channel channel); void ares__destroy_servers_state(ares_channel channel); +int ares__parse_qtype_reply(const unsigned char* abuf, int alen, int* qtype); +int ares__single_domain(ares_channel channel, const char *name, char **s); +int ares__cat_domain(const char *name, const char *domain, char **s); +int ares__sortaddrinfo(ares_channel channel, struct ares_addrinfo_node *ai_node); +int ares__readaddrinfo(FILE *fp, const char *name, unsigned short port, + const struct ares_addrinfo_hints *hints, + struct ares_addrinfo *ai); + +struct ares_addrinfo *ares__malloc_addrinfo(void); + +struct ares_addrinfo_node *ares__malloc_addrinfo_node(void); +void ares__freeaddrinfo_nodes(struct ares_addrinfo_node *ai_node); + +struct ares_addrinfo_node *ares__append_addrinfo_node(struct ares_addrinfo_node **ai_node); +void ares__addrinfo_cat_nodes(struct ares_addrinfo_node **head, + struct ares_addrinfo_node *tail); + +struct ares_addrinfo_cname *ares__malloc_addrinfo_cname(void); +void ares__freeaddrinfo_cnames(struct ares_addrinfo_cname *ai_cname); + +struct ares_addrinfo_cname *ares__append_addrinfo_cname(struct ares_addrinfo_cname **ai_cname); + +void ares__addrinfo_cat_cnames(struct ares_addrinfo_cname **head, + struct ares_addrinfo_cname *tail); + +int ares__parse_into_addrinfo(const unsigned char *abuf, + int alen, + struct ares_addrinfo *ai); + +int ares__parse_into_addrinfo2(const unsigned char *abuf, + int alen, + char **question_hostname, + struct ares_addrinfo *ai); + #if 0 /* Not used */ long ares__tvdiff(struct timeval t1, struct timeval t2); #endif -void ares__socket_close(ares_channel, ares_socket_t); +ares_socket_t ares__open_socket(ares_channel channel, + int af, int type, int protocol); +void ares__close_socket(ares_channel, ares_socket_t); +int ares__connect_socket(ares_channel channel, + ares_socket_t sockfd, + const struct sockaddr *addr, + ares_socklen_t addrlen); #define ARES_SWAP_BYTE(a,b) \ { unsigned char swapByte = *(a); *(a) = *(b); *(b) = swapByte; } diff --git a/deps/cares/src/ares_process.c b/deps/cares/src/ares_process.c index df9f290bb133a6..c86d3f2026b20b 100644 --- a/deps/cares/src/ares_process.c +++ b/deps/cares/src/ares_process.c @@ -1039,30 +1039,6 @@ static int configure_socket(ares_socket_t s, int family, ares_channel channel) return 0; } -static ares_socket_t open_socket(ares_channel channel, int af, int type, int protocol) -{ - if (channel->sock_funcs != 0) - return channel->sock_funcs->asocket(af, - type, - protocol, - channel->sock_func_cb_data); - - return socket(af, type, protocol); -} - -static int connect_socket(ares_channel channel, ares_socket_t sockfd, - const struct sockaddr * addr, - ares_socklen_t addrlen) -{ - if (channel->sock_funcs != 0) - return channel->sock_funcs->aconnect(sockfd, - addr, - addrlen, - channel->sock_func_cb_data); - - return connect(sockfd, addr, addrlen); -} - static int open_tcp_socket(ares_channel channel, struct server_state *server) { ares_socket_t s; @@ -1107,14 +1083,14 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server) } /* Acquire a socket. */ - s = open_socket(channel, server->addr.family, SOCK_STREAM, 0); + s = ares__open_socket(channel, server->addr.family, SOCK_STREAM, 0); if (s == ARES_SOCKET_BAD) return -1; /* Configure it. */ if (configure_socket(s, server->addr.family, channel) < 0) { - ares__socket_close(channel, s); + ares__close_socket(channel, s); return -1; } @@ -1131,7 +1107,7 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server) setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (void *)&opt, sizeof(opt)) == -1) { - ares__socket_close(channel, s); + ares__close_socket(channel, s); return -1; } #endif @@ -1142,19 +1118,19 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server) channel->sock_config_cb_data); if (err < 0) { - ares__socket_close(channel, s); + ares__close_socket(channel, s); return err; } } /* Connect to the server. */ - if (connect_socket(channel, s, sa, salen) == -1) + if (ares__connect_socket(channel, s, sa, salen) == -1) { int err = SOCKERRNO; if (err != EINPROGRESS && err != EWOULDBLOCK) { - ares__socket_close(channel, s); + ares__close_socket(channel, s); return -1; } } @@ -1165,7 +1141,7 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server) channel->sock_create_cb_data); if (err < 0) { - ares__socket_close(channel, s); + ares__close_socket(channel, s); return err; } } @@ -1220,14 +1196,14 @@ static int open_udp_socket(ares_channel channel, struct server_state *server) } /* Acquire a socket. */ - s = open_socket(channel, server->addr.family, SOCK_DGRAM, 0); + s = ares__open_socket(channel, server->addr.family, SOCK_DGRAM, 0); if (s == ARES_SOCKET_BAD) return -1; /* Set the socket non-blocking. */ if (configure_socket(s, server->addr.family, channel) < 0) { - ares__socket_close(channel, s); + ares__close_socket(channel, s); return -1; } @@ -1237,19 +1213,19 @@ static int open_udp_socket(ares_channel channel, struct server_state *server) channel->sock_config_cb_data); if (err < 0) { - ares__socket_close(channel, s); + ares__close_socket(channel, s); return err; } } /* Connect to the server. */ - if (connect_socket(channel, s, sa, salen) == -1) + if (ares__connect_socket(channel, s, sa, salen) == -1) { int err = SOCKERRNO; if (err != EINPROGRESS && err != EWOULDBLOCK) { - ares__socket_close(channel, s); + ares__close_socket(channel, s); return -1; } } @@ -1260,7 +1236,7 @@ static int open_udp_socket(ares_channel channel, struct server_state *server) channel->sock_create_cb_data); if (err < 0) { - ares__socket_close(channel, s); + ares__close_socket(channel, s); return err; } } @@ -1464,7 +1440,33 @@ void ares__free_query(struct query *query) ares_free(query); } -void ares__socket_close(ares_channel channel, ares_socket_t s) +ares_socket_t ares__open_socket(ares_channel channel, + int af, int type, int protocol) +{ + if (channel->sock_funcs) + return channel->sock_funcs->asocket(af, + type, + protocol, + channel->sock_func_cb_data); + else + return socket(af, type, protocol); +} + +int ares__connect_socket(ares_channel channel, + ares_socket_t sockfd, + const struct sockaddr *addr, + ares_socklen_t addrlen) +{ + if (channel->sock_funcs) + return channel->sock_funcs->aconnect(sockfd, + addr, + addrlen, + channel->sock_func_cb_data); + else + return connect(sockfd, addr, addrlen); +} + +void ares__close_socket(ares_channel channel, ares_socket_t s) { if (channel->sock_funcs) channel->sock_funcs->aclose(s, channel->sock_func_cb_data); diff --git a/deps/cares/src/ares_search.c b/deps/cares/src/ares_search.c index 001c3482a7dd5d..c4b0424f5bab75 100644 --- a/deps/cares/src/ares_search.c +++ b/deps/cares/src/ares_search.c @@ -43,8 +43,6 @@ static void search_callback(void *arg, int status, int timeouts, unsigned char *abuf, int alen); static void end_squery(struct search_query *squery, int status, unsigned char *abuf, int alen); -static int cat_domain(const char *name, const char *domain, char **s); -STATIC_TESTABLE int single_domain(ares_channel channel, const char *name, char **s); void ares_search(ares_channel channel, const char *name, int dnsclass, int type, ares_callback callback, void *arg) @@ -64,7 +62,7 @@ void ares_search(ares_channel channel, const char *name, int dnsclass, /* If name only yields one domain to search, then we don't have * to keep extra state, so just do an ares_query(). */ - status = single_domain(channel, name, &s); + status = ares__single_domain(channel, name, &s); if (status != ARES_SUCCESS) { callback(arg, status, 0, NULL, 0); @@ -126,7 +124,7 @@ void ares_search(ares_channel channel, const char *name, int dnsclass, /* Try the name as-is last; start with the first search domain. */ squery->next_domain = 1; squery->trying_as_is = 0; - status = cat_domain(name, channel->domains[0], &s); + status = ares__cat_domain(name, channel->domains[0], &s); if (status == ARES_SUCCESS) { ares_query(channel, s, dnsclass, type, search_callback, squery); @@ -174,7 +172,7 @@ static void search_callback(void *arg, int status, int timeouts, if (squery->next_domain < channel->ndomains) { /* Try the next domain. */ - status = cat_domain(squery->name, + status = ares__cat_domain(squery->name, channel->domains[squery->next_domain], &s); if (status != ARES_SUCCESS) end_squery(squery, status, NULL, 0); @@ -213,7 +211,7 @@ static void end_squery(struct search_query *squery, int status, } /* Concatenate two domains. */ -static int cat_domain(const char *name, const char *domain, char **s) +int ares__cat_domain(const char *name, const char *domain, char **s) { size_t nlen = strlen(name); size_t dlen = strlen(domain); @@ -232,7 +230,7 @@ static int cat_domain(const char *name, const char *domain, char **s) * the string we should query, in an allocated buffer. If not, set *s * to NULL. */ -STATIC_TESTABLE int single_domain(ares_channel channel, const char *name, char **s) +int ares__single_domain(ares_channel channel, const char *name, char **s) { size_t len = strlen(name); const char *hostaliases; diff --git a/deps/openssl/README.md b/deps/openssl/README.md index 758a1fb7459ad6..ad4fe193aa22ed 100644 --- a/deps/openssl/README.md +++ b/deps/openssl/README.md @@ -76,4 +76,4 @@ Please refer [config/opensslconf_asm.h](config/opensslconf_asm.h) for details. ### Upgrading OpenSSL -Please refer [config/README.md](config/README.md). +Please refer to [maintaining-openssl](../../doc/guides/maintaining-openssl.md). diff --git a/deps/openssl/config/archs/BSD-x86/asm/configdata.pm b/deps/openssl/config/archs/BSD-x86/asm/configdata.pm index 765ef97df004ce..e2c6b91ad4322a 100644 --- a/deps/openssl/config/archs/BSD-x86/asm/configdata.pm +++ b/deps/openssl/config/archs/BSD-x86/asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "BSD-x86" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "BSD-x86", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7413,6 +7413,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/BSD-x86/asm/crypto/buildinf.h b/deps/openssl/config/archs/BSD-x86/asm/crypto/buildinf.h index cc24d30a9b9b75..8906bbcd1667c1 100644 --- a/deps/openssl/config/archs/BSD-x86/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/BSD-x86/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: BSD-x86" -#define DATE "built on: Wed Mar 18 21:04:48 2020 UTC" +#define DATE "built on: Tue Apr 21 13:28:30 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/BSD-x86/asm_avx2/configdata.pm b/deps/openssl/config/archs/BSD-x86/asm_avx2/configdata.pm index 08151c2b5bbcad..cde9ab3f9cad77 100644 --- a/deps/openssl/config/archs/BSD-x86/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/BSD-x86/asm_avx2/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "BSD-x86" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "BSD-x86", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7413,6 +7413,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/BSD-x86/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/BSD-x86/asm_avx2/crypto/buildinf.h index 96c786974c2af5..9ae71b203b5c9c 100644 --- a/deps/openssl/config/archs/BSD-x86/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/BSD-x86/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: BSD-x86" -#define DATE "built on: Wed Mar 18 21:04:52 2020 UTC" +#define DATE "built on: Tue Apr 21 13:28:32 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/BSD-x86/no-asm/configdata.pm b/deps/openssl/config/archs/BSD-x86/no-asm/configdata.pm index c8fd824b7fa837..5569ba1f1ef9c6 100644 --- a/deps/openssl/config/archs/BSD-x86/no-asm/configdata.pm +++ b/deps/openssl/config/archs/BSD-x86/no-asm/configdata.pm @@ -61,7 +61,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "BSD-x86" ], perlenv => { "AR" => undef, @@ -110,8 +110,8 @@ our %config = ( sourcedir => ".", target => "BSD-x86", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7363,6 +7363,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/BSD-x86/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/BSD-x86/no-asm/crypto/buildinf.h index 4d7a6c77c175cd..0617bee2e0ff83 100644 --- a/deps/openssl/config/archs/BSD-x86/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/BSD-x86/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: BSD-x86" -#define DATE "built on: Wed Mar 18 21:04:56 2020 UTC" +#define DATE "built on: Tue Apr 21 13:28:34 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/BSD-x86_64/asm/configdata.pm b/deps/openssl/config/archs/BSD-x86_64/asm/configdata.pm index 49248aba5ea4b1..bae66a2b0d362c 100644 --- a/deps/openssl/config/archs/BSD-x86_64/asm/configdata.pm +++ b/deps/openssl/config/archs/BSD-x86_64/asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "BSD-x86_64" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "BSD-x86_64", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7502,6 +7502,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/BSD-x86_64/asm/crypto/buildinf.h b/deps/openssl/config/archs/BSD-x86_64/asm/crypto/buildinf.h index b52f1881d3036e..4fa13f787cd0d3 100644 --- a/deps/openssl/config/archs/BSD-x86_64/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/BSD-x86_64/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: BSD-x86_64" -#define DATE "built on: Wed Mar 18 21:04:59 2020 UTC" +#define DATE "built on: Tue Apr 21 13:28:35 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/BSD-x86_64/asm_avx2/configdata.pm b/deps/openssl/config/archs/BSD-x86_64/asm_avx2/configdata.pm index 30164e88aa0d0c..f7a112c24ff188 100644 --- a/deps/openssl/config/archs/BSD-x86_64/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/BSD-x86_64/asm_avx2/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "BSD-x86_64" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "BSD-x86_64", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7502,6 +7502,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/BSD-x86_64/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/BSD-x86_64/asm_avx2/crypto/buildinf.h index 6cb84c034f6626..e3d1b2ac9e4093 100644 --- a/deps/openssl/config/archs/BSD-x86_64/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/BSD-x86_64/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: BSD-x86_64" -#define DATE "built on: Wed Mar 18 21:05:08 2020 UTC" +#define DATE "built on: Tue Apr 21 13:28:40 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/BSD-x86_64/no-asm/configdata.pm b/deps/openssl/config/archs/BSD-x86_64/no-asm/configdata.pm index 23a0ff1905e00e..71aac6079d34a6 100644 --- a/deps/openssl/config/archs/BSD-x86_64/no-asm/configdata.pm +++ b/deps/openssl/config/archs/BSD-x86_64/no-asm/configdata.pm @@ -61,7 +61,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "BSD-x86_64" ], perlenv => { "AR" => undef, @@ -110,8 +110,8 @@ our %config = ( sourcedir => ".", target => "BSD-x86_64", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7384,6 +7384,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/BSD-x86_64/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/BSD-x86_64/no-asm/crypto/buildinf.h index 06c423068a45b5..21c7eb8a7ea97d 100644 --- a/deps/openssl/config/archs/BSD-x86_64/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/BSD-x86_64/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: BSD-x86_64" -#define DATE "built on: Wed Mar 18 21:05:17 2020 UTC" +#define DATE "built on: Tue Apr 21 13:28:45 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/VC-WIN32/asm/configdata.pm b/deps/openssl/config/archs/VC-WIN32/asm/configdata.pm index 1354452500558b..2971043ad9180a 100644 --- a/deps/openssl/config/archs/VC-WIN32/asm/configdata.pm +++ b/deps/openssl/config/archs/VC-WIN32/asm/configdata.pm @@ -66,7 +66,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "VC-WIN32" ], perlenv => { "AR" => undef, @@ -115,8 +115,8 @@ our %config = ( sourcedir => ".", target => "VC-WIN32", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -132,7 +132,7 @@ our %target = ( LDFLAGS => "/nologo /debug", MT => "mt", MTFLAGS => "-nologo", - RANLIB => "CODE(0x5567c34c1cd8)", + RANLIB => "CODE(0x555663f9f6e8)", RC => "rc", _conf_fname_int => [ "Configurations/00-base-templates.conf", "Configurations/00-base-templates.conf", "Configurations/10-main.conf", "Configurations/10-main.conf", "Configurations/00-base-templates.conf", "Configurations/10-main.conf", "Configurations/shared-info.pl" ], aes_asm_src => "aes_core.c aes_cbc.c vpaes-x86.s aesni-x86.s", @@ -7460,6 +7460,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/VC-WIN32/asm/crypto/buildinf.h b/deps/openssl/config/archs/VC-WIN32/asm/crypto/buildinf.h index a0e422963d254b..ce39e2899efdb8 100644 --- a/deps/openssl/config/archs/VC-WIN32/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/VC-WIN32/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: " -#define DATE "built on: Wed Mar 18 21:11:00 2020 UTC" +#define DATE "built on: Tue Apr 21 13:30:38 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/VC-WIN32/asm_avx2/configdata.pm b/deps/openssl/config/archs/VC-WIN32/asm_avx2/configdata.pm index 14713dbff02eeb..7cb55073eb56a0 100644 --- a/deps/openssl/config/archs/VC-WIN32/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/VC-WIN32/asm_avx2/configdata.pm @@ -66,7 +66,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "VC-WIN32" ], perlenv => { "AR" => undef, @@ -115,8 +115,8 @@ our %config = ( sourcedir => ".", target => "VC-WIN32", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -132,7 +132,7 @@ our %target = ( LDFLAGS => "/nologo /debug", MT => "mt", MTFLAGS => "-nologo", - RANLIB => "CODE(0x56041fcde128)", + RANLIB => "CODE(0x557555fd4548)", RC => "rc", _conf_fname_int => [ "Configurations/00-base-templates.conf", "Configurations/00-base-templates.conf", "Configurations/10-main.conf", "Configurations/10-main.conf", "Configurations/00-base-templates.conf", "Configurations/10-main.conf", "Configurations/shared-info.pl" ], aes_asm_src => "aes_core.c aes_cbc.c vpaes-x86.s aesni-x86.s", @@ -7460,6 +7460,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/VC-WIN32/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/VC-WIN32/asm_avx2/crypto/buildinf.h index 77f65c3b5445e2..91ea9162d31cac 100644 --- a/deps/openssl/config/archs/VC-WIN32/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/VC-WIN32/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: " -#define DATE "built on: Wed Mar 18 21:11:06 2020 UTC" +#define DATE "built on: Tue Apr 21 13:30:40 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/VC-WIN32/no-asm/configdata.pm b/deps/openssl/config/archs/VC-WIN32/no-asm/configdata.pm index e2e28d75311dd3..88ac450625e93a 100644 --- a/deps/openssl/config/archs/VC-WIN32/no-asm/configdata.pm +++ b/deps/openssl/config/archs/VC-WIN32/no-asm/configdata.pm @@ -65,7 +65,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "VC-WIN32" ], perlenv => { "AR" => undef, @@ -114,8 +114,8 @@ our %config = ( sourcedir => ".", target => "VC-WIN32", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -131,7 +131,7 @@ our %target = ( LDFLAGS => "/nologo /debug", MT => "mt", MTFLAGS => "-nologo", - RANLIB => "CODE(0x55e705f67598)", + RANLIB => "CODE(0x55b7cbf3ba68)", RC => "rc", _conf_fname_int => [ "Configurations/00-base-templates.conf", "Configurations/00-base-templates.conf", "Configurations/10-main.conf", "Configurations/10-main.conf", "Configurations/10-main.conf", "Configurations/shared-info.pl" ], aes_asm_src => "aes_core.c aes_cbc.c", @@ -7410,6 +7410,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/VC-WIN32/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/VC-WIN32/no-asm/crypto/buildinf.h index 71f5a9d1a106e9..13dfc8011a07c9 100644 --- a/deps/openssl/config/archs/VC-WIN32/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/VC-WIN32/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: " -#define DATE "built on: Wed Mar 18 21:11:12 2020 UTC" +#define DATE "built on: Tue Apr 21 13:30:42 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/VC-WIN64-ARM/no-asm/configdata.pm b/deps/openssl/config/archs/VC-WIN64-ARM/no-asm/configdata.pm index 949959ff1074ad..dbeb526a5afa98 100644 --- a/deps/openssl/config/archs/VC-WIN64-ARM/no-asm/configdata.pm +++ b/deps/openssl/config/archs/VC-WIN64-ARM/no-asm/configdata.pm @@ -64,7 +64,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "VC-WIN64-ARM" ], perlenv => { "AR" => undef, @@ -113,8 +113,8 @@ our %config = ( sourcedir => ".", target => "VC-WIN64-ARM", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -128,7 +128,7 @@ our %target = ( LDFLAGS => "/nologo /debug", MT => "mt", MTFLAGS => "-nologo", - RANLIB => "CODE(0x55748984a208)", + RANLIB => "CODE(0x561bd9d97ee8)", RC => "rc", _conf_fname_int => [ "Configurations/00-base-templates.conf", "Configurations/00-base-templates.conf", "Configurations/10-main.conf", "Configurations/10-main.conf", "Configurations/50-win-onecore.conf", "Configurations/shared-info.pl" ], aes_asm_src => "aes_core.c aes_cbc.c", @@ -7404,6 +7404,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/VC-WIN64-ARM/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/VC-WIN64-ARM/no-asm/crypto/buildinf.h index 95181bd2e5e4f9..c10c09b484eeea 100644 --- a/deps/openssl/config/archs/VC-WIN64-ARM/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/VC-WIN64-ARM/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: VC-WIN64-ARM" -#define DATE "built on: Wed Mar 18 21:11:15 2020 UTC" +#define DATE "built on: Tue Apr 21 13:30:43 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/VC-WIN64A/asm/configdata.pm b/deps/openssl/config/archs/VC-WIN64A/asm/configdata.pm index 84a7982debc195..88152c050df8df 100644 --- a/deps/openssl/config/archs/VC-WIN64A/asm/configdata.pm +++ b/deps/openssl/config/archs/VC-WIN64A/asm/configdata.pm @@ -67,7 +67,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "VC-WIN64A" ], perlenv => { "AR" => undef, @@ -116,8 +116,8 @@ our %config = ( sourcedir => ".", target => "VC-WIN64A", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -133,7 +133,7 @@ our %target = ( LDFLAGS => "/nologo /debug", MT => "mt", MTFLAGS => "-nologo", - RANLIB => "CODE(0x556e5b07ddf8)", + RANLIB => "CODE(0x5647ca1193c8)", RC => "rc", _conf_fname_int => [ "Configurations/00-base-templates.conf", "Configurations/00-base-templates.conf", "Configurations/10-main.conf", "Configurations/10-main.conf", "Configurations/10-main.conf", "Configurations/00-base-templates.conf", "Configurations/10-main.conf", "Configurations/shared-info.pl" ], aes_asm_src => "aes_core.c aes_cbc.c vpaes-x86_64.s aesni-x86_64.s aesni-sha1-x86_64.s aesni-sha256-x86_64.s aesni-mb-x86_64.s", @@ -7517,6 +7517,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/VC-WIN64A/asm/crypto/buildinf.h b/deps/openssl/config/archs/VC-WIN64A/asm/crypto/buildinf.h index eee9e84f1825ed..af137fbaf4057b 100644 --- a/deps/openssl/config/archs/VC-WIN64A/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/VC-WIN64A/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: " -#define DATE "built on: Wed Mar 18 21:10:25 2020 UTC" +#define DATE "built on: Tue Apr 21 13:30:25 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/VC-WIN64A/asm_avx2/configdata.pm b/deps/openssl/config/archs/VC-WIN64A/asm_avx2/configdata.pm index a95fc8411c77fe..0685aba7d91e61 100644 --- a/deps/openssl/config/archs/VC-WIN64A/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/VC-WIN64A/asm_avx2/configdata.pm @@ -67,7 +67,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "VC-WIN64A" ], perlenv => { "AR" => undef, @@ -116,8 +116,8 @@ our %config = ( sourcedir => ".", target => "VC-WIN64A", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -133,7 +133,7 @@ our %target = ( LDFLAGS => "/nologo /debug", MT => "mt", MTFLAGS => "-nologo", - RANLIB => "CODE(0x55c8e9449798)", + RANLIB => "CODE(0x55fd09262448)", RC => "rc", _conf_fname_int => [ "Configurations/00-base-templates.conf", "Configurations/00-base-templates.conf", "Configurations/10-main.conf", "Configurations/10-main.conf", "Configurations/10-main.conf", "Configurations/00-base-templates.conf", "Configurations/10-main.conf", "Configurations/shared-info.pl" ], aes_asm_src => "aes_core.c aes_cbc.c vpaes-x86_64.s aesni-x86_64.s aesni-sha1-x86_64.s aesni-sha256-x86_64.s aesni-mb-x86_64.s", @@ -7517,6 +7517,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/VC-WIN64A/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/VC-WIN64A/asm_avx2/crypto/buildinf.h index 59f6aefb5a0ecf..bf0778567f4261 100644 --- a/deps/openssl/config/archs/VC-WIN64A/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/VC-WIN64A/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: " -#define DATE "built on: Wed Mar 18 21:10:39 2020 UTC" +#define DATE "built on: Tue Apr 21 13:30:31 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/VC-WIN64A/no-asm/configdata.pm b/deps/openssl/config/archs/VC-WIN64A/no-asm/configdata.pm index 0091b95296b8f9..7163514b940850 100644 --- a/deps/openssl/config/archs/VC-WIN64A/no-asm/configdata.pm +++ b/deps/openssl/config/archs/VC-WIN64A/no-asm/configdata.pm @@ -66,7 +66,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "VC-WIN64A" ], perlenv => { "AR" => undef, @@ -115,8 +115,8 @@ our %config = ( sourcedir => ".", target => "VC-WIN64A", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -132,7 +132,7 @@ our %target = ( LDFLAGS => "/nologo /debug", MT => "mt", MTFLAGS => "-nologo", - RANLIB => "CODE(0x557c73be49d8)", + RANLIB => "CODE(0x55d89d717d18)", RC => "rc", _conf_fname_int => [ "Configurations/00-base-templates.conf", "Configurations/00-base-templates.conf", "Configurations/10-main.conf", "Configurations/10-main.conf", "Configurations/10-main.conf", "Configurations/10-main.conf", "Configurations/shared-info.pl" ], aes_asm_src => "aes_core.c aes_cbc.c", @@ -7412,6 +7412,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/VC-WIN64A/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/VC-WIN64A/no-asm/crypto/buildinf.h index 00baa0f8636963..f7d39297a9d538 100644 --- a/deps/openssl/config/archs/VC-WIN64A/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/VC-WIN64A/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: " -#define DATE "built on: Wed Mar 18 21:10:56 2020 UTC" +#define DATE "built on: Tue Apr 21 13:30:37 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/aix-gcc/asm/configdata.pm b/deps/openssl/config/archs/aix-gcc/asm/configdata.pm index 7dc4c54dd0fe4c..5e4cd5c0aab624 100644 --- a/deps/openssl/config/archs/aix-gcc/asm/configdata.pm +++ b/deps/openssl/config/archs/aix-gcc/asm/configdata.pm @@ -61,7 +61,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "aix-gcc" ], perlenv => { "AR" => undef, @@ -110,8 +110,8 @@ our %config = ( sourcedir => ".", target => "aix-gcc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7434,6 +7434,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/aix-gcc/asm/crypto/buildinf.h b/deps/openssl/config/archs/aix-gcc/asm/crypto/buildinf.h index 39bc5ba3c4b295..667b3ca4f1c370 100644 --- a/deps/openssl/config/archs/aix-gcc/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/aix-gcc/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: aix-gcc" -#define DATE "built on: Wed Mar 18 21:04:29 2020 UTC" +#define DATE "built on: Tue Apr 21 13:28:20 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/aix-gcc/asm_avx2/configdata.pm b/deps/openssl/config/archs/aix-gcc/asm_avx2/configdata.pm index 2308e3e39b6966..2478703e1f6320 100644 --- a/deps/openssl/config/archs/aix-gcc/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/aix-gcc/asm_avx2/configdata.pm @@ -61,7 +61,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "aix-gcc" ], perlenv => { "AR" => undef, @@ -110,8 +110,8 @@ our %config = ( sourcedir => ".", target => "aix-gcc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7434,6 +7434,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/aix-gcc/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/aix-gcc/asm_avx2/crypto/buildinf.h index eadeff3e4417da..58ce87ebdd9a8f 100644 --- a/deps/openssl/config/archs/aix-gcc/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/aix-gcc/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: aix-gcc" -#define DATE "built on: Wed Mar 18 21:04:33 2020 UTC" +#define DATE "built on: Tue Apr 21 13:28:22 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/aix-gcc/no-asm/configdata.pm b/deps/openssl/config/archs/aix-gcc/no-asm/configdata.pm index 401c0fa7dc230a..fa2542f6f7f844 100644 --- a/deps/openssl/config/archs/aix-gcc/no-asm/configdata.pm +++ b/deps/openssl/config/archs/aix-gcc/no-asm/configdata.pm @@ -61,7 +61,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "aix-gcc" ], perlenv => { "AR" => undef, @@ -110,8 +110,8 @@ our %config = ( sourcedir => ".", target => "aix-gcc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7380,6 +7380,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/aix-gcc/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/aix-gcc/no-asm/crypto/buildinf.h index 5a597aebe4a3eb..52e8166985ad74 100644 --- a/deps/openssl/config/archs/aix-gcc/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/aix-gcc/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: aix-gcc" -#define DATE "built on: Wed Mar 18 21:04:36 2020 UTC" +#define DATE "built on: Tue Apr 21 13:28:23 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/aix64-gcc/asm/configdata.pm b/deps/openssl/config/archs/aix64-gcc/asm/configdata.pm index 11958ce68b9186..cd41ec80d1ffcf 100644 --- a/deps/openssl/config/archs/aix64-gcc/asm/configdata.pm +++ b/deps/openssl/config/archs/aix64-gcc/asm/configdata.pm @@ -61,7 +61,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "aix64-gcc" ], perlenv => { "AR" => undef, @@ -110,8 +110,8 @@ our %config = ( sourcedir => ".", target => "aix64-gcc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7452,6 +7452,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/aix64-gcc/asm/crypto/buildinf.h b/deps/openssl/config/archs/aix64-gcc/asm/crypto/buildinf.h index a994547d9f6878..643ee46d44519c 100644 --- a/deps/openssl/config/archs/aix64-gcc/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/aix64-gcc/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: aix64-gcc" -#define DATE "built on: Wed Mar 18 21:04:38 2020 UTC" +#define DATE "built on: Tue Apr 21 13:28:25 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/aix64-gcc/asm_avx2/configdata.pm b/deps/openssl/config/archs/aix64-gcc/asm_avx2/configdata.pm index ce4e06798c4b0e..da22ab7abdb422 100644 --- a/deps/openssl/config/archs/aix64-gcc/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/aix64-gcc/asm_avx2/configdata.pm @@ -61,7 +61,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "aix64-gcc" ], perlenv => { "AR" => undef, @@ -110,8 +110,8 @@ our %config = ( sourcedir => ".", target => "aix64-gcc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7452,6 +7452,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/aix64-gcc/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/aix64-gcc/asm_avx2/crypto/buildinf.h index c53f28b67b46ab..8a8695172bdaaf 100644 --- a/deps/openssl/config/archs/aix64-gcc/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/aix64-gcc/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: aix64-gcc" -#define DATE "built on: Wed Mar 18 21:04:42 2020 UTC" +#define DATE "built on: Tue Apr 21 13:28:27 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/aix64-gcc/no-asm/configdata.pm b/deps/openssl/config/archs/aix64-gcc/no-asm/configdata.pm index e5164e6d11a314..936675844138cf 100644 --- a/deps/openssl/config/archs/aix64-gcc/no-asm/configdata.pm +++ b/deps/openssl/config/archs/aix64-gcc/no-asm/configdata.pm @@ -61,7 +61,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "aix64-gcc" ], perlenv => { "AR" => undef, @@ -110,8 +110,8 @@ our %config = ( sourcedir => ".", target => "aix64-gcc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7380,6 +7380,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/aix64-gcc/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/aix64-gcc/no-asm/crypto/buildinf.h index eca0e52e0aa6ff..bf9bd49b324c41 100644 --- a/deps/openssl/config/archs/aix64-gcc/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/aix64-gcc/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: aix64-gcc" -#define DATE "built on: Wed Mar 18 21:04:46 2020 UTC" +#define DATE "built on: Tue Apr 21 13:28:28 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/darwin-i386-cc/asm/configdata.pm b/deps/openssl/config/archs/darwin-i386-cc/asm/configdata.pm index e7607607e41f66..a1fc1ab0e21672 100644 --- a/deps/openssl/config/archs/darwin-i386-cc/asm/configdata.pm +++ b/deps/openssl/config/archs/darwin-i386-cc/asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "darwin-i386-cc" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "darwin-i386-cc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7408,6 +7408,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/darwin-i386-cc/asm/crypto/buildinf.h b/deps/openssl/config/archs/darwin-i386-cc/asm/crypto/buildinf.h index c577b784d27053..0e279fa03d0d04 100644 --- a/deps/openssl/config/archs/darwin-i386-cc/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/darwin-i386-cc/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: darwin-i386-cc" -#define DATE "built on: Wed Mar 18 21:05:40 2020 UTC" +#define DATE "built on: Tue Apr 21 13:28:57 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/darwin-i386-cc/asm_avx2/configdata.pm b/deps/openssl/config/archs/darwin-i386-cc/asm_avx2/configdata.pm index a35bca92f08a0d..49da9df5ba50ac 100644 --- a/deps/openssl/config/archs/darwin-i386-cc/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/darwin-i386-cc/asm_avx2/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "darwin-i386-cc" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "darwin-i386-cc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7408,6 +7408,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/darwin-i386-cc/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/darwin-i386-cc/asm_avx2/crypto/buildinf.h index a925b543a9fac5..48b19f2a62aa0c 100644 --- a/deps/openssl/config/archs/darwin-i386-cc/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/darwin-i386-cc/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: darwin-i386-cc" -#define DATE "built on: Wed Mar 18 21:05:45 2020 UTC" +#define DATE "built on: Tue Apr 21 13:28:59 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/darwin-i386-cc/no-asm/configdata.pm b/deps/openssl/config/archs/darwin-i386-cc/no-asm/configdata.pm index 191fabfac75fcb..2c457c5cffc0c5 100644 --- a/deps/openssl/config/archs/darwin-i386-cc/no-asm/configdata.pm +++ b/deps/openssl/config/archs/darwin-i386-cc/no-asm/configdata.pm @@ -61,7 +61,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "darwin-i386-cc" ], perlenv => { "AR" => undef, @@ -110,8 +110,8 @@ our %config = ( sourcedir => ".", target => "darwin-i386-cc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7358,6 +7358,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/darwin-i386-cc/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/darwin-i386-cc/no-asm/crypto/buildinf.h index 17da37fa077fa2..e3fca2397cc7f9 100644 --- a/deps/openssl/config/archs/darwin-i386-cc/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/darwin-i386-cc/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: darwin-i386-cc" -#define DATE "built on: Wed Mar 18 21:05:49 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:02 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/darwin64-x86_64-cc/asm/configdata.pm b/deps/openssl/config/archs/darwin64-x86_64-cc/asm/configdata.pm index b4e4f412154218..0323e8891f9049 100644 --- a/deps/openssl/config/archs/darwin64-x86_64-cc/asm/configdata.pm +++ b/deps/openssl/config/archs/darwin64-x86_64-cc/asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "darwin64-x86_64-cc" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "darwin64-x86_64-cc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7476,6 +7476,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/darwin64-x86_64-cc/asm/crypto/buildinf.h b/deps/openssl/config/archs/darwin64-x86_64-cc/asm/crypto/buildinf.h index ab5367073d6352..ef775454948310 100644 --- a/deps/openssl/config/archs/darwin64-x86_64-cc/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/darwin64-x86_64-cc/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: darwin64-x86_64-cc" -#define DATE "built on: Wed Mar 18 21:05:19 2020 UTC" +#define DATE "built on: Tue Apr 21 13:28:47 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/darwin64-x86_64-cc/asm_avx2/configdata.pm b/deps/openssl/config/archs/darwin64-x86_64-cc/asm_avx2/configdata.pm index e07de8a9b50ad8..ef6bab0fa6569f 100644 --- a/deps/openssl/config/archs/darwin64-x86_64-cc/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/darwin64-x86_64-cc/asm_avx2/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "darwin64-x86_64-cc" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "darwin64-x86_64-cc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7476,6 +7476,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/darwin64-x86_64-cc/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/darwin64-x86_64-cc/asm_avx2/crypto/buildinf.h index 7847154abb8994..e51b17fc4afb6f 100644 --- a/deps/openssl/config/archs/darwin64-x86_64-cc/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/darwin64-x86_64-cc/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: darwin64-x86_64-cc" -#define DATE "built on: Wed Mar 18 21:05:29 2020 UTC" +#define DATE "built on: Tue Apr 21 13:28:51 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/darwin64-x86_64-cc/no-asm/configdata.pm b/deps/openssl/config/archs/darwin64-x86_64-cc/no-asm/configdata.pm index 12d99f475e421e..da6f564d23da0c 100644 --- a/deps/openssl/config/archs/darwin64-x86_64-cc/no-asm/configdata.pm +++ b/deps/openssl/config/archs/darwin64-x86_64-cc/no-asm/configdata.pm @@ -61,7 +61,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "darwin64-x86_64-cc" ], perlenv => { "AR" => undef, @@ -110,8 +110,8 @@ our %config = ( sourcedir => ".", target => "darwin64-x86_64-cc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7358,6 +7358,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/darwin64-x86_64-cc/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/darwin64-x86_64-cc/no-asm/crypto/buildinf.h index 43f321a7ac65d0..8219a109e06583 100644 --- a/deps/openssl/config/archs/darwin64-x86_64-cc/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/darwin64-x86_64-cc/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: darwin64-x86_64-cc" -#define DATE "built on: Wed Mar 18 21:05:38 2020 UTC" +#define DATE "built on: Tue Apr 21 13:28:56 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-aarch64/asm/configdata.pm b/deps/openssl/config/archs/linux-aarch64/asm/configdata.pm index 1e08556a96b2bc..b5e9d18a4cbea7 100644 --- a/deps/openssl/config/archs/linux-aarch64/asm/configdata.pm +++ b/deps/openssl/config/archs/linux-aarch64/asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux-aarch64" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux-aarch64", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7417,6 +7417,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-aarch64/asm/crypto/buildinf.h b/deps/openssl/config/archs/linux-aarch64/asm/crypto/buildinf.h index ed35c1e5ca7997..6479d9cf084b05 100644 --- a/deps/openssl/config/archs/linux-aarch64/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-aarch64/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-aarch64" -#define DATE "built on: Wed Mar 18 21:05:53 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:03 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-aarch64/asm_avx2/configdata.pm b/deps/openssl/config/archs/linux-aarch64/asm_avx2/configdata.pm index 591ab6875b226b..4c89d33ad1b784 100644 --- a/deps/openssl/config/archs/linux-aarch64/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/linux-aarch64/asm_avx2/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux-aarch64" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux-aarch64", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7417,6 +7417,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-aarch64/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/linux-aarch64/asm_avx2/crypto/buildinf.h index 672273eb20e94a..b8787fef6970fb 100644 --- a/deps/openssl/config/archs/linux-aarch64/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-aarch64/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-aarch64" -#define DATE "built on: Wed Mar 18 21:05:58 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:05 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-aarch64/no-asm/configdata.pm b/deps/openssl/config/archs/linux-aarch64/no-asm/configdata.pm index a36f3889d4751f..5125170f571c6b 100644 --- a/deps/openssl/config/archs/linux-aarch64/no-asm/configdata.pm +++ b/deps/openssl/config/archs/linux-aarch64/no-asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "linux-aarch64" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux-aarch64", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7383,6 +7383,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-aarch64/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/linux-aarch64/no-asm/crypto/buildinf.h index 4f6ff84c2810f2..c592d53e84e5da 100644 --- a/deps/openssl/config/archs/linux-aarch64/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-aarch64/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-aarch64" -#define DATE "built on: Wed Mar 18 21:06:04 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:07 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-armv4/asm/configdata.pm b/deps/openssl/config/archs/linux-armv4/asm/configdata.pm index 42746324ce6230..38f4e239e52990 100644 --- a/deps/openssl/config/archs/linux-armv4/asm/configdata.pm +++ b/deps/openssl/config/archs/linux-armv4/asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux-armv4" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux-armv4", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7414,6 +7414,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-armv4/asm/crypto/buildinf.h b/deps/openssl/config/archs/linux-armv4/asm/crypto/buildinf.h index 69027a7fb80eb8..f899ea4fcc39ef 100644 --- a/deps/openssl/config/archs/linux-armv4/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-armv4/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-armv4" -#define DATE "built on: Wed Mar 18 21:06:07 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:08 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-armv4/asm_avx2/configdata.pm b/deps/openssl/config/archs/linux-armv4/asm_avx2/configdata.pm index ad3c832efe9312..d1a4696ff0b844 100644 --- a/deps/openssl/config/archs/linux-armv4/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/linux-armv4/asm_avx2/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux-armv4" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux-armv4", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7414,6 +7414,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-armv4/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/linux-armv4/asm_avx2/crypto/buildinf.h index d1b23647596725..2a707b15293df3 100644 --- a/deps/openssl/config/archs/linux-armv4/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-armv4/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-armv4" -#define DATE "built on: Wed Mar 18 21:06:14 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:10 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-armv4/no-asm/configdata.pm b/deps/openssl/config/archs/linux-armv4/no-asm/configdata.pm index c1fb4d9a7e6d75..1d593fbfe38a73 100644 --- a/deps/openssl/config/archs/linux-armv4/no-asm/configdata.pm +++ b/deps/openssl/config/archs/linux-armv4/no-asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "linux-armv4" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux-armv4", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7383,6 +7383,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-armv4/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/linux-armv4/no-asm/crypto/buildinf.h index b5e738fe28df89..c40dc3bcc88fb8 100644 --- a/deps/openssl/config/archs/linux-armv4/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-armv4/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-armv4" -#define DATE "built on: Wed Mar 18 21:06:19 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:12 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-elf/asm/configdata.pm b/deps/openssl/config/archs/linux-elf/asm/configdata.pm index 8a4cc46d2bc848..a80e71e4f4a71c 100644 --- a/deps/openssl/config/archs/linux-elf/asm/configdata.pm +++ b/deps/openssl/config/archs/linux-elf/asm/configdata.pm @@ -63,7 +63,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux-elf" ], perlenv => { "AR" => undef, @@ -112,8 +112,8 @@ our %config = ( sourcedir => ".", target => "linux-elf", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7433,6 +7433,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-elf/asm/crypto/buildinf.h b/deps/openssl/config/archs/linux-elf/asm/crypto/buildinf.h index bd6dc58174b08f..c471b16f716f74 100644 --- a/deps/openssl/config/archs/linux-elf/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-elf/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-elf" -#define DATE "built on: Wed Mar 18 21:06:23 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:13 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-elf/asm_avx2/configdata.pm b/deps/openssl/config/archs/linux-elf/asm_avx2/configdata.pm index 214775155c00f7..e7c10a1cef796d 100644 --- a/deps/openssl/config/archs/linux-elf/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/linux-elf/asm_avx2/configdata.pm @@ -63,7 +63,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux-elf" ], perlenv => { "AR" => undef, @@ -112,8 +112,8 @@ our %config = ( sourcedir => ".", target => "linux-elf", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7433,6 +7433,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-elf/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/linux-elf/asm_avx2/crypto/buildinf.h index c7df3525a0d884..57ad9b8f411c74 100644 --- a/deps/openssl/config/archs/linux-elf/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-elf/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-elf" -#define DATE "built on: Wed Mar 18 21:06:30 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:15 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-elf/no-asm/configdata.pm b/deps/openssl/config/archs/linux-elf/no-asm/configdata.pm index cd93118c7746ca..428ba35f579ecb 100644 --- a/deps/openssl/config/archs/linux-elf/no-asm/configdata.pm +++ b/deps/openssl/config/archs/linux-elf/no-asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "linux-elf" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux-elf", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7382,6 +7382,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-elf/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/linux-elf/no-asm/crypto/buildinf.h index 7dbb94e08737c2..23a4508342ad5e 100644 --- a/deps/openssl/config/archs/linux-elf/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-elf/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-elf" -#define DATE "built on: Wed Mar 18 21:06:37 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:17 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-ppc/asm/configdata.pm b/deps/openssl/config/archs/linux-ppc/asm/configdata.pm index 1afb56190cf72d..4c1bcb3f95609f 100644 --- a/deps/openssl/config/archs/linux-ppc/asm/configdata.pm +++ b/deps/openssl/config/archs/linux-ppc/asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux-ppc" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux-ppc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7437,6 +7437,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-ppc/asm/crypto/buildinf.h b/deps/openssl/config/archs/linux-ppc/asm/crypto/buildinf.h index 1072f9d31176ca..cb44914dd64005 100644 --- a/deps/openssl/config/archs/linux-ppc/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-ppc/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-ppc" -#define DATE "built on: Wed Mar 18 21:07:41 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:40 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-ppc/asm_avx2/configdata.pm b/deps/openssl/config/archs/linux-ppc/asm_avx2/configdata.pm index ae2648d219adb7..61e0463f5e62c0 100644 --- a/deps/openssl/config/archs/linux-ppc/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/linux-ppc/asm_avx2/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux-ppc" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux-ppc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7437,6 +7437,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-ppc/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/linux-ppc/asm_avx2/crypto/buildinf.h index 559beb8cb0d6b1..b06edc3d7d44fd 100644 --- a/deps/openssl/config/archs/linux-ppc/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-ppc/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-ppc" -#define DATE "built on: Wed Mar 18 21:07:49 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:42 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-ppc/no-asm/configdata.pm b/deps/openssl/config/archs/linux-ppc/no-asm/configdata.pm index 30a59660025863..2a10b1bba9ec48 100644 --- a/deps/openssl/config/archs/linux-ppc/no-asm/configdata.pm +++ b/deps/openssl/config/archs/linux-ppc/no-asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "linux-ppc" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux-ppc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7383,6 +7383,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-ppc/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/linux-ppc/no-asm/crypto/buildinf.h index 58a71fa717b68f..002eddcba2880d 100644 --- a/deps/openssl/config/archs/linux-ppc/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-ppc/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-ppc" -#define DATE "built on: Wed Mar 18 21:07:59 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:44 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-ppc64/asm/configdata.pm b/deps/openssl/config/archs/linux-ppc64/asm/configdata.pm index 1f45e9693072bd..52394a0961e477 100644 --- a/deps/openssl/config/archs/linux-ppc64/asm/configdata.pm +++ b/deps/openssl/config/archs/linux-ppc64/asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux-ppc64" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux-ppc64", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7456,6 +7456,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-ppc64/asm/crypto/buildinf.h b/deps/openssl/config/archs/linux-ppc64/asm/crypto/buildinf.h index f367bbd3426450..3d95753bf02679 100644 --- a/deps/openssl/config/archs/linux-ppc64/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-ppc64/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-ppc64" -#define DATE "built on: Wed Mar 18 21:08:05 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:45 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-ppc64/asm_avx2/configdata.pm b/deps/openssl/config/archs/linux-ppc64/asm_avx2/configdata.pm index d1cc20b09ef1a5..f1b96bbe74d80b 100644 --- a/deps/openssl/config/archs/linux-ppc64/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/linux-ppc64/asm_avx2/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux-ppc64" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux-ppc64", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7456,6 +7456,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-ppc64/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/linux-ppc64/asm_avx2/crypto/buildinf.h index dc7442135ad376..1ce61a43114354 100644 --- a/deps/openssl/config/archs/linux-ppc64/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-ppc64/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-ppc64" -#define DATE "built on: Wed Mar 18 21:08:13 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:47 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-ppc64/no-asm/configdata.pm b/deps/openssl/config/archs/linux-ppc64/no-asm/configdata.pm index 4b7653af00bde5..de71bb6e5a9173 100644 --- a/deps/openssl/config/archs/linux-ppc64/no-asm/configdata.pm +++ b/deps/openssl/config/archs/linux-ppc64/no-asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "linux-ppc64" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux-ppc64", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7384,6 +7384,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-ppc64/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/linux-ppc64/no-asm/crypto/buildinf.h index ca91089788aedd..a07f6603043d98 100644 --- a/deps/openssl/config/archs/linux-ppc64/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-ppc64/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-ppc64" -#define DATE "built on: Wed Mar 18 21:08:25 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:49 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-ppc64le/asm/configdata.pm b/deps/openssl/config/archs/linux-ppc64le/asm/configdata.pm index be34b5bfb58064..2709dbc5bc3047 100644 --- a/deps/openssl/config/archs/linux-ppc64le/asm/configdata.pm +++ b/deps/openssl/config/archs/linux-ppc64le/asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux-ppc64le" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux-ppc64le", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7455,6 +7455,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-ppc64le/asm/crypto/buildinf.h b/deps/openssl/config/archs/linux-ppc64le/asm/crypto/buildinf.h index 1dbf68d3564b60..13abf9fd8ad900 100644 --- a/deps/openssl/config/archs/linux-ppc64le/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-ppc64le/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-ppc64le" -#define DATE "built on: Wed Mar 18 21:08:32 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:50 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-ppc64le/asm_avx2/configdata.pm b/deps/openssl/config/archs/linux-ppc64le/asm_avx2/configdata.pm index f007db765e180d..32c6f0b14a398c 100644 --- a/deps/openssl/config/archs/linux-ppc64le/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/linux-ppc64le/asm_avx2/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux-ppc64le" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux-ppc64le", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7455,6 +7455,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-ppc64le/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/linux-ppc64le/asm_avx2/crypto/buildinf.h index 2bb616361144e4..06be7372834085 100644 --- a/deps/openssl/config/archs/linux-ppc64le/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-ppc64le/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-ppc64le" -#define DATE "built on: Wed Mar 18 21:08:43 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:52 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-ppc64le/no-asm/configdata.pm b/deps/openssl/config/archs/linux-ppc64le/no-asm/configdata.pm index b63dcfe765aa5e..f79ec0ca0aec3b 100644 --- a/deps/openssl/config/archs/linux-ppc64le/no-asm/configdata.pm +++ b/deps/openssl/config/archs/linux-ppc64le/no-asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "linux-ppc64le" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux-ppc64le", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7383,6 +7383,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-ppc64le/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/linux-ppc64le/no-asm/crypto/buildinf.h index 98bbd243c19c9a..4363c13947b980 100644 --- a/deps/openssl/config/archs/linux-ppc64le/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-ppc64le/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-ppc64le" -#define DATE "built on: Wed Mar 18 21:08:54 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:54 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-x32/asm/configdata.pm b/deps/openssl/config/archs/linux-x32/asm/configdata.pm index 87cae322cfb182..b24448028a0014 100644 --- a/deps/openssl/config/archs/linux-x32/asm/configdata.pm +++ b/deps/openssl/config/archs/linux-x32/asm/configdata.pm @@ -63,7 +63,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux-x32" ], perlenv => { "AR" => undef, @@ -112,8 +112,8 @@ our %config = ( sourcedir => ".", target => "linux-x32", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7502,6 +7502,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-x32/asm/crypto/buildinf.h b/deps/openssl/config/archs/linux-x32/asm/crypto/buildinf.h index 2dbe97005cf8ad..c234a16b3b4e29 100644 --- a/deps/openssl/config/archs/linux-x32/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-x32/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-x32" -#define DATE "built on: Wed Mar 18 21:06:40 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:19 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-x32/asm_avx2/configdata.pm b/deps/openssl/config/archs/linux-x32/asm_avx2/configdata.pm index 73d49d831b99b4..18de59ca09c2d6 100644 --- a/deps/openssl/config/archs/linux-x32/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/linux-x32/asm_avx2/configdata.pm @@ -63,7 +63,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux-x32" ], perlenv => { "AR" => undef, @@ -112,8 +112,8 @@ our %config = ( sourcedir => ".", target => "linux-x32", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7502,6 +7502,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-x32/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/linux-x32/asm_avx2/crypto/buildinf.h index 5b88a094e60a2d..b89bda8653dc28 100644 --- a/deps/openssl/config/archs/linux-x32/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-x32/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-x32" -#define DATE "built on: Wed Mar 18 21:06:52 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:24 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-x32/no-asm/configdata.pm b/deps/openssl/config/archs/linux-x32/no-asm/configdata.pm index 7943ec12dfc802..4b5a7704d93b2a 100644 --- a/deps/openssl/config/archs/linux-x32/no-asm/configdata.pm +++ b/deps/openssl/config/archs/linux-x32/no-asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "linux-x32" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux-x32", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7384,6 +7384,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-x32/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/linux-x32/no-asm/crypto/buildinf.h index fb611fa2c2e720..f4c2dce6f1602c 100644 --- a/deps/openssl/config/archs/linux-x32/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-x32/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-x32" -#define DATE "built on: Wed Mar 18 21:07:03 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:28 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-x86_64/asm/configdata.pm b/deps/openssl/config/archs/linux-x86_64/asm/configdata.pm index 6962df4c99b6be..d24a1adde8a741 100644 --- a/deps/openssl/config/archs/linux-x86_64/asm/configdata.pm +++ b/deps/openssl/config/archs/linux-x86_64/asm/configdata.pm @@ -63,7 +63,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux-x86_64" ], perlenv => { "AR" => undef, @@ -112,8 +112,8 @@ our %config = ( sourcedir => ".", target => "linux-x86_64", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7502,6 +7502,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-x86_64/asm/crypto/buildinf.h b/deps/openssl/config/archs/linux-x86_64/asm/crypto/buildinf.h index 83d6c611ca4206..919af33bcabd6a 100644 --- a/deps/openssl/config/archs/linux-x86_64/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-x86_64/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-x86_64" -#define DATE "built on: Wed Mar 18 21:07:06 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:29 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-x86_64/asm_avx2/configdata.pm b/deps/openssl/config/archs/linux-x86_64/asm_avx2/configdata.pm index 4c4db242e4e88e..9ba4396da82590 100644 --- a/deps/openssl/config/archs/linux-x86_64/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/linux-x86_64/asm_avx2/configdata.pm @@ -63,7 +63,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux-x86_64" ], perlenv => { "AR" => undef, @@ -112,8 +112,8 @@ our %config = ( sourcedir => ".", target => "linux-x86_64", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7502,6 +7502,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-x86_64/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/linux-x86_64/asm_avx2/crypto/buildinf.h index 62ab79d821c028..ae4d93579aeb67 100644 --- a/deps/openssl/config/archs/linux-x86_64/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-x86_64/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-x86_64" -#define DATE "built on: Wed Mar 18 21:07:18 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:34 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux-x86_64/no-asm/configdata.pm b/deps/openssl/config/archs/linux-x86_64/no-asm/configdata.pm index e9a7a8ce9f17d7..d82eea4612f3bd 100644 --- a/deps/openssl/config/archs/linux-x86_64/no-asm/configdata.pm +++ b/deps/openssl/config/archs/linux-x86_64/no-asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "linux-x86_64" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux-x86_64", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7384,6 +7384,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux-x86_64/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/linux-x86_64/no-asm/crypto/buildinf.h index 208c6e0e31cced..adf411b4c51c86 100644 --- a/deps/openssl/config/archs/linux-x86_64/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux-x86_64/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux-x86_64" -#define DATE "built on: Wed Mar 18 21:07:36 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:39 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux32-s390x/asm/configdata.pm b/deps/openssl/config/archs/linux32-s390x/asm/configdata.pm index 3efb27cfc66c16..9e49cb981e695e 100644 --- a/deps/openssl/config/archs/linux32-s390x/asm/configdata.pm +++ b/deps/openssl/config/archs/linux32-s390x/asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux32-s390x" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux32-s390x", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7392,6 +7392,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux32-s390x/asm/crypto/buildinf.h b/deps/openssl/config/archs/linux32-s390x/asm/crypto/buildinf.h index 9d017d177882b0..ec1ee2efd11e27 100644 --- a/deps/openssl/config/archs/linux32-s390x/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux32-s390x/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux32-s390x" -#define DATE "built on: Wed Mar 18 21:08:58 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:56 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux32-s390x/asm_avx2/configdata.pm b/deps/openssl/config/archs/linux32-s390x/asm_avx2/configdata.pm index d8384829df628d..1b8bc39854d564 100644 --- a/deps/openssl/config/archs/linux32-s390x/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/linux32-s390x/asm_avx2/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux32-s390x" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux32-s390x", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7392,6 +7392,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux32-s390x/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/linux32-s390x/asm_avx2/crypto/buildinf.h index e7fee2eb3e3165..4beac3e2af8a7c 100644 --- a/deps/openssl/config/archs/linux32-s390x/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux32-s390x/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux32-s390x" -#define DATE "built on: Wed Mar 18 21:09:02 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:57 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux32-s390x/no-asm/configdata.pm b/deps/openssl/config/archs/linux32-s390x/no-asm/configdata.pm index ba39c8551f82c0..22b2fb67657d9f 100644 --- a/deps/openssl/config/archs/linux32-s390x/no-asm/configdata.pm +++ b/deps/openssl/config/archs/linux32-s390x/no-asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "linux32-s390x" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux32-s390x", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7378,6 +7378,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux32-s390x/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/linux32-s390x/no-asm/crypto/buildinf.h index 2fbe63990cc612..80c3ebb97e0598 100644 --- a/deps/openssl/config/archs/linux32-s390x/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux32-s390x/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux32-s390x" -#define DATE "built on: Wed Mar 18 21:09:09 2020 UTC" +#define DATE "built on: Tue Apr 21 13:29:58 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux64-mips64/asm/configdata.pm b/deps/openssl/config/archs/linux64-mips64/asm/configdata.pm index 1302d730d02d59..6ea79c233bd4ec 100644 --- a/deps/openssl/config/archs/linux64-mips64/asm/configdata.pm +++ b/deps/openssl/config/archs/linux64-mips64/asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux64-mips64" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux64-mips64", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7388,6 +7388,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux64-mips64/asm/crypto/buildinf.h b/deps/openssl/config/archs/linux64-mips64/asm/crypto/buildinf.h index 5f969bc3a4bfc0..4aaf2f715b2786 100644 --- a/deps/openssl/config/archs/linux64-mips64/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux64-mips64/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux64-mips64" -#define DATE "built on: Wed Mar 18 21:09:33 2020 UTC" +#define DATE "built on: Tue Apr 21 13:30:04 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux64-mips64/asm_avx2/configdata.pm b/deps/openssl/config/archs/linux64-mips64/asm_avx2/configdata.pm index f53a77e0a05edb..335a17f197b2d7 100644 --- a/deps/openssl/config/archs/linux64-mips64/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/linux64-mips64/asm_avx2/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux64-mips64" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux64-mips64", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7388,6 +7388,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux64-mips64/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/linux64-mips64/asm_avx2/crypto/buildinf.h index 87d8f13efafd96..b1ca7beae8b4f7 100644 --- a/deps/openssl/config/archs/linux64-mips64/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux64-mips64/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux64-mips64" -#define DATE "built on: Wed Mar 18 21:09:39 2020 UTC" +#define DATE "built on: Tue Apr 21 13:30:05 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux64-mips64/no-asm/configdata.pm b/deps/openssl/config/archs/linux64-mips64/no-asm/configdata.pm index 62586346a8d849..2850108eecf20e 100644 --- a/deps/openssl/config/archs/linux64-mips64/no-asm/configdata.pm +++ b/deps/openssl/config/archs/linux64-mips64/no-asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "linux64-mips64" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux64-mips64", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7384,6 +7384,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux64-mips64/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/linux64-mips64/no-asm/crypto/buildinf.h index f58b88ffe332db..a3592bdfa133af 100644 --- a/deps/openssl/config/archs/linux64-mips64/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux64-mips64/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux64-mips64" -#define DATE "built on: Wed Mar 18 21:09:46 2020 UTC" +#define DATE "built on: Tue Apr 21 13:30:07 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux64-s390x/asm/configdata.pm b/deps/openssl/config/archs/linux64-s390x/asm/configdata.pm index b73e953e4d3b32..262b20c7c7b23e 100644 --- a/deps/openssl/config/archs/linux64-s390x/asm/configdata.pm +++ b/deps/openssl/config/archs/linux64-s390x/asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux64-s390x" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux64-s390x", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7405,6 +7405,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux64-s390x/asm/crypto/buildinf.h b/deps/openssl/config/archs/linux64-s390x/asm/crypto/buildinf.h index 48a866e7b2457e..0a88ba38dac443 100644 --- a/deps/openssl/config/archs/linux64-s390x/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux64-s390x/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux64-s390x" -#define DATE "built on: Wed Mar 18 21:09:15 2020 UTC" +#define DATE "built on: Tue Apr 21 13:30:00 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux64-s390x/asm_avx2/configdata.pm b/deps/openssl/config/archs/linux64-s390x/asm_avx2/configdata.pm index 4419066fcab00e..0e2c4a34fb94d8 100644 --- a/deps/openssl/config/archs/linux64-s390x/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/linux64-s390x/asm_avx2/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "linux64-s390x" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux64-s390x", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7405,6 +7405,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux64-s390x/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/linux64-s390x/asm_avx2/crypto/buildinf.h index 667449c83d298d..e6c0d9746137dc 100644 --- a/deps/openssl/config/archs/linux64-s390x/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux64-s390x/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux64-s390x" -#define DATE "built on: Wed Mar 18 21:09:21 2020 UTC" +#define DATE "built on: Tue Apr 21 13:30:01 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/linux64-s390x/no-asm/configdata.pm b/deps/openssl/config/archs/linux64-s390x/no-asm/configdata.pm index 37fd739d54ceaa..6cf06f127a9f5a 100644 --- a/deps/openssl/config/archs/linux64-s390x/no-asm/configdata.pm +++ b/deps/openssl/config/archs/linux64-s390x/no-asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "linux64-s390x" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "linux64-s390x", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7384,6 +7384,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/linux64-s390x/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/linux64-s390x/no-asm/crypto/buildinf.h index 984838d0e04349..36544bc5da2990 100644 --- a/deps/openssl/config/archs/linux64-s390x/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/linux64-s390x/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: linux64-s390x" -#define DATE "built on: Wed Mar 18 21:09:26 2020 UTC" +#define DATE "built on: Tue Apr 21 13:30:03 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/solaris-x86-gcc/asm/configdata.pm b/deps/openssl/config/archs/solaris-x86-gcc/asm/configdata.pm index 6374bc5069f5eb..3ac47d94a63097 100644 --- a/deps/openssl/config/archs/solaris-x86-gcc/asm/configdata.pm +++ b/deps/openssl/config/archs/solaris-x86-gcc/asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "solaris-x86-gcc" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "solaris-x86-gcc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7429,6 +7429,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/solaris-x86-gcc/asm/crypto/buildinf.h b/deps/openssl/config/archs/solaris-x86-gcc/asm/crypto/buildinf.h index 201a165d1cd70f..36ae42ae77bf05 100644 --- a/deps/openssl/config/archs/solaris-x86-gcc/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/solaris-x86-gcc/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: solaris-x86-gcc" -#define DATE "built on: Wed Mar 18 21:09:49 2020 UTC" +#define DATE "built on: Tue Apr 21 13:30:08 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/solaris-x86-gcc/asm_avx2/configdata.pm b/deps/openssl/config/archs/solaris-x86-gcc/asm_avx2/configdata.pm index 2cca99ea71113f..791a0c1e993f8e 100644 --- a/deps/openssl/config/archs/solaris-x86-gcc/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/solaris-x86-gcc/asm_avx2/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "solaris-x86-gcc" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "solaris-x86-gcc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7429,6 +7429,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/solaris-x86-gcc/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/solaris-x86-gcc/asm_avx2/crypto/buildinf.h index 98a20770933a66..028f93b66991c7 100644 --- a/deps/openssl/config/archs/solaris-x86-gcc/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/solaris-x86-gcc/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: solaris-x86-gcc" -#define DATE "built on: Wed Mar 18 21:09:53 2020 UTC" +#define DATE "built on: Tue Apr 21 13:30:10 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/solaris-x86-gcc/no-asm/configdata.pm b/deps/openssl/config/archs/solaris-x86-gcc/no-asm/configdata.pm index 2bdfa61a081508..23c76c2a4055b0 100644 --- a/deps/openssl/config/archs/solaris-x86-gcc/no-asm/configdata.pm +++ b/deps/openssl/config/archs/solaris-x86-gcc/no-asm/configdata.pm @@ -61,7 +61,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "solaris-x86-gcc" ], perlenv => { "AR" => undef, @@ -110,8 +110,8 @@ our %config = ( sourcedir => ".", target => "solaris-x86-gcc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7378,6 +7378,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/solaris-x86-gcc/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/solaris-x86-gcc/no-asm/crypto/buildinf.h index 0418a6f8bac290..bb1034543d523b 100644 --- a/deps/openssl/config/archs/solaris-x86-gcc/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/solaris-x86-gcc/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: solaris-x86-gcc" -#define DATE "built on: Wed Mar 18 21:09:57 2020 UTC" +#define DATE "built on: Tue Apr 21 13:30:13 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/solaris64-x86_64-gcc/asm/configdata.pm b/deps/openssl/config/archs/solaris64-x86_64-gcc/asm/configdata.pm index 499dac23213ea1..48d568b9d8a45e 100644 --- a/deps/openssl/config/archs/solaris64-x86_64-gcc/asm/configdata.pm +++ b/deps/openssl/config/archs/solaris64-x86_64-gcc/asm/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "solaris64-x86_64-gcc" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "solaris64-x86_64-gcc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7498,6 +7498,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/solaris64-x86_64-gcc/asm/crypto/buildinf.h b/deps/openssl/config/archs/solaris64-x86_64-gcc/asm/crypto/buildinf.h index a8141d6c785966..a0b629e46d0cfd 100644 --- a/deps/openssl/config/archs/solaris64-x86_64-gcc/asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/solaris64-x86_64-gcc/asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: solaris64-x86_64-gcc" -#define DATE "built on: Wed Mar 18 21:10:00 2020 UTC" +#define DATE "built on: Tue Apr 21 13:30:14 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/solaris64-x86_64-gcc/asm_avx2/configdata.pm b/deps/openssl/config/archs/solaris64-x86_64-gcc/asm_avx2/configdata.pm index 6fb7716b83a4ac..4f155ddf1fc637 100644 --- a/deps/openssl/config/archs/solaris64-x86_64-gcc/asm_avx2/configdata.pm +++ b/deps/openssl/config/archs/solaris64-x86_64-gcc/asm_avx2/configdata.pm @@ -62,7 +62,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "solaris64-x86_64-gcc" ], perlenv => { "AR" => undef, @@ -111,8 +111,8 @@ our %config = ( sourcedir => ".", target => "solaris64-x86_64-gcc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7498,6 +7498,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/solaris64-x86_64-gcc/asm_avx2/crypto/buildinf.h b/deps/openssl/config/archs/solaris64-x86_64-gcc/asm_avx2/crypto/buildinf.h index 2e41bb9b2ce786..d4965b40b0e150 100644 --- a/deps/openssl/config/archs/solaris64-x86_64-gcc/asm_avx2/crypto/buildinf.h +++ b/deps/openssl/config/archs/solaris64-x86_64-gcc/asm_avx2/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: solaris64-x86_64-gcc" -#define DATE "built on: Wed Mar 18 21:10:11 2020 UTC" +#define DATE "built on: Tue Apr 21 13:30:19 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/config/archs/solaris64-x86_64-gcc/no-asm/configdata.pm b/deps/openssl/config/archs/solaris64-x86_64-gcc/no-asm/configdata.pm index d398c0a8c31c26..bb91b718764c0f 100644 --- a/deps/openssl/config/archs/solaris64-x86_64-gcc/no-asm/configdata.pm +++ b/deps/openssl/config/archs/solaris64-x86_64-gcc/no-asm/configdata.pm @@ -61,7 +61,7 @@ our %config = ( options => "enable-ssl-trace no-afalgeng no-asan no-asm no-buildtest-c++ no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-devcryptoeng no-dynamic-engine no-ec_nistp_64_gcc_128 no-egd no-external-tests no-fuzz-afl no-fuzz-libfuzzer no-heartbeats no-md2 no-msan no-rc5 no-sctp no-shared no-ssl3 no-ssl3-method no-ubsan no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic", perl_archname => "x86_64-linux-gnu-thread-multi", perl_cmd => "/usr/bin/perl", - perl_version => "5.28.1", + perl_version => "5.26.1", perlargv => [ "no-comp", "no-shared", "no-afalgeng", "enable-ssl-trace", "no-asm", "solaris64-x86_64-gcc" ], perlenv => { "AR" => undef, @@ -110,8 +110,8 @@ our %config = ( sourcedir => ".", target => "solaris64-x86_64-gcc", tdirs => [ "ossl_shim" ], - version => "1.1.1e", - version_num => "0x1010105fL", + version => "1.1.1g", + version_num => "0x1010107fL", ); our %target = ( @@ -7380,6 +7380,7 @@ our %unified_info = ( [ ".", "include", + "crypto/modes", ], "crypto/rand/drbg_lib.o" => [ diff --git a/deps/openssl/config/archs/solaris64-x86_64-gcc/no-asm/crypto/buildinf.h b/deps/openssl/config/archs/solaris64-x86_64-gcc/no-asm/crypto/buildinf.h index c97a2322371166..b88ad42bb166a2 100644 --- a/deps/openssl/config/archs/solaris64-x86_64-gcc/no-asm/crypto/buildinf.h +++ b/deps/openssl/config/archs/solaris64-x86_64-gcc/no-asm/crypto/buildinf.h @@ -11,7 +11,7 @@ */ #define PLATFORM "platform: solaris64-x86_64-gcc" -#define DATE "built on: Wed Mar 18 21:10:22 2020 UTC" +#define DATE "built on: Tue Apr 21 13:30:24 2020 UTC" /* * Generate compiler_flags as an array of individual characters. This is a diff --git a/deps/openssl/openssl-cl_no_asm.gypi b/deps/openssl/openssl-cl_no_asm.gypi index bb9e55de91e3f2..2e12816aa3ebfd 100644 --- a/deps/openssl/openssl-cl_no_asm.gypi +++ b/deps/openssl/openssl-cl_no_asm.gypi @@ -12,9 +12,9 @@ 'includes': ['config/archs/linux-ppc64/no-asm/openssl-cl.gypi'], }, 'target_arch=="s390x" and OS=="linux"', { 'includes': ['config/archs/linux64-s390x/no-asm/openssl-cl.gypi'], - }, 'target_arch=="arm" and OS=="linux"', { + }, 'target_arch=="arm" and OS in ("linux", "android")', { 'includes': ['config/archs/linux-armv4/no-asm/openssl-cl.gypi'], - }, 'target_arch=="arm64" and OS=="linux"', { + }, 'target_arch=="arm64" and OS in ("linux", "android")', { 'includes': ['config/archs/linux-aarch64/no-asm/openssl-cl.gypi'], }, 'target_arch=="arm64" and OS=="win"', { 'includes': ['config/archs/VC-WIN64-ARM/no-asm/openssl-cl.gypi'], diff --git a/deps/openssl/openssl/CHANGES b/deps/openssl/openssl/CHANGES index 0250e4ef026bf7..057405b0bff935 100644 --- a/deps/openssl/openssl/CHANGES +++ b/deps/openssl/openssl/CHANGES @@ -7,6 +7,45 @@ https://github.com/openssl/openssl/commits/ and pick the appropriate release branch. + Changes between 1.1.1f and 1.1.1g [21 Apr 2020] + + *) Fixed segmentation fault in SSL_check_chain() + Server or client applications that call the SSL_check_chain() function + during or after a TLS 1.3 handshake may crash due to a NULL pointer + dereference as a result of incorrect handling of the + "signature_algorithms_cert" TLS extension. The crash occurs if an invalid + or unrecognised signature algorithm is received from the peer. This could + be exploited by a malicious peer in a Denial of Service attack. + (CVE-2020-1967) + [Benjamin Kaduk] + + *) Added AES consttime code for no-asm configurations + an optional constant time support for AES was added + when building openssl for no-asm. + Enable with: ./config no-asm -DOPENSSL_AES_CONST_TIME + Disable with: ./config no-asm -DOPENSSL_NO_AES_CONST_TIME + At this time this feature is by default disabled. + It will be enabled by default in 3.0. + [Bernd Edlinger] + + Changes between 1.1.1e and 1.1.1f [31 Mar 2020] + + *) Revert the change of EOF detection while reading in libssl to avoid + regressions in applications depending on the current way of reporting + the EOF. As the existing method is not fully accurate the change to + reporting the EOF via SSL_ERROR_SSL is kept on the current development + branch and will be present in the 3.0 release. + [Tomas Mraz] + + *) Revised BN_generate_prime_ex to not avoid factors 3..17863 in p-1 + when primes for RSA keys are computed. + Since we previously always generated primes == 2 (mod 3) for RSA keys, + the 2-prime and 3-prime RSA modules were easy to distinguish, since + N = p*q = 1 (mod 3), but N = p*q*r = 2 (mod 3). Therefore fingerprinting + 2-prime vs. 3-prime RSA keys was possible by computing N mod 3. + This avoids possible fingerprinting of newly generated RSA modules. + [Bernd Edlinger] + Changes between 1.1.1d and 1.1.1e [17 Mar 2020] *) Properly detect EOF while reading in libssl. Previously if we hit an EOF while reading in libssl then we would report an error back to the diff --git a/deps/openssl/openssl/Configurations/unix-Makefile.tmpl b/deps/openssl/openssl/Configurations/unix-Makefile.tmpl index 9bf54f21277fcb..3a24d551359bd0 100644 --- a/deps/openssl/openssl/Configurations/unix-Makefile.tmpl +++ b/deps/openssl/openssl/Configurations/unix-Makefile.tmpl @@ -547,78 +547,78 @@ uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev install_docs: install_man_docs install_html_docs uninstall_docs: uninstall_man_docs uninstall_html_docs - $(RM) -r $(DESTDIR)$(DOCDIR) + $(RM) -r "$(DESTDIR)$(DOCDIR)" install_ssldirs: - @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs - @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private - @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc + @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)/certs" + @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)/private" + @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)/misc" @set -e; for x in dummy $(MISC_SCRIPTS); do \ if [ "$$x" = "dummy" ]; then continue; fi; \ x1=`echo "$$x" | cut -f1 -d:`; \ x2=`echo "$$x" | cut -f2 -d:`; \ fn=`basename $$x1`; \ $(ECHO) "install $$x1 -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \ - cp $$x1 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \ - chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \ - mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \ - $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \ + cp $$x1 "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new"; \ + chmod 755 "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new"; \ + mv -f "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new" \ + "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \ if [ "$$x1" != "$$x2" ]; then \ ln=`basename "$$x2"`; \ : {- output_off() unless windowsdll(); "" -}; \ $(ECHO) "copy $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \ - cp $(DESTDIR)$(OPENSSLDIR)/misc/$$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \ + cp "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn" "$(DESTDIR)$(OPENSSLDIR)/misc/$$ln"; \ : {- output_on() unless windowsdll(); output_off() if windowsdll(); "" -}; \ $(ECHO) "link $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \ - ln -sf $$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \ + ln -sf $$fn "$(DESTDIR)$(OPENSSLDIR)/misc/$$ln"; \ : {- output_on() if windowsdll(); "" -}; \ fi; \ done @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist" - @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new - @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new - @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist + @cp $(SRCDIR)/apps/openssl.cnf "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new" + @chmod 644 "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new" + @mv -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new" "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist" @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \ $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \ - cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \ - chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \ + cp $(SRCDIR)/apps/openssl.cnf "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \ + chmod 644 "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \ fi @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist" - @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new - @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new - @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist + @cp $(SRCDIR)/apps/ct_log_list.cnf "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new" + @chmod 644 "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new" + @mv -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new" "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist" @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \ $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \ - cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \ - chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \ + cp $(SRCDIR)/apps/ct_log_list.cnf "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \ + chmod 644 "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \ fi install_dev: install_runtime_libs @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) @$(ECHO) "*** Installing development files" - @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl + @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(INSTALLTOP)/include/openssl" @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -} @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c" - @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c - @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c + @cp $(SRCDIR)/ms/applink.c "$(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c" + @chmod 644 "$(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c" @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -} @set -e; for i in $(SRCDIR)/include/openssl/*.h \ $(BLDDIR)/include/openssl/*.h; do \ fn=`basename $$i`; \ $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \ - cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \ - chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \ + cp $$i "$(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \ + chmod 644 "$(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \ done - @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir) + @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(libdir)" @set -e; for l in $(INSTALL_LIBS); do \ fn=`basename $$l`; \ $(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \ - cp $$l $(DESTDIR)$(libdir)/$$fn.new; \ - $(RANLIB) $(DESTDIR)$(libdir)/$$fn.new; \ - chmod 644 $(DESTDIR)$(libdir)/$$fn.new; \ - mv -f $(DESTDIR)$(libdir)/$$fn.new \ - $(DESTDIR)$(libdir)/$$fn; \ + cp $$l "$(DESTDIR)$(libdir)/$$fn.new"; \ + $(RANLIB) "$(DESTDIR)$(libdir)/$$fn.new"; \ + chmod 644 "$(DESTDIR)$(libdir)/$$fn.new"; \ + mv -f "$(DESTDIR)$(libdir)/$$fn.new" \ + "$(DESTDIR)$(libdir)/$$fn"; \ done @ : {- output_off() if $disabled{shared}; "" -} @set -e; for s in $(INSTALL_SHLIB_INFO); do \ @@ -629,61 +629,61 @@ install_dev: install_runtime_libs : {- output_off(); output_on() unless windowsdll() or sharedaix(); "" -}; \ if [ "$$fn1" != "$$fn2" ]; then \ $(ECHO) "link $(DESTDIR)$(libdir)/$$fn2 -> $(DESTDIR)$(libdir)/$$fn1"; \ - ln -sf $$fn1 $(DESTDIR)$(libdir)/$$fn2; \ + ln -sf $$fn1 "$(DESTDIR)$(libdir)/$$fn2"; \ fi; \ : {- output_off() unless windowsdll() or sharedaix(); output_on() if windowsdll(); "" -}; \ $(ECHO) "install $$s2 -> $(DESTDIR)$(libdir)/$$fn2"; \ - cp $$s2 $(DESTDIR)$(libdir)/$$fn2.new; \ - chmod 755 $(DESTDIR)$(libdir)/$$fn2.new; \ - mv -f $(DESTDIR)$(libdir)/$$fn2.new \ - $(DESTDIR)$(libdir)/$$fn2; \ + cp $$s2 "$(DESTDIR)$(libdir)/$$fn2.new"; \ + chmod 755 "$(DESTDIR)$(libdir)/$$fn2.new"; \ + mv -f "$(DESTDIR)$(libdir)/$$fn2.new" \ + "$(DESTDIR)$(libdir)/$$fn2"; \ : {- output_off() if windowsdll(); output_on() if sharedaix(); "" -}; \ - a=$(DESTDIR)$(libdir)/$$fn2; \ + a="$(DESTDIR)$(libdir)/$$fn2"; \ $(ECHO) "install $$s1 -> $$a"; \ - if [ -f $$a ]; then ( trap "rm -rf /tmp/ar.$$$$" INT 0; \ + if [ -f "$$a" ]; then ( trap "rm -rf /tmp/ar.$$$$" INT 0; \ mkdir /tmp/ar.$$$$; ( cd /tmp/ar.$$$$; \ - cp -f $$a $$a.new; \ - for so in `$(AR) t $$a`; do \ - $(AR) x $$a $$so; \ - chmod u+w $$so; \ - strip -X32_64 -e $$so; \ - $(AR) r $$a.new $$so; \ + cp -f "$$a" "$$a.new"; \ + for so in `$(AR) t "$$a"`; do \ + $(AR) x "$$a" "$$so"; \ + chmod u+w "$$so"; \ + strip -X32_64 -e "$$so"; \ + $(AR) r "$$a.new" "$$so"; \ done; \ )); fi; \ - $(AR) r $$a.new $$s1; \ - mv -f $$a.new $$a; \ + $(AR) r "$$a.new" "$$s1"; \ + mv -f "$$a.new" "$$a"; \ : {- output_off() if sharedaix(); output_on(); "" -}; \ done @ : {- output_on() if $disabled{shared}; "" -} - @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)/pkgconfig + @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(libdir)/pkgconfig" @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc" - @cp libcrypto.pc $(DESTDIR)$(libdir)/pkgconfig - @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc + @cp libcrypto.pc "$(DESTDIR)$(libdir)/pkgconfig" + @chmod 644 "$(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc" @$(ECHO) "install libssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/libssl.pc" - @cp libssl.pc $(DESTDIR)$(libdir)/pkgconfig - @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libssl.pc + @cp libssl.pc "$(DESTDIR)$(libdir)/pkgconfig" + @chmod 644 "$(DESTDIR)$(libdir)/pkgconfig/libssl.pc" @$(ECHO) "install openssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/openssl.pc" - @cp openssl.pc $(DESTDIR)$(libdir)/pkgconfig - @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/openssl.pc + @cp openssl.pc "$(DESTDIR)$(libdir)/pkgconfig" + @chmod 644 "$(DESTDIR)$(libdir)/pkgconfig/openssl.pc" uninstall_dev: uninstall_runtime_libs @$(ECHO) "*** Uninstalling development files" @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -} @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c" - @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c + @$(RM) "$(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c" @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -} @set -e; for i in $(SRCDIR)/include/openssl/*.h \ $(BLDDIR)/include/openssl/*.h; do \ fn=`basename $$i`; \ $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \ - $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \ + $(RM) "$(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \ done - -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl - -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include + -$(RMDIR) "$(DESTDIR)$(INSTALLTOP)/include/openssl" + -$(RMDIR) "$(DESTDIR)$(INSTALLTOP)/include" @set -e; for l in $(INSTALL_LIBS); do \ fn=`basename $$l`; \ $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \ - $(RM) $(DESTDIR)$(libdir)/$$fn; \ + $(RM) "$(DESTDIR)$(libdir)/$$fn"; \ done @ : {- output_off() if $disabled{shared}; "" -} @set -e; for s in $(INSTALL_SHLIB_INFO); do \ @@ -693,35 +693,35 @@ uninstall_dev: uninstall_runtime_libs fn2=`basename $$s2`; \ : {- output_off() if windowsdll(); "" -}; \ $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \ - $(RM) $(DESTDIR)$(libdir)/$$fn2; \ + $(RM) "$(DESTDIR)$(libdir)/$$fn2"; \ if [ "$$fn1" != "$$fn2" -a -f "$(DESTDIR)$(libdir)/$$fn1" ]; then \ $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn1"; \ - $(RM) $(DESTDIR)$(libdir)/$$fn1; \ + $(RM) "$(DESTDIR)$(libdir)/$$fn1"; \ fi; \ : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \ $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \ - $(RM) $(DESTDIR)$(libdir)/$$fn2; \ + $(RM) "$(DESTDIR)$(libdir)/$$fn2"; \ : {- output_on() unless windowsdll(); "" -}; \ done @ : {- output_on() if $disabled{shared}; "" -} - $(RM) $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc - $(RM) $(DESTDIR)$(libdir)/pkgconfig/libssl.pc - $(RM) $(DESTDIR)$(libdir)/pkgconfig/openssl.pc - -$(RMDIR) $(DESTDIR)$(libdir)/pkgconfig - -$(RMDIR) $(DESTDIR)$(libdir) + $(RM) "$(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc" + $(RM) "$(DESTDIR)$(libdir)/pkgconfig/libssl.pc" + $(RM) "$(DESTDIR)$(libdir)/pkgconfig/openssl.pc" + -$(RMDIR) "$(DESTDIR)$(libdir)/pkgconfig" + -$(RMDIR) "$(DESTDIR)$(libdir)" install_engines: install_runtime_libs build_engines @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) - @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/ + @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(ENGINESDIR)/" @$(ECHO) "*** Installing engines" @set -e; for e in dummy $(INSTALL_ENGINES); do \ if [ "$$e" = "dummy" ]; then continue; fi; \ fn=`basename $$e`; \ $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \ - cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \ - chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \ - mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \ - $(DESTDIR)$(ENGINESDIR)/$$fn; \ + cp $$e "$(DESTDIR)$(ENGINESDIR)/$$fn.new"; \ + chmod 755 "$(DESTDIR)$(ENGINESDIR)/$$fn.new"; \ + mv -f "$(DESTDIR)$(ENGINESDIR)/$$fn.new" \ + "$(DESTDIR)$(ENGINESDIR)/$$fn"; \ done uninstall_engines: @@ -733,18 +733,18 @@ uninstall_engines: continue; \ fi; \ $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \ - $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \ + $(RM) "$(DESTDIR)$(ENGINESDIR)/$$fn"; \ done - -$(RMDIR) $(DESTDIR)$(ENGINESDIR) + -$(RMDIR) "$(DESTDIR)$(ENGINESDIR)" install_runtime: install_programs install_runtime_libs: build_libs @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) @ : {- output_off() if windowsdll(); "" -} - @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir) + @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(libdir)" @ : {- output_on() if windowsdll(); output_off() unless windowsdll(); "" -} - @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin + @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(INSTALLTOP)/bin" @ : {- output_on() unless windowsdll(); "" -} @$(ECHO) "*** Installing runtime libraries" @set -e; for s in dummy $(INSTALL_SHLIBS); do \ @@ -752,40 +752,40 @@ install_runtime_libs: build_libs fn=`basename $$s`; \ : {- output_off() unless windowsdll(); "" -}; \ $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ - cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ - chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ - mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \ - $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ + cp $$s "$(DESTDIR)$(INSTALLTOP)/bin/$$fn.new"; \ + chmod 755 "$(DESTDIR)$(INSTALLTOP)/bin/$$fn.new"; \ + mv -f "$(DESTDIR)$(INSTALLTOP)/bin/$$fn.new" \ + "$(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \ $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \ - cp $$s $(DESTDIR)$(libdir)/$$fn.new; \ - chmod 755 $(DESTDIR)$(libdir)/$$fn.new; \ - mv -f $(DESTDIR)$(libdir)/$$fn.new \ - $(DESTDIR)$(libdir)/$$fn; \ + cp $$s "$(DESTDIR)$(libdir)/$$fn.new"; \ + chmod 755 "$(DESTDIR)$(libdir)/$$fn.new"; \ + mv -f "$(DESTDIR)$(libdir)/$$fn.new" \ + "$(DESTDIR)$(libdir)/$$fn"; \ : {- output_on() if windowsdll(); "" -}; \ done install_programs: install_runtime_libs build_programs @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) - @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin + @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(INSTALLTOP)/bin" @$(ECHO) "*** Installing runtime programs" @set -e; for x in dummy $(INSTALL_PROGRAMS); do \ if [ "$$x" = "dummy" ]; then continue; fi; \ fn=`basename $$x`; \ $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ - cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ - chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ - mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \ - $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ + cp $$x "$(DESTDIR)$(INSTALLTOP)/bin/$$fn.new"; \ + chmod 755 "$(DESTDIR)$(INSTALLTOP)/bin/$$fn.new"; \ + mv -f "$(DESTDIR)$(INSTALLTOP)/bin/$$fn.new" \ + "$(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ done @set -e; for x in dummy $(BIN_SCRIPTS); do \ if [ "$$x" = "dummy" ]; then continue; fi; \ fn=`basename $$x`; \ $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ - cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ - chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ - mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \ - $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ + cp $$x "$(DESTDIR)$(INSTALLTOP)/bin/$$fn.new"; \ + chmod 755 "$(DESTDIR)$(INSTALLTOP)/bin/$$fn.new"; \ + mv -f "$(DESTDIR)$(INSTALLTOP)/bin/$$fn.new" \ + "$(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ done uninstall_runtime: uninstall_programs uninstall_runtime_libs @@ -797,16 +797,16 @@ uninstall_programs: if [ "$$x" = "dummy" ]; then continue; fi; \ fn=`basename $$x`; \ $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ - $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ + $(RM) "$(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ done; @set -e; for x in dummy $(BIN_SCRIPTS); \ do \ if [ "$$x" = "dummy" ]; then continue; fi; \ fn=`basename $$x`; \ $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ - $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ + $(RM) "$(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ done - -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin + -$(RMDIR) "$(DESTDIR)$(INSTALLTOP)/bin" uninstall_runtime_libs: @$(ECHO) "*** Uninstalling runtime libraries" @@ -815,7 +815,7 @@ uninstall_runtime_libs: if [ "$$s" = "dummy" ]; then continue; fi; \ fn=`basename $$s`; \ $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ - $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ + $(RM) "$(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ done @ : {- output_on() unless windowsdll(); "" -} @@ -824,24 +824,24 @@ install_man_docs: @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) @$(ECHO) "*** Installing manpages" $(PERL) $(SRCDIR)/util/process_docs.pl \ - --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) + "--destdir=$(DESTDIR)$(MANDIR)" --type=man --suffix=$(MANSUFFIX) uninstall_man_docs: @$(ECHO) "*** Uninstalling manpages" $(PERL) $(SRCDIR)/util/process_docs.pl \ - --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \ + "--destdir=$(DESTDIR)$(MANDIR)" --type=man --suffix=$(MANSUFFIX) \ --remove install_html_docs: @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) @$(ECHO) "*** Installing HTML manpages" $(PERL) $(SRCDIR)/util/process_docs.pl \ - --destdir=$(DESTDIR)$(HTMLDIR) --type=html + "--destdir=$(DESTDIR)$(HTMLDIR)" --type=html uninstall_html_docs: @$(ECHO) "*** Uninstalling manpages" $(PERL) $(SRCDIR)/util/process_docs.pl \ - --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove + "--destdir=$(DESTDIR)$(HTMLDIR)" --type=html --remove # Developer targets (note: these are only available on Unix) ######### diff --git a/deps/openssl/openssl/INSTALL b/deps/openssl/openssl/INSTALL index 328ad2baf480b4..f5118428b3bca2 100644 --- a/deps/openssl/openssl/INSTALL +++ b/deps/openssl/openssl/INSTALL @@ -535,9 +535,9 @@ conjunction with the "-DPEDANTIC" option (or the --strict-warnings option). - no-ui - Don't build with the "UI" capability (i.e. the set of - features enabling text based prompts). + no-ui-console + Don't build with the "UI" console method (i.e. the "UI" + method that enables text based console prompts). enable-unit-test Enable additional unit test APIs. This should not typically diff --git a/deps/openssl/openssl/NEWS b/deps/openssl/openssl/NEWS index eba6c3b6d93fc2..455b02dcb264bd 100644 --- a/deps/openssl/openssl/NEWS +++ b/deps/openssl/openssl/NEWS @@ -5,10 +5,20 @@ This file gives a brief overview of the major changes between each OpenSSL release. For more details please read the CHANGES file. + Major changes between OpenSSL 1.1.1f and OpenSSL 1.1.1g [21 Apr 2020] + + o Fixed segmentation fault in SSL_check_chain() (CVE-2020-1967) + + Major changes between OpenSSL 1.1.1e and OpenSSL 1.1.1f [31 Mar 2020] + + o Revert the unexpected EOF reporting via SSL_ERROR_SSL + Major changes between OpenSSL 1.1.1d and OpenSSL 1.1.1e [17 Mar 2020] o Fixed an overflow bug in the x64_64 Montgomery squaring procedure used in exponentiation with 512-bit moduli (CVE-2019-1551) + o Properly detect unexpected EOF while reading in libssl and report + it via SSL_ERROR_SSL Major changes between OpenSSL 1.1.1c and OpenSSL 1.1.1d [10 Sep 2019] diff --git a/deps/openssl/openssl/README b/deps/openssl/openssl/README index 8e9ce75a335d74..46c2b537bed482 100644 --- a/deps/openssl/openssl/README +++ b/deps/openssl/openssl/README @@ -1,7 +1,7 @@ - OpenSSL 1.1.1e 17 Mar 2020 + OpenSSL 1.1.1g 21 Apr 2020 - Copyright (c) 1998-2019 The OpenSSL Project + Copyright (c) 1998-2020 The OpenSSL Project Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson All rights reserved. diff --git a/deps/openssl/openssl/apps/build.info b/deps/openssl/openssl/apps/build.info index 751d8da8281815..01537361820e1d 100644 --- a/deps/openssl/openssl/apps/build.info +++ b/deps/openssl/openssl/apps/build.info @@ -1,16 +1,17 @@ {- our @apps_openssl_src = qw(openssl.c - asn1pars.c ca.c ciphers.c cms.c crl.c crl2p7.c dgst.c dhparam.c - dsa.c dsaparam.c ec.c ecparam.c enc.c engine.c errstr.c gendsa.c - genpkey.c genrsa.c nseq.c ocsp.c passwd.c pkcs12.c pkcs7.c pkcs8.c - pkey.c pkeyparam.c pkeyutl.c prime.c rand.c req.c rsa.c rsautl.c + asn1pars.c ca.c ciphers.c cms.c crl.c crl2p7.c dgst.c + enc.c errstr.c + genpkey.c nseq.c passwd.c pkcs7.c pkcs8.c + pkey.c pkeyparam.c pkeyutl.c prime.c rand.c req.c s_client.c s_server.c s_time.c sess_id.c smime.c speed.c spkac.c - srp.c ts.c verify.c version.c x509.c rehash.c storeutl.c); + verify.c version.c x509.c rehash.c storeutl.c); our @apps_lib_src = ( qw(apps.c opt.c s_cb.c s_socket.c app_rand.c bf_prefix.c), split(/\s+/, $target{apps_aux_src}) ); our @apps_init_src = split(/\s+/, $target{apps_init_src}); "" -} + IF[{- !$disabled{apps} -}] LIBS_NO_INST=libapps.a SOURCE[libapps.a]={- join(" ", @apps_lib_src) -} @@ -21,11 +22,51 @@ IF[{- !$disabled{apps} -}] SOURCE[openssl]={- join(" ", @apps_openssl_src) -} INCLUDE[openssl]=.. ../include DEPEND[openssl]=libapps.a ../libssl - -IF[{- $config{target} =~ /^(?:Cygwin|mingw|VC-)/ -}] - GENERATE[openssl.rc]=../util/mkrc.pl openssl - SOURCE[openssl]=openssl.rc -ENDIF + IF[{- !$disabled{'des'} -}] + SOURCE[openssl]=pkcs12.c + DEPEND[pkcs12.o]=progs.h + ENDIF + IF[{- !$disabled{'ec'} -}] + SOURCE[openssl]=ec.c ecparam.c + DEPEND[ec.o]=progs.h + DEPEND[ecparam.o]=progs.h + ENDIF + IF[{- !$disabled{'ocsp'} -}] + SOURCE[openssl]=ocsp.c + DEPEND[ocsp.o]=progs.h + ENDIF + IF[{- !$disabled{'srp'} -}] + SOURCE[openssl]=srp.c + DEPEND[srp.o]=progs.h + ENDIF + IF[{- !$disabled{'ts'} -}] + SOURCE[openssl]=ts.c + DEPEND[ts.o]=progs.h + ENDIF + IF[{- !$disabled{'dh'} -}] + SOURCE[openssl]=dhparam.c + DEPEND[dhparam.o]=progs.h + ENDIF + IF[{- !$disabled{'dsa'} -}] + SOURCE[openssl]=dsa.c dsaparam.c gendsa.c + DEPEND[dsa.o]=progs.h + DEPEND[dsaparam.o]=progs.h + DEPEND[gendsa.o]=progs.h + ENDIF + IF[{- !$disabled{'engine'} -}] + SOURCE[openssl]=engine.c + DEPEND[engine.o]=progs.h + ENDIF + IF[{- !$disabled{'rsa'} -}] + SOURCE[openssl]=rsa.c rsautl.c genrsa.c + DEPEND[rsa.o]=progs.h + DEPEND[rsautl.o]=progs.h + DEPEND[genrsa.o]=progs.h + ENDIF + IF[{- $config{target} =~ /^(?:Cygwin|mingw|VC-)/ -}] + GENERATE[openssl.rc]=../util/mkrc.pl openssl + SOURCE[openssl]=openssl.rc + ENDIF {- join("\n ", map { (my $x = $_) =~ s|\.c$|.o|; "DEPEND[$x]=progs.h" } @apps_openssl_src) -} diff --git a/deps/openssl/openssl/apps/dhparam.c b/deps/openssl/openssl/apps/dhparam.c index 13f76754d27cbe..98c73214b53e26 100644 --- a/deps/openssl/openssl/apps/dhparam.c +++ b/deps/openssl/openssl/apps/dhparam.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,28 +8,24 @@ */ #include -#ifdef OPENSSL_NO_DH -NON_EMPTY_TRANSLATION_UNIT -#else - -# include -# include -# include -# include -# include "apps.h" -# include "progs.h" -# include -# include -# include -# include -# include -# include - -# ifndef OPENSSL_NO_DSA -# include -# endif - -# define DEFBITS 2048 +#include +#include +#include +#include +#include "apps.h" +#include "progs.h" +#include +#include +#include +#include +#include +#include + +#ifndef OPENSSL_NO_DSA +# include +#endif + +#define DEFBITS 2048 static int dh_cb(int p, int n, BN_GENCB *cb); @@ -56,13 +52,13 @@ const OPTIONS dhparam_options[] = { {"C", OPT_C, '-', "Print C code"}, {"2", OPT_2, '-', "Generate parameters using 2 as the generator value"}, {"5", OPT_5, '-', "Generate parameters using 5 as the generator value"}, -# ifndef OPENSSL_NO_DSA +#ifndef OPENSSL_NO_DSA {"dsaparam", OPT_DSAPARAM, '-', "Read or generate DSA parameters, convert to DH"}, -# endif -# ifndef OPENSSL_NO_ENGINE +#endif +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"}, -# endif +#endif {NULL} }; @@ -146,13 +142,13 @@ int dhparam_main(int argc, char **argv) if (g && !num) num = DEFBITS; -# ifndef OPENSSL_NO_DSA +#ifndef OPENSSL_NO_DSA if (dsaparam && g) { BIO_printf(bio_err, "generator may not be chosen for DSA parameters\n"); goto end; } -# endif +#endif out = bio_open_default(outfile, 'w', outformat); if (out == NULL) @@ -173,7 +169,7 @@ int dhparam_main(int argc, char **argv) BN_GENCB_set(cb, dh_cb, bio_err); -# ifndef OPENSSL_NO_DSA +#ifndef OPENSSL_NO_DSA if (dsaparam) { DSA *dsa = DSA_new(); @@ -196,7 +192,7 @@ int dhparam_main(int argc, char **argv) goto end; } } else -# endif +#endif { dh = DH_new(); BIO_printf(bio_err, @@ -217,7 +213,7 @@ int dhparam_main(int argc, char **argv) if (in == NULL) goto end; -# ifndef OPENSSL_NO_DSA +#ifndef OPENSSL_NO_DSA if (dsaparam) { DSA *dsa; @@ -239,7 +235,7 @@ int dhparam_main(int argc, char **argv) goto end; } } else -# endif +#endif { if (informat == FORMAT_ASN1) { /* @@ -376,4 +372,3 @@ static int dh_cb(int p, int n, BN_GENCB *cb) (void)BIO_flush(BN_GENCB_get_arg(cb)); return 1; } -#endif diff --git a/deps/openssl/openssl/apps/dsa.c b/deps/openssl/openssl/apps/dsa.c index 6022e64cd4cebe..c7884df166b70f 100644 --- a/deps/openssl/openssl/apps/dsa.c +++ b/deps/openssl/openssl/apps/dsa.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,23 +8,19 @@ */ #include -#ifdef OPENSSL_NO_DSA -NON_EMPTY_TRANSLATION_UNIT -#else - -# include -# include -# include -# include -# include "apps.h" -# include "progs.h" -# include -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include "apps.h" +#include "progs.h" +#include +#include +#include +#include +#include +#include +#include typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, @@ -49,14 +45,14 @@ const OPTIONS dsa_options[] = { {"passin", OPT_PASSIN, 's', "Input file pass phrase source"}, {"passout", OPT_PASSOUT, 's', "Output file pass phrase source"}, {"", OPT_CIPHER, '-', "Any supported cipher"}, -# ifndef OPENSSL_NO_RC4 +#ifndef OPENSSL_NO_RC4 {"pvk-strong", OPT_PVK_STRONG, '-', "Enable 'Strong' PVK encoding level (default)"}, {"pvk-weak", OPT_PVK_WEAK, '-', "Enable 'Weak' PVK encoding level"}, {"pvk-none", OPT_PVK_NONE, '-', "Don't enforce PVK encoding"}, -# endif -# ifndef OPENSSL_NO_ENGINE +#endif +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"}, -# endif +#endif {NULL} }; @@ -71,9 +67,9 @@ int dsa_main(int argc, char **argv) OPTION_CHOICE o; int informat = FORMAT_PEM, outformat = FORMAT_PEM, text = 0, noout = 0; int i, modulus = 0, pubin = 0, pubout = 0, ret = 1; -# ifndef OPENSSL_NO_RC4 +#ifndef OPENSSL_NO_RC4 int pvk_encr = 2; -# endif +#endif int private = 0; prog = opt_init(argc, argv, dsa_options); @@ -214,7 +210,7 @@ int dsa_main(int argc, char **argv) i = PEM_write_bio_DSAPrivateKey(out, dsa, enc, NULL, 0, NULL, passout); } -# ifndef OPENSSL_NO_RSA +#ifndef OPENSSL_NO_RSA } else if (outformat == FORMAT_MSBLOB || outformat == FORMAT_PVK) { EVP_PKEY *pk; pk = EVP_PKEY_new(); @@ -229,13 +225,13 @@ int dsa_main(int argc, char **argv) goto end; } assert(private); -# ifdef OPENSSL_NO_RC4 +# ifdef OPENSSL_NO_RC4 BIO_printf(bio_err, "PVK format not supported\n"); EVP_PKEY_free(pk); goto end; -# else +# else i = i2b_PVK_bio(out, pk, pvk_encr, 0, passout); -# endif +# endif } else if (pubin || pubout) { i = i2b_PublicKey_bio(out, pk); } else { @@ -243,7 +239,7 @@ int dsa_main(int argc, char **argv) i = i2b_PrivateKey_bio(out, pk); } EVP_PKEY_free(pk); -# endif +#endif } else { BIO_printf(bio_err, "bad output format specified for outfile\n"); goto end; @@ -262,4 +258,3 @@ int dsa_main(int argc, char **argv) OPENSSL_free(passout); return ret; } -#endif diff --git a/deps/openssl/openssl/apps/dsaparam.c b/deps/openssl/openssl/apps/dsaparam.c index b227b76a372362..75589ac6bc4eaa 100644 --- a/deps/openssl/openssl/apps/dsaparam.c +++ b/deps/openssl/openssl/apps/dsaparam.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,22 +8,18 @@ */ #include -#ifdef OPENSSL_NO_DSA -NON_EMPTY_TRANSLATION_UNIT -#else - -# include -# include -# include -# include -# include "apps.h" -# include "progs.h" -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include "apps.h" +#include "progs.h" +#include +#include +#include +#include +#include +#include static int dsa_cb(int p, int n, BN_GENCB *cb); @@ -44,9 +40,9 @@ const OPTIONS dsaparam_options[] = { {"noout", OPT_NOOUT, '-', "No output"}, {"genkey", OPT_GENKEY, '-', "Generate a DSA key"}, OPT_R_OPTIONS, -# ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"}, -# endif +#endif {NULL} }; @@ -255,4 +251,3 @@ static int dsa_cb(int p, int n, BN_GENCB *cb) (void)BIO_flush(BN_GENCB_get_arg(cb)); return 1; } -#endif diff --git a/deps/openssl/openssl/apps/ec.c b/deps/openssl/openssl/apps/ec.c index 03abb00683373b..0c8ed750cc1788 100644 --- a/deps/openssl/openssl/apps/ec.c +++ b/deps/openssl/openssl/apps/ec.c @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,19 +8,15 @@ */ #include -#ifdef OPENSSL_NO_EC -NON_EMPTY_TRANSLATION_UNIT -#else - -# include -# include -# include -# include "apps.h" -# include "progs.h" -# include -# include -# include -# include +#include +#include +#include +#include "apps.h" +#include "progs.h" +#include +#include +#include +#include static OPT_PAIR conv_forms[] = { {"compressed", POINT_CONVERSION_COMPRESSED}, @@ -62,9 +58,9 @@ const OPTIONS ec_options[] = { "Specifies the way the ec parameters are encoded"}, {"conv_form", OPT_CONV_FORM, 's', "Specifies the point conversion form "}, {"", OPT_CIPHER, '-', "Any supported cipher"}, -# ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, -# endif +#endif {NULL} }; @@ -280,4 +276,3 @@ int ec_main(int argc, char **argv) OPENSSL_free(passout); return ret; } -#endif diff --git a/deps/openssl/openssl/apps/ecparam.c b/deps/openssl/openssl/apps/ecparam.c index 917f1a86b2e36c..58fbeb95c9ce31 100644 --- a/deps/openssl/openssl/apps/ecparam.c +++ b/deps/openssl/openssl/apps/ecparam.c @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the OpenSSL license (the "License"). You may not use @@ -9,22 +9,18 @@ */ #include -#ifdef OPENSSL_NO_EC -NON_EMPTY_TRANSLATION_UNIT -#else - -# include -# include -# include -# include -# include "apps.h" -# include "progs.h" -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include "apps.h" +#include "progs.h" +#include +#include +#include +#include +#include +#include typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, @@ -55,9 +51,9 @@ const OPTIONS ecparam_options[] = { "Specifies the way the ec parameters are encoded"}, {"genkey", OPT_GENKEY, '-', "Generate ec key"}, OPT_R_OPTIONS, -# ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, -# endif +#endif {NULL} }; @@ -446,5 +442,3 @@ int ecparam_main(int argc, char **argv) BIO_free_all(out); return ret; } - -#endif diff --git a/deps/openssl/openssl/apps/engine.c b/deps/openssl/openssl/apps/engine.c index 83f9588a0ab19f..746cace354b2e0 100644 --- a/deps/openssl/openssl/apps/engine.c +++ b/deps/openssl/openssl/apps/engine.c @@ -1,5 +1,5 @@ /* - * Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,19 +8,15 @@ */ #include -#ifdef OPENSSL_NO_ENGINE -NON_EMPTY_TRANSLATION_UNIT -#else - -# include "apps.h" -# include "progs.h" -# include -# include -# include -# include -# include -# include -# include +#include "apps.h" +#include "progs.h" +#include +#include +#include +#include +#include +#include +#include typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, @@ -486,4 +482,3 @@ int engine_main(int argc, char **argv) BIO_free_all(out); return ret; } -#endif diff --git a/deps/openssl/openssl/apps/gendsa.c b/deps/openssl/openssl/apps/gendsa.c index 401375420bffad..ec57c92a949274 100644 --- a/deps/openssl/openssl/apps/gendsa.c +++ b/deps/openssl/openssl/apps/gendsa.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,22 +8,18 @@ */ #include -#ifdef OPENSSL_NO_DSA -NON_EMPTY_TRANSLATION_UNIT -#else - -# include -# include -# include -# include -# include "apps.h" -# include "progs.h" -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include "apps.h" +#include "progs.h" +#include +#include +#include +#include +#include +#include typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, @@ -39,9 +35,9 @@ const OPTIONS gendsa_options[] = { {"passout", OPT_PASSOUT, 's', "Output file pass phrase source"}, OPT_R_OPTIONS, {"", OPT_CIPHER, '-', "Encrypt the output with any supported cipher"}, -# ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, -# endif +#endif {NULL} }; @@ -143,4 +139,3 @@ int gendsa_main(int argc, char **argv) OPENSSL_free(passout); return ret; } -#endif diff --git a/deps/openssl/openssl/apps/genrsa.c b/deps/openssl/openssl/apps/genrsa.c index c17cd147154eea..e34a2f7ab9e883 100644 --- a/deps/openssl/openssl/apps/genrsa.c +++ b/deps/openssl/openssl/apps/genrsa.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,27 +8,23 @@ */ #include -#ifdef OPENSSL_NO_RSA -NON_EMPTY_TRANSLATION_UNIT -#else - -# include -# include -# include -# include -# include "apps.h" -# include "progs.h" -# include -# include -# include -# include -# include -# include -# include -# include - -# define DEFBITS 2048 -# define DEFPRIMES 2 +#include +#include +#include +#include +#include "apps.h" +#include "progs.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEFBITS 2048 +#define DEFPRIMES 2 static int genrsa_cb(int p, int n, BN_GENCB *cb); @@ -48,9 +44,9 @@ const OPTIONS genrsa_options[] = { OPT_R_OPTIONS, {"passout", OPT_PASSOUT, 's', "Output file pass phrase source"}, {"", OPT_CIPHER, '-', "Encrypt the output with any supported cipher"}, -# ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, -# endif +#endif {"primes", OPT_PRIMES, 'p', "Specify number of primes"}, {NULL} }; @@ -198,4 +194,3 @@ static int genrsa_cb(int p, int n, BN_GENCB *cb) (void)BIO_flush(BN_GENCB_get_arg(cb)); return 1; } -#endif diff --git a/deps/openssl/openssl/apps/ocsp.c b/deps/openssl/openssl/apps/ocsp.c index b85a4d82c1bd14..27ec94fa6b8d48 100644 --- a/deps/openssl/openssl/apps/ocsp.c +++ b/deps/openssl/openssl/apps/ocsp.c @@ -1,5 +1,5 @@ /* - * Copyright 2001-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -9,65 +9,62 @@ #include -#ifdef OPENSSL_NO_OCSP -NON_EMPTY_TRANSLATION_UNIT -#else -# ifdef OPENSSL_SYS_VMS -# define _XOPEN_SOURCE_EXTENDED/* So fd_set and friends get properly defined +#ifdef OPENSSL_SYS_VMS +# define _XOPEN_SOURCE_EXTENDED/* So fd_set and friends get properly defined * on OpenVMS */ -# endif +#endif -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include /* Needs to be included before the openssl headers */ -# include "apps.h" -# include "progs.h" -# include "internal/sockets.h" -# include -# include -# include -# include -# include -# include -# include -# include +#include "apps.h" +#include "progs.h" +#include "internal/sockets.h" +#include +#include +#include +#include +#include +#include +#include +#include #ifndef HAVE_FORK -# if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_WINDOWS) -# define HAVE_FORK 0 -# else -# define HAVE_FORK 1 -# endif +#if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_WINDOWS) +# define HAVE_FORK 0 +#else +# define HAVE_FORK 1 +#endif #endif #if HAVE_FORK -# undef NO_FORK +#undef NO_FORK #else -# define NO_FORK +#define NO_FORK #endif -# if !defined(NO_FORK) && !defined(OPENSSL_NO_SOCK) \ +#if !defined(NO_FORK) && !defined(OPENSSL_NO_SOCK) \ && !defined(OPENSSL_NO_POSIX_IO) -# define OCSP_DAEMON -# include -# include -# include -# include -# define MAXERRLEN 1000 /* limit error text sent to syslog to 1000 bytes */ -# else -# undef LOG_INFO -# undef LOG_WARNING -# undef LOG_ERR -# define LOG_INFO 0 -# define LOG_WARNING 1 -# define LOG_ERR 2 -# endif +# define OCSP_DAEMON +# include +# include +# include +# include +# define MAXERRLEN 1000 /* limit error text sent to syslog to 1000 bytes */ +#else +# undef LOG_INFO +# undef LOG_WARNING +# undef LOG_ERR +# define LOG_INFO 0 +# define LOG_WARNING 1 +# define LOG_ERR 2 +#endif -# if defined(OPENSSL_SYS_VXWORKS) +#if defined(OPENSSL_SYS_VXWORKS) /* not supported */ int setpgid(pid_t pid, pid_t pgid) { @@ -80,9 +77,9 @@ pid_t fork(void) errno = ENOSYS; return (pid_t) -1; } -# endif +#endif /* Maximum leeway in validity period: default 5 minutes */ -# define MAX_VALIDITY_PERIOD (5 * 60) +#define MAX_VALIDITY_PERIOD (5 * 60) static int add_ocsp_cert(OCSP_REQUEST **req, X509 *cert, const EVP_MD *cert_id_md, X509 *issuer, @@ -109,20 +106,20 @@ static void log_message(int level, const char *fmt, ...); static char *prog; static int multi = 0; -# ifdef OCSP_DAEMON +#ifdef OCSP_DAEMON static int acfd = (int) INVALID_SOCKET; static int index_changed(CA_DB *); static void spawn_loop(void); static int print_syslog(const char *str, size_t len, void *levPtr); static void socket_timeout(int signum); -# endif +#endif -# ifndef OPENSSL_NO_SOCK +#ifndef OPENSSL_NO_SOCK static OCSP_RESPONSE *query_responder(BIO *cbio, const char *host, const char *path, const STACK_OF(CONF_VALUE) *headers, OCSP_REQUEST *req, int req_timeout); -# endif +#endif typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, @@ -160,9 +157,9 @@ const OPTIONS ocsp_options[] = { "Don't include any certificates in response"}, {"resp_key_id", OPT_RESP_KEY_ID, '-', "Identify response by signing certificate key ID"}, -# ifdef OCSP_DAEMON +#ifdef OCSP_DAEMON {"multi", OPT_MULTI, 'p', "run multiple responder processes"}, -# endif +#endif {"no_certs", OPT_NO_CERTS, '-', "Don't include any certificates in signed request"}, {"no_signature_verify", OPT_NO_SIGNATURE_VERIFY, '-', @@ -511,9 +508,9 @@ int ocsp_main(int argc, char **argv) trailing_md = 1; break; case OPT_MULTI: -# ifdef OCSP_DAEMON +#ifdef OCSP_DAEMON multi = atoi(opt_arg()); -# endif +#endif break; } } @@ -593,7 +590,7 @@ int ocsp_main(int argc, char **argv) } } -# ifdef OCSP_DAEMON +#ifdef OCSP_DAEMON if (multi && acbio != NULL) spawn_loop(); if (acbio != NULL && req_timeout > 0) @@ -606,7 +603,7 @@ int ocsp_main(int argc, char **argv) redo_accept: if (acbio != NULL) { -# ifdef OCSP_DAEMON +#ifdef OCSP_DAEMON if (index_changed(rdb)) { CA_DB *newrdb = load_index(ridx_filename, NULL); @@ -619,7 +616,7 @@ int ocsp_main(int argc, char **argv) ridx_filename); } } -# endif +#endif req = NULL; if (!do_responder(&req, &cbio, acbio, req_timeout)) @@ -688,16 +685,16 @@ int ocsp_main(int argc, char **argv) if (cbio != NULL) send_ocsp_response(cbio, resp); } else if (host != NULL) { -# ifndef OPENSSL_NO_SOCK +#ifndef OPENSSL_NO_SOCK resp = process_responder(req, host, path, port, use_ssl, headers, req_timeout); if (resp == NULL) goto end; -# else +#else BIO_printf(bio_err, "Error creating connect BIO - sockets not supported.\n"); goto end; -# endif +#endif } else if (respin != NULL) { derbio = bio_open_default(respin, 'r', FORMAT_ASN1); if (derbio == NULL) @@ -840,7 +837,7 @@ log_message(int level, const char *fmt, ...) va_list ap; va_start(ap, fmt); -# ifdef OCSP_DAEMON +#ifdef OCSP_DAEMON if (multi) { char buf[1024]; if (vsnprintf(buf, sizeof(buf), fmt, ap) > 0) { @@ -849,7 +846,7 @@ log_message(int level, const char *fmt, ...) if (level >= LOG_ERR) ERR_print_errors_cb(print_syslog, &level); } -# endif +#endif if (!multi) { BIO_printf(bio_err, "%s: ", prog); BIO_vprintf(bio_err, fmt, ap); @@ -858,7 +855,7 @@ log_message(int level, const char *fmt, ...) va_end(ap); } -# ifdef OCSP_DAEMON +#ifdef OCSP_DAEMON static int print_syslog(const char *str, size_t len, void *levPtr) { @@ -1011,7 +1008,7 @@ static void spawn_loop(void) syslog(LOG_INFO, "terminating on signal: %d", termsig); killall(0, kidpids); } -# endif +#endif static int add_ocsp_cert(OCSP_REQUEST **req, X509 *cert, const EVP_MD *cert_id_md, X509 *issuer, @@ -1291,11 +1288,11 @@ static char **lookup_serial(CA_DB *db, ASN1_INTEGER *ser) static BIO *init_responder(const char *port) { -# ifdef OPENSSL_NO_SOCK +#ifdef OPENSSL_NO_SOCK BIO_printf(bio_err, "Error setting up accept BIO - sockets not supported.\n"); return NULL; -# else +#else BIO *acbio = NULL, *bufbio = NULL; bufbio = BIO_new(BIO_f_buffer()); @@ -1322,10 +1319,10 @@ static BIO *init_responder(const char *port) BIO_free_all(acbio); BIO_free(bufbio); return NULL; -# endif +#endif } -# ifndef OPENSSL_NO_SOCK +#ifndef OPENSSL_NO_SOCK /* * Decode %xx URL-decoding in-place. Ignores mal-formed sequences. */ @@ -1349,22 +1346,22 @@ static int urldecode(char *p) *out = '\0'; return (int)(out - save); } -# endif +#endif -# ifdef OCSP_DAEMON +#ifdef OCSP_DAEMON static void socket_timeout(int signum) { if (acfd != (int)INVALID_SOCKET) (void)shutdown(acfd, SHUT_RD); } -# endif +#endif static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio, int timeout) { -# ifdef OPENSSL_NO_SOCK +#ifdef OPENSSL_NO_SOCK return 0; -# else +#else int len; OCSP_REQUEST *req = NULL; char inbuf[2048], reqbuf[2048]; @@ -1382,12 +1379,12 @@ static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio, *pcbio = cbio; client = BIO_get_peer_name(cbio); -# ifdef OCSP_DAEMON +# ifdef OCSP_DAEMON if (timeout > 0) { (void) BIO_get_fd(cbio, &acfd); alarm(timeout); } -# endif +# endif /* Read the request line. */ len = BIO_gets(cbio, reqbuf, sizeof(reqbuf)); @@ -1450,11 +1447,11 @@ static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio, break; } -# ifdef OCSP_DAEMON +# ifdef OCSP_DAEMON /* Clear alarm before we close the client socket */ alarm(0); timeout = 0; -# endif +# endif /* Try to read OCSP request */ if (getbio != NULL) { @@ -1470,13 +1467,13 @@ static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio, *preq = req; out: -# ifdef OCSP_DAEMON +# ifdef OCSP_DAEMON if (timeout > 0) alarm(0); acfd = (int)INVALID_SOCKET; -# endif - return 1; # endif + return 1; +#endif } static int send_ocsp_response(BIO *cbio, OCSP_RESPONSE *resp) @@ -1492,7 +1489,7 @@ static int send_ocsp_response(BIO *cbio, OCSP_RESPONSE *resp) return 1; } -# ifndef OPENSSL_NO_SOCK +#ifndef OPENSSL_NO_SOCK static OCSP_RESPONSE *query_responder(BIO *cbio, const char *host, const char *path, const STACK_OF(CONF_VALUE) *headers, @@ -1623,6 +1620,4 @@ OCSP_RESPONSE *process_responder(OCSP_REQUEST *req, SSL_CTX_free(ctx); return resp; } -# endif - #endif diff --git a/deps/openssl/openssl/apps/pkcs12.c b/deps/openssl/openssl/apps/pkcs12.c index 3603b60c19b3ab..8c5d963b8c654a 100644 --- a/deps/openssl/openssl/apps/pkcs12.c +++ b/deps/openssl/openssl/apps/pkcs12.c @@ -1,5 +1,5 @@ /* - * Copyright 1999-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,25 +8,21 @@ */ #include -#if defined(OPENSSL_NO_DES) -NON_EMPTY_TRANSLATION_UNIT -#else - -# include -# include -# include -# include "apps.h" -# include "progs.h" -# include -# include -# include -# include - -# define NOKEYS 0x1 -# define NOCERTS 0x2 -# define INFO 0x4 -# define CLCERTS 0x8 -# define CACERTS 0x10 +#include +#include +#include +#include "apps.h" +#include "progs.h" +#include +#include +#include +#include + +#define NOKEYS 0x1 +#define NOCERTS 0x2 +#define INFO 0x4 +#define CLCERTS 0x8 +#define CACERTS 0x10 #define PASSWD_BUF_SIZE 2048 @@ -74,15 +70,15 @@ const OPTIONS pkcs12_options[] = { {"chain", OPT_CHAIN, '-', "Add certificate chain"}, {"twopass", OPT_TWOPASS, '-', "Separate MAC, encryption passwords"}, {"nomacver", OPT_NOMACVER, '-', "Don't verify MAC"}, -# ifndef OPENSSL_NO_RC2 +#ifndef OPENSSL_NO_RC2 {"descert", OPT_DESCERT, '-', "Encrypt output with 3DES (default RC2-40)"}, {"certpbe", OPT_CERTPBE, 's', "Certificate PBE algorithm (default RC2-40)"}, -# else +#else {"descert", OPT_DESCERT, '-', "Encrypt output with 3DES (the default)"}, {"certpbe", OPT_CERTPBE, 's', "Certificate PBE algorithm (default 3DES)"}, -# endif +#endif {"export", OPT_EXPORT, '-', "Output PKCS12 file"}, {"noiter", OPT_NOITER, '-', "Don't use encryption iteration"}, {"maciter", OPT_MACITER, '-', "Use MAC iteration"}, @@ -113,9 +109,9 @@ const OPTIONS pkcs12_options[] = { {"no-CApath", OPT_NOCAPATH, '-', "Do not load certificates from the default certificates directory"}, {"", OPT_CIPHER, '-', "Any supported cipher"}, -# ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, -# endif +#endif {NULL} }; @@ -126,11 +122,11 @@ int pkcs12_main(int argc, char **argv) char pass[PASSWD_BUF_SIZE] = "", macpass[PASSWD_BUF_SIZE] = ""; int export_cert = 0, options = 0, chain = 0, twopass = 0, keytype = 0; int iter = PKCS12_DEFAULT_ITER, maciter = PKCS12_DEFAULT_ITER; -# ifndef OPENSSL_NO_RC2 +#ifndef OPENSSL_NO_RC2 int cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC; -# else +#else int cert_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC; -# endif +#endif int key_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC; int ret = 1, macver = 1, add_lmk = 0, private = 0; int noprompt = 0; @@ -976,5 +972,3 @@ static int set_pbe(int *ppbe, const char *str) } return 1; } - -#endif diff --git a/deps/openssl/openssl/apps/rehash.c b/deps/openssl/openssl/apps/rehash.c index 2b769fbceb87ef..fc1dffe974976d 100644 --- a/deps/openssl/openssl/apps/rehash.c +++ b/deps/openssl/openssl/apps/rehash.c @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2013-2014 Timo Teräs * * Licensed under the OpenSSL license (the "License"). You may not use @@ -274,11 +274,19 @@ static int do_file(const char *filename, const char *fullpath, enum Hash h) if (x->x509 != NULL) { type = TYPE_CERT; name = X509_get_subject_name(x->x509); - X509_digest(x->x509, evpmd, digest, NULL); + if (!X509_digest(x->x509, evpmd, digest, NULL)) { + BIO_printf(bio_err, "out of memory\n"); + ++errs; + goto end; + } } else if (x->crl != NULL) { type = TYPE_CRL; name = X509_CRL_get_issuer(x->crl); - X509_CRL_digest(x->crl, evpmd, digest, NULL); + if (!X509_CRL_digest(x->crl, evpmd, digest, NULL)) { + BIO_printf(bio_err, "out of memory\n"); + ++errs; + goto end; + } } else { ++errs; goto end; diff --git a/deps/openssl/openssl/apps/rsa.c b/deps/openssl/openssl/apps/rsa.c index fdd02dce32419a..aeda917cc7686e 100644 --- a/deps/openssl/openssl/apps/rsa.c +++ b/deps/openssl/openssl/apps/rsa.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,23 +8,19 @@ */ #include -#ifdef OPENSSL_NO_RSA -NON_EMPTY_TRANSLATION_UNIT -#else - -# include -# include -# include -# include -# include "apps.h" -# include "progs.h" -# include -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include "apps.h" +#include "progs.h" +#include +#include +#include +#include +#include +#include +#include typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, @@ -53,14 +49,14 @@ const OPTIONS rsa_options[] = { {"modulus", OPT_MODULUS, '-', "Print the RSA key modulus"}, {"check", OPT_CHECK, '-', "Verify key consistency"}, {"", OPT_CIPHER, '-', "Any supported cipher"}, -# if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4) +#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4) {"pvk-strong", OPT_PVK_STRONG, '-', "Enable 'Strong' PVK encoding level (default)"}, {"pvk-weak", OPT_PVK_WEAK, '-', "Enable 'Weak' PVK encoding level"}, {"pvk-none", OPT_PVK_NONE, '-', "Don't enforce PVK encoding"}, -# endif -# ifndef OPENSSL_NO_ENGINE +#endif +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, -# endif +#endif {NULL} }; @@ -75,9 +71,9 @@ int rsa_main(int argc, char **argv) int i, private = 0; int informat = FORMAT_PEM, outformat = FORMAT_PEM, text = 0, check = 0; int noout = 0, modulus = 0, pubin = 0, pubout = 0, ret = 1; -# if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4) +#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4) int pvk_encr = 2; -# endif +#endif OPTION_CHOICE o; prog = opt_init(argc, argv, rsa_options); @@ -130,9 +126,9 @@ int rsa_main(int argc, char **argv) case OPT_PVK_STRONG: /* pvk_encr:= 2 */ case OPT_PVK_WEAK: /* pvk_encr:= 1 */ case OPT_PVK_NONE: /* pvk_encr:= 0 */ -# if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4) +#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4) pvk_encr = (o - OPT_PVK_NONE); -# endif +#endif break; case OPT_NOOUT: noout = 1; @@ -265,7 +261,7 @@ int rsa_main(int argc, char **argv) i = PEM_write_bio_RSAPrivateKey(out, rsa, enc, NULL, 0, NULL, passout); } -# ifndef OPENSSL_NO_DSA +#ifndef OPENSSL_NO_DSA } else if (outformat == FORMAT_MSBLOB || outformat == FORMAT_PVK) { EVP_PKEY *pk; pk = EVP_PKEY_new(); @@ -280,13 +276,13 @@ int rsa_main(int argc, char **argv) goto end; } assert(private); -# ifdef OPENSSL_NO_RC4 +# ifdef OPENSSL_NO_RC4 BIO_printf(bio_err, "PVK format not supported\n"); EVP_PKEY_free(pk); goto end; -# else +# else i = i2b_PVK_bio(out, pk, pvk_encr, 0, passout); -# endif +# endif } else if (pubin || pubout) { i = i2b_PublicKey_bio(out, pk); } else { @@ -294,7 +290,7 @@ int rsa_main(int argc, char **argv) i = i2b_PrivateKey_bio(out, pk); } EVP_PKEY_free(pk); -# endif +#endif } else { BIO_printf(bio_err, "bad output format specified for outfile\n"); goto end; @@ -313,4 +309,3 @@ int rsa_main(int argc, char **argv) OPENSSL_free(passout); return ret; } -#endif diff --git a/deps/openssl/openssl/apps/rsautl.c b/deps/openssl/openssl/apps/rsautl.c index 5da8504d3c061f..0c0fa8eba30ade 100644 --- a/deps/openssl/openssl/apps/rsautl.c +++ b/deps/openssl/openssl/apps/rsautl.c @@ -1,5 +1,5 @@ /* - * Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,25 +8,21 @@ */ #include -#ifdef OPENSSL_NO_RSA -NON_EMPTY_TRANSLATION_UNIT -#else +#include "apps.h" +#include "progs.h" +#include +#include +#include +#include -# include "apps.h" -# include "progs.h" -# include -# include -# include -# include +#define RSA_SIGN 1 +#define RSA_VERIFY 2 +#define RSA_ENCRYPT 3 +#define RSA_DECRYPT 4 -# define RSA_SIGN 1 -# define RSA_VERIFY 2 -# define RSA_ENCRYPT 3 -# define RSA_DECRYPT 4 - -# define KEY_PRIVKEY 1 -# define KEY_PUBKEY 2 -# define KEY_CERT 3 +#define KEY_PRIVKEY 1 +#define KEY_PUBKEY 2 +#define KEY_CERT 3 typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, @@ -60,9 +56,9 @@ const OPTIONS rsautl_options[] = { {"decrypt", OPT_DECRYPT, '-', "Decrypt with private key"}, {"passin", OPT_PASSIN, 's', "Input file pass phrase source"}, OPT_R_OPTIONS, -# ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, -# endif +#endif {NULL} }; @@ -279,4 +275,3 @@ int rsautl_main(int argc, char **argv) OPENSSL_free(passin); return ret; } -#endif diff --git a/deps/openssl/openssl/apps/s_server.c b/deps/openssl/openssl/apps/s_server.c index 2248a432e26814..0ba75999fd286e 100644 --- a/deps/openssl/openssl/apps/s_server.c +++ b/deps/openssl/openssl/apps/s_server.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * Copyright 2005 Nokia. All rights reserved. * @@ -1904,7 +1904,7 @@ int s_server_main(int argc, char *argv[]) BIO_printf(bio_s_out, "Setting secondary ctx parameters\n"); if (sdebug) - ssl_ctx_security_debug(ctx, sdebug); + ssl_ctx_security_debug(ctx2, sdebug); if (session_id_prefix) { if (strlen(session_id_prefix) >= 32) diff --git a/deps/openssl/openssl/apps/s_time.c b/deps/openssl/openssl/apps/s_time.c index 82d40a5a513246..628e65b26e19c0 100644 --- a/deps/openssl/openssl/apps/s_time.c +++ b/deps/openssl/openssl/apps/s_time.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -62,6 +62,7 @@ const OPTIONS s_time_options[] = { {"key", OPT_KEY, '<', "File with key, PEM; default is -cert file"}, {"CApath", OPT_CAPATH, '/', "PEM format directory of CA's"}, {"cafile", OPT_CAFILE, '<', "PEM format file of CA's"}, + {"CAfile", OPT_CAFILE, '<', "PEM format file of CA's"}, {"no-CAfile", OPT_NOCAFILE, '-', "Do not load the default certificates file"}, {"no-CApath", OPT_NOCAPATH, '-', diff --git a/deps/openssl/openssl/apps/srp.c b/deps/openssl/openssl/apps/srp.c index 689574a4854c84..6c58173879739f 100644 --- a/deps/openssl/openssl/apps/srp.c +++ b/deps/openssl/openssl/apps/srp.c @@ -1,5 +1,5 @@ /* - * Copyright 2004-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2004-2020 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2004, EdelKey Project. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use @@ -12,28 +12,24 @@ */ #include -#ifdef OPENSSL_NO_SRP -NON_EMPTY_TRANSLATION_UNIT -#else +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "apps.h" +#include "progs.h" -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include "apps.h" -# include "progs.h" +#define BASE_SECTION "srp" +#define CONFIG_FILE "openssl.cnf" -# define BASE_SECTION "srp" -# define CONFIG_FILE "openssl.cnf" - -# define ENV_DATABASE "srpvfile" -# define ENV_DEFAULT_SRP "default_srp" +#define ENV_DATABASE "srpvfile" +#define ENV_DEFAULT_SRP "default_srp" static int get_index(CA_DB *db, char *id, char type) { @@ -212,9 +208,9 @@ const OPTIONS srp_options[] = { {"passin", OPT_PASSIN, 's', "Input file pass phrase source"}, {"passout", OPT_PASSOUT, 's', "Output file pass phrase source"}, OPT_R_OPTIONS, -# ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, -# endif +#endif {NULL} }; @@ -610,4 +606,3 @@ int srp_main(int argc, char **argv) release_engine(e); return ret; } -#endif diff --git a/deps/openssl/openssl/apps/ts.c b/deps/openssl/openssl/apps/ts.c index 44a8f75d4a370b..66a0c810e0c301 100644 --- a/deps/openssl/openssl/apps/ts.c +++ b/deps/openssl/openssl/apps/ts.c @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,29 +8,26 @@ */ #include -#ifdef OPENSSL_NO_TS -NON_EMPTY_TRANSLATION_UNIT -#else -# include -# include -# include -# include "apps.h" -# include "progs.h" -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include "apps.h" +#include "progs.h" +#include +#include +#include +#include +#include +#include /* Request nonce length, in bits (must be a multiple of 8). */ -# define NONCE_LENGTH 64 +#define NONCE_LENGTH 64 /* Name of config entry that defines the OID file. */ -# define ENV_OID_FILE "oid_file" +#define ENV_OID_FILE "oid_file" /* Is |EXACTLY_ONE| of three pointers set? */ -# define EXACTLY_ONE(a, b, c) \ +#define EXACTLY_ONE(a, b, c) \ (( a && !b && !c) || \ ( b && !a && !c) || \ ( c && !a && !b)) @@ -114,9 +111,9 @@ const OPTIONS ts_options[] = { {"CAfile", OPT_CAFILE, '<', "File with trusted CA certs"}, {"untrusted", OPT_UNTRUSTED, '<', "File with untrusted certs"}, {"", OPT_MD, '-', "Any supported digest"}, -# ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, -# endif +#endif {OPT_HELP_STR, 1, '-', "\nOptions specific to 'ts -verify': \n"}, OPT_V_OPTIONS, {OPT_HELP_STR, 1, '-', "\n"}, @@ -137,11 +134,11 @@ static char* opt_helplist[] = { " [-signer tsa_cert.pem] [-inkey private_key.pem]", " [-chain certs_file.pem] [-tspolicy oid]", " [-in file] [-token_in] [-out file] [-token_out]", -# ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE " [-text] [-engine id]", -# else +#else " [-text]", -# endif +#endif " or", "ts -verify -CApath dir -CAfile file.pem -untrusted file.pem", " [-data file] [-digest hexstring]", @@ -682,10 +679,10 @@ static TS_RESP *create_response(CONF *conf, const char *section, const char *eng goto end; if (!TS_CONF_set_serial(conf, section, serial_cb, resp_ctx)) goto end; -# ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE if (!TS_CONF_set_crypto_device(conf, section, engine)) goto end; -# endif +#endif if (!TS_CONF_set_signer_cert(conf, section, signer, resp_ctx)) goto end; if (!TS_CONF_set_certs(conf, section, chain, resp_ctx)) @@ -984,4 +981,3 @@ static int verify_cb(int ok, X509_STORE_CTX *ctx) { return ok; } -#endif /* ndef OPENSSL_NO_TS */ diff --git a/deps/openssl/openssl/crypto/aes/aes_core.c b/deps/openssl/openssl/crypto/aes/aes_core.c index e3e688f528a5d5..687dd5829baaf4 100644 --- a/deps/openssl/openssl/crypto/aes/aes_core.c +++ b/deps/openssl/openssl/crypto/aes/aes_core.c @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -43,7 +43,988 @@ #include #include "aes_local.h" -#ifndef AES_ASM +#if defined(OPENSSL_AES_CONST_TIME) && !defined(AES_ASM) +typedef union { + unsigned char b[8]; + u32 w[2]; + u64 d; +} uni; + +/* + * Compute w := (w * x) mod (x^8 + x^4 + x^3 + x^1 + 1) + * Therefore the name "xtime". + */ +static void XtimeWord(u32 *w) +{ + u32 a, b; + + a = *w; + b = a & 0x80808080u; + a ^= b; + b -= b >> 7; + b &= 0x1B1B1B1Bu; + b ^= a << 1; + *w = b; +} + +static void XtimeLong(u64 *w) +{ + u64 a, b; + + a = *w; + b = a & 0x8080808080808080uLL; + a ^= b; + b -= b >> 7; + b &= 0x1B1B1B1B1B1B1B1BuLL; + b ^= a << 1; + *w = b; +} + +/* + * This computes w := S * w ^ -1 + c, where c = {01100011}. + * Instead of using GF(2^8) mod (x^8+x^4+x^3+x+1} we do the inversion + * in GF(GF(GF(2^2)^2)^2) mod (X^2+X+8) + * and GF(GF(2^2)^2) mod (X^2+X+2) + * and GF(2^2) mod (X^2+X+1) + * The first part of the algorithm below transfers the coordinates + * {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80} => + * {1,Y,Y^2,Y^3,Y^4,Y^5,Y^6,Y^7} with Y=0x41: + * {0x01,0x41,0x66,0x6c,0x56,0x9a,0x58,0xc4} + * The last part undoes the coordinate transfer and the final affine + * transformation S: + * b[i] = b[i] + b[(i+4)%8] + b[(i+5)%8] + b[(i+6)%8] + b[(i+7)%8] + c[i] + * in one step. + * The multiplication in GF(2^2^2^2) is done in ordinary coords: + * A = (a0*1 + a1*x^4) + * B = (b0*1 + b1*x^4) + * AB = ((a0*b0 + 8*a1*b1)*1 + (a1*b0 + (a0+a1)*b1)*x^4) + * When A = (a0,a1) is given we want to solve AB = 1: + * (a) 1 = a0*b0 + 8*a1*b1 + * (b) 0 = a1*b0 + (a0+a1)*b1 + * => multiply (a) by a1 and (b) by a0 + * (c) a1 = a1*a0*b0 + (8*a1*a1)*b1 + * (d) 0 = a1*a0*b0 + (a0*a0+a1*a0)*b1 + * => add (c) + (d) + * (e) a1 = (a0*a0 + a1*a0 + 8*a1*a1)*b1 + * => therefore + * b1 = (a0*a0 + a1*a0 + 8*a1*a1)^-1 * a1 + * => and adding (a1*b0) to (b) we get + * (f) a1*b0 = (a0+a1)*b1 + * => therefore + * b0 = (a0*a0 + a1*a0 + 8*a1*a1)^-1 * (a0+a1) + * Note this formula also works for the case + * (a0+a1)*a0 + 8*a1*a1 = 0 + * if the inverse element for 0^-1 is mapped to 0. + * Repeat the same for GF(2^2^2) and GF(2^2). + * We get the following algorithm: + * inv8(a0,a1): + * x0 = a0^a1 + * [y0,y1] = mul4([x0,a1],[a0,a1]); (*) + * y1 = mul4(8,y1); + * t = inv4(y0^y1); + * [b0,b1] = mul4([x0,a1],[t,t]); (*) + * return [b0,b1]; + * The non-linear multiplies (*) can be done in parallel at no extra cost. + */ +static void SubWord(u32 *w) +{ + u32 x, y, a1, a2, a3, a4, a5, a6; + + x = *w; + y = ((x & 0xFEFEFEFEu) >> 1) | ((x & 0x01010101u) << 7); + x &= 0xDDDDDDDDu; + x ^= y & 0x57575757u; + y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); + x ^= y & 0x1C1C1C1Cu; + y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); + x ^= y & 0x4A4A4A4Au; + y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); + x ^= y & 0x42424242u; + y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); + x ^= y & 0x64646464u; + y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); + x ^= y & 0xE0E0E0E0u; + a1 = x; + a1 ^= (x & 0xF0F0F0F0u) >> 4; + a2 = ((x & 0xCCCCCCCCu) >> 2) | ((x & 0x33333333u) << 2); + a3 = x & a1; + a3 ^= (a3 & 0xAAAAAAAAu) >> 1; + a3 ^= (((x << 1) & a1) ^ ((a1 << 1) & x)) & 0xAAAAAAAAu; + a4 = a2 & a1; + a4 ^= (a4 & 0xAAAAAAAAu) >> 1; + a4 ^= (((a2 << 1) & a1) ^ ((a1 << 1) & a2)) & 0xAAAAAAAAu; + a5 = (a3 & 0xCCCCCCCCu) >> 2; + a3 ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCu; + a4 = a5 & 0x22222222u; + a4 |= a4 >> 1; + a4 ^= (a5 << 1) & 0x22222222u; + a3 ^= a4; + a5 = a3 & 0xA0A0A0A0u; + a5 |= a5 >> 1; + a5 ^= (a3 << 1) & 0xA0A0A0A0u; + a4 = a5 & 0xC0C0C0C0u; + a6 = a4 >> 2; + a4 ^= (a5 << 2) & 0xC0C0C0C0u; + a5 = a6 & 0x20202020u; + a5 |= a5 >> 1; + a5 ^= (a6 << 1) & 0x20202020u; + a4 |= a5; + a3 ^= a4 >> 4; + a3 &= 0x0F0F0F0Fu; + a2 = a3; + a2 ^= (a3 & 0x0C0C0C0Cu) >> 2; + a4 = a3 & a2; + a4 ^= (a4 & 0x0A0A0A0A0Au) >> 1; + a4 ^= (((a3 << 1) & a2) ^ ((a2 << 1) & a3)) & 0x0A0A0A0Au; + a5 = a4 & 0x08080808u; + a5 |= a5 >> 1; + a5 ^= (a4 << 1) & 0x08080808u; + a4 ^= a5 >> 2; + a4 &= 0x03030303u; + a4 ^= (a4 & 0x02020202u) >> 1; + a4 |= a4 << 2; + a3 = a2 & a4; + a3 ^= (a3 & 0x0A0A0A0Au) >> 1; + a3 ^= (((a2 << 1) & a4) ^ ((a4 << 1) & a2)) & 0x0A0A0A0Au; + a3 |= a3 << 4; + a2 = ((a1 & 0xCCCCCCCCu) >> 2) | ((a1 & 0x33333333u) << 2); + x = a1 & a3; + x ^= (x & 0xAAAAAAAAu) >> 1; + x ^= (((a1 << 1) & a3) ^ ((a3 << 1) & a1)) & 0xAAAAAAAAu; + a4 = a2 & a3; + a4 ^= (a4 & 0xAAAAAAAAu) >> 1; + a4 ^= (((a2 << 1) & a3) ^ ((a3 << 1) & a2)) & 0xAAAAAAAAu; + a5 = (x & 0xCCCCCCCCu) >> 2; + x ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCu; + a4 = a5 & 0x22222222u; + a4 |= a4 >> 1; + a4 ^= (a5 << 1) & 0x22222222u; + x ^= a4; + y = ((x & 0xFEFEFEFEu) >> 1) | ((x & 0x01010101u) << 7); + x &= 0x39393939u; + x ^= y & 0x3F3F3F3Fu; + y = ((y & 0xFCFCFCFCu) >> 2) | ((y & 0x03030303u) << 6); + x ^= y & 0x97979797u; + y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); + x ^= y & 0x9B9B9B9Bu; + y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); + x ^= y & 0x3C3C3C3Cu; + y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); + x ^= y & 0xDDDDDDDDu; + y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); + x ^= y & 0x72727272u; + x ^= 0x63636363u; + *w = x; +} + +static void SubLong(u64 *w) +{ + u64 x, y, a1, a2, a3, a4, a5, a6; + + x = *w; + y = ((x & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((x & 0x0101010101010101uLL) << 7); + x &= 0xDDDDDDDDDDDDDDDDuLL; + x ^= y & 0x5757575757575757uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x1C1C1C1C1C1C1C1CuLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x4A4A4A4A4A4A4A4AuLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x4242424242424242uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x6464646464646464uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0xE0E0E0E0E0E0E0E0uLL; + a1 = x; + a1 ^= (x & 0xF0F0F0F0F0F0F0F0uLL) >> 4; + a2 = ((x & 0xCCCCCCCCCCCCCCCCuLL) >> 2) | ((x & 0x3333333333333333uLL) << 2); + a3 = x & a1; + a3 ^= (a3 & 0xAAAAAAAAAAAAAAAAuLL) >> 1; + a3 ^= (((x << 1) & a1) ^ ((a1 << 1) & x)) & 0xAAAAAAAAAAAAAAAAuLL; + a4 = a2 & a1; + a4 ^= (a4 & 0xAAAAAAAAAAAAAAAAuLL) >> 1; + a4 ^= (((a2 << 1) & a1) ^ ((a1 << 1) & a2)) & 0xAAAAAAAAAAAAAAAAuLL; + a5 = (a3 & 0xCCCCCCCCCCCCCCCCuLL) >> 2; + a3 ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCCCCCCCCCuLL; + a4 = a5 & 0x2222222222222222uLL; + a4 |= a4 >> 1; + a4 ^= (a5 << 1) & 0x2222222222222222uLL; + a3 ^= a4; + a5 = a3 & 0xA0A0A0A0A0A0A0A0uLL; + a5 |= a5 >> 1; + a5 ^= (a3 << 1) & 0xA0A0A0A0A0A0A0A0uLL; + a4 = a5 & 0xC0C0C0C0C0C0C0C0uLL; + a6 = a4 >> 2; + a4 ^= (a5 << 2) & 0xC0C0C0C0C0C0C0C0uLL; + a5 = a6 & 0x2020202020202020uLL; + a5 |= a5 >> 1; + a5 ^= (a6 << 1) & 0x2020202020202020uLL; + a4 |= a5; + a3 ^= a4 >> 4; + a3 &= 0x0F0F0F0F0F0F0F0FuLL; + a2 = a3; + a2 ^= (a3 & 0x0C0C0C0C0C0C0C0CuLL) >> 2; + a4 = a3 & a2; + a4 ^= (a4 & 0x0A0A0A0A0A0A0A0AuLL) >> 1; + a4 ^= (((a3 << 1) & a2) ^ ((a2 << 1) & a3)) & 0x0A0A0A0A0A0A0A0AuLL; + a5 = a4 & 0x0808080808080808uLL; + a5 |= a5 >> 1; + a5 ^= (a4 << 1) & 0x0808080808080808uLL; + a4 ^= a5 >> 2; + a4 &= 0x0303030303030303uLL; + a4 ^= (a4 & 0x0202020202020202uLL) >> 1; + a4 |= a4 << 2; + a3 = a2 & a4; + a3 ^= (a3 & 0x0A0A0A0A0A0A0A0AuLL) >> 1; + a3 ^= (((a2 << 1) & a4) ^ ((a4 << 1) & a2)) & 0x0A0A0A0A0A0A0A0AuLL; + a3 |= a3 << 4; + a2 = ((a1 & 0xCCCCCCCCCCCCCCCCuLL) >> 2) | ((a1 & 0x3333333333333333uLL) << 2); + x = a1 & a3; + x ^= (x & 0xAAAAAAAAAAAAAAAAuLL) >> 1; + x ^= (((a1 << 1) & a3) ^ ((a3 << 1) & a1)) & 0xAAAAAAAAAAAAAAAAuLL; + a4 = a2 & a3; + a4 ^= (a4 & 0xAAAAAAAAAAAAAAAAuLL) >> 1; + a4 ^= (((a2 << 1) & a3) ^ ((a3 << 1) & a2)) & 0xAAAAAAAAAAAAAAAAuLL; + a5 = (x & 0xCCCCCCCCCCCCCCCCuLL) >> 2; + x ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCCCCCCCCCuLL; + a4 = a5 & 0x2222222222222222uLL; + a4 |= a4 >> 1; + a4 ^= (a5 << 1) & 0x2222222222222222uLL; + x ^= a4; + y = ((x & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((x & 0x0101010101010101uLL) << 7); + x &= 0x3939393939393939uLL; + x ^= y & 0x3F3F3F3F3F3F3F3FuLL; + y = ((y & 0xFCFCFCFCFCFCFCFCuLL) >> 2) | ((y & 0x0303030303030303uLL) << 6); + x ^= y & 0x9797979797979797uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x9B9B9B9B9B9B9B9BuLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x3C3C3C3C3C3C3C3CuLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0xDDDDDDDDDDDDDDDDuLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x7272727272727272uLL; + x ^= 0x6363636363636363uLL; + *w = x; +} + +/* + * This computes w := (S^-1 * (w + c))^-1 + */ +static void InvSubLong(u64 *w) +{ + u64 x, y, a1, a2, a3, a4, a5, a6; + + x = *w; + x ^= 0x6363636363636363uLL; + y = ((x & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((x & 0x0101010101010101uLL) << 7); + x &= 0xFDFDFDFDFDFDFDFDuLL; + x ^= y & 0x5E5E5E5E5E5E5E5EuLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0xF3F3F3F3F3F3F3F3uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0xF5F5F5F5F5F5F5F5uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x7878787878787878uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x7777777777777777uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x1515151515151515uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0xA5A5A5A5A5A5A5A5uLL; + a1 = x; + a1 ^= (x & 0xF0F0F0F0F0F0F0F0uLL) >> 4; + a2 = ((x & 0xCCCCCCCCCCCCCCCCuLL) >> 2) | ((x & 0x3333333333333333uLL) << 2); + a3 = x & a1; + a3 ^= (a3 & 0xAAAAAAAAAAAAAAAAuLL) >> 1; + a3 ^= (((x << 1) & a1) ^ ((a1 << 1) & x)) & 0xAAAAAAAAAAAAAAAAuLL; + a4 = a2 & a1; + a4 ^= (a4 & 0xAAAAAAAAAAAAAAAAuLL) >> 1; + a4 ^= (((a2 << 1) & a1) ^ ((a1 << 1) & a2)) & 0xAAAAAAAAAAAAAAAAuLL; + a5 = (a3 & 0xCCCCCCCCCCCCCCCCuLL) >> 2; + a3 ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCCCCCCCCCuLL; + a4 = a5 & 0x2222222222222222uLL; + a4 |= a4 >> 1; + a4 ^= (a5 << 1) & 0x2222222222222222uLL; + a3 ^= a4; + a5 = a3 & 0xA0A0A0A0A0A0A0A0uLL; + a5 |= a5 >> 1; + a5 ^= (a3 << 1) & 0xA0A0A0A0A0A0A0A0uLL; + a4 = a5 & 0xC0C0C0C0C0C0C0C0uLL; + a6 = a4 >> 2; + a4 ^= (a5 << 2) & 0xC0C0C0C0C0C0C0C0uLL; + a5 = a6 & 0x2020202020202020uLL; + a5 |= a5 >> 1; + a5 ^= (a6 << 1) & 0x2020202020202020uLL; + a4 |= a5; + a3 ^= a4 >> 4; + a3 &= 0x0F0F0F0F0F0F0F0FuLL; + a2 = a3; + a2 ^= (a3 & 0x0C0C0C0C0C0C0C0CuLL) >> 2; + a4 = a3 & a2; + a4 ^= (a4 & 0x0A0A0A0A0A0A0A0AuLL) >> 1; + a4 ^= (((a3 << 1) & a2) ^ ((a2 << 1) & a3)) & 0x0A0A0A0A0A0A0A0AuLL; + a5 = a4 & 0x0808080808080808uLL; + a5 |= a5 >> 1; + a5 ^= (a4 << 1) & 0x0808080808080808uLL; + a4 ^= a5 >> 2; + a4 &= 0x0303030303030303uLL; + a4 ^= (a4 & 0x0202020202020202uLL) >> 1; + a4 |= a4 << 2; + a3 = a2 & a4; + a3 ^= (a3 & 0x0A0A0A0A0A0A0A0AuLL) >> 1; + a3 ^= (((a2 << 1) & a4) ^ ((a4 << 1) & a2)) & 0x0A0A0A0A0A0A0A0AuLL; + a3 |= a3 << 4; + a2 = ((a1 & 0xCCCCCCCCCCCCCCCCuLL) >> 2) | ((a1 & 0x3333333333333333uLL) << 2); + x = a1 & a3; + x ^= (x & 0xAAAAAAAAAAAAAAAAuLL) >> 1; + x ^= (((a1 << 1) & a3) ^ ((a3 << 1) & a1)) & 0xAAAAAAAAAAAAAAAAuLL; + a4 = a2 & a3; + a4 ^= (a4 & 0xAAAAAAAAAAAAAAAAuLL) >> 1; + a4 ^= (((a2 << 1) & a3) ^ ((a3 << 1) & a2)) & 0xAAAAAAAAAAAAAAAAuLL; + a5 = (x & 0xCCCCCCCCCCCCCCCCuLL) >> 2; + x ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCCCCCCCCCuLL; + a4 = a5 & 0x2222222222222222uLL; + a4 |= a4 >> 1; + a4 ^= (a5 << 1) & 0x2222222222222222uLL; + x ^= a4; + y = ((x & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((x & 0x0101010101010101uLL) << 7); + x &= 0xB5B5B5B5B5B5B5B5uLL; + x ^= y & 0x4040404040404040uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x8080808080808080uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x1616161616161616uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0xEBEBEBEBEBEBEBEBuLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x9797979797979797uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0xFBFBFBFBFBFBFBFBuLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x7D7D7D7D7D7D7D7DuLL; + *w = x; +} + +static void ShiftRows(u64 *state) +{ + unsigned char s[4]; + unsigned char *s0; + int r; + + s0 = (unsigned char *)state; + for (r = 0; r < 4; r++) { + s[0] = s0[0*4 + r]; + s[1] = s0[1*4 + r]; + s[2] = s0[2*4 + r]; + s[3] = s0[3*4 + r]; + s0[0*4 + r] = s[(r+0) % 4]; + s0[1*4 + r] = s[(r+1) % 4]; + s0[2*4 + r] = s[(r+2) % 4]; + s0[3*4 + r] = s[(r+3) % 4]; + } +} + +static void InvShiftRows(u64 *state) +{ + unsigned char s[4]; + unsigned char *s0; + int r; + + s0 = (unsigned char *)state; + for (r = 0; r < 4; r++) { + s[0] = s0[0*4 + r]; + s[1] = s0[1*4 + r]; + s[2] = s0[2*4 + r]; + s[3] = s0[3*4 + r]; + s0[0*4 + r] = s[(4-r) % 4]; + s0[1*4 + r] = s[(5-r) % 4]; + s0[2*4 + r] = s[(6-r) % 4]; + s0[3*4 + r] = s[(7-r) % 4]; + } +} + +static void MixColumns(u64 *state) +{ + uni s1; + uni s; + int c; + + for (c = 0; c < 2; c++) { + s1.d = state[c]; + s.d = s1.d; + s.d ^= ((s.d & 0xFFFF0000FFFF0000uLL) >> 16) + | ((s.d & 0x0000FFFF0000FFFFuLL) << 16); + s.d ^= ((s.d & 0xFF00FF00FF00FF00uLL) >> 8) + | ((s.d & 0x00FF00FF00FF00FFuLL) << 8); + s.d ^= s1.d; + XtimeLong(&s1.d); + s.d ^= s1.d; + s.b[0] ^= s1.b[1]; + s.b[1] ^= s1.b[2]; + s.b[2] ^= s1.b[3]; + s.b[3] ^= s1.b[0]; + s.b[4] ^= s1.b[5]; + s.b[5] ^= s1.b[6]; + s.b[6] ^= s1.b[7]; + s.b[7] ^= s1.b[4]; + state[c] = s.d; + } +} + +static void InvMixColumns(u64 *state) +{ + uni s1; + uni s; + int c; + + for (c = 0; c < 2; c++) { + s1.d = state[c]; + s.d = s1.d; + s.d ^= ((s.d & 0xFFFF0000FFFF0000uLL) >> 16) + | ((s.d & 0x0000FFFF0000FFFFuLL) << 16); + s.d ^= ((s.d & 0xFF00FF00FF00FF00uLL) >> 8) + | ((s.d & 0x00FF00FF00FF00FFuLL) << 8); + s.d ^= s1.d; + XtimeLong(&s1.d); + s.d ^= s1.d; + s.b[0] ^= s1.b[1]; + s.b[1] ^= s1.b[2]; + s.b[2] ^= s1.b[3]; + s.b[3] ^= s1.b[0]; + s.b[4] ^= s1.b[5]; + s.b[5] ^= s1.b[6]; + s.b[6] ^= s1.b[7]; + s.b[7] ^= s1.b[4]; + XtimeLong(&s1.d); + s1.d ^= ((s1.d & 0xFFFF0000FFFF0000uLL) >> 16) + | ((s1.d & 0x0000FFFF0000FFFFuLL) << 16); + s.d ^= s1.d; + XtimeLong(&s1.d); + s1.d ^= ((s1.d & 0xFF00FF00FF00FF00uLL) >> 8) + | ((s1.d & 0x00FF00FF00FF00FFuLL) << 8); + s.d ^= s1.d; + state[c] = s.d; + } +} + +static void AddRoundKey(u64 *state, const u64 *w) +{ + state[0] ^= w[0]; + state[1] ^= w[1]; +} + +static void Cipher(const unsigned char *in, unsigned char *out, + const u64 *w, int nr) +{ + u64 state[2]; + int i; + + memcpy(state, in, 16); + + AddRoundKey(state, w); + + for (i = 1; i < nr; i++) { + SubLong(&state[0]); + SubLong(&state[1]); + ShiftRows(state); + MixColumns(state); + AddRoundKey(state, w + i*2); + } + + SubLong(&state[0]); + SubLong(&state[1]); + ShiftRows(state); + AddRoundKey(state, w + nr*2); + + memcpy(out, state, 16); +} + +static void InvCipher(const unsigned char *in, unsigned char *out, + const u64 *w, int nr) + +{ + u64 state[2]; + int i; + + memcpy(state, in, 16); + + AddRoundKey(state, w + nr*2); + + for (i = nr - 1; i > 0; i--) { + InvShiftRows(state); + InvSubLong(&state[0]); + InvSubLong(&state[1]); + AddRoundKey(state, w + i*2); + InvMixColumns(state); + } + + InvShiftRows(state); + InvSubLong(&state[0]); + InvSubLong(&state[1]); + AddRoundKey(state, w); + + memcpy(out, state, 16); +} + +static void RotWord(u32 *x) +{ + unsigned char *w0; + unsigned char tmp; + + w0 = (unsigned char *)x; + tmp = w0[0]; + w0[0] = w0[1]; + w0[1] = w0[2]; + w0[2] = w0[3]; + w0[3] = tmp; +} + +static void KeyExpansion(const unsigned char *key, u64 *w, + int nr, int nk) +{ + u32 rcon; + uni prev; + u32 temp; + int i, n; + + memcpy(w, key, nk*4); + memcpy(&rcon, "\1\0\0\0", 4); + n = nk/2; + prev.d = w[n-1]; + for (i = n; i < (nr+1)*2; i++) { + temp = prev.w[1]; + if (i % n == 0) { + RotWord(&temp); + SubWord(&temp); + temp ^= rcon; + XtimeWord(&rcon); + } else if (nk > 6 && i % n == 2) { + SubWord(&temp); + } + prev.d = w[i-n]; + prev.w[0] ^= temp; + prev.w[1] ^= prev.w[0]; + w[i] = prev.d; + } +} + +/** + * Expand the cipher key into the encryption key schedule. + */ +int AES_set_encrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key) +{ + u64 *rk; + + if (!userKey || !key) + return -1; + if (bits != 128 && bits != 192 && bits != 256) + return -2; + + rk = (u64*)key->rd_key; + + if (bits == 128) + key->rounds = 10; + else if (bits == 192) + key->rounds = 12; + else + key->rounds = 14; + + KeyExpansion(userKey, rk, key->rounds, bits/32); + return 0; +} + +/** + * Expand the cipher key into the decryption key schedule. + */ +int AES_set_decrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key) +{ + return AES_set_encrypt_key(userKey, bits, key); +} + +/* + * Encrypt a single block + * in and out can overlap + */ +void AES_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key) +{ + const u64 *rk; + + assert(in && out && key); + rk = (u64*)key->rd_key; + + Cipher(in, out, rk, key->rounds); +} + +/* + * Decrypt a single block + * in and out can overlap + */ +void AES_decrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key) +{ + const u64 *rk; + + assert(in && out && key); + rk = (u64*)key->rd_key; + + InvCipher(in, out, rk, key->rounds); +} + +# ifndef OPENSSL_SMALL_FOOTPRINT +void AES_ctr32_encrypt(const unsigned char *in, unsigned char *out, + size_t blocks, const AES_KEY *key, + const unsigned char *ivec); + +static void RawToBits(const u8 raw[64], u64 bits[8]) +{ + int i, j; + u64 in, out; + + memset(bits, 0, 64); + for (i = 0; i < 8; i++) { + in = 0; + for (j = 0; j < 8; j++) + in |= ((u64)raw[i * 8 + j]) << (8 * j); + out = in & 0xF0F0F0F00F0F0F0FuLL; + out |= (in & 0x0F0F0F0F00000000uLL) >> 28; + out |= (in & 0x00000000F0F0F0F0uLL) << 28; + in = out & 0xCCCC3333CCCC3333uLL; + in |= (out & 0x3333000033330000uLL) >> 14; + in |= (out & 0x0000CCCC0000CCCCuLL) << 14; + out = in & 0xAA55AA55AA55AA55uLL; + out |= (in & 0x5500550055005500uLL) >> 7; + out |= (in & 0x00AA00AA00AA00AAuLL) << 7; + for (j = 0; j < 8; j++) { + bits[j] |= (out & 0xFFuLL) << (8 * i); + out = out >> 8; + } + } +} + +static void BitsToRaw(const u64 bits[8], u8 raw[64]) +{ + int i, j; + u64 in, out; + + for (i = 0; i < 8; i++) { + in = 0; + for (j = 0; j < 8; j++) + in |= ((bits[j] >> (8 * i)) & 0xFFuLL) << (8 * j); + out = in & 0xF0F0F0F00F0F0F0FuLL; + out |= (in & 0x0F0F0F0F00000000uLL) >> 28; + out |= (in & 0x00000000F0F0F0F0uLL) << 28; + in = out & 0xCCCC3333CCCC3333uLL; + in |= (out & 0x3333000033330000uLL) >> 14; + in |= (out & 0x0000CCCC0000CCCCuLL) << 14; + out = in & 0xAA55AA55AA55AA55uLL; + out |= (in & 0x5500550055005500uLL) >> 7; + out |= (in & 0x00AA00AA00AA00AAuLL) << 7; + for (j = 0; j < 8; j++) { + raw[i * 8 + j] = (u8)out; + out = out >> 8; + } + } +} + +static void BitsXtime(u64 state[8]) +{ + u64 b; + + b = state[7]; + state[7] = state[6]; + state[6] = state[5]; + state[5] = state[4]; + state[4] = state[3] ^ b; + state[3] = state[2] ^ b; + state[2] = state[1]; + state[1] = state[0] ^ b; + state[0] = b; +} + +/* + * This S-box implementation follows a circuit described in + * Boyar and Peralta: "A new combinational logic minimization + * technique with applications to cryptology." + * https://eprint.iacr.org/2009/191.pdf + * + * The math is similar to above, in that it uses + * a tower field of GF(2^2^2^2) but with a different + * basis representation, that is better suited to + * logic designs. + */ +static void BitsSub(u64 state[8]) +{ + u64 x0, x1, x2, x3, x4, x5, x6, x7; + u64 y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11; + u64 y12, y13, y14, y15, y16, y17, y18, y19, y20, y21; + u64 t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11; + u64 t12, t13, t14, t15, t16, t17, t18, t19, t20, t21; + u64 t22, t23, t24, t25, t26, t27, t28, t29, t30, t31; + u64 t32, t33, t34, t35, t36, t37, t38, t39, t40, t41; + u64 t42, t43, t44, t45, t46, t47, t48, t49, t50, t51; + u64 t52, t53, t54, t55, t56, t57, t58, t59, t60, t61; + u64 t62, t63, t64, t65, t66, t67; + u64 z0, z1, z2, z3, z4, z5, z6, z7, z8, z9, z10, z11; + u64 z12, z13, z14, z15, z16, z17; + u64 s0, s1, s2, s3, s4, s5, s6, s7; + + x7 = state[0]; + x6 = state[1]; + x5 = state[2]; + x4 = state[3]; + x3 = state[4]; + x2 = state[5]; + x1 = state[6]; + x0 = state[7]; + y14 = x3 ^ x5; + y13 = x0 ^ x6; + y9 = x0 ^ x3; + y8 = x0 ^ x5; + t0 = x1 ^ x2; + y1 = t0 ^ x7; + y4 = y1 ^ x3; + y12 = y13 ^ y14; + y2 = y1 ^ x0; + y5 = y1 ^ x6; + y3 = y5 ^ y8; + t1 = x4 ^ y12; + y15 = t1 ^ x5; + y20 = t1 ^ x1; + y6 = y15 ^ x7; + y10 = y15 ^ t0; + y11 = y20 ^ y9; + y7 = x7 ^ y11; + y17 = y10 ^ y11; + y19 = y10 ^ y8; + y16 = t0 ^ y11; + y21 = y13 ^ y16; + y18 = x0 ^ y16; + t2 = y12 & y15; + t3 = y3 & y6; + t4 = t3 ^ t2; + t5 = y4 & x7; + t6 = t5 ^ t2; + t7 = y13 & y16; + t8 = y5 & y1; + t9 = t8 ^ t7; + t10 = y2 & y7; + t11 = t10 ^ t7; + t12 = y9 & y11; + t13 = y14 & y17; + t14 = t13 ^ t12; + t15 = y8 & y10; + t16 = t15 ^ t12; + t17 = t4 ^ t14; + t18 = t6 ^ t16; + t19 = t9 ^ t14; + t20 = t11 ^ t16; + t21 = t17 ^ y20; + t22 = t18 ^ y19; + t23 = t19 ^ y21; + t24 = t20 ^ y18; + t25 = t21 ^ t22; + t26 = t21 & t23; + t27 = t24 ^ t26; + t28 = t25 & t27; + t29 = t28 ^ t22; + t30 = t23 ^ t24; + t31 = t22 ^ t26; + t32 = t31 & t30; + t33 = t32 ^ t24; + t34 = t23 ^ t33; + t35 = t27 ^ t33; + t36 = t24 & t35; + t37 = t36 ^ t34; + t38 = t27 ^ t36; + t39 = t29 & t38; + t40 = t25 ^ t39; + t41 = t40 ^ t37; + t42 = t29 ^ t33; + t43 = t29 ^ t40; + t44 = t33 ^ t37; + t45 = t42 ^ t41; + z0 = t44 & y15; + z1 = t37 & y6; + z2 = t33 & x7; + z3 = t43 & y16; + z4 = t40 & y1; + z5 = t29 & y7; + z6 = t42 & y11; + z7 = t45 & y17; + z8 = t41 & y10; + z9 = t44 & y12; + z10 = t37 & y3; + z11 = t33 & y4; + z12 = t43 & y13; + z13 = t40 & y5; + z14 = t29 & y2; + z15 = t42 & y9; + z16 = t45 & y14; + z17 = t41 & y8; + t46 = z15 ^ z16; + t47 = z10 ^ z11; + t48 = z5 ^ z13; + t49 = z9 ^ z10; + t50 = z2 ^ z12; + t51 = z2 ^ z5; + t52 = z7 ^ z8; + t53 = z0 ^ z3; + t54 = z6 ^ z7; + t55 = z16 ^ z17; + t56 = z12 ^ t48; + t57 = t50 ^ t53; + t58 = z4 ^ t46; + t59 = z3 ^ t54; + t60 = t46 ^ t57; + t61 = z14 ^ t57; + t62 = t52 ^ t58; + t63 = t49 ^ t58; + t64 = z4 ^ t59; + t65 = t61 ^ t62; + t66 = z1 ^ t63; + s0 = t59 ^ t63; + s6 = ~(t56 ^ t62); + s7 = ~(t48 ^ t60); + t67 = t64 ^ t65; + s3 = t53 ^ t66; + s4 = t51 ^ t66; + s5 = t47 ^ t65; + s1 = ~(t64 ^ s3); + s2 = ~(t55 ^ t67); + state[0] = s7; + state[1] = s6; + state[2] = s5; + state[3] = s4; + state[4] = s3; + state[5] = s2; + state[6] = s1; + state[7] = s0; +} + +static void BitsShiftRows(u64 state[8]) +{ + u64 s, s0; + int i; + + for (i = 0; i < 8; i++) { + s = state[i]; + s0 = s & 0x1111111111111111uLL; + s0 |= ((s & 0x2220222022202220uLL) >> 4) | ((s & 0x0002000200020002uLL) << 12); + s0 |= ((s & 0x4400440044004400uLL) >> 8) | ((s & 0x0044004400440044uLL) << 8); + s0 |= ((s & 0x8000800080008000uLL) >> 12) | ((s & 0x0888088808880888uLL) << 4); + state[i] = s0; + } +} + +static void BitsMixColumns(u64 state[8]) +{ + u64 s1, s; + u64 s0[8]; + int i; + + for (i = 0; i < 8; i++) { + s1 = state[i]; + s = s1; + s ^= ((s & 0xCCCCCCCCCCCCCCCCuLL) >> 2) | ((s & 0x3333333333333333uLL) << 2); + s ^= ((s & 0xAAAAAAAAAAAAAAAAuLL) >> 1) | ((s & 0x5555555555555555uLL) << 1); + s ^= s1; + s0[i] = s; + } + BitsXtime(state); + for (i = 0; i < 8; i++) { + s1 = state[i]; + s = s0[i]; + s ^= s1; + s ^= ((s1 & 0xEEEEEEEEEEEEEEEEuLL) >> 1) | ((s1 & 0x1111111111111111uLL) << 3); + state[i] = s; + } +} + +static void BitsAddRoundKey(u64 state[8], const u64 key[8]) +{ + int i; + + for (i = 0; i < 8; i++) + state[i] ^= key[i]; +} + +void AES_ctr32_encrypt(const unsigned char *in, unsigned char *out, + size_t blocks, const AES_KEY *key, + const unsigned char *ivec) +{ + struct { + u8 cipher[64]; + u64 state[8]; + u64 rd_key[AES_MAXNR + 1][8]; + } *bs; + u32 ctr32; + int i; + + ctr32 = GETU32(ivec + 12); + if (blocks >= 4 + && (bs = OPENSSL_malloc(sizeof(*bs)))) { + for (i = 0; i < key->rounds + 1; i++) { + memcpy(bs->cipher + 0, &key->rd_key[4 * i], 16); + memcpy(bs->cipher + 16, bs->cipher, 16); + memcpy(bs->cipher + 32, bs->cipher, 32); + RawToBits(bs->cipher, bs->rd_key[i]); + } + while (blocks) { + memcpy(bs->cipher, ivec, 12); + PUTU32(bs->cipher + 12, ctr32); + ctr32++; + memcpy(bs->cipher + 16, ivec, 12); + PUTU32(bs->cipher + 28, ctr32); + ctr32++; + memcpy(bs->cipher + 32, ivec, 12); + PUTU32(bs->cipher + 44, ctr32); + ctr32++; + memcpy(bs->cipher + 48, ivec, 12); + PUTU32(bs->cipher + 60, ctr32); + ctr32++; + RawToBits(bs->cipher, bs->state); + BitsAddRoundKey(bs->state, bs->rd_key[0]); + for (i = 1; i < key->rounds; i++) { + BitsSub(bs->state); + BitsShiftRows(bs->state); + BitsMixColumns(bs->state); + BitsAddRoundKey(bs->state, bs->rd_key[i]); + } + BitsSub(bs->state); + BitsShiftRows(bs->state); + BitsAddRoundKey(bs->state, bs->rd_key[key->rounds]); + BitsToRaw(bs->state, bs->cipher); + for (i = 0; i < 64 && blocks; i++) { + out[i] = in[i] ^ bs->cipher[i]; + if ((i & 15) == 15) + blocks--; + } + in += i; + out += i; + } + OPENSSL_clear_free(bs, sizeof(*bs)); + } else { + unsigned char cipher[16]; + + while (blocks) { + memcpy(cipher, ivec, 12); + PUTU32(cipher + 12, ctr32); + AES_encrypt(cipher, cipher, key); + for (i = 0; i < 16; i++) + out[i] = in[i] ^ cipher[i]; + in += 16; + out += 16; + ctr32++; + blocks--; + } + } +} +# endif +#elif !defined(AES_ASM) /*- Te0[x] = S [x].[02, 01, 01, 03]; Te1[x] = S [x].[03, 02, 01, 01]; diff --git a/deps/openssl/openssl/crypto/aes/aes_local.h b/deps/openssl/openssl/crypto/aes/aes_local.h index cc8456861d928e..a9c0059e52ccbc 100644 --- a/deps/openssl/openssl/crypto/aes/aes_local.h +++ b/deps/openssl/openssl/crypto/aes/aes_local.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -24,6 +24,7 @@ # define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); } # endif +typedef unsigned long long u64; # ifdef AES_LONG typedef unsigned long u32; # else diff --git a/deps/openssl/openssl/crypto/asn1/asn1_lib.c b/deps/openssl/openssl/crypto/asn1/asn1_lib.c index a7d32ae5e2c3cf..366afc5f6c6b52 100644 --- a/deps/openssl/openssl/crypto/asn1/asn1_lib.c +++ b/deps/openssl/openssl/crypto/asn1/asn1_lib.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -268,18 +268,29 @@ ASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *str) return ret; } -int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len) +int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in) { unsigned char *c; const char *data = _data; + size_t len; - if (len < 0) { + if (len_in < 0) { if (data == NULL) return 0; - else - len = strlen(data); + len = strlen(data); + } else { + len = (size_t)len_in; + } + /* + * Verify that the length fits within an integer for assignment to + * str->length below. The additional 1 is subtracted to allow for the + * '\0' terminator even though this isn't strictly necessary. + */ + if (len > INT_MAX - 1) { + ASN1err(0, ASN1_R_TOO_LARGE); + return 0; } - if ((str->length <= len) || (str->data == NULL)) { + if ((size_t)str->length <= len || str->data == NULL) { c = str->data; str->data = OPENSSL_realloc(c, len + 1); if (str->data == NULL) { diff --git a/deps/openssl/openssl/crypto/bio/bss_acpt.c b/deps/openssl/openssl/crypto/bio/bss_acpt.c index b38e47a592f44f..5a2cb50dfc39fe 100644 --- a/deps/openssl/openssl/crypto/bio/bss_acpt.c +++ b/deps/openssl/openssl/crypto/bio/bss_acpt.c @@ -222,10 +222,10 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c) break; case ACPT_S_CREATE_SOCKET: - ret = BIO_socket(BIO_ADDRINFO_family(c->addr_iter), - BIO_ADDRINFO_socktype(c->addr_iter), - BIO_ADDRINFO_protocol(c->addr_iter), 0); - if (ret == (int)INVALID_SOCKET) { + s = BIO_socket(BIO_ADDRINFO_family(c->addr_iter), + BIO_ADDRINFO_socktype(c->addr_iter), + BIO_ADDRINFO_protocol(c->addr_iter), 0); + if (s == (int)INVALID_SOCKET) { SYSerr(SYS_F_SOCKET, get_last_socket_error()); ERR_add_error_data(4, "hostname=", c->param_addr, @@ -233,9 +233,10 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c) BIOerr(BIO_F_ACPT_STATE, BIO_R_UNABLE_TO_CREATE_SOCKET); goto exit_loop; } - c->accept_sock = ret; - b->num = ret; + c->accept_sock = s; + b->num = s; c->state = ACPT_S_LISTEN; + s = -1; break; case ACPT_S_LISTEN: diff --git a/deps/openssl/openssl/crypto/bn/bn_local.h b/deps/openssl/openssl/crypto/bn/bn_local.h index 37228104c640f4..8ad69ccd3639ed 100644 --- a/deps/openssl/openssl/crypto/bn/bn_local.h +++ b/deps/openssl/openssl/crypto/bn/bn_local.h @@ -1,5 +1,5 @@ /* - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -654,9 +654,6 @@ BIGNUM *int_bn_mod_inverse(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx, int *noinv); -int bn_probable_prime_dh(BIGNUM *rnd, int bits, - const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx); - static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits) { if (bits > (INT_MAX - BN_BITS2 + 1)) diff --git a/deps/openssl/openssl/crypto/bn/bn_prime.c b/deps/openssl/openssl/crypto/bn/bn_prime.c index 6d74da26d3c702..d0cf3779fa50d8 100644 --- a/deps/openssl/openssl/crypto/bn/bn_prime.c +++ b/deps/openssl/openssl/crypto/bn/bn_prime.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -22,10 +22,12 @@ static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1, const BIGNUM *a1_odd, int k, BN_CTX *ctx, BN_MONT_CTX *mont); -static int probable_prime(BIGNUM *rnd, int bits, prime_t *mods); -static int probable_prime_dh_safe(BIGNUM *rnd, int bits, - const BIGNUM *add, const BIGNUM *rem, - BN_CTX *ctx); +static int probable_prime(BIGNUM *rnd, int bits, int safe, prime_t *mods); +static int probable_prime_dh(BIGNUM *rnd, int bits, int safe, prime_t *mods, + const BIGNUM *add, const BIGNUM *rem, + BN_CTX *ctx); + +#define square(x) ((BN_ULONG)(x) * (BN_ULONG)(x)) int BN_GENCB_call(BN_GENCB *cb, int a, int b) { @@ -87,16 +89,11 @@ int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, loop: /* make a random number and set the top and bottom bits */ if (add == NULL) { - if (!probable_prime(ret, bits, mods)) + if (!probable_prime(ret, bits, safe, mods)) goto err; } else { - if (safe) { - if (!probable_prime_dh_safe(ret, bits, add, rem, ctx)) - goto err; - } else { - if (!bn_probable_prime_dh(ret, bits, add, rem, ctx)) - goto err; - } + if (!probable_prime_dh(ret, bits, safe, mods, add, rem, ctx)) + goto err; } if (!BN_GENCB_call(cb, 0, c1++)) @@ -272,17 +269,18 @@ static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1, return 1; } -static int probable_prime(BIGNUM *rnd, int bits, prime_t *mods) +static int probable_prime(BIGNUM *rnd, int bits, int safe, prime_t *mods) { int i; BN_ULONG delta; BN_ULONG maxdelta = BN_MASK2 - primes[NUMPRIMES - 1]; - char is_single_word = bits <= BN_BITS2; again: /* TODO: Not all primes are private */ if (!BN_priv_rand(rnd, bits, BN_RAND_TOP_TWO, BN_RAND_BOTTOM_ODD)) return 0; + if (safe && !BN_set_bit(rnd, 1)) + return 0; /* we now have a random number 'rnd' to test. */ for (i = 1; i < NUMPRIMES; i++) { BN_ULONG mod = BN_mod_word(rnd, (BN_ULONG)primes[i]); @@ -290,61 +288,25 @@ static int probable_prime(BIGNUM *rnd, int bits, prime_t *mods) return 0; mods[i] = (prime_t) mod; } - /* - * If bits is so small that it fits into a single word then we - * additionally don't want to exceed that many bits. - */ - if (is_single_word) { - BN_ULONG size_limit; - - if (bits == BN_BITS2) { - /* - * Shifting by this much has undefined behaviour so we do it a - * different way - */ - size_limit = ~((BN_ULONG)0) - BN_get_word(rnd); - } else { - size_limit = (((BN_ULONG)1) << bits) - BN_get_word(rnd) - 1; - } - if (size_limit < maxdelta) - maxdelta = size_limit; - } delta = 0; loop: - if (is_single_word) { - BN_ULONG rnd_word = BN_get_word(rnd); - - /*- - * In the case that the candidate prime is a single word then - * we check that: - * 1) It's greater than primes[i] because we shouldn't reject - * 3 as being a prime number because it's a multiple of - * three. - * 2) That it's not a multiple of a known prime. We don't - * check that rnd-1 is also coprime to all the known - * primes because there aren't many small primes where - * that's true. + for (i = 1; i < NUMPRIMES; i++) { + /* + * check that rnd is a prime and also that + * gcd(rnd-1,primes) == 1 (except for 2) + * do the second check only if we are interested in safe primes + * in the case that the candidate prime is a single word then + * we check only the primes up to sqrt(rnd) */ - for (i = 1; i < NUMPRIMES && primes[i] < rnd_word; i++) { - if ((mods[i] + delta) % primes[i] == 0) { - delta += 2; - if (delta > maxdelta) - goto again; - goto loop; - } - } - } else { - for (i = 1; i < NUMPRIMES; i++) { - /* - * check that rnd is not a prime and also that gcd(rnd-1,primes) - * == 1 (except for 2) - */ - if (((mods[i] + delta) % primes[i]) <= 1) { - delta += 2; - if (delta > maxdelta) - goto again; - goto loop; - } + if (bits <= 31 && delta <= 0x7fffffff + && square(primes[i]) > BN_get_word(rnd) + delta) + break; + if (safe ? (mods[i] + delta) % primes[i] <= 1 + : (mods[i] + delta) % primes[i] == 0) { + delta += safe ? 4 : 2; + if (delta > maxdelta) + goto again; + goto loop; } } if (!BN_add_word(rnd, delta)) @@ -355,16 +317,23 @@ static int probable_prime(BIGNUM *rnd, int bits, prime_t *mods) return 1; } -int bn_probable_prime_dh(BIGNUM *rnd, int bits, - const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx) +static int probable_prime_dh(BIGNUM *rnd, int bits, int safe, prime_t *mods, + const BIGNUM *add, const BIGNUM *rem, + BN_CTX *ctx) { int i, ret = 0; BIGNUM *t1; + BN_ULONG delta; + BN_ULONG maxdelta = BN_MASK2 - primes[NUMPRIMES - 1]; BN_CTX_start(ctx); if ((t1 = BN_CTX_get(ctx)) == NULL) goto err; + if (maxdelta > BN_MASK2 - BN_get_word(add)) + maxdelta = BN_MASK2 - BN_get_word(add); + + again: if (!BN_rand(rnd, bits, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD)) goto err; @@ -375,98 +344,48 @@ int bn_probable_prime_dh(BIGNUM *rnd, int bits, if (!BN_sub(rnd, rnd, t1)) goto err; if (rem == NULL) { - if (!BN_add_word(rnd, 1)) + if (!BN_add_word(rnd, safe ? 3u : 1u)) goto err; } else { if (!BN_add(rnd, rnd, rem)) goto err; } - /* we now have a random number 'rand' to test. */ + if (BN_num_bits(rnd) < bits + || BN_get_word(rnd) < (safe ? 5u : 3u)) { + if (!BN_add(rnd, rnd, add)) + goto err; + } - loop: + /* we now have a random number 'rnd' to test. */ for (i = 1; i < NUMPRIMES; i++) { - /* check that rnd is a prime */ BN_ULONG mod = BN_mod_word(rnd, (BN_ULONG)primes[i]); if (mod == (BN_ULONG)-1) goto err; - if (mod <= 1) { - if (!BN_add(rnd, rnd, add)) - goto err; - goto loop; - } - } - ret = 1; - - err: - BN_CTX_end(ctx); - bn_check_top(rnd); - return ret; -} - -static int probable_prime_dh_safe(BIGNUM *p, int bits, const BIGNUM *padd, - const BIGNUM *rem, BN_CTX *ctx) -{ - int i, ret = 0; - BIGNUM *t1, *qadd, *q; - - bits--; - BN_CTX_start(ctx); - t1 = BN_CTX_get(ctx); - q = BN_CTX_get(ctx); - qadd = BN_CTX_get(ctx); - if (qadd == NULL) - goto err; - - if (!BN_rshift1(qadd, padd)) - goto err; - - if (!BN_rand(q, bits, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD)) - goto err; - - /* we need ((rnd-rem) % add) == 0 */ - if (!BN_mod(t1, q, qadd, ctx)) - goto err; - if (!BN_sub(q, q, t1)) - goto err; - if (rem == NULL) { - if (!BN_add_word(q, 1)) - goto err; - } else { - if (!BN_rshift1(t1, rem)) - goto err; - if (!BN_add(q, q, t1)) - goto err; + mods[i] = (prime_t) mod; } - - /* we now have a random number 'rand' to test. */ - if (!BN_lshift1(p, q)) - goto err; - if (!BN_add_word(p, 1)) - goto err; - + delta = 0; loop: for (i = 1; i < NUMPRIMES; i++) { - /* check that p and q are prime */ - /* - * check that for p and q gcd(p-1,primes) == 1 (except for 2) - */ - BN_ULONG pmod = BN_mod_word(p, (BN_ULONG)primes[i]); - BN_ULONG qmod = BN_mod_word(q, (BN_ULONG)primes[i]); - if (pmod == (BN_ULONG)-1 || qmod == (BN_ULONG)-1) - goto err; - if (pmod == 0 || qmod == 0) { - if (!BN_add(p, p, padd)) - goto err; - if (!BN_add(q, q, qadd)) - goto err; + /* check that rnd is a prime */ + if (bits <= 31 && delta <= 0x7fffffff + && square(primes[i]) > BN_get_word(rnd) + delta) + break; + /* rnd mod p == 1 implies q = (rnd-1)/2 is divisible by p */ + if (safe ? (mods[i] + delta) % primes[i] <= 1 + : (mods[i] + delta) % primes[i] == 0) { + delta += BN_get_word(add); + if (delta > maxdelta) + goto again; goto loop; } } + if (!BN_add_word(rnd, delta)) + goto err; ret = 1; err: BN_CTX_end(ctx); - bn_check_top(p); + bn_check_top(rnd); return ret; } diff --git a/deps/openssl/openssl/crypto/conf/conf_lib.c b/deps/openssl/openssl/crypto/conf/conf_lib.c index 0b7dd26d63b0a0..add1dfa1c18132 100644 --- a/deps/openssl/openssl/crypto/conf/conf_lib.c +++ b/deps/openssl/openssl/crypto/conf/conf_lib.c @@ -1,5 +1,5 @@ /* - * Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -356,8 +356,10 @@ OPENSSL_INIT_SETTINGS *OPENSSL_INIT_new(void) { OPENSSL_INIT_SETTINGS *ret = malloc(sizeof(*ret)); - if (ret != NULL) - memset(ret, 0, sizeof(*ret)); + if (ret == NULL) + return NULL; + + memset(ret, 0, sizeof(*ret)); ret->flags = DEFAULT_CONF_MFLAGS; return ret; diff --git a/deps/openssl/openssl/crypto/ec/ec_asn1.c b/deps/openssl/openssl/crypto/ec/ec_asn1.c index 336afc989d3016..006f9a5dea1781 100644 --- a/deps/openssl/openssl/crypto/ec/ec_asn1.c +++ b/deps/openssl/openssl/crypto/ec/ec_asn1.c @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -1297,5 +1297,7 @@ int ECDSA_size(const EC_KEY *r) i = i2d_ASN1_INTEGER(&bs, NULL); i += i; /* r and s */ ret = ASN1_object_size(1, i, V_ASN1_SEQUENCE); + if (ret < 0) + return 0; return ret; } diff --git a/deps/openssl/openssl/crypto/ec/ec_lib.c b/deps/openssl/openssl/crypto/ec/ec_lib.c index 3554ada82797b9..6832383cad5181 100644 --- a/deps/openssl/openssl/crypto/ec/ec_lib.c +++ b/deps/openssl/openssl/crypto/ec/ec_lib.c @@ -1,5 +1,5 @@ /* - * Copyright 2001-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the OpenSSL license (the "License"). You may not use @@ -1007,14 +1007,14 @@ int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t i = 0; BN_CTX *new_ctx = NULL; - if ((scalar == NULL) && (num == 0)) { - return EC_POINT_set_to_infinity(group, r); - } - if (!ec_point_is_compat(r, group)) { ECerr(EC_F_EC_POINTS_MUL, EC_R_INCOMPATIBLE_OBJECTS); return 0; } + + if (scalar == NULL && num == 0) + return EC_POINT_set_to_infinity(group, r); + for (i = 0; i < num; i++) { if (!ec_point_is_compat(points[i], group)) { ECerr(EC_F_EC_POINTS_MUL, EC_R_INCOMPATIBLE_OBJECTS); diff --git a/deps/openssl/openssl/crypto/ec/ec_mult.c b/deps/openssl/openssl/crypto/ec/ec_mult.c index 7980a6728288d8..9a1e3974ed9e29 100644 --- a/deps/openssl/openssl/crypto/ec/ec_mult.c +++ b/deps/openssl/openssl/crypto/ec/ec_mult.c @@ -1,5 +1,5 @@ /* - * Copyright 2001-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the OpenSSL license (the "License"). You may not use @@ -260,17 +260,10 @@ int ec_scalar_mul_ladder(const EC_GROUP *group, EC_POINT *r, goto err; } - /*- - * Apply coordinate blinding for EC_POINT. - * - * The underlying EC_METHOD can optionally implement this function: - * ec_point_blind_coordinates() returns 0 in case of errors or 1 on - * success or if coordinate blinding is not implemented for this - * group. - */ - if (!ec_point_blind_coordinates(group, p, ctx)) { - ECerr(EC_F_EC_SCALAR_MUL_LADDER, EC_R_POINT_COORDINATES_BLIND_FAILURE); - goto err; + /* ensure input point is in affine coords for ladder step efficiency */ + if (!p->Z_is_one && !EC_POINT_make_affine(group, p, ctx)) { + ECerr(EC_F_EC_SCALAR_MUL_LADDER, ERR_R_EC_LIB); + goto err; } /* Initialize the Montgomery ladder */ @@ -747,6 +740,20 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, if (r_is_at_infinity) { if (!EC_POINT_copy(r, val_sub[i][digit >> 1])) goto err; + + /*- + * Apply coordinate blinding for EC_POINT. + * + * The underlying EC_METHOD can optionally implement this function: + * ec_point_blind_coordinates() returns 0 in case of errors or 1 on + * success or if coordinate blinding is not implemented for this + * group. + */ + if (!ec_point_blind_coordinates(group, r, ctx)) { + ECerr(EC_F_EC_WNAF_MUL, EC_R_POINT_COORDINATES_BLIND_FAILURE); + goto err; + } + r_is_at_infinity = 0; } else { if (!EC_POINT_add diff --git a/deps/openssl/openssl/crypto/ec/ecp_smpl.c b/deps/openssl/openssl/crypto/ec/ecp_smpl.c index b354bfe9ce9ee4..b3110ec89dbe21 100644 --- a/deps/openssl/openssl/crypto/ec/ecp_smpl.c +++ b/deps/openssl/openssl/crypto/ec/ecp_smpl.c @@ -1,5 +1,5 @@ /* - * Copyright 2001-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the OpenSSL license (the "License"). You may not use @@ -1372,6 +1372,7 @@ int ec_GFp_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, * Computes the multiplicative inverse of a in GF(p), storing the result in r. * If a is zero (or equivalent), you'll get a EC_R_CANNOT_INVERT error. * Since we don't have a Mont structure here, SCA hardening is with blinding. + * NB: "a" must be in _decoded_ form. (i.e. field_decode must precede.) */ int ec_GFp_simple_field_inv(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) @@ -1431,112 +1432,133 @@ int ec_GFp_simple_blind_coordinates(const EC_GROUP *group, EC_POINT *p, temp = BN_CTX_get(ctx); if (temp == NULL) { ECerr(EC_F_EC_GFP_SIMPLE_BLIND_COORDINATES, ERR_R_MALLOC_FAILURE); - goto err; + goto end; } - /* make sure lambda is not zero */ + /*- + * Make sure lambda is not zero. + * If the RNG fails, we cannot blind but nevertheless want + * code to continue smoothly and not clobber the error stack. + */ do { - if (!BN_priv_rand_range(lambda, group->field)) { - ECerr(EC_F_EC_GFP_SIMPLE_BLIND_COORDINATES, ERR_R_BN_LIB); - goto err; + ERR_set_mark(); + ret = BN_priv_rand_range(lambda, group->field); + ERR_pop_to_mark(); + if (ret == 0) { + ret = 1; + goto end; } } while (BN_is_zero(lambda)); /* if field_encode defined convert between representations */ - if (group->meth->field_encode != NULL - && !group->meth->field_encode(group, lambda, lambda, ctx)) - goto err; - if (!group->meth->field_mul(group, p->Z, p->Z, lambda, ctx)) - goto err; - if (!group->meth->field_sqr(group, temp, lambda, ctx)) - goto err; - if (!group->meth->field_mul(group, p->X, p->X, temp, ctx)) - goto err; - if (!group->meth->field_mul(group, temp, temp, lambda, ctx)) - goto err; - if (!group->meth->field_mul(group, p->Y, p->Y, temp, ctx)) - goto err; - p->Z_is_one = 0; + if ((group->meth->field_encode != NULL + && !group->meth->field_encode(group, lambda, lambda, ctx)) + || !group->meth->field_mul(group, p->Z, p->Z, lambda, ctx) + || !group->meth->field_sqr(group, temp, lambda, ctx) + || !group->meth->field_mul(group, p->X, p->X, temp, ctx) + || !group->meth->field_mul(group, temp, temp, lambda, ctx) + || !group->meth->field_mul(group, p->Y, p->Y, temp, ctx)) + goto end; + p->Z_is_one = 0; ret = 1; - err: + end: BN_CTX_end(ctx); return ret; } /*- - * Set s := p, r := 2p. + * Input: + * - p: affine coordinates + * + * Output: + * - s := p, r := 2p: blinded projective (homogeneous) coordinates * * For doubling we use Formula 3 from Izu-Takagi "A fast parallel elliptic curve - * multiplication resistant against side channel attacks" appendix, as described - * at + * multiplication resistant against side channel attacks" appendix, described at * https://hyperelliptic.org/EFD/g1p/auto-shortw-xz.html#doubling-dbl-2002-it-2 + * simplified for Z1=1. * - * The input point p will be in randomized Jacobian projective coords: - * x = X/Z**2, y=Y/Z**3 - * - * The output points p, s, and r are converted to standard (homogeneous) - * projective coords: - * x = X/Z, y=Y/Z + * Blinding uses the equivalence relation (\lambda X, \lambda Y, \lambda Z) + * for any non-zero \lambda that holds for projective (homogeneous) coords. */ int ec_GFp_simple_ladder_pre(const EC_GROUP *group, EC_POINT *r, EC_POINT *s, EC_POINT *p, BN_CTX *ctx) { - BIGNUM *t1, *t2, *t3, *t4, *t5, *t6 = NULL; + BIGNUM *t1, *t2, *t3, *t4, *t5 = NULL; - t1 = r->Z; - t2 = r->Y; + t1 = s->Z; + t2 = r->Z; t3 = s->X; t4 = r->X; t5 = s->Y; - t6 = s->Z; - - /* convert p: (X,Y,Z) -> (XZ,Y,Z**3) */ - if (!group->meth->field_mul(group, p->X, p->X, p->Z, ctx) - || !group->meth->field_sqr(group, t1, p->Z, ctx) - || !group->meth->field_mul(group, p->Z, p->Z, t1, ctx) - /* r := 2p */ - || !group->meth->field_sqr(group, t2, p->X, ctx) - || !group->meth->field_sqr(group, t3, p->Z, ctx) - || !group->meth->field_mul(group, t4, t3, group->a, ctx) - || !BN_mod_sub_quick(t5, t2, t4, group->field) - || !BN_mod_add_quick(t2, t2, t4, group->field) - || !group->meth->field_sqr(group, t5, t5, ctx) - || !group->meth->field_mul(group, t6, t3, group->b, ctx) - || !group->meth->field_mul(group, t1, p->X, p->Z, ctx) - || !group->meth->field_mul(group, t4, t1, t6, ctx) - || !BN_mod_lshift_quick(t4, t4, 3, group->field) + + if (!p->Z_is_one /* r := 2p */ + || !group->meth->field_sqr(group, t3, p->X, ctx) + || !BN_mod_sub_quick(t4, t3, group->a, group->field) + || !group->meth->field_sqr(group, t4, t4, ctx) + || !group->meth->field_mul(group, t5, p->X, group->b, ctx) + || !BN_mod_lshift_quick(t5, t5, 3, group->field) /* r->X coord output */ - || !BN_mod_sub_quick(r->X, t5, t4, group->field) - || !group->meth->field_mul(group, t1, t1, t2, ctx) - || !group->meth->field_mul(group, t2, t3, t6, ctx) - || !BN_mod_add_quick(t1, t1, t2, group->field) + || !BN_mod_sub_quick(r->X, t4, t5, group->field) + || !BN_mod_add_quick(t1, t3, group->a, group->field) + || !group->meth->field_mul(group, t2, p->X, t1, ctx) + || !BN_mod_add_quick(t2, group->b, t2, group->field) /* r->Z coord output */ - || !BN_mod_lshift_quick(r->Z, t1, 2, group->field) - || !EC_POINT_copy(s, p)) + || !BN_mod_lshift_quick(r->Z, t2, 2, group->field)) + return 0; + + /* make sure lambda (r->Y here for storage) is not zero */ + do { + if (!BN_priv_rand_range(r->Y, group->field)) + return 0; + } while (BN_is_zero(r->Y)); + + /* make sure lambda (s->Z here for storage) is not zero */ + do { + if (!BN_priv_rand_range(s->Z, group->field)) + return 0; + } while (BN_is_zero(s->Z)); + + /* if field_encode defined convert between representations */ + if (group->meth->field_encode != NULL + && (!group->meth->field_encode(group, r->Y, r->Y, ctx) + || !group->meth->field_encode(group, s->Z, s->Z, ctx))) + return 0; + + /* blind r and s independently */ + if (!group->meth->field_mul(group, r->Z, r->Z, r->Y, ctx) + || !group->meth->field_mul(group, r->X, r->X, r->Y, ctx) + || !group->meth->field_mul(group, s->X, p->X, s->Z, ctx)) /* s := p */ return 0; r->Z_is_one = 0; s->Z_is_one = 0; - p->Z_is_one = 0; return 1; } /*- - * Differential addition-and-doubling using Eq. (9) and (10) from Izu-Takagi + * Input: + * - s, r: projective (homogeneous) coordinates + * - p: affine coordinates + * + * Output: + * - s := r + s, r := 2r: projective (homogeneous) coordinates + * + * Differential addition-and-doubling using Eq. (9) and (10) from Izu-Takagi * "A fast parallel elliptic curve multiplication resistant against side channel * attacks", as described at - * https://hyperelliptic.org/EFD/g1p/auto-shortw-xz.html#ladder-ladd-2002-it-4 + * https://hyperelliptic.org/EFD/g1p/auto-shortw-xz.html#ladder-mladd-2002-it-4 */ int ec_GFp_simple_ladder_step(const EC_GROUP *group, EC_POINT *r, EC_POINT *s, EC_POINT *p, BN_CTX *ctx) { int ret = 0; - BIGNUM *t0, *t1, *t2, *t3, *t4, *t5, *t6, *t7 = NULL; + BIGNUM *t0, *t1, *t2, *t3, *t4, *t5, *t6 = NULL; BN_CTX_start(ctx); t0 = BN_CTX_get(ctx); @@ -1546,50 +1568,47 @@ int ec_GFp_simple_ladder_step(const EC_GROUP *group, t4 = BN_CTX_get(ctx); t5 = BN_CTX_get(ctx); t6 = BN_CTX_get(ctx); - t7 = BN_CTX_get(ctx); - if (t7 == NULL - || !group->meth->field_mul(group, t0, r->X, s->X, ctx) - || !group->meth->field_mul(group, t1, r->Z, s->Z, ctx) - || !group->meth->field_mul(group, t2, r->X, s->Z, ctx) + if (t6 == NULL + || !group->meth->field_mul(group, t6, r->X, s->X, ctx) + || !group->meth->field_mul(group, t0, r->Z, s->Z, ctx) + || !group->meth->field_mul(group, t4, r->X, s->Z, ctx) || !group->meth->field_mul(group, t3, r->Z, s->X, ctx) - || !group->meth->field_mul(group, t4, group->a, t1, ctx) - || !BN_mod_add_quick(t0, t0, t4, group->field) - || !BN_mod_add_quick(t4, t3, t2, group->field) - || !group->meth->field_mul(group, t0, t4, t0, ctx) - || !group->meth->field_sqr(group, t1, t1, ctx) - || !BN_mod_lshift_quick(t7, group->b, 2, group->field) - || !group->meth->field_mul(group, t1, t7, t1, ctx) - || !BN_mod_lshift1_quick(t0, t0, group->field) - || !BN_mod_add_quick(t0, t1, t0, group->field) - || !BN_mod_sub_quick(t1, t2, t3, group->field) - || !group->meth->field_sqr(group, t1, t1, ctx) - || !group->meth->field_mul(group, t3, t1, p->X, ctx) - || !group->meth->field_mul(group, t0, p->Z, t0, ctx) - /* s->X coord output */ - || !BN_mod_sub_quick(s->X, t0, t3, group->field) - /* s->Z coord output */ - || !group->meth->field_mul(group, s->Z, p->Z, t1, ctx) - || !group->meth->field_sqr(group, t3, r->X, ctx) - || !group->meth->field_sqr(group, t2, r->Z, ctx) - || !group->meth->field_mul(group, t4, t2, group->a, ctx) - || !BN_mod_add_quick(t5, r->X, r->Z, group->field) - || !group->meth->field_sqr(group, t5, t5, ctx) - || !BN_mod_sub_quick(t5, t5, t3, group->field) - || !BN_mod_sub_quick(t5, t5, t2, group->field) - || !BN_mod_sub_quick(t6, t3, t4, group->field) - || !group->meth->field_sqr(group, t6, t6, ctx) - || !group->meth->field_mul(group, t0, t2, t5, ctx) - || !group->meth->field_mul(group, t0, t7, t0, ctx) - /* r->X coord output */ - || !BN_mod_sub_quick(r->X, t6, t0, group->field) + || !group->meth->field_mul(group, t5, group->a, t0, ctx) + || !BN_mod_add_quick(t5, t6, t5, group->field) || !BN_mod_add_quick(t6, t3, t4, group->field) - || !group->meth->field_sqr(group, t3, t2, ctx) - || !group->meth->field_mul(group, t7, t3, t7, ctx) - || !group->meth->field_mul(group, t5, t5, t6, ctx) + || !group->meth->field_mul(group, t5, t6, t5, ctx) + || !group->meth->field_sqr(group, t0, t0, ctx) + || !BN_mod_lshift_quick(t2, group->b, 2, group->field) + || !group->meth->field_mul(group, t0, t2, t0, ctx) || !BN_mod_lshift1_quick(t5, t5, group->field) + || !BN_mod_sub_quick(t3, t4, t3, group->field) + /* s->Z coord output */ + || !group->meth->field_sqr(group, s->Z, t3, ctx) + || !group->meth->field_mul(group, t4, s->Z, p->X, ctx) + || !BN_mod_add_quick(t0, t0, t5, group->field) + /* s->X coord output */ + || !BN_mod_sub_quick(s->X, t0, t4, group->field) + || !group->meth->field_sqr(group, t4, r->X, ctx) + || !group->meth->field_sqr(group, t5, r->Z, ctx) + || !group->meth->field_mul(group, t6, t5, group->a, ctx) + || !BN_mod_add_quick(t1, r->X, r->Z, group->field) + || !group->meth->field_sqr(group, t1, t1, ctx) + || !BN_mod_sub_quick(t1, t1, t4, group->field) + || !BN_mod_sub_quick(t1, t1, t5, group->field) + || !BN_mod_sub_quick(t3, t4, t6, group->field) + || !group->meth->field_sqr(group, t3, t3, ctx) + || !group->meth->field_mul(group, t0, t5, t1, ctx) + || !group->meth->field_mul(group, t0, t2, t0, ctx) + /* r->X coord output */ + || !BN_mod_sub_quick(r->X, t3, t0, group->field) + || !BN_mod_add_quick(t3, t4, t6, group->field) + || !group->meth->field_sqr(group, t4, t5, ctx) + || !group->meth->field_mul(group, t4, t4, t2, ctx) + || !group->meth->field_mul(group, t1, t1, t3, ctx) + || !BN_mod_lshift1_quick(t1, t1, group->field) /* r->Z coord output */ - || !BN_mod_add_quick(r->Z, t7, t5, group->field)) + || !BN_mod_add_quick(r->Z, t4, t1, group->field)) goto err; ret = 1; @@ -1600,17 +1619,23 @@ int ec_GFp_simple_ladder_step(const EC_GROUP *group, } /*- + * Input: + * - s, r: projective (homogeneous) coordinates + * - p: affine coordinates + * + * Output: + * - r := (x,y): affine coordinates + * * Recovers the y-coordinate of r using Eq. (8) from Brier-Joye, "Weierstrass - * Elliptic Curves and Side-Channel Attacks", modified to work in projective - * coordinates and return r in Jacobian projective coordinates. + * Elliptic Curves and Side-Channel Attacks", modified to work in mixed + * projective coords, i.e. p is affine and (r,s) in projective (homogeneous) + * coords, and return r in affine coordinates. * - * X4 = two*Y1*X2*Z3*Z2*Z1; - * Y4 = two*b*Z3*SQR(Z2*Z1) + Z3*(a*Z2*Z1+X1*X2)*(X1*Z2+X2*Z1) - X3*SQR(X1*Z2-X2*Z1); - * Z4 = two*Y1*Z3*SQR(Z2)*Z1; + * X4 = two*Y1*X2*Z3*Z2; + * Y4 = two*b*Z3*SQR(Z2) + Z3*(a*Z2+X1*X2)*(X1*Z2+X2) - X3*SQR(X1*Z2-X2); + * Z4 = two*Y1*Z3*SQR(Z2); * * Z4 != 0 because: - * - Z1==0 implies p is at infinity, which would have caused an early exit in - * the caller; * - Z2==0 implies r is at infinity (handled by the BN_is_zero(r->Z) branch); * - Z3==0 implies s is at infinity (handled by the BN_is_zero(s->Z) branch); * - Y1==0 implies p has order 2, so either r or s are infinity and handled by @@ -1627,11 +1652,7 @@ int ec_GFp_simple_ladder_post(const EC_GROUP *group, return EC_POINT_set_to_infinity(group, r); if (BN_is_zero(s->Z)) { - /* (X,Y,Z) -> (XZ,YZ**2,Z) */ - if (!group->meth->field_mul(group, r->X, p->X, p->Z, ctx) - || !group->meth->field_sqr(group, r->Z, p->Z, ctx) - || !group->meth->field_mul(group, r->Y, p->Y, r->Z, ctx) - || !BN_copy(r->Z, p->Z) + if (!EC_POINT_copy(r, p) || !EC_POINT_invert(group, r, ctx)) return 0; return 1; @@ -1647,38 +1668,46 @@ int ec_GFp_simple_ladder_post(const EC_GROUP *group, t6 = BN_CTX_get(ctx); if (t6 == NULL - || !BN_mod_lshift1_quick(t0, p->Y, group->field) - || !group->meth->field_mul(group, t1, r->X, p->Z, ctx) - || !group->meth->field_mul(group, t2, r->Z, s->Z, ctx) - || !group->meth->field_mul(group, t2, t1, t2, ctx) - || !group->meth->field_mul(group, t3, t2, t0, ctx) - || !group->meth->field_mul(group, t2, r->Z, p->Z, ctx) - || !group->meth->field_sqr(group, t4, t2, ctx) - || !BN_mod_lshift1_quick(t5, group->b, group->field) - || !group->meth->field_mul(group, t4, t4, t5, ctx) - || !group->meth->field_mul(group, t6, t2, group->a, ctx) - || !group->meth->field_mul(group, t5, r->X, p->X, ctx) - || !BN_mod_add_quick(t5, t6, t5, group->field) - || !group->meth->field_mul(group, t6, r->Z, p->X, ctx) - || !BN_mod_add_quick(t2, t6, t1, group->field) - || !group->meth->field_mul(group, t5, t5, t2, ctx) - || !BN_mod_sub_quick(t6, t6, t1, group->field) - || !group->meth->field_sqr(group, t6, t6, ctx) - || !group->meth->field_mul(group, t6, t6, s->X, ctx) - || !BN_mod_add_quick(t4, t5, t4, group->field) - || !group->meth->field_mul(group, t4, t4, s->Z, ctx) - || !BN_mod_sub_quick(t4, t4, t6, group->field) - || !group->meth->field_sqr(group, t5, r->Z, ctx) - || !group->meth->field_mul(group, r->Z, p->Z, s->Z, ctx) - || !group->meth->field_mul(group, r->Z, t5, r->Z, ctx) - || !group->meth->field_mul(group, r->Z, r->Z, t0, ctx) - /* t3 := X, t4 := Y */ - /* (X,Y,Z) -> (XZ,YZ**2,Z) */ - || !group->meth->field_mul(group, r->X, t3, r->Z, ctx) + || !BN_mod_lshift1_quick(t4, p->Y, group->field) + || !group->meth->field_mul(group, t6, r->X, t4, ctx) + || !group->meth->field_mul(group, t6, s->Z, t6, ctx) + || !group->meth->field_mul(group, t5, r->Z, t6, ctx) + || !BN_mod_lshift1_quick(t1, group->b, group->field) + || !group->meth->field_mul(group, t1, s->Z, t1, ctx) || !group->meth->field_sqr(group, t3, r->Z, ctx) - || !group->meth->field_mul(group, r->Y, t4, t3, ctx)) + || !group->meth->field_mul(group, t2, t3, t1, ctx) + || !group->meth->field_mul(group, t6, r->Z, group->a, ctx) + || !group->meth->field_mul(group, t1, p->X, r->X, ctx) + || !BN_mod_add_quick(t1, t1, t6, group->field) + || !group->meth->field_mul(group, t1, s->Z, t1, ctx) + || !group->meth->field_mul(group, t0, p->X, r->Z, ctx) + || !BN_mod_add_quick(t6, r->X, t0, group->field) + || !group->meth->field_mul(group, t6, t6, t1, ctx) + || !BN_mod_add_quick(t6, t6, t2, group->field) + || !BN_mod_sub_quick(t0, t0, r->X, group->field) + || !group->meth->field_sqr(group, t0, t0, ctx) + || !group->meth->field_mul(group, t0, t0, s->X, ctx) + || !BN_mod_sub_quick(t0, t6, t0, group->field) + || !group->meth->field_mul(group, t1, s->Z, t4, ctx) + || !group->meth->field_mul(group, t1, t3, t1, ctx) + || (group->meth->field_decode != NULL + && !group->meth->field_decode(group, t1, t1, ctx)) + || !group->meth->field_inv(group, t1, t1, ctx) + || (group->meth->field_encode != NULL + && !group->meth->field_encode(group, t1, t1, ctx)) + || !group->meth->field_mul(group, r->X, t5, t1, ctx) + || !group->meth->field_mul(group, r->Y, t0, t1, ctx)) goto err; + if (group->meth->field_set_to_one != NULL) { + if (!group->meth->field_set_to_one(group, r->Z, ctx)) + goto err; + } else { + if (!BN_one(r->Z)) + goto err; + } + + r->Z_is_one = 1; ret = 1; err: diff --git a/deps/openssl/openssl/crypto/err/openssl.txt b/deps/openssl/openssl/crypto/err/openssl.txt index f5324c6819d8e2..35512f9caf96b0 100644 --- a/deps/openssl/openssl/crypto/err/openssl.txt +++ b/deps/openssl/openssl/crypto/err/openssl.txt @@ -2852,7 +2852,6 @@ SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES:242:unable to load ssl3 md5 routines SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES:243:unable to load ssl3 sha1 routines SSL_R_UNEXPECTED_CCS_MESSAGE:262:unexpected ccs message SSL_R_UNEXPECTED_END_OF_EARLY_DATA:178:unexpected end of early data -SSL_R_UNEXPECTED_EOF_WHILE_READING:294:unexpected eof while reading SSL_R_UNEXPECTED_MESSAGE:244:unexpected message SSL_R_UNEXPECTED_RECORD:245:unexpected record SSL_R_UNINITIALIZED:276:uninitialized diff --git a/deps/openssl/openssl/crypto/evp/e_aes.c b/deps/openssl/openssl/crypto/evp/e_aes.c index 4ebceeb95bb548..38c7cd42deb0c2 100644 --- a/deps/openssl/openssl/crypto/evp/e_aes.c +++ b/deps/openssl/openssl/crypto/evp/e_aes.c @@ -130,6 +130,11 @@ void bsaes_xts_decrypt(const unsigned char *inp, unsigned char *out, size_t len, const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16]); #endif +#if !defined(AES_ASM) && !defined(AES_CTR_ASM) \ + && defined(OPENSSL_AES_CONST_TIME) \ + && !defined(OPENSSL_SMALL_FOOTPRINT) +# define AES_CTR_ASM +#endif #ifdef AES_CTR_ASM void AES_ctr32_encrypt(const unsigned char *in, unsigned char *out, size_t blocks, const AES_KEY *key, diff --git a/deps/openssl/openssl/crypto/ex_data.c b/deps/openssl/openssl/crypto/ex_data.c index 22f3b70edf14e3..0f5a9295056abe 100644 --- a/deps/openssl/openssl/crypto/ex_data.c +++ b/deps/openssl/openssl/crypto/ex_data.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -235,7 +235,7 @@ int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad) return 0; } for (i = 0; i < mx; i++) { - if (storage[i] && storage[i]->new_func) { + if (storage[i] != NULL && storage[i]->new_func != NULL) { ptr = CRYPTO_get_ex_data(ad, i); storage[i]->new_func(obj, ptr, ad, i, storage[i]->argl, storage[i]->argp); @@ -299,7 +299,7 @@ int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, for (i = 0; i < mx; i++) { ptr = CRYPTO_get_ex_data(from, i); - if (storage[i] && storage[i]->dup_func) + if (storage[i] != NULL && storage[i]->dup_func != NULL) if (!storage[i]->dup_func(to, from, &ptr, i, storage[i]->argl, storage[i]->argp)) goto err; diff --git a/deps/openssl/openssl/crypto/pkcs12/p12_crt.c b/deps/openssl/openssl/crypto/pkcs12/p12_crt.c index d43dc3b30cf3a6..bfcae3f697e950 100644 --- a/deps/openssl/openssl/crypto/pkcs12/p12_crt.c +++ b/deps/openssl/openssl/crypto/pkcs12/p12_crt.c @@ -1,5 +1,5 @@ /* - * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -62,7 +62,8 @@ PKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey, X509 * if (pkey && cert) { if (!X509_check_private_key(cert, pkey)) return NULL; - X509_digest(cert, EVP_sha1(), keyid, &keyidlen); + if (!X509_digest(cert, EVP_sha1(), keyid, &keyidlen)) + return NULL; } if (cert) { diff --git a/deps/openssl/openssl/crypto/rand/build.info b/deps/openssl/openssl/crypto/rand/build.info index df9bac67f04ccb..a4e7900bdbffc0 100644 --- a/deps/openssl/openssl/crypto/rand/build.info +++ b/deps/openssl/openssl/crypto/rand/build.info @@ -2,3 +2,5 @@ LIBS=../../libcrypto SOURCE[../../libcrypto]=\ randfile.c rand_lib.c rand_err.c rand_egd.c \ rand_win.c rand_unix.c rand_vms.c drbg_lib.c drbg_ctr.c + +INCLUDE[drbg_ctr.o]=../modes diff --git a/deps/openssl/openssl/crypto/rand/drbg_ctr.c b/deps/openssl/openssl/crypto/rand/drbg_ctr.c index 93b82f34ceda12..0f0ad1b37be475 100644 --- a/deps/openssl/openssl/crypto/rand/drbg_ctr.c +++ b/deps/openssl/openssl/crypto/rand/drbg_ctr.c @@ -1,5 +1,5 @@ /* - * Copyright 2011-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2011-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -12,28 +12,25 @@ #include #include #include -#include "internal/thread_once.h" +#include "modes_local.h" #include "internal/thread_once.h" #include "rand_local.h" + /* * Implementation of NIST SP 800-90A CTR DRBG. */ static void inc_128(RAND_DRBG_CTR *ctr) { - int i; - unsigned char c; - unsigned char *p = &ctr->V[15]; - - for (i = 0; i < 16; i++, p--) { - c = *p; - c++; - *p = c; - if (c != 0) { - /* If we didn't wrap around, we're done. */ - break; - } - } + unsigned char *p = &ctr->V[0]; + u32 n = 16, c = 1; + + do { + --n; + c += p[n]; + p[n] = (u8)c; + c >>= 8; + } while (n); } static void ctr_XOR(RAND_DRBG_CTR *ctr, const unsigned char *in, size_t inlen) diff --git a/deps/openssl/openssl/crypto/threads_win.c b/deps/openssl/openssl/crypto/threads_win.c index ba25d2719aadb3..83dccb84fb6848 100644 --- a/deps/openssl/openssl/crypto/threads_win.c +++ b/deps/openssl/openssl/crypto/threads_win.c @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -155,7 +155,7 @@ int CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b) int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock) { - *ret = InterlockedExchangeAdd(val, amount) + amount; + *ret = (int)InterlockedExchangeAdd((long volatile *)val, (long)amount) + amount; return 1; } diff --git a/deps/openssl/openssl/crypto/ts/ts_rsp_sign.c b/deps/openssl/openssl/crypto/ts/ts_rsp_sign.c index a584ae5f5edde0..041a187da68c6a 100644 --- a/deps/openssl/openssl/crypto/ts/ts_rsp_sign.c +++ b/deps/openssl/openssl/crypto/ts/ts_rsp_sign.c @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -771,7 +771,8 @@ static ESS_CERT_ID *ess_CERT_ID_new_init(X509 *cert, int issuer_needed) X509_check_purpose(cert, -1, 0); if ((cid = ESS_CERT_ID_new()) == NULL) goto err; - X509_digest(cert, EVP_sha1(), cert_sha1, NULL); + if (!X509_digest(cert, EVP_sha1(), cert_sha1, NULL)) + goto err; if (!ASN1_OCTET_STRING_set(cid->hash, cert_sha1, SHA_DIGEST_LENGTH)) goto err; diff --git a/deps/openssl/openssl/crypto/ts/ts_rsp_verify.c b/deps/openssl/openssl/crypto/ts/ts_rsp_verify.c index 086021247c01ca..c2e7abd67f5096 100644 --- a/deps/openssl/openssl/crypto/ts/ts_rsp_verify.c +++ b/deps/openssl/openssl/crypto/ts/ts_rsp_verify.c @@ -1,5 +1,5 @@ /* - * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -289,11 +289,12 @@ static int ts_find_cert(STACK_OF(ESS_CERT_ID) *cert_ids, X509 *cert) if (!cert_ids || !cert) return -1; - X509_digest(cert, EVP_sha1(), cert_sha1, NULL); - /* Recompute SHA1 hash of certificate if necessary (side effect). */ X509_check_purpose(cert, -1, 0); + if (!X509_digest(cert, EVP_sha1(), cert_sha1, NULL)) + return -1; + /* Look for cert in the cert_ids vector. */ for (i = 0; i < sk_ESS_CERT_ID_num(cert_ids); ++i) { ESS_CERT_ID *cid = sk_ESS_CERT_ID_value(cert_ids, i); @@ -326,7 +327,8 @@ static int ts_find_cert_v2(STACK_OF(ESS_CERT_ID_V2) *cert_ids, X509 *cert) else md = EVP_sha256(); - X509_digest(cert, md, cert_digest, &len); + if (!X509_digest(cert, md, cert_digest, &len)) + return -1; if (cid->hash->length != (int)len) return -1; diff --git a/deps/openssl/openssl/crypto/x509/x509_cmp.c b/deps/openssl/openssl/crypto/x509/x509_cmp.c index e06489c3347b94..d1600e1e8ddab4 100644 --- a/deps/openssl/openssl/crypto/x509/x509_cmp.c +++ b/deps/openssl/openssl/crypto/x509/x509_cmp.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -134,9 +134,12 @@ unsigned long X509_subject_name_hash_old(X509 *x) int X509_cmp(const X509 *a, const X509 *b) { int rv; + /* ensure hash is valid */ - X509_check_purpose((X509 *)a, -1, 0); - X509_check_purpose((X509 *)b, -1, 0); + if (X509_check_purpose((X509 *)a, -1, 0) != 1) + return -2; + if (X509_check_purpose((X509 *)b, -1, 0) != 1) + return -2; rv = memcmp(a->sha1_hash, b->sha1_hash, SHA_DIGEST_LENGTH); if (rv) diff --git a/deps/openssl/openssl/crypto/x509/x509_trs.c b/deps/openssl/openssl/crypto/x509/x509_trs.c index 9e199d63e46a31..a10d437735b8df 100644 --- a/deps/openssl/openssl/crypto/x509/x509_trs.c +++ b/deps/openssl/openssl/crypto/x509/x509_trs.c @@ -1,5 +1,5 @@ /* - * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -240,8 +240,9 @@ static int trust_1oid(X509_TRUST *trust, X509 *x, int flags) static int trust_compat(X509_TRUST *trust, X509 *x, int flags) { /* Call for side-effect of computing hash and caching extensions */ - X509_check_purpose(x, -1, 0); - if ((flags & X509_TRUST_NO_SS_COMPAT) == 0 && x->ex_flags & EXFLAG_SS) + if (X509_check_purpose(x, -1, 0) != 1) + return X509_TRUST_UNTRUSTED; + if ((flags & X509_TRUST_NO_SS_COMPAT) == 0 && (x->ex_flags & EXFLAG_SS)) return X509_TRUST_TRUSTED; else return X509_TRUST_UNTRUSTED; diff --git a/deps/openssl/openssl/crypto/x509/x509_vfy.c b/deps/openssl/openssl/crypto/x509/x509_vfy.c index 361954c62ee785..41625e75ad6a65 100644 --- a/deps/openssl/openssl/crypto/x509/x509_vfy.c +++ b/deps/openssl/openssl/crypto/x509/x509_vfy.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -107,12 +107,8 @@ static int null_callback(int ok, X509_STORE_CTX *e) /* Return 1 is a certificate is self signed */ static int cert_self_signed(X509 *x) { - /* - * FIXME: x509v3_cache_extensions() needs to detect more failures and not - * set EXFLAG_SET when that happens. Especially, if the failures are - * parse errors, rather than memory pressure! - */ - X509_check_purpose(x, -1, 0); + if (X509_check_purpose(x, -1, 0) != 1) + return 0; if (x->ex_flags & EXFLAG_SS) return 1; else @@ -512,6 +508,12 @@ static int check_chain_extensions(X509_STORE_CTX *ctx) ret = 1; break; } + if ((x->ex_flags & EXFLAG_CA) == 0 + && x->ex_pathlen != -1 + && (ctx->param->flags & X509_V_FLAG_X509_STRICT)) { + ctx->error = X509_V_ERR_INVALID_EXTENSION; + ret = 0; + } if (ret == 0 && !verify_cb_cert(ctx, x, i, X509_V_OK)) return 0; /* check_purpose() makes the callback as needed */ diff --git a/deps/openssl/openssl/crypto/x509/x_all.c b/deps/openssl/openssl/crypto/x509/x_all.c index 6cccfa99d1a62e..aa5ccba448997d 100644 --- a/deps/openssl/openssl/crypto/x509/x_all.c +++ b/deps/openssl/openssl/crypto/x509/x_all.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -362,7 +362,8 @@ int X509_pubkey_digest(const X509 *data, const EVP_MD *type, int X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md, unsigned int *len) { - if (type == EVP_sha1() && (data->ex_flags & EXFLAG_SET) != 0) { + if (type == EVP_sha1() && (data->ex_flags & EXFLAG_SET) != 0 + && (data->ex_flags & EXFLAG_INVALID) == 0) { /* Asking for SHA1 and we already computed it. */ if (len != NULL) *len = sizeof(data->sha1_hash); @@ -376,7 +377,8 @@ int X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md, int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type, unsigned char *md, unsigned int *len) { - if (type == EVP_sha1() && (data->flags & EXFLAG_SET) != 0) { + if (type == EVP_sha1() && (data->flags & EXFLAG_SET) != 0 + && (data->flags & EXFLAG_INVALID) == 0) { /* Asking for SHA1; always computed in CRL d2i. */ if (len != NULL) *len = sizeof(data->sha1_hash); diff --git a/deps/openssl/openssl/crypto/x509/x_crl.c b/deps/openssl/openssl/crypto/x509/x_crl.c index e864126fef3726..c9762f9e2394af 100644 --- a/deps/openssl/openssl/crypto/x509/x_crl.c +++ b/deps/openssl/openssl/crypto/x509/x_crl.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -17,7 +17,7 @@ static int X509_REVOKED_cmp(const X509_REVOKED *const *a, const X509_REVOKED *const *b); -static void setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp); +static int setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp); ASN1_SEQUENCE(X509_REVOKED) = { ASN1_EMBED(X509_REVOKED,serialNumber, ASN1_INTEGER), @@ -155,7 +155,7 @@ static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, X509_CRL *crl = (X509_CRL *)*pval; STACK_OF(X509_EXTENSION) *exts; X509_EXTENSION *ext; - int idx; + int idx, i; switch (operation) { case ASN1_OP_D2I_PRE: @@ -184,23 +184,35 @@ static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, break; case ASN1_OP_D2I_POST: - X509_CRL_digest(crl, EVP_sha1(), crl->sha1_hash, NULL); + if (!X509_CRL_digest(crl, EVP_sha1(), crl->sha1_hash, NULL)) + crl->flags |= EXFLAG_INVALID; crl->idp = X509_CRL_get_ext_d2i(crl, - NID_issuing_distribution_point, NULL, + NID_issuing_distribution_point, &i, NULL); - if (crl->idp) - setup_idp(crl, crl->idp); + if (crl->idp != NULL) { + if (!setup_idp(crl, crl->idp)) + crl->flags |= EXFLAG_INVALID; + } + else if (i != -1) { + crl->flags |= EXFLAG_INVALID; + } crl->akid = X509_CRL_get_ext_d2i(crl, - NID_authority_key_identifier, NULL, + NID_authority_key_identifier, &i, NULL); + if (crl->akid == NULL && i != -1) + crl->flags |= EXFLAG_INVALID; crl->crl_number = X509_CRL_get_ext_d2i(crl, - NID_crl_number, NULL, NULL); + NID_crl_number, &i, NULL); + if (crl->crl_number == NULL && i != -1) + crl->flags |= EXFLAG_INVALID; crl->base_crl_number = X509_CRL_get_ext_d2i(crl, - NID_delta_crl, NULL, + NID_delta_crl, &i, NULL); + if (crl->base_crl_number == NULL && i != -1) + crl->flags |= EXFLAG_INVALID; /* Delta CRLs must have CRL number */ if (crl->base_crl_number && !crl->crl_number) crl->flags |= EXFLAG_INVALID; @@ -259,9 +271,10 @@ static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, /* Convert IDP into a more convenient form */ -static void setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp) +static int setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp) { int idp_only = 0; + /* Set various flags according to IDP */ crl->idp_flags |= IDP_PRESENT; if (idp->onlyuser > 0) { @@ -292,7 +305,7 @@ static void setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp) crl->idp_reasons &= CRLDP_ALL_REASONS; } - DIST_POINT_set_dpname(idp->distpoint, X509_CRL_get_issuer(crl)); + return DIST_POINT_set_dpname(idp->distpoint, X509_CRL_get_issuer(crl)); } ASN1_SEQUENCE_ref(X509_CRL, crl_cb) = { diff --git a/deps/openssl/openssl/crypto/x509v3/v3_purp.c b/deps/openssl/openssl/crypto/x509v3/v3_purp.c index 3f60c2ea1da336..f023c6489548b5 100644 --- a/deps/openssl/openssl/crypto/x509v3/v3_purp.c +++ b/deps/openssl/openssl/crypto/x509v3/v3_purp.c @@ -1,5 +1,5 @@ /* - * Copyright 1999-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -81,6 +81,8 @@ int X509_check_purpose(X509 *x, int id, int ca) const X509_PURPOSE *pt; x509v3_cache_extensions(x); + if (x->ex_flags & EXFLAG_INVALID) + return -1; /* Return if side-effect only call */ if (id == -1) @@ -300,10 +302,11 @@ int X509_supported_extension(X509_EXTENSION *ex) return 0; } -static void setup_dp(X509 *x, DIST_POINT *dp) +static int setup_dp(X509 *x, DIST_POINT *dp) { X509_NAME *iname = NULL; int i; + if (dp->reasons) { if (dp->reasons->length > 0) dp->dp_reasons = dp->reasons->data[0]; @@ -313,7 +316,7 @@ static void setup_dp(X509 *x, DIST_POINT *dp) } else dp->dp_reasons = CRLDP_ALL_REASONS; if (!dp->distpoint || (dp->distpoint->type != 1)) - return; + return 1; for (i = 0; i < sk_GENERAL_NAME_num(dp->CRLissuer); i++) { GENERAL_NAME *gen = sk_GENERAL_NAME_value(dp->CRLissuer, i); if (gen->type == GEN_DIRNAME) { @@ -324,16 +327,21 @@ static void setup_dp(X509 *x, DIST_POINT *dp) if (!iname) iname = X509_get_issuer_name(x); - DIST_POINT_set_dpname(dp->distpoint, iname); - + return DIST_POINT_set_dpname(dp->distpoint, iname); } -static void setup_crldp(X509 *x) +static int setup_crldp(X509 *x) { int i; - x->crldp = X509_get_ext_d2i(x, NID_crl_distribution_points, NULL, NULL); - for (i = 0; i < sk_DIST_POINT_num(x->crldp); i++) - setup_dp(x, sk_DIST_POINT_value(x->crldp, i)); + + x->crldp = X509_get_ext_d2i(x, NID_crl_distribution_points, &i, NULL); + if (x->crldp == NULL && i != -1) + return 0; + for (i = 0; i < sk_DIST_POINT_num(x->crldp); i++) { + if (!setup_dp(x, sk_DIST_POINT_value(x->crldp, i))) + return 0; + } + return 1; } #define V1_ROOT (EXFLAG_V1|EXFLAG_SS) @@ -366,28 +374,35 @@ static void x509v3_cache_extensions(X509 *x) return; } - X509_digest(x, EVP_sha1(), x->sha1_hash, NULL); + if (!X509_digest(x, EVP_sha1(), x->sha1_hash, NULL)) + x->ex_flags |= EXFLAG_INVALID; /* V1 should mean no extensions ... */ if (!X509_get_version(x)) x->ex_flags |= EXFLAG_V1; /* Handle basic constraints */ - if ((bs = X509_get_ext_d2i(x, NID_basic_constraints, NULL, NULL))) { + if ((bs = X509_get_ext_d2i(x, NID_basic_constraints, &i, NULL))) { if (bs->ca) x->ex_flags |= EXFLAG_CA; if (bs->pathlen) { - if ((bs->pathlen->type == V_ASN1_NEG_INTEGER) - || !bs->ca) { + if (bs->pathlen->type == V_ASN1_NEG_INTEGER) { x->ex_flags |= EXFLAG_INVALID; x->ex_pathlen = 0; - } else + } else { x->ex_pathlen = ASN1_INTEGER_get(bs->pathlen); + if (!bs->ca && x->ex_pathlen != 0) { + x->ex_flags |= EXFLAG_INVALID; + x->ex_pathlen = 0; + } + } } else x->ex_pathlen = -1; BASIC_CONSTRAINTS_free(bs); x->ex_flags |= EXFLAG_BCONS; + } else if (i != -1) { + x->ex_flags |= EXFLAG_INVALID; } /* Handle proxy certificates */ - if ((pci = X509_get_ext_d2i(x, NID_proxyCertInfo, NULL, NULL))) { + if ((pci = X509_get_ext_d2i(x, NID_proxyCertInfo, &i, NULL))) { if (x->ex_flags & EXFLAG_CA || X509_get_ext_by_NID(x, NID_subject_alt_name, -1) >= 0 || X509_get_ext_by_NID(x, NID_issuer_alt_name, -1) >= 0) { @@ -399,9 +414,11 @@ static void x509v3_cache_extensions(X509 *x) x->ex_pcpathlen = -1; PROXY_CERT_INFO_EXTENSION_free(pci); x->ex_flags |= EXFLAG_PROXY; + } else if (i != -1) { + x->ex_flags |= EXFLAG_INVALID; } /* Handle key usage */ - if ((usage = X509_get_ext_d2i(x, NID_key_usage, NULL, NULL))) { + if ((usage = X509_get_ext_d2i(x, NID_key_usage, &i, NULL))) { if (usage->length > 0) { x->ex_kusage = usage->data[0]; if (usage->length > 1) @@ -410,9 +427,11 @@ static void x509v3_cache_extensions(X509 *x) x->ex_kusage = 0; x->ex_flags |= EXFLAG_KUSAGE; ASN1_BIT_STRING_free(usage); + } else if (i != -1) { + x->ex_flags |= EXFLAG_INVALID; } x->ex_xkusage = 0; - if ((extusage = X509_get_ext_d2i(x, NID_ext_key_usage, NULL, NULL))) { + if ((extusage = X509_get_ext_d2i(x, NID_ext_key_usage, &i, NULL))) { x->ex_flags |= EXFLAG_XKUSAGE; for (i = 0; i < sk_ASN1_OBJECT_num(extusage); i++) { switch (OBJ_obj2nid(sk_ASN1_OBJECT_value(extusage, i))) { @@ -455,18 +474,26 @@ static void x509v3_cache_extensions(X509 *x) } } sk_ASN1_OBJECT_pop_free(extusage, ASN1_OBJECT_free); + } else if (i != -1) { + x->ex_flags |= EXFLAG_INVALID; } - if ((ns = X509_get_ext_d2i(x, NID_netscape_cert_type, NULL, NULL))) { + if ((ns = X509_get_ext_d2i(x, NID_netscape_cert_type, &i, NULL))) { if (ns->length > 0) x->ex_nscert = ns->data[0]; else x->ex_nscert = 0; x->ex_flags |= EXFLAG_NSCERT; ASN1_BIT_STRING_free(ns); + } else if (i != -1) { + x->ex_flags |= EXFLAG_INVALID; } - x->skid = X509_get_ext_d2i(x, NID_subject_key_identifier, NULL, NULL); - x->akid = X509_get_ext_d2i(x, NID_authority_key_identifier, NULL, NULL); + x->skid = X509_get_ext_d2i(x, NID_subject_key_identifier, &i, NULL); + if (x->skid == NULL && i != -1) + x->ex_flags |= EXFLAG_INVALID; + x->akid = X509_get_ext_d2i(x, NID_authority_key_identifier, &i, NULL); + if (x->akid == NULL && i != -1) + x->ex_flags |= EXFLAG_INVALID; /* Does subject name match issuer ? */ if (!X509_NAME_cmp(X509_get_subject_name(x), X509_get_issuer_name(x))) { x->ex_flags |= EXFLAG_SI; @@ -475,16 +502,22 @@ static void x509v3_cache_extensions(X509 *x) !ku_reject(x, KU_KEY_CERT_SIGN)) x->ex_flags |= EXFLAG_SS; } - x->altname = X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL); + x->altname = X509_get_ext_d2i(x, NID_subject_alt_name, &i, NULL); + if (x->altname == NULL && i != -1) + x->ex_flags |= EXFLAG_INVALID; x->nc = X509_get_ext_d2i(x, NID_name_constraints, &i, NULL); - if (!x->nc && (i != -1)) + if (x->nc == NULL && i != -1) + x->ex_flags |= EXFLAG_INVALID; + if (!setup_crldp(x)) x->ex_flags |= EXFLAG_INVALID; - setup_crldp(x); #ifndef OPENSSL_NO_RFC3779 - x->rfc3779_addr = X509_get_ext_d2i(x, NID_sbgp_ipAddrBlock, NULL, NULL); - x->rfc3779_asid = X509_get_ext_d2i(x, NID_sbgp_autonomousSysNum, - NULL, NULL); + x->rfc3779_addr = X509_get_ext_d2i(x, NID_sbgp_ipAddrBlock, &i, NULL); + if (x->rfc3779_addr == NULL && i != -1) + x->ex_flags |= EXFLAG_INVALID; + x->rfc3779_asid = X509_get_ext_d2i(x, NID_sbgp_autonomousSysNum, &i, NULL); + if (x->rfc3779_asid == NULL && i != -1) + x->ex_flags |= EXFLAG_INVALID; #endif for (i = 0; i < X509_get_ext_count(x); i++) { ex = X509_get_ext(x, i); @@ -516,9 +549,11 @@ static void x509v3_cache_extensions(X509 *x) * return codes: * 0 not a CA * 1 is a CA - * 2 basicConstraints absent so "maybe" a CA + * 2 Only possible in older versions of openSSL when basicConstraints are absent + * new versions will not return this value. May be a CA * 3 basicConstraints absent but self signed V1. * 4 basicConstraints absent but keyUsage present and keyCertSign asserted. + * 5 Netscape specific CA Flags present */ static int check_ca(const X509 *x) @@ -777,7 +812,11 @@ int X509_check_issued(X509 *issuer, X509 *subject) return X509_V_ERR_SUBJECT_ISSUER_MISMATCH; x509v3_cache_extensions(issuer); + if (issuer->ex_flags & EXFLAG_INVALID) + return X509_V_ERR_UNSPECIFIED; x509v3_cache_extensions(subject); + if (subject->ex_flags & EXFLAG_INVALID) + return X509_V_ERR_UNSPECIFIED; if (subject->akid) { int ret = X509_check_akid(issuer, subject->akid); @@ -842,7 +881,8 @@ uint32_t X509_get_extension_flags(X509 *x) uint32_t X509_get_key_usage(X509 *x) { /* Call for side-effect of computing hash and caching extensions */ - X509_check_purpose(x, -1, -1); + if (X509_check_purpose(x, -1, -1) != 1) + return 0; if (x->ex_flags & EXFLAG_KUSAGE) return x->ex_kusage; return UINT32_MAX; @@ -851,7 +891,8 @@ uint32_t X509_get_key_usage(X509 *x) uint32_t X509_get_extended_key_usage(X509 *x) { /* Call for side-effect of computing hash and caching extensions */ - X509_check_purpose(x, -1, -1); + if (X509_check_purpose(x, -1, -1) != 1) + return 0; if (x->ex_flags & EXFLAG_XKUSAGE) return x->ex_xkusage; return UINT32_MAX; @@ -860,28 +901,32 @@ uint32_t X509_get_extended_key_usage(X509 *x) const ASN1_OCTET_STRING *X509_get0_subject_key_id(X509 *x) { /* Call for side-effect of computing hash and caching extensions */ - X509_check_purpose(x, -1, -1); + if (X509_check_purpose(x, -1, -1) != 1) + return NULL; return x->skid; } const ASN1_OCTET_STRING *X509_get0_authority_key_id(X509 *x) { /* Call for side-effect of computing hash and caching extensions */ - X509_check_purpose(x, -1, -1); + if (X509_check_purpose(x, -1, -1) != 1) + return NULL; return (x->akid != NULL ? x->akid->keyid : NULL); } const GENERAL_NAMES *X509_get0_authority_issuer(X509 *x) { /* Call for side-effect of computing hash and caching extensions */ - X509_check_purpose(x, -1, -1); + if (X509_check_purpose(x, -1, -1) != 1) + return NULL; return (x->akid != NULL ? x->akid->issuer : NULL); } const ASN1_INTEGER *X509_get0_authority_serial(X509 *x) { /* Call for side-effect of computing hash and caching extensions */ - X509_check_purpose(x, -1, -1); + if (X509_check_purpose(x, -1, -1) != 1) + return NULL; return (x->akid != NULL ? x->akid->serial : NULL); } diff --git a/deps/openssl/openssl/doc/man1/s_time.pod b/deps/openssl/openssl/doc/man1/s_time.pod index ac32f36bc78985..e1a3bef41cfc36 100644 --- a/deps/openssl/openssl/doc/man1/s_time.pod +++ b/deps/openssl/openssl/doc/man1/s_time.pod @@ -14,7 +14,7 @@ B B [B<-cert filename>] [B<-key filename>] [B<-CApath directory>] -[B<-cafile filename>] +[B<-CAfile filename>] [B<-no-CAfile>] [B<-no-CApath>] [B<-reuse>] @@ -202,7 +202,7 @@ L, L, L =head1 COPYRIGHT -Copyright 2004-2019 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2004-2020 The OpenSSL Project Authors. All Rights Reserved. Licensed under the OpenSSL license (the "License"). You may not use this file except in compliance with the License. You can obtain a copy diff --git a/deps/openssl/openssl/doc/man3/BN_generate_prime.pod b/deps/openssl/openssl/doc/man3/BN_generate_prime.pod index 31fbc1ffa1743f..f1e63f3b3c4aa9 100644 --- a/deps/openssl/openssl/doc/man3/BN_generate_prime.pod +++ b/deps/openssl/openssl/doc/man3/BN_generate_prime.pod @@ -52,7 +52,9 @@ Deprecated: BN_generate_prime_ex() generates a pseudo-random prime number of at least bit length B. The returned number is probably prime -with a negligible error. +with a negligible error. If B is B the returned prime +number will have exact bit length B with the top most two +bits set. If B is not B, it will be used to store the number. @@ -89,7 +91,9 @@ If B is not B, the prime will fulfill the condition p % B generator. If B is true, it will be a safe prime (i.e. a prime p so -that (p-1)/2 is also prime). +that (p-1)/2 is also prime). If B is true, and B == B +the condition will be p % B == 3. +It is recommended that B is a multiple of 4. The random generator must be seeded prior to calling BN_generate_prime_ex(). If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to @@ -206,7 +210,7 @@ and BN_GENCB_get_arg() functions were added in OpenSSL 1.1.0. =head1 COPYRIGHT -Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved. Licensed under the OpenSSL license (the "License"). You may not use this file except in compliance with the License. You can obtain a copy diff --git a/deps/openssl/openssl/doc/man3/EVP_aes.pod b/deps/openssl/openssl/doc/man3/EVP_aes.pod index 4192a9ec369f90..6377fc9a21b0ab 100644 --- a/deps/openssl/openssl/doc/man3/EVP_aes.pod +++ b/deps/openssl/openssl/doc/man3/EVP_aes.pod @@ -160,6 +160,13 @@ In particular, XTS-AES-128 (B) takes input of a 256-bit key to achieve AES 128-bit security, and XTS-AES-256 (B) takes input of a 512-bit key to achieve AES 256-bit security. +The XTS implementation in OpenSSL does not support streaming. That is there must +only be one L call per L call (and +similarly with the "Decrypt" functions). + +The I parameter to L or L is +the XTS "tweak" value. + =back =head1 RETURN VALUES @@ -176,7 +183,7 @@ L =head1 COPYRIGHT -Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved. Licensed under the OpenSSL license (the "License"). You may not use this file except in compliance with the License. You can obtain a copy diff --git a/deps/openssl/openssl/doc/man3/RAND_set_rand_method.pod b/deps/openssl/openssl/doc/man3/RAND_set_rand_method.pod index b120e712e6f3d7..1e9360d220dce4 100644 --- a/deps/openssl/openssl/doc/man3/RAND_set_rand_method.pod +++ b/deps/openssl/openssl/doc/man3/RAND_set_rand_method.pod @@ -33,10 +33,10 @@ RAND_get_rand_method() returns a pointer to the current B. =head1 THE RAND_METHOD STRUCTURE typedef struct rand_meth_st { - void (*seed)(const void *buf, int num); + int (*seed)(const void *buf, int num); int (*bytes)(unsigned char *buf, int num); void (*cleanup)(void); - void (*add)(const void *buf, int num, int randomness); + int (*add)(const void *buf, int num, double entropy); int (*pseudorand)(unsigned char *buf, int num); int (*status)(void); } RAND_METHOD; @@ -60,7 +60,7 @@ L =head1 COPYRIGHT -Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved. Licensed under the OpenSSL license (the "License"). You may not use this file except in compliance with the License. You can obtain a copy diff --git a/deps/openssl/openssl/doc/man3/SSL_get_error.pod b/deps/openssl/openssl/doc/man3/SSL_get_error.pod index 97320a6c153f6f..5221ccfe18049a 100644 --- a/deps/openssl/openssl/doc/man3/SSL_get_error.pod +++ b/deps/openssl/openssl/doc/man3/SSL_get_error.pod @@ -155,6 +155,18 @@ connection and SSL_shutdown() must not be called. =back +=head1 BUGS + +The B with B value of 0 indicates unexpected EOF from +the peer. This will be properly reported as B with reason +code B in the OpenSSL 3.0 release because +it is truly a TLS protocol error to terminate the connection without +a SSL_shutdown(). + +The issue is kept unfixed in OpenSSL 1.1.1 releases because many applications +which choose to ignore this protocol error depend on the existing way of +reporting the error. + =head1 SEE ALSO L @@ -166,7 +178,7 @@ The SSL_ERROR_WANT_CLIENT_HELLO_CB error code was added in OpenSSL 1.1.1. =head1 COPYRIGHT -Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved. Licensed under the OpenSSL license (the "License"). You may not use this file except in compliance with the License. You can obtain a copy diff --git a/deps/openssl/openssl/doc/man3/X509_check_purpose.pod b/deps/openssl/openssl/doc/man3/X509_check_purpose.pod new file mode 100644 index 00000000000000..bc38138743cdd8 --- /dev/null +++ b/deps/openssl/openssl/doc/man3/X509_check_purpose.pod @@ -0,0 +1,74 @@ +=pod + +=head1 NAME + +X509_check_purpose - Check the purpose of a certificate + +=head1 SYNOPSIS + + #include + + int X509_check_purpose(X509 *x, int id, int ca) + +=head1 DESCRIPTION + +This function checks if certificate I was created with the purpose +represented by I. If I is nonzero, then certificate I is +checked to determine if it's a possible CA with various levels of certainty +possibly returned. + +Below are the potential ID's that can be checked: + + # define X509_PURPOSE_SSL_CLIENT 1 + # define X509_PURPOSE_SSL_SERVER 2 + # define X509_PURPOSE_NS_SSL_SERVER 3 + # define X509_PURPOSE_SMIME_SIGN 4 + # define X509_PURPOSE_SMIME_ENCRYPT 5 + # define X509_PURPOSE_CRL_SIGN 6 + # define X509_PURPOSE_ANY 7 + # define X509_PURPOSE_OCSP_HELPER 8 + # define X509_PURPOSE_TIMESTAMP_SIGN 9 + +=head1 RETURN VALUES + +For non-CA checks + +=over 4 + +=item -1 an error condition has occured + +=item E<32>1 if the certificate was created to perform the purpose represented by I + +=item E<32>0 if the certificate was not created to perform the purpose represented by I + +=back + +For CA checks the below integers could be returned with the following meanings: + +=over 4 + +=item -1 an error condition has occured + +=item E<32>0 not a CA or does not have the purpose represented by I + +=item E<32>1 is a CA. + +=item E<32>2 Only possible in old versions of openSSL when basicConstraints are absent. + New versions will not return this value. May be a CA + +=item E<32>3 basicConstraints absent but self signed V1. + +=item E<32>4 basicConstraints absent but keyUsage present and keyCertSign asserted. + +=item E<32>5 legacy Netscape specific CA Flags present + +=back + +=head1 COPYRIGHT + +Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved. +Licensed under the Apache License 2.0 (the "License"). You may not use this +file except in compliance with the License. You can obtain a copy in the file +LICENSE in the source distribution or at L. + +=cut diff --git a/deps/openssl/openssl/doc/man3/X509_get_extension_flags.pod b/deps/openssl/openssl/doc/man3/X509_get_extension_flags.pod index 2dfe2ef3727582..43c9c952c6b770 100644 --- a/deps/openssl/openssl/doc/man3/X509_get_extension_flags.pod +++ b/deps/openssl/openssl/doc/man3/X509_get_extension_flags.pod @@ -80,6 +80,17 @@ The certificate contains an unhandled critical extension. Some certificate extension values are invalid or inconsistent. The certificate should be rejected. +This bit may also be raised after an out-of-memory error while +processing the X509 object, so it may not be related to the processed +ASN1 object itself. + +=item B + +The NID_certificate_policies certificate extension is invalid or +inconsistent. The certificate should be rejected. +This bit may also be raised after an out-of-memory error while +processing the X509 object, so it may not be related to the processed +ASN1 object itself. =item B @@ -183,7 +194,7 @@ X509_get_proxy_pathlen() were added in OpenSSL 1.1.0. =head1 COPYRIGHT -Copyright 2015-2019 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved. Licensed under the OpenSSL license (the "License"). You may not use this file except in compliance with the License. You can obtain a copy diff --git a/deps/openssl/openssl/include/openssl/opensslv.h b/deps/openssl/openssl/include/openssl/opensslv.h index dd8ef3df722f81..17d271f54c7f52 100644 --- a/deps/openssl/openssl/include/openssl/opensslv.h +++ b/deps/openssl/openssl/include/openssl/opensslv.h @@ -1,5 +1,5 @@ /* - * Copyright 1999-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -39,8 +39,8 @@ extern "C" { * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for * major minor fix final patch/beta) */ -# define OPENSSL_VERSION_NUMBER 0x1010105fL -# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1e 17 Mar 2020" +# define OPENSSL_VERSION_NUMBER 0x1010107fL +# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1g 21 Apr 2020" /*- * The macros below are to be used for shared library (.so, .dll, ...) diff --git a/deps/openssl/openssl/include/openssl/sslerr.h b/deps/openssl/openssl/include/openssl/sslerr.h index 0ef684f3c13192..82983d3c1e99fd 100644 --- a/deps/openssl/openssl/include/openssl/sslerr.h +++ b/deps/openssl/openssl/include/openssl/sslerr.h @@ -734,7 +734,6 @@ int ERR_load_SSL_strings(void); # define SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES 243 # define SSL_R_UNEXPECTED_CCS_MESSAGE 262 # define SSL_R_UNEXPECTED_END_OF_EARLY_DATA 178 -# define SSL_R_UNEXPECTED_EOF_WHILE_READING 294 # define SSL_R_UNEXPECTED_MESSAGE 244 # define SSL_R_UNEXPECTED_RECORD 245 # define SSL_R_UNINITIALIZED 276 diff --git a/deps/openssl/openssl/ssl/record/rec_layer_s3.c b/deps/openssl/openssl/ssl/record/rec_layer_s3.c index 1c885a664f35e3..b2a7a47eb07529 100644 --- a/deps/openssl/openssl/ssl/record/rec_layer_s3.c +++ b/deps/openssl/openssl/ssl/record/rec_layer_s3.c @@ -296,12 +296,6 @@ int ssl3_read_n(SSL *s, size_t n, size_t max, int extend, int clearold, ret = BIO_read(s->rbio, pkt + len + left, max - left); if (ret >= 0) bioread = ret; - if (ret <= 0 - && !BIO_should_retry(s->rbio) - && BIO_eof(s->rbio)) { - SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_SSL3_READ_N, - SSL_R_UNEXPECTED_EOF_WHILE_READING); - } } else { SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_READ_N, SSL_R_READ_BIO_NOT_SET); diff --git a/deps/openssl/openssl/ssl/ssl_err.c b/deps/openssl/openssl/ssl/ssl_err.c index a0c7b79659d4d7..4b12ed1485d985 100644 --- a/deps/openssl/openssl/ssl/ssl_err.c +++ b/deps/openssl/openssl/ssl/ssl_err.c @@ -1,6 +1,6 @@ /* * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -1205,8 +1205,6 @@ static const ERR_STRING_DATA SSL_str_reasons[] = { "unexpected ccs message"}, {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_UNEXPECTED_END_OF_EARLY_DATA), "unexpected end of early data"}, - {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_UNEXPECTED_EOF_WHILE_READING), - "unexpected eof while reading"}, {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_UNEXPECTED_MESSAGE), "unexpected message"}, {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_UNEXPECTED_RECORD), "unexpected record"}, {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_UNINITIALIZED), "uninitialized"}, diff --git a/deps/openssl/openssl/ssl/t1_lib.c b/deps/openssl/openssl/ssl/t1_lib.c index a254fd5a055913..76b4baa38893f8 100644 --- a/deps/openssl/openssl/ssl/t1_lib.c +++ b/deps/openssl/openssl/ssl/t1_lib.c @@ -2130,7 +2130,7 @@ static int tls1_check_sig_alg(SSL *s, X509 *x, int default_nid) sigalg = use_pc_sigalgs ? tls1_lookup_sigalg(s->s3->tmp.peer_cert_sigalgs[i]) : s->shared_sigalgs[i]; - if (sig_nid == sigalg->sigandhash) + if (sigalg != NULL && sig_nid == sigalg->sigandhash) return 1; } return 0; diff --git a/deps/openssl/openssl/test/certs/ee-pathlen.pem b/deps/openssl/openssl/test/certs/ee-pathlen.pem new file mode 100644 index 00000000000000..0bcae1d7bdb91e --- /dev/null +++ b/deps/openssl/openssl/test/certs/ee-pathlen.pem @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICszCCAZugAwIBAgIBAjANBgkqhkiG9w0BAQsFADANMQswCQYDVQQDDAJDQTAg +Fw0yMDA0MDMwODA0MTVaGA8yMTIwMDQwNDA4MDQxNVowGTEXMBUGA1UEAwwOc2Vy +dmVyLmV4YW1wbGUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCo/4lY +YYWu3tssD9Vz++K3qBt6dWAr1H08c3a1rt6TL38kkG3JHPSKOM2fooAWVsu0LLuT +5Rcf/w3GQ/4xNPgo2HXpo7uIgu+jcuJTYgVFTeAxl++qnRDSWA2eBp4yuxsIVl1l +Dz9mjsI2oBH/wFk1/Ukc3RxCMwZ4rgQ4I+XndWfTlK1aqUAfrFkQ9QzBZK1KxMY1 +U7OWaoIbFYvRmavknm+UqtKW5Vf7jJFkijwkFsbSGb6CYBM7YrDtPh2zyvlr3zG5 +ep5LR2inKcc/SuIiJ7TvkGPX79ByST5brbkb1Ctvhmjd1XMSuEPJ3EEPoqNGT4tn +iIQPYf55NB9KiR+3AgMBAAGjEDAOMAwGA1UdEwQFMAMCAQAwDQYJKoZIhvcNAQEL +BQADggEBAApOUnWWd09I0ts3xa1oK7eakc+fKTF4d7pbGznFNONaCR3KFRgnBVlG +Bm8/oehrrQ28Ad3XPSug34DQQ5kM6JIuaddx50/n4Xkgj8/fgXVA0HXizOJ3QpKC +IojLVajXlQHhpo72VUQuNOha0UxG9daYjS20iXRhanTm9rUz7qQZEugVQCiR0z/f +9NgM7FU9UaSidzH3gZu/Ufc4Ggn6nZV7LM9sf4IUV+KszS1VpcK+9phAmsB6BaAi +cFXvVXZjTNualQgPyPwOD8c+vVCIfIemfF5TZ6fyqpOjprWQAphwrTtfNDSmqRTz +FRhDf+vJERQclgUtg37EgWGKtnNQeRY= +-----END CERTIFICATE----- diff --git a/deps/openssl/openssl/test/certs/setup.sh b/deps/openssl/openssl/test/certs/setup.sh index 2d53ea5b08c6cb..bbe4842a5187ae 100755 --- a/deps/openssl/openssl/test/certs/setup.sh +++ b/deps/openssl/openssl/test/certs/setup.sh @@ -154,7 +154,7 @@ openssl x509 -in sca-cert.pem -trustout \ -addtrust anyExtendedKeyUsage -out sca+anyEKU.pem # Primary leaf cert: ee-cert -# ee variants: expired, issuer-key2, issuer-name2 +# ee variants: expired, issuer-key2, issuer-name2, bad-pathlen # trust variants: +serverAuth, -serverAuth, +clientAuth, -clientAuth # purpose variants: client # @@ -163,6 +163,8 @@ openssl x509 -in sca-cert.pem -trustout \ ./mkcert.sh genee server.example ee-key ee-cert2 ca-key2 ca-cert2 ./mkcert.sh genee server.example ee-key ee-name2 ca-key ca-name2 ./mkcert.sh genee -p clientAuth server.example ee-key ee-client ca-key ca-cert +./mkcert.sh genee server.example ee-key ee-pathlen ca-key ca-cert \ + -extfile <(echo "basicConstraints=CA:FALSE,pathlen:0") # openssl x509 -in ee-cert.pem -trustout \ -addtrust serverAuth -out ee+serverAuth.pem diff --git a/deps/openssl/openssl/test/recipes/25-test_verify.t b/deps/openssl/openssl/test/recipes/25-test_verify.t index b80a1cde3edde0..cf7842cdfdd90c 100644 --- a/deps/openssl/openssl/test/recipes/25-test_verify.t +++ b/deps/openssl/openssl/test/recipes/25-test_verify.t @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved. # # Licensed under the OpenSSL license (the "License"). You may not use # this file except in compliance with the License. You can obtain a copy @@ -27,7 +27,7 @@ sub verify { run(app([@args])); } -plan tests => 135; +plan tests => 137; # Canonical success ok(verify("ee-cert", "sslserver", ["root-cert"], ["ca-cert"]), @@ -222,6 +222,10 @@ ok(verify("ee-client", "sslclient", [qw(ee+clientAuth)], [], "-partial_chain"), "accept direct match with client trust"); ok(!verify("ee-client", "sslclient", [qw(ee-clientAuth)], [], "-partial_chain"), "reject direct match with client mistrust"); +ok(verify("ee-pathlen", "sslserver", [qw(root-cert)], [qw(ca-cert)]), + "accept non-ca with pathlen:0 by default"); +ok(!verify("ee-pathlen", "sslserver", [qw(root-cert)], [qw(ca-cert)], "-x509_strict"), + "reject non-ca with pathlen:0 with strict flag"); # Proxy certificates ok(!verify("pc1-cert", "sslclient", [qw(root-cert)], [qw(ee-client ca-cert)]), diff --git a/deps/openssl/openssl/test/recipes/70-test_sslsigalgs.t b/deps/openssl/openssl/test/recipes/70-test_sslsigalgs.t index b3339ff59f9833..9ea9d05219ca24 100644 --- a/deps/openssl/openssl/test/recipes/70-test_sslsigalgs.t +++ b/deps/openssl/openssl/test/recipes/70-test_sslsigalgs.t @@ -44,7 +44,9 @@ use constant { COMPAT_SIGALGS => 6, SIGALGS_CERT_ALL => 7, SIGALGS_CERT_PKCS => 8, - SIGALGS_CERT_INVALID => 9 + SIGALGS_CERT_INVALID => 9, + UNRECOGNIZED_SIGALGS_CERT => 10, + UNRECOGNIZED_SIGALG => 11 }; #Note: Throughout this test we override the default ciphersuites where TLSv1.2 @@ -53,7 +55,7 @@ use constant { #Test 1: Default sig algs should succeed $proxy->start() or plan skip_all => "Unable to start up Proxy for tests"; -plan tests => 24; +plan tests => 26; ok(TLSProxy::Message->success, "Default sigalgs"); my $testtype; @@ -282,6 +284,39 @@ SKIP: { ok(TLSProxy::Message->fail, "No matching certificate for sigalgs_cert"); } +SKIP: { + skip "TLS 1.3 disabled", 2 if disabled("tls1_3"); + #Test 25: Send an unrecognized signature_algorithms_cert + # We should be able to skip over the unrecognized value and use a + # valid one that appears later in the list. + $proxy->clear(); + $proxy->filter(\&inject_unrecognized_sigalg); + $proxy->clientflags("-tls1_3"); + # Use -xcert to get SSL_check_chain() to run in the cert_cb. This is + # needed to trigger (e.g.) CVE-2020-1967 + $proxy->serverflags("" . + " -xcert " . srctop_file("test", "certs", "servercert.pem") . + " -xkey " . srctop_file("test", "certs", "serverkey.pem") . + " -xchain " . srctop_file("test", "certs", "rootcert.pem")); + $testtype = UNRECOGNIZED_SIGALGS_CERT; + $proxy->start(); + ok(TLSProxy::Message->success(), "Unrecognized sigalg_cert in ClientHello"); + + #Test 26: Send an unrecognized signature_algorithms + # We should be able to skip over the unrecognized value and use a + # valid one that appears later in the list. + $proxy->clear(); + $proxy->filter(\&inject_unrecognized_sigalg); + $proxy->clientflags("-tls1_3"); + $proxy->serverflags("" . + " -xcert " . srctop_file("test", "certs", "servercert.pem") . + " -xkey " . srctop_file("test", "certs", "serverkey.pem") . + " -xchain " . srctop_file("test", "certs", "rootcert.pem")); + $testtype = UNRECOGNIZED_SIGALG; + $proxy->start(); + ok(TLSProxy::Message->success(), "Unrecognized sigalg in ClientHello"); +} + sub sigalgs_filter @@ -427,3 +462,30 @@ sub modify_cert_verify_sigalg } } } + +sub inject_unrecognized_sigalg +{ + my $proxy = shift; + my $type; + + # We're only interested in the initial ClientHello + if ($proxy->flight != 0) { + return; + } + if ($testtype == UNRECOGNIZED_SIGALGS_CERT) { + $type = TLSProxy::Message::EXT_SIG_ALGS_CERT; + } elsif ($testtype == UNRECOGNIZED_SIGALG) { + $type = TLSProxy::Message::EXT_SIG_ALGS; + } else { + return; + } + + my $ext = pack "C8", + 0x00, 0x06, #Extension length + 0xfe, 0x18, #private use + 0x04, 0x01, #rsa_pkcs1_sha256 + 0x08, 0x04; #rsa_pss_rsae_sha256; + my $message = ${$proxy->message_list}[0]; + $message->set_extension($type, $ext); + $message->repack; +} diff --git a/deps/openssl/openssl/test/sm2_internal_test.c b/deps/openssl/openssl/test/sm2_internal_test.c index 952f688e8b1448..2bb73947ff3bd6 100644 --- a/deps/openssl/openssl/test/sm2_internal_test.c +++ b/deps/openssl/openssl/test/sm2_internal_test.c @@ -1,5 +1,5 @@ /* - * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -32,17 +32,18 @@ static size_t fake_rand_size = 0; static int get_faked_bytes(unsigned char *buf, int num) { - int i; - if (fake_rand_bytes == NULL) return saved_rand->bytes(buf, num); - if (!TEST_size_t_le(fake_rand_bytes_offset + num, fake_rand_size)) + if (!TEST_size_t_gt(fake_rand_size, 0)) return 0; - for (i = 0; i != num; ++i) - buf[i] = fake_rand_bytes[fake_rand_bytes_offset + i]; - fake_rand_bytes_offset += num; + while (num-- > 0) { + if (fake_rand_bytes_offset >= fake_rand_size) + fake_rand_bytes_offset = 0; + *buf++ = fake_rand_bytes[fake_rand_bytes_offset++]; + } + return 1; } @@ -175,8 +176,7 @@ static int test_sm2_crypt(const EC_GROUP *group, start_fake_rand(k_hex); if (!TEST_true(sm2_encrypt(key, digest, (const uint8_t *)message, msg_len, - ctext, &ctext_len)) - || !TEST_size_t_eq(fake_rand_bytes_offset, fake_rand_size)) { + ctext, &ctext_len))) { restore_rand(); goto done; } @@ -296,8 +296,7 @@ static int test_sm2_sign(const EC_GROUP *group, start_fake_rand(k_hex); sig = sm2_do_sign(key, EVP_sm3(), (const uint8_t *)userid, strlen(userid), (const uint8_t *)message, msg_len); - if (!TEST_ptr(sig) - || !TEST_size_t_eq(fake_rand_bytes_offset, fake_rand_size)) { + if (!TEST_ptr(sig)) { restore_rand(); goto done; } diff --git a/deps/openssl/openssl_no_asm.gypi b/deps/openssl/openssl_no_asm.gypi index 8eb61d970380c3..858c7d895eaee8 100644 --- a/deps/openssl/openssl_no_asm.gypi +++ b/deps/openssl/openssl_no_asm.gypi @@ -13,9 +13,9 @@ 'includes': ['config/archs/linux-ppc64/no-asm/openssl.gypi'], }, 'target_arch=="s390x" and OS=="linux"', { 'includes': ['config/archs/linux64-s390x/no-asm/openssl.gypi'], - }, 'target_arch=="arm" and OS=="linux"', { + }, 'target_arch=="arm" and OS in ("linux", "android")', { 'includes': ['config/archs/linux-armv4/no-asm/openssl.gypi'], - }, 'target_arch=="arm64" and OS=="linux"', { + }, 'target_arch=="arm64" and OS in ("linux", "android")', { 'includes': ['config/archs/linux-aarch64/no-asm/openssl.gypi'], }, 'target_arch=="ia32" and OS=="freebsd"', { 'includes': ['config/archs/BSD-x86/no-asm/openssl.gypi'], diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp index 116b7537195618..fa0a001527d790 100644 --- a/deps/uv/uv.gyp +++ b/deps/uv/uv.gyp @@ -261,6 +261,7 @@ 'src/unix/android-ifaddrs.c', 'src/unix/procfs-exepath.c', 'src/unix/random-getrandom.c', + 'src/unix/random-getentropy.c', 'src/unix/random-sysctl-linux.c', 'src/unix/sysinfo-loadavg.c', ], diff --git a/deps/uvwasi/include/fd_table.h b/deps/uvwasi/include/fd_table.h index fa8a44e7468d41..f29b1adf88d6f0 100644 --- a/deps/uvwasi/include/fd_table.h +++ b/deps/uvwasi/include/fd_table.h @@ -6,6 +6,7 @@ #include "wasi_types.h" struct uvwasi_s; +struct uvwasi_options_s; struct uvwasi_fd_wrap_t { uvwasi_fd_t id; @@ -27,8 +28,7 @@ struct uvwasi_fd_table_t { }; uvwasi_errno_t uvwasi_fd_table_init(struct uvwasi_s* uvwasi, - struct uvwasi_fd_table_t* table, - uint32_t init_size); + struct uvwasi_options_s* options); void uvwasi_fd_table_free(struct uvwasi_s* uvwasi, struct uvwasi_fd_table_t* table); uvwasi_errno_t uvwasi_fd_table_insert(struct uvwasi_s* uvwasi, diff --git a/deps/uvwasi/include/uvwasi.h b/deps/uvwasi/include/uvwasi.h index 9ca30459e23a73..39ee2f0ceb6609 100644 --- a/deps/uvwasi/include/uvwasi.h +++ b/deps/uvwasi/include/uvwasi.h @@ -11,7 +11,7 @@ extern "C" { #define UVWASI_VERSION_MAJOR 0 #define UVWASI_VERSION_MINOR 0 -#define UVWASI_VERSION_PATCH 5 +#define UVWASI_VERSION_PATCH 6 #define UVWASI_VERSION_HEX ((UVWASI_VERSION_MAJOR << 16) | \ (UVWASI_VERSION_MINOR << 8) | \ (UVWASI_VERSION_PATCH)) @@ -60,6 +60,9 @@ typedef struct uvwasi_options_s { size_t argc; char** argv; char** envp; + uvwasi_fd_t in; + uvwasi_fd_t out; + uvwasi_fd_t err; const uvwasi_mem_t* allocator; } uvwasi_options_t; diff --git a/deps/uvwasi/src/clocks.c b/deps/uvwasi/src/clocks.c index e1fbc696b62f05..fd42b9e50e4d8e 100644 --- a/deps/uvwasi/src/clocks.c +++ b/deps/uvwasi/src/clocks.c @@ -6,6 +6,7 @@ #endif /* _WIN32 */ #include "uv.h" +#include "clocks.h" #include "wasi_types.h" #include "uv_mapping.h" diff --git a/deps/uvwasi/src/fd_table.c b/deps/uvwasi/src/fd_table.c index bc32f4dd28bbce..f6e530d9591df2 100644 --- a/deps/uvwasi/src/fd_table.c +++ b/deps/uvwasi/src/fd_table.c @@ -14,6 +14,46 @@ #include "uvwasi_alloc.h" +static uvwasi_errno_t uvwasi__insert_stdio(uvwasi_t* uvwasi, + struct uvwasi_fd_table_t* table, + const uvwasi_fd_t fd, + const uvwasi_fd_t expected, + const char* name) { + struct uvwasi_fd_wrap_t* wrap; + uvwasi_filetype_t type; + uvwasi_rights_t base; + uvwasi_rights_t inheriting; + uvwasi_errno_t err; + + err = uvwasi__get_filetype_by_fd(fd, &type); + if (err != UVWASI_ESUCCESS) + return err; + + err = uvwasi__get_rights(fd, UV_FS_O_RDWR, type, &base, &inheriting); + if (err != UVWASI_ESUCCESS) + return err; + + err = uvwasi_fd_table_insert(uvwasi, + table, + fd, + name, + name, + type, + base, + inheriting, + 0, + &wrap); + if (err != UVWASI_ESUCCESS) + return err; + + if (wrap->id != expected) + err = UVWASI_EBADF; + + uv_mutex_unlock(&wrap->mutex); + return err; +} + + uvwasi_errno_t uvwasi_fd_table_insert(uvwasi_t* uvwasi, struct uvwasi_fd_table_t* table, uv_file fd, @@ -28,7 +68,7 @@ uvwasi_errno_t uvwasi_fd_table_insert(uvwasi_t* uvwasi, struct uvwasi_fd_wrap_t** new_fds; uvwasi_errno_t err; uint32_t new_size; - int index; + uint32_t index; uint32_t i; int r; size_t mp_len; @@ -69,16 +109,17 @@ uvwasi_errno_t uvwasi_fd_table_insert(uvwasi_t* uvwasi, table->size = new_size; } else { /* The table is big enough, so find an empty slot for the new data. */ - index = -1; + int valid_slot = 0; for (i = 0; i < table->size; ++i) { if (table->fds[i] == NULL) { + valid_slot = 1; index = i; break; } } - /* index should never be -1. */ - if (index == -1) { + /* This should never happen. */ + if (valid_slot == 0) { uvwasi__free(uvwasi, entry); err = UVWASI_ENOSPC; goto exit; @@ -116,25 +157,21 @@ uvwasi_errno_t uvwasi_fd_table_insert(uvwasi_t* uvwasi, uvwasi_errno_t uvwasi_fd_table_init(uvwasi_t* uvwasi, - struct uvwasi_fd_table_t* table, - uint32_t init_size) { - struct uvwasi_fd_wrap_t* wrap; - uvwasi_filetype_t type; - uvwasi_rights_t base; - uvwasi_rights_t inheriting; + uvwasi_options_t* options) { + struct uvwasi_fd_table_t* table; uvwasi_errno_t err; - uvwasi_fd_t i; int r; /* Require an initial size of at least three to store the stdio FDs. */ - if (table == NULL || init_size < 3) + if (uvwasi == NULL || options == NULL || options->fd_table_size < 3) return UVWASI_EINVAL; + table = &uvwasi->fds; table->fds = NULL; table->used = 0; - table->size = init_size; + table->size = options->fd_table_size; table->fds = uvwasi__calloc(uvwasi, - init_size, + options->fd_table_size, sizeof(struct uvwasi_fd_wrap_t*)); if (table->fds == NULL) @@ -153,35 +190,17 @@ uvwasi_errno_t uvwasi_fd_table_init(uvwasi_t* uvwasi, } /* Create the stdio FDs. */ - for (i = 0; i < 3; ++i) { - err = uvwasi__get_filetype_by_fd(i, &type); - if (err != UVWASI_ESUCCESS) - goto error_exit; - - err = uvwasi__get_rights(i, UV_FS_O_RDWR, type, &base, &inheriting); - if (err != UVWASI_ESUCCESS) - goto error_exit; - - err = uvwasi_fd_table_insert(uvwasi, - table, - i, - "", - "", - type, - base, - inheriting, - 0, - &wrap); - if (err != UVWASI_ESUCCESS) - goto error_exit; - - r = wrap->id != i || wrap->id != (uvwasi_fd_t) wrap->fd; - uv_mutex_unlock(&wrap->mutex); - if (r) { - err = UVWASI_EBADF; - goto error_exit; - } - } + err = uvwasi__insert_stdio(uvwasi, table, options->in, 0, ""); + if (err != UVWASI_ESUCCESS) + goto error_exit; + + err = uvwasi__insert_stdio(uvwasi, table, options->out, 1, ""); + if (err != UVWASI_ESUCCESS) + goto error_exit; + + err = uvwasi__insert_stdio(uvwasi, table, options->err, 2, ""); + if (err != UVWASI_ESUCCESS) + goto error_exit; return UVWASI_ESUCCESS; error_exit: diff --git a/deps/uvwasi/src/uvwasi.c b/deps/uvwasi/src/uvwasi.c index 53b7699f590e53..c80fc7715c1dc0 100644 --- a/deps/uvwasi/src/uvwasi.c +++ b/deps/uvwasi/src/uvwasi.c @@ -34,6 +34,11 @@ # define PATH_MAX_BYTES (PATH_MAX) #endif +/* IBMi PASE does not support posix_fadvise() */ +#ifdef __PASE__ +# undef POSIX_FADV_NORMAL +#endif + static void* default_malloc(size_t size, void* mem_user_data) { return malloc(size); } @@ -569,7 +574,7 @@ uvwasi_errno_t uvwasi_init(uvwasi_t* uvwasi, uvwasi_options_t* options) { } } - err = uvwasi_fd_table_init(uvwasi, &uvwasi->fds, options->fd_table_size); + err = uvwasi_fd_table_init(uvwasi, options); if (err != UVWASI_ESUCCESS) goto exit; diff --git a/deps/v8/src/parsing/parser.cc b/deps/v8/src/parsing/parser.cc index 3a61253db5a193..ac9374e71d81df 100644 --- a/deps/v8/src/parsing/parser.cc +++ b/deps/v8/src/parsing/parser.cc @@ -502,7 +502,6 @@ FunctionLiteral* Parser::ParseProgram(Isolate* isolate, ParseInfo* info) { Scope::DeserializationMode::kIncludingVariables); scanner_.Initialize(); - scanner_.SkipHashBang(); FunctionLiteral* result = DoParseProgram(isolate, info); MaybeResetCharacterStream(info, result); MaybeProcessSourceRanges(info, result, stack_limit_); diff --git a/deps/v8/src/parsing/preparser.cc b/deps/v8/src/parsing/preparser.cc index 67ee1930accaca..c25ed2f8dd4cb8 100644 --- a/deps/v8/src/parsing/preparser.cc +++ b/deps/v8/src/parsing/preparser.cc @@ -74,10 +74,6 @@ PreParser::PreParseResult PreParser::PreParseProgram() { scope->set_is_being_lazily_parsed(true); #endif - // Note: We should only skip the hashbang in non-Eval scripts - // (currently, Eval is not handled by the PreParser). - scanner()->SkipHashBang(); - // ModuleDeclarationInstantiation for Source Text Module Records creates a // new Module Environment Record whose outer lexical environment record is // the global scope. diff --git a/deps/v8/src/parsing/scanner-inl.h b/deps/v8/src/parsing/scanner-inl.h index b76076d92ffaaa..53b53cb9981259 100644 --- a/deps/v8/src/parsing/scanner-inl.h +++ b/deps/v8/src/parsing/scanner-inl.h @@ -505,6 +505,10 @@ V8_INLINE Token::Value Scanner::ScanSingleToken() { return ScanTemplateSpan(); case Token::PRIVATE_NAME: + if (source_pos() == 0 && Peek() == '!') { + token = SkipSingleLineComment(); + continue; + } return ScanPrivateName(); case Token::WHITESPACE: diff --git a/deps/v8/src/parsing/scanner.cc b/deps/v8/src/parsing/scanner.cc index 28e43747874605..d444719f638906 100644 --- a/deps/v8/src/parsing/scanner.cc +++ b/deps/v8/src/parsing/scanner.cc @@ -314,13 +314,6 @@ Token::Value Scanner::SkipMultiLineComment() { return Token::ILLEGAL; } -void Scanner::SkipHashBang() { - if (c0_ == '#' && Peek() == '!' && source_pos() == 0) { - SkipSingleLineComment(); - Scan(); - } -} - Token::Value Scanner::ScanHtmlComment() { // Check for - -Node.js can be started using the `--zero-fill-buffers` command line option to -cause all newly-allocated `Buffer` instances to be zero-filled upon creation by -default. Without the option, buffers created with [`Buffer.allocUnsafe()`][], -[`Buffer.allocUnsafeSlow()`][], and `new SlowBuffer(size)` are not zero-filled. -Use of this flag can have a significant negative impact on performance. Use the -`--zero-fill-buffers` option only when necessary to enforce that newly allocated -`Buffer` instances cannot contain old data that is potentially sensitive. - -```console -$ node --zero-fill-buffers -> Buffer.allocUnsafe(5); - +// Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74]. +const buf7 = Buffer.from('tést', 'latin1'); ``` -### What makes `Buffer.allocUnsafe()` and `Buffer.allocUnsafeSlow()` "unsafe"? - -When calling [`Buffer.allocUnsafe()`][] and [`Buffer.allocUnsafeSlow()`][], the -segment of allocated memory is *uninitialized* (it is not zeroed-out). While -this design makes the allocation of memory quite fast, the allocated segment of -memory might contain old data that is potentially sensitive. Using a `Buffer` -created by [`Buffer.allocUnsafe()`][] without *completely* overwriting the -memory can allow this old data to be leaked when the `Buffer` memory is read. - -While there are clear performance advantages to using -[`Buffer.allocUnsafe()`][], extra care *must* be taken in order to avoid -introducing security vulnerabilities into an application. - ## Buffers and Character Encodings -When string data is stored in or extracted out of a `Buffer` instance, a -character encoding may be specified. +When converting between `Buffer`s and strings, a character encoding may be +specified. If no character encoding is specified, UTF-8 will be used as the +default. ```js -const buf = Buffer.from('hello world', 'ascii'); +const buf = Buffer.from('hello world', 'utf8'); console.log(buf.toString('hex')); // Prints: 68656c6c6f20776f726c64 console.log(buf.toString('base64')); // Prints: aGVsbG8gd29ybGQ= -console.log(Buffer.from('fhqwhgads', 'ascii')); +console.log(Buffer.from('fhqwhgads', 'utf8')); // Prints: console.log(Buffer.from('fhqwhgads', 'utf16le')); // Prints: ``` -The character encodings currently supported by Node.js include: +The character encodings currently supported by Node.js are the following: -* `'ascii'`: For 7-bit ASCII data only. This encoding is fast and will strip - the high bit if set. +* `'utf8'`: Multi-byte encoded Unicode characters. Many web pages and other + document formats use [UTF-8][]. This is the default character encoding. + When decoding a `Buffer` into a string that does not exclusively contain + valid UTF-8 data, the Unicode replacement character `U+FFFD` � will be used + to represent those errors. -* `'utf8'`: Multibyte encoded Unicode characters. Many web pages and other - document formats use UTF-8. +* `'utf16le'`: Multi-byte encoded Unicode characters. Unlike `'utf8'`, each + character in the string will be encoded using either 2 or 4 bytes. + Node.js only supports the [little-endian][endianness] variant of [UTF-16][]. -* `'utf16le'`: 2 or 4 bytes, little-endian encoded Unicode characters. - Surrogate pairs (U+10000 to U+10FFFF) are supported. +* `'latin1'`: Latin-1 stands for [ISO-8859-1][]. This character encoding only + supports the Unicode characters from `U+0000` to `U+00FF`. Each character is + encoded using a single byte. Characters that do not fit into that range are + truncated and will be mapped to characters in that range. -* `'ucs2'`: Alias of `'utf16le'`. +Converting a `Buffer` into a string using one of the above is referred to as +decoding, and converting a string into a `Buffer` is referred to as encoding. -* `'base64'`: Base64 encoding. When creating a `Buffer` from a string, +Node.js also supports the following two binary-to-text encodings. For +binary-to-text encodings, the naming convention is reversed: Converting a +`Buffer` into a string is typically referred to as encoding, and converting a +string into a `Buffer` as decoding. + +* `'base64'`: [Base64][] encoding. When creating a `Buffer` from a string, this encoding will also correctly accept "URL and Filename Safe Alphabet" as specified in [RFC 4648, Section 5][]. -* `'latin1'`: A way of encoding the `Buffer` into a one-byte encoded string - (as defined by the IANA in [RFC 1345][], - page 63, to be the Latin-1 supplement block and C0/C1 control codes). +* `'hex'`: Encode each byte as two hexadecimal characters. Data truncation + may occur when decoding string that do exclusively contain valid hexadecimal + characters. See below for an example. + +The following legacy character encodings are also supported: -* `'binary'`: Alias for `'latin1'`. +* `'ascii'`: For 7-bit [ASCII][] data only. When encoding a string into a + `Buffer`, this is equivalent to using `'latin1'`. When decoding a `Buffer` + into a string, using encoding this will additionally unset the highest bit of + each byte before decoding as `'latin1'`. + Generally, there should be no reason to use this encoding, as `'utf8'` + (or, if the data is known to always be ASCII-only, `'latin1'`) will be a + better choice when encoding or decoding ASCII-only text. It is only provided + for legacy compatibility. -* `'hex'`: Encode each byte as two hexadecimal characters. Data truncation - may occur for unsanitized input. For example: +* `'binary'`: Alias for `'latin1'`. See [binary strings][] for more background + on this topic. The name of this encoding can be very misleading, as all of the + encodings listed here convert between strings and binary data. For converting + between strings and `Buffer`s, typically `'utf-8'` is the right choice. + +* `'ucs2'`: Alias of `'utf16le'`. UCS-2 used to refer to a variant of UTF-16 + that did not support characters that had code points larger than U+FFFF. + In Node.js, these code points are always supported. ```js Buffer.from('1ag', 'hex'); @@ -222,7 +154,7 @@ the WHATWG specification it is possible that the server actually returned `'win-1252'`-encoded data, and using `'latin1'` encoding may incorrectly decode the characters. -## Buffers and TypedArray +## Buffers and TypedArrays -`Buffer` instances are also [`Uint8Array`][] instances. However, there are -subtle incompatibilities with [`TypedArray`][]. For example, while -[`ArrayBuffer#slice()`][] creates a copy of the slice, the implementation of -[`Buffer#slice()`][`buf.slice()`] creates a view over the existing `Buffer` -without copying, making [`Buffer#slice()`][`buf.slice()`] far more efficient. +`Buffer` instances are also [`Uint8Array`][] instances, which is the language’s +built-in class for working with binary data. [`Uint8Array`][] in turn is a +subclass of [`TypedArray`][]. Therefore, all [`TypedArray`][] methods are also +available on `Buffer`s. However, there are subtle incompatibilities between +the `Buffer` API and the [`TypedArray`][] API. + +In particular: -It is also possible to create new [`TypedArray`][] instances from a `Buffer` -with the following caveats: +* While [`TypedArray#slice()`][] creates a copy of part of the `TypedArray`, + [`Buffer#slice()`][`buf.slice()`] creates a view over the existing `Buffer` + without copying. This behavior can be surprising, and only exists for legacy + compatibility. [`TypedArray#subarray()`][] can be used to achieve the behavior + of [`Buffer#slice()`][`buf.slice()`] on both `Buffer`s and other + `TypedArray`s. +* [`buf.toString()`][] is incompatible with its `TypedArray` equivalent. +* A number of methods, e.g. [`buf.indexOf()`][], support additional arguments. -1. The `Buffer` object's memory is copied to the [`TypedArray`][], not shared. +There are two ways to create new [`TypedArray`][] instances from a `Buffer`. -2. The `Buffer` object's memory is interpreted as an array of distinct -elements, and not as a byte array of the target type. That is, +When passing a `Buffer` to a [`TypedArray`][] constructor, the `Buffer`’s +elements will be copied, interpreted as an array of integers, and not as a byte +array of the target type. For example, `new Uint32Array(Buffer.from([1, 2, 3, 4]))` creates a 4-element -[`Uint32Array`][] with elements `[1, 2, 3, 4]`, not a [`Uint32Array`][] with a -single element `[0x1020304]` or `[0x4030201]`. +[`Uint32Array`][] with elements `[1, 2, 3, 4]`, rather than a +[`Uint32Array`][] with a single element `[0x1020304]` or `[0x4030201]`. -It is possible to create a new `Buffer` that shares the same allocated memory as -a [`TypedArray`][] instance by using the `TypedArray` object's `.buffer` -property. +In order to create a [`TypedArray`][] that shares its memory with the `Buffer`, +the underlying [`ArrayBuffer`][] can be passed to the [`TypedArray`][] +constructor instead: + +```js +const buf = Buffer.from('hello', 'utf16le'); +const uint16arr = new Uint16Array( + buf.buffer, buf.byteOffset, buf.length / Uint16Array.BYTES_PER_ELEMENT); +``` + +It is also possible to create a new `Buffer` that shares the same allocated +memory as a [`TypedArray`][] instance by using the `TypedArray` object’s +`.buffer` property in the same way. [`Buffer.from()`][`Buffer.from(arrayBuf)`] +behaves like `new Uint8Array()` in this context. ```js const arr = new Uint16Array(2); @@ -326,298 +278,101 @@ Additionally, the [`buf.values()`][], [`buf.keys()`][], and The `Buffer` class is a global type for dealing with binary data directly. It can be constructed in a variety of ways. -### `new Buffer(array)` +### Class Method: `Buffer.alloc(size[, fill[, encoding]])` -> Stability: 0 - Deprecated: Use [`Buffer.from(array)`][] instead. - -* `array` {integer[]} An array of bytes to copy from. +* `size` {integer} The desired length of the new `Buffer`. +* `fill` {string|Buffer|Uint8Array|integer} A value to pre-fill the new `Buffer` + with. **Default:** `0`. +* `encoding` {string} If `fill` is a string, this is its encoding. + **Default:** `'utf8'`. -Allocates a new `Buffer` using an `array` of octets. +Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the +`Buffer` will be zero-filled. ```js -// Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'. -const buf = new Buffer([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]); +const buf = Buffer.alloc(5); + +console.log(buf); +// Prints: ``` -### `new Buffer(arrayBuffer[, byteOffset[, length]])` - +If `size` is larger than +[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_INVALID_OPT_VALUE`][] +is thrown. -> Stability: 0 - Deprecated: Use -> [`Buffer.from(arrayBuffer[, byteOffset[, length]])`][`Buffer.from(arrayBuf)`] -> instead. +If `fill` is specified, the allocated `Buffer` will be initialized by calling +[`buf.fill(fill)`][`buf.fill()`]. -* `arrayBuffer` {ArrayBuffer|SharedArrayBuffer} An [`ArrayBuffer`][], - [`SharedArrayBuffer`][] or the `.buffer` property of a [`TypedArray`][]. -* `byteOffset` {integer} Index of first byte to expose. **Default:** `0`. -* `length` {integer} Number of bytes to expose. - **Default:** `arrayBuffer.byteLength - byteOffset`. +```js +const buf = Buffer.alloc(5, 'a'); -This creates a view of the [`ArrayBuffer`][] or [`SharedArrayBuffer`][] without -copying the underlying memory. For example, when passed a reference to the -`.buffer` property of a [`TypedArray`][] instance, the newly created `Buffer` -will share the same allocated memory as the [`TypedArray`][]. +console.log(buf); +// Prints: +``` -The optional `byteOffset` and `length` arguments specify a memory range within -the `arrayBuffer` that will be shared by the `Buffer`. +If both `fill` and `encoding` are specified, the allocated `Buffer` will be +initialized by calling [`buf.fill(fill, encoding)`][`buf.fill()`]. ```js -const arr = new Uint16Array(2); - -arr[0] = 5000; -arr[1] = 4000; - -// Shares memory with `arr`. -const buf = new Buffer(arr.buffer); +const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64'); console.log(buf); -// Prints: +// Prints: +``` -// Changing the original Uint16Array changes the Buffer also. -arr[1] = 6000; +Calling [`Buffer.alloc()`][] can be measurably slower than the alternative +[`Buffer.allocUnsafe()`][] but ensures that the newly created `Buffer` instance +contents will never contain sensitive data from previous allocations, including +data that might not have been allocated for `Buffer`s. -console.log(buf); -// Prints: -``` +A `TypeError` will be thrown if `size` is not a number. -### `new Buffer(buffer)` +### Class Method: `Buffer.allocUnsafe(size)` -> Stability: 0 - Deprecated: Use [`Buffer.from(buffer)`][] instead. +* `size` {integer} The desired length of the new `Buffer`. -* `buffer` {Buffer|Uint8Array} An existing `Buffer` or [`Uint8Array`][] from - which to copy data. +Allocates a new `Buffer` of `size` bytes. If `size` is larger than +[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_INVALID_OPT_VALUE`][] +is thrown. -Copies the passed `buffer` data onto a new `Buffer` instance. +The underlying memory for `Buffer` instances created in this way is *not +initialized*. The contents of the newly created `Buffer` are unknown and +*may contain sensitive data*. Use [`Buffer.alloc()`][] instead to initialize +`Buffer` instances with zeroes. ```js -const buf1 = new Buffer('buffer'); -const buf2 = new Buffer(buf1); +const buf = Buffer.allocUnsafe(10); -buf1[0] = 0x61; +console.log(buf); +// Prints (contents may vary): -console.log(buf1.toString()); -// Prints: auffer -console.log(buf2.toString()); -// Prints: buffer -``` - -### `new Buffer(size)` - - -> Stability: 0 - Deprecated: Use [`Buffer.alloc()`][] instead (also see -> [`Buffer.allocUnsafe()`][]). - -* `size` {integer} The desired length of the new `Buffer`. - -Allocates a new `Buffer` of `size` bytes. If `size` is larger than -[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_INVALID_OPT_VALUE`][] -is thrown. A zero-length `Buffer` is created if `size` is 0. - -Prior to Node.js 8.0.0, the underlying memory for `Buffer` instances -created in this way is *not initialized*. The contents of a newly created -`Buffer` are unknown and *may contain sensitive data*. Use -[`Buffer.alloc(size)`][`Buffer.alloc()`] instead to initialize a `Buffer` -with zeroes. - -```js -const buf = new Buffer(10); - -console.log(buf); -// Prints: -``` - -### `new Buffer(string[, encoding])` - - -> Stability: 0 - Deprecated: -> Use [`Buffer.from(string[, encoding])`][`Buffer.from(string)`] instead. - -* `string` {string} String to encode. -* `encoding` {string} The encoding of `string`. **Default:** `'utf8'`. - -Creates a new `Buffer` containing `string`. The `encoding` parameter identifies -the character encoding of `string`. - -```js -const buf1 = new Buffer('this is a tést'); -const buf2 = new Buffer('7468697320697320612074c3a97374', 'hex'); - -console.log(buf1.toString()); -// Prints: this is a tést -console.log(buf2.toString()); -// Prints: this is a tést -console.log(buf1.toString('ascii')); -// Prints: this is a tC)st -``` - -### Class Method: `Buffer.alloc(size[, fill[, encoding]])` - - -* `size` {integer} The desired length of the new `Buffer`. -* `fill` {string|Buffer|Uint8Array|integer} A value to pre-fill the new `Buffer` - with. **Default:** `0`. -* `encoding` {string} If `fill` is a string, this is its encoding. - **Default:** `'utf8'`. - -Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the -`Buffer` will be *zero-filled*. - -```js -const buf = Buffer.alloc(5); - -console.log(buf); -// Prints: -``` - -If `size` is larger than -[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_INVALID_OPT_VALUE`][] -is thrown. A zero-length `Buffer` is created if `size` is 0. - -If `fill` is specified, the allocated `Buffer` will be initialized by calling -[`buf.fill(fill)`][`buf.fill()`]. - -```js -const buf = Buffer.alloc(5, 'a'); - -console.log(buf); -// Prints: -``` - -If both `fill` and `encoding` are specified, the allocated `Buffer` will be -initialized by calling [`buf.fill(fill, encoding)`][`buf.fill()`]. - -```js -const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64'); - -console.log(buf); -// Prints: -``` - -Calling [`Buffer.alloc()`][] can be significantly slower than the alternative -[`Buffer.allocUnsafe()`][] but ensures that the newly created `Buffer` instance -contents will *never contain sensitive data*. - -A `TypeError` will be thrown if `size` is not a number. - -### Class Method: `Buffer.allocUnsafe(size)` - - -* `size` {integer} The desired length of the new `Buffer`. - -Allocates a new `Buffer` of `size` bytes. If `size` is larger than -[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_INVALID_OPT_VALUE`][] -is thrown. A zero-length `Buffer` is created if `size` is 0. - -The underlying memory for `Buffer` instances created in this way is *not -initialized*. The contents of the newly created `Buffer` are unknown and -*may contain sensitive data*. Use [`Buffer.alloc()`][] instead to initialize -`Buffer` instances with zeroes. - -```js -const buf = Buffer.allocUnsafe(10); - -console.log(buf); -// Prints (contents may vary): - -buf.fill(0); - -console.log(buf); -// Prints: +buf.fill(0); + +console.log(buf); +// Prints: ``` A `TypeError` will be thrown if `size` is not a number. @@ -657,7 +412,7 @@ allocations under 4KB are sliced from a single pre-allocated `Buffer`. This allows applications to avoid the garbage collection overhead of creating many individually allocated `Buffer` instances. This approach improves both performance and memory usage by eliminating the need to track and clean up as -many persistent objects. +many individual `ArrayBuffer` objects. However, in the case where a developer may need to retain a small chunk of memory from a pool for an indeterminate amount of time, it may be appropriate @@ -682,9 +437,6 @@ socket.on('readable', () => { }); ``` -`Buffer.allocUnsafeSlow()` should be used only as a last resort after a -developer has observed undue memory retention in their applications. - A `TypeError` will be thrown if `size` is not a number. ### Class Method: `Buffer.byteLength(string[, encoding])` @@ -706,12 +458,12 @@ changes: **Default:** `'utf8'`. * Returns: {integer} The number of bytes contained within `string`. -Returns the actual byte length of a string. This is not the same as -[`String.prototype.length`][] since that returns the number of *characters* in -a string. +Returns the byte length of a string when encoded using `encoding`. +This is not the same as [`String.prototype.length`][], which does not account +for the encoding that is used to convert the string into bytes. For `'base64'` and `'hex'`, this function assumes valid input. For strings that -contain non-Base64/Hex-encoded data (e.g. whitespace), the return value might be +contain non-base64/hex-encoded data (e.g. whitespace), the return value might be greater than the length of a `Buffer` created from the string. ```js @@ -723,7 +475,8 @@ console.log(`${str}: ${str.length} characters, ` + ``` When `string` is a `Buffer`/[`DataView`][]/[`TypedArray`][]/[`ArrayBuffer`][]/ -[`SharedArrayBuffer`][], the actual byte length is returned. +[`SharedArrayBuffer`][], the byte length as reported by `.byteLength` +is returned. ### Class Method: `Buffer.compare(buf1, buf2)` * `list` {Buffer[] | Uint8Array[]} List of `Buffer` or [`Uint8Array`][] - instances to concat. + instances to concatenate. * `totalLength` {integer} Total length of the `Buffer` instances in `list` when concatenated. * Returns: {Buffer} @@ -774,9 +528,7 @@ If the list has no items, or if the `totalLength` is 0, then a new zero-length `Buffer` is returned. If `totalLength` is not provided, it is calculated from the `Buffer` instances -in `list`. This however causes an additional loop to be executed in order to -calculate the `totalLength`, so it is faster to provide the length explicitly if -it is already known. +in `list` by adding their lengths. If `totalLength` is provided, it is coerced to an unsigned integer. If the combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is @@ -808,10 +560,11 @@ added: v5.10.0 * `array` {integer[]} -Allocates a new `Buffer` using an `array` of octets. +Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`. +Array entries outside that range will be truncated to fit into it. ```js -// Creates a new Buffer containing UTF-8 bytes of the string 'buffer'. +// Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'. const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]); ``` @@ -824,7 +577,8 @@ added: v5.10.0 --> * `arrayBuffer` {ArrayBuffer|SharedArrayBuffer} An [`ArrayBuffer`][], - [`SharedArrayBuffer`][], or the `.buffer` property of a [`TypedArray`][]. + [`SharedArrayBuffer`][], for example the `.buffer` property of a + [`TypedArray`][]. * `byteOffset` {integer} Index of first byte to expose. **Default:** `0`. * `length` {integer} Number of bytes to expose. **Default:** `arrayBuffer.byteLength - byteOffset`. @@ -938,7 +692,7 @@ added: v5.10.0 * `encoding` {string} The encoding of `string`. **Default:** `'utf8'`. Creates a new `Buffer` containing `string`. The `encoding` parameter identifies -the character encoding of `string`. +the character encoding to be used when converting `string` into bytes. ```js const buf1 = Buffer.from('this is a tést'); @@ -948,8 +702,8 @@ console.log(buf1.toString()); // Prints: this is a tést console.log(buf2.toString()); // Prints: this is a tést -console.log(buf1.toString('ascii')); -// Prints: this is a tC)st +console.log(buf1.toString('latin1')); +// Prints: this is a tést ``` A `TypeError` will be thrown if `string` is not a string or other type @@ -973,8 +727,8 @@ added: v0.9.1 * `encoding` {string} A character encoding name to check. * Returns: {boolean} -Returns `true` if `encoding` contains a supported character encoding, or `false` -otherwise. +Returns `true` if `encoding` is the name of a supported character encoding, +or `false` otherwise. ```js console.log(Buffer.isEncoding('utf-8')); @@ -1013,11 +767,15 @@ The index operator `[index]` can be used to get and set the octet at position range is between `0x00` and `0xFF` (hex) or `0` and `255` (decimal). This operator is inherited from `Uint8Array`, so its behavior on out-of-bounds -access is the same as `UInt8Array`. In other words, getting returns `undefined` -and setting does nothing. +access is the same as `Uint8Array`. In other words, `buf[index]` returns +`undefined` when `index` is negative or `>= buf.length`, and +`buf[index] = value` does not modify the buffer if `index` is negative or +`>= buf.length`. ```js // Copy an ASCII string into a `Buffer` one byte at a time. +// (This only works for ASCII-only strings. In general, one should use +// `Buffer.from()` to perform this conversion.) const str = 'Node.js'; const buf = Buffer.allocUnsafe(str.length); @@ -1026,7 +784,7 @@ for (let i = 0; i < str.length; i++) { buf[i] = str.charCodeAt(i); } -console.log(buf.toString('ascii')); +console.log(buf.toString('utf8')); // Prints: Node.js ``` @@ -1051,23 +809,24 @@ console.log(buffer.buffer === arrayBuffer); * {integer} The `byteOffset` on the underlying `ArrayBuffer` object based on which this `Buffer` object is created. -When setting `byteOffset` in `Buffer.from(ArrayBuffer, byteOffset, length)` -or sometimes when allocating a buffer smaller than `Buffer.poolSize` the +When setting `byteOffset` in `Buffer.from(ArrayBuffer, byteOffset, length)`, +or sometimes when allocating a buffer smaller than `Buffer.poolSize`, the buffer doesn't start from a zero offset on the underlying `ArrayBuffer`. This can cause problems when accessing the underlying `ArrayBuffer` directly -using `buf.buffer`, as the first bytes in this `ArrayBuffer` may be unrelated +using `buf.buffer`, as other parts of the `ArrayBuffer` may be unrelated to the `buf` object itself. -A common issue is when casting a `Buffer` object to a `TypedArray` object, -in this case one needs to specify the `byteOffset` correctly: +A common issue when creating a `TypedArray` object that shares its memory with +a `Buffer` is that in this case one needs to specify the `byteOffset` correctly: ```js // Create a buffer smaller than `Buffer.poolSize`. const nodeBuffer = new Buffer.from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); -// When casting the Node.js Buffer to an Int8 TypedArray remember to use the -// byteOffset. +// When casting the Node.js Buffer to an Int8Array, use the byteOffset +// to refer only to the part of `nodeBuffer.buffer` that contains the memory +// for `nodeBuffer`. new Int8Array(nodeBuffer.buffer, nodeBuffer.byteOffset, nodeBuffer.length); ``` @@ -1156,9 +915,13 @@ added: v0.1.90 inclusive). **Default:** [`buf.length`][]. * Returns: {integer} The number of bytes copied. -Copies data from a region of `buf` to a region in `target` even if the `target` +Copies data from a region of `buf` to a region in `target`, even if the `target` memory region overlaps with `buf`. +[`TypedArray#set()`][] performs the same operation, and is available for all +TypedArrays, including Node.js `Buffer`s, although it takes different +function arguments. + ```js // Create two `Buffer` instances. const buf1 = Buffer.allocUnsafe(26); @@ -1171,6 +934,8 @@ for (let i = 0; i < 26; i++) { // Copy `buf1` bytes 16 through 19 into `buf2` starting at byte 8 of `buf2`. buf1.copy(buf2, 8, 16, 20); +// This is equivalent to: +// buf2.set(buf1.subarray(16, 20), 8); console.log(buf2.toString('ascii', 0, 25)); // Prints: !!!!!!!!qrst!!!!!!!!!!!!! @@ -1234,7 +999,8 @@ changes: * Returns: {boolean} Returns `true` if both `buf` and `otherBuffer` have exactly the same bytes, -`false` otherwise. +`false` otherwise. Equivalent to +[`buf.compare(otherBuffer) === 0`][`buf.compare()`]. ```js const buf1 = Buffer.from('ABC'); @@ -1299,10 +1065,10 @@ If the final write of a `fill()` operation falls on a multi-byte character, then only the bytes of that character that fit into `buf` are written: ```js -// Fill a `Buffer` with a two-byte character. +// Fill a `Buffer` with character that takes up two bytes in UTF-8. -console.log(Buffer.allocUnsafe(3).fill('\u0222')); -// Prints: +console.log(Buffer.allocUnsafe(5).fill('\u0222')); +// Prints: ``` If `value` contains invalid characters, it is truncated; if no valid @@ -1543,42 +1309,22 @@ added: v0.1.90 * {integer} -Returns the amount of memory allocated for `buf` in bytes. This -does not necessarily reflect the amount of "usable" data within `buf`. +Returns the number of bytes in `buf`. ```js -// Create a `Buffer` and write a shorter ASCII string to it. +// Create a `Buffer` and write a shorter string to it using UTF-8. const buf = Buffer.alloc(1234); console.log(buf.length); // Prints: 1234 -buf.write('some string', 0, 'ascii'); +buf.write('some string', 0, 'utf8'); console.log(buf.length); // Prints: 1234 ``` -While the `length` property is not immutable, changing the value of `length` -can result in undefined and inconsistent behavior. Applications that wish to -modify the length of a `Buffer` should therefore treat `length` as read-only and -use [`buf.slice()`][] to create a new `Buffer`. - -```js -let buf = Buffer.allocUnsafe(10); - -buf.write('abcdefghj', 0, 'ascii'); - -console.log(buf.length); -// Prints: 10 - -buf = buf.slice(0, 5); - -console.log(buf.length); -// Prints: 5 -``` - ### `buf.parent` + +> Stability: 0 - Deprecated: Use [`Buffer.from(array)`][] instead. + +* `array` {integer[]} An array of bytes to copy from. + +See [`Buffer.from(array)`][]. + +### `new Buffer(arrayBuffer[, byteOffset[, length]])` + + +> Stability: 0 - Deprecated: Use +> [`Buffer.from(arrayBuffer[, byteOffset[, length]])`][`Buffer.from(arrayBuf)`] +> instead. + +* `arrayBuffer` {ArrayBuffer|SharedArrayBuffer} An [`ArrayBuffer`][], + [`SharedArrayBuffer`][] or the `.buffer` property of a [`TypedArray`][]. +* `byteOffset` {integer} Index of first byte to expose. **Default:** `0`. +* `length` {integer} Number of bytes to expose. + **Default:** `arrayBuffer.byteLength - byteOffset`. + +See +[`Buffer.from(arrayBuffer[, byteOffset[, length]])`][`Buffer.from(arrayBuf)`]. + +### `new Buffer(buffer)` + + +> Stability: 0 - Deprecated: Use [`Buffer.from(buffer)`][] instead. + +* `buffer` {Buffer|Uint8Array} An existing `Buffer` or [`Uint8Array`][] from + which to copy data. + +See [`Buffer.from(buffer)`][]. + +### `new Buffer(size)` + + +> Stability: 0 - Deprecated: Use [`Buffer.alloc()`][] instead (also see +> [`Buffer.allocUnsafe()`][]). + +* `size` {integer} The desired length of the new `Buffer`. + +See [`Buffer.alloc()`][] and [`Buffer.allocUnsafe()`][]. This variant of the +constructor is equivalent to [`Buffer.allocUnsafe()`][], although using +[`Buffer.alloc()`][] is recommended in code paths that are not critical to +performance. + +### `new Buffer(string[, encoding])` + + +> Stability: 0 - Deprecated: +> Use [`Buffer.from(string[, encoding])`][`Buffer.from(string)`] instead. + +* `string` {string} String to encode. +* `encoding` {string} The encoding of `string`. **Default:** `'utf8'`. + +See [`Buffer.from(string[, encoding])`][`Buffer.from(string)`]. + ## `buffer.INSPECT_MAX_BYTES` + +Node.js can be started using the `--zero-fill-buffers` command line option to +cause all newly-allocated `Buffer` instances to be zero-filled upon creation by +default. Without the option, buffers created with [`Buffer.allocUnsafe()`][], +[`Buffer.allocUnsafeSlow()`][], and `new SlowBuffer(size)` are not zero-filled. +Use of this flag can have a measurable negative impact on performance. Use the +`--zero-fill-buffers` option only when necessary to enforce that newly allocated +`Buffer` instances cannot contain old data that is potentially sensitive. + +```console +$ node --zero-fill-buffers +> Buffer.allocUnsafe(5); + +``` + +### What makes `Buffer.allocUnsafe()` and `Buffer.allocUnsafeSlow()` "unsafe"? + +When calling [`Buffer.allocUnsafe()`][] and [`Buffer.allocUnsafeSlow()`][], the +segment of allocated memory is *uninitialized* (it is not zeroed-out). While +this design makes the allocation of memory quite fast, the allocated segment of +memory might contain old data that is potentially sensitive. Using a `Buffer` +created by [`Buffer.allocUnsafe()`][] without *completely* overwriting the +memory can allow this old data to be leaked when the `Buffer` memory is read. + +While there are clear performance advantages to using +[`Buffer.allocUnsafe()`][], extra care *must* be taken in order to avoid +introducing security vulnerabilities into an application. + [RFC 4648, Section 5]: https://tools.ietf.org/html/rfc4648#section-5 [WHATWG Encoding Standard]: https://encoding.spec.whatwg.org/ -[`ArrayBuffer#slice()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice [`ArrayBuffer`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer [`Buffer.alloc()`]: #buffer_class_method_buffer_alloc_size_fill_encoding [`Buffer.allocUnsafe()`]: #buffer_class_method_buffer_allocunsafe_size @@ -2847,6 +2791,9 @@ This value may depend on the JS engine that is being used. [`String#lastIndexOf()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf [`String.prototype.length`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length [`TypedArray.from()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from +[`TypedArray#set()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set +[`TypedArray#slice()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice +[`TypedArray#subarray()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray [`TypedArray`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray [`Uint32Array`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array [`Uint8Array`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array @@ -2858,9 +2805,17 @@ This value may depend on the JS engine that is being used. [`buf.keys()`]: #buffer_buf_keys [`buf.length`]: #buffer_buf_length [`buf.slice()`]: #buffer_buf_slice_start_end +[`buf.toString()`]: #buffer_buf_tostring_encoding_start_end [`buf.values()`]: #buffer_buf_values [`buffer.constants.MAX_LENGTH`]: #buffer_buffer_constants_max_length [`buffer.constants.MAX_STRING_LENGTH`]: #buffer_buffer_constants_max_string_length [`buffer.kMaxLength`]: #buffer_buffer_kmaxlength [`util.inspect()`]: util.html#util_util_inspect_object_options +[ASCII]: https://en.wikipedia.org/wiki/ASCII +[Base64]: https://en.wikipedia.org/wiki/Base64 +[ISO-8859-1]: https://en.wikipedia.org/wiki/ISO-8859-1 +[UTF-8]: https://en.wikipedia.org/wiki/UTF-8 +[UTF-16]: https://en.wikipedia.org/wiki/UTF-16 +[binary strings]: https://developer.mozilla.org/en-US/docs/Web/API/DOMString/Binary +[endianness]: https://en.wikipedia.org/wiki/Endianness [iterator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols diff --git a/doc/api/child_process.md b/doc/api/child_process.md index cd47fec7982b3e..d5812c3975486b 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -33,6 +33,14 @@ process will block waiting for the pipe buffer to accept more data. This is identical to the behavior of pipes in the shell. Use the `{ stdio: 'ignore' }` option if the output will not be consumed. +The command lookup will be performed using `options.env.PATH` environment +variable if passed in `options` object, otherwise `process.env.PATH` will be +used. To account for the fact that Windows environment variables are +case-insensitive Node.js will lexicographically sort all `env` keys and choose +the first one case-insensitively matching `PATH` to perform command lookup. +This may lead to issues on Windows when passing objects to `env` option that +have multiple variants of `PATH` variable. + The [`child_process.spawn()`][] method spawns the child process asynchronously, without blocking the Node.js event loop. The [`child_process.spawnSync()`][] function provides equivalent functionality in a synchronous manner that blocks diff --git a/doc/api/cli.md b/doc/api/cli.md index 2f3c6a9f7da114..d323e24f3ecf96 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -1384,6 +1384,30 @@ threadpool by setting the `'UV_THREADPOOL_SIZE'` environment variable to a value greater than `4` (its current default value). For more information, see the [libuv threadpool documentation][]. +## Useful V8 options + +V8 has its own set of CLI options. Any V8 CLI option that is provided to `node` +will be passed on to V8 to handle. V8's options have _no stability guarantee_. +The V8 team themselves don't consider them to be part of their formal API, +and reserve the right to change them at any time. Likewise, they are not +covered by the Node.js stability guarantees. Many of the V8 +options are of interest only to V8 developers. Despite this, there is a small +set of V8 options that are widely applicable to Node.js, and they are +documented here: + +### `--max-old-space-size=SIZE` (in Mbytes) + +Sets the max memory size of V8's old memory section. As memory +consumption approaches the limit, V8 will spend more time on +garbage collection in an effort to free unused memory. + +On a machine with 2GB of memory, consider setting this to +1536 (1.5GB) to leave some memory for other uses and avoid swapping. + +```console +$ node --max-old-space-size=1536 index.js +``` + [`--openssl-config`]: #cli_openssl_config_file [`Buffer`]: buffer.html#buffer_class_buffer [`SlowBuffer`]: buffer.html#buffer_class_slowbuffer diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 40bde378450402..2b1c472835ca92 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -2273,8 +2273,9 @@ console.log(aliceSecret === bobSecret); added: v10.0.0 --> -* Returns: {boolean} `true` if and only if a FIPS compliant crypto provider is - currently in use. +* Returns: {number} `1` if and only if a FIPS compliant crypto provider is + currently in use, `0` otherwise. A future semver-major release may change + the return type of this API to a {boolean}. ### `crypto.getHashes()` * `privateKey` {Object | string | Buffer | KeyObject} - * `oaepHash` {string} The hash function to use for OAEP padding. + * `oaepHash` {string} The hash function to use for OAEP padding and MGF1. **Default:** `'sha1'` * `oaepLabel` {Buffer | TypedArray | DataView} The label to use for OAEP padding. If not specified, no label is used. @@ -2529,7 +2530,7 @@ changes: * `key` {Object | string | Buffer | KeyObject} * `key` {string | Buffer | KeyObject} A PEM encoded public or private key. - * `oaepHash` {string} The hash function to use for OAEP padding. + * `oaepHash` {string} The hash function to use for OAEP padding and MGF1. **Default:** `'sha1'` * `oaepLabel` {Buffer | TypedArray | DataView} The label to use for OAEP padding. If not specified, no label is used. diff --git a/doc/api/dgram.md b/doc/api/dgram.md index 2dabf72d668587..5235589f2d3f94 100644 --- a/doc/api/dgram.md +++ b/doc/api/dgram.md @@ -73,8 +73,11 @@ function is passed a single `Error` object. added: v0.1.99 --> -The `'listening'` event is emitted whenever a socket begins listening for -datagram messages. This occurs as soon as UDP sockets are created. +The `'listening'` event is emitted once the `dgram.Socket` is addressable and +can receive data. This happens either explicitly with `socket.bind()` or +implicitly the first time data is sent using `socket.send()`. +Until the `dgram.Socket` is listening, the underlying system resources do not +exist and calls such as `socket.address()` and `socket.setTTL()` will fail. ### Event: `'message'` diff --git a/doc/api/esm.md b/doc/api/esm.md index 3b2d859b190ea6..da2f5184ed9d4d 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -1645,7 +1645,7 @@ The resolver can throw the following errors: > 1. If _exports_ contains any index property keys, as defined in ECMA-262 > [6.1.7 Array Index][], throw an _Invalid Package Configuration_ error. > 1. For each property _p_ of _target_, in object insertion order as, -> 1. If _env_ contains an entry for _p_, then +> 1. If _p_ equals _"default"_ or _env_ contains an entry for _p_, then > 1. Let _targetValue_ be the value of the _p_ property in _target_. > 1. Return the result of **PACKAGE_EXPORTS_TARGET_RESOLVE**( > _packageURL_, _targetValue_, _subpath_, _env_), continuing the diff --git a/doc/api/events.md b/doc/api/events.md index 93939131a513c6..854150de3a4982 100644 --- a/doc/api/events.md +++ b/doc/api/events.md @@ -715,10 +715,9 @@ added: v0.3.5 By default `EventEmitter`s will print a warning if more than `10` listeners are added for a particular event. This is a useful default that helps finding -memory leaks. Obviously, not all events should be limited to just 10 listeners. -The `emitter.setMaxListeners()` method allows the limit to be modified for this -specific `EventEmitter` instance. The value can be set to `Infinity` (or `0`) -to indicate an unlimited number of listeners. +memory leaks. The `emitter.setMaxListeners()` method allows the limit to be +modified for this specific `EventEmitter` instance. The value can be set to +`Infinity` (or `0`) to indicate an unlimited number of listeners. Returns a reference to the `EventEmitter`, so that calls can be chained. @@ -888,6 +887,7 @@ const { on, EventEmitter } = require('events'); // if concurrent execution is required. console.log(event); // prints ['bar'] [42] } + // Unreachable here })(); ``` diff --git a/doc/api/fs.md b/doc/api/fs.md index 8a96797fb68bc1..c3a94862b5ce30 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -152,8 +152,8 @@ fs.open(Buffer.from('/open/some/file.txt'), 'r', (err, fd) => { On Windows, Node.js follows the concept of per-drive working directory. This behavior can be observed when using a drive path without a backslash. For -example `fs.readdirSync('c:\\')` can potentially return a different result than -`fs.readdirSync('c:')`. For more information, see +example `fs.readdirSync('C:\\')` can potentially return a different result than +`fs.readdirSync('C:')`. For more information, see [this MSDN page][MSDN-Rel-Path]. ### URL object support @@ -2735,7 +2735,7 @@ changes: Read data from the file specified by `fd`. -`buffer` is the buffer that the data will be written to. +`buffer` is the buffer that the data (read from the fd) will be written to. `offset` is the offset in the buffer to start writing at. @@ -3758,6 +3758,9 @@ unavailable in some situations. The recursive option is only supported on macOS and Windows. +On Windows, no events will be emitted if the watched directory is moved or +renamed. An `EPERM` error is reported when the watched directory is deleted. + #### Availability @@ -3774,10 +3777,10 @@ to be notified of filesystem changes. * On Aix systems, this feature depends on [`AHAFS`][], which must be enabled. If the underlying functionality is not available for some reason, then -`fs.watch` will not be able to function. For example, watching files or -directories can be unreliable, and in some cases impossible, on network file -systems (NFS, SMB, etc), or host file systems when using virtualization software -such as Vagrant, Docker, etc. +`fs.watch()` will not be able to function and may thrown an exception. +For example, watching files or directories can be unreliable, and in some +cases impossible, on network file systems (NFS, SMB, etc) or host file systems +when using virtualization software such as Vagrant or Docker. It is still possible to use `fs.watchFile()`, which uses stat polling, but this method is slower and less reliable. diff --git a/doc/api/http.md b/doc/api/http.md index 6de82da455546f..be4642177a73c0 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -239,6 +239,9 @@ added: v0.11.4 An object which contains arrays of sockets currently awaiting use by the agent when `keepAlive` is enabled. Do not modify. +Sockets in the `freeSockets` list will be automatically destroyed and +removed from the array on `'timeout'`. + ### `agent.getName(options)` @@ -736,6 +722,8 @@ changes: Use the internal `require()` machinery to look up the location of a module, but rather than loading the module, just return the resolved filename. +If the module can not be found, a `MODULE_NOT_FOUND` error is thrown. + ##### `require.resolve.paths(request)` -* Returns: {Object|string} +* Returns: {Object|string|null} Returns the bound `address`, the address `family` name, and `port` of the server as reported by the operating system if listening on an IP socket @@ -138,7 +138,8 @@ server.listen(() => { }); ``` -Don't call `server.address()` until the `'listening'` event has been emitted. +`server.address()` returns `null` before the `'listening'` event has been +emitted or after calling `server.close()`. ### `server.close([callback])` * `port` {number} Port the socket should connect to. Will be passed to - [`socket.connect(port[, host][, connectListener])`][`socket.connect(port, host)`]. + [`socket.connect(port[, host][, connectListener])`][`socket.connect(port)`]. * `host` {string} Host the socket should connect to. Will be passed to - [`socket.connect(port[, host][, connectListener])`][`socket.connect(port, host)`]. + [`socket.connect(port[, host][, connectListener])`][`socket.connect(port)`]. **Default:** `'localhost'`. * `connectListener` {Function} Common parameter of the [`net.createConnection()`][] functions, an "once" listener for the `'connect'` event on the initiating socket. Will be passed to - [`socket.connect(port[, host][, connectListener])`][`socket.connect(port, host)`]. + [`socket.connect(port[, host][, connectListener])`][`socket.connect(port)`]. * Returns: {net.Socket} The newly created socket used to start the connection. Initiates a TCP connection. This function creates a new [`net.Socket`][] with all options set to default, immediately initiates connection with -[`socket.connect(port[, host][, connectListener])`][`socket.connect(port, host)`], +[`socket.connect(port[, host][, connectListener])`][`socket.connect(port)`], then returns the `net.Socket` that starts the connection. ## `net.createServer([options][, connectionListener])` @@ -1174,8 +1174,7 @@ Test this by using `telnet`: $ telnet localhost 8124 ``` -To listen on the socket `/tmp/echo.sock` the third line from the last would -just be changed to: +To listen on the socket `/tmp/echo.sock`: ```js server.listen('/tmp/echo.sock', () => { @@ -1260,7 +1259,7 @@ Returns `true` if input is a version 6 IP address, otherwise returns `false`. [`socket.connect()`]: #net_socket_connect [`socket.connect(options)`]: #net_socket_connect_options_connectlistener [`socket.connect(path)`]: #net_socket_connect_path_connectlistener -[`socket.connect(port, host)`]: #net_socket_connect_port_host_connectlistener +[`socket.connect(port)`]: #net_socket_connect_port_host_connectlistener [`socket.connecting`]: #net_socket_connecting [`socket.destroy()`]: #net_socket_destroy_exception [`socket.end()`]: #net_socket_end_data_encoding_callback diff --git a/doc/api/path.md b/doc/api/path.md index c05a5c29efb12f..945c1a0394ca46 100644 --- a/doc/api/path.md +++ b/doc/api/path.md @@ -56,8 +56,8 @@ path.posix.basename('/tmp/myfile.html'); On Windows Node.js follows the concept of per-drive working directory. This behavior can be observed when using a drive path without a backslash. For -example, `path.resolve('c:\\')` can potentially return a different result than -`path.resolve('c:')`. For more information, see +example, `path.resolve('C:\\')` can potentially return a different result than +`path.resolve('C:')`. For more information, see [this MSDN page][MSDN-Rel-Path]. ## `path.basename(path[, ext])` diff --git a/doc/api/perf_hooks.md b/doc/api/perf_hooks.md index 02dee38bae1987..a34d41ce3f250f 100644 --- a/doc/api/perf_hooks.md +++ b/doc/api/perf_hooks.md @@ -17,9 +17,12 @@ const obs = new PerformanceObserver((items) => { performance.clearMarks(); }); obs.observe({ entryTypes: ['measure'] }); +performance.measure('Start to Now'); performance.mark('A'); doSomeLongRunningProcess(() => { + performance.measure('A to Now', 'A'); + performance.mark('B'); performance.measure('A to B', 'A', 'B'); }); @@ -53,14 +56,18 @@ Creates a new `PerformanceMark` entry in the Performance Timeline. A `performanceEntry.duration` is always `0`. Performance marks are used to mark specific significant moments in the Performance Timeline. -### `performance.measure(name, startMark, endMark)` +### `performance.measure(name[, startMark[, endMark]])` * `name` {string} -* `startMark` {string} -* `endMark` {string} +* `startMark` {string} Optional. +* `endMark` {string} Optional. Creates a new `PerformanceMeasure` entry in the Performance Timeline. A `PerformanceMeasure` is a subclass of `PerformanceEntry` whose @@ -73,9 +80,10 @@ Performance Timeline, or *may* identify any of the timestamp properties provided by the `PerformanceNodeTiming` class. If the named `startMark` does not exist, then `startMark` is set to [`timeOrigin`][] by default. -The `endMark` argument must identify any *existing* `PerformanceMark` in the -Performance Timeline or any of the timestamp properties provided by the -`PerformanceNodeTiming` class. If the named `endMark` does not exist, an +The optional `endMark` argument must identify any *existing* `PerformanceMark` +in the Performance Timeline or any of the timestamp properties provided by the +`PerformanceNodeTiming` class. `endMark` will be `performance.now()` +if no parameter is passed, otherwise if the named `endMark` does not exist, an error will be thrown. ### `performance.nodeTiming` diff --git a/doc/api/process.md b/doc/api/process.md index ed439c44156441..72fb416373fa12 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -486,11 +486,17 @@ process.on('SIGTERM', handle); the process hanging in an endless loop, since listeners attached using `process.on()` are called asynchronously and therefore unable to correct the underlying problem. - -Windows does not support sending signals, but Node.js offers some emulation -with [`process.kill()`][], and [`subprocess.kill()`][]. Sending signal `0` can -be used to test for the existence of a process. Sending `SIGINT`, `SIGTERM`, -and `SIGKILL` cause the unconditional termination of the target process. +* `0` can be sent to test for the existence of a process, it has no effect if + the process exists, but will throw an error if the process does not exist. + +Windows does not support signals so has no equivalent to termination by signal, +but Node.js offers some emulation with [`process.kill()`][], and +[`subprocess.kill()`][]: +* Sending `SIGINT`, `SIGTERM`, and `SIGKILL` will cause the unconditional + termination of the target process, and afterwards, subprocess will report that + the process was terminated by signal. +* Sending signal `0` can be used as a platform independent way to test for the + existence of a process. ## `process.abort()` * `iterable` {Iterable} Object implementing the `Symbol.asyncIterator` or diff --git a/doc/api/string_decoder.md b/doc/api/string_decoder.md index 29defb71747095..54fcc876c9a9e9 100644 --- a/doc/api/string_decoder.md +++ b/doc/api/string_decoder.md @@ -49,7 +49,7 @@ console.log(decoder.end(Buffer.from([0xAC]))); added: v0.1.99 --> -* `encoding` {string} The character encoding the `StringDecoder` will use. +* `encoding` {string} The character [encoding][] the `StringDecoder` will use. **Default:** `'utf8'`. Creates a new `StringDecoder` instance. @@ -88,3 +88,5 @@ Returns a decoded string, ensuring that any incomplete multibyte characters at the end of the `Buffer`, or `TypedArray`, or `DataView` are omitted from the returned string and stored in an internal buffer for the next call to `stringDecoder.write()` or `stringDecoder.end()`. + +[encoding]: buffer.html#buffer_buffers_and_character_encodings diff --git a/doc/api/vm.md b/doc/api/vm.md index e6792385ef2138..595f4fdfa40ccc 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -312,9 +312,8 @@ specification. Unlike `vm.Script` however, every `vm.Module` object is bound to a context from its creation. Operations on `vm.Module` objects are intrinsically asynchronous, -in contrast with the synchronous nature of `vm.Script` objects. With the help -of async functions, however, manipulating `vm.Module` objects is fairly -straightforward. +in contrast with the synchronous nature of `vm.Script` objects. The use of +'async' functions can help with manipulating `vm.Module` objects. Using a `vm.Module` object requires three distinct steps: creation/parsing, linking, and evaluation. These three steps are illustrated in the following diff --git a/doc/api_assets/style.css b/doc/api_assets/style.css index 9b6be151420d6c..5799a777353ba7 100644 --- a/doc/api_assets/style.css +++ b/doc/api_assets/style.css @@ -251,7 +251,7 @@ table { th, td { border: 1px solid #aaa; - padding: .75rem 1rem; + padding: .5rem; vertical-align: top; } @@ -259,6 +259,22 @@ th { text-align: left; } +td { + word-break: break-all; /* Fallback if break-word isn't supported */ + word-break: break-word; +} + +@media only screen and (min-width: 600px) { + th, + td { + padding: .75rem 1rem; + } + + td:first-child { + word-break: normal; + } +} + ol, ul, dl { diff --git a/doc/changelogs/CHANGELOG_V12.md b/doc/changelogs/CHANGELOG_V12.md index 60925eeb6e4101..bc9463d95eb697 100644 --- a/doc/changelogs/CHANGELOG_V12.md +++ b/doc/changelogs/CHANGELOG_V12.md @@ -10,6 +10,7 @@ +12.16.3
12.16.2
12.16.1
12.16.0
@@ -55,6 +56,211 @@ * [io.js](CHANGELOG_IOJS.md) * [Archive](CHANGELOG_ARCHIVE.md) + +## 2020-04-28, Version 12.16.3 'Erbium' (LTS), @targos + +### Notable Changes + +* **Dependencies**: + * Updated OpenSSL to 1.1.1g (Hassaan Pasha) [#32971](https://github.com/nodejs/node/pull/32971). + * Updated c-ares to 1.16.0 (Anna Henningsen) [#32246](https://github.com/nodejs/node/pull/32246). + * Updated experimental uvwasi to 0.0.6 (Colin Ihrig) [#32309](https://github.com/nodejs/node/pull/32309). +* **ESM (experimental)**: + * Additional warnings are no longer printed for modules that use conditional + exports or package name self resolution (Guy Bedford) [#31845](https://github.com/nodejs/node/pull/31845). + +### Commits + +* [[`2c5b0147fa`](https://github.com/nodejs/node/commit/2c5b0147fa)] - **async_hooks**: use hasHooks function internally (rickyes) [#32656](https://github.com/nodejs/node/pull/32656) +* [[`28abbfd594`](https://github.com/nodejs/node/commit/28abbfd594)] - **async_hooks**: move to lazy destroy hook registration in AsyncResource (Andrey Pechkurov) [#32429](https://github.com/nodejs/node/pull/32429) +* [[`146ad4eaae`](https://github.com/nodejs/node/commit/146ad4eaae)] - **async_hooks**: avoid resource reuse by FileHandle (Gerhard Stoebich) [#31972](https://github.com/nodejs/node/pull/31972) +* [[`39a3cc13dc`](https://github.com/nodejs/node/commit/39a3cc13dc)] - **buffer,n-api**: fix double ArrayBuffer::Detach() during cleanup (Anna Henningsen) [#33039](https://github.com/nodejs/node/pull/33039) +* [[`20f3e9d836`](https://github.com/nodejs/node/commit/20f3e9d836)] - **build**: output dots instead of tap in GitHub actions (Michaël Zasso) [#32714](https://github.com/nodejs/node/pull/32714) +* [[`c98aa9312e`](https://github.com/nodejs/node/commit/c98aa9312e)] - **build**: move doc versions JSON file out of out/doc (Richard Lau) [#32728](https://github.com/nodejs/node/pull/32728) +* [[`546a9ea998`](https://github.com/nodejs/node/commit/546a9ea998)] - **build**: fix LINT\_MD\_NEWER assignment (Rich Trott) [#32712](https://github.com/nodejs/node/pull/32712) +* [[`ae772b7c6a`](https://github.com/nodejs/node/commit/ae772b7c6a)] - **build**: log detected compilers in --verbose mode (Richard Lau) [#32715](https://github.com/nodejs/node/pull/32715) +* [[`43055519d3`](https://github.com/nodejs/node/commit/43055519d3)] - **build**: use tabs for indentation in Makefile (Luigi Pinca) [#32614](https://github.com/nodejs/node/pull/32614) +* [[`2e31ac96f3`](https://github.com/nodejs/node/commit/2e31ac96f3)] - **build**: remove make lint on lint-py (himself65) [#32599](https://github.com/nodejs/node/pull/32599) +* [[`d8a948f0fc`](https://github.com/nodejs/node/commit/d8a948f0fc)] - **build**: disable -Wattributes warnings on aix (Ben Noordhuis) [#32419](https://github.com/nodejs/node/pull/32419) +* [[`a3848e51aa`](https://github.com/nodejs/node/commit/a3848e51aa)] - **build**: expand ASAN acronym in configure help (Sam Roberts) [#32325](https://github.com/nodejs/node/pull/32325) +* [[`c8541a7d7a`](https://github.com/nodejs/node/commit/c8541a7d7a)] - **build**: disable libstdc++ debug containers globally (Ben Noordhuis) [#30147](https://github.com/nodejs/node/pull/30147) +* [[`d3c9a82a6e`](https://github.com/nodejs/node/commit/d3c9a82a6e)] - **build**: remove empty line on node.gyp file (Juan José Arboleda) [#31952](https://github.com/nodejs/node/pull/31952) +* [[`e65586985f`](https://github.com/nodejs/node/commit/e65586985f)] - **build**: support android build on ndk version equal or above 23 (forfun414) [#31521](https://github.com/nodejs/node/pull/31521) +* [[`790841597d`](https://github.com/nodejs/node/commit/790841597d)] - **console**: fixup error message (James M Snell) [#32475](https://github.com/nodejs/node/pull/32475) +* [[`d19251630e`](https://github.com/nodejs/node/commit/d19251630e)] - **crypto**: clear openssl error stack after en/decrypt (Ben Noordhuis) [#32248](https://github.com/nodejs/node/pull/32248) +* [[`51f05d2f3d`](https://github.com/nodejs/node/commit/51f05d2f3d)] - **deps**: update archs files for OpenSSL-1.1.1g (Hassaan Pasha) [#32971](https://github.com/nodejs/node/pull/32971) +* [[`a89744f4e0`](https://github.com/nodejs/node/commit/a89744f4e0)] - **deps**: upgrade openssl sources to 1.1.1g (Hassaan Pasha) [#32971](https://github.com/nodejs/node/pull/32971) +* [[`80c89d4ec7`](https://github.com/nodejs/node/commit/80c89d4ec7)] - **deps**: update archs files for OpenSSL-1.1.1f (Hassaan Pasha) [#32583](https://github.com/nodejs/node/pull/32583) +* [[`c9cc38114a`](https://github.com/nodejs/node/commit/c9cc38114a)] - **deps**: upgrade openssl sources to 1.1.1f (Hassaan Pasha) [#32583](https://github.com/nodejs/node/pull/32583) +* [[`fedcb16144`](https://github.com/nodejs/node/commit/fedcb16144)] - **deps**: update acorn to v7.1.1 (Ruben Bridgewater) [#32310](https://github.com/nodejs/node/pull/32310) +* [[`37476a339a`](https://github.com/nodejs/node/commit/37476a339a)] - **deps**: upgrade to c-ares v1.16.0 (Anna Henningsen) [#32246](https://github.com/nodejs/node/pull/32246) +* [[`fe0e1dbd13`](https://github.com/nodejs/node/commit/fe0e1dbd13)] - **deps**: update to uvwasi 0.0.6 (Colin Ihrig) [#32309](https://github.com/nodejs/node/pull/32309) +* [[`2e92cb476d`](https://github.com/nodejs/node/commit/2e92cb476d)] - **deps**: V8: cherry-pick f9257802c1c0 (Matheus Marchini) [#32180](https://github.com/nodejs/node/pull/32180) +* [[`0e922440d6`](https://github.com/nodejs/node/commit/0e922440d6)] - **deps,doc**: move openssl maintenance guide to doc (Sam Roberts) [#32209](https://github.com/nodejs/node/pull/32209) +* [[`06d16cf9ef`](https://github.com/nodejs/node/commit/06d16cf9ef)] - **dns**: remove duplicate code (rickyes) [#32664](https://github.com/nodejs/node/pull/32664) +* [[`af392a114b`](https://github.com/nodejs/node/commit/af392a114b)] - **doc**: add link to code ide configs (Robert Nagy) [#32767](https://github.com/nodejs/node/pull/32767) +* [[`b1790fbf4b`](https://github.com/nodejs/node/commit/b1790fbf4b)] - **doc**: replace node-test-pull-request-lite-pipeline from onboarding (Juan José Arboleda) [#32736](https://github.com/nodejs/node/pull/32736) +* [[`00ce6a3240`](https://github.com/nodejs/node/commit/00ce6a3240)] - **doc**: add useful v8 option section (Nimit) [#32262](https://github.com/nodejs/node/pull/32262) +* [[`c78019d792`](https://github.com/nodejs/node/commit/c78019d792)] - **doc**: add himself65 to collaborators (himself65) [#32734](https://github.com/nodejs/node/pull/32734) +* [[`16126328ac`](https://github.com/nodejs/node/commit/16126328ac)] - **doc**: clarify behavior of napi\_get\_typedarray\_info (Michael Dawson) [#32603](https://github.com/nodejs/node/pull/32603) +* [[`a5fd29b024`](https://github.com/nodejs/node/commit/a5fd29b024)] - **doc**: remove optional parameter from markdown anchor link (Rich Trott) [#32671](https://github.com/nodejs/node/pull/32671) +* [[`d2c86a9dfc`](https://github.com/nodejs/node/commit/d2c86a9dfc)] - **doc**: clarify `listening` event (Harshitha KP) [#32581](https://github.com/nodejs/node/pull/32581) +* [[`9039c03967`](https://github.com/nodejs/node/commit/9039c03967)] - **doc**: update Ninja information in build guide (Adrian Estrada) [#32629](https://github.com/nodejs/node/pull/32629) +* [[`1d563a646e`](https://github.com/nodejs/node/commit/1d563a646e)] - **doc**: correct version metadata for Readable.from (Dave Vandyke) [#32639](https://github.com/nodejs/node/pull/32639) +* [[`5e2791ee84`](https://github.com/nodejs/node/commit/5e2791ee84)] - **doc**: adjust paths in openssl maintenance guide (Hassaan Pasha) [#32593](https://github.com/nodejs/node/pull/32593) +* [[`21c3685623`](https://github.com/nodejs/node/commit/21c3685623)] - **doc**: clarify docs fs.watch exception may be emitted (Juan José Arboleda) [#32513](https://github.com/nodejs/node/pull/32513) +* [[`c3d91eb94d`](https://github.com/nodejs/node/commit/c3d91eb94d)] - **doc**: add unreachable code on events example (himself65) [#32364](https://github.com/nodejs/node/pull/32364) +* [[`b4ba9b8bef`](https://github.com/nodejs/node/commit/b4ba9b8bef)] - **doc**: clarify `length` param in `buffer.write` (Harshitha KP) [#32119](https://github.com/nodejs/node/pull/32119) +* [[`5996df3c39`](https://github.com/nodejs/node/commit/5996df3c39)] - **doc**: document that server.address() can return null (Thomas Watson Steen) [#32519](https://github.com/nodejs/node/pull/32519) +* [[`a299e9cf28`](https://github.com/nodejs/node/commit/a299e9cf28)] - **doc**: return type of `crypto.getFips()` may change (Richard Lau) [#32580](https://github.com/nodejs/node/pull/32580) +* [[`4604127697`](https://github.com/nodejs/node/commit/4604127697)] - **doc**: fix return type of `crypto.getFips()` (Richard Lau) [#32580](https://github.com/nodejs/node/pull/32580) +* [[`f2235f68aa`](https://github.com/nodejs/node/commit/f2235f68aa)] - **doc**: clarify `requireManualDestroy` option (Harshitha KP) [#32514](https://github.com/nodejs/node/pull/32514) +* [[`7e952f2d38`](https://github.com/nodejs/node/commit/7e952f2d38)] - **doc**: fix wordy sentence (Moni) [#32567](https://github.com/nodejs/node/pull/32567) +* [[`f93b770bda`](https://github.com/nodejs/node/commit/f93b770bda)] - **doc**: fix more links (Alba Mendez) [#32586](https://github.com/nodejs/node/pull/32586) +* [[`d764414706`](https://github.com/nodejs/node/commit/d764414706)] - **doc**: improve markdown link checker (Alba Mendez) [#32586](https://github.com/nodejs/node/pull/32586) +* [[`3d36458cc6`](https://github.com/nodejs/node/commit/3d36458cc6)] - **doc**: add flarna to collaborators (Gerhard Stoebich) [#32620](https://github.com/nodejs/node/pull/32620) +* [[`4b417f87bd`](https://github.com/nodejs/node/commit/4b417f87bd)] - **doc**: improve fs.read documentation (Hachimi Aa (Sfeir)) [#29270](https://github.com/nodejs/node/pull/29270) +* [[`959055f225`](https://github.com/nodejs/node/commit/959055f225)] - **doc**: add ASAN build instructions (gengjiawen) [#32436](https://github.com/nodejs/node/pull/32436) +* [[`f1552f830f`](https://github.com/nodejs/node/commit/f1552f830f)] - **doc**: update context-aware section of addon doc (Gabriel Schulhof) [#28659](https://github.com/nodejs/node/pull/28659) +* [[`d0d414d98c`](https://github.com/nodejs/node/commit/d0d414d98c)] - **doc**: update AUTHORS list (Luigi Pinca) [#32222](https://github.com/nodejs/node/pull/32222) +* [[`e51c42dc52`](https://github.com/nodejs/node/commit/e51c42dc52)] - **doc**: tests local links in markdown documents (Antoine du HAMEL) [#32359](https://github.com/nodejs/node/pull/32359) +* [[`8b355eab57`](https://github.com/nodejs/node/commit/8b355eab57)] - **doc**: fix profile type of --heap-prof-name (Syohei YOSHIDA) [#32404](https://github.com/nodejs/node/pull/32404) +* [[`59a8dbebc2`](https://github.com/nodejs/node/commit/59a8dbebc2)] - **doc**: use uppercase on windows path (himself65) [#32294](https://github.com/nodejs/node/pull/32294) +* [[`fa9b10cebe`](https://github.com/nodejs/node/commit/fa9b10cebe)] - **doc**: rename cve\_management\_process.md to fit doc style guide (Ling Samuel) [#32456](https://github.com/nodejs/node/pull/32456) +* [[`3ed9fcd784`](https://github.com/nodejs/node/commit/3ed9fcd784)] - **doc**: add mildsunrise to collaborators (Alba Mendez) [#32525](https://github.com/nodejs/node/pull/32525) +* [[`5d15dd3fe3`](https://github.com/nodejs/node/commit/5d15dd3fe3)] - **doc**: add link to DNS definition (unknown) [#32228](https://github.com/nodejs/node/pull/32228) +* [[`8d27eb94d1`](https://github.com/nodejs/node/commit/8d27eb94d1)] - **doc**: remove extraneous sentence in events.md (Rich Trott) [#32457](https://github.com/nodejs/node/pull/32457) +* [[`1c84d85437`](https://github.com/nodejs/node/commit/1c84d85437)] - **doc**: trim wording in n-api.md text about exceptions (Rich Trott) [#32457](https://github.com/nodejs/node/pull/32457) +* [[`bba8dd3344`](https://github.com/nodejs/node/commit/bba8dd3344)] - **doc**: simplify and correct example descriptions in net.md (Rich Trott) [#32451](https://github.com/nodejs/node/pull/32451) +* [[`2976ac6c2e`](https://github.com/nodejs/node/commit/2976ac6c2e)] - **doc**: add new TSC members (Michael Dawson) [#32473](https://github.com/nodejs/node/pull/32473) +* [[`3d752cd3b9`](https://github.com/nodejs/node/commit/3d752cd3b9)] - **doc**: improve wording in vm.md (Rich Trott) [#32427](https://github.com/nodejs/node/pull/32427) +* [[`80a8e20826`](https://github.com/nodejs/node/commit/80a8e20826)] - **doc**: update security release process (Sam Roberts) [#31679](https://github.com/nodejs/node/pull/31679) +* [[`80493f54c8`](https://github.com/nodejs/node/commit/80493f54c8)] - **doc**: fix some 404 links (Thomas Watson Steen) [#32200](https://github.com/nodejs/node/pull/32200) +* [[`76e2455b06`](https://github.com/nodejs/node/commit/76e2455b06)] - **doc**: expand fs.watch caveats (Bartosz Sosnowski) [#32176](https://github.com/nodejs/node/pull/32176) +* [[`c1c3aa1b5f`](https://github.com/nodejs/node/commit/c1c3aa1b5f)] - **doc**: add Ruben to TSC (Michael Dawson) [#32213](https://github.com/nodejs/node/pull/32213) +* [[`385faf7721`](https://github.com/nodejs/node/commit/385faf7721)] - **doc**: include the error type in the request.resolve doc (Joe Pea) [#32152](https://github.com/nodejs/node/pull/32152) +* [[`11899f647a`](https://github.com/nodejs/node/commit/11899f647a)] - **doc**: clear up child\_process command resolution (Denys Otrishko) [#32091](https://github.com/nodejs/node/pull/32091) +* [[`e33e989f20`](https://github.com/nodejs/node/commit/e33e989f20)] - **doc**: clarify windows specific behaviour (Sam Roberts) [#32079](https://github.com/nodejs/node/pull/32079) +* [[`860239255b`](https://github.com/nodejs/node/commit/860239255b)] - **doc**: improve Buffer documentation (Anna Henningsen) [#32086](https://github.com/nodejs/node/pull/32086) +* [[`ab1136a7ed`](https://github.com/nodejs/node/commit/ab1136a7ed)] - **doc**: add support encoding link on string\_decoder.md (himself65) [#31911](https://github.com/nodejs/node/pull/31911) +* [[`c439d83dbf`](https://github.com/nodejs/node/commit/c439d83dbf)] - **doc**: add entry for `AsyncHook` class (Harshitha KP) [#31865](https://github.com/nodejs/node/pull/31865) +* [[`e6e38ecf64`](https://github.com/nodejs/node/commit/e6e38ecf64)] - **doc**: prevent tables from shrinking page (David Gilbertson) [#31859](https://github.com/nodejs/node/pull/31859) +* [[`6e68d9816d`](https://github.com/nodejs/node/commit/6e68d9816d)] - **doc**: fix anchor for ERR\_TLS\_INVALID\_CONTEXT (Tobias Nießen) [#31915](https://github.com/nodejs/node/pull/31915) +* [[`d3b9a8810c`](https://github.com/nodejs/node/commit/d3b9a8810c)] - **doc,crypto**: clarify oaepHash option's impact (Filip Skokan) [#32340](https://github.com/nodejs/node/pull/32340) +* [[`b85bc0cc02`](https://github.com/nodejs/node/commit/b85bc0cc02)] - **fs**: fixup error message for invalid options.recursive (James M Snell) [#32472](https://github.com/nodejs/node/pull/32472) +* [[`010814856a`](https://github.com/nodejs/node/commit/010814856a)] - **fs**: fix writeFile\[Sync\] for non-seekable files (Alba Mendez) [#32006](https://github.com/nodejs/node/pull/32006) +* [[`225ddd5f42`](https://github.com/nodejs/node/commit/225ddd5f42)] - **http**: move free socket error handling to agent (Robert Nagy) [#32003](https://github.com/nodejs/node/pull/32003) +* [[`3b0204245d`](https://github.com/nodejs/node/commit/3b0204245d)] - **http**: don't emit 'readable' after 'close' (Robert Nagy) [#32277](https://github.com/nodejs/node/pull/32277) +* [[`52a52d2664`](https://github.com/nodejs/node/commit/52a52d2664)] - **http**: fixup options.method error message (James M Snell) [#32471](https://github.com/nodejs/node/pull/32471) +* [[`cf47bb9818`](https://github.com/nodejs/node/commit/cf47bb9818)] - **http**: don't emit 'finish' after 'error' (Robert Nagy) [#32276](https://github.com/nodejs/node/pull/32276) +* [[`f9123eb91b`](https://github.com/nodejs/node/commit/f9123eb91b)] - **http**: fix socket re-use races (Robert Nagy) [#32000](https://github.com/nodejs/node/pull/32000) +* [[`e54eb46cdb`](https://github.com/nodejs/node/commit/e54eb46cdb)] - **http2**: rename counter in `mapToHeaders` inner loop (Mateusz Krawczuk) [#32012](https://github.com/nodejs/node/pull/32012) +* [[`0db58753db`](https://github.com/nodejs/node/commit/0db58753db)] - **lib**: fix return type of setTimeout in net.Socket (龙腾道) [#32722](https://github.com/nodejs/node/pull/32722) +* [[`a152792590`](https://github.com/nodejs/node/commit/a152792590)] - **lib**: removes unnecessary params (Jesus Hernandez) [#32694](https://github.com/nodejs/node/pull/32694) +* [[`7dd001c1db`](https://github.com/nodejs/node/commit/7dd001c1db)] - **lib**: changed functional logic in cluster schedulers (Yash Ladha) [#32505](https://github.com/nodejs/node/pull/32505) +* [[`5a671772a2`](https://github.com/nodejs/node/commit/5a671772a2)] - **lib**: use spread operator on cluster (himself65) [#32125](https://github.com/nodejs/node/pull/32125) +* [[`4d0be3dce5`](https://github.com/nodejs/node/commit/4d0be3dce5)] - **meta**: move inactive collaborators to emeriti (Rich Trott) [#32151](https://github.com/nodejs/node/pull/32151) +* [[`ecddf6519f`](https://github.com/nodejs/node/commit/ecddf6519f)] - **module**: disable conditional exports, self resolve warnings (Guy Bedford) [#31845](https://github.com/nodejs/node/pull/31845) +* [[`717f9c5905`](https://github.com/nodejs/node/commit/717f9c5905)] - **module**: path-only CJS exports extension searching (Guy Bedford) [#32351](https://github.com/nodejs/node/pull/32351) +* [[`ff5ab6f925`](https://github.com/nodejs/node/commit/ff5ab6f925)] - **net**: fix crash if POLLHUP is received (Santiago Gimeno) [#32590](https://github.com/nodejs/node/pull/32590) +* [[`ed21d32a7c`](https://github.com/nodejs/node/commit/ed21d32a7c)] - **net**: wait for shutdown to complete before closing (Robert Nagy) [#32491](https://github.com/nodejs/node/pull/32491) +* [[`7d66ceadbb`](https://github.com/nodejs/node/commit/7d66ceadbb)] - **perf,src**: add HistogramBase and internal/histogram.js (James M Snell) [#31988](https://github.com/nodejs/node/pull/31988) +* [[`f302ac9ae4`](https://github.com/nodejs/node/commit/f302ac9ae4)] - **perf_hooks**: allow omitted parameters in 'performance.measure' (himself65) [#32651](https://github.com/nodejs/node/pull/32651) +* [[`7c0c4e9a7e`](https://github.com/nodejs/node/commit/7c0c4e9a7e)] - **repl**: fixup error message (James M Snell) [#32474](https://github.com/nodejs/node/pull/32474) +* [[`522101dbca`](https://github.com/nodejs/node/commit/522101dbca)] - **src**: removes unused v8::Integer and v8::Array namespace (Jesus Hernandez) [#32779](https://github.com/nodejs/node/pull/32779) +* [[`f9d94143fb`](https://github.com/nodejs/node/commit/f9d94143fb)] - **src**: remove unused v8::TryCatch namespace (Juan José Arboleda) [#32729](https://github.com/nodejs/node/pull/32729) +* [[`d0d7ebc2a6`](https://github.com/nodejs/node/commit/d0d7ebc2a6)] - **src**: remove duplicated code (himself65) [#32719](https://github.com/nodejs/node/pull/32719) +* [[`a50220955e`](https://github.com/nodejs/node/commit/a50220955e)] - **src**: refactor to avoid goto in node\_file.cc (Tobias Nießen) [#32637](https://github.com/nodejs/node/pull/32637) +* [[`fabb53ed79`](https://github.com/nodejs/node/commit/fabb53ed79)] - **src**: fix warnings on SPrintF (himself65) [#32558](https://github.com/nodejs/node/pull/32558) +* [[`3605a9d67a`](https://github.com/nodejs/node/commit/3605a9d67a)] - **src**: replace goto with lambda in options parser (Tobias Nießen) [#32635](https://github.com/nodejs/node/pull/32635) +* [[`872f893e0f`](https://github.com/nodejs/node/commit/872f893e0f)] - **src**: align PerformanceState class name with conventions (Anna Henningsen) [#32539](https://github.com/nodejs/node/pull/32539) +* [[`191cde0e4d`](https://github.com/nodejs/node/commit/191cde0e4d)] - **src**: remove unnecessary 'Local.As' operation (himself65) [#32286](https://github.com/nodejs/node/pull/32286) +* [[`6d71eb5b5b`](https://github.com/nodejs/node/commit/6d71eb5b5b)] - **src**: add test/abort build tasks (Christian Niederer) [#31740](https://github.com/nodejs/node/pull/31740) +* [[`0dfb9514de`](https://github.com/nodejs/node/commit/0dfb9514de)] - **src**: add aliased-buffer-overflow abort test (Christian Niederer) [#31740](https://github.com/nodejs/node/pull/31740) +* [[`28cfaa837e`](https://github.com/nodejs/node/commit/28cfaa837e)] - **src**: check for overflow when extending AliasedBufferBase (Christian Niederer) [#31740](https://github.com/nodejs/node/pull/31740) +* [[`4155358031`](https://github.com/nodejs/node/commit/4155358031)] - **src**: replace handle dereference with ContainerOf (Harshitha KP) [#32298](https://github.com/nodejs/node/pull/32298) +* [[`c9b22c8d6d`](https://github.com/nodejs/node/commit/c9b22c8d6d)] - **src**: enhance template function 'MakeUtf8String' (himself65) [#32322](https://github.com/nodejs/node/pull/32322) +* [[`ad347f4cbb`](https://github.com/nodejs/node/commit/ad347f4cbb)] - **src**: remove excess v8 namespace (himself65) [#32191](https://github.com/nodejs/node/pull/32191) +* [[`12d83b3242`](https://github.com/nodejs/node/commit/12d83b3242)] - **src**: clean v8 namespaces in env.cc file (Juan José Arboleda) [#32374](https://github.com/nodejs/node/pull/32374) +* [[`13a7e0546f`](https://github.com/nodejs/node/commit/13a7e0546f)] - **src**: check for empty maybe local (Xavier Stouder) [#32339](https://github.com/nodejs/node/pull/32339) +* [[`aaf94fd6bb`](https://github.com/nodejs/node/commit/aaf94fd6bb)] - **src**: cleanup DestroyParam when Environment exits (Anna Henningsen) [#32421](https://github.com/nodejs/node/pull/32421) +* [[`4b5fd24855`](https://github.com/nodejs/node/commit/4b5fd24855)] - **src**: enhance C++ sprintf utility (himself65) [#32385](https://github.com/nodejs/node/pull/32385) +* [[`46e68bb445`](https://github.com/nodejs/node/commit/46e68bb445)] - **src**: simplify IsolateData shortcut accesses (Anna Henningsen) [#32407](https://github.com/nodejs/node/pull/32407) +* [[`7aa2ee2bd8`](https://github.com/nodejs/node/commit/7aa2ee2bd8)] - **src**: delete CallbackInfo when cleared from cleanup hook (Anna Henningsen) [#32405](https://github.com/nodejs/node/pull/32405) +* [[`7a346f63d6`](https://github.com/nodejs/node/commit/7a346f63d6)] - **src**: update comment for SetImmediate() (Anna Henningsen) [#32300](https://github.com/nodejs/node/pull/32300) +* [[`46c751e7f1`](https://github.com/nodejs/node/commit/46c751e7f1)] - **src**: handle NULL env scenario (himself65) [#32230](https://github.com/nodejs/node/pull/32230) +* [[`9b6f678751`](https://github.com/nodejs/node/commit/9b6f678751)] - **src**: fix warn\_unused\_result compiler warning (Colin Ihrig) [#32241](https://github.com/nodejs/node/pull/32241) +* [[`4e268314b5`](https://github.com/nodejs/node/commit/4e268314b5)] - **src**: refactor to more safe method (gengjiawen) [#32087](https://github.com/nodejs/node/pull/32087) +* [[`f223d2c7e4`](https://github.com/nodejs/node/commit/f223d2c7e4)] - **src**: fix spawnSync CHECK when SIGKILL fails (Ben Noordhuis) [#31768](https://github.com/nodejs/node/pull/31768) +* [[`5b2f698b32`](https://github.com/nodejs/node/commit/5b2f698b32)] - **src**: fix missing extra ca in tls.rootCertificates (Eric Bickle) [#32075](https://github.com/nodejs/node/pull/32075) +* [[`a53980d947`](https://github.com/nodejs/node/commit/a53980d947)] - **src**: fix -Wmaybe-uninitialized compiler warning (Ben Noordhuis) [#31809](https://github.com/nodejs/node/pull/31809) +* [[`a2d961da23`](https://github.com/nodejs/node/commit/a2d961da23)] - **src**: remove unused include from node\_file.cc (Ben Noordhuis) [#31809](https://github.com/nodejs/node/pull/31809) +* [[`8fe70e88fe`](https://github.com/nodejs/node/commit/8fe70e88fe)] - **src**: elevate v8 namespace (RamanandPatil) [#32041](https://github.com/nodejs/node/pull/32041) +* [[`7e5e34d01e`](https://github.com/nodejs/node/commit/7e5e34d01e)] - **src**: simplify node\_worker.cc using new KVStore API (Denys Otrishko) [#31773](https://github.com/nodejs/node/pull/31773) +* [[`7152fe3180`](https://github.com/nodejs/node/commit/7152fe3180)] - **src**: improve KVStore API (Denys Otrishko) [#31773](https://github.com/nodejs/node/pull/31773) +* [[`3bf21b096e`](https://github.com/nodejs/node/commit/3bf21b096e)] - **src**: fix minor typo in base\_object.h (Daniel Bevenius) [#31535](https://github.com/nodejs/node/pull/31535) +* [[`8d1eeb1ae5`](https://github.com/nodejs/node/commit/8d1eeb1ae5)] - **stream**: combine properties using defineProperties (antsmartian) [#31187](https://github.com/nodejs/node/pull/31187) +* [[`d07dd313ae`](https://github.com/nodejs/node/commit/d07dd313ae)] - **stream**: add regression test for async iteration completion (Matteo Collina) [#31508](https://github.com/nodejs/node/pull/31508) +* [[`2f72054ec7`](https://github.com/nodejs/node/commit/2f72054ec7)] - **test**: replace console.log/error with debuglog (Agustin Daguerre) [#32695](https://github.com/nodejs/node/pull/32695) +* [[`bc9453a870`](https://github.com/nodejs/node/commit/bc9453a870)] - **test**: make sure that inspector tests finish (Anna Henningsen) [#32673](https://github.com/nodejs/node/pull/32673) +* [[`2cf7381a87`](https://github.com/nodejs/node/commit/2cf7381a87)] - **test**: fix check error name on error instance (himself65) [#32508](https://github.com/nodejs/node/pull/32508) +* [[`e4174165f3`](https://github.com/nodejs/node/commit/e4174165f3)] - ***Revert*** "**test**: mark empty udp tests flaky on OS X" (Luigi Pinca) [#32489](https://github.com/nodejs/node/pull/32489) +* [[`6feed98f33`](https://github.com/nodejs/node/commit/6feed98f33)] - **test**: remove unused variables on async hook test (Julian Duque) [#32630](https://github.com/nodejs/node/pull/32630) +* [[`b0386b4aaf`](https://github.com/nodejs/node/commit/b0386b4aaf)] - **test**: check that --expose-internals is disallowed in NODE\_OPTIONS (Juan José Arboleda) [#32554](https://github.com/nodejs/node/pull/32554) +* [[`0adc867d59`](https://github.com/nodejs/node/commit/0adc867d59)] - **test**: add Worker initialization failure test case (Harshitha KP) [#31929](https://github.com/nodejs/node/pull/31929) +* [[`73221278d7`](https://github.com/nodejs/node/commit/73221278d7)] - **test**: fix tool path in test-doctool-versions.js (Richard Lau) [#32645](https://github.com/nodejs/node/pull/32645) +* [[`90a5b9d964`](https://github.com/nodejs/node/commit/90a5b9d964)] - **test**: copy addons .gitignore to test/abort/ (Anna Henningsen) [#32624](https://github.com/nodejs/node/pull/32624) +* [[`39be571a3f`](https://github.com/nodejs/node/commit/39be571a3f)] - **test**: refactor test-http2-buffersize (Rich Trott) [#32540](https://github.com/nodejs/node/pull/32540) +* [[`f71007ff39`](https://github.com/nodejs/node/commit/f71007ff39)] - **test**: skip crypto test on arm buildbots (Ben Noordhuis) [#32636](https://github.com/nodejs/node/pull/32636) +* [[`4e405ee899`](https://github.com/nodejs/node/commit/4e405ee899)] - **test**: replace console.error() with debuglog calls (Rich Trott) [#32588](https://github.com/nodejs/node/pull/32588) +* [[`8083d452e6`](https://github.com/nodejs/node/commit/8083d452e6)] - **test**: add a missing common.mustCall (Harshitha KP) [#32305](https://github.com/nodejs/node/pull/32305) +* [[`416531227e`](https://github.com/nodejs/node/commit/416531227e)] - **test**: remove unnecessary console.log() calls (Juan José Arboleda) [#32541](https://github.com/nodejs/node/pull/32541) +* [[`30d21fb6e6`](https://github.com/nodejs/node/commit/30d21fb6e6)] - **test**: replace console.log() with debuglog() (Juan José Arboleda) [#32550](https://github.com/nodejs/node/pull/32550) +* [[`fcf1123052`](https://github.com/nodejs/node/commit/fcf1123052)] - **test**: validate util.format when the value is 'Infinity' (Andrés M. Gómez) [#32573](https://github.com/nodejs/node/pull/32573) +* [[`e2174e4e3c`](https://github.com/nodejs/node/commit/e2174e4e3c)] - **test**: fix fs test-fs-utimes strictEqual arg order (Ben Noordhuis) [#32420](https://github.com/nodejs/node/pull/32420) +* [[`32ab30cc35`](https://github.com/nodejs/node/commit/32ab30cc35)] - **test**: use common.mustCall in test-worker-esm-exit (himself65) [#32544](https://github.com/nodejs/node/pull/32544) +* [[`a0552441fa`](https://github.com/nodejs/node/commit/a0552441fa)] - **test**: use template strings in parallel tests (Daniel Estiven Rico Posada) [#32549](https://github.com/nodejs/node/pull/32549) +* [[`d53d152da3`](https://github.com/nodejs/node/commit/d53d152da3)] - **test**: add known issues test for #31733 (Ben Noordhuis) [#31734](https://github.com/nodejs/node/pull/31734) +* [[`d6f6623243`](https://github.com/nodejs/node/commit/d6f6623243)] - **test**: refactor test-http-information-processing (Rich Trott) [#32547](https://github.com/nodejs/node/pull/32547) +* [[`b6e739a6b3`](https://github.com/nodejs/node/commit/b6e739a6b3)] - **test**: skip a wasi test on IBMi PASE (Xu Meng) [#32459](https://github.com/nodejs/node/pull/32459) +* [[`a40e7daf3c`](https://github.com/nodejs/node/commit/a40e7daf3c)] - **test**: harden the tick sampling logic (Harshitha KP) [#32190](https://github.com/nodejs/node/pull/32190) +* [[`9c84d7773a`](https://github.com/nodejs/node/commit/9c84d7773a)] - **test**: skip some binding tests on IBMi PASE (Xu Meng) [#31967](https://github.com/nodejs/node/pull/31967) +* [[`afc0c708a2`](https://github.com/nodejs/node/commit/afc0c708a2)] - **test**: revise test-http-response-multi-content-length (Rich Trott) [#32526](https://github.com/nodejs/node/pull/32526) +* [[`df890ad3d2`](https://github.com/nodejs/node/commit/df890ad3d2)] - **test**: remove a duplicated test (himself65) [#32453](https://github.com/nodejs/node/pull/32453) +* [[`fa4de53a3e`](https://github.com/nodejs/node/commit/fa4de53a3e)] - **test**: check bundled binaries are signed on macOS (Richard Lau) [#32522](https://github.com/nodejs/node/pull/32522) +* [[`d9abea5e3f`](https://github.com/nodejs/node/commit/d9abea5e3f)] - **test**: unflake async-hooks/test-statwatcher (Bartosz Sosnowski) [#32484](https://github.com/nodejs/node/pull/32484) +* [[`5cae1b7a53`](https://github.com/nodejs/node/commit/5cae1b7a53)] - **test**: use Promise.all() in test-cluster-net-listen-ipv6only-false (Rich Trott) [#32398](https://github.com/nodejs/node/pull/32398) +* [[`60db56ddba`](https://github.com/nodejs/node/commit/60db56ddba)] - **test**: replace Map with Array in test-cluster-net-listen-ipv6only-false (Rich Trott) [#32398](https://github.com/nodejs/node/pull/32398) +* [[`565f0f73e2`](https://github.com/nodejs/node/commit/565f0f73e2)] - **test**: revise test-http-client-default-headers-exist (Rich Trott) [#32493](https://github.com/nodejs/node/pull/32493) +* [[`7f5b89c307`](https://github.com/nodejs/node/commit/7f5b89c307)] - **test**: use mustCall in place of countdown in timers test (Rich Trott) [#32416](https://github.com/nodejs/node/pull/32416) +* [[`97e352d1a6`](https://github.com/nodejs/node/commit/97e352d1a6)] - **test**: replace countdown with Promise.all() in cluster-net-listen tests (Rich Trott) [#32381](https://github.com/nodejs/node/pull/32381) +* [[`1b79174203`](https://github.com/nodejs/node/commit/1b79174203)] - **test**: replace Map with Array in cluster-net-listen tests (Rich Trott) [#32381](https://github.com/nodejs/node/pull/32381) +* [[`85ae5661df`](https://github.com/nodejs/node/commit/85ae5661df)] - **test**: uv\_tty\_init returns EBADF on IBM i (Xu Meng) [#32338](https://github.com/nodejs/node/pull/32338) +* [[`8dbd7cf0e4`](https://github.com/nodejs/node/commit/8dbd7cf0e4)] - **test**: use Promise.all() in test-hash-seed (Rich Trott) [#32273](https://github.com/nodejs/node/pull/32273) +* [[`92a207cd2d`](https://github.com/nodejs/node/commit/92a207cd2d)] - **test**: workaround for V8 8.1 inspector pause issue (Matheus Marchini) [#32234](https://github.com/nodejs/node/pull/32234) +* [[`776905ef99`](https://github.com/nodejs/node/commit/776905ef99)] - **test**: use portable EOL (Harshitha KP) [#32104](https://github.com/nodejs/node/pull/32104) +* [[`914edddd79`](https://github.com/nodejs/node/commit/914edddd79)] - **test**: `buffer.write` with longer string scenario (Harshitha KP) [#32123](https://github.com/nodejs/node/pull/32123) +* [[`7060ed1176`](https://github.com/nodejs/node/commit/7060ed1176)] - **test**: fix test-tls-env-extra-ca-file-load (Eric Bickle) [#32073](https://github.com/nodejs/node/pull/32073) +* [[`bee009d271`](https://github.com/nodejs/node/commit/bee009d271)] - **test**: improve test-fs-existssync-false.js (himself65) [#31883](https://github.com/nodejs/node/pull/31883) +* [[`0403f00321`](https://github.com/nodejs/node/commit/0403f00321)] - **test**: mark test-timers-blocking-callback flaky on osx (Myles Borins) [#32189](https://github.com/nodejs/node/pull/32189) +* [[`fa7e975d2f`](https://github.com/nodejs/node/commit/fa7e975d2f)] - **test**: warn when inspector process crashes (Matheus Marchini) [#32133](https://github.com/nodejs/node/pull/32133) +* [[`4a94179a3c`](https://github.com/nodejs/node/commit/4a94179a3c)] - **tools**: update Boxstarter script and document (himself65) [#32299](https://github.com/nodejs/node/pull/32299) +* [[`8bc53d1298`](https://github.com/nodejs/node/commit/8bc53d1298)] - **tools**: update ESLint to 7.0.0-alpha.3 (Colin Ihrig) [#32533](https://github.com/nodejs/node/pull/32533) +* [[`baf56f8135`](https://github.com/nodejs/node/commit/baf56f8135)] - **tools**: fixup icutrim.py use of string and bytes objects (Jonathan MERCIER) [#31659](https://github.com/nodejs/node/pull/31659) +* [[`540a024057`](https://github.com/nodejs/node/commit/540a024057)] - **tools**: update to acorn@7.1.1 (Rich Trott) [#32259](https://github.com/nodejs/node/pull/32259) +* [[`ecf842ec27`](https://github.com/nodejs/node/commit/ecf842ec27)] - **tools**: enable no-useless-backreference lint rule (Colin Ihrig) [#31400](https://github.com/nodejs/node/pull/31400) +* [[`bcf152e2d0`](https://github.com/nodejs/node/commit/bcf152e2d0)] - **tools**: enable default-case-last lint rule (Colin Ihrig) [#31400](https://github.com/nodejs/node/pull/31400) +* [[`5dacfa76f2`](https://github.com/nodejs/node/commit/5dacfa76f2)] - **tools**: update ESLint to 7.0.0-alpha.2 (Colin Ihrig) [#31400](https://github.com/nodejs/node/pull/31400) +* [[`e641b3c6b6`](https://github.com/nodejs/node/commit/e641b3c6b6)] - **tools**: update ESLint to 7.0.0-alpha.1 (Colin Ihrig) [#31400](https://github.com/nodejs/node/pull/31400) +* [[`394fa1f356`](https://github.com/nodejs/node/commit/394fa1f356)] - **tools**: update ESLint to 7.0.0-alpha.0 (Colin Ihrig) [#31400](https://github.com/nodejs/node/pull/31400) +* [[`848df6f6cc`](https://github.com/nodejs/node/commit/848df6f6cc)] - **tracing**: do not attempt to call into JS when disallowed (Anna Henningsen) [#32548](https://github.com/nodejs/node/pull/32548) +* [[`12fe985154`](https://github.com/nodejs/node/commit/12fe985154)] - **util**: only inspect error properties that are not visible otherwise (Ruben Bridgewater) [#32327](https://github.com/nodejs/node/pull/32327) +* [[`eccd2a7740`](https://github.com/nodejs/node/commit/eccd2a7740)] - **util**: fix inspecting document.all (Gus Caplan) [#31938](https://github.com/nodejs/node/pull/31938) +* [[`58c6422f83`](https://github.com/nodejs/node/commit/58c6422f83)] - **util**: text decoding allows SharedArrayBuffer (Bradley Farias) [#32203](https://github.com/nodejs/node/pull/32203) +* [[`10c525f38d`](https://github.com/nodejs/node/commit/10c525f38d)] - **win,build**: set exit\_code on configure failure (Bartlomiej Brzozowski) [#32205](https://github.com/nodejs/node/pull/32205) +* [[`aeea7d9c1f`](https://github.com/nodejs/node/commit/aeea7d9c1f)] - **worker**: do not emit 'exit' events during process.exit() (Anna Henningsen) [#32546](https://github.com/nodejs/node/pull/32546) +* [[`28cb7e78ff`](https://github.com/nodejs/node/commit/28cb7e78ff)] - **worker**: improve MessagePort performance (Anna Henningsen) [#31605](https://github.com/nodejs/node/pull/31605) + ## 2020-04-08, Version 12.16.2 'Erbium' (LTS), @codebytere diff --git a/doc/guides/building-node-with-ninja.md b/doc/guides/building-node-with-ninja.md index 7a14d9e9c97f32..b4b36f76c6acb2 100644 --- a/doc/guides/building-node-with-ninja.md +++ b/doc/guides/building-node-with-ninja.md @@ -4,13 +4,15 @@ The purpose of this guide is to show how to build Node.js using [Ninja][], as doing so can be significantly quicker than using `make`. Please see [Ninja's site][Ninja] for installation instructions (Unix only). -To build Node.js with ninja, there are 3 steps that must be taken: +[Ninja][] is supported in the Makefile. Run `./configure --ninja` to configure +the project to run the regular `make` commands with Ninja. -1. Configure the project's OS-based build rules via `./configure --ninja`. -2. Run `ninja -C out/Release` to produce a compiled release binary. -3. Lastly, make symlink to `./node` using `ln -fs out/Release/node node`. +For example, `make` will execute `ninja -C out/Release` internally +to produce a compiled release binary, It will also execute +`ln -fs out/Release/node node`, so that you can execute `./node` at +the project's root. -When running `ninja -C out/Release` you will see output similar to the following +When running `make`, you will see output similar to the following if the build has succeeded: ```txt @@ -22,27 +24,20 @@ The bottom line will change while building, showing the progress as `[finished/total]` build steps. This is useful output that `make` does not produce and is one of the benefits of using Ninja. Also, Ninja will likely compile much faster than even `make -j4` (or -`-j`). +`-j`). You can still pass the +number of processes to run for [Ninja][] using the environment variable `JOBS`. +This will be the equivalent to the `-j` parameter in the regular `make`: -## Considerations - -Ninja builds vary slightly from `make` builds. If you wish to run `make test` -after, `make` will likely still need to rebuild some amount of Node.js. - -As such, if you wish to run the tests, it can be helpful to invoke the test -runner directly, like so: -`tools/test.py --mode=release message parallel sequential -J` - -## Alias - -`alias nnode='./configure --ninja && ninja -C out/Release && ln -fs -out/Release/node node'` +```bash +$ JOBS=12 make +``` ## Producing a debug build -The above alias can be modified slightly to produce a debug build, rather than a -release build as shown below: -`alias nnodedebug='./configure --ninja && ninja -C out/Debug && ln -fs -out/Debug/node node_g'` +To create a debug build rather than a release build: + +```bash +$ ./configure --ninja --debug && make +``` [Ninja]: https://ninja-build.org/ diff --git a/doc/guides/collaborator-guide.md b/doc/guides/collaborator-guide.md index 956eae7fb23726..5a105b6cee8137 100644 --- a/doc/guides/collaborator-guide.md +++ b/doc/guides/collaborator-guide.md @@ -37,8 +37,8 @@ This document explains how Collaborators manage the Node.js project. Collaborators should understand the -[guidelines for new contributors](CONTRIBUTING.md) and the -[project governance model](GOVERNANCE.md). +[guidelines for new contributors](../../CONTRIBUTING.md) and the +[project governance model](../../GOVERNANCE.md). ## Issues and Pull Requests @@ -50,7 +50,7 @@ request. See [Who to CC in the issue tracker](#who-to-cc-in-the-issue-tracker). Always show courtesy to individuals submitting issues and pull requests. Be welcoming to first-time contributors, identified by the GitHub -![First-time contributor](./doc/first_timer_badge.png) badge. +![First-time contributor](../first_timer_badge.png) badge. For first-time contributors, check if the commit author is the same as the pull request author. This way, once their pull request lands, GitHub will show them @@ -474,7 +474,7 @@ $ git checkout master ``` Update the tree (assumes your repo is set up as detailed in -[CONTRIBUTING.md](./doc/guides/contributing/pull-requests.md#step-1-fork)): +[CONTRIBUTING.md](./contributing/pull-requests.md#step-1-fork)): ```text $ git fetch upstream @@ -752,13 +752,13 @@ If you cannot find who to cc for a file, `git shortlog -n -s ` may help. ["Merge Pull Request"]: https://help.github.com/articles/merging-a-pull-request/#merging-a-pull-request-on-github [Deprecation]: https://en.wikipedia.org/wiki/Deprecation -[Stability Index]: doc/api/documentation.md#stability-index +[Stability Index]: ../api/documentation.md#stability-index [TSC]: https://github.com/nodejs/TSC -[`--pending-deprecation`]: doc/api/cli.md#--pending-deprecation -[`--throw-deprecation`]: doc/api/cli.md#--throw-deprecation +[`--pending-deprecation`]: ../api/cli.md#--pending-deprecation +[`--throw-deprecation`]: ../api/cli.md#--throw-deprecation [`node-core-utils`]: https://github.com/nodejs/node-core-utils -[backporting guide]: doc/guides/backporting-to-release-lines.md -[commit message guidelines]: ./doc/guides/contributing/pull-requests.md#commit-message-guidelines +[backporting guide]: backporting-to-release-lines.md +[commit message guidelines]: contributing/pull-requests.md#commit-message-guidelines [commit-example]: https://github.com/nodejs/node/commit/b636ba8186 [git-node]: https://github.com/nodejs/node-core-utils/blob/master/docs/git-node.md [git-node-metadata]: https://github.com/nodejs/node-core-utils/blob/master/docs/git-node.md#git-node-metadata diff --git a/doc/guides/contributing/code-of-conduct.md b/doc/guides/contributing/code-of-conduct.md index f2c337cf5099b3..6e2c1db36e9f60 100644 --- a/doc/guides/contributing/code-of-conduct.md +++ b/doc/guides/contributing/code-of-conduct.md @@ -26,9 +26,9 @@ All contributors to Node.js tacitly agree to abide by both the letter and spirit of the [Code of Conduct][]. Failure, or unwillingness, to do so will result in contributions being respectfully declined. -A *bad actor* is someone who repeatedly violates the *spirit* of the Code of -Conduct through consistent failure to self-regulate the way in which they -interact with other contributors in the project. In doing so, bad actors +A *bad actor* is someone who repeatedly violates the spirit of the Code of +Conduct through failure to regulate how they +interact with others. In doing so, bad actors alienate other contributors, discourage collaboration, and generally reflect poorly on the project as a whole. diff --git a/doc/guides/contributing/pull-requests.md b/doc/guides/contributing/pull-requests.md index 39b84bc34f17d5..a37929726612d1 100644 --- a/doc/guides/contributing/pull-requests.md +++ b/doc/guides/contributing/pull-requests.md @@ -58,6 +58,9 @@ To get started, you will need to have `git` installed locally. Depending on your operating system, there are also a number of other dependencies required. These are detailed in the [Building guide][]. +Depending on your environment you might want to grab IDE specific settings from +[IDE configs](https://github.com/nodejs/node-code-ide-configs). + Once you have `git` and are sure you have all of the necessary dependencies, it's time to create a fork. @@ -121,7 +124,7 @@ included in the API docs will also be checked when running `make lint` (or use `REPLACEME` for the version number in the documentation YAML. For contributing C++ code, you may want to look at the -[C++ Style Guide](../../cpp-style-guide.md), as well as the +[C++ Style Guide](../cpp-style-guide.md), as well as the [README of `src/`](../../../src/README.md) for an overview over Node.js C++ internals. @@ -582,14 +585,14 @@ If you want to know more about the code review and the landing process, see the [Collaborator Guide][]. [approved]: #getting-approvals-for-your-pull-request -[benchmark results]: ../../../benchmark/writing-and-running-benchmarks.md +[benchmark results]: ../writing-and-running-benchmarks.md [Building guide]: ../../../BUILDING.md [CI (Continuous Integration) test run]: #ci-testing [Code of Conduct]: https://github.com/nodejs/admin/blob/master/CODE_OF_CONDUCT.md -[Collaborator Guide]: ../../../COLLABORATOR_GUIDE.md +[Collaborator Guide]: ../collaborator-guide.md [guide for writing tests in Node.js]: ../writing-tests.md [hiding-a-comment]: https://help.github.com/articles/managing-disruptive-comments/#hiding-a-comment [https://ci.nodejs.org/]: https://ci.nodejs.org/ [IRC in the #node-dev channel]: https://webchat.freenode.net?channels=node-dev&uio=d4 -[Onboarding guide]: ../../onboarding.md +[Onboarding guide]: ../../../onboarding.md [running tests]: ../../../BUILDING.md#running-tests diff --git a/doc/guides/cpp-style-guide.md b/doc/guides/cpp-style-guide.md index f3dcd4e647b04e..f937b60edc20d4 100644 --- a/doc/guides/cpp-style-guide.md +++ b/doc/guides/cpp-style-guide.md @@ -1,7 +1,7 @@ # C++ Style Guide -See also the [C++ codebase README](src/README.md) for C++ idioms in the Node.js -codebase not related to stylistic issues. +See also the [C++ codebase README](../../src/README.md) for C++ idioms in the +Node.js codebase not related to stylistic issues. ## Table of Contents diff --git a/doc/guides/cve_management_process.md b/doc/guides/cve-management-process.md similarity index 100% rename from doc/guides/cve_management_process.md rename to doc/guides/cve-management-process.md diff --git a/doc/guides/doc-style-guide.md b/doc/guides/doc-style-guide.md index 7ee2cac4ec366f..fad23941416713 100644 --- a/doc/guides/doc-style-guide.md +++ b/doc/guides/doc-style-guide.md @@ -68,4 +68,4 @@ See also API documentation structure overview in [doctools README][]. [Javascript type]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Data_structures_and_types [serial commas]: https://en.wikipedia.org/wiki/Serial_comma [plugin]: https://editorconfig.org/#download -[doctools README]: ../tools/doc/README.md +[doctools README]: ../../tools/doc/README.md diff --git a/deps/openssl/config/README.md b/doc/guides/maintaining-openssl.md similarity index 63% rename from deps/openssl/config/README.md rename to doc/guides/maintaining-openssl.md index 1adb6fa83cf729..dfa5c7150d6148 100644 --- a/deps/openssl/config/README.md +++ b/doc/guides/maintaining-openssl.md @@ -1,44 +1,46 @@ -## Upgrading OpenSSL +# Maintaining OpenSSL -### Requirements -- Linux environment (Only CentOS7.1 and Ubuntu16 are tested) -- `perl` Only Perl version 5 is tested. -- `nasm` (http://www.nasm.us/) The version of 2.11 or higher is needed. -- GNU `as` in binutils. The version of 2.26 or higher is needed. +This document describes how to update `deps/openssl/`. -### 0. Check Requirements +## Requirements +* Linux environment +* `perl` Only Perl version 5 is tested. +* `nasm` (http://www.nasm.us/) The version of 2.11 or higher is needed. +* GNU `as` in binutils. The version of 2.26 or higher is needed. + +## 0. Check Requirements ```sh -$ perl -v +% perl -v This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-linux-gnu-thread-multi (with 60 registered patches, see perl -V for more detail) -$ as --version +% as --version GNU assembler (GNU Binutils for Ubuntu) 2.26.1 Copyright (C) 2015 Free Software Foundation, Inc. ... -$ nasm -v +% nasm -v NASM version 2.11.08 ``` -### 1. Obtain and extract new OpenSSL sources +## 1. Obtain and extract new OpenSSL sources Get a new source from https://www.openssl.org/source/ and extract all files into `deps/openssl/openssl`. Then add all files and commit them. ```sh -$ cd deps/openssl/ -$ rm -rf openssl -$ tar zxf ~/tmp/openssl-1.1.0h.tar.gz -$ mv openssl-1.1.0h openssl -$ git add --all openssl -$ git commit openssl +% cd deps/openssl/ +% rm -rf openssl +% tar zxf ~/tmp/openssl-1.1.0h.tar.gz +% mv openssl-1.1.0h openssl +% git add --all openssl +% git commit openssl ```` The commit message can be (with the openssl version set to the relevant value): -``` +```text deps: upgrade openssl sources to 1.1.0h This updates all sources in deps/openssl/openssl by: @@ -50,22 +52,22 @@ This updates all sources in deps/openssl/openssl by: $ git commit openssl ``` -### 2. Execute `make` in `deps/openssl/config` directory +## 2. Execute `make` in `deps/openssl/config` directory Use `make` to regenerate all platform dependent files in `deps/openssl/config/archs/`: ```sh -$ cd deps/openssl/config; make +% cd deps/openssl/config; make ``` -### 3. Check diffs +## 3. Check diffs Check diffs if updates are right. Even if no updates in openssl sources, `buildinf.h` files will be updated for they have a timestamp data in them. ```sh -$ cd deps/openssl/config -$ git diff +% cd deps/openssl/config +% git diff ``` *Note*: On Windows, OpenSSL Configure generates `makefile` that can be @@ -75,20 +77,20 @@ created. When source files or build options are updated in Windows, it needs to change these two Makefiles by hand. If you are not sure, please ask @shigeki for details. -### 4. Commit and make test +## 4. Commit and make test Update all architecture dependent files. Do not forget to git add or remove files if they are changed before commit: ```sh -$ git add deps/openssl/config/archs -$ git add deps/openssl/openssl/crypto/include/internal/bn_conf.h -$ git add deps/openssl/openssl/crypto/include/internal/dso_conf.h -$ git add deps/openssl/openssl/include/openssl/opensslconf.h -$ git commit +% git add deps/openssl/config/archs +% git add deps/openssl/openssl/include/crypto/bn_conf.h +% git add deps/openssl/openssl/include/crypto/dso_conf.h +% git add deps/openssl/openssl/include/openssl/opensslconf.h +% git commit ``` The commit message can be (with the openssl version set to the relevant value): -``` +```text deps: update archs files for OpenSSL-1.1.0 After an OpenSSL source update, all the config files need to be regenerated and @@ -96,10 +98,10 @@ The commit message can be (with the openssl version set to the relevant value): $ cd deps/openssl/config $ make $ git add deps/openssl/config/archs - $ git add deps/openssl/openssl/crypto/include/internal/bn_conf.h - $ git add deps/openssl/openssl/crypto/include/internal/dso_conf.h + $ git add deps/openssl/openssl/include/crypto/bn_conf.h + $ git add deps/openssl/openssl/include/crypto/dso_conf.h $ git add deps/openssl/openssl/include/openssl/opensslconf.h $ git commit ``` -Finally, build Node and run tests. +Finally, build Node.js and run tests. diff --git a/doc/guides/releases.md b/doc/guides/releases.md index 37018e1b3fd002..2068a46dc111e4 100644 --- a/doc/guides/releases.md +++ b/doc/guides/releases.md @@ -322,8 +322,8 @@ accordingly by removing the bold styling from the previous release. If this release includes new APIs then it is necessary to document that they were first added in this version. The relevant commits should already include `REPLACEME` tags as per the example in the -[docs README](../tools/doc/README.md). Check for these tags with `grep REPLACEME -doc/api/*.md`, and substitute this node version with `sed -i +[docs README](../../tools/doc/README.md). Check for these tags with `grep +REPLACEME doc/api/*.md`, and substitute this node version with `sed -i "s/REPLACEME/$VERSION/g" doc/api/*.md` or `perl -pi -e "s/REPLACEME/$VERSION/g" doc/api/*.md`. diff --git a/doc/guides/security-release-process.md b/doc/guides/security-release-process.md index c396dfad7d7d19..55951f94d4ae1f 100644 --- a/doc/guides/security-release-process.md +++ b/doc/guides/security-release-process.md @@ -2,118 +2,92 @@ The security release process covers the steps required to plan/implement a security release. This document is copied into the description of the Next -Security Release, and used to track progess on the release. It contains -***TEXT LIKE THIS*** which will be replaced during the release process with -the information described. +Security Release, and used to track progess on the release. It contains ***TEXT +LIKE THIS*** which will be replaced during the release process with the +information described. ## Planning -* [ ] Open an issue in the private security repo titled `Next Security Release` - and add this planning checklist to the description. +* [ ] Open an [issue](https://github.com/nodejs-private/node-private) titled + `Next Security Release`, and put this checklist in the description. * [ ] Get agreement on the list of vulnerabilities to be addressed: - * ***LINKS TO VULNS...*** + * ***H1 REPORT LINK***: ***DESCRIPTION*** (***CVE or H1 CVE request link***) + * v10.x, v12.x: ***LINK to PR URL*** + * ... + +* [ ] PR release announcements in [private](https://github.com/nodejs-private/nodejs.org-private): + * (Use previous PRs as templates, don't forget to update the site banner, and + the date in the slug so that it will move to the top of the blog list.) + * [ ] pre-release: ***LINK TO PR*** + * [ ] post-release: ***LINK TO PR*** * [ ] Get agreement on the planned date for the release: ***RELEASE DATE*** -* [ ] Validate that all vulnerabilities have been assigned a CVE. Upstream deps - such as OpenSSL and NPM will have CVEs, issues reported on H1 may have CVEs, - otherwise allocate them by following the - [cve_management_process](https://github.com/nodejs/node/blob/master/doc/guides/cve_management_process.md). +* [ ] Get release team volunteers for all affected lines: + * v12.x: ***NAME of RELEASER(S)*** + * ... other lines, if multiple releasers + +## Announcement (one week in advance of the planned release) -* [ ] Co-ordinate with the Release team members to line up one or more releasers - to do the releases on the agreed date. Releaser: ***NAME of RELEASER(S)*** +* [ ] Check that all vulnerabilities are ready for release integration: + * PRs against all affected release lines or cherry-pick clean + * Approved + * Pass `make test` + * Have CVEs + * Described in the pre/post announcements -* [ ] Prep for the security announcements by getting agreement on drafts (use - previously announced releases as the template): - * pre-release: ***LINK TO COMMENT ON THIS ISSUE CONTAINING DRAFT*** - * post-release: ***LINK TO COMMENT ON THIS ISSUE CONTAINING DRAFT*** +* [ ] Pre-release announcement [email][]: ***LINK TO EMAIL*** + (Get access from existing manager: Ben Noordhuis, Rod Vagg, Michael Dawson) -## Announcement (one week in advance of the planned release) +* [ ] Pre-release announcement to nodejs.org blog: ***LINK TO BLOG*** + (Re-PR the pre-approved branch from nodejs-private/nodejs.org-private to + nodejs/nodejs.org) -* [ ] Send pre-release announcement to - https://groups.google.com/forum/#!forum/nodejs-sec. - One of the existing managers can give access (Ben - Noordhuis, Rod Vagg, Michael Dawson). ***LINK TO EMAIL*** - -* [ ] Post pre-release announcement in vulnerabilities section of Nodejs.org - blog (https://github.com/nodejs/nodejs.org/tree/master/locale/en/blog/vulnerability). - Use last pre-release announcement as a template (it includes blog metadata - such as updates to the banner on the Node.js website to indicate security - releases are coming). Submit PR and land immediately. Text was already - reviewed in security repo. ***LINK TO BLOG PR AND POST*** - -* [ ] Open an issue in the build working repository with a notification of the - date for the security release. Use this issue to co-ordinate with the build - team to ensure there will be coverage/availability of build team resources the - day of the release. Those who volunteer from the build WG should be available - in node/build during the release in case they are needed by the individual - doing the release. ***LINK TO BUILD ISSUE*** +* [ ] Request releaser(s) to start integrating the PRs to be released. + +* [ ] Notify [docker-node][] of upcoming security release date: ***LINK*** + +* [ ] Notify build-wg of upcoming security release date by opening an issue + in [nodejs/build][] to request WG members are available to fix any CI issues. ## Release day +* [ ] [Lock CI](https://github.com/nodejs/build/blob/master/doc/jenkins-guide.md#before-the-release) + * [ ] The releaser(s) run the release process to completion. -* [ ] Send post-release announcement as a reply to the - original message in https://groups.google.com/forum/#!forum/nodejs-sec - ***LINK TO EMAIL*** - -* [ ] Update the blog post in - https://github.com/nodejs/nodejs.org/tree/master/locale/en/blog/vulnerability - with the information that releases are available and the full - vulnerability details. Keep the original blog content at the - bottom of the blog. Use this as an example: - https://github.com/nodejs/nodejs.org/blob/master/locale/en/blog/vulnerability/june-2016-security-releases.md. - Make sure to update the date in the slug so that it will move to - the top of the blog list, and not that it updates the - banner on Node.js org to indicate the security release(s) are - available. ***LINK TO PR*** - - *Note*: If the release blog obviously points to the people having caused the - issue (for example when explicitly mentioning reverting a commit), adding - those people as a CC on the PR for the blog post to give them a heads up - might be appropriate. - -* [ ] Email foundation contact to tweet out nodejs-sec announcement from - foundation twitter account. FIXME - who is this contact? - -* [ ] Create a PR to update the Node.js version in the official docker images. - * Checkout the docker-node repo. - * Run the update.sh using the `-s` option so that ONLY the Node.js - versions are updated. At the request from docker (and because - it is good practice) we limit the changes to those necessary in - security updates. - * Open a PR and get volunteer lined up earlier to approve. - * Merge the PR with the merge button. - * Checkout the [official-images](https://github.com/docker-library/official-images) - repository . - * In the docker-node repository run the - [generate-stackbrew-library.sh]( https://github.com/nodejs/docker-node/blob/master/generate-stackbrew-library.sh) - script and replace official-images/library/node with the output generated. - ```console - $ ./generate-stackbrew-library.sh > .../official-images/library/node - ``` - * Open a PR with the changes to official-images/library/node making sure to - @mention the official images. - [maintainers](https://github.com/docker-library/official-images/blob/master/MAINTAINERS). - In addition, make sure to prefix the PR title with `[security]`. - * Send an email to the - [maintainers](https://github.com/docker-library/official-images/blob/master/MAINTAINERS) - indicating that the PR is open. - -* [ ] If we allocated CVES: - * [ ] Ensure that the announced CVEs are reported to Mitre as per the - [cve_management_process](https://github.com/nodejs/security-wg/blob/master/processes/cve_management_process.md). - * [ ] Ensure that the announced CVEs are updated in the cve-management - repository as per the - [cve_management_process](https://github.com/nodejs/security-wg/blob/master/processes/cve_management_process.md) - so that they are listed under Announced. +* [ ] [Unlock CI](https://github.com/nodejs/build/blob/master/doc/jenkins-guide.md#after-the-release) + +* [ ] Post-release announcement in reply [email][]: ***LINK TO EMAIL*** + +* [ ] Post-release announcement to Nodejs.org blog: ***LINK TO BLOG POST*** + * (Re-PR the pre-approved branch from nodejs-private/nodejs.org-private to + nodejs/nodejs.org) + +* [ ] Email `"Rachel Romoff" ` to tweet an + announcement, or if you are on twitter you can just direct message the + `@nodejs` handle. + +* [ ] Comment in [docker-node][] issue that release is ready for integration. + The docker-node team will build and release docker image updates. + +* [ ] For every H1 report resolved: + * Close as Resolved + * Request Disclosure + * Request publication of [H1 CVE requests][] + * (Check that the "Version Fixed" field in the CVE is correct, and provide + links to the release blogs in the "Public Reference" section) * [ ] PR machine-readable JSON descriptions of the vulnerabilities to the [core](https://github.com/nodejs/security-wg/tree/master/vuln/core) vulnerability DB. ***LINK TO PR*** +* [ ] Close this issue + * [ ] Make sure the PRs for the vulnerabilities are closed. -* [ ] Ensure this issue in the private security repo for the release is closed - out. +[H1 CVE requests]: https://hackerone.com/nodejs/cve_requests +[docker-node]: https://github.com/nodejs/docker-node/issues) +[nodejs/build]: https://github.com/nodejs/build/issues) +[email]: https://groups.google.com/forum/#!forum/nodejs-sec diff --git a/lib/_http_agent.js b/lib/_http_agent.js index b3cd60b8bead7a..40eb2a352b8e70 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -60,6 +60,13 @@ class ReusedHandle { } } +function freeSocketErrorListener(err) { + const socket = this; + debug('SOCKET ERROR on FREE socket:', err.message, err.stack); + socket.destroy(); + socket.emit('agentRemove'); +} + function Agent(options) { if (!(this instanceof Agent)) return new Agent(options); @@ -85,6 +92,11 @@ function Agent(options) { const name = this.getName(options); debug('agent.on(free)', name); + // TODO(ronag): socket.destroy(err) might have been called + // before coming here and have an 'error' scheduled. In the + // case of socket.destroy() below this 'error' has no handler + // and could cause unhandled exception. + if (socket.writable && this.requests[name] && this.requests[name].length) { const req = this.requests[name].shift(); @@ -115,6 +127,13 @@ function Agent(options) { socket[async_id_symbol] = -1; socket._httpMessage = null; this.removeSocket(socket, options); + + const agentTimeout = this.options.timeout || 0; + if (socket.timeout !== agentTimeout) { + socket.setTimeout(agentTimeout); + } + + socket.once('error', freeSocketErrorListener); freeSockets.push(socket); } else { // Implementation doesn't want to keep socket alive @@ -197,12 +216,21 @@ Agent.prototype.addRequest = function addRequest(req, options, port/* legacy */, this.sockets[name] = []; } - const freeLen = this.freeSockets[name] ? this.freeSockets[name].length : 0; + const freeSockets = this.freeSockets[name]; + let socket; + if (freeSockets) { + while (freeSockets.length && freeSockets[0].destroyed) { + freeSockets.shift(); + } + socket = freeSockets.shift(); + if (!freeSockets.length) + delete this.freeSockets[name]; + } + + const freeLen = freeSockets ? freeSockets.length : 0; const sockLen = freeLen + this.sockets[name].length; - if (freeLen) { - // We have a free socket, so use that. - const socket = this.freeSockets[name].shift(); + if (socket) { // Guard against an uninitialized or user supplied Socket. const handle = socket._handle; if (handle && typeof handle.asyncReset === 'function') { @@ -211,10 +239,6 @@ Agent.prototype.addRequest = function addRequest(req, options, port/* legacy */, socket[async_id_symbol] = handle.getAsyncId(); } - // don't leak - if (!this.freeSockets[name].length) - delete this.freeSockets[name]; - this.reuseSocket(socket, req); setRequestSocket(this, req, socket); this.sockets[name].push(socket); @@ -309,6 +333,20 @@ function installListeners(agent, s, options) { } s.on('close', onClose); + function onTimeout() { + debug('CLIENT socket onTimeout'); + + // Destroy if in free list. + // TODO(ronag): Always destroy, even if not in free list. + const sockets = agent.freeSockets; + for (const name of ObjectKeys(sockets)) { + if (sockets[name].includes(s)) { + return s.destroy(); + } + } + } + s.on('timeout', onTimeout); + function onRemove() { // We need this function for cases like HTTP 'upgrade' // (defined by WebSockets) where we need to remove a socket from the @@ -317,6 +355,7 @@ function installListeners(agent, s, options) { agent.removeSocket(s, options); s.removeListener('close', onClose); s.removeListener('free', onFree); + s.removeListener('timeout', onTimeout); s.removeListener('agentRemove', onRemove); } s.on('agentRemove', onRemove); @@ -365,6 +404,7 @@ Agent.prototype.keepSocketAlive = function keepSocketAlive(socket) { Agent.prototype.reuseSocket = function reuseSocket(socket, req) { debug('have free socket'); + socket.removeListener('error', freeSocketErrorListener); req.reusedSocket = true; socket.ref(); }; @@ -399,14 +439,6 @@ function setRequestSocket(agent, req, socket) { return; } socket.setTimeout(req.timeout); - // Reset timeout after response end - req.once('response', (res) => { - res.once('end', () => { - if (socket.timeout !== agentTimeout) { - socket.setTimeout(agentTimeout); - } - }); - }); } function emitErrorNT(emitter, err) { diff --git a/lib/_http_client.js b/lib/_http_client.js index 2d2e4eeed21915..dda29e3e8e6be5 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -169,7 +169,7 @@ function ClientRequest(input, options, cb) { let method = options.method; const methodIsString = (typeof method === 'string'); if (method !== null && method !== undefined && !methodIsString) { - throw new ERR_INVALID_ARG_TYPE('method', 'string', method); + throw new ERR_INVALID_ARG_TYPE('options.method', 'string', method); } if (methodIsString && method) { @@ -185,7 +185,7 @@ function ClientRequest(input, options, cb) { if (insecureHTTPParser !== undefined && typeof insecureHTTPParser !== 'boolean') { throw new ERR_INVALID_ARG_TYPE( - 'insecureHTTPParser', 'boolean', insecureHTTPParser); + 'options.insecureHTTPParser', 'boolean', insecureHTTPParser); } this.insecureHTTPParser = insecureHTTPParser; @@ -441,13 +441,6 @@ function socketErrorListener(err) { socket.destroy(); } -function freeSocketErrorListener(err) { - const socket = this; - debug('SOCKET ERROR on FREE socket:', err.message, err.stack); - socket.destroy(); - socket.emit('agentRemove'); -} - function socketOnEnd() { const socket = this; const req = this._httpMessage; @@ -622,8 +615,11 @@ function responseKeepAlive(req) { socket.removeListener('error', socketErrorListener); socket.removeListener('data', socketOnData); socket.removeListener('end', socketOnEnd); - socket.once('error', freeSocketErrorListener); - // There are cases where _handle === null. Avoid those. Passing null to + + // TODO(ronag): Between here and emitFreeNT the socket + // has no 'error' handler. + + // There are cases where _handle === null. Avoid those. Passing undefined to // nextTick() will call getDefaultTriggerAsyncId() to retrieve the id. const asyncId = socket._handle ? socket._handle.getAsyncId() : undefined; // Mark this socket as available, AFTER user-added end @@ -692,7 +688,6 @@ function tickOnSocket(req, socket) { } parser.onIncoming = parserOnIncomingClient; - socket.removeListener('error', freeSocketErrorListener); socket.on('error', socketErrorListener); socket.on('data', socketOnData); socket.on('end', socketOnEnd); @@ -732,6 +727,8 @@ function listenSocketTimeout(req) { } ClientRequest.prototype.onSocket = function onSocket(socket) { + // TODO(ronag): Between here and onSocketNT the socket + // has no 'error' handler. process.nextTick(onSocketNT, this, socket); }; diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 4e08ebece8dd12..49f6e57fb1c6fd 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -727,6 +727,7 @@ OutgoingMessage.prototype.addTrailers = function addTrailers(headers) { }; function onFinish(outmsg) { + if (outmsg && outmsg.socket && outmsg.socket._hadError) return; outmsg.emit('finish'); } diff --git a/lib/_http_server.js b/lib/_http_server.js index 9a7d23844cb535..d43c1bfb63d67b 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -336,7 +336,7 @@ function Server(options, requestListener) { if (insecureHTTPParser !== undefined && typeof insecureHTTPParser !== 'boolean') { throw new ERR_INVALID_ARG_TYPE( - 'insecureHTTPParser', 'boolean', insecureHTTPParser); + 'options.insecureHTTPParser', 'boolean', insecureHTTPParser); } this.insecureHTTPParser = insecureHTTPParser; @@ -660,9 +660,12 @@ function clearIncoming(req) { if (parser && parser.incoming === req) { if (req.readableEnded) { parser.incoming = null; + req.emit('close'); } else { req.on('end', clearIncoming); } + } else { + req.emit('close'); } } @@ -673,7 +676,6 @@ function resOnFinish(req, res, socket, state, server) { assert(state.incoming.length === 0 || state.incoming[0] === req); state.incoming.shift(); - clearIncoming(req); // If the user never called req.read(), and didn't pipe() or // .resume() or .on('data'), then we call req._dump() so that the @@ -682,7 +684,7 @@ function resOnFinish(req, res, socket, state, server) { req._dump(); res.detachSocket(socket); - req.emit('close'); + clearIncoming(req); process.nextTick(emitCloseNT, res); if (res._last) { diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index 067aa86442383a..6f5758bef08343 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -29,6 +29,7 @@ const { Array, FunctionPrototype, ObjectDefineProperty, + ObjectDefineProperties, ObjectSetPrototypeOf, Symbol, SymbolHasInstance, @@ -348,46 +349,6 @@ Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { return this; }; -ObjectDefineProperty(Writable.prototype, 'writableBuffer', { - // Making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function() { - return this._writableState && this._writableState.getBuffer(); - } -}); - -ObjectDefineProperty(Writable.prototype, 'writableEnded', { - // Making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function() { - return this._writableState ? this._writableState.ending : false; - } -}); - -ObjectDefineProperty(Writable.prototype, 'writableHighWaterMark', { - // Making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function() { - return this._writableState && this._writableState.highWaterMark; - } -}); - -ObjectDefineProperty(Writable.prototype, 'writableCorked', { - // Making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function() { - return this._writableState ? this._writableState.corked : 0; - } -}); - // If we're already writing something, then just put this // in the queue, and wait our turn. Otherwise, call _write // If we return false, then we need a drain event, so set that flag. @@ -636,16 +597,6 @@ Writable.prototype.end = function(chunk, encoding, cb) { return this; }; -ObjectDefineProperty(Writable.prototype, 'writableLength', { - // Making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get() { - return this._writableState.length; - } -}); - function needFinish(state) { return (state.ending && state.length === 0 && @@ -727,44 +678,60 @@ function onCorkedFinish(corkReq, state, err) { state.corkedRequestsFree.next = corkReq; } -ObjectDefineProperty(Writable.prototype, 'destroyed', { - // Making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get() { - if (this._writableState === undefined) { - return false; +ObjectDefineProperties(Writable.prototype, { + + destroyed: { + get() { + return this._writableState ? this._writableState.destroyed : false; + }, + set(value) { + // Backward compatibility, the user is explicitly managing destroyed + if (this._writableState) { + this._writableState.destroyed = value; + } } - return this._writableState.destroyed; }, - set(value) { - // We ignore the value if the stream - // has not been initialized yet - if (!this._writableState) { - return; + + writableFinished: { + get() { + return this._writableState ? this._writableState.finished : false; } + }, - // Backward compatibility, the user is explicitly - // managing destroyed - this._writableState.destroyed = value; - } -}); + writableObjectMode: { + get() { + return this._writableState ? this._writableState.objectMode : false; + } + }, -ObjectDefineProperty(Writable.prototype, 'writableObjectMode', { - enumerable: false, - get() { - return this._writableState ? this._writableState.objectMode : false; - } -}); + writableBuffer: { + get() { + return this._writableState && this._writableState.getBuffer(); + } + }, + + writableEnded: { + get() { + return this._writableState ? this._writableState.ending : false; + } + }, + + writableHighWaterMark: { + get() { + return this._writableState && this._writableState.highWaterMark; + } + }, -ObjectDefineProperty(Writable.prototype, 'writableFinished', { - // Making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get() { - return this._writableState ? this._writableState.finished : false; + writableCorked: { + get() { + return this._writableState ? this._writableState.corked : 0; + } + }, + + writableLength: { + get() { + return this._writableState && this._writableState.length; + } } }); diff --git a/lib/async_hooks.js b/lib/async_hooks.js index 009f15c83b1d8e..0e77e7402b5282 100644 --- a/lib/async_hooks.js +++ b/lib/async_hooks.js @@ -35,6 +35,7 @@ const { emitDestroy, enabledHooksExist, initHooksExist, + destroyHooksExist, } = internal_async_hooks; // Get symbols @@ -167,7 +168,7 @@ class AsyncResource { emitInit(asyncId, type, triggerAsyncId, this); } - if (!requireManualDestroy) { + if (!requireManualDestroy && destroyHooksExist()) { // This prop name (destroyed) has to be synchronized with C++ const destroyed = { destroyed: false }; this[destroyedSymbol] = destroyed; diff --git a/lib/dns.js b/lib/dns.js index 8a6c7456babbd0..df593a5255af87 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -63,11 +63,7 @@ function onlookup(err, addresses) { if (err) { return this.callback(dnsException(err, 'getaddrinfo', this.hostname)); } - if (this.family) { - this.callback(null, addresses[0], this.family); - } else { - this.callback(null, addresses[0], isIP(addresses[0])); - } + this.callback(null, addresses[0], this.family || isIP(addresses[0])); } diff --git a/lib/fs.js b/lib/fs.js index 31fd05dd3ab435..5fb1784605700e 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -813,7 +813,7 @@ function mkdir(path, options, callback) { path = getValidatedPath(path); if (typeof recursive !== 'boolean') - throw new ERR_INVALID_ARG_TYPE('recursive', 'boolean', recursive); + throw new ERR_INVALID_ARG_TYPE('options.recursive', 'boolean', recursive); const req = new FSReqCallback(); req.oncomplete = callback; @@ -832,7 +832,7 @@ function mkdirSync(path, options) { path = getValidatedPath(path); if (typeof recursive !== 'boolean') - throw new ERR_INVALID_ARG_TYPE('recursive', 'boolean', recursive); + throw new ERR_INVALID_ARG_TYPE('options.recursive', 'boolean', recursive); const ctx = { path }; binding.mkdir(pathModule.toNamespacedPath(path), @@ -1220,9 +1220,9 @@ function futimesSync(fd, atime, mtime) { handleErrorFromBinding(ctx); } -function writeAll(fd, isUserFd, buffer, offset, length, position, callback) { +function writeAll(fd, isUserFd, buffer, offset, length, callback) { // write(fd, buffer, offset, length, position, callback) - fs.write(fd, buffer, offset, length, position, (writeErr, written) => { + fs.write(fd, buffer, offset, length, null, (writeErr, written) => { if (writeErr) { if (isUserFd) { callback(writeErr); @@ -1240,10 +1240,7 @@ function writeAll(fd, isUserFd, buffer, offset, length, position, callback) { } else { offset += written; length -= written; - if (position !== null) { - position += written; - } - writeAll(fd, isUserFd, buffer, offset, length, position, callback); + writeAll(fd, isUserFd, buffer, offset, length, callback); } }); } @@ -1269,9 +1266,8 @@ function writeFile(path, data, options, callback) { function writeFd(fd, isUserFd) { const buffer = isArrayBufferView(data) ? data : Buffer.from('' + data, options.encoding || 'utf8'); - const position = (/a/.test(flag) || isUserFd) ? null : 0; - writeAll(fd, isUserFd, buffer, 0, buffer.byteLength, position, callback); + writeAll(fd, isUserFd, buffer, 0, buffer.byteLength, callback); } } @@ -1287,15 +1283,11 @@ function writeFileSync(path, data, options) { } let offset = 0; let length = data.byteLength; - let position = (/a/.test(flag) || isUserFd) ? null : 0; try { while (length > 0) { - const written = fs.writeSync(fd, data, offset, length, position); + const written = fs.writeSync(fd, data, offset, length); offset += written; length -= written; - if (position !== null) { - position += written; - } } } finally { if (!isUserFd) fs.closeSync(fd); diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js index 02b0e91ac2e965..2cb81ca44f795d 100644 --- a/lib/internal/async_hooks.js +++ b/lib/internal/async_hooks.js @@ -299,27 +299,31 @@ function defaultTriggerAsyncIdScope(triggerAsyncId, block, ...args) { } } +function hasHooks(key) { + return async_hook_fields[key] > 0; +} + function enabledHooksExist() { - return async_hook_fields[kCheck] > 0; + return hasHooks(kCheck); } function initHooksExist() { - return async_hook_fields[kInit] > 0; + return hasHooks(kInit); } function afterHooksExist() { - return async_hook_fields[kAfter] > 0; + return hasHooks(kAfter); } function destroyHooksExist() { - return async_hook_fields[kDestroy] > 0; + return hasHooks(kDestroy); } function emitInitScript(asyncId, type, triggerAsyncId, resource) { // Short circuit all checks for the common case. Which is that no hooks have // been set. Do this to remove performance impact for embedders (and core). - if (async_hook_fields[kInit] === 0) + if (!hasHooks(kInit)) return; if (triggerAsyncId === null) { @@ -333,13 +337,13 @@ function emitInitScript(asyncId, type, triggerAsyncId, resource) { function emitBeforeScript(asyncId, triggerAsyncId) { pushAsyncIds(asyncId, triggerAsyncId); - if (async_hook_fields[kBefore] > 0) + if (hasHooks(kBefore)) emitBeforeNative(asyncId); } function emitAfterScript(asyncId) { - if (async_hook_fields[kAfter] > 0) + if (hasHooks(kAfter)) emitAfterNative(asyncId); popAsyncIds(asyncId); @@ -348,7 +352,7 @@ function emitAfterScript(asyncId) { function emitDestroyScript(asyncId) { // Return early if there are no destroy callbacks, or invalid asyncId. - if (async_hook_fields[kDestroy] === 0 || asyncId <= 0) + if (!hasHooks(kDestroy) || asyncId <= 0) return; async_wrap.queueDestroyAsyncId(asyncId); } @@ -364,7 +368,7 @@ function clearAsyncIdStack() { function hasAsyncIdStack() { - return async_hook_fields[kStackLength] > 0; + return hasHooks(kStackLength); } diff --git a/lib/internal/cluster/master.js b/lib/internal/cluster/master.js index 9bdb0181d3db93..70707e359f4997 100644 --- a/lib/internal/cluster/master.js +++ b/lib/internal/cluster/master.js @@ -67,7 +67,7 @@ cluster.setupMaster = function(options) { // process has its own memory mappings.) if (settings.execArgv.some((s) => s.startsWith('--prof')) && !settings.execArgv.some((s) => s.startsWith('--logfile='))) { - settings.execArgv = settings.execArgv.concat(['--logfile=v8-%p.log']); + settings.execArgv = [...settings.execArgv, '--logfile=v8-%p.log']; } cluster.settings = settings; @@ -104,7 +104,7 @@ function setupSettingsNT(settings) { function createWorkerProcess(id, env) { const workerEnv = { ...process.env, ...env, NODE_UNIQUE_ID: `${id}` }; - const execArgv = cluster.settings.execArgv.slice(); + const execArgv = [...cluster.settings.execArgv]; const debugArgRegex = /--inspect(?:-brk|-port)?|--debug-port/; const nodeOptions = process.env.NODE_OPTIONS ? process.env.NODE_OPTIONS : ''; diff --git a/lib/internal/cluster/round_robin_handle.js b/lib/internal/cluster/round_robin_handle.js index 819d5e0fe749ae..5fcd43d4200f7a 100644 --- a/lib/internal/cluster/round_robin_handle.js +++ b/lib/internal/cluster/round_robin_handle.js @@ -1,6 +1,7 @@ 'use strict'; const { + ArrayIsArray, Boolean, Map, } = primordials; @@ -16,7 +17,7 @@ module.exports = RoundRobinHandle; function RoundRobinHandle(key, address, port, addressType, fd, flags) { this.key = key; this.all = new Map(); - this.free = []; + this.free = new Map(); this.handles = []; this.handle = null; this.server = net.createServer(assert.fail); @@ -77,10 +78,7 @@ RoundRobinHandle.prototype.remove = function(worker) { if (!existed) return false; - const index = this.free.indexOf(worker); - - if (index !== -1) - this.free.splice(index, 1); + this.free.delete(worker.id); if (this.all.size !== 0) return false; @@ -97,21 +95,24 @@ RoundRobinHandle.prototype.remove = function(worker) { RoundRobinHandle.prototype.distribute = function(err, handle) { this.handles.push(handle); - const worker = this.free.shift(); + const [ workerEntry ] = this.free; - if (worker) + if (ArrayIsArray(workerEntry)) { + const [ workerId, worker ] = workerEntry; + this.free.delete(workerId); this.handoff(worker); + } }; RoundRobinHandle.prototype.handoff = function(worker) { - if (this.all.has(worker.id) === false) { + if (!this.all.has(worker.id)) { return; // Worker is closing (or has closed) the server. } const handle = this.handles.shift(); if (handle === undefined) { - this.free.push(worker); // Add to ready queue again. + this.free.set(worker.id, worker); // Add to ready queue again. return; } diff --git a/lib/internal/cluster/shared_handle.js b/lib/internal/cluster/shared_handle.js index 088798597382f8..20c028ce313d40 100644 --- a/lib/internal/cluster/shared_handle.js +++ b/lib/internal/cluster/shared_handle.js @@ -1,4 +1,5 @@ 'use strict'; +const { Map } = primordials; const assert = require('internal/assert'); const dgram = require('internal/dgram'); const net = require('net'); @@ -7,7 +8,7 @@ module.exports = SharedHandle; function SharedHandle(key, address, port, addressType, fd, flags) { this.key = key; - this.workers = []; + this.workers = new Map(); this.handle = null; this.errno = 0; @@ -24,20 +25,18 @@ function SharedHandle(key, address, port, addressType, fd, flags) { } SharedHandle.prototype.add = function(worker, send) { - assert(!this.workers.includes(worker)); - this.workers.push(worker); + assert(!this.workers.has(worker.id)); + this.workers.set(worker.id, worker); send(this.errno, null, this.handle); }; SharedHandle.prototype.remove = function(worker) { - const index = this.workers.indexOf(worker); - - if (index === -1) - return false; // The worker wasn't sharing this handle. + if (!this.workers.has(worker.id)) + return false; - this.workers.splice(index, 1); + this.workers.delete(worker.id); - if (this.workers.length !== 0) + if (this.workers.size !== 0) return false; this.handle.close(); diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js index 81c8939e90f81c..360c8acbbfd4e3 100644 --- a/lib/internal/console/constructor.js +++ b/lib/internal/console/constructor.js @@ -104,11 +104,14 @@ function Console(options /* or: stdout, stderr, ignoreErrors = true */) { if (inspectOptions.colors !== undefined && options.colorMode !== undefined) { throw new ERR_INCOMPATIBLE_OPTION_PAIR( - 'inspectOptions.color', 'colorMode'); + 'options.inspectOptions.color', 'colorMode'); } optionsMap.set(this, inspectOptions); } else if (inspectOptions !== undefined) { - throw new ERR_INVALID_ARG_TYPE('inspectOptions', 'object', inspectOptions); + throw new ERR_INVALID_ARG_TYPE( + 'options.inspectOptions', + 'object', + inspectOptions); } // Bind the prototype functions to this Console instance diff --git a/lib/internal/encoding.js b/lib/internal/encoding.js index 6cb840e9d1e84f..befc4f811b2dde 100644 --- a/lib/internal/encoding.js +++ b/lib/internal/encoding.js @@ -31,7 +31,7 @@ const { } = require('internal/util'); const { - isArrayBuffer, + isAnyArrayBuffer, isArrayBufferView, isUint8Array } = require('internal/util/types'); @@ -404,7 +404,7 @@ function makeTextDecoderICU() { decode(input = empty, options = {}) { validateDecoder(this); - if (isArrayBuffer(input)) { + if (isAnyArrayBuffer(input)) { input = lazyBuffer().from(input); } else if (!isArrayBufferView(input)) { throw new ERR_INVALID_ARG_TYPE('input', @@ -469,7 +469,7 @@ function makeTextDecoderJS() { decode(input = empty, options = {}) { validateDecoder(this); - if (isArrayBuffer(input)) { + if (isAnyArrayBuffer(input)) { input = lazyBuffer().from(input); } else if (isArrayBufferView(input)) { input = lazyBuffer().from(input.buffer, input.byteOffset, diff --git a/lib/internal/fs/dir.js b/lib/internal/fs/dir.js index 1351ce6c245281..e23b2f7725b2a2 100644 --- a/lib/internal/fs/dir.js +++ b/lib/internal/fs/dir.js @@ -105,7 +105,7 @@ class Dir { ); } - readSync(options) { + readSync() { if (this[kDirClosed] === true) { throw new ERR_DIR_CLOSED(); } diff --git a/lib/internal/fs/promises.js b/lib/internal/fs/promises.js index cc907c8c9eae68..927bf739e79763 100644 --- a/lib/internal/fs/promises.js +++ b/lib/internal/fs/promises.js @@ -333,7 +333,7 @@ async function mkdir(path, options) { } = options || {}; path = getValidatedPath(path); if (typeof recursive !== 'boolean') - throw new ERR_INVALID_ARG_TYPE('recursive', 'boolean', recursive); + throw new ERR_INVALID_ARG_TYPE('options.recursive', 'boolean', recursive); return binding.mkdir(pathModule.toNamespacedPath(path), parseMode(mode, 'mode', 0o777), recursive, diff --git a/lib/internal/histogram.js b/lib/internal/histogram.js new file mode 100644 index 00000000000000..6deb8314a41bbb --- /dev/null +++ b/lib/internal/histogram.js @@ -0,0 +1,94 @@ +'use strict'; + +const { + customInspectSymbol: kInspect, +} = require('internal/util'); + +const { format } = require('util'); +const { Map, Symbol } = primordials; + +const { + ERR_INVALID_ARG_TYPE, + ERR_INVALID_ARG_VALUE, +} = require('internal/errors').codes; + +const kDestroy = Symbol('kDestroy'); +const kHandle = Symbol('kHandle'); + +// Histograms are created internally by Node.js and used to +// record various metrics. This Histogram class provides a +// generally read-only view of the internal histogram. +class Histogram { + #handle = undefined; + #map = new Map(); + + constructor(internal) { + this.#handle = internal; + } + + [kInspect]() { + const obj = { + min: this.min, + max: this.max, + mean: this.mean, + exceeds: this.exceeds, + stddev: this.stddev, + percentiles: this.percentiles, + }; + return `Histogram ${format(obj)}`; + } + + get min() { + return this.#handle ? this.#handle.min() : undefined; + } + + get max() { + return this.#handle ? this.#handle.max() : undefined; + } + + get mean() { + return this.#handle ? this.#handle.mean() : undefined; + } + + get exceeds() { + return this.#handle ? this.#handle.exceeds() : undefined; + } + + get stddev() { + return this.#handle ? this.#handle.stddev() : undefined; + } + + percentile(percentile) { + if (typeof percentile !== 'number') + throw new ERR_INVALID_ARG_TYPE('percentile', 'number', percentile); + + if (percentile <= 0 || percentile > 100) + throw new ERR_INVALID_ARG_VALUE.RangeError('percentile', percentile); + + return this.#handle ? this.#handle.percentile(percentile) : undefined; + } + + get percentiles() { + this.#map.clear(); + if (this.#handle) + this.#handle.percentiles(this.#map); + return this.#map; + } + + reset() { + if (this.#handle) + this.#handle.reset(); + } + + [kDestroy]() { + this.#handle = undefined; + } + + get [kHandle]() { return this.#handle; } +} + +module.exports = { + Histogram, + kDestroy, + kHandle, +}; diff --git a/lib/internal/http2/util.js b/lib/internal/http2/util.js index 3c9b35bb774960..dcc1355a3230fd 100644 --- a/lib/internal/http2/util.js +++ b/lib/internal/http2/util.js @@ -442,13 +442,13 @@ function mapToHeaders(map, let count = 0; const keys = ObjectKeys(map); const singles = new Set(); - let i; + let i, j; let isArray; let key; let value; let isSingleValueHeader; let err; - for (i = 0; i < keys.length; i++) { + for (i = 0; i < keys.length; ++i) { key = keys[i]; value = map[key]; if (value === undefined || key === '') @@ -488,8 +488,8 @@ function mapToHeaders(map, throw new ERR_HTTP2_INVALID_CONNECTION_HEADERS(key); } if (isArray) { - for (var k = 0; k < value.length; k++) { - const val = String(value[k]); + for (j = 0; j < value.length; ++j) { + const val = String(value[j]); ret += `${key}\0${val}\0`; } count += value.length; diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 734dffa343a522..0a359a3d8973bc 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -34,6 +34,7 @@ const { ObjectKeys, ObjectPrototypeHasOwnProperty, ReflectSet, + RegExpPrototypeTest, SafeMap, String, StringPrototypeIndexOf, @@ -48,7 +49,7 @@ const { rekeySourceMap } = require('internal/source_map/source_map_cache'); const { pathToFileURL, fileURLToPath, URL } = require('internal/url'); -const { deprecate, emitExperimentalWarning } = require('internal/util'); +const { deprecate } = require('internal/util'); const vm = require('vm'); const assert = require('internal/assert'); const fs = require('fs'); @@ -122,7 +123,10 @@ function enrichCJSError(err) { after a comment block and/or after a variable definition. */ if (err.message.startsWith('Unexpected token \'export\'') || - (/^\s*import(?=[ {'"*])\s*(?![ (])/).test(lineWithErr)) { + (RegExpPrototypeTest(/^\s*import(?=[ {'"*])\s*(?![ (])/, lineWithErr))) { + // Emit the warning synchronously because we are in the middle of handling + // a SyntaxError that will throw and likely terminate the process before an + // asynchronous warning would be emitted. process.emitWarning( 'To load an ES module, set "type": "module" in the package.json or use ' + 'the .mjs extension.', @@ -349,10 +353,11 @@ const realpathCache = new Map(); // absolute realpath. function tryFile(requestPath, isMain) { const rc = stat(requestPath); + if (rc !== 0) return; if (preserveSymlinks && !isMain) { - return rc === 0 && path.resolve(requestPath); + return path.resolve(requestPath); } - return rc === 0 && toRealPath(requestPath); + return toRealPath(requestPath); } function toRealPath(requestPath) { @@ -389,52 +394,7 @@ function findLongestRegisteredExtension(filename) { return '.js'; } -function resolveBasePath(basePath, exts, isMain, trailingSlash, request) { - let filename; - - const rc = stat(basePath); - if (!trailingSlash) { - if (rc === 0) { // File. - if (!isMain) { - if (preserveSymlinks) { - filename = path.resolve(basePath); - } else { - filename = toRealPath(basePath); - } - } else if (preserveSymlinksMain) { - // For the main module, we use the preserveSymlinksMain flag instead - // mainly for backward compatibility, as the preserveSymlinks flag - // historically has not applied to the main module. Most likely this - // was intended to keep .bin/ binaries working, as following those - // symlinks is usually required for the imports in the corresponding - // files to resolve; that said, in some use cases following symlinks - // causes bigger problems which is why the preserveSymlinksMain option - // is needed. - filename = path.resolve(basePath); - } else { - filename = toRealPath(basePath); - } - } - - if (!filename) { - // Try it with each of the extensions - if (exts === undefined) - exts = ObjectKeys(Module._extensions); - filename = tryExtensions(basePath, exts, isMain); - } - } - - if (!filename && rc === 1) { // Directory. - // try it with each of the extensions at "index" - if (exts === undefined) - exts = ObjectKeys(Module._extensions); - filename = tryPackage(basePath, exts, isMain, request); - } - - return filename; -} - -function trySelf(parentPath, isMain, request) { +function trySelf(parentPath, request) { if (!experimentalModules) return false; const { data: pkg, path: basePath } = readPackageScope(parentPath) || {}; if (!pkg || pkg.exports === undefined) return false; @@ -449,20 +409,11 @@ function trySelf(parentPath, isMain, request) { return false; } - const exts = ObjectKeys(Module._extensions); const fromExports = applyExports(basePath, expansion); - // Use exports if (fromExports) { - let trailingSlash = request.length > 0 && - request.charCodeAt(request.length - 1) === CHAR_FORWARD_SLASH; - if (!trailingSlash) { - trailingSlash = /(?:^|\/)\.?\.$/.test(request); - } - return resolveBasePath(fromExports, exts, isMain, trailingSlash, request); - } else { - // Use main field - return tryPackage(basePath, exts, isMain, request); + return tryFile(fromExports, false); } + assert(fromExports !== false); } function isConditionalDotExportSugar(exports, basePath) { @@ -494,7 +445,7 @@ function applyExports(basePath, expansion) { let pkgExports = readPackageExports(basePath); if (pkgExports === undefined || pkgExports === null || !experimentalModules) - return path.resolve(basePath, mappingKey); + return false; if (isConditionalDotExportSugar(pkgExports, basePath)) pkgExports = { '.': pkgExports }; @@ -518,8 +469,24 @@ function applyExports(basePath, expansion) { if (dirMatch !== '') { const mapping = pkgExports[dirMatch]; const subpath = StringPrototypeSlice(mappingKey, dirMatch.length); - return resolveExportsTarget(pathToFileURL(basePath + '/'), mapping, - subpath, mappingKey); + const resolved = resolveExportsTarget(pathToFileURL(basePath + '/'), + mapping, subpath, mappingKey); + // Extension searching for folder exports only + const rc = stat(resolved); + if (rc === 0) return resolved; + if (!(RegExpPrototypeTest(trailingSlashRegex, resolved))) { + const exts = ObjectKeys(Module._extensions); + const filename = tryExtensions(resolved, exts, false); + if (filename) return filename; + } + if (rc === 1) { + const exts = ObjectKeys(Module._extensions); + const filename = tryPackage(resolved, exts, false, + basePath + expansion); + if (filename) return filename; + } + // Undefined means not found + return; } } @@ -530,20 +497,20 @@ function applyExports(basePath, expansion) { // 1. name/.* // 2. @scope/name/.* const EXPORTS_PATTERN = /^((?:@[^/\\%]+\/)?[^./\\%][^/\\%]*)(\/.*)?$/; -function resolveExports(nmPath, request, absoluteRequest) { +function resolveExports(nmPath, request) { // The implementation's behavior is meant to mirror resolution in ESM. - if (!absoluteRequest) { - const [, name, expansion = ''] = - StringPrototypeMatch(request, EXPORTS_PATTERN) || []; - if (!name) { - return path.resolve(nmPath, request); - } - - const basePath = path.resolve(nmPath, name); - return applyExports(basePath, expansion); + const [, name, expansion = ''] = + StringPrototypeMatch(request, EXPORTS_PATTERN) || []; + if (!name) { + return false; } - return path.resolve(nmPath, request); + const basePath = path.resolve(nmPath, name); + const fromExports = applyExports(basePath, expansion); + if (fromExports) { + return tryFile(fromExports, false); + } + return fromExports; } function isArrayIndex(p) { @@ -612,7 +579,6 @@ function resolveExportsTarget(baseUrl, target, subpath, mappingKey) { case 'node': case 'require': try { - emitExperimentalWarning('Conditional exports'); return resolveExportsTarget(baseUrl, target[p], subpath, mappingKey); } catch (e) { @@ -635,6 +601,7 @@ function resolveExportsTarget(baseUrl, target, subpath, mappingKey) { StringPrototypeSlice(baseUrl.pathname, 0, -1), mappingKey, subpath, target); } +const trailingSlashRegex = /(?:^|\/)\.?\.$/; Module._findPath = function(request, paths, isMain) { const absoluteRequest = path.isAbsolute(request); if (absoluteRequest) { @@ -653,7 +620,7 @@ Module._findPath = function(request, paths, isMain) { let trailingSlash = request.length > 0 && request.charCodeAt(request.length - 1) === CHAR_FORWARD_SLASH; if (!trailingSlash) { - trailingSlash = /(?:^|\/)\.?\.$/.test(request); + trailingSlash = RegExpPrototypeTest(trailingSlashRegex, request); } // For each path @@ -661,7 +628,18 @@ Module._findPath = function(request, paths, isMain) { // Don't search further if path doesn't exist const curPath = paths[i]; if (curPath && stat(curPath) < 1) continue; - const basePath = resolveExports(curPath, request, absoluteRequest); + + if (!absoluteRequest) { + const exportsResolved = resolveExports(curPath, request); + // Undefined means not found, false means no exports + if (exportsResolved === undefined) + break; + if (exportsResolved) { + return exportsResolved; + } + } + + const basePath = path.resolve(curPath, request); let filename; const rc = stat(basePath); @@ -953,9 +931,8 @@ Module._resolveFilename = function(request, parent, isMain, options) { } if (parent && parent.filename) { - const filename = trySelf(parent.filename, isMain, request); + const filename = trySelf(parent.filename, request); if (filename) { - emitExperimentalWarning('Package name self resolution'); const cacheKey = request + '\x00' + (paths.length === 1 ? paths[0] : paths.join('\x00')); Module._pathCache[cacheKey] = filename; diff --git a/lib/internal/per_context/messageport.js b/lib/internal/per_context/messageport.js new file mode 100644 index 00000000000000..ee08a596122a51 --- /dev/null +++ b/lib/internal/per_context/messageport.js @@ -0,0 +1,12 @@ +'use strict'; +class MessageEvent { + constructor(data, target) { + this.data = data; + this.target = target; + } +} + +exports.emitMessage = function(data) { + if (typeof this.onmessage === 'function') + this.onmessage(new MessageEvent(data, this)); +}; diff --git a/lib/internal/stream_base_commons.js b/lib/internal/stream_base_commons.js index 800ba4cefd6370..df26119be0fca4 100644 --- a/lib/internal/stream_base_commons.js +++ b/lib/internal/stream_base_commons.js @@ -213,6 +213,16 @@ function onStreamRead(arrayBuffer) { if (stream[kMaybeDestroy]) stream.on('end', stream[kMaybeDestroy]); + // TODO(ronag): Without this `readStop`, `onStreamRead` + // will be called once more (i.e. after Readable.ended) + // on Windows causing a ECONNRESET, failing the + // test-https-truncate test. + if (handle.readStop) { + const err = handle.readStop(); + if (err) + return stream.destroy(errnoException(err, 'read')); + } + // Push a null to signal the end of data. // Do it before `maybeDestroy` for correct order of events: // `end` -> `close` @@ -223,7 +233,7 @@ function onStreamRead(arrayBuffer) { function setStreamTimeout(msecs, callback) { if (this.destroyed) - return; + return this; this.timeout = msecs; diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index f37452f9786057..1059ac4209e0eb 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -134,6 +134,9 @@ const builtInObjects = new Set( ObjectGetOwnPropertyNames(global).filter((e) => /^[A-Z][a-zA-Z0-9]+$/.test(e)) ); +// https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot +const isUndetectableObject = (v) => typeof v === 'undefined' && v !== undefined; + // These options must stay in sync with `getUserOptions`. So if any option will // be added or removed, `getUserOptions` must also be updated accordingly. const inspectDefaultOptions = ObjectSeal({ @@ -466,7 +469,7 @@ function getEmptyFormatArray() { function getConstructorName(obj, ctx, recurseTimes, protoProps) { let firstProto; const tmp = obj; - while (obj) { + while (obj || isUndetectableObject(obj)) { const descriptor = ObjectGetOwnPropertyDescriptor(obj, 'constructor'); if (descriptor !== undefined && typeof descriptor.value === 'function' && @@ -664,7 +667,9 @@ function findTypedConstructor(value) { // value afterwards again. function formatValue(ctx, value, recurseTimes, typedArray) { // Primitive types cannot have properties. - if (typeof value !== 'object' && typeof value !== 'function') { + if (typeof value !== 'object' && + typeof value !== 'function' && + !isUndetectableObject(value)) { return formatPrimitive(ctx.stylize, value, ctx); } if (value === null) { @@ -869,7 +874,7 @@ function formatRaw(ctx, value, recurseTimes, typedArray) { return ctx.stylize(base, 'date'); } } else if (isError(value)) { - base = formatError(value, constructor, tag, ctx); + base = formatError(value, constructor, tag, ctx, keys); if (keys.length === 0 && protoProps === undefined) return base; } else if (isAnyArrayBuffer(value)) { @@ -1059,11 +1064,23 @@ function getFunctionBase(value, constructor, tag) { return base; } -function formatError(err, constructor, tag, ctx) { +function formatError(err, constructor, tag, ctx, keys) { const name = err.name != null ? String(err.name) : 'Error'; let len = name.length; let stack = err.stack ? String(err.stack) : ErrorPrototypeToString(err); + // Do not "duplicate" error properties that are already included in the output + // otherwise. + if (!ctx.showHidden && keys.length !== 0) { + for (const name of ['name', 'message', 'stack']) { + const index = keys.indexOf(name); + // Only hide the property in case it's part of the original stack + if (index !== -1 && stack.includes(err[name])) { + keys.splice(index, 1); + } + } + } + // A stack trace may contain arbitrary data. Only manipulate the output // for "regular errors" (errors that "look normal") for now. if (constructor === null || diff --git a/lib/net.js b/lib/net.js index 21d17702b53798..39dc526641e216 100644 --- a/lib/net.js +++ b/lib/net.js @@ -629,9 +629,9 @@ function onReadableStreamEnd() { this.write = writeAfterFIN; if (this.writable) this.end(); - } - - if (!this.destroyed && !this.writable && !this.writableLength) + else if (!this.writableLength) + this.destroy(); + } else if (!this.destroyed && !this.writable && !this.writableLength) this.destroy(); } diff --git a/lib/perf_hooks.js b/lib/perf_hooks.js index 267b4577ffee3d..11a9b5eba6a343 100644 --- a/lib/perf_hooks.js +++ b/lib/perf_hooks.js @@ -3,7 +3,6 @@ const { ArrayIsArray, Boolean, - Map, NumberIsSafeInteger, ObjectDefineProperties, ObjectDefineProperty, @@ -52,16 +51,18 @@ const kInspect = require('internal/util').customInspectSymbol; const { ERR_INVALID_CALLBACK, - ERR_INVALID_ARG_VALUE, ERR_INVALID_ARG_TYPE, ERR_INVALID_OPT_VALUE, ERR_VALID_PERFORMANCE_ENTRY_TYPE, ERR_INVALID_PERFORMANCE_MARK } = require('internal/errors').codes; +const { + Histogram, + kHandle, +} = require('internal/histogram'); + const { setImmediate } = require('timers'); -const kHandle = Symbol('handle'); -const kMap = Symbol('map'); const kCallback = Symbol('callback'); const kTypes = Symbol('types'); const kEntries = Symbol('entries'); @@ -394,12 +395,14 @@ class Performance { measure(name, startMark, endMark) { name = `${name}`; - endMark = `${endMark}`; - startMark = startMark !== undefined ? `${startMark}` : ''; const marks = this[kIndex][kMarks]; - if (!marks.has(endMark) && !(endMark in nodeTiming)) { - throw new ERR_INVALID_PERFORMANCE_MARK(endMark); + if (arguments.length >= 3) { + if (!marks.has(endMark) && !(endMark in nodeTiming)) + throw new ERR_INVALID_PERFORMANCE_MARK(endMark); + else + endMark = `${endMark}`; } + startMark = startMark !== undefined ? `${startMark}` : ''; _measure(name, startMark, endMark); } @@ -557,47 +560,9 @@ function sortedInsert(list, entry) { list.splice(location, 0, entry); } -class ELDHistogram { - constructor(handle) { - this[kHandle] = handle; - this[kMap] = new Map(); - } - - reset() { this[kHandle].reset(); } +class ELDHistogram extends Histogram { enable() { return this[kHandle].enable(); } disable() { return this[kHandle].disable(); } - - get exceeds() { return this[kHandle].exceeds(); } - get min() { return this[kHandle].min(); } - get max() { return this[kHandle].max(); } - get mean() { return this[kHandle].mean(); } - get stddev() { return this[kHandle].stddev(); } - percentile(percentile) { - if (typeof percentile !== 'number') { - throw new ERR_INVALID_ARG_TYPE('percentile', 'number', percentile); - } - if (percentile <= 0 || percentile > 100) { - throw new ERR_INVALID_ARG_VALUE.RangeError('percentile', - percentile); - } - return this[kHandle].percentile(percentile); - } - get percentiles() { - this[kMap].clear(); - this[kHandle].percentiles(this[kMap]); - return this[kMap]; - } - - [kInspect]() { - return { - min: this.min, - max: this.max, - mean: this.mean, - stddev: this.stddev, - percentiles: this.percentiles, - exceeds: this.exceeds - }; - } } function monitorEventLoopDelay(options = {}) { diff --git a/lib/repl.js b/lib/repl.js index 420b9558f99700..19272f2229c702 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -1447,7 +1447,7 @@ REPLServer.prototype.defineCommand = function(keyword, cmd) { if (typeof cmd === 'function') { cmd = { action: cmd }; } else if (typeof cmd.action !== 'function') { - throw new ERR_INVALID_ARG_TYPE('action', 'Function', cmd.action); + throw new ERR_INVALID_ARG_TYPE('cmd.action', 'Function', cmd.action); } this.commands[keyword] = cmd; }; diff --git a/node.gyp b/node.gyp index ee99fbe7c522e9..784ce677c3d081 100644 --- a/node.gyp +++ b/node.gyp @@ -35,6 +35,7 @@ 'lib/internal/bootstrap/switches/is_not_main_thread.js', 'lib/internal/per_context/primordials.js', 'lib/internal/per_context/domexception.js', + 'lib/internal/per_context/messageport.js', 'lib/async_hooks.js', 'lib/assert.js', 'lib/buffer.js', @@ -136,6 +137,7 @@ 'lib/internal/fs/utils.js', 'lib/internal/fs/watchers.js', 'lib/internal/http.js', + 'lib/internal/histogram.js', 'lib/internal/idna.js', 'lib/internal/inspector_async_hook.js', 'lib/internal/js_stream_socket.js', @@ -518,7 +520,6 @@ 'src/api/exceptions.cc', 'src/api/hooks.cc', 'src/api/utils.cc', - 'src/async_wrap.cc', 'src/cares_wrap.cc', 'src/connect_wrap.cc', @@ -528,6 +529,7 @@ 'src/fs_event_wrap.cc', 'src/handle_wrap.cc', 'src/heap_utils.cc', + 'src/histogram.cc', 'src/js_native_api.h', 'src/js_native_api_types.h', 'src/js_native_api_v8.cc', diff --git a/onboarding.md b/onboarding.md index 092061c031131e..4f1346f2d06600 100644 --- a/onboarding.md +++ b/onboarding.md @@ -83,7 +83,7 @@ onboarding session. * Be nice about closing issues! Let people know why, and that issues and PRs can be reopened if necessary -* [**See "Labels"**](./onboarding-extras.md#labels) +* [**See "Labels"**](./doc/guides/onboarding-extras.md#labels) * There is [a bot](https://github.com/nodejs-github-bot/github-bot) that applies subsystem labels (for example, `doc`, `test`, `assert`, or `buffer`) so that we know what parts of the code base the pull request modifies. It is @@ -110,7 +110,7 @@ onboarding session. organization (not just Collaborators on Node.js core) have access. Its contents should not be shared externally. * You can find the full moderation policy - [here](https://github.com/nodejs/TSC/blob/master/Moderation-Policy.md). + [here](https://github.com/nodejs/admin/blob/master/Moderation-Policy.md). ## Reviewing PRs @@ -207,8 +207,7 @@ needs to be pointed out separately during the onboarding. * Optionally, include your personal pronouns. * Label your pull request with the `doc`, `notable-change`, and `fast-track` labels. -* Run CI on the PR. Because the PR does not affect any code, use the - `node-test-pull-request-lite-pipeline` CI task. +* Run CI on the PR. Use the `node-test-pull-request` CI task. * After two Collaborator approvals for the change and two Collaborator approvals for fast-tracking, land the PR. * Be sure to add the `PR-URL: ` and appropriate `Reviewed-By:` @@ -239,13 +238,13 @@ needs to be pointed out separately during the onboarding. the [summit](https://github.com/nodejs/summit) repository for details. [Code of Conduct]: https://github.com/nodejs/admin/blob/master/CODE_OF_CONDUCT.md -[`author-ready`]: https://github.com/nodejs/node/blob/master/COLLABORATOR_GUIDE.md#author-ready-pull-requests +[`author-ready`]: doc/guides/collaborator-guide.md#author-ready-pull-requests [`core-validate-commit`]: https://github.com/nodejs/core-validate-commit [`git-node`]: https://github.com/nodejs/node-core-utils/blob/master/docs/git-node.md [`node-core-utils`]: https://github.com/nodejs/node-core-utils -[Landing Pull Requests]: https://github.com/nodejs/node/blob/master/COLLABORATOR_GUIDE.md#landing-pull-requests +[Landing Pull Requests]: doc/guides/collaborator-guide.md#landing-pull-requests [Publicizing or hiding organization membership]: https://help.github.com/articles/publicizing-or-hiding-organization-membership/ [set up the credentials]: https://github.com/nodejs/node-core-utils#setting-up-credentials [two-factor authentication]: https://help.github.com/articles/securing-your-account-with-two-factor-authentication-2fa/ [using a TOTP mobile app]: https://help.github.com/articles/configuring-two-factor-authentication-via-a-totp-mobile-app/ -[who-to-cc]: ../COLLABORATOR_GUIDE.md#who-to-cc-in-the-issue-tracker +[who-to-cc]: doc/guides/collaborator-guide.md#who-to-cc-in-the-issue-tracker diff --git a/src/aliased_buffer.h b/src/aliased_buffer.h index 868d495be9e04c..717b1d631cb4f1 100644 --- a/src/aliased_buffer.h +++ b/src/aliased_buffer.h @@ -221,7 +221,8 @@ class AliasedBufferBase { const v8::HandleScope handle_scope(isolate_); const size_t old_size_in_bytes = sizeof(NativeT) * count_; - const size_t new_size_in_bytes = sizeof(NativeT) * new_capacity; + const size_t new_size_in_bytes = MultiplyWithOverflowCheck(sizeof(NativeT), + new_capacity); // allocate v8 new ArrayBuffer v8::Local ab = v8::ArrayBuffer::New( diff --git a/src/api/environment.cc b/src/api/environment.cc index 48c45b6e5e3eb9..1df70cf6a6d44d 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -433,6 +433,7 @@ bool InitializeContextForSnapshot(Local context) { static const char* context_files[] = {"internal/per_context/primordials", "internal/per_context/domexception", + "internal/per_context/messageport", nullptr}; for (const char** module = context_files; *module != nullptr; module++) { diff --git a/src/async_wrap.cc b/src/async_wrap.cc index 58d89225e0e523..784493fe4ed734 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -49,7 +49,6 @@ using v8::PropertyAttribute; using v8::PropertyCallbackInfo; using v8::ReadOnly; using v8::String; -using v8::TryCatch; using v8::Uint32; using v8::Undefined; using v8::Value; @@ -348,6 +347,10 @@ class DestroyParam { Global propBag; }; +static void DestroyParamCleanupHook(void* ptr) { + delete static_cast(ptr); +} + void AsyncWrap::WeakCallback(const WeakCallbackInfo& info) { HandleScope scope(info.GetIsolate()); @@ -356,6 +359,8 @@ void AsyncWrap::WeakCallback(const WeakCallbackInfo& info) { p->propBag); Local val; + p->env->RemoveCleanupHook(DestroyParamCleanupHook, p.get()); + if (!prop_bag->Get(p->env->context(), p->env->destroyed_string()) .ToLocal(&val)) { return; @@ -380,6 +385,7 @@ static void RegisterDestroyHook(const FunctionCallbackInfo& args) { p->target.Reset(isolate, args[0].As()); p->propBag.Reset(isolate, args[2].As()); p->target.SetWeak(p, AsyncWrap::WeakCallback, WeakCallbackType::kParameter); + p->env->AddCleanupHook(DestroyParamCleanupHook, p); } @@ -581,7 +587,7 @@ AsyncWrap::AsyncWrap(Environment* env, provider_type_ = provider; // Use AsyncReset() call to execute the init() callbacks. - AsyncReset(execution_async_id, silent); + AsyncReset(object, execution_async_id, silent); init_hook_ran_ = true; } @@ -647,10 +653,6 @@ void AsyncWrap::EmitDestroy(Environment* env, double async_id) { env->destroy_async_id_list()->push_back(async_id); } -void AsyncWrap::AsyncReset(double execution_async_id, bool silent) { - AsyncReset(object(), execution_async_id, silent); -} - // Generalized call for both the constructor and for handles that are pooled // and reused over their lifetime. This way a new uid can be assigned when // the resource is pulled out of the pool and put back into use. diff --git a/src/async_wrap.h b/src/async_wrap.h index dd82497a259243..521560c795768e 100644 --- a/src/async_wrap.h +++ b/src/async_wrap.h @@ -168,9 +168,6 @@ class AsyncWrap : public BaseObject { double execution_async_id = kInvalidAsyncId, bool silent = false); - void AsyncReset(double execution_async_id = kInvalidAsyncId, - bool silent = false); - // Only call these within a valid HandleScope. v8::MaybeLocal MakeCallback(const v8::Local cb, int argc, diff --git a/src/base_object.h b/src/base_object.h index daf40b7c1eb7b4..e7ef029995f1cf 100644 --- a/src/base_object.h +++ b/src/base_object.h @@ -165,7 +165,7 @@ inline T* Unwrap(v8::Local obj) { // Implementation of a generic strong or weak pointer to a BaseObject. // If strong, this will keep the target BaseObject alive regardless of other -// circumstances such das GC or Environment cleanup. +// circumstances such as the GC or Environment cleanup. // If weak, destruction behaviour is not affected, but the pointer will be // reset to nullptr once the BaseObject is destroyed. // The API matches std::shared_ptr closely. diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index 8eeaeddf8300d8..082f86ff41d673 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -64,6 +64,7 @@ using v8::FunctionTemplate; using v8::HandleScope; using v8::Int32; using v8::Integer; +using v8::Isolate; using v8::Local; using v8::Null; using v8::Object; @@ -1917,7 +1918,7 @@ int ParseIP(const char* ip, ParseIPResult* result = nullptr) { } void CanonicalizeIP(const FunctionCallbackInfo& args) { - v8::Isolate* isolate = args.GetIsolate(); + Isolate* isolate = args.GetIsolate(); node::Utf8Value ip(isolate, args[0]); ParseIPResult result; @@ -1927,7 +1928,7 @@ void CanonicalizeIP(const FunctionCallbackInfo& args) { char canonical_ip[INET6_ADDRSTRLEN]; const int af = (rc == 4 ? AF_INET : AF_INET6); CHECK_EQ(0, uv_inet_ntop(af, &result, canonical_ip, sizeof(canonical_ip))); - v8::Local val = String::NewFromUtf8(isolate, canonical_ip, + Local val = String::NewFromUtf8(isolate, canonical_ip, v8::NewStringType::kNormal).ToLocalChecked(); args.GetReturnValue().Set(val); } diff --git a/src/debug_utils-inl.h b/src/debug_utils-inl.h index ae2d2046486466..d87dd62c8952af 100644 --- a/src/debug_utils-inl.h +++ b/src/debug_utils-inl.h @@ -27,6 +27,28 @@ struct ToStringHelper { } static std::string Convert(const std::string& value) { return value; } static std::string Convert(bool value) { return value ? "true" : "false"; } + template ::value, int>::type = 0> + static std::string BaseConvert(const T& value) { + auto v = static_cast(value); + char ret[3 * sizeof(T)]; + char* ptr = ret + 3 * sizeof(T) - 1; + *ptr = '\0'; + const char* digits = "0123456789abcdef"; + do { + unsigned digit = v & ((1 << BASE_BITS) - 1); + *--ptr = + (BASE_BITS < 4 ? static_cast('0' + digit) : digits[digit]); + } while ((v >>= BASE_BITS) != 0); + return ptr; + } + template ::value, int>::type = 0> + static std::string BaseConvert(T value) { + return Convert(std::forward(value)); + } }; template @@ -34,6 +56,11 @@ std::string ToString(const T& value) { return ToStringHelper::Convert(value); } +template +std::string ToBaseString(const T& value) { + return ToStringHelper::BaseConvert(value); +} + inline std::string SPrintFImpl(const char* format) { const char* p = strchr(format, '%'); if (LIKELY(p == nullptr)) return format; @@ -64,7 +91,18 @@ std::string COLD_NOINLINE SPrintFImpl( // NOLINT(runtime/string) case 'd': case 'i': case 'u': - case 's': ret += ToString(arg); break; + case 's': + ret += ToString(arg); + break; + case 'o': + ret += ToBaseString<3>(arg); + break; + case 'x': + ret += ToBaseString<4>(arg); + break; + case 'X': + ret += node::ToUpper(ToBaseString<4>(arg)); + break; case 'p': { CHECK(std::is_pointer::type>::value); char out[20]; diff --git a/src/debug_utils.h b/src/debug_utils.h index b654159ac2a24e..3ecbdea90e2c22 100644 --- a/src/debug_utils.h +++ b/src/debug_utils.h @@ -5,6 +5,7 @@ #include "async_wrap.h" +#include #include #include diff --git a/src/env-inl.h b/src/env-inl.h index 08df9c061ac91f..5248e7062354c1 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -928,7 +928,7 @@ inline const Mutex& Environment::extra_linked_bindings_mutex() const { return extra_linked_bindings_mutex_; } -inline performance::performance_state* Environment::performance_state() { +inline performance::PerformanceState* Environment::performance_state() { return performance_state_.get(); } @@ -1227,9 +1227,8 @@ int64_t Environment::base_object_count() const { #define VS(PropertyName, StringValue) V(v8::String, PropertyName) #define V(TypeName, PropertyName) \ inline \ - v8::Local IsolateData::PropertyName(v8::Isolate* isolate) const { \ - /* Strings are immutable so casting away const-ness here is okay. */ \ - return const_cast(this)->PropertyName ## _.Get(isolate); \ + v8::Local IsolateData::PropertyName() const { \ + return PropertyName ## _ .Get(isolate_); \ } PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP) PER_ISOLATE_SYMBOL_PROPERTIES(VY) @@ -1244,7 +1243,7 @@ int64_t Environment::base_object_count() const { #define VS(PropertyName, StringValue) V(v8::String, PropertyName) #define V(TypeName, PropertyName) \ inline v8::Local Environment::PropertyName() const { \ - return isolate_data()->PropertyName(isolate()); \ + return isolate_data()->PropertyName(); \ } PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP) PER_ISOLATE_SYMBOL_PROPERTIES(VY) diff --git a/src/env.cc b/src/env.cc index 2bdac964cb03ca..ec50d8841ac1e3 100644 --- a/src/env.cc +++ b/src/env.cc @@ -64,9 +64,9 @@ std::vector IsolateData::Serialize(SnapshotCreator* creator) { // but that's not part of the V8 API contract so we use an array // just to be safe. -#define VP(PropertyName, StringValue) V(v8::Private, PropertyName) -#define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName) -#define VS(PropertyName, StringValue) V(v8::String, PropertyName) +#define VP(PropertyName, StringValue) V(Private, PropertyName) +#define VY(PropertyName, StringValue) V(Symbol, PropertyName) +#define VS(PropertyName, StringValue) V(String, PropertyName) #define V(TypeName, PropertyName) \ indexes.push_back(creator->AddData(PropertyName##_.Get(isolate))); PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP) @@ -84,9 +84,9 @@ void IsolateData::DeserializeProperties(const std::vector* indexes) { size_t i = 0; HandleScope handle_scope(isolate_); -#define VP(PropertyName, StringValue) V(v8::Private, PropertyName) -#define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName) -#define VS(PropertyName, StringValue) V(v8::String, PropertyName) +#define VP(PropertyName, StringValue) V(Private, PropertyName) +#define VY(PropertyName, StringValue) V(Symbol, PropertyName) +#define VS(PropertyName, StringValue) V(String, PropertyName) #define V(TypeName, PropertyName) \ do { \ MaybeLocal field = \ @@ -181,12 +181,12 @@ IsolateData::IsolateData(Isolate* isolate, void IsolateData::MemoryInfo(MemoryTracker* tracker) const { #define V(PropertyName, StringValue) \ - tracker->TrackField(#PropertyName, PropertyName(isolate())); + tracker->TrackField(#PropertyName, PropertyName()); PER_ISOLATE_SYMBOL_PROPERTIES(V) #undef V #define V(PropertyName, StringValue) \ - tracker->TrackField(#PropertyName, PropertyName(isolate())); + tracker->TrackField(#PropertyName, PropertyName()); PER_ISOLATE_STRING_PROPERTIES(V) #undef V @@ -207,7 +207,7 @@ void InitThreadLocalOnce() { } void TrackingTraceStateObserver::UpdateTraceCategoryState() { - if (!env_->owns_process_state()) { + if (!env_->owns_process_state() || !env_->can_call_into_js()) { // Ideally, we’d have a consistent story that treats all threads/Environment // instances equally here. However, tracing is essentially global, and this // callback is called from whichever thread calls `StartTracing()` or @@ -228,8 +228,7 @@ void TrackingTraceStateObserver::UpdateTraceCategoryState() { TryCatchScope try_catch(env_); try_catch.SetVerbose(true); Local args[] = {Boolean::New(isolate, async_hooks_enabled)}; - cb->Call(env_->context(), Undefined(isolate), arraysize(args), args) - .ToLocalChecked(); + USE(cb->Call(env_->context(), Undefined(isolate), arraysize(args), args)); } static std::atomic next_thread_id{0}; @@ -349,7 +348,7 @@ Environment::Environment(IsolateData* isolate_data, this); performance_state_ = - std::make_unique(isolate()); + std::make_unique(isolate()); performance_state_->Mark( performance::NODE_PERFORMANCE_MILESTONE_ENVIRONMENT); performance_state_->Mark(performance::NODE_PERFORMANCE_MILESTONE_NODE_START, @@ -969,6 +968,7 @@ void Environment::Exit(int exit_code) { isolate(), stack_trace_limit(), StackTrace::kDetailed)); } if (is_main_thread()) { + set_can_call_into_js(false); stop_sub_worker_contexts(); DisposePlatform(); exit(exit_code); @@ -994,7 +994,7 @@ Environment* Environment::worker_parent_env() const { void MemoryTracker::TrackField(const char* edge_name, const CleanupHookCallback& value, const char* node_name) { - v8::HandleScope handle_scope(isolate_); + HandleScope handle_scope(isolate_); // Here, we utilize the fact that CleanupHookCallback instances // are all unique and won't be tracked twice in one BuildEmbedderGraph // callback. diff --git a/src/env.h b/src/env.h index e5e8c107f6881d..cdcb8f5cf3b923 100644 --- a/src/env.h +++ b/src/env.h @@ -64,7 +64,7 @@ class FileHandleReadWrap; } namespace performance { -class performance_state; +class PerformanceState; } namespace tracing { @@ -409,11 +409,11 @@ constexpr size_t kFsStatsBufferLength = V(filehandlereadwrap_template, v8::ObjectTemplate) \ V(fsreqpromise_constructor_template, v8::ObjectTemplate) \ V(handle_wrap_ctor_template, v8::FunctionTemplate) \ + V(histogram_instance_template, v8::ObjectTemplate) \ V(http2settings_constructor_template, v8::ObjectTemplate) \ V(http2stream_constructor_template, v8::ObjectTemplate) \ V(http2ping_constructor_template, v8::ObjectTemplate) \ V(libuv_stream_wrap_ctor_template, v8::FunctionTemplate) \ - V(message_event_object_template, v8::ObjectTemplate) \ V(message_port_constructor_template, v8::FunctionTemplate) \ V(pipe_constructor_template, v8::FunctionTemplate) \ V(promise_wrap_template, v8::ObjectTemplate) \ @@ -502,7 +502,7 @@ class IsolateData : public MemoryRetainer { #define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName) #define VS(PropertyName, StringValue) V(v8::String, PropertyName) #define V(TypeName, PropertyName) \ - inline v8::Local PropertyName(v8::Isolate* isolate) const; + inline v8::Local PropertyName() const; PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP) PER_ISOLATE_SYMBOL_PROPERTIES(VY) PER_ISOLATE_STRING_PROPERTIES(VS) @@ -596,11 +596,13 @@ class KVStore { virtual v8::MaybeLocal Get(v8::Isolate* isolate, v8::Local key) const = 0; + virtual v8::Maybe Get(const char* key) const = 0; virtual void Set(v8::Isolate* isolate, v8::Local key, v8::Local value) = 0; virtual int32_t Query(v8::Isolate* isolate, v8::Local key) const = 0; + virtual int32_t Query(const char* key) const = 0; virtual void Delete(v8::Isolate* isolate, v8::Local key) = 0; virtual v8::Local Enumerate(v8::Isolate* isolate) const = 0; @@ -1014,7 +1016,7 @@ class Environment : public MemoryRetainer { inline std::vector>& file_handle_read_wrap_freelist(); - inline performance::performance_state* performance_state(); + inline performance::PerformanceState* performance_state(); inline std::unordered_map* performance_marks(); void CollectUVExceptionInfo(v8::Local context, @@ -1170,7 +1172,8 @@ class Environment : public MemoryRetainer { } // cb will be called as cb(env) on the next event loop iteration. - // keep_alive will be kept alive between now and after the callback has run. + // Unlike the JS setImmediate() function, nested SetImmediate() calls will + // be run without returning control to the event loop, similar to nextTick(). template inline void SetImmediate(Fn&& cb); template @@ -1324,7 +1327,7 @@ class Environment : public MemoryRetainer { AliasedInt32Array stream_base_state_; - std::unique_ptr performance_state_; + std::unique_ptr performance_state_; std::unordered_map performance_marks_; bool has_run_bootstrapping_code_ = false; diff --git a/src/histogram-inl.h b/src/histogram-inl.h index 3135041f7387a9..58911dae8f2dae 100644 --- a/src/histogram-inl.h +++ b/src/histogram-inl.h @@ -4,58 +4,78 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #include "histogram.h" +#include "base_object-inl.h" #include "node_internals.h" namespace node { -inline Histogram::Histogram(int64_t lowest, int64_t highest, int figures) { - CHECK_EQ(0, hdr_init(lowest, highest, figures, &histogram_)); +void Histogram::Reset() { + hdr_reset(histogram_.get()); } -inline Histogram::~Histogram() { - hdr_close(histogram_); +bool Histogram::Record(int64_t value) { + return hdr_record_value(histogram_.get(), value); } -inline void Histogram::Reset() { - hdr_reset(histogram_); +int64_t Histogram::Min() { + return hdr_min(histogram_.get()); } -inline bool Histogram::Record(int64_t value) { - return hdr_record_value(histogram_, value); +int64_t Histogram::Max() { + return hdr_max(histogram_.get()); } -inline int64_t Histogram::Min() { - return hdr_min(histogram_); +double Histogram::Mean() { + return hdr_mean(histogram_.get()); } -inline int64_t Histogram::Max() { - return hdr_max(histogram_); +double Histogram::Stddev() { + return hdr_stddev(histogram_.get()); } -inline double Histogram::Mean() { - return hdr_mean(histogram_); -} - -inline double Histogram::Stddev() { - return hdr_stddev(histogram_); -} - -inline double Histogram::Percentile(double percentile) { +double Histogram::Percentile(double percentile) { CHECK_GT(percentile, 0); CHECK_LE(percentile, 100); - return hdr_value_at_percentile(histogram_, percentile); + return static_cast( + hdr_value_at_percentile(histogram_.get(), percentile)); } -inline void Histogram::Percentiles(std::function fn) { +template +void Histogram::Percentiles(Iterator&& fn) { hdr_iter iter; - hdr_iter_percentile_init(&iter, histogram_, 1); + hdr_iter_percentile_init(&iter, histogram_.get(), 1); while (hdr_iter_next(&iter)) { double key = iter.specifics.percentiles.percentile; - double value = iter.value; + double value = static_cast(iter.value); fn(key, value); } } +bool HistogramBase::RecordDelta() { + uint64_t time = uv_hrtime(); + bool ret = true; + if (prev_ > 0) { + int64_t delta = time - prev_; + if (delta > 0) { + ret = Record(delta); + TraceDelta(delta); + if (!ret) { + if (exceeds_ < 0xFFFFFFFF) + exceeds_++; + TraceExceeds(delta); + } + } + } + prev_ = time; + return ret; +} + +void HistogramBase::ResetState() { + Reset(); + exceeds_ = 0; + prev_ = 0; +} + } // namespace node #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS diff --git a/src/histogram.cc b/src/histogram.cc new file mode 100644 index 00000000000000..8d1eb77b1bc88e --- /dev/null +++ b/src/histogram.cc @@ -0,0 +1,141 @@ +#include "histogram.h" // NOLINT(build/include_inline) +#include "histogram-inl.h" +#include "memory_tracker-inl.h" + +namespace node { + +using v8::FunctionCallbackInfo; +using v8::FunctionTemplate; +using v8::Local; +using v8::Map; +using v8::Number; +using v8::ObjectTemplate; +using v8::String; +using v8::Value; + +Histogram::Histogram(int64_t lowest, int64_t highest, int figures) { + hdr_histogram* histogram; + CHECK_EQ(0, hdr_init(lowest, highest, figures, &histogram)); + histogram_.reset(histogram); +} + +HistogramBase::HistogramBase( + Environment* env, + v8::Local wrap, + int64_t lowest, + int64_t highest, + int figures) + : BaseObject(env, wrap), + Histogram(lowest, highest, figures) { + MakeWeak(); +} + +void HistogramBase::MemoryInfo(MemoryTracker* tracker) const { + tracker->TrackFieldWithSize("histogram", GetMemorySize()); +} + +void HistogramBase::GetMin(const FunctionCallbackInfo& args) { + HistogramBase* histogram; + ASSIGN_OR_RETURN_UNWRAP(&histogram, args.Holder()); + double value = static_cast(histogram->Min()); + args.GetReturnValue().Set(value); +} + +void HistogramBase::GetMax(const FunctionCallbackInfo& args) { + HistogramBase* histogram; + ASSIGN_OR_RETURN_UNWRAP(&histogram, args.Holder()); + double value = static_cast(histogram->Max()); + args.GetReturnValue().Set(value); +} + +void HistogramBase::GetMean(const FunctionCallbackInfo& args) { + HistogramBase* histogram; + ASSIGN_OR_RETURN_UNWRAP(&histogram, args.Holder()); + args.GetReturnValue().Set(histogram->Mean()); +} + +void HistogramBase::GetExceeds(const FunctionCallbackInfo& args) { + HistogramBase* histogram; + ASSIGN_OR_RETURN_UNWRAP(&histogram, args.Holder()); + double value = static_cast(histogram->Exceeds()); + args.GetReturnValue().Set(value); +} + +void HistogramBase::GetStddev(const FunctionCallbackInfo& args) { + HistogramBase* histogram; + ASSIGN_OR_RETURN_UNWRAP(&histogram, args.Holder()); + args.GetReturnValue().Set(histogram->Stddev()); +} + +void HistogramBase::GetPercentile( + const FunctionCallbackInfo& args) { + HistogramBase* histogram; + ASSIGN_OR_RETURN_UNWRAP(&histogram, args.Holder()); + CHECK(args[0]->IsNumber()); + double percentile = args[0].As()->Value(); + args.GetReturnValue().Set(histogram->Percentile(percentile)); +} + +void HistogramBase::GetPercentiles( + const FunctionCallbackInfo& args) { + Environment* env = Environment::GetCurrent(args); + HistogramBase* histogram; + ASSIGN_OR_RETURN_UNWRAP(&histogram, args.Holder()); + CHECK(args[0]->IsMap()); + Local map = args[0].As(); + histogram->Percentiles([map, env](double key, double value) { + map->Set( + env->context(), + Number::New(env->isolate(), key), + Number::New(env->isolate(), value)).IsEmpty(); + }); +} + +void HistogramBase::DoReset(const FunctionCallbackInfo& args) { + HistogramBase* histogram; + ASSIGN_OR_RETURN_UNWRAP(&histogram, args.Holder()); + histogram->ResetState(); +} + +BaseObjectPtr HistogramBase::New( + Environment* env, + int64_t lowest, + int64_t highest, + int figures) { + CHECK_LE(lowest, highest); + CHECK_GT(figures, 0); + v8::Local obj; + auto tmpl = env->histogram_instance_template(); + if (!tmpl->NewInstance(env->context()).ToLocal(&obj)) + return {}; + + return MakeDetachedBaseObject( + env, obj, lowest, highest, figures); +} + +void HistogramBase::Initialize(Environment* env) { + // Guard against multiple initializations + if (!env->histogram_instance_template().IsEmpty()) + return; + + Local histogram = FunctionTemplate::New(env->isolate()); + Local classname = FIXED_ONE_BYTE_STRING(env->isolate(), "Histogram"); + histogram->SetClassName(classname); + + Local histogramt = + histogram->InstanceTemplate(); + + histogramt->SetInternalFieldCount(1); + env->SetProtoMethod(histogram, "exceeds", HistogramBase::GetExceeds); + env->SetProtoMethod(histogram, "min", HistogramBase::GetMin); + env->SetProtoMethod(histogram, "max", HistogramBase::GetMax); + env->SetProtoMethod(histogram, "mean", HistogramBase::GetMean); + env->SetProtoMethod(histogram, "stddev", HistogramBase::GetStddev); + env->SetProtoMethod(histogram, "percentile", HistogramBase::GetPercentile); + env->SetProtoMethod(histogram, "percentiles", HistogramBase::GetPercentiles); + env->SetProtoMethod(histogram, "reset", HistogramBase::DoReset); + + env->set_histogram_instance_template(histogramt); +} + +} // namespace node diff --git a/src/histogram.h b/src/histogram.h index eb94af5da2a997..e92c31c4724ac6 100644 --- a/src/histogram.h +++ b/src/histogram.h @@ -4,15 +4,24 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #include "hdr_histogram.h" +#include "base_object.h" +#include "util.h" + #include +#include #include namespace node { +constexpr int kDefaultHistogramFigures = 3; + class Histogram { public: - inline Histogram(int64_t lowest, int64_t highest, int figures = 3); - inline virtual ~Histogram(); + Histogram( + int64_t lowest = std::numeric_limits::min(), + int64_t highest = std::numeric_limits::max(), + int figures = kDefaultHistogramFigures); + virtual ~Histogram() = default; inline bool Record(int64_t value); inline void Reset(); @@ -21,14 +30,65 @@ class Histogram { inline double Mean(); inline double Stddev(); inline double Percentile(double percentile); - inline void Percentiles(std::function fn); + + // Iterator is a function type that takes two doubles as argument, one for + // percentile and one for the value at that percentile. + template + inline void Percentiles(Iterator&& fn); size_t GetMemorySize() const { - return hdr_get_memory_size(histogram_); + return hdr_get_memory_size(histogram_.get()); } private: - hdr_histogram* histogram_; + using HistogramPointer = DeleteFnPtr; + HistogramPointer histogram_; +}; + +class HistogramBase : public BaseObject, public Histogram { + public: + virtual ~HistogramBase() = default; + + virtual void TraceDelta(int64_t delta) {} + virtual void TraceExceeds(int64_t delta) {} + + inline bool RecordDelta(); + inline void ResetState(); + + int64_t Exceeds() const { return exceeds_; } + + void MemoryInfo(MemoryTracker* tracker) const override; + SET_MEMORY_INFO_NAME(HistogramBase) + SET_SELF_SIZE(HistogramBase) + + static void GetMin(const v8::FunctionCallbackInfo& args); + static void GetMax(const v8::FunctionCallbackInfo& args); + static void GetMean(const v8::FunctionCallbackInfo& args); + static void GetExceeds(const v8::FunctionCallbackInfo& args); + static void GetStddev(const v8::FunctionCallbackInfo& args); + static void GetPercentile( + const v8::FunctionCallbackInfo& args); + static void GetPercentiles( + const v8::FunctionCallbackInfo& args); + static void DoReset(const v8::FunctionCallbackInfo& args); + static void Initialize(Environment* env); + + static BaseObjectPtr New( + Environment* env, + int64_t lowest = std::numeric_limits::min(), + int64_t highest = std::numeric_limits::max(), + int figures = kDefaultHistogramFigures); + + HistogramBase( + Environment* env, + v8::Local wrap, + int64_t lowest = std::numeric_limits::min(), + int64_t highest = std::numeric_limits::max(), + int figures = kDefaultHistogramFigures); + + private: + int64_t exceeds_ = 0; + uint64_t prev_ = 0; }; } // namespace node diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc index d26b28dd0df4e8..f232248c4e12d3 100644 --- a/src/js_native_api_v8.cc +++ b/src/js_native_api_v8.cc @@ -392,10 +392,12 @@ class ArrayBufferReference final : public Reference { inline void Finalize(bool is_env_teardown) override { if (is_env_teardown) { v8::HandleScope handle_scope(_env->isolate); - v8::Local ab = Get(); - CHECK(!ab.IsEmpty()); - CHECK(ab->IsArrayBuffer()); - ab.As()->Detach(); + v8::Local obj = Get(); + CHECK(!obj.IsEmpty()); + CHECK(obj->IsArrayBuffer()); + v8::Local ab = obj.As(); + if (ab->IsDetachable()) + ab->Detach(); } Reference::Finalize(is_env_teardown); diff --git a/src/module_wrap.cc b/src/module_wrap.cc index c25edd9a28a964..29078bf6e58ce1 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -1047,7 +1047,6 @@ Maybe ResolveExportsTarget(Environment* env, return Nothing(); } CHECK(!try_catch.HasCaught()); - ProcessEmitExperimentalWarning(env, "Conditional exports"); return resolved; } } else if (key_str == "default") { @@ -1068,7 +1067,6 @@ Maybe ResolveExportsTarget(Environment* env, return Nothing(); } CHECK(!try_catch.HasCaught()); - ProcessEmitExperimentalWarning(env, "Conditional exports"); return resolved; } } @@ -1284,7 +1282,6 @@ Maybe PackageResolve(Environment* env, } } if (found_pjson && pcfg->name == pkg_name && !pcfg->exports.IsEmpty()) { - ProcessEmitExperimentalWarning(env, "Package name self resolution"); if (pkg_subpath == "./") { return Just(URL("./", pjson_url)); } else if (!pkg_subpath.length()) { @@ -1426,8 +1423,8 @@ static MaybeLocal ImportModuleDynamically( Local options = referrer->GetHostDefinedOptions(); if (options->Length() != HostDefinedOptions::kLength) { - Local resolver = - Promise::Resolver::New(context).ToLocalChecked(); + Local resolver; + if (!Promise::Resolver::New(context).ToLocal(&resolver)) return {}; resolver ->Reject(context, v8::Exception::TypeError(FIXED_ONE_BYTE_STRING( @@ -1495,7 +1492,8 @@ void ModuleWrap::SetImportModuleDynamicallyCallback( void ModuleWrap::HostInitializeImportMetaObjectCallback( Local context, Local module, Local meta) { Environment* env = Environment::GetCurrent(context); - CHECK_NOT_NULL(env); // TODO(addaleax): Handle nullptr here. + if (env == nullptr) + return; ModuleWrap* module_wrap = GetFromModule(env, module); if (module_wrap == nullptr) { diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 18a46fd6fc9ae8..59baa45413d500 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -151,7 +151,8 @@ void CallbackInfo::CleanupHook(void* data) { HandleScope handle_scope(self->env_->isolate()); Local ab = self->persistent_.Get(self->env_->isolate()); CHECK(!ab.IsEmpty()); - ab->Detach(); + if (ab->IsDetachable()) + ab->Detach(); } self->WeakCallback(self->env_->isolate()); @@ -162,7 +163,6 @@ void CallbackInfo::WeakCallback( const WeakCallbackInfo& data) { CallbackInfo* self = data.GetParameter(); self->WeakCallback(data.GetIsolate()); - delete self; } @@ -170,6 +170,7 @@ void CallbackInfo::WeakCallback(Isolate* isolate) { callback_(data_, hint_); int64_t change_in_bytes = -static_cast(sizeof(*this)); isolate->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); + delete this; } diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 4e1a4d8bc80fe3..ee42630ad06da9 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -499,7 +499,7 @@ void SecureContext::Initialize(Environment* env, Local target) { env->set_secure_context_constructor_template(t); } -SecureContext::SecureContext(Environment* env, v8::Local wrap) +SecureContext::SecureContext(Environment* env, Local wrap) : BaseObject(env, wrap) { MakeWeak(); env->isolate()->AdjustAmountOfExternalAllocatedMemory(kExternalSize); @@ -985,24 +985,6 @@ static X509_STORE* NewRootCertStore() { } -void GetRootCertificates(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args); - Local result[arraysize(root_certs)]; - - for (size_t i = 0; i < arraysize(root_certs); i++) { - if (!String::NewFromOneByte( - env->isolate(), - reinterpret_cast(root_certs[i]), - NewStringType::kNormal).ToLocal(&result[i])) { - return; - } - } - - args.GetReturnValue().Set( - Array::New(env->isolate(), result, arraysize(root_certs))); -} - - void SecureContext::AddCACert(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); @@ -2645,6 +2627,21 @@ static inline Local BIOToStringOrBuffer(Environment* env, } } +static MaybeLocal X509ToPEM(Environment* env, X509* cert) { + BIOPointer bio(BIO_new(BIO_s_mem())); + if (!bio) { + ThrowCryptoError(env, ERR_get_error(), "BIO_new"); + return MaybeLocal(); + } + + if (PEM_write_bio_X509(bio.get(), cert) == 0) { + ThrowCryptoError(env, ERR_get_error(), "PEM_write_bio_X509"); + return MaybeLocal(); + } + + return BIOToStringOrBuffer(env, bio.get(), kKeyFormatPEM); +} + static bool WritePublicKeyInner(EVP_PKEY* pkey, const BIOPointer& bio, const PublicKeyEncodingConfig& config) { @@ -3252,7 +3249,7 @@ KeyType KeyObject::GetKeyType() const { } KeyObject::KeyObject(Environment* env, - v8::Local wrap, + Local wrap, KeyType key_type) : BaseObject(env, wrap), key_type_(key_type), @@ -3297,7 +3294,7 @@ void KeyObject::Init(const FunctionCallbackInfo& args) { } } -void KeyObject::InitSecret(v8::Local abv) { +void KeyObject::InitSecret(Local abv) { CHECK_EQ(this->key_type_, kKeyTypeSecret); size_t key_len = abv->ByteLength(); @@ -3359,7 +3356,7 @@ void KeyObject::GetSymmetricKeySize(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(static_cast(key->GetSymmetricKeySize())); } -void KeyObject::Export(const v8::FunctionCallbackInfo& args) { +void KeyObject::Export(const FunctionCallbackInfo& args) { KeyObject* key; ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder()); @@ -3403,7 +3400,7 @@ MaybeLocal KeyObject::ExportPrivateKey( } CipherBase::CipherBase(Environment* env, - v8::Local wrap, + Local wrap, CipherKind kind) : BaseObject(env, wrap), ctx_(nullptr), @@ -4034,7 +4031,7 @@ void CipherBase::Final(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(out.ToBuffer().ToLocalChecked()); } -Hmac::Hmac(Environment* env, v8::Local wrap) +Hmac::Hmac(Environment* env, Local wrap) : BaseObject(env, wrap), ctx_(nullptr) { MakeWeak(); @@ -4157,7 +4154,7 @@ void Hmac::HmacDigest(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(rc.ToLocalChecked()); } -Hash::Hash(Environment* env, v8::Local wrap) +Hash::Hash(Environment* env, Local wrap) : BaseObject(env, wrap), mdctx_(nullptr), has_md_(false), @@ -4405,7 +4402,7 @@ void CheckThrow(Environment* env, SignBase::Error error) { } } -SignBase::SignBase(Environment* env, v8::Local wrap) +SignBase::SignBase(Environment* env, Local wrap) : BaseObject(env, wrap) { } @@ -4432,7 +4429,7 @@ static bool ApplyRSAOptions(const ManagedEVPPKey& pkey, } -Sign::Sign(Environment* env, v8::Local wrap) : SignBase(env, wrap) { +Sign::Sign(Environment* env, Local wrap) : SignBase(env, wrap) { MakeWeak(); } @@ -4755,8 +4752,8 @@ void SignOneShot(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(signature.ToBuffer().ToLocalChecked()); } -Verify::Verify(Environment* env, v8::Local wrap) : - SignBase(env, wrap) { +Verify::Verify(Environment* env, Local wrap) + : SignBase(env, wrap) { MakeWeak(); } @@ -5014,6 +5011,7 @@ template void PublicKeyCipher::Cipher(const FunctionCallbackInfo& args) { + MarkPopErrorOnReturn mark_pop_error_on_return; Environment* env = Environment::GetCurrent(args); unsigned int offset = 0; @@ -5044,8 +5042,6 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo& args) { AllocatedBuffer out; - ClearErrorOnReturn clear_error_on_return; - bool r = Cipher( env, pkey, @@ -5063,7 +5059,7 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(out.ToBuffer().ToLocalChecked()); } -DiffieHellman::DiffieHellman(Environment* env, v8::Local wrap) +DiffieHellman::DiffieHellman(Environment* env, Local wrap) : BaseObject(env, wrap), verifyError_(0) { MakeWeak(); } @@ -5426,7 +5422,7 @@ void ECDH::Initialize(Environment* env, Local target) { t->GetFunction(env->context()).ToLocalChecked()).Check(); } -ECDH::ECDH(Environment* env, v8::Local wrap, ECKeyPointer&& key) +ECDH::ECDH(Environment* env, Local wrap, ECKeyPointer&& key) : BaseObject(env, wrap), key_(std::move(key)), group_(EC_KEY_get0_group(key_.get())) { @@ -6513,6 +6509,36 @@ void ExportChallenge(const FunctionCallbackInfo& args) { } +void GetRootCertificates(const FunctionCallbackInfo& args) { + Environment* env = Environment::GetCurrent(args); + + if (root_cert_store == nullptr) + root_cert_store = NewRootCertStore(); + + stack_st_X509_OBJECT* objs = X509_STORE_get0_objects(root_cert_store); + int num_objs = sk_X509_OBJECT_num(objs); + + std::vector> result; + result.reserve(num_objs); + + for (int i = 0; i < num_objs; i++) { + X509_OBJECT* obj = sk_X509_OBJECT_value(objs, i); + if (X509_OBJECT_get_type(obj) == X509_LU_X509) { + X509* cert = X509_OBJECT_get0_X509(obj); + + Local value; + if (!X509ToPEM(env, cert).ToLocal(&value)) + return; + + result.push_back(value); + } + } + + args.GetReturnValue().Set( + Array::New(env->isolate(), result.data(), result.size())); +} + + // Convert the input public key to compressed, uncompressed, or hybrid formats. void ConvertKey(const FunctionCallbackInfo& args) { MarkPopErrorOnReturn mark_pop_error_on_return; diff --git a/src/node_env_var.cc b/src/node_env_var.cc index 69f7f5c862d1d7..d6440ba403cad4 100644 --- a/src/node_env_var.cc +++ b/src/node_env_var.cc @@ -29,8 +29,10 @@ using v8::Value; class RealEnvStore final : public KVStore { public: MaybeLocal Get(Isolate* isolate, Local key) const override; + Maybe Get(const char* key) const override; void Set(Isolate* isolate, Local key, Local value) override; int32_t Query(Isolate* isolate, Local key) const override; + int32_t Query(const char* key) const override; void Delete(Isolate* isolate, Local key) override; Local Enumerate(Isolate* isolate) const override; }; @@ -38,8 +40,10 @@ class RealEnvStore final : public KVStore { class MapKVStore final : public KVStore { public: MaybeLocal Get(Isolate* isolate, Local key) const override; + Maybe Get(const char* key) const override; void Set(Isolate* isolate, Local key, Local value) override; int32_t Query(Isolate* isolate, Local key) const override; + int32_t Query(const char* key) const override; void Delete(Isolate* isolate, Local key) override; Local Enumerate(Isolate* isolate) const override; @@ -58,26 +62,36 @@ Mutex env_var_mutex; std::shared_ptr system_environment = std::make_shared(); } // namespace per_process -MaybeLocal RealEnvStore::Get(Isolate* isolate, - Local property) const { +Maybe RealEnvStore::Get(const char* key) const { Mutex::ScopedLock lock(per_process::env_var_mutex); - node::Utf8Value key(isolate, property); size_t init_sz = 256; MaybeStackBuffer val; - int ret = uv_os_getenv(*key, *val, &init_sz); + int ret = uv_os_getenv(key, *val, &init_sz); if (ret == UV_ENOBUFS) { // Buffer is not large enough, reallocate to the updated init_sz // and fetch env value again. val.AllocateSufficientStorage(init_sz); - ret = uv_os_getenv(*key, *val, &init_sz); + ret = uv_os_getenv(key, *val, &init_sz); } if (ret >= 0) { // Env key value fetch success. - MaybeLocal value_string = - String::NewFromUtf8(isolate, *val, NewStringType::kNormal, init_sz); - return value_string; + return v8::Just(std::string(*val, init_sz)); + } + + return v8::Nothing(); +} + +MaybeLocal RealEnvStore::Get(Isolate* isolate, + Local property) const { + node::Utf8Value key(isolate, property); + Maybe value = Get(*key); + + if (value.IsJust()) { + std::string val = value.FromJust(); + return String::NewFromUtf8( + isolate, val.data(), NewStringType::kNormal, val.size()); } return MaybeLocal(); @@ -97,14 +111,12 @@ void RealEnvStore::Set(Isolate* isolate, uv_os_setenv(*key, *val); } -int32_t RealEnvStore::Query(Isolate* isolate, Local property) const { +int32_t RealEnvStore::Query(const char* key) const { Mutex::ScopedLock lock(per_process::env_var_mutex); - node::Utf8Value key(isolate, property); - char val[2]; size_t init_sz = sizeof(val); - int ret = uv_os_getenv(*key, val, &init_sz); + int ret = uv_os_getenv(key, val, &init_sz); if (ret == UV_ENOENT) { return -1; @@ -121,6 +133,11 @@ int32_t RealEnvStore::Query(Isolate* isolate, Local property) const { return 0; } +int32_t RealEnvStore::Query(Isolate* isolate, Local property) const { + node::Utf8Value key(isolate, property); + return Query(*key); +} + void RealEnvStore::Delete(Isolate* isolate, Local property) { Mutex::ScopedLock lock(per_process::env_var_mutex); @@ -174,13 +191,19 @@ std::shared_ptr KVStore::Clone(v8::Isolate* isolate) const { return copy; } -MaybeLocal MapKVStore::Get(Isolate* isolate, Local key) const { +Maybe MapKVStore::Get(const char* key) const { Mutex::ScopedLock lock(mutex_); + auto it = map_.find(key); + return it == map_.end() ? v8::Nothing() : v8::Just(it->second); +} + +MaybeLocal MapKVStore::Get(Isolate* isolate, Local key) const { Utf8Value str(isolate, key); - auto it = map_.find(std::string(*str, str.length())); - if (it == map_.end()) return Local(); - return String::NewFromUtf8(isolate, it->second.data(), - NewStringType::kNormal, it->second.size()); + Maybe value = Get(*str); + if (value.IsNothing()) return Local(); + std::string val = value.FromJust(); + return String::NewFromUtf8( + isolate, val.data(), NewStringType::kNormal, val.size()); } void MapKVStore::Set(Isolate* isolate, Local key, Local value) { @@ -193,11 +216,14 @@ void MapKVStore::Set(Isolate* isolate, Local key, Local value) { } } -int32_t MapKVStore::Query(Isolate* isolate, Local key) const { +int32_t MapKVStore::Query(const char* key) const { Mutex::ScopedLock lock(mutex_); + return map_.find(key) == map_.end() ? -1 : 0; +} + +int32_t MapKVStore::Query(Isolate* isolate, Local key) const { Utf8Value str(isolate, key); - auto it = map_.find(std::string(*str, str.length())); - return it == map_.end() ? -1 : 0; + return Query(*str); } void MapKVStore::Delete(Isolate* isolate, Local key) { @@ -243,7 +269,7 @@ Maybe KVStore::AssignFromObject(Local context, Local value; Local value_string; - if (!entries->Get(context, key.As()).ToLocal(&value) || + if (!entries->Get(context, key).ToLocal(&value) || !value->ToString(context).ToLocal(&value_string)) { return Nothing(); } diff --git a/src/node_file.cc b/src/node_file.cc index 71cb13c4f15048..bfdc73c9371ad1 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -32,7 +32,6 @@ #include "req_wrap-inl.h" #include "stream_base-inl.h" #include "string_bytes.h" -#include "string_search.h" #include #include @@ -370,7 +369,12 @@ int FileHandle::ReadStart() { if (freelist.size() > 0) { read_wrap = std::move(freelist.back()); freelist.pop_back(); - read_wrap->AsyncReset(); + // Use a fresh async resource. + // Lifetime is ensured via AsyncWrap::resource_. + Local resource = Object::New(env()->isolate()); + USE(resource->Set( + env()->context(), env()->handle_string(), read_wrap->object())); + read_wrap->AsyncReset(resource); read_wrap->file_handle_ = this; } else { Local wrap_obj; @@ -821,10 +825,8 @@ static void InternalModuleReadJSON(const FunctionCallbackInfo& args) { while (p < pe) { char c = *p++; - if (c == '"') goto quote; // Keeps code flat and inner loop small. if (c == '\\' && p < pe && *p == '"') p++; - continue; -quote: + if (c != '"') continue; *ppos++ = p; if (ppos < &pos[2]) continue; ppos = &pos[0]; diff --git a/src/node_messaging.cc b/src/node_messaging.cc index f55cb7ed9bd08c..c7c46063731a5b 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -28,7 +28,6 @@ using v8::Maybe; using v8::MaybeLocal; using v8::Nothing; using v8::Object; -using v8::ObjectTemplate; using v8::SharedArrayBuffer; using v8::String; using v8::Symbol; @@ -188,6 +187,20 @@ uint32_t Message::AddWASMModule(WasmModuleObject::TransferrableModule&& mod) { namespace { +MaybeLocal GetEmitMessageFunction(Local context) { + Isolate* isolate = context->GetIsolate(); + Local per_context_bindings; + Local emit_message_val; + if (!GetPerContextExports(context).ToLocal(&per_context_bindings) || + !per_context_bindings->Get(context, + FIXED_ONE_BYTE_STRING(isolate, "emitMessage")) + .ToLocal(&emit_message_val)) { + return MaybeLocal(); + } + CHECK(emit_message_val->IsFunction()); + return emit_message_val.As(); +} + MaybeLocal GetDOMException(Local context) { Isolate* isolate = context->GetIsolate(); Local per_context_bindings; @@ -498,10 +511,14 @@ MessagePort::MessagePort(Environment* env, MessagePort* channel = ContainerOf(&MessagePort::async_, handle); channel->OnMessage(); }; + CHECK_EQ(uv_async_init(env->event_loop(), &async_, onmessage), 0); - async_.data = static_cast(this); + async_.data = nullptr; // Reset later to indicate success of the constructor. + auto cleanup = OnScopeLeave([&]() { + if (async_.data == nullptr) Close(); + }); Local fn; if (!wrap->Get(context, env->oninit_symbol()).ToLocal(&fn)) @@ -509,9 +526,16 @@ MessagePort::MessagePort(Environment* env, if (fn->IsFunction()) { Local init = fn.As(); - USE(init->Call(context, wrap, 0, nullptr)); + if (init->Call(context, wrap, 0, nullptr).IsEmpty()) + return; } + Local emit_message_fn; + if (!GetEmitMessageFunction(context).ToLocal(&emit_message_fn)) + return; + emit_message_fn_.Reset(env->isolate(), emit_message_fn); + + async_.data = static_cast(this); Debug(this, "Created message port"); } @@ -559,6 +583,11 @@ MessagePort* MessagePort::New( return nullptr; MessagePort* port = new MessagePort(env, context, instance); CHECK_NOT_NULL(port); + if (port->IsHandleClosing()) { + // Construction failed with an exception. + return nullptr; + } + if (data) { port->Detach(); port->data_ = std::move(data); @@ -651,16 +680,8 @@ void MessagePort::OnMessage() { continue; } - Local event; - Local cb_args[1]; - if (!env()->message_event_object_template()->NewInstance(context) - .ToLocal(&event) || - event->Set(context, env()->data_string(), payload).IsNothing() || - event->Set(context, env()->target_string(), object()).IsNothing() || - (cb_args[0] = event, false) || - MakeCallback(env()->onmessage_string(), - arraysize(cb_args), - cb_args).IsEmpty()) { + Local emit_message = PersistentToLocal::Strong(emit_message_fn_); + if (MakeCallback(emit_message, 1, &payload).IsEmpty()) { // Re-schedule OnMessage() execution in case of failure. if (data_) TriggerAsync(); @@ -929,6 +950,7 @@ void MessagePort::Entangle(MessagePort* a, MessagePortData* b) { void MessagePort::MemoryInfo(MemoryTracker* tracker) const { tracker->TrackField("data", data_); + tracker->TrackField("emit_message_fn", emit_message_fn_); } Local GetMessagePortConstructorTemplate(Environment* env) { @@ -938,8 +960,6 @@ Local GetMessagePortConstructorTemplate(Environment* env) { if (!templ.IsEmpty()) return templ; - Isolate* isolate = env->isolate(); - { Local m = env->NewFunctionTemplate(MessagePort::New); m->SetClassName(env->message_port_constructor_string()); @@ -950,13 +970,6 @@ Local GetMessagePortConstructorTemplate(Environment* env) { env->SetProtoMethod(m, "start", MessagePort::Start); env->set_message_port_constructor_template(m); - - Local event_ctor = FunctionTemplate::New(isolate); - event_ctor->SetClassName(FIXED_ONE_BYTE_STRING(isolate, "MessageEvent")); - Local e = event_ctor->InstanceTemplate(); - e->Set(env->data_string(), Null(isolate)); - e->Set(env->target_string(), Null(isolate)); - env->set_message_event_object_template(e); } return GetMessagePortConstructorTemplate(env); @@ -975,7 +988,13 @@ static void MessageChannel(const FunctionCallbackInfo& args) { Context::Scope context_scope(context); MessagePort* port1 = MessagePort::New(env, context); + if (port1 == nullptr) return; MessagePort* port2 = MessagePort::New(env, context); + if (port2 == nullptr) { + port1->Close(); + return; + } + MessagePort::Entangle(port1, port2); args.This()->Set(context, env->port1_string(), port1->object()) diff --git a/src/node_messaging.h b/src/node_messaging.h index d64bf23e086d05..43f710a84e8315 100644 --- a/src/node_messaging.h +++ b/src/node_messaging.h @@ -132,12 +132,16 @@ class MessagePortData : public MemoryRetainer { // the uv_async_t handle that is used to notify the current event loop of // new incoming messages. class MessagePort : public HandleWrap { - public: + private: // Create a new MessagePort. The `context` argument specifies the Context // instance that is used for creating the values emitted from this port. + // This is called by MessagePort::New(), which is the public API used for + // creating MessagePort instances. MessagePort(Environment* env, v8::Local context, v8::Local wrap); + + public: ~MessagePort() override; // Create a new message port instance, optionally over an existing @@ -206,6 +210,7 @@ class MessagePort : public HandleWrap { std::unique_ptr data_ = nullptr; bool receiving_messages_ = false; uv_async_t async_; + v8::Global emit_message_fn_; friend class MessagePortData; }; diff --git a/src/node_options-inl.h b/src/node_options-inl.h index 885cb849744205..682a1c6c47d020 100644 --- a/src/node_options-inl.h +++ b/src/node_options-inl.h @@ -315,6 +315,10 @@ void OptionsParser::Parse( if (equals_index != std::string::npos) original_name += '='; + auto missing_argument = [&]() { + errors->push_back(RequiresArgumentErr(original_name)); + }; + // Normalize by replacing `_` with `-` in options. for (std::string::size_type i = 2; i < name.size(); ++i) { if (name[i] == '_') @@ -381,18 +385,20 @@ void OptionsParser::Parse( if (equals_index != std::string::npos) { value = arg.substr(equals_index + 1); if (value.empty()) { - missing_argument: - errors->push_back(RequiresArgumentErr(original_name)); + missing_argument(); break; } } else { - if (args.empty()) - goto missing_argument; + if (args.empty()) { + missing_argument(); + break; + } value = args.pop_first(); if (!value.empty() && value[0] == '-') { - goto missing_argument; + missing_argument(); + break; } else { if (!value.empty() && value[0] == '\\' && value[1] == '-') value = value.substr(1); // Treat \- as escaping an -. diff --git a/src/node_options.cc b/src/node_options.cc index 695935e2774a91..9985a6e405895b 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -495,7 +495,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { "the profile to the current working directory.", &EnvironmentOptions::heap_prof); AddOption("--heap-prof-name", - "specified file name of the V8 CPU profile generated with " + "specified file name of the V8 heap profile generated with " "--heap-prof", &EnvironmentOptions::heap_prof_name); AddOption("--heap-prof-dir", diff --git a/src/node_perf.cc b/src/node_perf.cc index 0536c39f6c7353..67eedf7b30032f 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -44,7 +44,7 @@ const uint64_t timeOrigin = PERFORMANCE_NOW(); const double timeOriginTimestamp = GetCurrentTimeInMicroseconds(); uint64_t performance_v8_start; -void performance_state::Mark(enum PerformanceMilestone milestone, +void PerformanceState::Mark(enum PerformanceMilestone milestone, uint64_t ts) { this->milestones[milestone] = ts; TRACE_EVENT_INSTANT_WITH_TIMESTAMP0( @@ -172,7 +172,6 @@ void Measure(const FunctionCallbackInfo& args) { HandleScope scope(env->isolate()); Utf8Value name(env->isolate(), args[0]); Utf8Value startMark(env->isolate(), args[1]); - Utf8Value endMark(env->isolate(), args[2]); AliasedFloat64Array& milestones = env->performance_state()->milestones; @@ -186,11 +185,17 @@ void Measure(const FunctionCallbackInfo& args) { startTimestamp = milestones[milestone]; } - uint64_t endTimestamp = GetPerformanceMark(env, *endMark); - if (endTimestamp == 0) { - PerformanceMilestone milestone = ToPerformanceMilestoneEnum(*endMark); - if (milestone != NODE_PERFORMANCE_MILESTONE_INVALID) - endTimestamp = milestones[milestone]; + uint64_t endTimestamp = 0; + if (args[2]->IsUndefined()) { + endTimestamp = PERFORMANCE_NOW(); + } else { + Utf8Value endMark(env->isolate(), args[2]); + endTimestamp = GetPerformanceMark(env, *endMark); + if (endTimestamp == 0) { + PerformanceMilestone milestone = ToPerformanceMilestoneEnum(*endMark); + if (milestone != NODE_PERFORMANCE_MILESTONE_INVALID) + endTimestamp = milestones[milestone]; + } } if (endTimestamp < startTimestamp) @@ -263,7 +268,7 @@ void MarkGarbageCollectionEnd(Isolate* isolate, GCCallbackFlags flags, void* data) { Environment* env = static_cast(data); - performance_state* state = env->performance_state(); + PerformanceState* state = env->performance_state(); // If no one is listening to gc performance entries, do not create them. if (!state->observers[NODE_PERFORMANCE_ENTRY_TYPE_GC]) return; @@ -548,7 +553,7 @@ void Initialize(Local target, void* priv) { Environment* env = Environment::GetCurrent(context); Isolate* isolate = env->isolate(); - performance_state* state = env->performance_state(); + PerformanceState* state = env->performance_state(); target->Set(context, FIXED_ONE_BYTE_STRING(isolate, "observerCounts"), diff --git a/src/node_perf.h b/src/node_perf.h index c5e45261c2c6fd..d7f593e5303542 100644 --- a/src/node_perf.h +++ b/src/node_perf.h @@ -139,7 +139,7 @@ class ELDHistogram : public HandleWrap, public Histogram { exceeds_ = 0; prev_ = 0; } - int64_t Exceeds() { return exceeds_; } + int64_t Exceeds() const { return exceeds_; } void MemoryInfo(MemoryTracker* tracker) const override { tracker->TrackFieldWithSize("histogram", GetMemorySize()); diff --git a/src/node_perf_common.h b/src/node_perf_common.h index 8e602a766367bd..75d266afc257e9 100644 --- a/src/node_perf_common.h +++ b/src/node_perf_common.h @@ -52,9 +52,9 @@ enum PerformanceEntryType { NODE_PERFORMANCE_ENTRY_TYPE_INVALID }; -class performance_state { +class PerformanceState { public: - explicit performance_state(v8::Isolate* isolate) : + explicit PerformanceState(v8::Isolate* isolate) : root( isolate, sizeof(performance_state_internal)), diff --git a/src/node_version.h b/src/node_version.h index f83260df2870e0..958519fbe4a832 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -29,7 +29,7 @@ #define NODE_VERSION_IS_LTS 1 #define NODE_VERSION_LTS_CODENAME "Erbium" -#define NODE_VERSION_IS_RELEASE 0 +#define NODE_VERSION_IS_RELEASE 1 #ifndef NODE_STRINGIFY #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n) diff --git a/src/node_wasi.cc b/src/node_wasi.cc index 2305a75d031659..ab4dd69b823300 100644 --- a/src/node_wasi.cc +++ b/src/node_wasi.cc @@ -169,6 +169,9 @@ void WASI::New(const FunctionCallbackInfo& args) { const uint32_t argc = argv->Length(); uvwasi_options_t options; + options.in = 0; + options.out = 1; + options.err = 2; options.fd_table_size = 3; options.argc = argc; options.argv = argc == 0 ? nullptr : new char*[argc]; diff --git a/src/node_worker.cc b/src/node_worker.cc index 83597c1616a6d4..d6028af1ead07e 100644 --- a/src/node_worker.cc +++ b/src/node_worker.cc @@ -30,6 +30,7 @@ using v8::Integer; using v8::Isolate; using v8::Local; using v8::Locker; +using v8::Maybe; using v8::MaybeLocal; using v8::Null; using v8::Number; @@ -504,14 +505,9 @@ void Worker::New(const FunctionCallbackInfo& args) { if (args[1]->IsObject() || args[2]->IsArray()) { per_isolate_opts.reset(new PerIsolateOptions()); - HandleEnvOptions( - per_isolate_opts->per_env, [isolate, &env_vars](const char* name) { - MaybeLocal value = - env_vars->Get(isolate, OneByteString(isolate, name)); - return value.IsEmpty() ? std::string{} - : std::string(*String::Utf8Value( - isolate, value.ToLocalChecked())); - }); + HandleEnvOptions(per_isolate_opts->per_env, [&env_vars](const char* name) { + return env_vars->Get(name).FromMaybe(""); + }); #ifndef NODE_WITHOUT_NODE_OPTIONS MaybeLocal maybe_node_opts = diff --git a/src/process_wrap.cc b/src/process_wrap.cc index a75f271d1c77b8..e294c6464f2a11 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -291,8 +291,7 @@ class ProcessWrap : public HandleWrap { static void OnExit(uv_process_t* handle, int64_t exit_status, int term_signal) { - ProcessWrap* wrap = static_cast(handle->data); - CHECK_NOT_NULL(wrap); + ProcessWrap* wrap = ContainerOf(&ProcessWrap::process_, handle); CHECK_EQ(&wrap->process_, handle); Environment* env = wrap->env(); diff --git a/src/spawn_sync.cc b/src/spawn_sync.cc index 589b77f6c1eb95..11126c478f76f7 100644 --- a/src/spawn_sync.cc +++ b/src/spawn_sync.cc @@ -607,8 +607,9 @@ void SyncProcessRunner::Kill() { if (r < 0 && r != UV_ESRCH) { SetError(r); - r = uv_process_kill(&uv_process_, SIGKILL); - CHECK(r >= 0 || r == UV_ESRCH); + // Deliberately ignore the return value, we might not have + // sufficient privileges to signal the child process. + USE(uv_process_kill(&uv_process_, SIGKILL)); } } @@ -1039,8 +1040,7 @@ Maybe SyncProcessRunner::CopyJsStringArray(Local js_value, js_array ->Set(context, i, - value->ToString(env()->isolate()->GetCurrentContext()) - .ToLocalChecked()) + string) .Check(); } diff --git a/src/stream_base.cc b/src/stream_base.cc index eaccfc995c745f..3f313aaeff3a44 100644 --- a/src/stream_base.cc +++ b/src/stream_base.cc @@ -508,13 +508,21 @@ uv_buf_t CustomBufferJSListener::OnStreamAlloc(size_t suggested_size) { void CustomBufferJSListener::OnStreamRead(ssize_t nread, const uv_buf_t& buf) { CHECK_NOT_NULL(stream_); - CHECK_EQ(buf.base, buffer_.base); StreamBase* stream = static_cast(stream_); Environment* env = stream->stream_env(); HandleScope handle_scope(env->isolate()); Context::Scope context_scope(env->context()); + // To deal with the case where POLLHUP is received and UV_EOF is returned, as + // libuv returns an empty buffer (on unices only). + if (nread == UV_EOF && buf.base == nullptr) { + stream->CallJSOnreadMethod(nread, Local()); + return; + } + + CHECK_EQ(buf.base, buffer_.base); + MaybeLocal ret = stream->CallJSOnreadMethod(nread, Local(), 0, diff --git a/src/string_search.h b/src/string_search.h index b339c355fe168d..3d06f32058f673 100644 --- a/src/string_search.h +++ b/src/string_search.h @@ -100,17 +100,29 @@ class StringSearch : private StringSearchBase { CHECK_GT(pattern_length, 0); if (pattern_length < kBMMinPatternLength) { if (pattern_length == 1) { - strategy_ = &StringSearch::SingleCharSearch; + strategy_ = SearchStrategy::kSingleChar; return; } - strategy_ = &StringSearch::LinearSearch; + strategy_ = SearchStrategy::kLinear; return; } - strategy_ = &StringSearch::InitialSearch; + strategy_ = SearchStrategy::kInitial; } size_t Search(Vector subject, size_t index) { - return (this->*strategy_)(subject, index); + switch (strategy_) { + case kBoyerMooreHorspool: + return BoyerMooreHorspoolSearch(subject, index); + case kBoyerMoore: + return BoyerMooreSearch(subject, index); + case kInitial: + return InitialSearch(subject, index); + case kLinear: + return LinearSearch(subject, index); + case kSingleChar: + return SingleCharSearch(subject, index); + } + UNREACHABLE(); } static inline int AlphabetSize() { @@ -149,10 +161,17 @@ class StringSearch : private StringSearchBase { return bad_char_occurrence[equiv_class]; } + enum SearchStrategy { + kBoyerMooreHorspool, + kBoyerMoore, + kInitial, + kLinear, + kSingleChar, + }; + // The pattern to search for. Vector pattern_; - // Pointer to implementation of the search. - SearchFunction strategy_; + SearchStrategy strategy_; // Cache value of Max(0, pattern_length() - kBMMaxShift) size_t start_; }; @@ -476,7 +495,7 @@ size_t StringSearch::BoyerMooreHorspoolSearch( badness += (pattern_length - j) - last_char_shift; if (badness > 0) { PopulateBoyerMooreTable(); - strategy_ = &StringSearch::BoyerMooreSearch; + strategy_ = SearchStrategy::kBoyerMoore; return BoyerMooreSearch(subject, index); } } @@ -548,7 +567,7 @@ size_t StringSearch::InitialSearch( badness += j; } else { PopulateBoyerMooreHorspoolTable(); - strategy_ = &StringSearch::BoyerMooreHorspoolSearch; + strategy_ = SearchStrategy::kBoyerMooreHorspool; return BoyerMooreHorspoolSearch(subject, i); } } diff --git a/src/timers.cc b/src/timers.cc index f35ae1cf649807..fab1b12018a921 100644 --- a/src/timers.cc +++ b/src/timers.cc @@ -7,11 +7,9 @@ namespace node { namespace { -using v8::Array; using v8::Context; using v8::Function; using v8::FunctionCallbackInfo; -using v8::Integer; using v8::Local; using v8::Object; using v8::Value; diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index 4a66ce0a1f1018..a1f70a58e4bb03 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -477,7 +477,8 @@ void UDPWrap::DoSend(const FunctionCallbackInfo& args, int family) { // construct uv_buf_t array for (size_t i = 0; i < count; i++) { - Local chunk = chunks->Get(env->context(), i).ToLocalChecked(); + Local chunk; + if (!chunks->Get(env->context(), i).ToLocal(&chunk)) return; size_t length = Buffer::Length(chunk); diff --git a/src/util.cc b/src/util.cc index 29bfb5d351e35b..c604c4c9555b60 100644 --- a/src/util.cc +++ b/src/util.cc @@ -63,7 +63,7 @@ using v8::Value; template static void MakeUtf8String(Isolate* isolate, Local value, - T* target) { + MaybeStackBuffer* target) { Local string; if (!value->ToString(isolate->GetCurrentContext()).ToLocal(&string)) return; diff --git a/test/abort/.gitignore b/test/abort/.gitignore new file mode 100644 index 00000000000000..bde1cf3ab9662b --- /dev/null +++ b/test/abort/.gitignore @@ -0,0 +1,7 @@ +.buildstamp +.docbuildstamp +Makefile +*.Makefile +*.mk +gyp-mac-tool +/*/build diff --git a/test/abort/common.gypi b/test/abort/common.gypi new file mode 100644 index 00000000000000..19396c61856af3 --- /dev/null +++ b/test/abort/common.gypi @@ -0,0 +1,8 @@ +{ + 'defines': [ 'V8_DEPRECATION_WARNINGS=1', 'NODE_WANT_INTERNALS=1' ], + 'conditions': [ + [ 'OS in "linux freebsd openbsd solaris android aix cloudabi"', { + 'cflags': ['-Wno-cast-function-type'], + }], + ], +} diff --git a/test/abort/test_abort-aliased-buffer-overflow/binding.cc b/test/abort/test_abort-aliased-buffer-overflow/binding.cc new file mode 100644 index 00000000000000..c3bf66061bf0ee --- /dev/null +++ b/test/abort/test_abort-aliased-buffer-overflow/binding.cc @@ -0,0 +1,23 @@ +#include +#include +#include + +#include +#include + +void AllocateAndResizeBuffer( + const v8::FunctionCallbackInfo& args) { + v8::Isolate* isolate = args.GetIsolate(); + int64_t length = args[0].As()->Int64Value(); + + node::AliasedBigUint64Array array{isolate, 0}; + + array.reserve(length); + assert(false); + } + +void init(v8::Local exports) { + NODE_SET_METHOD(exports, + "allocateAndResizeBuffer", + AllocateAndResizeBuffer); +} diff --git a/test/abort/test_abort-aliased-buffer-overflow/binding.gyp b/test/abort/test_abort-aliased-buffer-overflow/binding.gyp new file mode 100644 index 00000000000000..55fbe7050f18e4 --- /dev/null +++ b/test/abort/test_abort-aliased-buffer-overflow/binding.gyp @@ -0,0 +1,9 @@ +{ + 'targets': [ + { + 'target_name': 'binding', + 'sources': [ 'binding.cc' ], + 'includes': ['../common.gypi'], + } + ] +} diff --git a/test/abort/test_abort-aliased-buffer-overflow/test-abort-aliased-buffer-overflow.js b/test/abort/test_abort-aliased-buffer-overflow/test-abort-aliased-buffer-overflow.js new file mode 100644 index 00000000000000..33cd21295848b9 --- /dev/null +++ b/test/abort/test_abort-aliased-buffer-overflow/test-abort-aliased-buffer-overflow.js @@ -0,0 +1,28 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const cp = require('child_process'); + +// This test ensures that during resizing of an Aliased*Array the computation +// of the new size does not overflow. + +if (process.argv[2] === 'child') { + // test + const binding = require(`./build/${common.buildType}/binding`); + + const bigValue = BigInt('0xE000 0000 E000 0000'); + binding.AllocateAndResizeBuffer(bigValue); + assert.fail('this should be unreachable'); +} else { + // observer + const child = cp.spawn(`${process.execPath}`, [`${__filename}`, 'child']); + child.on('exit', common.mustCall(function(code, signal) { + if (common.isWindows) { + assert.strictEqual(code, 134); + assert.strictEqual(signal, null); + } else { + assert.strictEqual(code, null); + assert.strictEqual(signal, 'SIGABRT'); + } + })); +} diff --git a/test/addons/addon.status b/test/addons/addon.status index 081725af9fa465..951cddc48465d1 100644 --- a/test/addons/addon.status +++ b/test/addons/addon.status @@ -9,3 +9,7 @@ prefix addons [$arch==arm] # https://github.com/nodejs/node/issues/30786 openssl-binding/test: PASS,FLAKY + +[$system==ibmi] +openssl-binding/test: SKIP +zlib-binding/test: SKIP diff --git a/test/addons/openssl-binding/binding.gyp b/test/addons/openssl-binding/binding.gyp index 3a30a7e86922a4..06c5d15057f586 100644 --- a/test/addons/openssl-binding/binding.gyp +++ b/test/addons/openssl-binding/binding.gyp @@ -3,8 +3,13 @@ { 'target_name': 'binding', 'includes': ['../common.gypi'], + 'variables': { + # Skip this building on IBM i. + 'aix_variant_name': ' { + stream.respondWithFD(fd, { + [HTTP2_HEADER_CONTENT_TYPE]: 'text/plain' + }); +}); +server.on('close', common.mustCall(() => fs.closeSync(fd))); +server.listen(0, () => { + const client = http2.connect(`http://localhost:${server.address().port}`); + const req = client.request(); + + req.on('response', common.mustCall()); + req.on('data', () => {}); + req.on('end', common.mustCall(() => { + client.close(); + server.close(); + })); + req.end(); +}); + +process.on('exit', onExit); + +function onExit() { + hooks.disable(); + hooks.sanityCheck(); + const activities = hooks.activities; + + // Verify both invocations + const fsReqs = activities.filter((x) => x.type === 'FSREQCALLBACK'); + assert.ok(fsReqs.length >= 2); + + checkInvocations(fsReqs[0], { init: 1, destroy: 1 }, 'when process exits'); + checkInvocations(fsReqs[1], { init: 1, destroy: 1 }, 'when process exits'); + + // Verify reuse handle has been wrapped + assert.ok(fsReqs[0].handle !== fsReqs[1].handle, 'Resource reused'); + assert.ok(fsReqs[0].handle === fsReqs[1].handle.handle, + 'Resource not wrapped correctly'); +} diff --git a/test/async-hooks/test-graph.tls-write.js b/test/async-hooks/test-graph.tls-write.js index f8bee6a879d0b4..078dd27c36088c 100644 --- a/test/async-hooks/test-graph.tls-write.js +++ b/test/async-hooks/test-graph.tls-write.js @@ -65,9 +65,7 @@ function onexit() { { type: 'TCPCONNECTWRAP', id: 'tcpconnect:1', triggerAsyncId: 'tcp:1' }, { type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcpserver:1' }, - { type: 'TLSWRAP', id: 'tls:2', triggerAsyncId: 'tcpserver:1' }, - { type: 'Immediate', id: 'immediate:1', triggerAsyncId: 'tcp:2' }, - { type: 'Immediate', id: 'immediate:2', triggerAsyncId: 'tcp:1' }, + { type: 'TLSWRAP', id: 'tls:2', triggerAsyncId: 'tcpserver:1' } ] ); } diff --git a/test/async-hooks/test-statwatcher.js b/test/async-hooks/test-statwatcher.js index 0c1e245c4e21df..b8651ab8e0431e 100644 --- a/test/async-hooks/test-statwatcher.js +++ b/test/async-hooks/test-statwatcher.js @@ -64,8 +64,6 @@ w1.on('change', common.mustCallAtLeast((curr, prev) => { // Wait until we get the write above. if (prev.size !== 0 || curr.size !== 5) return; - // Remove listeners to make w1HookCount final - w1.removeAllListeners('change'); setImmediate(() => { checkInvocations(statwatcher1, @@ -81,8 +79,6 @@ w1.on('change', common.mustCallAtLeast((curr, prev) => { // Wait until we get the write above. if (prev.size !== 0 || curr.size !== 5) return; - // Remove listeners to make w2HookCount final - w2.removeAllListeners('change'); setImmediate(() => { checkInvocations(statwatcher1, diff --git a/test/cctest/test_util.cc b/test/cctest/test_util.cc index a38f549f0387dc..6cfd5d317f7982 100644 --- a/test/cctest/test_util.cc +++ b/test/cctest/test_util.cc @@ -268,6 +268,12 @@ TEST(UtilTest, SPrintF) { EXPECT_EQ(SPrintF("%u", -10000000000LL), "-10000000000"); EXPECT_EQ(SPrintF("%i", 10), "10"); EXPECT_EQ(SPrintF("%d", 10), "10"); + EXPECT_EQ(SPrintF("%x", 15), "f"); + EXPECT_EQ(SPrintF("%x", 16), "10"); + EXPECT_EQ(SPrintF("%X", 15), "F"); + EXPECT_EQ(SPrintF("%X", 16), "10"); + EXPECT_EQ(SPrintF("%o", 7), "7"); + EXPECT_EQ(SPrintF("%o", 8), "10"); EXPECT_EQ(atof(SPrintF("%s", 0.5).c_str()), 0.5); EXPECT_EQ(atof(SPrintF("%s", -0.5).c_str()), -0.5); diff --git a/test/common/inspector-helper.js b/test/common/inspector-helper.js index 42d6baed4410de..d430137746dd81 100644 --- a/test/common/inspector-helper.js +++ b/test/common/inspector-helper.js @@ -344,6 +344,9 @@ class NodeInstance extends EventEmitter { this._shutdownPromise = new Promise((resolve) => { this._process.once('exit', (exitCode, signal) => { + if (signal) { + console.error(`[err] child process crashed, signal ${signal}`); + } resolve({ exitCode, signal }); this._running = false; }); diff --git a/test/doctool/test-doctool-versions.js b/test/doctool/test-doctool-versions.js index a37ead7c0adb5b..5673cc79402df7 100644 --- a/test/doctool/test-doctool-versions.js +++ b/test/doctool/test-doctool-versions.js @@ -9,7 +9,7 @@ const tmpdir = require('../common/tmpdir'); const util = require('util'); const debuglog = util.debuglog('test'); -const versionsTool = path.join('../../tools/doc/versions.js'); +const versionsTool = path.resolve(__dirname, '../../tools/doc/versions.js'); // At the time of writing these are the minimum expected versions. // New versions of Node.js do not have to be explicitly added here. @@ -29,7 +29,7 @@ const expected = [ tmpdir.refresh(); const versionsFile = path.join(tmpdir.path, 'versions.json'); -debuglog(versionsFile); +debuglog(`${process.execPath} ${versionsTool} ${versionsFile}`); const opts = { cwd: tmpdir.path, encoding: 'utf8' }; const cp = spawnSync(process.execPath, [ versionsTool, versionsFile ], opts); debuglog(cp.stderr); diff --git a/test/es-module/test-esm-exports.mjs b/test/es-module/test-esm-exports.mjs index cc576e083a236d..8aaa66aae47d19 100644 --- a/test/es-module/test-esm-exports.mjs +++ b/test/es-module/test-esm-exports.mjs @@ -36,6 +36,14 @@ import fromInside from '../fixtures/node_modules/pkgexports/lib/hole.js'; ['pkgexports-sugar', { default: 'main' }], ]); + if (isRequire) { + validSpecifiers.set('pkgexports/subpath/file', { default: 'file' }); + validSpecifiers.set('pkgexports/subpath/dir1', { default: 'main' }); + validSpecifiers.set('pkgexports/subpath/dir1/', { default: 'main' }); + validSpecifiers.set('pkgexports/subpath/dir2', { default: 'index' }); + validSpecifiers.set('pkgexports/subpath/dir2/', { default: 'index' }); + } + for (const [validSpecifier, expected] of validSpecifiers) { if (validSpecifier === null) continue; @@ -119,14 +127,28 @@ import fromInside from '../fixtures/node_modules/pkgexports/lib/hole.js'; })); } - // Covering out bases - not a file is still not a file after dir mapping. - loadFixture('pkgexports/sub/not-a-file.js').catch(mustCall((err) => { - strictEqual(err.code, (isRequire ? '' : 'ERR_') + 'MODULE_NOT_FOUND'); - // ESM returns a full file path - assertStartsWith(err.message, isRequire ? - 'Cannot find module \'pkgexports/sub/not-a-file.js\'' : - 'Cannot find module'); - })); + const notFoundExports = new Map([ + // Non-existing file + ['pkgexports/sub/not-a-file.js', 'pkgexports/sub/not-a-file.js'], + // No extension lookups + ['pkgexports/no-ext', 'pkgexports/no-ext'], + ]); + + if (!isRequire) { + notFoundExports.set('pkgexports/subpath/file', 'pkgexports/subpath/file'); + notFoundExports.set('pkgexports/subpath/dir1', 'pkgexports/subpath/dir1'); + notFoundExports.set('pkgexports/subpath/dir2', 'pkgexports/subpath/dir2'); + } + + for (const [specifier, request] of notFoundExports) { + loadFixture(specifier).catch(mustCall((err) => { + strictEqual(err.code, (isRequire ? '' : 'ERR_') + 'MODULE_NOT_FOUND'); + // ESM returns a full file path + assertStartsWith(err.message, isRequire ? + `Cannot find module '${request}'` : + 'Cannot find module'); + })); + } // The use of %2F escapes in paths fails loading loadFixture('pkgexports/sub/..%2F..%2Fbar.js').catch(mustCall((err) => { diff --git a/test/es-module/test-esm-nowarn-exports.mjs b/test/es-module/test-esm-nowarn-exports.mjs new file mode 100644 index 00000000000000..0c5ae17e764797 --- /dev/null +++ b/test/es-module/test-esm-nowarn-exports.mjs @@ -0,0 +1,27 @@ +// Flags: --experimental-modules +import '../common/index.mjs'; +import { path } from '../common/fixtures.mjs'; +import { strictEqual, ok } from 'assert'; +import { spawn } from 'child_process'; + +const child = spawn(process.execPath, [ + '--experimental-modules', + '--experimental-import-meta-resolve', + path('/es-modules/import-resolve-exports.mjs') +]); + +let stderr = ''; +child.stderr.setEncoding('utf8'); +child.stderr.on('data', (data) => { + stderr += data; +}); +child.on('close', (code, signal) => { + strictEqual(code, 0); + strictEqual(signal, null); + ok(stderr.toString().includes( + 'ExperimentalWarning: The ESM module loader is experimental' + )); + ok(!stderr.toString().includes( + 'ExperimentalWarning: Conditional exports' + )); +}); diff --git a/test/fixtures/es-modules/import-resolve-exports.mjs b/test/fixtures/es-modules/import-resolve-exports.mjs new file mode 100644 index 00000000000000..0bbce4fbc5efc0 --- /dev/null +++ b/test/fixtures/es-modules/import-resolve-exports.mjs @@ -0,0 +1,10 @@ +import { strictEqual } from 'assert'; + +(async () => { + const resolved = await import.meta.resolve('pkgexports-sugar'); + strictEqual(typeof resolved, 'string'); +})() +.catch((e) => { + console.error(e); + process.exit(1); +}); diff --git a/test/fixtures/inspector-global-function.js b/test/fixtures/inspector-global-function.js index 6155ae5298cdef..b89808b88079bb 100644 --- a/test/fixtures/inspector-global-function.js +++ b/test/fixtures/inspector-global-function.js @@ -10,4 +10,8 @@ global.sum = function() { console.log(invocations++, c); }; +// NOTE(mmarchini): Calls console.log two times to ensure we loaded every +// internal module before pausing. See +// https://bugs.chromium.org/p/v8/issues/detail?id=10287. +console.log('Loading'); console.log('Ready!'); diff --git a/test/fixtures/node_modules/pkgexports/package.json b/test/fixtures/node_modules/pkgexports/package.json index 7f417ad5457bfc..200c028f88c9d3 100644 --- a/test/fixtures/node_modules/pkgexports/package.json +++ b/test/fixtures/node_modules/pkgexports/package.json @@ -32,6 +32,7 @@ "nomatch": "./nothing.js" } }], + "./no-ext": "./asdf", "./resolve-self": { "require": "./resolve-self.js", "import": "./resolve-self.mjs" @@ -39,6 +40,7 @@ "./resolve-self-invalid": { "require": "./resolve-self-invalid.js", "import": "./resolve-self-invalid.mjs" - } + }, + "./subpath/": "./subpath/" } } diff --git a/test/fixtures/node_modules/pkgexports/subpath/dir1/dir1.js b/test/fixtures/node_modules/pkgexports/subpath/dir1/dir1.js new file mode 100644 index 00000000000000..dfdd47b877319c --- /dev/null +++ b/test/fixtures/node_modules/pkgexports/subpath/dir1/dir1.js @@ -0,0 +1 @@ +module.exports = 'main'; diff --git a/test/fixtures/node_modules/pkgexports/subpath/dir1/package.json b/test/fixtures/node_modules/pkgexports/subpath/dir1/package.json new file mode 100644 index 00000000000000..ca1584ec6fe659 --- /dev/null +++ b/test/fixtures/node_modules/pkgexports/subpath/dir1/package.json @@ -0,0 +1,3 @@ +{ + "main": "dir1" +} diff --git a/test/fixtures/node_modules/pkgexports/subpath/dir2/index.js b/test/fixtures/node_modules/pkgexports/subpath/dir2/index.js new file mode 100644 index 00000000000000..d17bd0f1e9ba0f --- /dev/null +++ b/test/fixtures/node_modules/pkgexports/subpath/dir2/index.js @@ -0,0 +1 @@ +module.exports = 'index'; diff --git a/test/fixtures/node_modules/pkgexports/subpath/file.js b/test/fixtures/node_modules/pkgexports/subpath/file.js new file mode 100644 index 00000000000000..1485f701f49e67 --- /dev/null +++ b/test/fixtures/node_modules/pkgexports/subpath/file.js @@ -0,0 +1,2 @@ +module.exports = 'file'; + diff --git a/test/known_issues/known_issues.status b/test/known_issues/known_issues.status index 8dd569a3950bf6..9ca45bbd85420a 100644 --- a/test/known_issues/known_issues.status +++ b/test/known_issues/known_issues.status @@ -27,3 +27,6 @@ test-vm-timeout-escape-promise: PASS,FLAKY [$system==aix] [$arch==arm] +# The Raspberry Pis are too slow to run this test. +# See https://github.com/nodejs/build/issues/2227#issuecomment-608334574 +test-crypto-authenticated-stream: SKIP diff --git a/test/known_issues/test-crypto-authenticated-stream.js b/test/known_issues/test-crypto-authenticated-stream.js new file mode 100644 index 00000000000000..1e2a9edd7b0a6e --- /dev/null +++ b/test/known_issues/test-crypto-authenticated-stream.js @@ -0,0 +1,142 @@ +/* eslint-disable node-core/crypto-check */ +'use strict'; +// Refs: https://github.com/nodejs/node/issues/31733 +const common = require('../common'); +const assert = require('assert'); +const crypto = require('crypto'); +const fs = require('fs'); +const path = require('path'); +const stream = require('stream'); +const tmpdir = require('../common/tmpdir'); + +class Sink extends stream.Writable { + constructor() { + super(); + this.chunks = []; + } + + _write(chunk, encoding, cb) { + this.chunks.push(chunk); + cb(); + } +} + +function direct(config) { + const { cipher, key, iv, aad, authTagLength, plaintextLength } = config; + const expected = Buffer.alloc(plaintextLength); + + const c = crypto.createCipheriv(cipher, key, iv, { authTagLength }); + c.setAAD(aad, { plaintextLength }); + const ciphertext = Buffer.concat([c.update(expected), c.final()]); + + const d = crypto.createDecipheriv(cipher, key, iv, { authTagLength }); + d.setAAD(aad, { plaintextLength }); + d.setAuthTag(c.getAuthTag()); + const actual = Buffer.concat([d.update(ciphertext), d.final()]); + + assert.deepStrictEqual(expected, actual); +} + +function mstream(config) { + const { cipher, key, iv, aad, authTagLength, plaintextLength } = config; + const expected = Buffer.alloc(plaintextLength); + + const c = crypto.createCipheriv(cipher, key, iv, { authTagLength }); + c.setAAD(aad, { plaintextLength }); + + const plain = new stream.PassThrough(); + const crypt = new Sink(); + const chunks = crypt.chunks; + plain.pipe(c).pipe(crypt); + plain.end(expected); + + crypt.on('close', common.mustCall(() => { + const d = crypto.createDecipheriv(cipher, key, iv, { authTagLength }); + d.setAAD(aad, { plaintextLength }); + d.setAuthTag(c.getAuthTag()); + + const crypt = new stream.PassThrough(); + const plain = new Sink(); + crypt.pipe(d).pipe(plain); + for (const chunk of chunks) crypt.write(chunk); + crypt.end(); + + plain.on('close', common.mustCall(() => { + const actual = Buffer.concat(plain.chunks); + assert.deepStrictEqual(expected, actual); + })); + })); +} + +function fstream(config) { + const count = fstream.count++; + const filename = (name) => path.join(tmpdir.path, `${name}${count}`); + + const { cipher, key, iv, aad, authTagLength, plaintextLength } = config; + const expected = Buffer.alloc(plaintextLength); + fs.writeFileSync(filename('a'), expected); + + const c = crypto.createCipheriv(cipher, key, iv, { authTagLength }); + c.setAAD(aad, { plaintextLength }); + + const plain = fs.createReadStream(filename('a')); + const crypt = fs.createWriteStream(filename('b')); + plain.pipe(c).pipe(crypt); + + // Observation: 'close' comes before 'end' on |c|, which definitely feels + // wrong. Switching to `c.on('end', ...)` doesn't fix the test though. + crypt.on('close', common.mustCall(() => { + // Just to drive home the point that decryption does actually work: + // reading the file synchronously, then decrypting it, works. + { + const ciphertext = fs.readFileSync(filename('b')); + const d = crypto.createDecipheriv(cipher, key, iv, { authTagLength }); + d.setAAD(aad, { plaintextLength }); + d.setAuthTag(c.getAuthTag()); + const actual = Buffer.concat([d.update(ciphertext), d.final()]); + assert.deepStrictEqual(expected, actual); + } + + const d = crypto.createDecipheriv(cipher, key, iv, { authTagLength }); + d.setAAD(aad, { plaintextLength }); + d.setAuthTag(c.getAuthTag()); + + const crypt = fs.createReadStream(filename('b')); + const plain = fs.createWriteStream(filename('c')); + crypt.pipe(d).pipe(plain); + + plain.on('close', common.mustCall(() => { + const actual = fs.readFileSync(filename('c')); + assert.deepStrictEqual(expected, actual); + })); + })); +} +fstream.count = 0; + +function test(config) { + direct(config); + mstream(config); + fstream(config); +} + +tmpdir.refresh(); + +// OK +test({ + cipher: 'aes-128-ccm', + aad: Buffer.alloc(1), + iv: Buffer.alloc(8), + key: Buffer.alloc(16), + authTagLength: 16, + plaintextLength: 32768, +}); + +// Fails the fstream test. +test({ + cipher: 'aes-128-ccm', + aad: Buffer.alloc(1), + iv: Buffer.alloc(8), + key: Buffer.alloc(16), + authTagLength: 16, + plaintextLength: 32769, +}); diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index f282844cd0aa64..0d11851bbd82e8 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -29,13 +29,6 @@ test-worker-message-port-transfer-terminate: PASS,FLAKY [$system==linux] [$system==macos] -# https://github.com/nodejs/node/issues/30030 -test-dgram-connect-send-empty-buffer: PASS,FLAKY -test-dgram-connect-send-empty-array: PASS,FLAKY -test-dgram-connect-send-empty-packet: PASS,FLAKY -test-dgram-send-empty-array: PASS,FLAKY -test-dgram-send-empty-buffer: PASS,FLAKY -test-dgram-send-empty-packet: PASS,FLAKY [$arch==arm || $arch==arm64] # https://github.com/nodejs/node/issues/26610 diff --git a/test/parallel/test-async-hooks-enable-recursive.js b/test/parallel/test-async-hooks-enable-recursive.js index bcb0dcc0ce0a66..74caebbad225ba 100644 --- a/test/parallel/test-async-hooks-enable-recursive.js +++ b/test/parallel/test-async-hooks-enable-recursive.js @@ -9,7 +9,7 @@ const nestedHook = async_hooks.createHook({ }); async_hooks.createHook({ - init: common.mustCall((id, type) => { + init: common.mustCall(() => { nestedHook.enable(); }, 2) }).enable(); diff --git a/test/parallel/test-async-hooks-http-parser-destroy.js b/test/parallel/test-async-hooks-http-parser-destroy.js index 22b5a0ff11b889..6cbc2043b09583 100644 --- a/test/parallel/test-async-hooks-http-parser-destroy.js +++ b/test/parallel/test-async-hooks-http-parser-destroy.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const async_hooks = require('async_hooks'); const http = require('http'); @@ -45,6 +45,9 @@ async_hooks.createHook({ }).enable(); const server = http.createServer((req, res) => { + req.on('close', common.mustCall(() => { + req.on('readable', common.mustNotCall()); + })); res.end('Hello'); }); diff --git a/test/parallel/test-async-hooks-recursive-stack.js b/test/parallel/test-async-hooks-recursive-stack.js deleted file mode 100644 index bc4ac86e7f1ca1..00000000000000 --- a/test/parallel/test-async-hooks-recursive-stack.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; -require('../common'); -const assert = require('assert'); -const async_hooks = require('async_hooks'); - -// This test verifies that the async ID stack can grow indefinitely. - -function recurse(n) { - const a = new async_hooks.AsyncResource('foobar'); - a.runInAsyncScope(() => { - assert.strictEqual(a.asyncId(), async_hooks.executionAsyncId()); - assert.strictEqual(a.triggerAsyncId(), async_hooks.triggerAsyncId()); - if (n >= 0) - recurse(n - 1); - assert.strictEqual(a.asyncId(), async_hooks.executionAsyncId()); - assert.strictEqual(a.triggerAsyncId(), async_hooks.triggerAsyncId()); - }); -} - -recurse(1000); diff --git a/test/parallel/test-buffer-bigint64.js b/test/parallel/test-buffer-bigint64.js index 60d376bdaf84af..a160d35b4a551a 100644 --- a/test/parallel/test-buffer-bigint64.js +++ b/test/parallel/test-buffer-bigint64.js @@ -7,49 +7,49 @@ const buf = Buffer.allocUnsafe(8); ['LE', 'BE'].forEach(function(endianness) { // Should allow simple BigInts to be written and read let val = 123456789n; - buf['writeBigInt64' + endianness](val, 0); - let rtn = buf['readBigInt64' + endianness](0); + buf[`writeBigInt64${endianness}`](val, 0); + let rtn = buf[`readBigInt64${endianness}`](0); assert.strictEqual(val, rtn); // Should allow INT64_MAX to be written and read val = 0x7fffffffffffffffn; - buf['writeBigInt64' + endianness](val, 0); - rtn = buf['readBigInt64' + endianness](0); + buf[`writeBigInt64${endianness}`](val, 0); + rtn = buf[`readBigInt64${endianness}`](0); assert.strictEqual(val, rtn); // Should read and write a negative signed 64-bit integer val = -123456789n; - buf['writeBigInt64' + endianness](val, 0); - assert.strictEqual(val, buf['readBigInt64' + endianness](0)); + buf[`writeBigInt64${endianness}`](val, 0); + assert.strictEqual(val, buf[`readBigInt64${endianness}`](0)); // Should read and write an unsigned 64-bit integer val = 123456789n; - buf['writeBigUInt64' + endianness](val, 0); - assert.strictEqual(val, buf['readBigUInt64' + endianness](0)); + buf[`writeBigUInt64${endianness}`](val, 0); + assert.strictEqual(val, buf[`readBigUInt64${endianness}`](0)); // Should throw a RangeError upon INT64_MAX+1 being written assert.throws(function() { const val = 0x8000000000000000n; - buf['writeBigInt64' + endianness](val, 0); + buf[`writeBigInt64${endianness}`](val, 0); }, RangeError); // Should throw a RangeError upon UINT64_MAX+1 being written assert.throws(function() { const val = 0x10000000000000000n; - buf['writeBigUInt64' + endianness](val, 0); + buf[`writeBigUInt64${endianness}`](val, 0); }, { code: 'ERR_OUT_OF_RANGE', message: 'The value of "value" is out of range. It must be ' + - '>= 0n and < 2n ** 64n. Received 18_446_744_073_709_551_616n' + '>= 0n and < 2n ** 64n. Received 18_446_744_073_709_551_616n' }); // Should throw a TypeError upon invalid input assert.throws(function() { - buf['writeBigInt64' + endianness]('bad', 0); + buf[`writeBigInt64${endianness}`]('bad', 0); }, TypeError); // Should throw a TypeError upon invalid input assert.throws(function() { - buf['writeBigUInt64' + endianness]('bad', 0); + buf[`writeBigUInt64${endianness}`]('bad', 0); }, TypeError); }); diff --git a/test/parallel/test-buffer-write.js b/test/parallel/test-buffer-write.js index 1f080add08451f..842b12c04c04db 100644 --- a/test/parallel/test-buffer-write.js +++ b/test/parallel/test-buffer-write.js @@ -90,6 +90,9 @@ for (let i = 1; i < 4; i++) { const z = Buffer.alloc(4, 0); assert.strictEqual(z.write('\u0001', 3, 'ucs2'), 0); assert.strictEqual(Buffer.compare(z, Buffer.alloc(4, 0)), 0); +// Make sure longer strings are written up to the buffer end. +assert.strictEqual(z.write('abcd', 2), 2); +assert.deepStrictEqual([...z], [0, 0, 0x61, 0x62]); // Large overrun could corrupt the process assert.strictEqual(Buffer.alloc(4) diff --git a/test/parallel/test-child-process-pipe-dataflow.js b/test/parallel/test-child-process-pipe-dataflow.js index bc5e4e02fdf4e9..5f425a6f3d087c 100644 --- a/test/parallel/test-child-process-pipe-dataflow.js +++ b/test/parallel/test-child-process-pipe-dataflow.js @@ -3,6 +3,7 @@ const common = require('../common'); const assert = require('assert'); const path = require('path'); const fs = require('fs'); +const os = require('os'); const spawn = require('child_process').spawn; const tmpdir = require('../common/tmpdir'); @@ -25,8 +26,8 @@ const MB = KB * KB; // meanings to new line - for example, line buffering. // So cut the buffer into lines at some points, forcing // data flow to be split in the stream. - for (let i = 0; i < KB; i++) - buf[i * KB] = 10; + for (let i = 1; i < KB; i++) + buf.write(os.EOL, i * KB); fs.writeFileSync(file, buf.toString()); cat = spawn('cat', [file]); @@ -61,6 +62,7 @@ const MB = KB * KB; }); wc.stdout.on('data', common.mustCall((data) => { - assert.strictEqual(data.toString().trim(), MB.toString()); + // Grep always adds one extra byte at the end. + assert.strictEqual(data.toString().trim(), (MB + 1).toString()); })); } diff --git a/test/parallel/test-cli-node-options-disallowed.js b/test/parallel/test-cli-node-options-disallowed.js index 70341fd97b93ce..2e66b1b0d7af5d 100644 --- a/test/parallel/test-cli-node-options-disallowed.js +++ b/test/parallel/test-cli-node-options-disallowed.js @@ -25,6 +25,8 @@ disallow('-c'); disallow('--interactive'); disallow('-i'); disallow('--v8-options'); +disallow('--expose_internals'); +disallow('--expose-internals'); disallow('--'); function disallow(opt) { diff --git a/test/parallel/test-cluster-net-listen-ipv6only-false.js b/test/parallel/test-cluster-net-listen-ipv6only-false.js index 4d495d8faf6ddc..f48e9f1c29dc4a 100644 --- a/test/parallel/test-cluster-net-listen-ipv6only-false.js +++ b/test/parallel/test-cluster-net-listen-ipv6only-false.js @@ -7,7 +7,6 @@ if (!common.hasIPv6) const assert = require('assert'); const cluster = require('cluster'); const net = require('net'); -const Countdown = require('../common/countdown'); // This test ensures that dual-stack support still works for cluster module // when `ipv6Only` is not `true`. @@ -15,38 +14,40 @@ const host = '::'; const WORKER_COUNT = 3; if (cluster.isMaster) { - const workers = new Map(); + const workers = []; let address; - const countdown = new Countdown(WORKER_COUNT, () => { + for (let i = 0; i < WORKER_COUNT; i += 1) { + const myWorker = new Promise((resolve) => { + const worker = cluster.fork().on('exit', common.mustCall((statusCode) => { + assert.strictEqual(statusCode, 0); + })).on('listening', common.mustCall((workerAddress) => { + if (!address) { + address = workerAddress; + } else { + assert.strictEqual(address.addressType, workerAddress.addressType); + assert.strictEqual(address.host, workerAddress.host); + assert.strictEqual(address.port, workerAddress.port); + } + resolve(worker); + })); + }); + + workers.push(myWorker); + } + + Promise.all(workers).then(common.mustCall((resolvedWorkers) => { const socket = net.connect({ port: address.port, host: '0.0.0.0', }, common.mustCall(() => { socket.destroy(); - workers.forEach((worker) => { - worker.disconnect(); + resolvedWorkers.forEach((resolvedWorker) => { + resolvedWorker.disconnect(); }); })); socket.on('error', common.mustNotCall()); - }); - - for (let i = 0; i < WORKER_COUNT; i += 1) { - const worker = cluster.fork().on('exit', common.mustCall((statusCode) => { - assert.strictEqual(statusCode, 0); - })).on('listening', common.mustCall((workerAddress) => { - if (!address) { - address = workerAddress; - } else { - assert.strictEqual(address.addressType, workerAddress.addressType); - assert.strictEqual(address.host, workerAddress.host); - assert.strictEqual(address.port, workerAddress.port); - } - countdown.dec(); - })); - - workers.set(i, worker); - } + })); } else { net.createServer().listen({ host, diff --git a/test/parallel/test-cluster-setup-master-multiple.js b/test/parallel/test-cluster-setup-master-multiple.js index 33d490df45f57a..11434edb90048a 100644 --- a/test/parallel/test-cluster-setup-master-multiple.js +++ b/test/parallel/test-cluster-setup-master-multiple.js @@ -23,6 +23,7 @@ require('../common'); const assert = require('assert'); const cluster = require('cluster'); +const debug = require('util').debuglog('test'); assert(cluster.isMaster); @@ -36,7 +37,7 @@ const configs = []; // Capture changes cluster.on('setup', () => { - console.log('"setup" emitted', cluster.settings); + debug(`"setup" emitted ${JSON.stringify(cluster.settings)}`); configs.push(cheapClone(cluster.settings)); }); @@ -65,5 +66,5 @@ execs.forEach((v, i) => { // Cluster emits 'setup' asynchronously, so we must stay alive long // enough for that to happen setTimeout(() => { - console.log('cluster setup complete'); + debug('cluster setup complete'); }, (execs.length + 1) * 100); diff --git a/test/parallel/test-console-instance.js b/test/parallel/test-console-instance.js index 19c4271d243ea7..bf22314e22e031 100644 --- a/test/parallel/test-console-instance.js +++ b/test/parallel/test-console-instance.js @@ -140,7 +140,7 @@ out.write = err.write = (d) => {}; }); }, { - message: 'The "inspectOptions" argument must be of type object.' + + message: 'The "options.inspectOptions" property must be of type object.' + common.invalidArgTypeHelper(inspectOptions), code: 'ERR_INVALID_ARG_TYPE' } diff --git a/test/parallel/test-console-tty-colors.js b/test/parallel/test-console-tty-colors.js index 41e72c3c8513bc..e906c71c186177 100644 --- a/test/parallel/test-console-tty-colors.js +++ b/test/parallel/test-console-tty-colors.js @@ -86,7 +86,7 @@ check(false, false, false); }); }, { - message: 'Option "inspectOptions.color" cannot be used in ' + + message: 'Option "options.inspectOptions.color" cannot be used in ' + 'combination with option "colorMode"', code: 'ERR_INCOMPATIBLE_OPTION_PAIR' } diff --git a/test/parallel/test-crypto-private-decrypt-gh32240.js b/test/parallel/test-crypto-private-decrypt-gh32240.js new file mode 100644 index 00000000000000..4b48774145a3f8 --- /dev/null +++ b/test/parallel/test-crypto-private-decrypt-gh32240.js @@ -0,0 +1,38 @@ +'use strict'; + +// Verify that privateDecrypt() does not leave an error on the +// openssl error stack that is visible to subsequent operations. + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); + +const assert = require('assert'); +const { + generateKeyPairSync, + publicEncrypt, + privateDecrypt, +} = require('crypto'); + +const pair = generateKeyPairSync('rsa', { modulusLength: 512 }); + +const expected = Buffer.from('shibboleth'); +const encrypted = publicEncrypt(pair.publicKey, expected); + +const pkey = pair.privateKey.export({ type: 'pkcs1', format: 'pem' }); +const pkeyEncrypted = + pair.privateKey.export({ + type: 'pkcs1', + format: 'pem', + cipher: 'aes128', + passphrase: 'secret', + }); + +function decrypt(key) { + const decrypted = privateDecrypt(key, encrypted); + assert.deepStrictEqual(decrypted, expected); +} + +decrypt(pkey); +assert.throws(() => decrypt(pkeyEncrypted), { code: 'ERR_MISSING_PASSPHRASE' }); +decrypt(pkey); // Should not throw. diff --git a/test/parallel/test-fs-existssync-false.js b/test/parallel/test-fs-existssync-false.js index 096be6de38df9b..3808750d7f304a 100644 --- a/test/parallel/test-fs-existssync-false.js +++ b/test/parallel/test-fs-existssync-false.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +const common = require('../common'); const tmpdir = require('../common/tmpdir'); // This test ensures that fs.existsSync doesn't incorrectly return false. @@ -31,6 +31,6 @@ for (let i = 0; i < 50; i++) { assert(fs.existsSync(dir), 'Directory is not accessible'); // Test if file exists asynchronously -fs.access(dir, function(err) { +fs.access(dir, common.mustCall((err) => { assert.ifError(err); -}); +})); diff --git a/test/parallel/test-fs-mkdir.js b/test/parallel/test-fs-mkdir.js index c911587753a091..417f5c7e06b8b5 100644 --- a/test/parallel/test-fs-mkdir.js +++ b/test/parallel/test-fs-mkdir.js @@ -229,7 +229,7 @@ if (common.isMainThread && (common.isLinux || common.isOSX)) { { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError', - message: 'The "recursive" argument must be of type boolean.' + + message: 'The "options.recursive" property must be of type boolean.' + received } ); @@ -238,7 +238,7 @@ if (common.isMainThread && (common.isLinux || common.isOSX)) { { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError', - message: 'The "recursive" argument must be of type boolean.' + + message: 'The "options.recursive" property must be of type boolean.' + received } ); diff --git a/test/parallel/test-fs-utimes.js b/test/parallel/test-fs-utimes.js index fa2ddcbeeda2b7..c5ed73733c5c40 100644 --- a/test/parallel/test-fs-utimes.js +++ b/test/parallel/test-fs-utimes.js @@ -150,7 +150,7 @@ if (!process.arch.includes('arm') && const Y2K38_mtime = 2 ** 31; fs.utimesSync(path, Y2K38_mtime, Y2K38_mtime); const Y2K38_stats = fs.statSync(path); - assert.strictEqual(Y2K38_mtime, Y2K38_stats.mtime.getTime() / 1000); + assert.strictEqual(Y2K38_stats.mtime.getTime() / 1000, Y2K38_mtime); } if (common.isWindows) { @@ -158,7 +158,7 @@ if (common.isWindows) { const truncate_mtime = 1713037251360; fs.utimesSync(path, truncate_mtime / 1000, truncate_mtime / 1000); const truncate_stats = fs.statSync(path); - assert.strictEqual(truncate_mtime, truncate_stats.mtime.getTime()); + assert.strictEqual(truncate_stats.mtime.getTime(), truncate_mtime); // test Y2K38 for windows // This value if treaded as a `signed long` gets converted to -2135622133469. @@ -168,7 +168,7 @@ if (common.isWindows) { const overflow_mtime = 2159345162531; fs.utimesSync(path, overflow_mtime / 1000, overflow_mtime / 1000); const overflow_stats = fs.statSync(path); - assert.strictEqual(overflow_mtime, overflow_stats.mtime.getTime()); + assert.strictEqual(overflow_stats.mtime.getTime(), overflow_mtime); } const expectTypeError = { diff --git a/test/parallel/test-http-agent-timeout-option.js b/test/parallel/test-http-agent-timeout-option.js index d0c05827f23d56..60a86779838520 100644 --- a/test/parallel/test-http-agent-timeout-option.js +++ b/test/parallel/test-http-agent-timeout-option.js @@ -18,6 +18,6 @@ request.on('socket', mustCall((socket) => { const listeners = socket.listeners('timeout'); - strictEqual(listeners.length, 1); - strictEqual(listeners[0], request.timeoutCb); + strictEqual(listeners.length, 2); + strictEqual(listeners[1], request.timeoutCb); })); diff --git a/test/parallel/test-http-agent-timeout.js b/test/parallel/test-http-agent-timeout.js new file mode 100644 index 00000000000000..d8d34414d991a1 --- /dev/null +++ b/test/parallel/test-http-agent-timeout.js @@ -0,0 +1,94 @@ +'use strict'; + +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); + +{ + // Ensure reuse of successful sockets. + + const agent = new http.Agent({ keepAlive: true }); + + const server = http.createServer((req, res) => { + res.end(); + }); + + server.listen(0, common.mustCall(() => { + let socket; + http.get({ port: server.address().port, agent }) + .on('response', common.mustCall((res) => { + socket = res.socket; + assert(socket); + res.resume(); + socket.on('free', common.mustCall(() => { + http.get({ port: server.address().port, agent }) + .on('response', common.mustCall((res) => { + assert.strictEqual(socket, res.socket); + assert(socket); + agent.destroy(); + server.close(); + })); + })); + })); + })); +} + +{ + // Ensure that timeouted sockets are not reused. + + const agent = new http.Agent({ keepAlive: true, timeout: 50 }); + + const server = http.createServer((req, res) => { + res.end(); + }); + + server.listen(0, common.mustCall(() => { + http.get({ port: server.address().port, agent }) + .on('response', common.mustCall((res) => { + const socket = res.socket; + assert(socket); + res.resume(); + socket.on('free', common.mustCall(() => { + socket.on('timeout', common.mustCall(() => { + http.get({ port: server.address().port, agent }) + .on('response', common.mustCall((res) => { + assert.notStrictEqual(socket, res.socket); + assert.strictEqual(socket.destroyed, true); + agent.destroy(); + server.close(); + })); + })); + })); + })); + })); +} + +{ + // Ensure that destroyed sockets are not reused. + + const agent = new http.Agent({ keepAlive: true }); + + const server = http.createServer((req, res) => { + res.end(); + }); + + server.listen(0, common.mustCall(() => { + let socket; + http.get({ port: server.address().port, agent }) + .on('response', common.mustCall((res) => { + socket = res.socket; + assert(socket); + res.resume(); + socket.on('free', common.mustCall(() => { + socket.destroy(); + http.get({ port: server.address().port, agent }) + .on('response', common.mustCall((res) => { + assert.notStrictEqual(socket, res.socket); + assert(socket); + agent.destroy(); + server.close(); + })); + })); + })); + })); +} diff --git a/test/parallel/test-http-client-check-http-token.js b/test/parallel/test-http-client-check-http-token.js index d09fbe1b8ee959..ef2445ec66e520 100644 --- a/test/parallel/test-http-client-check-http-token.js +++ b/test/parallel/test-http-client-check-http-token.js @@ -23,7 +23,7 @@ server.listen(0, common.mustCall(() => { }, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError', - message: 'The "method" argument must be of type string.' + + message: 'The "options.method" property must be of type string.' + common.invalidArgTypeHelper(method) }); }); diff --git a/test/parallel/test-http-client-default-headers-exist.js b/test/parallel/test-http-client-default-headers-exist.js index ba4d4fa660b2cc..e19be4b7d70856 100644 --- a/test/parallel/test-http-client-default-headers-exist.js +++ b/test/parallel/test-http-client-default-headers-exist.js @@ -23,7 +23,8 @@ const common = require('../common'); const assert = require('assert'); const http = require('http'); -const Countdown = require('../common/countdown'); + +const { once } = require('events'); const expectedHeaders = { 'DELETE': ['host', 'connection'], @@ -37,10 +38,6 @@ const expectedHeaders = { const expectedMethods = Object.keys(expectedHeaders); -const countdown = - new Countdown(expectedMethods.length, - common.mustCall(() => server.close())); - const server = http.createServer(common.mustCall((req, res) => { res.end(); @@ -49,9 +46,8 @@ const server = http.createServer(common.mustCall((req, res) => { const requestHeaders = Object.keys(req.headers); requestHeaders.forEach((header) => { - assert.strictEqual( + assert.ok( expectedHeaders[req.method].includes(header.toLowerCase()), - true, `${header} should not exist for method ${req.method}` ); }); @@ -61,15 +57,14 @@ const server = http.createServer(common.mustCall((req, res) => { expectedHeaders[req.method].length, `some headers were missing for method: ${req.method}` ); - - countdown.dec(); }, expectedMethods.length)); server.listen(0, common.mustCall(() => { - expectedMethods.forEach((method) => { - http.request({ + Promise.all(expectedMethods.map(async (method) => { + const request = http.request({ method: method, port: server.address().port }).end(); - }); + return once(request, 'response'); + })).then(common.mustCall(() => { server.close(); })); })); diff --git a/test/parallel/test-http-client-set-timeout-after-end.js b/test/parallel/test-http-client-set-timeout-after-end.js index 99bbf3dd1bc766..93eab80938a74b 100644 --- a/test/parallel/test-http-client-set-timeout-after-end.js +++ b/test/parallel/test-http-client-set-timeout-after-end.js @@ -20,7 +20,7 @@ server.listen(0, () => { const req = get({ agent, port }, (res) => { res.on('end', () => { strictEqual(req.setTimeout(0), req); - strictEqual(socket.listenerCount('timeout'), 0); + strictEqual(socket.listenerCount('timeout'), 1); agent.destroy(); server.close(); }); diff --git a/test/parallel/test-http-client-set-timeout.js b/test/parallel/test-http-client-set-timeout.js index 7717b7d6069c73..51b6622a6b71cc 100644 --- a/test/parallel/test-http-client-set-timeout.js +++ b/test/parallel/test-http-client-set-timeout.js @@ -42,7 +42,7 @@ server.listen(0, mustCall(() => { })); req.on('timeout', mustCall(() => { - strictEqual(req.socket.listenerCount('timeout'), 0); + strictEqual(req.socket.listenerCount('timeout'), 1); req.destroy(); })); })); diff --git a/test/parallel/test-http-client-timeout-option-listeners.js b/test/parallel/test-http-client-timeout-option-listeners.js index 727b5fddf09624..dac89b5fd1a2bb 100644 --- a/test/parallel/test-http-client-timeout-option-listeners.js +++ b/test/parallel/test-http-client-timeout-option-listeners.js @@ -24,9 +24,9 @@ const options = { server.listen(0, options.host, common.mustCall(() => { options.port = server.address().port; doRequest(common.mustCall((numListeners) => { - assert.strictEqual(numListeners, 1); + assert.strictEqual(numListeners, 2); doRequest(common.mustCall((numListeners) => { - assert.strictEqual(numListeners, 1); + assert.strictEqual(numListeners, 2); server.close(); agent.destroy(); })); diff --git a/test/parallel/test-http-client-timeout-option-with-agent.js b/test/parallel/test-http-client-timeout-option-with-agent.js index 594dd1215f43e5..833c21c8929b72 100644 --- a/test/parallel/test-http-client-timeout-option-with-agent.js +++ b/test/parallel/test-http-client-timeout-option-with-agent.js @@ -18,6 +18,6 @@ request.on('socket', mustCall((socket) => { const listeners = socket.listeners('timeout'); - strictEqual(listeners.length, 1); - strictEqual(listeners[0], request.timeoutCb); + strictEqual(listeners.length, 2); + strictEqual(listeners[1], request.timeoutCb); })); diff --git a/test/parallel/test-http-information-processing.js b/test/parallel/test-http-information-processing.js index 94554c2109d433..b9e5fea339ad0f 100644 --- a/test/parallel/test-http-information-processing.js +++ b/test/parallel/test-http-information-processing.js @@ -2,22 +2,22 @@ require('../common'); const assert = require('assert'); const http = require('http'); -const Countdown = require('../common/countdown'); +const debug = require('util').debuglog('test'); -const test_res_body = 'other stuff!\n'; -const countdown = new Countdown(3, () => server.close()); +const testResBody = 'other stuff!\n'; +const kMessageCount = 2; const server = http.createServer((req, res) => { - console.error('Server sending informational message #1...'); - res.writeProcessing(); - console.error('Server sending informational message #2...'); - res.writeProcessing(); - console.error('Server sending full response...'); + for (let i = 0; i < kMessageCount; i++) { + debug(`Server sending informational message #${i}...`); + res.writeProcessing(); + } + debug('Server sending full response...'); res.writeHead(200, { 'Content-Type': 'text/plain', 'ABCD': '1' }); - res.end(test_res_body); + res.end(testResBody); }); server.listen(0, function() { @@ -26,27 +26,25 @@ server.listen(0, function() { path: '/world' }); req.end(); - console.error('Client sending request...'); + debug('Client sending request...'); let body = ''; + let infoCount = 0; - req.on('information', function(res) { - console.error('Client got 102 Processing...'); - countdown.dec(); - }); + req.on('information', () => { infoCount++; }); req.on('response', function(res) { // Check that all 102 Processing received before full response received. - assert.strictEqual(countdown.remaining, 1); + assert.strictEqual(infoCount, kMessageCount); assert.strictEqual(res.statusCode, 200, `Final status code was ${res.statusCode}, not 200.`); res.setEncoding('utf8'); res.on('data', function(chunk) { body += chunk; }); res.on('end', function() { - console.error('Got full response.'); - assert.strictEqual(body, test_res_body); + debug('Got full response.'); + assert.strictEqual(body, testResBody); assert.ok('abcd' in res.headers); - countdown.dec(); + server.close(); }); }); }); diff --git a/test/parallel/test-http-no-read-no-dump.js b/test/parallel/test-http-no-read-no-dump.js index 17d36c56b2eeba..c6ce19845d80ab 100644 --- a/test/parallel/test-http-no-read-no-dump.js +++ b/test/parallel/test-http-no-read-no-dump.js @@ -11,6 +11,10 @@ const server = http.createServer((req, res) => { res.writeHead(200); res.flushHeaders(); + req.on('close', common.mustCall(() => { + req.on('end', common.mustNotCall()); + })); + req.connection.on('pause', () => { res.end(); onPause(); diff --git a/test/parallel/test-http-readable-data-event.js b/test/parallel/test-http-readable-data-event.js index 21b1fa65c661c8..643176ec7b066a 100644 --- a/test/parallel/test-http-readable-data-event.js +++ b/test/parallel/test-http-readable-data-event.js @@ -10,14 +10,14 @@ let next = null; const server = http.createServer((req, res) => { res.writeHead(200, { - 'Content-Length': '' + (helloWorld.length + helloAgainLater.length) + 'Content-Length': `${(helloWorld.length + helloAgainLater.length)}` }); // We need to make sure the data is flushed // before writing again next = () => { res.end(helloAgainLater); - next = () => {}; + next = () => { }; }; res.write(helloWorld); diff --git a/test/parallel/test-http-response-multi-content-length.js b/test/parallel/test-http-response-multi-content-length.js index b2d28b7a9bcec1..0ef45a027fb64d 100644 --- a/test/parallel/test-http-response-multi-content-length.js +++ b/test/parallel/test-http-response-multi-content-length.js @@ -3,45 +3,39 @@ const common = require('../common'); const http = require('http'); const assert = require('assert'); -const Countdown = require('../common/countdown'); -const MAX_COUNT = 2; +// TODO(@jasnell) At some point this should be refactored as the API should not +// be allowing users to set multiple content-length values in the first place. -const server = http.createServer((req, res) => { - const num = req.headers['x-num']; - // TODO(@jasnell) At some point this should be refactored as the API - // should not be allowing users to set multiple content-length values - // in the first place. - switch (num) { - case '1': - res.setHeader('content-length', [2, 1]); - break; - case '2': - res.writeHead(200, { 'content-length': [1, 2] }); - break; - default: - assert.fail('should never get here'); - } - res.end('ok'); -}); - -const countdown = new Countdown(MAX_COUNT, () => server.close()); - -server.listen(0, common.mustCall(() => { - for (let n = 1; n <= MAX_COUNT; n++) { - // This runs twice, the first time, the server will use - // setHeader, the second time it uses writeHead. In either - // case, the error handler must be called because the client - // is not allowed to accept multiple content-length headers. +function test(server) { + server.listen(0, common.mustCall(() => { http.get( - { port: server.address().port, headers: { 'x-num': n } }, - (res) => { - assert.fail('client allowed multiple content-length headers.'); - } + { port: server.address().port }, + () => { assert.fail('Client allowed multiple content-length headers.'); } ).on('error', common.mustCall((err) => { - assert(/^Parse Error/.test(err.message)); + assert.ok(err.message.startsWith('Parse Error'), err.message); assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); - countdown.dec(); + server.close(); })); - } -})); + })); +} + +// Test adding an extra content-length header using setHeader(). +{ + const server = http.createServer((req, res) => { + res.setHeader('content-length', [2, 1]); + res.end('ok'); + }); + + test(server); +} + +// Test adding an extra content-length header using writeHead(). +{ + const server = http.createServer((req, res) => { + res.writeHead(200, { 'content-length': [1, 2] }); + res.end('ok'); + }); + + test(server); +} diff --git a/test/parallel/test-http2-buffersize.js b/test/parallel/test-http2-buffersize.js index f18cc4c1ec4e18..2a21833f1cae3a 100644 --- a/test/parallel/test-http2-buffersize.js +++ b/test/parallel/test-http2-buffersize.js @@ -5,32 +5,31 @@ if (!hasCrypto) skip('missing crypto'); const assert = require('assert'); const { createServer, connect } = require('http2'); -const Countdown = require('../common/countdown'); +const { once } = require('events'); // This test ensures that `bufferSize` of Http2Session and Http2Stream work // as expected. { - const SOCKETS = 2; - const TIMES = 10; - const BUFFER_SIZE = 30; + const kSockets = 2; + const kTimes = 10; + const kBufferSize = 30; const server = createServer(); let client; - const countdown = new Countdown(SOCKETS, () => { - client.close(); - server.close(); - }); - // Other `bufferSize` tests for net module and tls module - // don't assert `bufferSize` of server-side sockets. - server.on('stream', mustCall((stream) => { + const getStream = async () => { + const [ stream ] = await once(server, 'stream'); stream.on('data', mustCall()); stream.on('end', mustCall()); + stream.on('close', mustCall()); + return once(stream, 'close'); + }; - stream.on('close', mustCall(() => { - countdown.dec(); - })); - }, SOCKETS)); + const promises = [...new Array(kSockets)].map(getStream); + Promise.all(promises).then(mustCall(() => { + client.close(); + server.close(); + })); server.listen(0, mustCall(() => { const authority = `http://localhost:${server.address().port}`; @@ -38,13 +37,13 @@ const Countdown = require('../common/countdown'); client.once('connect', mustCall()); - for (let j = 0; j < SOCKETS; j += 1) { + for (let j = 0; j < kSockets; j += 1) { const stream = client.request({ ':method': 'POST' }); stream.on('data', () => {}); - for (let i = 0; i < TIMES; i += 1) { - stream.write(Buffer.allocUnsafe(BUFFER_SIZE), mustCall()); - const expectedSocketBufferSize = BUFFER_SIZE * (i + 1); + for (let i = 0; i < kTimes; i += 1) { + stream.write(Buffer.allocUnsafe(kBufferSize), mustCall()); + const expectedSocketBufferSize = kBufferSize * (i + 1); assert.strictEqual(stream.bufferSize, expectedSocketBufferSize); } stream.end(); diff --git a/test/parallel/test-http2-origin.js b/test/parallel/test-http2-origin.js index 6f90a043d8a7cc..519e8cb1a3dedd 100644 --- a/test/parallel/test-http2-origin.js +++ b/test/parallel/test-http2-origin.js @@ -70,7 +70,7 @@ const ca = readKey('fake-startcom-root-cert.pem', 'binary'); } ); }); - const longInput = 'http://foo.bar' + 'a'.repeat(16383); + const longInput = `http://foo.bar${'a'.repeat(16383)}`; throws( () => session.origin(longInput), { @@ -107,7 +107,7 @@ const ca = readKey('fake-startcom-root-cert.pem', 'binary'); // Test automatically sending origin on connection start { - const origins = [ 'https://foo.org/a/b/c', 'https://bar.org' ]; + const origins = ['https://foo.org/a/b/c', 'https://bar.org']; const server = createSecureServer({ key, cert, origins }); server.on('stream', mustCall((stream) => { stream.respond(); diff --git a/test/parallel/test-http2-server-session-destroy.js b/test/parallel/test-http2-server-session-destroy.js index 9b7f126510757c..afa3dd3398dba8 100644 --- a/test/parallel/test-http2-server-session-destroy.js +++ b/test/parallel/test-http2-server-session-destroy.js @@ -16,5 +16,5 @@ server.listen(0, common.localhostIPv4, common.mustCall(() => { const port = server.address().port; const host = common.localhostIPv4; - h2.connect('http://' + host + ':' + port, afterConnect); + h2.connect(`http://${host}:${port}`, afterConnect); })); diff --git a/test/parallel/test-inspector-bindings.js b/test/parallel/test-inspector-bindings.js index c632bb8840fa30..3e88c858f8de9e 100644 --- a/test/parallel/test-inspector-bindings.js +++ b/test/parallel/test-inspector-bindings.js @@ -127,4 +127,4 @@ async function doTests() { await testNoCrashConsoleLogBeforeThrow(); } -doTests(); +doTests().then(common.mustCall()); diff --git a/test/parallel/test-inspector-esm.js b/test/parallel/test-inspector-esm.js index b5f55b68d717ff..19d493c519b5e3 100644 --- a/test/parallel/test-inspector-esm.js +++ b/test/parallel/test-inspector-esm.js @@ -109,4 +109,4 @@ async function runTest() { assert.strictEqual((await child.expectShutdown()).exitCode, 55); } -runTest(); +runTest().then(common.mustCall()); diff --git a/test/parallel/test-inspector-multisession-js.js b/test/parallel/test-inspector-multisession-js.js index 92879d3ff3a7df..31aa0c5f569854 100644 --- a/test/parallel/test-inspector-multisession-js.js +++ b/test/parallel/test-inspector-multisession-js.js @@ -57,7 +57,7 @@ async function test() { } const interval = setInterval(() => {}, 1000); -test().then(() => { +test().then(common.mustCall(() => { clearInterval(interval); console.log('Done!'); -}); +})); diff --git a/test/parallel/test-inspector-multisession-ws.js b/test/parallel/test-inspector-multisession-ws.js index 6b07af0b85e987..7981eef0d30149 100644 --- a/test/parallel/test-inspector-multisession-ws.js +++ b/test/parallel/test-inspector-multisession-ws.js @@ -20,6 +20,7 @@ session.on('Debugger.paused', () => { session.connect(); session.post('Debugger.enable'); console.log('Ready'); +console.log('Ready'); `; async function setupSession(node) { @@ -46,6 +47,10 @@ async function testSuspend(sessionA, sessionB) { await sessionA.waitForNotification('Debugger.paused', 'Initial pause'); sessionA.send({ 'method': 'Debugger.resume' }); + await sessionA.waitForNotification('Runtime.consoleAPICalled', + 'Console output'); + // NOTE(mmarchini): Remove second console.log when + // https://bugs.chromium.org/p/v8/issues/detail?id=10287 is fixed. await sessionA.waitForNotification('Runtime.consoleAPICalled', 'Console output'); sessionA.send({ 'method': 'Debugger.pause' }); @@ -69,4 +74,4 @@ async function runTest() { return child.expectShutdown(); } -runTest(); +runTest().then(common.mustCall()); diff --git a/test/parallel/test-inspector-reported-host.js b/test/parallel/test-inspector-reported-host.js index b3bc7368032c9c..676e5387c8102c 100644 --- a/test/parallel/test-inspector-reported-host.js +++ b/test/parallel/test-inspector-reported-host.js @@ -16,4 +16,4 @@ async function test() { child.kill(); } -test(); +test().then(common.mustCall()); diff --git a/test/parallel/test-inspector-tracing-domain.js b/test/parallel/test-inspector-tracing-domain.js index 9d3d33d94d5bbd..152df1491553f1 100644 --- a/test/parallel/test-inspector-tracing-domain.js +++ b/test/parallel/test-inspector-tracing-domain.js @@ -66,4 +66,4 @@ async function test() { console.log('Success'); } -test(); +test().then(common.mustCall()); diff --git a/test/parallel/test-inspector-wait-for-connection.js b/test/parallel/test-inspector-wait-for-connection.js index 44bb6dd5e1c30f..0f562faede1e55 100644 --- a/test/parallel/test-inspector-wait-for-connection.js +++ b/test/parallel/test-inspector-wait-for-connection.js @@ -58,4 +58,4 @@ async function runTests() { assert.throws(() => require('inspector').waitForDebugger(), re); } -runTests(); +runTests().then(common.mustCall()); diff --git a/test/parallel/test-inspector-waiting-for-disconnect.js b/test/parallel/test-inspector-waiting-for-disconnect.js index 187875abc1b621..e9d39978d7aaf0 100644 --- a/test/parallel/test-inspector-waiting-for-disconnect.js +++ b/test/parallel/test-inspector-waiting-for-disconnect.js @@ -41,4 +41,4 @@ async function runTest() { assert.strictEqual((await child.expectShutdown()).exitCode, 55); } -runTest(); +runTest().then(common.mustCall()); diff --git a/test/parallel/test-macos-signed-deps.js b/test/parallel/test-macos-signed-deps.js new file mode 100644 index 00000000000000..1932d7686caae3 --- /dev/null +++ b/test/parallel/test-macos-signed-deps.js @@ -0,0 +1,31 @@ +'use strict'; + +// Notarization on macOS requires all binaries to be signed. +// We sign our own binaries but check here if any binaries from our dependencies +// (e.g. npm) are signed. +const common = require('../common'); + +if (!common.isOSX) { + common.skip('macOS specific test'); +} + +const assert = require('assert'); +const { spawnSync } = require('child_process'); +const path = require('path'); + +const debuglog = require('util').debuglog('test'); + +const binaries = [ + 'deps/npm/node_modules/term-size/vendor/macos/term-size', +]; + +for (const testbin of binaries) { + const bin = path.resolve(__dirname, '..', '..', testbin); + debuglog(`Checking ${bin}`); + const cp = spawnSync('codesign', [ '-vvvv', bin ], { encoding: 'utf8' }); + debuglog(cp.stdout); + debuglog(cp.stderr); + assert.strictEqual(cp.signal, null); + assert.strictEqual(cp.status, 0, `${bin} does not appear to be signed.\n` + + `${cp.stdout}\n${cp.stderr}`); +} diff --git a/test/parallel/test-net-allow-half-open.js b/test/parallel/test-net-allow-half-open.js new file mode 100644 index 00000000000000..8f68c0105a15dc --- /dev/null +++ b/test/parallel/test-net-allow-half-open.js @@ -0,0 +1,25 @@ +'use strict'; + +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); + +const server = net.createServer(common.mustCall((socket) => { + socket.end(Buffer.alloc(1024)); +})).listen(0, common.mustCall(() => { + const socket = net.connect(server.address().port); + assert.strictEqual(socket.allowHalfOpen, false); + socket.resume(); + socket.on('end', common.mustCall(() => { + process.nextTick(() => { + // Ensure socket is not destroyed straight away + // without proper shutdown. + assert(!socket.destroyed); + server.close(); + }); + })); + socket.on('finish', common.mustCall(() => { + assert(!socket.destroyed); + })); + socket.on('close', common.mustCall()); +})); diff --git a/test/parallel/test-net-socket-timeout.js b/test/parallel/test-net-socket-timeout.js index 8b197b44d61281..e01304afe53f01 100644 --- a/test/parallel/test-net-socket-timeout.js +++ b/test/parallel/test-net-socket-timeout.js @@ -70,8 +70,12 @@ for (let i = 0; i < invalidCallbacks.length; i++) { const server = net.Server(); server.listen(0, common.mustCall(() => { const socket = net.createConnection(server.address().port); - socket.setTimeout(1, common.mustCall(() => { - socket.destroy(); - server.close(); - })); + assert.strictEqual( + socket.setTimeout(1, common.mustCall(() => { + socket.destroy(); + assert.strictEqual(socket.setTimeout(1, common.mustNotCall()), socket); + server.close(); + })), + socket + ); })); diff --git a/test/parallel/test-performance-measure.js b/test/parallel/test-performance-measure.js new file mode 100644 index 00000000000000..06e04cc219c7fd --- /dev/null +++ b/test/parallel/test-performance-measure.js @@ -0,0 +1,25 @@ +'use strict'; + +const common = require('../common'); +const assert = require('assert'); + +const { PerformanceObserver, performance } = require('perf_hooks'); +const DELAY = 1000; + +const expected = ['Start to Now', 'A to Now', 'A to B']; +const obs = new PerformanceObserver(common.mustCall((items) => { + const entries = items.getEntries(); + const { name, duration } = entries[0]; + assert.ok(duration > DELAY); + assert.strictEqual(expected.shift(), name); +}, 3)); +obs.observe({ entryTypes: ['measure'] }); + +performance.mark('A'); +setTimeout(common.mustCall(() => { + performance.measure('Start to Now'); + performance.measure('A to Now', 'A'); + + performance.mark('B'); + performance.measure('A to B', 'A', 'B'); +}), DELAY); diff --git a/test/parallel/test-process-exit-code.js b/test/parallel/test-process-exit-code.js index 9059b0b5c22487..2f658a172cdc5a 100644 --- a/test/parallel/test-process-exit-code.js +++ b/test/parallel/test-process-exit-code.js @@ -22,6 +22,7 @@ 'use strict'; require('../common'); const assert = require('assert'); +const debug = require('util').debuglog('test'); const testCases = require('../fixtures/process-exit-code-cases'); @@ -30,7 +31,7 @@ if (!process.argv[2]) { } else { const i = parseInt(process.argv[2]); if (Number.isNaN(i)) { - console.log('Invalid test case index'); + debug('Invalid test case index'); process.exit(100); return; } @@ -48,7 +49,7 @@ function parent() { assert.strictEqual( code, exit, `wrong exit for ${arg}-${name}\nexpected:${exit} but got:${code}`); - console.log(`ok - ${arg} exited with ${exit}`); + debug(`ok - ${arg} exited with ${exit}`); }); }; diff --git a/test/parallel/test-process-getactiverequests.js b/test/parallel/test-process-getactiverequests.js index 41883d35aa7dbc..ed3c0c8fe861ec 100644 --- a/test/parallel/test-process-getactiverequests.js +++ b/test/parallel/test-process-getactiverequests.js @@ -1,10 +1,10 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const fs = require('fs'); for (let i = 0; i < 12; i++) - fs.open(__filename, 'r', () => {}); + fs.open(__filename, 'r', common.mustCall()); assert.strictEqual(process._getActiveRequests().length, 12); diff --git a/test/parallel/test-promises-warning-on-unhandled-rejection.js b/test/parallel/test-promises-warning-on-unhandled-rejection.js index ba420157e72bbd..596bf27ad1917d 100644 --- a/test/parallel/test-promises-warning-on-unhandled-rejection.js +++ b/test/parallel/test-promises-warning-on-unhandled-rejection.js @@ -23,7 +23,7 @@ process.on('warning', common.mustCall((warning) => { assert( /Unhandled promise rejection/.test(warning.message), 'Expected warning message to contain "Unhandled promise rejection" ' + - 'but did not. Had "' + warning.message + '" instead.' + `but did not. Had "${warning.message}" instead.` ); break; case 2: @@ -40,7 +40,7 @@ process.on('warning', common.mustCall((warning) => { assert( /Unhandled promise rejection/.test(warning.message), 'Expected warning message to contain "Unhandled promise rejection" ' + - 'but did not. Had "' + warning.message + '" instead.' + `but did not. Had "${warning.message}" instead.` ); break; case 5: diff --git a/test/parallel/test-stream-readable-async-iterators.js b/test/parallel/test-stream-readable-async-iterators.js index 4a63e9fd3022e6..c8b0e5151af0aa 100644 --- a/test/parallel/test-stream-readable-async-iterators.js +++ b/test/parallel/test-stream-readable-async-iterators.js @@ -527,5 +527,24 @@ async function tests() { p.then(common.mustCall()).catch(common.mustNotCall()); } +{ + // AsyncIterator should finish correctly if destroyed. + + const r = new Readable({ + objectMode: true, + read() { + } + }); + + r.destroy(); + r.on('close', () => { + const it = r[Symbol.asyncIterator](); + const next = it.next(); + next + .then(common.mustCall(({ done }) => assert.strictEqual(done, true))) + .catch(common.mustNotCall()); + }); +} + // To avoid missing some tests if a promise does not resolve tests().then(common.mustCall()); diff --git a/test/parallel/test-timers-immediate-unref.js b/test/parallel/test-timers-immediate-unref.js index 5a7629781d54f5..fa9fd9aa55c661 100644 --- a/test/parallel/test-timers-immediate-unref.js +++ b/test/parallel/test-timers-immediate-unref.js @@ -1,8 +1,6 @@ 'use strict'; const common = require('../common'); -const Countdown = require('../common/countdown'); - const assert = require('assert'); const immediate = setImmediate(() => {}); @@ -16,12 +14,10 @@ clearImmediate(immediate); setImmediate(common.mustCall(firstStep)).ref().unref().unref().ref(); function firstStep() { - const countdown = - new Countdown(2, common.mustCall(() => setImmediate(secondStep))); // Unrefed setImmediate executes if it was unrefed but something else keeps // the loop open - setImmediate(() => countdown.dec()).unref(); - setTimeout(() => countdown.dec(), 50); + setImmediate(common.mustCall()).unref(); + setTimeout(common.mustCall(() => { setImmediate(secondStep); }), 0); } function secondStep() { diff --git a/test/parallel/test-tls-env-extra-ca-file-load.js b/test/parallel/test-tls-env-extra-ca-file-load.js index 2c6119f0a53d32..75d7c17c1f1ee3 100644 --- a/test/parallel/test-tls-env-extra-ca-file-load.js +++ b/test/parallel/test-tls-env-extra-ca-file-load.js @@ -16,14 +16,7 @@ const { fork } = require('child_process'); // This test ensures that extra certificates are loaded at startup. if (process.argv[2] !== 'child') { - if (process.env.CHILD_USE_EXTRA_CA_CERTS === 'yes') { - assert.strictEqual(binding.isExtraRootCertsFileLoaded(), true); - } else if (process.env.CHILD_USE_EXTRA_CA_CERTS === 'no') { - assert.strictEqual(binding.isExtraRootCertsFileLoaded(), false); - tls.createServer({}); - assert.strictEqual(binding.isExtraRootCertsFileLoaded(), false); - } -} else { + // Parent const NODE_EXTRA_CA_CERTS = fixtures.path('keys', 'ca1-cert.pem'); const extendsEnv = (obj) => ({ ...process.env, ...obj }); @@ -37,4 +30,12 @@ if (process.argv[2] !== 'child') { assert.strictEqual(status, 0); })); }); +} else if (process.env.CHILD_USE_EXTRA_CA_CERTS === 'yes') { + // Child with extra certificates loaded at startup. + assert.strictEqual(binding.isExtraRootCertsFileLoaded(), true); +} else { + // Child without extra certificates. + assert.strictEqual(binding.isExtraRootCertsFileLoaded(), false); + tls.createServer({}); + assert.strictEqual(binding.isExtraRootCertsFileLoaded(), false); } diff --git a/test/parallel/test-tls-psk-server.js b/test/parallel/test-tls-psk-server.js index 69b850c70226a6..434d31380fe2ad 100644 --- a/test/parallel/test-tls-psk-server.js +++ b/test/parallel/test-tls-psk-server.js @@ -43,7 +43,7 @@ let gotWorld = false; server.listen(0, () => { const client = spawn(common.opensslCli, [ 's_client', - '-connect', '127.0.0.1:' + server.address().port, + '-connect', `127.0.0.1:${server.address().port}`, '-cipher', CIPHERS, '-psk', KEY, '-psk_identity', IDENTITY diff --git a/test/parallel/test-tls-root-certificates.js b/test/parallel/test-tls-root-certificates.js index 5f7aa418ac05a3..f200231fa301a5 100644 --- a/test/parallel/test-tls-root-certificates.js +++ b/test/parallel/test-tls-root-certificates.js @@ -2,30 +2,49 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +const fixtures = require('../common/fixtures'); const assert = require('assert'); const tls = require('tls'); - -assert(Array.isArray(tls.rootCertificates)); -assert(tls.rootCertificates.length > 0); - -// Getter should return the same object. -assert.strictEqual(tls.rootCertificates, tls.rootCertificates); - -// Array is immutable... -assert.throws(() => tls.rootCertificates[0] = 0, /TypeError/); -assert.throws(() => tls.rootCertificates.sort(), /TypeError/); - -// ...and so is the property. -assert.throws(() => tls.rootCertificates = 0, /TypeError/); - -// Does not contain duplicates. -assert.strictEqual(tls.rootCertificates.length, - new Set(tls.rootCertificates).size); - -assert(tls.rootCertificates.every((s) => { - return s.startsWith('-----BEGIN CERTIFICATE-----\n'); -})); - -assert(tls.rootCertificates.every((s) => { - return s.endsWith('\n-----END CERTIFICATE-----'); -})); +const { fork } = require('child_process'); + +if (process.argv[2] !== 'child') { + // Parent + const NODE_EXTRA_CA_CERTS = fixtures.path('keys', 'ca1-cert.pem'); + + fork( + __filename, + ['child'], + { env: { ...process.env, NODE_EXTRA_CA_CERTS } } + ).on('exit', common.mustCall(function(status) { + assert.strictEqual(status, 0); + })); +} else { + // Child + assert(Array.isArray(tls.rootCertificates)); + assert(tls.rootCertificates.length > 0); + + // Getter should return the same object. + assert.strictEqual(tls.rootCertificates, tls.rootCertificates); + + // Array is immutable... + assert.throws(() => tls.rootCertificates[0] = 0, /TypeError/); + assert.throws(() => tls.rootCertificates.sort(), /TypeError/); + + // ...and so is the property. + assert.throws(() => tls.rootCertificates = 0, /TypeError/); + + // Does not contain duplicates. + assert.strictEqual(tls.rootCertificates.length, + new Set(tls.rootCertificates).size); + + assert(tls.rootCertificates.every((s) => { + return s.startsWith('-----BEGIN CERTIFICATE-----\n'); + })); + + assert(tls.rootCertificates.every((s) => { + return s.endsWith('\n-----END CERTIFICATE-----\n'); + })); + + const extraCert = fixtures.readKey('ca1-cert.pem', 'utf8'); + assert(tls.rootCertificates.includes(extraCert)); +} diff --git a/test/parallel/test-tls-set-secure-context.js b/test/parallel/test-tls-set-secure-context.js index f8857701c68b3c..f72daff6ef14fb 100644 --- a/test/parallel/test-tls-set-secure-context.js +++ b/test/parallel/test-tls-set-secure-context.js @@ -82,6 +82,7 @@ function makeRequest(port, id) { headers: { id } }; + let errored = false; https.get(`https://localhost:${port}`, options, (res) => { let response = ''; @@ -95,7 +96,10 @@ function makeRequest(port, id) { resolve(response); })); }).on('error', (err) => { + errored = true; reject(err); + }).on('finish', () => { + assert.strictEqual(errored, false); }); }); } diff --git a/test/parallel/test-ttywrap-invalid-fd.js b/test/parallel/test-ttywrap-invalid-fd.js index ea2e0f276dbf9a..5539ff22962244 100644 --- a/test/parallel/test-ttywrap-invalid-fd.js +++ b/test/parallel/test-ttywrap-invalid-fd.js @@ -21,13 +21,14 @@ assert.throws( { const info = { - code: common.isWindows ? 'EBADF' : 'EINVAL', - message: common.isWindows ? 'bad file descriptor' : 'invalid argument', - errno: common.isWindows ? UV_EBADF : UV_EINVAL, + code: common.isWindows || common.isIBMi ? 'EBADF' : 'EINVAL', + message: common.isWindows || + common.isIBMi ? 'bad file descriptor' : 'invalid argument', + errno: common.isWindows || common.isIBMi ? UV_EBADF : UV_EINVAL, syscall: 'uv_tty_init' }; - const suffix = common.isWindows ? + const suffix = common.isWindows || common.isIBMi ? 'EBADF (bad file descriptor)' : 'EINVAL (invalid argument)'; const message = `TTY initialization failed: uv_tty_init returned ${suffix}`; diff --git a/test/parallel/test-util-format.js b/test/parallel/test-util-format.js index d39df436146820..d1cb83b51d1986 100644 --- a/test/parallel/test-util-format.js +++ b/test/parallel/test-util-format.js @@ -57,6 +57,8 @@ assert.strictEqual(util.format('%d', -0.0), '-0'); assert.strictEqual(util.format('%d', ''), '0'); assert.strictEqual(util.format('%d', ' -0.000'), '-0'); assert.strictEqual(util.format('%d', Symbol()), 'NaN'); +assert.strictEqual(util.format('%d', Infinity), 'Infinity'); +assert.strictEqual(util.format('%d', -Infinity), '-Infinity'); assert.strictEqual(util.format('%d %d', 42, 43), '42 43'); assert.strictEqual(util.format('%d %d', 42), '42 %d'); assert.strictEqual( @@ -81,6 +83,8 @@ assert.strictEqual(util.format('%i', '42.0'), '42'); assert.strictEqual(util.format('%i', 1.5), '1'); assert.strictEqual(util.format('%i', -0.5), '-0'); assert.strictEqual(util.format('%i', ''), 'NaN'); +assert.strictEqual(util.format('%i', Infinity), 'NaN'); +assert.strictEqual(util.format('%i', -Infinity), 'NaN'); assert.strictEqual(util.format('%i', Symbol()), 'NaN'); assert.strictEqual(util.format('%i %i', 42, 43), '42 43'); assert.strictEqual(util.format('%i %i', 42), '42 %i'); @@ -120,6 +124,8 @@ assert.strictEqual(util.format('%f', Math.PI), '3.141592653589793'); assert.strictEqual(util.format('%f', ''), 'NaN'); assert.strictEqual(util.format('%f', Symbol('foo')), 'NaN'); assert.strictEqual(util.format('%f', 5n), '5'); +assert.strictEqual(util.format('%f', Infinity), 'Infinity'); +assert.strictEqual(util.format('%f', -Infinity), '-Infinity'); assert.strictEqual(util.format('%f %f', 42, 43), '42 43'); assert.strictEqual(util.format('%f %f', 42), '42 %f'); @@ -141,6 +147,8 @@ assert.strictEqual(util.format('%s', { a: [1, 2, 3] }), '{ a: [Array] }'); assert.strictEqual(util.format('%s', { toString() { return 'Foo'; } }), 'Foo'); assert.strictEqual(util.format('%s', { toString: 5 }), '{ toString: 5 }'); assert.strictEqual(util.format('%s', () => 5), '() => 5'); +assert.strictEqual(util.format('%s', Infinity), 'Infinity'); +assert.strictEqual(util.format('%s', -Infinity), '-Infinity'); // String format specifier including `toString` properties on the prototype. { diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index e1a0b7c011965c..5df203e6d33be0 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -26,6 +26,7 @@ const { internalBinding } = require('internal/test/binding'); const JSStream = internalBinding('js_stream').JSStream; const util = require('util'); const vm = require('vm'); +const v8 = require('v8'); const { previewEntries } = internalBinding('util'); const { inspect } = util; const { MessageChannel } = require('worker_threads'); @@ -695,6 +696,28 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324'); Error.stackTraceLimit = tmp; } +// Prevent enumerable error properties from being printed. +{ + let err = new Error(); + err.message = 'foobar'; + let out = util.inspect(err).split('\n'); + assert.strictEqual(out[0], 'Error: foobar'); + assert(out[out.length - 1].startsWith(' at ')); + // Reset the error, the stack is otherwise not recreated. + err = new Error(); + err.message = 'foobar'; + err.name = 'Unique'; + Object.defineProperty(err, 'stack', { value: err.stack, enumerable: true }); + out = util.inspect(err).split('\n'); + assert.strictEqual(out[0], 'Unique: foobar'); + assert(out[out.length - 1].startsWith(' at ')); + err.name = 'Baz'; + out = util.inspect(err).split('\n'); + assert.strictEqual(out[0], 'Unique: foobar'); + assert.strictEqual(out[out.length - 2], " name: 'Baz'"); + assert.strictEqual(out[out.length - 1], '}'); +} + // Doesn't capture stack trace. { function BadCustomError(msg) { @@ -2727,3 +2750,11 @@ assert.strictEqual( assert.deepStrictEqual(colors.gray, originalValue); assert.strictEqual(colors.grey, colors.gray); } + +// https://github.com/nodejs/node/issues/31889 +{ + v8.setFlagsFromString('--allow-natives-syntax'); + const undetectable = vm.runInThisContext('%GetUndetectable()'); + v8.setFlagsFromString('--no-allow-natives-syntax'); + assert.strictEqual(inspect(undetectable), '{}'); +} diff --git a/test/parallel/test-worker-esm-exit.js b/test/parallel/test-worker-esm-exit.js index c0b9d874895725..aebb17edda0baf 100644 --- a/test/parallel/test-worker-esm-exit.js +++ b/test/parallel/test-worker-esm-exit.js @@ -7,4 +7,6 @@ const { Worker } = require('worker_threads'); const w = new Worker(fixtures.path('es-modules/import-process-exit.mjs'), { execArgv: ['--experimental-modules'] }); w.on('error', common.mustNotCall()); -w.on('exit', (code) => assert.strictEqual(code, 42)); +w.on('exit', + common.mustCall((code) => assert.strictEqual(code, 42)) +); diff --git a/test/parallel/test-worker-init-failure.js b/test/parallel/test-worker-init-failure.js new file mode 100644 index 00000000000000..ea9654200ecaf8 --- /dev/null +++ b/test/parallel/test-worker-init-failure.js @@ -0,0 +1,67 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const child_process = require('child_process'); + +// Test that workers fail with meaningful error message +// when their initialization fails. + +if (common.isWindows) { + common.skip('ulimit does not work on Windows.'); +} + +// A reasonably low fd count. An empty node process +// creates around 30 fds for its internal purposes, +// so making it too low will crash the process early, +// making it too high will cause too much resource use. +const OPENFILES = 128; + +// Double the open files - so that some workers fail for sure. +const WORKERCOUNT = 256; + +if (process.argv[2] === 'child') { + const { Worker } = require('worker_threads'); + for (let i = 0; i < WORKERCOUNT; ++i) { + const worker = new Worker( + 'require(\'worker_threads\').parentPort.postMessage(2 + 2)', + { eval: true }); + worker.on('message', (result) => { + assert.strictEqual(result, 4); + }); + + // We want to test that if there is an error in a constrained running + // environment, it will be one of `EMFILE` or `ERR_WORKER_INIT_FAILED`. + // `common.mustCall*` cannot be used here as in some environments + // (i.e. single cpu) `ulimit` may not lead to such an error. + + worker.on('error', (e) => { + assert.match(e.message, /EMFILE/); + assert.ok(e.code === 'ERR_WORKER_INIT_FAILED' || e.code === 'EMFILE'); + }); + } + +} else { + // Limit the number of open files, to force workers to fail. + let testCmd = `ulimit -n ${OPENFILES} && `; + testCmd += `${process.execPath} ${__filename} child`; + const cp = child_process.exec(testCmd); + + // Turn on the child streams for debugging purposes. + let stdout = ''; + cp.stdout.setEncoding('utf8'); + cp.stdout.on('data', (chunk) => { + stdout += chunk; + }); + let stderr = ''; + cp.stderr.setEncoding('utf8'); + cp.stderr.on('data', (chunk) => { + stderr += chunk; + }); + + cp.on('exit', common.mustCall((code, signal) => { + console.log(`child stdout: ${stdout}\n`); + console.log(`child stderr: ${stderr}\n`); + assert.strictEqual(code, 0); + assert.strictEqual(signal, null); + })); +} diff --git a/test/parallel/test-worker-nested-on-process-exit.js b/test/parallel/test-worker-nested-on-process-exit.js new file mode 100644 index 00000000000000..aa544fa3289a11 --- /dev/null +++ b/test/parallel/test-worker-nested-on-process-exit.js @@ -0,0 +1,20 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const { Worker, workerData } = require('worker_threads'); + +// Test that 'exit' events for nested Workers are not received when a Worker +// terminates itself through process.exit(). + +if (workerData === null) { + const nestedWorkerExitCounter = new Int32Array(new SharedArrayBuffer(4)); + const w = new Worker(__filename, { workerData: nestedWorkerExitCounter }); + w.on('exit', common.mustCall(() => { + assert.strictEqual(nestedWorkerExitCounter[0], 0); + })); +} else { + const nestedWorker = new Worker('setInterval(() => {}, 100)', { eval: true }); + // The counter should never be increased here. + nestedWorker.on('exit', () => workerData[0]++); + nestedWorker.on('online', () => process.exit()); +} diff --git a/test/parallel/test-worker-on-process-exit.js b/test/parallel/test-worker-on-process-exit.js new file mode 100644 index 00000000000000..ec1c4affd1cc6f --- /dev/null +++ b/test/parallel/test-worker-on-process-exit.js @@ -0,0 +1,22 @@ +'use strict'; +require('../common'); +const assert = require('assert'); +const { spawnSync } = require('child_process'); +const { Worker } = require('worker_threads'); + +// Test that 'exit' events for Workers are not received when the main thread +// terminates itself through process.exit(). + +if (process.argv[2] !== 'child') { + const { + stdout, stderr, status + } = spawnSync(process.execPath, [__filename, 'child'], { encoding: 'utf8' }); + assert.strictEqual(stderr, ''); + assert.strictEqual(stdout, ''); + assert.strictEqual(status, 0); +} else { + const nestedWorker = new Worker('setInterval(() => {}, 100)', { eval: true }); + // This console.log() should never fire. + nestedWorker.on('exit', () => console.log('exit event received')); + nestedWorker.on('online', () => process.exit()); +} diff --git a/test/parallel/test-worker-relative-path.js b/test/parallel/test-worker-relative-path.js index 3b7bb95b0d78f4..73dc5b3637912f 100644 --- a/test/parallel/test-worker-relative-path.js +++ b/test/parallel/test-worker-relative-path.js @@ -5,7 +5,7 @@ const assert = require('assert'); const { Worker, isMainThread, parentPort } = require('worker_threads'); if (isMainThread) { - const w = new Worker('./' + path.relative('.', __filename)); + const w = new Worker(`./${path.relative('.', __filename)}`); w.on('message', common.mustCall((message) => { assert.strictEqual(message, 'Hello, world!'); })); diff --git a/test/parallel/test-worker-syntax-error-file.js b/test/parallel/test-worker-syntax-error-file.js index ca42c174808500..36b8913895dfa2 100644 --- a/test/parallel/test-worker-syntax-error-file.js +++ b/test/parallel/test-worker-syntax-error-file.js @@ -11,7 +11,7 @@ if (!process.env.HAS_STARTED_WORKER) { w.on('message', common.mustNotCall()); w.on('error', common.mustCall((err) => { assert.strictEqual(err.constructor, SyntaxError); - assert(/SyntaxError/.test(err)); + assert.strictEqual(err.name, 'SyntaxError'); })); } else { throw new Error('foo'); diff --git a/test/parallel/test-worker-syntax-error.js b/test/parallel/test-worker-syntax-error.js index 1c1fbf1c1ab3a0..99ebf26a9fa714 100644 --- a/test/parallel/test-worker-syntax-error.js +++ b/test/parallel/test-worker-syntax-error.js @@ -7,5 +7,5 @@ const w = new Worker('abc)', { eval: true }); w.on('message', common.mustNotCall()); w.on('error', common.mustCall((err) => { assert.strictEqual(err.constructor, SyntaxError); - assert(/SyntaxError/.test(err)); + assert.strictEqual(err.name, 'SyntaxError'); })); diff --git a/test/parallel/test-worker-terminate-null-handler.js b/test/parallel/test-worker-terminate-null-handler.js index 3807501de025f0..9db2e38b5c4920 100644 --- a/test/parallel/test-worker-terminate-null-handler.js +++ b/test/parallel/test-worker-terminate-null-handler.js @@ -11,13 +11,9 @@ const { parentPort } = require('worker_threads'); parentPort.postMessage({ hello: 'world' }); `, { eval: true }); -process.once('beforeExit', common.mustCall(() => { - console.log('beforeExit'); - worker.ref(); -})); +process.once('beforeExit', common.mustCall(() => worker.ref())); worker.on('exit', common.mustCall(() => { - console.log('exit'); worker.terminate().then((res) => assert.strictEqual(res, undefined)); worker.terminate(() => null).then( (res) => assert.strictEqual(res, undefined) diff --git a/test/pummel/test-hash-seed.js b/test/pummel/test-hash-seed.js index 2b7f13593a9aa4..30edca32f6f852 100644 --- a/test/pummel/test-hash-seed.js +++ b/test/pummel/test-hash-seed.js @@ -1,31 +1,26 @@ 'use strict'; // Check that spawn child doesn't create duplicated entries -require('../common'); -const Countdown = require('../common/countdown'); -const REPETITIONS = 2; +const common = require('../common'); +const kRepetitions = 2; const assert = require('assert'); const fixtures = require('../common/fixtures'); -const { spawn } = require('child_process'); +const { promisify, debuglog } = require('util'); +const debug = debuglog('test'); + +const { execFile } = require('child_process'); +const execFilePromise = promisify(execFile); const targetScript = fixtures.path('guess-hash-seed.js'); -const seeds = []; -const requiredCallback = () => { - console.log(`Seeds: ${seeds}`); +const requiredCallback = common.mustCall((results) => { + const seeds = results.map((val) => val.stdout.trim()); + debug(`Seeds: ${seeds}`); assert.strictEqual(new Set(seeds).size, seeds.length); - assert.strictEqual(seeds.length, REPETITIONS); -}; - -const countdown = new Countdown(REPETITIONS, requiredCallback); + assert.strictEqual(seeds.length, kRepetitions); +}); -for (let i = 0; i < REPETITIONS; ++i) { - let result = ''; - const subprocess = spawn(process.execPath, [targetScript]); - subprocess.stdout.setEncoding('utf8'); - subprocess.stdout.on('data', (data) => { result += data; }); +const generateSeed = () => execFilePromise(process.execPath, [targetScript]); +const subprocesses = [...new Array(kRepetitions)].map(generateSeed); - subprocess.on('exit', () => { - seeds.push(result.trim()); - countdown.dec(); - }); -} +Promise.all(subprocesses) + .then(requiredCallback); diff --git a/test/sequential/sequential.status b/test/sequential/sequential.status index 9fc935f00d96ab..3d432b7bbb0dd3 100644 --- a/test/sequential/sequential.status +++ b/test/sequential/sequential.status @@ -15,6 +15,8 @@ test-worker-prof: PASS, FLAKY [$system==linux] [$system==macos] +# https://github.com/nodejs/node/issues/21781 +test-timers-blocking-callback: PASS, FLAKY [$system==solaris] # Also applies to SmartOS diff --git a/test/sequential/test-cluster-net-listen-ipv6only-none.js b/test/sequential/test-cluster-net-listen-ipv6only-none.js index d520b7f25ccf30..ef167f650850bb 100644 --- a/test/sequential/test-cluster-net-listen-ipv6only-none.js +++ b/test/sequential/test-cluster-net-listen-ipv6only-none.js @@ -7,7 +7,6 @@ if (!common.hasIPv6) const assert = require('assert'); const cluster = require('cluster'); const net = require('net'); -const Countdown = require('../common/countdown'); // This test ensures that the `ipv6Only` option in `net.Server.listen()` // works as expected when we use cluster with `SCHED_NONE` schedulingPolicy. @@ -16,9 +15,24 @@ const host = '::'; const WORKER_ACCOUNT = 3; if (cluster.isMaster) { - const workers = new Map(); + const workers = []; - const countdown = new Countdown(WORKER_ACCOUNT, () => { + for (let i = 0; i < WORKER_ACCOUNT; i += 1) { + const myWorker = new Promise((resolve) => { + const worker = cluster.fork().on('exit', common.mustCall((statusCode) => { + assert.strictEqual(statusCode, 0); + })).on('listening', common.mustCall((workerAddress) => { + assert.strictEqual(workerAddress.addressType, 6); + assert.strictEqual(workerAddress.address, host); + assert.strictEqual(workerAddress.port, common.PORT); + resolve(worker); + })); + }); + + workers.push(myWorker); + } + + Promise.all(workers).then(common.mustCall((resolvedWorkers) => { // Make sure the `ipv6Only` option works. This is the part of the test that // requires the whole test to use `common.PORT` rather than port `0`. If it // used port `0` instead, then the operating system can supply a port that @@ -30,24 +44,11 @@ if (cluster.isMaster) { }, common.mustCall(() => { // Exit. server.close(); - workers.forEach((worker) => { - worker.disconnect(); + resolvedWorkers.forEach((resolvedWorker) => { + resolvedWorker.disconnect(); }); })); - }); - - for (let i = 0; i < WORKER_ACCOUNT; i += 1) { - const worker = cluster.fork().on('exit', common.mustCall((statusCode) => { - assert.strictEqual(statusCode, 0); - })).on('listening', common.mustCall((workerAddress) => { - assert.strictEqual(workerAddress.addressType, 6); - assert.strictEqual(workerAddress.address, host); - assert.strictEqual(workerAddress.port, common.PORT); - countdown.dec(); - })); - - workers.set(i, worker); - } + })); } else { net.createServer().listen({ host, diff --git a/test/sequential/test-cluster-net-listen-ipv6only-rr.js b/test/sequential/test-cluster-net-listen-ipv6only-rr.js index a42be88ddf17f0..514e5032823c2c 100644 --- a/test/sequential/test-cluster-net-listen-ipv6only-rr.js +++ b/test/sequential/test-cluster-net-listen-ipv6only-rr.js @@ -7,7 +7,6 @@ if (!common.hasIPv6) const assert = require('assert'); const cluster = require('cluster'); const net = require('net'); -const Countdown = require('../common/countdown'); // This test ensures that the `ipv6Only` option in `net.Server.listen()` // works as expected when we use cluster with `SCHED_RR` schedulingPolicy. @@ -16,37 +15,40 @@ const host = '::'; const WORKER_ACCOUNT = 3; if (cluster.isMaster) { - const workers = new Map(); + const workers = []; let address; - const countdown = new Countdown(WORKER_ACCOUNT, () => { - // Make sure the `ipv6Only` option works. + for (let i = 0; i < WORKER_ACCOUNT; i += 1) { + const myWorker = new Promise((resolve) => { + const worker = cluster.fork().on('exit', common.mustCall((statusCode) => { + assert.strictEqual(statusCode, 0); + })).on('listening', common.mustCall((workerAddress) => { + if (!address) { + address = workerAddress; + } else { + assert.deepStrictEqual(workerAddress, address); + } + resolve(worker); + })); + }); + + workers.push(myWorker); + } + + Promise.all(workers).then(common.mustCall((resolvedWorkers) => { + // Make sure the `ipv6Only` option works. Should be able to use the port on + // IPv4. const server = net.createServer().listen({ host: '0.0.0.0', port: address.port, }, common.mustCall(() => { // Exit. server.close(); - workers.forEach((worker) => { - worker.disconnect(); + resolvedWorkers.forEach((resolvedWorker) => { + resolvedWorker.disconnect(); }); })); - }); - - for (let i = 0; i < WORKER_ACCOUNT; i += 1) { - const worker = cluster.fork().on('exit', common.mustCall((statusCode) => { - assert.strictEqual(statusCode, 0); - })).on('listening', common.mustCall((workerAddress) => { - if (!address) { - address = workerAddress; - } else { - assert.deepStrictEqual(workerAddress, address); - } - countdown.dec(); - })); - - workers.set(i, worker); - } + })); } else { // As the cluster member has the potential to grab any port // from the environment, this can cause collision when master diff --git a/test/sequential/test-inspector-async-hook-setup-at-inspect-brk.js b/test/sequential/test-inspector-async-hook-setup-at-inspect-brk.js index 595f934c0238a8..f4f45a1aa8f4ce 100644 --- a/test/sequential/test-inspector-async-hook-setup-at-inspect-brk.js +++ b/test/sequential/test-inspector-async-hook-setup-at-inspect-brk.js @@ -46,4 +46,4 @@ async function runTests() { assert.strictEqual((await instance.expectShutdown()).exitCode, 55); } -runTests(); +runTests().then(common.mustCall()); diff --git a/test/sequential/test-inspector-async-hook-setup-at-signal.js b/test/sequential/test-inspector-async-hook-setup-at-signal.js index a52627e5012fee..259a40db976e46 100644 --- a/test/sequential/test-inspector-async-hook-setup-at-signal.js +++ b/test/sequential/test-inspector-async-hook-setup-at-signal.js @@ -81,4 +81,4 @@ async function runTests() { instance.kill(); } -runTests(); +runTests().then(common.mustCall()); diff --git a/test/sequential/test-inspector-async-stack-traces-promise-then.js b/test/sequential/test-inspector-async-stack-traces-promise-then.js index f9a30e3f5471ea..40b05c9aacf375 100644 --- a/test/sequential/test-inspector-async-stack-traces-promise-then.js +++ b/test/sequential/test-inspector-async-stack-traces-promise-then.js @@ -68,4 +68,4 @@ function assertArrayIncludes(actual, expected) { `Expected ${actualString} to contain ${expectedString}.`); } -runTests(); +runTests().then(common.mustCall()); diff --git a/test/sequential/test-inspector-async-stack-traces-set-interval.js b/test/sequential/test-inspector-async-stack-traces-set-interval.js index ee37a654958c6a..97b2917b70092c 100644 --- a/test/sequential/test-inspector-async-stack-traces-set-interval.js +++ b/test/sequential/test-inspector-async-stack-traces-set-interval.js @@ -44,4 +44,4 @@ async function runTests() { instance.kill(); } -runTests(); +runTests().then(common.mustCall()); diff --git a/test/sequential/test-inspector-break-e.js b/test/sequential/test-inspector-break-e.js index 6aae729977b5d8..f2a52fcae835fd 100644 --- a/test/sequential/test-inspector-break-e.js +++ b/test/sequential/test-inspector-break-e.js @@ -18,4 +18,4 @@ async function runTests() { assert.strictEqual((await instance.expectShutdown()).exitCode, 0); } -runTests(); +runTests().then(common.mustCall()); diff --git a/test/sequential/test-inspector-break-when-eval.js b/test/sequential/test-inspector-break-when-eval.js index c419a0c530dc4d..7a834e9934b1ab 100644 --- a/test/sequential/test-inspector-break-when-eval.js +++ b/test/sequential/test-inspector-break-when-eval.js @@ -18,7 +18,15 @@ async function setupDebugger(session) { { 'method': 'Runtime.runIfWaitingForDebugger' }, ]; session.send(commands); - await session.waitForNotification('Runtime.consoleAPICalled'); + + await session.waitForNotification('Debugger.paused', 'Initial pause'); + + // NOTE(mmarchini): We wait for the second console.log to ensure we loaded + // every internal module before pausing. See + // https://bugs.chromium.org/p/v8/issues/detail?id=10287. + const waitForReady = session.waitForConsoleOutput('log', 'Ready!'); + session.send({ 'method': 'Debugger.resume' }); + await waitForReady; } async function breakOnLine(session) { @@ -56,7 +64,9 @@ async function stepOverConsoleStatement(session) { } async function runTests() { - const child = new NodeInstance(['--inspect=0'], undefined, script); + // NOTE(mmarchini): Use --inspect-brk to improve avoid undeterministic + // behavior. + const child = new NodeInstance(['--inspect-brk=0'], undefined, script); const session = await child.connectInspectorSession(); await setupDebugger(session); await breakOnLine(session); @@ -65,4 +75,4 @@ async function runTests() { assert.strictEqual((await child.expectShutdown()).exitCode, 0); } -runTests(); +runTests().then(common.mustCall()); diff --git a/test/sequential/test-inspector-console.js b/test/sequential/test-inspector-console.js index 15e2e2e8f63978..bb0f0ce42a3d03 100644 --- a/test/sequential/test-inspector-console.js +++ b/test/sequential/test-inspector-console.js @@ -34,4 +34,4 @@ async function runTest() { session.disconnect(); } -runTest(); +runTest().then(common.mustCall()); diff --git a/test/sequential/test-inspector-contexts.js b/test/sequential/test-inspector-contexts.js index 8c7a68d4650d8a..9cdf2d0017c4be 100644 --- a/test/sequential/test-inspector-contexts.js +++ b/test/sequential/test-inspector-contexts.js @@ -163,4 +163,7 @@ async function testBreakpointHit() { await pausedPromise; } -testContextCreatedAndDestroyed().then(common.mustCall(testBreakpointHit)); +(async function() { + await testContextCreatedAndDestroyed(); + await testBreakpointHit(); +})().then(common.mustCall()); diff --git a/test/sequential/test-inspector-debug-brk-flag.js b/test/sequential/test-inspector-debug-brk-flag.js index f281f2c09ce4b9..f1312b47ad8d8b 100644 --- a/test/sequential/test-inspector-debug-brk-flag.js +++ b/test/sequential/test-inspector-debug-brk-flag.js @@ -27,7 +27,7 @@ async function testBreakpointOnStart(session) { } async function runTests() { - const child = new NodeInstance(['--inspect', '--debug-brk']); + const child = new NodeInstance(['--inspect', '--inspect-brk']); const session = await child.connectInspectorSession(); await testBreakpointOnStart(session); @@ -36,4 +36,4 @@ async function runTests() { assert.strictEqual((await child.expectShutdown()).exitCode, 55); } -runTests(); +runTests().then(common.mustCall()); diff --git a/test/sequential/test-inspector-debug-end.js b/test/sequential/test-inspector-debug-end.js index 789fe9c76323d8..f3e343a0dadb25 100644 --- a/test/sequential/test-inspector-debug-end.js +++ b/test/sequential/test-inspector-debug-end.js @@ -41,4 +41,4 @@ async function runTest() { await testSessionNoCrash(); } -runTest(); +runTest().then(common.mustCall()); diff --git a/test/sequential/test-inspector-exception.js b/test/sequential/test-inspector-exception.js index 9a453eb7deb9d8..f1cd2eca3f30f3 100644 --- a/test/sequential/test-inspector-exception.js +++ b/test/sequential/test-inspector-exception.js @@ -41,4 +41,4 @@ async function runTest() { assert.strictEqual((await child.expectShutdown()).exitCode, 1); } -runTest(); +runTest().then(common.mustCall()); diff --git a/test/sequential/test-inspector-ip-detection.js b/test/sequential/test-inspector-ip-detection.js index 6af06bb4828324..333749de3c13e7 100644 --- a/test/sequential/test-inspector-ip-detection.js +++ b/test/sequential/test-inspector-ip-detection.js @@ -43,4 +43,4 @@ async function test() { instance.kill(); } -test(); +test().then(common.mustCall()); diff --git a/test/sequential/test-inspector-not-blocked-on-idle.js b/test/sequential/test-inspector-not-blocked-on-idle.js index 032efd6a9f62a0..fbf26d15c91f12 100644 --- a/test/sequential/test-inspector-not-blocked-on-idle.js +++ b/test/sequential/test-inspector-not-blocked-on-idle.js @@ -17,4 +17,4 @@ async function runTests() { node.kill(); } -runTests(); +runTests().then(common.mustCall()); diff --git a/test/sequential/test-inspector-overwrite-config.js b/test/sequential/test-inspector-overwrite-config.js index 49f48a59a04b4f..c20df083256120 100644 --- a/test/sequential/test-inspector-overwrite-config.js +++ b/test/sequential/test-inspector-overwrite-config.js @@ -41,4 +41,4 @@ async function runTests() { assert.ok(asserted, 'log statement did not reach the inspector'); } -runTests(); +runTests().then(common.mustCall()); diff --git a/test/sequential/test-inspector-resource-name-to-url.js b/test/sequential/test-inspector-resource-name-to-url.js index 41a98ba219b24c..0465c065b96379 100644 --- a/test/sequential/test-inspector-resource-name-to-url.js +++ b/test/sequential/test-inspector-resource-name-to-url.js @@ -37,4 +37,4 @@ common.skipIfInspectorDisabled(); const { params: { url } } = await promise; strictEqual(url, expected); } -})(); +})().then(common.mustCall()); diff --git a/test/sequential/test-inspector-runtime-evaluate-with-timeout.js b/test/sequential/test-inspector-runtime-evaluate-with-timeout.js index b20aa77a5d5b92..84dff6cdd9c3ed 100644 --- a/test/sequential/test-inspector-runtime-evaluate-with-timeout.js +++ b/test/sequential/test-inspector-runtime-evaluate-with-timeout.js @@ -22,4 +22,4 @@ common.skipIfInspectorDisabled(); } ); session.disconnect(); -})(); +})().then(common.mustCall()); diff --git a/test/sequential/test-inspector-scriptparsed-context.js b/test/sequential/test-inspector-scriptparsed-context.js index 3a4c3f84692be3..e656436879ce63 100644 --- a/test/sequential/test-inspector-scriptparsed-context.js +++ b/test/sequential/test-inspector-scriptparsed-context.js @@ -83,4 +83,4 @@ async function runTests() { assert.strictEqual((await instance.expectShutdown()).exitCode, 0); } -runTests(); +runTests().then(common.mustCall()); diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index e242658e296d6c..f81884ecfd4e46 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -27,4 +27,4 @@ async function runTests() { assert.strictEqual((await child.expectShutdown()).exitCode, 0); } -runTests(); +runTests().then(common.mustCall()); diff --git a/test/sequential/test-inspector-stress-http.js b/test/sequential/test-inspector-stress-http.js index 8d4a2db9570aad..c038b7832ef61d 100644 --- a/test/sequential/test-inspector-stress-http.js +++ b/test/sequential/test-inspector-stress-http.js @@ -28,4 +28,4 @@ async function runTest() { return child.kill(); } -runTest(); +runTest().then(common.mustCall()); diff --git a/test/sequential/test-inspector.js b/test/sequential/test-inspector.js index b5ced631643d5f..a1ef109cf1a9a0 100644 --- a/test/sequential/test-inspector.js +++ b/test/sequential/test-inspector.js @@ -314,4 +314,4 @@ async function runTest() { ); } -runTest(); +runTest().then(common.mustCall()); diff --git a/test/sequential/test-worker-prof.js b/test/sequential/test-worker-prof.js index 80596a76f94f66..f89ff962ff785d 100644 --- a/test/sequential/test-worker-prof.js +++ b/test/sequential/test-worker-prof.js @@ -11,6 +11,7 @@ const { spawnSync } = require('child_process'); // Refs: https://github.com/nodejs/node/issues/24016 if (process.argv[2] === 'child') { + const fs = require('fs'); let files = fs.readdirSync(tmpdir.path); const plog = files.filter((name) => /\.log$/.test(name))[0]; if (plog === undefined) { @@ -19,20 +20,20 @@ if (process.argv[2] === 'child') { } const pingpong = ` let counter = 0; + const fs = require('fs'); const { Worker, parentPort } = require('worker_threads'); parentPort.on('message', (m) => { - if (counter++ === 1024) + if (counter++ === 10) process.exit(0); parentPort.postMessage( - m.toString().split('').reverse().toString().replace(/,/g, '')); + fs.readFileSync(m.toString()).slice(0, 1024 * 1024)); }); `; const { Worker } = require('worker_threads'); - const data = 'x'.repeat(1024); const w = new Worker(pingpong, { eval: true }); w.on('message', (m) => { - w.postMessage(m.toString().split('').reverse().toString().replace(/,/g, '')); + w.postMessage(process.execPath); }); w.on('exit', common.mustCall(() => { @@ -45,7 +46,7 @@ if (process.argv[2] === 'child') { } process.exit(0); })); - w.postMessage(data); + w.postMessage(process.execPath); } else { tmpdir.refresh(); const spawnResult = spawnSync( diff --git a/test/wasi/test-wasi.js b/test/wasi/test-wasi.js index 357eb7531fbea2..89d8f73d684833 100644 --- a/test/wasi/test-wasi.js +++ b/test/wasi/test-wasi.js @@ -57,12 +57,20 @@ if (process.argv[2] === 'wasi-child') { } runWASI({ test: 'cant_dotdot' }); - runWASI({ test: 'clock_getres' }); + + // Tests that are currently unsupported on IBM i PASE. + if (!common.isIBMi) { + runWASI({ test: 'clock_getres' }); + } runWASI({ test: 'exitcode', exitCode: 120 }); runWASI({ test: 'fd_prestat_get_refresh' }); runWASI({ test: 'freopen', stdout: `hello from input2.txt${EOL}` }); runWASI({ test: 'getentropy' }); - runWASI({ test: 'getrusage' }); + + // Tests that are currently unsupported on IBM i PASE. + if (!common.isIBMi) { + runWASI({ test: 'getrusage' }); + } runWASI({ test: 'gettimeofday' }); runWASI({ test: 'link' }); runWASI({ test: 'main_args' }); diff --git a/tools/bootstrap/README.md b/tools/bootstrap/README.md index ec031e637c24a8..2f323331b4b0c3 100644 --- a/tools/bootstrap/README.md +++ b/tools/bootstrap/README.md @@ -1,2 +1,3 @@ -See the main project [BUILDING.md](../../BUILDING.md#boxstarter) for details on -how to use this script. +See the main project +[BUILDING.md](../../BUILDING.md#option-2-automated-install-with-boxstarter) +for details on how to use this script. diff --git a/tools/bootstrap/windows_boxstarter b/tools/bootstrap/windows_boxstarter index 86867ced52ce29..dd6dd25ba03a2f 100644 --- a/tools/bootstrap/windows_boxstarter +++ b/tools/bootstrap/windows_boxstarter @@ -16,9 +16,9 @@ choco install git -params /GitAndUnixToolsOnPath -y choco install python python2 -y -# Installs VS 2017 Build Tools -choco install visualstudio2017buildtools -y -choco install visualstudio2017-workload-vctools -y --params="--add Microsoft.VisualStudio.Component.VC.Tools.ARM64 --add Microsoft.VisualStudio.Component.VC.ATL.ARM64" +# Installs VS 2019 Build Tools +choco install visualstudio2019buildtools -y +choco install visualstudio2019-workload-vctools -y --params="--add Microsoft.VisualStudio.Component.VC.Tools.ARM64 --add Microsoft.VisualStudio.Component.VC.ATL.ARM64" # NASM choco install nasm -y diff --git a/tools/doc/checkLinks.js b/tools/doc/checkLinks.js new file mode 100644 index 00000000000000..60a3f65e5ea9f1 --- /dev/null +++ b/tools/doc/checkLinks.js @@ -0,0 +1,56 @@ +'use strict'; + +const fs = require('fs'); +const { extname, join, resolve } = require('path'); +const unified = require('unified'); +const { pathToFileURL } = require('url'); +const DIR = resolve(process.argv[2]); + +console.log('Running Markdown link checker...'); +findMarkdownFilesRecursively(DIR); + +function* getLinksRecursively(node) { + if (node.url && !node.url.startsWith('#')) { + yield node; + } + for (const child of node.children || []) { + yield* getLinksRecursively(child); + } +} + +function findMarkdownFilesRecursively(dirPath) { + const entries = fs.readdirSync(dirPath, { withFileTypes: true }); + + for (const entry of entries) { + const path = join(dirPath, entry.name); + + if ( + entry.isDirectory() && + entry.name !== 'api' && + entry.name !== 'fixtures' && + entry.name !== 'changelogs' && + entry.name !== 'deps' && + entry.name !== 'node_modules' + ) { + findMarkdownFilesRecursively(path); + } else if (entry.isFile() && extname(entry.name) === '.md') { + checkFile(path); + } + } +} + +function checkFile(path) { + const tree = unified() + .use(require('remark-parse')) + .parse(fs.readFileSync(path)); + + const base = pathToFileURL(path); + for (const node of getLinksRecursively(tree)) { + const targetURL = new URL(node.url, base); + if (targetURL.protocol === 'file:' && !fs.existsSync(targetURL)) { + const { line, column } = node.position.start; + console.error(`Broken link at ${path}:${line}:${column} (${node.url})`); + process.exitCode = 1; + } + } +} diff --git a/tools/eslint-rules/crypto-check.js b/tools/eslint-rules/crypto-check.js index 1087fcaa39151a..93a0c1ec865f38 100644 --- a/tools/eslint-rules/crypto-check.js +++ b/tools/eslint-rules/crypto-check.js @@ -71,7 +71,7 @@ module.exports = function(context) { if (missingCheckNodes.length > 0) { requireNodes.forEach((requireNode) => { const beforeAllChecks = missingCheckNodes.every((checkNode) => { - return requireNode.start < checkNode.start; + return requireNode.range[0] < checkNode.range[0]; }); if (beforeAllChecks) { diff --git a/tools/gyp/pylib/gyp/generator/make.py b/tools/gyp/pylib/gyp/generator/make.py index 26cf88cccf275d..848418d3fb6f16 100644 --- a/tools/gyp/pylib/gyp/generator/make.py +++ b/tools/gyp/pylib/gyp/generator/make.py @@ -201,7 +201,7 @@ def CalculateGeneratorInputInfo(params): quiet_cmd_link = LINK($(TOOLSET)) $@ quiet_cmd_link_host = LINK($(TOOLSET)) $@ cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) -cmd_link_host = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS) +cmd_link_host = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) # Other shared-object link notes: # - Set SONAME to the library filename so our binaries don't reference diff --git a/tools/icu/icutrim.py b/tools/icu/icutrim.py index 25bd99d9cb260d..f857e73bbce298 100755 --- a/tools/icu/icutrim.py +++ b/tools/icu/icutrim.py @@ -13,6 +13,7 @@ from __future__ import print_function +import io import json import optparse import os @@ -159,9 +160,8 @@ def runcmd(tool, cmd, doContinue=False): return rc ## STEP 0 - read in json config -fi= open(options.filterfile, "rb") -config=json.load(fi) -fi.close() +with io.open(options.filterfile, encoding='utf-8') as fi: + config = json.load(fi) if options.locales: config["variables"] = config.get("variables", {}) @@ -285,10 +285,9 @@ def addTreeByType(tree, mytree): # read in the resource list for the tree treelistfile = os.path.join(options.tmpdir,"%s.lst" % tree) runcmd("iculslocs", "-i %s -N %s -T %s -l > %s" % (outfile, dataname, tree, treelistfile)) - fi = open(treelistfile, 'rb') - treeitems = fi.readlines() - trees[tree]["locs"] = [treeitems[i].strip() for i in range(len(treeitems))] - fi.close() + with io.open(treelistfile, 'r', encoding='utf-8') as fi: + treeitems = fi.readlines() + trees[tree]["locs"] = [line.strip() for line in treeitems] if tree not in config.get("trees", {}): print(" Warning: filter file %s does not mention trees.%s - will be kept as-is" % (options.filterfile, tree)) else: @@ -317,12 +316,12 @@ def removeList(count=0): erritems = fi.readlines() fi.close() #Item zone/zh_Hant_TW.res depends on missing item zone/zh_Hant.res - pat = re.compile("""^Item ([^ ]+) depends on missing item ([^ ]+).*""") + pat = re.compile(bytes(r"^Item ([^ ]+) depends on missing item ([^ ]+).*", 'utf-8')) for i in range(len(erritems)): line = erritems[i].strip() m = pat.match(line) if m: - toDelete = m.group(1) + toDelete = m.group(1).decode("utf-8") if(options.verbose > 5): print("<< %s added to delete" % toDelete) remove.add(toDelete) diff --git a/tools/node-lint-md-cli-rollup/package-lock.json b/tools/node-lint-md-cli-rollup/package-lock.json index 5a8728bc98a7cc..e6597cfdd506fe 100644 --- a/tools/node-lint-md-cli-rollup/package-lock.json +++ b/tools/node-lint-md-cli-rollup/package-lock.json @@ -75,9 +75,9 @@ "integrity": "sha512-FvUupuM3rlRsRtCN+fDudtmytGO6iHJuuRKS1Ss0pG5z8oX0diNEw94UEL7hgDbpN94rgaK5R7sWm6RrSkZuAQ==" }, "acorn": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz", - "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz", + "integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==", "dev": true }, "ansi-regex": { diff --git a/tools/node_modules/eslint/README.md b/tools/node_modules/eslint/README.md index 0cde09fc602b17..da75b5c149d799 100644 --- a/tools/node_modules/eslint/README.md +++ b/tools/node_modules/eslint/README.md @@ -1,9 +1,12 @@ -[![NPM version][npm-image]][npm-url] +[![NPM version](https://img.shields.io/npm/v/eslint.svg)](https://www.npmjs.com/package/eslint) +[![Downloads](https://img.shields.io/npm/dm/eslint.svg)](https://www.npmjs.com/package/eslint) [![Build Status](https://github.com/eslint/eslint/workflows/CI/badge.svg)](https://github.com/eslint/eslint/actions) -[![Downloads][downloads-image]][downloads-url] -[![Bountysource](https://www.bountysource.com/badge/tracker?tracker_id=282608)](https://www.bountysource.com/trackers/282608-eslint?utm_source=282608&utm_medium=shield&utm_campaign=TRACKER_BADGE) -[![Join the chat at https://gitter.im/eslint/eslint](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/eslint/eslint?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Feslint%2Feslint.svg?type=shield)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Feslint%2Feslint?ref=badge_shield) +
+[![Open Collective Backers](https://img.shields.io/opencollective/backers/eslint)](https://opencollective.com/eslint) +[![Open Collective Sponsors](https://img.shields.io/opencollective/sponsors/eslint)](https://opencollective.com/eslint) +[![Join the chat at https://gitter.im/eslint/eslint](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/eslint/eslint?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Follow us on Twitter](https://img.shields.io/twitter/follow/geteslint?label=Follow&style=social)](https://twitter.com/intent/user?screen_name=geteslint) # ESLint @@ -39,7 +42,7 @@ ESLint is a tool for identifying and reporting on patterns found in ECMAScript/J ## Installation and Usage -Prerequisites: [Node.js](https://nodejs.org/) (`^8.10.0`, `^10.13.0`, or `>=11.10.1`) built with SSL support. (If you are using an official Node.js distribution, SSL is always built in.) +Prerequisites: [Node.js](https://nodejs.org/) (`^10.12.0`, or `>=12.0.0`) built with SSL support. (If you are using an official Node.js distribution, SSL is always built in.) You can install ESLint using npm: @@ -185,16 +188,6 @@ The people who manage releases, review feature requests, and meet regularly to e Nicholas C. Zakas - -
-Kevin Partington -
- - -
-Ilya Volodin -
-
Brandon Mills @@ -209,11 +202,6 @@ Toru Nagashima
Kai Cataldo
- - -
-Teddy Katz -
@@ -236,16 +224,16 @@ The people who review and implement new features. The people who review and fix bugs and help triage issues.
- -
-Gyandeep Singh -
-

Pig Fang
+ +
+YeonJuan +
+

Milos Djermanovic @@ -262,17 +250,11 @@ The following companies, organizations, and individuals support ESLint's ongoing

Gold Sponsors

-

Shopify Salesforce Badoo Airbnb Facebook Open Source

Silver Sponsors

+

Shopify Salesforce MagicLab Airbnb

Silver Sponsors

AMP Project

Bronze Sponsors

-

UI UX Design Agencies Top Web Design Agencies Bugsnag Stability Monitoring Crosswordsolver Codacy Mixpanel VPS Server Free Icons by Icons8 EduBirdie clay Discord ThemeIsle TekHattan Marfeel Fire Stick Tricks JSHeroes

+

Kasinot.fi Pelisivut Nettikasinot.org BonusFinder Deutschland Top Web Design Agencies Bugsnag Stability Monitoring Mixpanel VPS Server Free Icons by Icons8 UI UX Design Agencies clay Discord ThemeIsle TekHattan Marfeel Fire Stick Tricks

## Technology Sponsors * Site search ([eslint.org](https://eslint.org)) is sponsored by [Algolia](https://www.algolia.com) - - -[npm-image]: https://img.shields.io/npm/v/eslint.svg?style=flat-square -[npm-url]: https://www.npmjs.com/package/eslint -[downloads-image]: https://img.shields.io/npm/dm/eslint.svg?style=flat-square -[downloads-url]: https://www.npmjs.com/package/eslint diff --git a/tools/node_modules/eslint/conf/category-list.json b/tools/node_modules/eslint/conf/category-list.json index 5427667b09e332..6609734950a443 100644 --- a/tools/node_modules/eslint/conf/category-list.json +++ b/tools/node_modules/eslint/conf/category-list.json @@ -10,12 +10,12 @@ ], "deprecated": { "name": "Deprecated", - "description": "These rules have been deprecated in accordance with the [deprecation policy](/docs/user-guide/rule-deprecation), and replaced by newer rules:", + "description": "These rules have been deprecated in accordance with the deprecation policy, and replaced by newer rules:", "rules": [] }, "removed": { "name": "Removed", - "description": "These rules from older versions of ESLint (before the [deprecation policy](/docs/user-guide/rule-deprecation) existed) have been replaced by newer rules:", + "description": "These rules from older versions of ESLint (before the deprecation policy existed) have been replaced by newer rules:", "rules": [ { "removed": "generator-star", "replacedBy": ["generator-star-spacing"] }, { "removed": "global-strict", "replacedBy": ["strict"] }, diff --git a/tools/node_modules/eslint/conf/default-cli-options.js b/tools/node_modules/eslint/conf/default-cli-options.js index 0f7b377fb362ec..e09a829d17cee2 100644 --- a/tools/node_modules/eslint/conf/default-cli-options.js +++ b/tools/node_modules/eslint/conf/default-cli-options.js @@ -12,7 +12,7 @@ module.exports = { useEslintrc: true, envs: [], globals: [], - extensions: [".js"], + extensions: null, ignore: true, ignorePath: void 0, cache: false, diff --git a/tools/node_modules/eslint/conf/environments.js b/tools/node_modules/eslint/conf/environments.js index 10e6fdaa70fca5..90589b1c3270f3 100644 --- a/tools/node_modules/eslint/conf/environments.js +++ b/tools/node_modules/eslint/conf/environments.js @@ -15,7 +15,7 @@ const globals = require("globals"); //------------------------------------------------------------------------------ /** - * Get the object that has differentce. + * Get the object that has difference. * @param {Record} current The newer object. * @param {Record} prev The older object. * @returns {Record} The difference object. @@ -40,7 +40,8 @@ const newGlobals2017 = { const newGlobals2020 = { BigInt: false, BigInt64Array: false, - BigUint64Array: false + BigUint64Array: false, + globalThis: false }; //------------------------------------------------------------------------------ diff --git a/tools/node_modules/eslint/conf/eslint-recommended.js b/tools/node_modules/eslint/conf/eslint-recommended.js index e915ec449040e9..2137685fb7c63e 100644 --- a/tools/node_modules/eslint/conf/eslint-recommended.js +++ b/tools/node_modules/eslint/conf/eslint-recommended.js @@ -26,6 +26,7 @@ module.exports = { "no-delete-var": "error", "no-dupe-args": "error", "no-dupe-class-members": "error", + "no-dupe-else-if": "error", "no-dupe-keys": "error", "no-duplicate-case": "error", "no-empty": "error", @@ -37,6 +38,7 @@ module.exports = { "no-fallthrough": "error", "no-func-assign": "error", "no-global-assign": "error", + "no-import-assign": "error", "no-inner-declarations": "error", "no-invalid-regexp": "error", "no-irregular-whitespace": "error", @@ -49,6 +51,7 @@ module.exports = { "no-redeclare": "error", "no-regex-spaces": "error", "no-self-assign": "error", + "no-setter-return": "error", "no-shadow-restricted-names": "error", "no-sparse-arrays": "error", "no-this-before-super": "error", diff --git a/tools/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js b/tools/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js index 52703a873bb67e..b53f67bd9dce6c 100644 --- a/tools/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js +++ b/tools/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js @@ -26,6 +26,7 @@ const os = require("os"); const path = require("path"); const { validateConfigArray } = require("../shared/config-validator"); +const { emitDeprecationWarning } = require("../shared/deprecation-warnings"); const { ConfigArrayFactory } = require("./config-array-factory"); const { ConfigArray, ConfigDependency, IgnorePattern } = require("./config-array"); const loadRules = require("./load-rules"); @@ -105,6 +106,7 @@ function createBaseConfigArray({ */ if (rulePaths && rulePaths.length > 0) { baseConfigArray.push({ + type: "config", name: "--rulesdir", filePath: "", plugins: { @@ -138,6 +140,7 @@ function createBaseConfigArray({ function createCLIConfigArray({ cliConfigData, configArrayFactory, + cwd, ignorePath, specificConfigPath }) { @@ -156,7 +159,7 @@ function createCLIConfigArray({ cliConfigArray.unshift( ...configArrayFactory.loadFile( specificConfigPath, - { name: "--config" } + { name: "--config", basePath: cwd } ) ); } @@ -196,7 +199,7 @@ class CascadingConfigArrayFactory { cliConfig: cliConfigData = null, cwd = process.cwd(), ignorePath, - resolvePluginsRelativeTo = cwd, + resolvePluginsRelativeTo, rulePaths = [], specificConfigPath = null, useEslintrc = true @@ -218,6 +221,7 @@ class CascadingConfigArrayFactory { cliConfigArray: createCLIConfigArray({ cliConfigData, configArrayFactory, + cwd, ignorePath, specificConfigPath }), @@ -290,10 +294,11 @@ class CascadingConfigArrayFactory { /** * Load and normalize config files from the ancestor directories. * @param {string} directoryPath The path to a leaf directory. + * @param {boolean} configsExistInSubdirs `true` if configurations exist in subdirectories. * @returns {ConfigArray} The loaded config. * @private */ - _loadConfigInAncestors(directoryPath) { + _loadConfigInAncestors(directoryPath, configsExistInSubdirs = false) { const { baseConfigArray, configArrayFactory, @@ -320,6 +325,16 @@ class CascadingConfigArrayFactory { // Consider this is root. if (directoryPath === homePath && cwd !== homePath) { debug("Stop traversing because of considered root."); + if (configsExistInSubdirs) { + const filePath = ConfigArrayFactory.getPathToConfigFileInDirectory(directoryPath); + + if (filePath) { + emitDeprecationWarning( + filePath, + "ESLINT_PERSONAL_CONFIG_SUPPRESS" + ); + } + } return this._cacheConfig(directoryPath, baseConfigArray); } @@ -344,7 +359,10 @@ class CascadingConfigArrayFactory { // Load from the ancestors and merge it. const parentPath = path.dirname(directoryPath); const parentConfigArray = parentPath && parentPath !== directoryPath - ? this._loadConfigInAncestors(parentPath) + ? this._loadConfigInAncestors( + parentPath, + configsExistInSubdirs || configArray.length > 0 + ) : baseConfigArray; if (configArray.length > 0) { @@ -400,12 +418,29 @@ class CascadingConfigArrayFactory { configArray.every(c => !c.filePath) && cliConfigArray.every(c => !c.filePath) // `--config` option can be a file. ) { - debug("Loading the config file of the home directory."); + const homePath = os.homedir(); + + debug("Loading the config file of the home directory:", homePath); - finalConfigArray = configArrayFactory.loadInDirectory( - os.homedir(), - { name: "PersonalConfig", parent: finalConfigArray } + const personalConfigArray = configArrayFactory.loadInDirectory( + homePath, + { name: "PersonalConfig" } ); + + if ( + personalConfigArray.length > 0 && + !directoryPath.startsWith(homePath) + ) { + const lastElement = + personalConfigArray[personalConfigArray.length - 1]; + + emitDeprecationWarning( + lastElement.filePath, + "ESLINT_PERSONAL_CONFIG_LOAD" + ); + } + + finalConfigArray = finalConfigArray.concat(personalConfigArray); } // Apply CLI options. diff --git a/tools/node_modules/eslint/lib/cli-engine/cli-engine.js b/tools/node_modules/eslint/lib/cli-engine/cli-engine.js index 22336a91de2909..72d1fa4d5dcd5d 100644 --- a/tools/node_modules/eslint/lib/cli-engine/cli-engine.js +++ b/tools/node_modules/eslint/lib/cli-engine/cli-engine.js @@ -57,7 +57,7 @@ const validFixTypes = new Set(["problem", "suggestion", "layout"]); * @property {string} configFile The configuration file to use. * @property {string} cwd The value to use for the current working directory. * @property {string[]} envs An array of environments to load. - * @property {string[]} extensions An array of file extensions to check. + * @property {string[]|null} extensions An array of file extensions to check. * @property {boolean|Function} fix Execute in autofix mode. If a function, should return a boolean. * @property {string[]} fixTypes Array of rule types to apply fixes for. * @property {string[]} globals An array of global variables to declare. @@ -201,7 +201,7 @@ function calculateStatsPerRun(results) { * @param {boolean} config.fix If `true` then it does fix. * @param {boolean} config.allowInlineConfig If `true` then it uses directive comments. * @param {boolean} config.reportUnusedDisableDirectives If `true` then it reports unused `eslint-disable` comments. - * @param {RegExp} config.extensionRegExp The `RegExp` object that tests if a file path has the allowed file extensions. + * @param {FileEnumerator} config.fileEnumerator The file enumerator to check if a path is a target or not. * @param {Linter} config.linter The linter instance to verify. * @returns {LintResult} The result of linting. * @private @@ -214,7 +214,7 @@ function verifyText({ fix, allowInlineConfig, reportUnusedDisableDirectives, - extensionRegExp, + fileEnumerator, linter }) { const filePath = providedFilePath || ""; @@ -238,13 +238,11 @@ function verifyText({ /** * Check if the linter should adopt a given code block or not. - * Currently, the linter adopts code blocks if the name matches `--ext` option. - * In the future, `overrides` in the configuration would affect the adoption (https://github.com/eslint/rfcs/pull/20). * @param {string} blockFilename The virtual filename of a code block. * @returns {boolean} `true` if the linter should adopt the code block. */ filterCodeBlock(blockFilename) { - return extensionRegExp.test(blockFilename); + return fileEnumerator.isTargetPath(blockFilename); } } ); @@ -278,16 +276,14 @@ function verifyText({ */ function createIgnoreResult(filePath, baseDir) { let message; - const isHidden = /^\./u.test(path.basename(filePath)); + const isHidden = filePath.split(path.sep) + .find(segment => /^\./u.test(segment)); const isInNodeModules = baseDir && path.relative(baseDir, filePath).startsWith("node_modules"); - const isInBowerComponents = baseDir && path.relative(baseDir, filePath).startsWith("bower_components"); if (isHidden) { message = "File ignored by default. Use a negated ignore pattern (like \"--ignore-pattern '!'\") to override."; } else if (isInNodeModules) { message = "File ignored by default. Use \"--ignore-pattern '!node_modules/*'\" to override."; - } else if (isInBowerComponents) { - message = "File ignored by default. Use \"--ignore-pattern '!bower_components/*'\" to override."; } else { message = "File ignored because of a matching ignore pattern. Use \"--no-ignore\" to override."; } @@ -704,7 +700,7 @@ class CLIEngine { return patterns.filter(Boolean); } - const extensions = options.extensions.map(ext => ext.replace(/^\./u, "")); + const extensions = (options.extensions || [".js"]).map(ext => ext.replace(/^\./u, "")); const dirSuffix = `/**/*.{${extensions.join(",")}}`; return patterns.filter(Boolean).map(pathname => { @@ -803,7 +799,7 @@ class CLIEngine { fix, allowInlineConfig, reportUnusedDisableDirectives, - extensionRegExp: fileEnumerator.extensionRegExp, + fileEnumerator, linter }); @@ -891,7 +887,7 @@ class CLIEngine { fix, allowInlineConfig, reportUnusedDisableDirectives, - extensionRegExp: fileEnumerator.extensionRegExp, + fileEnumerator, linter })); } diff --git a/tools/node_modules/eslint/lib/cli-engine/config-array-factory.js b/tools/node_modules/eslint/lib/cli-engine/config-array-factory.js index 76c4ccd70212cd..b1429af6ad95cf 100644 --- a/tools/node_modules/eslint/lib/cli-engine/config-array-factory.js +++ b/tools/node_modules/eslint/lib/cli-engine/config-array-factory.js @@ -90,7 +90,24 @@ const configFilenames = [ * @typedef {Object} ConfigArrayFactoryInternalSlots * @property {Map} additionalPluginPool The map for additional plugins. * @property {string} cwd The path to the current working directory. - * @property {string} resolvePluginsRelativeTo An absolute path the the directory that plugins should be resolved from. + * @property {string | undefined} resolvePluginsRelativeTo An absolute path the the directory that plugins should be resolved from. + */ + +/** + * @typedef {Object} ConfigArrayFactoryLoadingContext + * @property {string} filePath The path to the current configuration. + * @property {string} matchBasePath The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`. + * @property {string} name The name of the current configuration. + * @property {string} pluginBasePath The base path to resolve plugins. + * @property {"config" | "ignore" | "implicit-processor"} type The type of the current configuration. This is `"config"` in normal. This is `"ignore"` if it came from `.eslintignore`. This is `"implicit-processor"` if it came from legacy file-extension processors. + */ + +/** + * @typedef {Object} ConfigArrayFactoryLoadingContext + * @property {string} filePath The path to the current configuration. + * @property {string} matchBasePath The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`. + * @property {string} name The name of the current configuration. + * @property {"config" | "ignore" | "implicit-processor"} type The type of the current configuration. This is `"config"` in normal. This is `"ignore"` if it came from `.eslintignore`. This is `"implicit-processor"` if it came from legacy file-extension processors. */ /** @type {WeakMap} */ @@ -328,21 +345,39 @@ function writeDebugLogForLoading(request, relativeTo, filePath) { } /** - * Concatenate two config data. - * @param {IterableIterator|null} elements The config elements. - * @param {ConfigArray|null} parentConfigArray The parent config array. - * @returns {ConfigArray} The concatenated config array. + * Create a new context with default values. + * @param {ConfigArrayFactoryInternalSlots} slots The internal slots. + * @param {"config" | "ignore" | "implicit-processor" | undefined} providedType The type of the current configuration. Default is `"config"`. + * @param {string | undefined} providedName The name of the current configuration. Default is the relative path from `cwd` to `filePath`. + * @param {string | undefined} providedFilePath The path to the current configuration. Default is empty string. + * @param {string | undefined} providedMatchBasePath The type of the current configuration. Default is the directory of `filePath` or `cwd`. + * @returns {ConfigArrayFactoryLoadingContext} The created context. */ -function createConfigArray(elements, parentConfigArray) { - if (!elements) { - return parentConfigArray || new ConfigArray(); - } - const configArray = new ConfigArray(...elements); - - if (parentConfigArray && !configArray.isRoot()) { - configArray.unshift(...parentConfigArray); - } - return configArray; +function createContext( + { cwd, resolvePluginsRelativeTo }, + providedType, + providedName, + providedFilePath, + providedMatchBasePath +) { + const filePath = providedFilePath + ? path.resolve(cwd, providedFilePath) + : ""; + const matchBasePath = + (providedMatchBasePath && path.resolve(cwd, providedMatchBasePath)) || + (filePath && path.dirname(filePath)) || + cwd; + const name = + providedName || + (filePath && path.relative(cwd, filePath)) || + ""; + const pluginBasePath = + resolvePluginsRelativeTo || + (filePath && path.dirname(filePath)) || + cwd; + const type = providedType || "config"; + + return { filePath, matchBasePath, name, pluginBasePath, type }; } /** @@ -377,63 +412,118 @@ class ConfigArrayFactory { constructor({ additionalPluginPool = new Map(), cwd = process.cwd(), - resolvePluginsRelativeTo = cwd + resolvePluginsRelativeTo } = {}) { - internalSlotsMap.set(this, { additionalPluginPool, cwd, resolvePluginsRelativeTo: path.resolve(cwd, resolvePluginsRelativeTo) }); + internalSlotsMap.set(this, { + additionalPluginPool, + cwd, + resolvePluginsRelativeTo: + resolvePluginsRelativeTo && + path.resolve(cwd, resolvePluginsRelativeTo) + }); } /** * Create `ConfigArray` instance from a config data. * @param {ConfigData|null} configData The config data to create. * @param {Object} [options] The options. + * @param {string} [options.basePath] The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`. * @param {string} [options.filePath] The path to this config data. * @param {string} [options.name] The config name. - * @param {ConfigArray} [options.parent] The parent config array. * @returns {ConfigArray} Loaded config. */ - create(configData, { filePath, name, parent } = {}) { - return createConfigArray( - configData - ? this._normalizeConfigData(configData, filePath, name) - : null, - parent - ); + create(configData, { basePath, filePath, name } = {}) { + if (!configData) { + return new ConfigArray(); + } + + const slots = internalSlotsMap.get(this); + const ctx = createContext(slots, "config", name, filePath, basePath); + const elements = this._normalizeConfigData(configData, ctx); + + return new ConfigArray(...elements); } /** * Load a config file. * @param {string} filePath The path to a config file. * @param {Object} [options] The options. + * @param {string} [options.basePath] The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`. * @param {string} [options.name] The config name. - * @param {ConfigArray} [options.parent] The parent config array. * @returns {ConfigArray} Loaded config. */ - loadFile(filePath, { name, parent } = {}) { - const { cwd } = internalSlotsMap.get(this); - const absolutePath = path.resolve(cwd, filePath); + loadFile(filePath, { basePath, name } = {}) { + const slots = internalSlotsMap.get(this); + const ctx = createContext(slots, "config", name, filePath, basePath); - return createConfigArray( - this._loadConfigData(absolutePath, name), - parent - ); + return new ConfigArray(...this._loadConfigData(ctx)); } /** * Load the config file on a given directory if exists. * @param {string} directoryPath The path to a directory. * @param {Object} [options] The options. + * @param {string} [options.basePath] The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`. * @param {string} [options.name] The config name. - * @param {ConfigArray} [options.parent] The parent config array. * @returns {ConfigArray} Loaded config. An empty `ConfigArray` if any config doesn't exist. */ - loadInDirectory(directoryPath, { name, parent } = {}) { - const { cwd } = internalSlotsMap.get(this); - const absolutePath = path.resolve(cwd, directoryPath); + loadInDirectory(directoryPath, { basePath, name } = {}) { + const slots = internalSlotsMap.get(this); - return createConfigArray( - this._loadConfigDataInDirectory(absolutePath, name), - parent - ); + for (const filename of configFilenames) { + const ctx = createContext( + slots, + "config", + name, + path.join(directoryPath, filename), + basePath + ); + + if (fs.existsSync(ctx.filePath)) { + let configData; + + try { + configData = loadConfigFile(ctx.filePath); + } catch (error) { + if (!error || error.code !== "ESLINT_CONFIG_FIELD_NOT_FOUND") { + throw error; + } + } + + if (configData) { + debug(`Config file found: ${ctx.filePath}`); + return new ConfigArray( + ...this._normalizeConfigData(configData, ctx) + ); + } + } + } + + debug(`Config file not found on ${directoryPath}`); + return new ConfigArray(); + } + + /** + * Check if a config file on a given directory exists or not. + * @param {string} directoryPath The path to a directory. + * @returns {string | null} The path to the found config file. If not found then null. + */ + static getPathToConfigFileInDirectory(directoryPath) { + for (const filename of configFilenames) { + const filePath = path.join(directoryPath, filename); + + if (fs.existsSync(filePath)) { + if (filename === "package.json") { + try { + loadPackageJSONConfigFile(filePath); + return filePath; + } catch (error) { /* ignore */ } + } else { + return filePath; + } + } + } + return null; } /** @@ -442,13 +532,18 @@ class ConfigArrayFactory { * @returns {ConfigArray} Loaded config. An empty `ConfigArray` if any config doesn't exist. */ loadESLintIgnore(filePath) { - const { cwd } = internalSlotsMap.get(this); - const absolutePath = path.resolve(cwd, filePath); - const name = path.relative(cwd, absolutePath); - const ignorePatterns = loadESLintIgnoreFile(absolutePath); + const slots = internalSlotsMap.get(this); + const ctx = createContext( + slots, + "ignore", + void 0, + filePath, + slots.cwd + ); + const ignorePatterns = loadESLintIgnoreFile(ctx.filePath); - return createConfigArray( - this._normalizeESLintIgnoreData(ignorePatterns, absolutePath, name) + return new ConfigArray( + ...this._normalizeESLintIgnoreData(ignorePatterns, ctx) ); } @@ -457,9 +552,9 @@ class ConfigArrayFactory { * @returns {ConfigArray} Loaded config. An empty `ConfigArray` if any config doesn't exist. */ loadDefaultESLintIgnore() { - const { cwd } = internalSlotsMap.get(this); - const eslintIgnorePath = path.resolve(cwd, ".eslintignore"); - const packageJsonPath = path.resolve(cwd, "package.json"); + const slots = internalSlotsMap.get(this); + const eslintIgnorePath = path.resolve(slots.cwd, ".eslintignore"); + const packageJsonPath = path.resolve(slots.cwd, "package.json"); if (fs.existsSync(eslintIgnorePath)) { return this.loadESLintIgnore(eslintIgnorePath); @@ -471,12 +566,16 @@ class ConfigArrayFactory { if (!Array.isArray(data.eslintIgnore)) { throw new Error("Package.json eslintIgnore property requires an array of paths"); } - return createConfigArray( - this._normalizeESLintIgnoreData( - data.eslintIgnore, - packageJsonPath, - "eslintIgnore in package.json" - ) + const ctx = createContext( + slots, + "ignore", + "eslintIgnore in package.json", + packageJsonPath, + slots.cwd + ); + + return new ConfigArray( + ...this._normalizeESLintIgnoreData(data.eslintIgnore, ctx) ); } } @@ -486,65 +585,25 @@ class ConfigArrayFactory { /** * Load a given config file. - * @param {string} filePath The path to a config file. - * @param {string} name The config name. + * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. * @returns {IterableIterator} Loaded config. * @private */ - _loadConfigData(filePath, name) { - return this._normalizeConfigData( - loadConfigFile(filePath), - filePath, - name - ); - } - - /** - * Load the config file in a given directory if exists. - * @param {string} directoryPath The path to a directory. - * @param {string} name The config name. - * @returns {IterableIterator | null} Loaded config. `null` if any config doesn't exist. - * @private - */ - _loadConfigDataInDirectory(directoryPath, name) { - for (const filename of configFilenames) { - const filePath = path.join(directoryPath, filename); - - if (fs.existsSync(filePath)) { - let configData; - - try { - configData = loadConfigFile(filePath); - } catch (error) { - if (!error || error.code !== "ESLINT_CONFIG_FIELD_NOT_FOUND") { - throw error; - } - } - - if (configData) { - debug(`Config file found: ${filePath}`); - return this._normalizeConfigData(configData, filePath, name); - } - } - } - - debug(`Config file not found on ${directoryPath}`); - return null; + _loadConfigData(ctx) { + return this._normalizeConfigData(loadConfigFile(ctx.filePath), ctx); } /** * Normalize a given `.eslintignore` data to config array elements. * @param {string[]} ignorePatterns The patterns to ignore files. - * @param {string|undefined} filePath The file path of this config. - * @param {string|undefined} name The name of this config. + * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. * @returns {IterableIterator} The normalized config. * @private */ - *_normalizeESLintIgnoreData(ignorePatterns, filePath, name) { + *_normalizeESLintIgnoreData(ignorePatterns, ctx) { const elements = this._normalizeObjectConfigData( { ignorePatterns }, - filePath, - name + ctx ); // Set `ignorePattern.loose` flag for backward compatibility. @@ -559,53 +618,38 @@ class ConfigArrayFactory { /** * Normalize a given config to an array. * @param {ConfigData} configData The config data to normalize. - * @param {string|undefined} providedFilePath The file path of this config. - * @param {string|undefined} providedName The name of this config. + * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. * @returns {IterableIterator} The normalized config. * @private */ - _normalizeConfigData(configData, providedFilePath, providedName) { - const { cwd } = internalSlotsMap.get(this); - const filePath = providedFilePath - ? path.resolve(cwd, providedFilePath) - : ""; - const name = providedName || (filePath && path.relative(cwd, filePath)); - - validateConfigSchema(configData, name || filePath); - - return this._normalizeObjectConfigData(configData, filePath, name); + _normalizeConfigData(configData, ctx) { + validateConfigSchema(configData, ctx.name || ctx.filePath); + return this._normalizeObjectConfigData(configData, ctx); } /** * Normalize a given config to an array. * @param {ConfigData|OverrideConfigData} configData The config data to normalize. - * @param {string} filePath The file path of this config. - * @param {string} name The name of this config. + * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. * @returns {IterableIterator} The normalized config. * @private */ - *_normalizeObjectConfigData(configData, filePath, name) { - const { cwd } = internalSlotsMap.get(this); + *_normalizeObjectConfigData(configData, ctx) { const { files, excludedFiles, ...configBody } = configData; - const basePath = filePath ? path.dirname(filePath) : cwd; - const criteria = OverrideTester.create(files, excludedFiles, basePath); - const elements = - this._normalizeObjectConfigDataBody(configBody, filePath, name); + const criteria = OverrideTester.create( + files, + excludedFiles, + ctx.matchBasePath + ); + const elements = this._normalizeObjectConfigDataBody(configBody, ctx); // Apply the criteria to every element. for (const element of elements) { - // Adopt the base path of the entry file (the outermost base path). - if (element.criteria) { - element.criteria.basePath = basePath; - } - if (element.ignorePattern) { - element.ignorePattern.basePath = basePath; - } - /* - * Merge the criteria; this is for only file extension processors in - * `overrides` section for now. + * Merge the criteria. + * This is for the `overrides` entries that came from the + * configurations of `overrides[].extends`. */ element.criteria = OverrideTester.and(criteria, element.criteria); @@ -624,8 +668,7 @@ class ConfigArrayFactory { /** * Normalize a given config to an array. * @param {ConfigData} configData The config data to normalize. - * @param {string} filePath The file path of this config. - * @param {string} name The name of this config. + * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. * @returns {IterableIterator} The normalized config. * @private */ @@ -646,37 +689,35 @@ class ConfigArrayFactory { settings, overrides: overrideList = [] }, - filePath, - name + ctx ) { const extendList = Array.isArray(extend) ? extend : [extend]; const ignorePattern = ignorePatterns && new IgnorePattern( Array.isArray(ignorePatterns) ? ignorePatterns : [ignorePatterns], - filePath ? path.dirname(filePath) : internalSlotsMap.get(this).cwd + ctx.matchBasePath ); // Flatten `extends`. for (const extendName of extendList.filter(Boolean)) { - yield* this._loadExtends(extendName, filePath, name); + yield* this._loadExtends(extendName, ctx); } // Load parser & plugins. - const parser = - parserName && this._loadParser(parserName, filePath, name); - const plugins = - pluginList && this._loadPlugins(pluginList, filePath, name); + const parser = parserName && this._loadParser(parserName, ctx); + const plugins = pluginList && this._loadPlugins(pluginList, ctx); // Yield pseudo config data for file extension processors. if (plugins) { - yield* this._takeFileExtensionProcessors(plugins, filePath, name); + yield* this._takeFileExtensionProcessors(plugins, ctx); } // Yield the config data except `extends` and `overrides`. yield { // Debug information. - name, - filePath, + type: ctx.type, + name: ctx.name, + filePath: ctx.filePath, // Config data. criteria: null, @@ -698,8 +739,7 @@ class ConfigArrayFactory { for (let i = 0; i < overrideList.length; ++i) { yield* this._normalizeObjectConfigData( overrideList[i], - filePath, - `${name}#overrides[${i}]` + { ...ctx, name: `${ctx.name}#overrides[${i}]` } ); } } @@ -707,34 +747,22 @@ class ConfigArrayFactory { /** * Load configs of an element in `extends`. * @param {string} extendName The name of a base config. - * @param {string} importerPath The file path which has the `extends` property. - * @param {string} importerName The name of the config which has the `extends` property. + * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. * @returns {IterableIterator} The normalized config. * @private */ - _loadExtends(extendName, importerPath, importerName) { - debug("Loading {extends:%j} relative to %s", extendName, importerPath); + _loadExtends(extendName, ctx) { + debug("Loading {extends:%j} relative to %s", extendName, ctx.filePath); try { if (extendName.startsWith("eslint:")) { - return this._loadExtendedBuiltInConfig( - extendName, - importerName - ); + return this._loadExtendedBuiltInConfig(extendName, ctx); } if (extendName.startsWith("plugin:")) { - return this._loadExtendedPluginConfig( - extendName, - importerPath, - importerName - ); + return this._loadExtendedPluginConfig(extendName, ctx); } - return this._loadExtendedShareableConfig( - extendName, - importerPath, - importerName - ); + return this._loadExtendedShareableConfig(extendName, ctx); } catch (error) { - error.message += `\nReferenced from: ${importerPath || importerName}`; + error.message += `\nReferenced from: ${ctx.filePath || ctx.name}`; throw error; } } @@ -742,32 +770,37 @@ class ConfigArrayFactory { /** * Load configs of an element in `extends`. * @param {string} extendName The name of a base config. - * @param {string} importerName The name of the config which has the `extends` property. + * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. * @returns {IterableIterator} The normalized config. * @private */ - _loadExtendedBuiltInConfig(extendName, importerName) { - const name = `${importerName} » ${extendName}`; - + _loadExtendedBuiltInConfig(extendName, ctx) { if (extendName === "eslint:recommended") { - return this._loadConfigData(eslintRecommendedPath, name); + return this._loadConfigData({ + ...ctx, + filePath: eslintRecommendedPath, + name: `${ctx.name} » ${extendName}` + }); } if (extendName === "eslint:all") { - return this._loadConfigData(eslintAllPath, name); + return this._loadConfigData({ + ...ctx, + filePath: eslintAllPath, + name: `${ctx.name} » ${extendName}` + }); } - throw configMissingError(extendName, importerName); + throw configMissingError(extendName, ctx.name); } /** * Load configs of an element in `extends`. * @param {string} extendName The name of a base config. - * @param {string} importerPath The file path which has the `extends` property. - * @param {string} importerName The name of the config which has the `extends` property. + * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. * @returns {IterableIterator} The normalized config. * @private */ - _loadExtendedPluginConfig(extendName, importerPath, importerName) { + _loadExtendedPluginConfig(extendName, ctx) { const slashIndex = extendName.lastIndexOf("/"); const pluginName = extendName.slice("plugin:".length, slashIndex); const configName = extendName.slice(slashIndex + 1); @@ -776,33 +809,32 @@ class ConfigArrayFactory { throw new Error("'extends' cannot use a file path for plugins."); } - const plugin = this._loadPlugin(pluginName, importerPath, importerName); + const plugin = this._loadPlugin(pluginName, ctx); const configData = plugin.definition && plugin.definition.configs[configName]; if (configData) { - return this._normalizeConfigData( - configData, - plugin.filePath, - `${importerName} » plugin:${plugin.id}/${configName}` - ); + return this._normalizeConfigData(configData, { + ...ctx, + filePath: plugin.filePath, + name: `${ctx.name} » plugin:${plugin.id}/${configName}` + }); } - throw plugin.error || configMissingError(extendName, importerPath); + throw plugin.error || configMissingError(extendName, ctx.filePath); } /** * Load configs of an element in `extends`. * @param {string} extendName The name of a base config. - * @param {string} importerPath The file path which has the `extends` property. - * @param {string} importerName The name of the config which has the `extends` property. + * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. * @returns {IterableIterator} The normalized config. * @private */ - _loadExtendedShareableConfig(extendName, importerPath, importerName) { + _loadExtendedShareableConfig(extendName, ctx) { const { cwd } = internalSlotsMap.get(this); - const relativeTo = importerPath || path.join(cwd, "__placeholder__.js"); + const relativeTo = ctx.filePath || path.join(cwd, "__placeholder__.js"); let request; if (isFilePath(extendName)) { @@ -823,29 +855,32 @@ class ConfigArrayFactory { } catch (error) { /* istanbul ignore else */ if (error && error.code === "MODULE_NOT_FOUND") { - throw configMissingError(extendName, importerPath); + throw configMissingError(extendName, ctx.filePath); } throw error; } writeDebugLogForLoading(request, relativeTo, filePath); - return this._loadConfigData(filePath, `${importerName} » ${request}`); + return this._loadConfigData({ + ...ctx, + filePath, + name: `${ctx.name} » ${request}` + }); } /** * Load given plugins. * @param {string[]} names The plugin names to load. - * @param {string} importerPath The path to a config file that imports it. This is just a debug info. - * @param {string} importerName The name of a config file that imports it. This is just a debug info. + * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. * @returns {Record} The loaded parser. * @private */ - _loadPlugins(names, importerPath, importerName) { + _loadPlugins(names, ctx) { return names.reduce((map, name) => { if (isFilePath(name)) { throw new Error("Plugins array cannot includes file paths."); } - const plugin = this._loadPlugin(name, importerPath, importerName); + const plugin = this._loadPlugin(name, ctx); map[plugin.id] = plugin; @@ -856,15 +891,14 @@ class ConfigArrayFactory { /** * Load a given parser. * @param {string} nameOrPath The package name or the path to a parser file. - * @param {string} importerPath The path to a config file that imports it. - * @param {string} importerName The name of a config file that imports it. This is just a debug info. + * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. * @returns {DependentParser} The loaded parser. */ - _loadParser(nameOrPath, importerPath, importerName) { - debug("Loading parser %j from %s", nameOrPath, importerPath); + _loadParser(nameOrPath, ctx) { + debug("Loading parser %j from %s", nameOrPath, ctx.filePath); const { cwd } = internalSlotsMap.get(this); - const relativeTo = importerPath || path.join(cwd, "__placeholder__.js"); + const relativeTo = ctx.filePath || path.join(cwd, "__placeholder__.js"); try { const filePath = ModuleResolver.resolve(nameOrPath, relativeTo); @@ -875,8 +909,8 @@ class ConfigArrayFactory { definition: require(filePath), filePath, id: nameOrPath, - importerName, - importerPath + importerName: ctx.name, + importerPath: ctx.filePath }); } catch (error) { @@ -887,19 +921,19 @@ class ConfigArrayFactory { definition: require("espree"), filePath: require.resolve("espree"), id: nameOrPath, - importerName, - importerPath + importerName: ctx.name, + importerPath: ctx.filePath }); } - debug("Failed to load parser '%s' declared in '%s'.", nameOrPath, importerName); - error.message = `Failed to load parser '${nameOrPath}' declared in '${importerName}': ${error.message}`; + debug("Failed to load parser '%s' declared in '%s'.", nameOrPath, ctx.name); + error.message = `Failed to load parser '${nameOrPath}' declared in '${ctx.name}': ${error.message}`; return new ConfigDependency({ error, id: nameOrPath, - importerName, - importerPath + importerName: ctx.name, + importerPath: ctx.filePath }); } } @@ -907,18 +941,17 @@ class ConfigArrayFactory { /** * Load a given plugin. * @param {string} name The plugin name to load. - * @param {string} importerPath The path to a config file that imports it. This is just a debug info. - * @param {string} importerName The name of a config file that imports it. This is just a debug info. + * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. * @returns {DependentPlugin} The loaded plugin. * @private */ - _loadPlugin(name, importerPath, importerName) { - debug("Loading plugin %j from %s", name, importerPath); + _loadPlugin(name, ctx) { + debug("Loading plugin %j from %s", name, ctx.filePath); - const { additionalPluginPool, resolvePluginsRelativeTo } = internalSlotsMap.get(this); + const { additionalPluginPool } = internalSlotsMap.get(this); const request = naming.normalizePackageName(name, "eslint-plugin"); const id = naming.getShorthandName(request, "eslint-plugin"); - const relativeTo = path.join(resolvePluginsRelativeTo, "__placeholder__.js"); + const relativeTo = path.join(ctx.pluginBasePath, "__placeholder__.js"); if (name.match(/\s+/u)) { const error = Object.assign( @@ -932,8 +965,8 @@ class ConfigArrayFactory { return new ConfigDependency({ error, id, - importerName, - importerPath + importerName: ctx.name, + importerPath: ctx.filePath }); } @@ -945,10 +978,10 @@ class ConfigArrayFactory { if (plugin) { return new ConfigDependency({ definition: normalizePlugin(plugin), - filePath: importerPath, + filePath: ctx.filePath, id, - importerName, - importerPath + importerName: ctx.name, + importerPath: ctx.filePath }); } @@ -964,8 +997,8 @@ class ConfigArrayFactory { error.messageTemplate = "plugin-missing"; error.messageData = { pluginName: request, - resolvePluginsRelativeTo, - importerName + resolvePluginsRelativeTo: ctx.pluginBasePath, + importerName: ctx.name }; } } @@ -983,33 +1016,32 @@ class ConfigArrayFactory { definition: normalizePlugin(pluginDefinition), filePath, id, - importerName, - importerPath + importerName: ctx.name, + importerPath: ctx.filePath }); } catch (loadError) { error = loadError; } } - debug("Failed to load plugin '%s' declared in '%s'.", name, importerName); - error.message = `Failed to load plugin '${name}' declared in '${importerName}': ${error.message}`; + debug("Failed to load plugin '%s' declared in '%s'.", name, ctx.name); + error.message = `Failed to load plugin '${name}' declared in '${ctx.name}': ${error.message}`; return new ConfigDependency({ error, id, - importerName, - importerPath + importerName: ctx.name, + importerPath: ctx.filePath }); } /** * Take file expression processors as config array elements. * @param {Record} plugins The plugin definitions. - * @param {string} filePath The file path of this config. - * @param {string} name The name of this config. + * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. * @returns {IterableIterator} The config array elements of file expression processors. * @private */ - *_takeFileExtensionProcessors(plugins, filePath, name) { + *_takeFileExtensionProcessors(plugins, ctx) { for (const pluginId of Object.keys(plugins)) { const processors = plugins[pluginId] && @@ -1027,8 +1059,11 @@ class ConfigArrayFactory { files: [`*${processorId}`], processor: `${pluginId}/${processorId}` }, - filePath, - `${name}#processors["${pluginId}/${processorId}"]` + { + ...ctx, + type: "implicit-processor", + name: `${ctx.name}#processors["${pluginId}/${processorId}"]` + } ); } } @@ -1036,4 +1071,4 @@ class ConfigArrayFactory { } } -module.exports = { ConfigArrayFactory }; +module.exports = { ConfigArrayFactory, createContext }; diff --git a/tools/node_modules/eslint/lib/cli-engine/config-array/config-array.js b/tools/node_modules/eslint/lib/cli-engine/config-array/config-array.js index 4fae8deaca1b69..b3434198b19201 100644 --- a/tools/node_modules/eslint/lib/cli-engine/config-array/config-array.js +++ b/tools/node_modules/eslint/lib/cli-engine/config-array/config-array.js @@ -5,7 +5,7 @@ * config file, base config files that were extended, loaded parsers, and loaded * plugins. * - * `ConfigArray` class provies three properties and two methods. + * `ConfigArray` class provides three properties and two methods. * * - `pluginEnvironments` * - `pluginProcessors` @@ -65,6 +65,7 @@ const { IgnorePattern } = require("./ignore-pattern"); * @property {boolean|undefined} root The flag to express root. * @property {Record|undefined} rules The rule settings * @property {Object|undefined} settings The shared settings. + * @property {"config" | "ignore" | "implicit-processor"} type The element type. */ /** @@ -155,6 +156,23 @@ function mergeWithoutOverwrite(target, source) { } } +/** + * The error for plugin conflicts. + */ +class PluginConflictError extends Error { + + /** + * Initialize this error object. + * @param {string} pluginId The plugin ID. + * @param {{filePath:string, importerName:string}[]} plugins The resolved plugins. + */ + constructor(pluginId, plugins) { + super(`Plugin "${pluginId}" was conflicted between ${plugins.map(p => `"${p.importerName}"`).join(" and ")}.`); + this.messageTemplate = "plugin-conflict"; + this.messageData = { pluginId, plugins }; + } +} + /** * Merge plugins. * `target`'s definition is prior to `source`'s. @@ -180,6 +198,17 @@ function mergePlugins(target, source) { throw sourceValue.error; } target[key] = sourceValue; + } else if (sourceValue.filePath !== targetValue.filePath) { + throw new PluginConflictError(key, [ + { + filePath: targetValue.filePath, + importerName: targetValue.importerName + }, + { + filePath: sourceValue.filePath, + importerName: sourceValue.importerName + } + ]); } } } @@ -454,6 +483,25 @@ class ConfigArray extends Array { return cache.get(cacheKey); } + + /** + * Check if a given path is an additional lint target. + * @param {string} filePath The absolute path to the target file. + * @returns {boolean} `true` if the file is an additional lint target. + */ + isAdditionalTargetPath(filePath) { + for (const { criteria, type } of this) { + if ( + type === "config" && + criteria && + !criteria.endsWithWildcard && + criteria.test(filePath) + ) { + return true; + } + } + return false; + } } const exportObject = { diff --git a/tools/node_modules/eslint/lib/cli-engine/config-array/ignore-pattern.js b/tools/node_modules/eslint/lib/cli-engine/config-array/ignore-pattern.js index 6140194433e861..92690b9f8ae342 100644 --- a/tools/node_modules/eslint/lib/cli-engine/config-array/ignore-pattern.js +++ b/tools/node_modules/eslint/lib/cli-engine/config-array/ignore-pattern.js @@ -103,8 +103,8 @@ function dirSuffix(filePath) { return isDir ? "/" : ""; } -const DefaultPatterns = Object.freeze(["/node_modules/*", "/bower_components/*"]); -const DotPatterns = Object.freeze([".*", "!../"]); +const DefaultPatterns = Object.freeze(["/**/node_modules/*"]); +const DotPatterns = Object.freeze([".*", "!.eslintrc.*", "!../"]); //------------------------------------------------------------------------------ // Public diff --git a/tools/node_modules/eslint/lib/cli-engine/config-array/override-tester.js b/tools/node_modules/eslint/lib/cli-engine/config-array/override-tester.js index 67c8a6ed8a0cbb..e7ba1202f1cb08 100644 --- a/tools/node_modules/eslint/lib/cli-engine/config-array/override-tester.js +++ b/tools/node_modules/eslint/lib/cli-engine/config-array/override-tester.js @@ -96,14 +96,22 @@ class OverrideTester { static create(files, excludedFiles, basePath) { const includePatterns = normalizePatterns(files); const excludePatterns = normalizePatterns(excludedFiles); - const allPatterns = includePatterns.concat(excludePatterns); + let endsWithWildcard = false; - if (allPatterns.length === 0) { + if (includePatterns.length === 0) { return null; } // Rejects absolute paths or relative paths to parents. - for (const pattern of allPatterns) { + for (const pattern of includePatterns) { + if (path.isAbsolute(pattern) || pattern.includes("..")) { + throw new Error(`Invalid override pattern (expected relative path not containing '..'): ${pattern}`); + } + if (pattern.endsWith("*")) { + endsWithWildcard = true; + } + } + for (const pattern of excludePatterns) { if (path.isAbsolute(pattern) || pattern.includes("..")) { throw new Error(`Invalid override pattern (expected relative path not containing '..'): ${pattern}`); } @@ -112,7 +120,11 @@ class OverrideTester { const includes = toMatcher(includePatterns); const excludes = toMatcher(excludePatterns); - return new OverrideTester([{ includes, excludes }], basePath); + return new OverrideTester( + [{ includes, excludes }], + basePath, + endsWithWildcard + ); } /** @@ -125,28 +137,44 @@ class OverrideTester { */ static and(a, b) { if (!b) { - return a && new OverrideTester(a.patterns, a.basePath); + return a && new OverrideTester( + a.patterns, + a.basePath, + a.endsWithWildcard + ); } if (!a) { - return new OverrideTester(b.patterns, b.basePath); + return new OverrideTester( + b.patterns, + b.basePath, + b.endsWithWildcard + ); } assert.strictEqual(a.basePath, b.basePath); - return new OverrideTester(a.patterns.concat(b.patterns), a.basePath); + return new OverrideTester( + a.patterns.concat(b.patterns), + a.basePath, + a.endsWithWildcard || b.endsWithWildcard + ); } /** * Initialize this instance. * @param {Pattern[]} patterns The matchers. * @param {string} basePath The base path. + * @param {boolean} endsWithWildcard If `true` then a pattern ends with `*`. */ - constructor(patterns, basePath) { + constructor(patterns, basePath, endsWithWildcard = false) { /** @type {Pattern[]} */ this.patterns = patterns; /** @type {string} */ this.basePath = basePath; + + /** @type {boolean} */ + this.endsWithWildcard = endsWithWildcard; } /** diff --git a/tools/node_modules/eslint/lib/cli-engine/file-enumerator.js b/tools/node_modules/eslint/lib/cli-engine/file-enumerator.js index c67e01aef9b1c8..7c433d32f44b1c 100644 --- a/tools/node_modules/eslint/lib/cli-engine/file-enumerator.js +++ b/tools/node_modules/eslint/lib/cli-engine/file-enumerator.js @@ -6,7 +6,7 @@ * 1. Find target files by processing glob patterns. * 2. Tie each target file and appropriate configuration. * - * It provies a method: + * It provides a method: * * - `iterateFiles(patterns)` * Iterate files which are matched by given patterns together with the @@ -88,7 +88,7 @@ const IGNORED = 2; * @typedef {Object} FileEnumeratorInternalSlots * @property {CascadingConfigArrayFactory} configArrayFactory The factory for config arrays. * @property {string} cwd The base directory to start lookup. - * @property {RegExp} extensionRegExp The RegExp to test if a string ends with specific file extensions. + * @property {RegExp|null} extensionRegExp The RegExp to test if a string ends with specific file extensions. * @property {boolean} globInputPaths Set to false to skip glob resolution of input file paths to lint (default: true). If false, each input file paths is assumed to be a non-glob path to an existing file. * @property {boolean} ignoreFlag The flag to check ignored files. * @property {(filePath:string, dot:boolean) => boolean} defaultIgnores The default predicate function to ignore files. @@ -127,12 +127,12 @@ function statSafeSync(filePath) { /** * Get filenames in a given path to a directory. * @param {string} directoryPath The path to target directory. - * @returns {string[]} The filenames. + * @returns {import("fs").Dirent[]} The filenames. * @private */ function readdirSafeSync(directoryPath) { try { - return fs.readdirSync(directoryPath); + return fs.readdirSync(directoryPath, { withFileTypes: true }); } catch (error) { /* istanbul ignore next */ if (error.code !== "ENOENT") { @@ -142,6 +142,27 @@ function readdirSafeSync(directoryPath) { } } +/** + * Create a `RegExp` object to detect extensions. + * @param {string[] | null} extensions The extensions to create. + * @returns {RegExp | null} The created `RegExp` object or null. + */ +function createExtensionRegExp(extensions) { + if (extensions) { + const normalizedExts = extensions.map(ext => escapeRegExp( + ext.startsWith(".") + ? ext.slice(1) + : ext + )); + + return new RegExp( + `.\\.(?:${normalizedExts.join("|")})$`, + "u" + ); + } + return null; +} + /** * The error type when no files match a glob. */ @@ -188,7 +209,7 @@ class FileEnumerator { constructor({ cwd = process.cwd(), configArrayFactory = new CascadingConfigArrayFactory({ cwd }), - extensions = [".js"], + extensions = null, globInputPaths = true, errorOnUnmatchedPattern = true, ignore = true @@ -197,17 +218,7 @@ class FileEnumerator { configArrayFactory, cwd, defaultIgnores: IgnorePattern.createDefaultIgnore(cwd), - extensionRegExp: new RegExp( - `.\\.(?:${extensions - .map(ext => escapeRegExp( - ext.startsWith(".") - ? ext.slice(1) - : ext - )) - .join("|") - })$`, - "u" - ), + extensionRegExp: createExtensionRegExp(extensions), globInputPaths, errorOnUnmatchedPattern, ignoreFlag: ignore @@ -215,11 +226,36 @@ class FileEnumerator { } /** - * The `RegExp` object that tests if a file path has the allowed file extensions. - * @type {RegExp} + * Check if a given file is target or not. + * @param {string} filePath The path to a candidate file. + * @param {ConfigArray} [providedConfig] Optional. The configuration for the file. + * @returns {boolean} `true` if the file is a target. */ - get extensionRegExp() { - return internalSlotsMap.get(this).extensionRegExp; + isTargetPath(filePath, providedConfig) { + const { + configArrayFactory, + extensionRegExp + } = internalSlotsMap.get(this); + + // If `--ext` option is present, use it. + if (extensionRegExp) { + return extensionRegExp.test(filePath); + } + + // `.js` file is target by default. + if (filePath.endsWith(".js")) { + return true; + } + + // use `overrides[].files` to check additional targets. + const config = + providedConfig || + configArrayFactory.getConfigArrayForFile( + filePath, + { ignoreNotFoundError: true } + ); + + return config.isAdditionalTargetPath(filePath); } /** @@ -247,7 +283,7 @@ class FileEnumerator { continue; } - // Iterate files of this pttern. + // Iterate files of this pattern. for (const { config, filePath, flag } of this._iterateFiles(pattern)) { foundRegardlessOfIgnored = true; if (flag === IGNORED_SILENTLY) { @@ -380,18 +416,17 @@ class FileEnumerator { */ *_iterateFilesRecursive(directoryPath, options) { debug(`Enter the directory: ${directoryPath}`); - const { configArrayFactory, extensionRegExp } = internalSlotsMap.get(this); + const { configArrayFactory } = internalSlotsMap.get(this); /** @type {ConfigArray|null} */ let config = null; // Enumerate the files of this directory. - for (const filename of readdirSafeSync(directoryPath)) { - const filePath = path.join(directoryPath, filename); - const stat = statSafeSync(filePath); // TODO: Use `withFileTypes` in the future. + for (const entry of readdirSafeSync(directoryPath)) { + const filePath = path.join(directoryPath, entry.name); // Check if the file is matched. - if (stat && stat.isFile()) { + if (entry.isFile()) { if (!config) { config = configArrayFactory.getConfigArrayForFile( filePath, @@ -404,29 +439,30 @@ class FileEnumerator { { ignoreNotFoundError: true } ); } - const ignored = this._isIgnoredFile(filePath, { ...options, config }); - const flag = ignored ? IGNORED_SILENTLY : NONE; const matched = options.selector // Started with a glob pattern; choose by the pattern. ? options.selector.match(filePath) // Started with a directory path; choose by file extensions. - : extensionRegExp.test(filePath); + : this.isTargetPath(filePath, config); if (matched) { - debug(`Yield: ${filename}${ignored ? " but ignored" : ""}`); + const ignored = this._isIgnoredFile(filePath, { ...options, config }); + const flag = ignored ? IGNORED_SILENTLY : NONE; + + debug(`Yield: ${entry.name}${ignored ? " but ignored" : ""}`); yield { config: configArrayFactory.getConfigArrayForFile(filePath), filePath, flag }; } else { - debug(`Didn't match: ${filename}`); + debug(`Didn't match: ${entry.name}`); } // Dive into the sub directory. - } else if (options.recursive && stat && stat.isDirectory()) { + } else if (options.recursive && entry.isDirectory()) { if (!config) { config = configArrayFactory.getConfigArrayForFile( filePath, diff --git a/tools/node_modules/eslint/lib/cli-engine/formatters/junit.js b/tools/node_modules/eslint/lib/cli-engine/formatters/junit.js index c32425883f7cac..a994b4b1980eea 100644 --- a/tools/node_modules/eslint/lib/cli-engine/formatters/junit.js +++ b/tools/node_modules/eslint/lib/cli-engine/formatters/junit.js @@ -32,7 +32,7 @@ function getMessageType(message) { * @private */ function pathWithoutExt(filePath) { - return path.posix.join(path.posix.dirname(filePath), path.basename(filePath, path.extname(filePath))); + return path.join(path.dirname(filePath), path.basename(filePath, path.extname(filePath))); } //------------------------------------------------------------------------------ diff --git a/tools/node_modules/eslint/lib/cli.js b/tools/node_modules/eslint/lib/cli.js index 944b4b79353b3d..815ce68c22fe2e 100644 --- a/tools/node_modules/eslint/lib/cli.js +++ b/tools/node_modules/eslint/lib/cli.js @@ -17,7 +17,6 @@ const fs = require("fs"), path = require("path"), - mkdirp = require("mkdirp"), { CLIEngine } = require("./cli-engine"), options = require("./options"), log = require("./shared/logging"), @@ -115,7 +114,7 @@ function printResults(engine, results, format, outputFile) { } try { - mkdirp.sync(path.dirname(filePath)); + fs.mkdirSync(path.dirname(filePath), { recursive: true }); fs.writeFileSync(filePath, output); } catch (ex) { log.error("There was a problem writing the output file:\n%s", ex); diff --git a/tools/node_modules/eslint/lib/init/config-file.js b/tools/node_modules/eslint/lib/init/config-file.js index 960b572cddb3ea..fc62b81525e66b 100644 --- a/tools/node_modules/eslint/lib/init/config-file.js +++ b/tools/node_modules/eslint/lib/init/config-file.js @@ -45,7 +45,7 @@ function sortByKey(a, b) { function writeJSONConfigFile(config, filePath) { debug(`Writing JSON config file: ${filePath}`); - const content = stringify(config, { cmp: sortByKey, space: 4 }); + const content = `${stringify(config, { cmp: sortByKey, space: 4 })}\n`; fs.writeFileSync(filePath, content, "utf8"); } @@ -80,7 +80,7 @@ function writeJSConfigFile(config, filePath) { debug(`Writing JS config file: ${filePath}`); let contentToWrite; - const stringifiedContent = `module.exports = ${stringify(config, { cmp: sortByKey, space: 4 })};`; + const stringifiedContent = `module.exports = ${stringify(config, { cmp: sortByKey, space: 4 })};\n`; try { const { CLIEngine } = require("../cli-engine"); diff --git a/tools/node_modules/eslint/lib/init/npm-utils.js b/tools/node_modules/eslint/lib/init/npm-utils.js index 28c198fc8ada67..555ea2b2b28cb2 100644 --- a/tools/node_modules/eslint/lib/init/npm-utils.js +++ b/tools/node_modules/eslint/lib/init/npm-utils.js @@ -135,7 +135,7 @@ function check(packages, opt) { * * Convenience wrapper around check(). * @param {string[]} packages Array of node modules to check. - * @param {string} rootDir The directory contianing a package.json + * @param {string} rootDir The directory containing a package.json * @returns {Object} An object whose keys are the module names * and values are booleans indicating installation. */ diff --git a/tools/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js b/tools/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js index 6822ae2be0a6cd..8a623e33ea0681 100644 --- a/tools/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js +++ b/tools/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js @@ -518,6 +518,7 @@ function processCodePathToExit(analyzer, node) { case "ImportExpression": case "MemberExpression": case "NewExpression": + case "YieldExpression": state.makeFirstThrowablePathInTryBlock(); break; diff --git a/tools/node_modules/eslint/lib/linter/code-path-analysis/debug-helpers.js b/tools/node_modules/eslint/lib/linter/code-path-analysis/debug-helpers.js index 35a4cb2dacb1ca..bde4e0a38ad24b 100644 --- a/tools/node_modules/eslint/lib/linter/code-path-analysis/debug-helpers.js +++ b/tools/node_modules/eslint/lib/linter/code-path-analysis/debug-helpers.js @@ -70,7 +70,7 @@ module.exports = { /** * Dumps a DOT code of a given code path. - * The DOT code can be visialized with Graphvis. + * The DOT code can be visualized with Graphvis. * @param {CodePath} codePath A code path to dump. * @returns {void} * @see http://www.graphviz.org @@ -135,7 +135,7 @@ module.exports = { /** * Makes a DOT code of a given code path. - * The DOT code can be visialized with Graphvis. + * The DOT code can be visualized with Graphvis. * @param {CodePath} codePath A code path to make DOT. * @param {Object} traceMap Optional. A map to check whether or not segments had been done. * @returns {string} A DOT code of the code path. diff --git a/tools/node_modules/eslint/lib/linter/code-path-analysis/fork-context.js b/tools/node_modules/eslint/lib/linter/code-path-analysis/fork-context.js index eb1d2de5a7db5b..2e872b5c0dbf5a 100644 --- a/tools/node_modules/eslint/lib/linter/code-path-analysis/fork-context.js +++ b/tools/node_modules/eslint/lib/linter/code-path-analysis/fork-context.js @@ -211,7 +211,7 @@ class ForkContext { } /** - * Clears all secments in this context. + * Clears all segments in this context. * @returns {void} */ clear() { diff --git a/tools/node_modules/eslint/lib/linter/linter.js b/tools/node_modules/eslint/lib/linter/linter.js index 6d88cb5aa1245f..1d021d1e82e7fb 100644 --- a/tools/node_modules/eslint/lib/linter/linter.js +++ b/tools/node_modules/eslint/lib/linter/linter.js @@ -267,6 +267,15 @@ function createDisableDirectives(options) { return result; } +/** + * Remove the ignored part from a given directive comment and trim it. + * @param {string} value The comment text to strip. + * @returns {string} The stripped text. + */ +function stripDirectiveComment(value) { + return value.split(/\s-{2,}\s/u)[0].trim(); +} + /** * Parses comments in file to extract file-specific config of rules, globals * and environments and merges them with global config; also code blocks @@ -286,7 +295,7 @@ function getDirectiveComments(filename, ast, ruleMapper, warnInlineConfig) { const disableDirectives = []; ast.comments.filter(token => token.type !== "Shebang").forEach(comment => { - const trimmedCommentText = comment.value.trim(); + const trimmedCommentText = stripDirectiveComment(comment.value); const match = /^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u.exec(trimmedCommentText); if (!match) { @@ -444,8 +453,11 @@ function findEslintEnv(text) { eslintEnvPattern.lastIndex = 0; - while ((match = eslintEnvPattern.exec(text))) { - retv = Object.assign(retv || {}, commentParser.parseListConfig(match[1])); + while ((match = eslintEnvPattern.exec(text)) !== null) { + retv = Object.assign( + retv || {}, + commentParser.parseListConfig(stripDirectiveComment(match[1])) + ); } return retv; @@ -1260,7 +1272,7 @@ class Linter { * @param {string|SourceCode} textOrSourceCode The source code. * @param {ConfigData|ExtractedConfig} config The config array. * @param {VerifyOptions&ProcessorOptions} options The options. - * @param {ConfigArray} [configForRecursive] The `CofnigArray` object to apply multiple processors recursively. + * @param {ConfigArray} [configForRecursive] The `ConfigArray` object to apply multiple processors recursively. * @returns {LintMessage[]} The found problems. */ _verifyWithProcessor(textOrSourceCode, config, options, configForRecursive) { diff --git a/tools/node_modules/eslint/lib/linter/node-event-generator.js b/tools/node_modules/eslint/lib/linter/node-event-generator.js index fc7b879f64172b..6f3b2513998dcd 100644 --- a/tools/node_modules/eslint/lib/linter/node-event-generator.js +++ b/tools/node_modules/eslint/lib/linter/node-event-generator.js @@ -159,8 +159,8 @@ function tryParseSelector(rawSelector) { try { return esquery.parse(rawSelector.replace(/:exit$/u, "")); } catch (err) { - if (typeof err.offset === "number") { - throw new SyntaxError(`Syntax error in selector "${rawSelector}" at position ${err.offset}: ${err.message}`); + if (err.location && err.location.start && typeof err.location.start.offset === "number") { + throw new SyntaxError(`Syntax error in selector "${rawSelector}" at position ${err.location.start.offset}: ${err.message}`); } throw err; } diff --git a/tools/node_modules/eslint/lib/rule-tester/rule-tester.js b/tools/node_modules/eslint/lib/rule-tester/rule-tester.js index 44e01dadf09b5d..1c1737152c1b19 100644 --- a/tools/node_modules/eslint/lib/rule-tester/rule-tester.js +++ b/tools/node_modules/eslint/lib/rule-tester/rule-tester.js @@ -45,11 +45,61 @@ const path = require("path"), util = require("util"), lodash = require("lodash"), + Traverser = require("../../lib/shared/traverser"), { getRuleOptionsSchema, validate } = require("../shared/config-validator"), { Linter, SourceCodeFixer, interpolate } = require("../linter"); const ajv = require("../shared/ajv")({ strictDefaults: true }); +const espreePath = require.resolve("espree"); + +//------------------------------------------------------------------------------ +// Typedefs +//------------------------------------------------------------------------------ + +/** @typedef {import("../shared/types").Parser} Parser */ + +/** + * A test case that is expected to pass lint. + * @typedef {Object} ValidTestCase + * @property {string} code Code for the test case. + * @property {any[]} [options] Options for the test case. + * @property {{ [name: string]: any }} [settings] Settings for the test case. + * @property {string} [filename] The fake filename for the test case. Useful for rules that make assertion about filenames. + * @property {string} [parser] The absolute path for the parser. + * @property {{ [name: string]: any }} [parserOptions] Options for the parser. + * @property {{ [name: string]: "readonly" | "writable" | "off" }} [globals] The additional global variables. + * @property {{ [name: string]: boolean }} [env] Environments for the test case. + */ + +/** + * A test case that is expected to fail lint. + * @typedef {Object} InvalidTestCase + * @property {string} code Code for the test case. + * @property {number | Array} errors Expected errors. + * @property {string | null} [output] The expected code after autofixes are applied. If set to `null`, the test runner will assert that no autofix is suggested. + * @property {any[]} [options] Options for the test case. + * @property {{ [name: string]: any }} [settings] Settings for the test case. + * @property {string} [filename] The fake filename for the test case. Useful for rules that make assertion about filenames. + * @property {string} [parser] The absolute path for the parser. + * @property {{ [name: string]: any }} [parserOptions] Options for the parser. + * @property {{ [name: string]: "readonly" | "writable" | "off" }} [globals] The additional global variables. + * @property {{ [name: string]: boolean }} [env] Environments for the test case. + */ + +/** + * A description of a reported error used in a rule tester test. + * @typedef {Object} TestCaseError + * @property {string | RegExp} [message] Message. + * @property {string} [messageId] Message ID. + * @property {string} [type] The type of the reported AST node. + * @property {{ [name: string]: string }} [data] The data used to fill the message template. + * @property {number} [line] The 1-based line number of the reported start location. + * @property {number} [column] The 1-based column number of the reported start location. + * @property {number} [endLine] The 1-based line number of the reported end location. + * @property {number} [endColumn] The 1-based column number of the reported end location. + */ + //------------------------------------------------------------------------------ // Private Members //------------------------------------------------------------------------------ @@ -73,6 +123,33 @@ const RuleTesterParameters = [ "output" ]; +/* + * All allowed property names in error objects. + */ +const errorObjectParameters = new Set([ + "message", + "messageId", + "data", + "type", + "line", + "column", + "endLine", + "endColumn", + "suggestions" +]); +const friendlyErrorObjectParameterList = `[${[...errorObjectParameters].map(key => `'${key}'`).join(", ")}]`; + +/* + * All allowed property names in suggestion objects. + */ +const suggestionObjectParameters = new Set([ + "desc", + "messageId", + "data", + "output" +]); +const friendlySuggestionObjectParameterList = `[${[...suggestionObjectParameters].map(key => `'${key}'`).join(", ")}]`; + const hasOwnProperty = Function.call.bind(Object.hasOwnProperty); /** @@ -128,11 +205,75 @@ function freezeDeeply(x) { */ function sanitize(text) { return text.replace( - /[\u0000-\u0009|\u000b-\u001a]/gu, // eslint-disable-line no-control-regex + /[\u0000-\u0009\u000b-\u001a]/gu, // eslint-disable-line no-control-regex c => `\\u${c.codePointAt(0).toString(16).padStart(4, "0")}` ); } +/** + * Define `start`/`end` properties as throwing error. + * @param {string} objName Object name used for error messages. + * @param {ASTNode} node The node to define. + * @returns {void} + */ +function defineStartEndAsError(objName, node) { + Object.defineProperties(node, { + start: { + get() { + throw new Error(`Use ${objName}.range[0] instead of ${objName}.start`); + }, + configurable: true, + enumerable: false + }, + end: { + get() { + throw new Error(`Use ${objName}.range[1] instead of ${objName}.end`); + }, + configurable: true, + enumerable: false + } + }); +} + +/** + * Define `start`/`end` properties of all nodes of the given AST as throwing error. + * @param {ASTNode} ast The root node to errorize `start`/`end` properties. + * @param {Object} [visitorKeys] Visitor keys to be used for traversing the given ast. + * @returns {void} + */ +function defineStartEndAsErrorInTree(ast, visitorKeys) { + Traverser.traverse(ast, { visitorKeys, enter: defineStartEndAsError.bind(null, "node") }); + ast.tokens.forEach(defineStartEndAsError.bind(null, "token")); + ast.comments.forEach(defineStartEndAsError.bind(null, "token")); +} + +/** + * Wraps the given parser in order to intercept and modify return values from the `parse` and `parseForESLint` methods, for test purposes. + * In particular, to modify ast nodes, tokens and comments to throw on access to their `start` and `end` properties. + * @param {Parser} parser Parser object. + * @returns {Parser} Wrapped parser object. + */ +function wrapParser(parser) { + if (typeof parser.parseForESLint === "function") { + return { + parseForESLint(...args) { + const ret = parser.parseForESLint(...args); + + defineStartEndAsErrorInTree(ret.ast, ret.visitorKeys); + return ret; + } + }; + } + return { + parse(...args) { + const ast = parser.parse(...args); + + defineStartEndAsErrorInTree(ast); + return ast; + } + }; +} + //------------------------------------------------------------------------------ // Public Interface //------------------------------------------------------------------------------ @@ -273,7 +414,10 @@ class RuleTester { * Adds a new rule test to execute. * @param {string} ruleName The name of the rule to run. * @param {Function} rule The rule to test. - * @param {Object} test The collection of tests to run. + * @param {{ + * valid: (ValidTestCase | string)[], + * invalid: InvalidTestCase[] + * }} test The collection of tests to run. * @returns {void} */ run(ruleName, rule, test) { @@ -374,9 +518,12 @@ class RuleTester { if (typeof config.parser === "string") { assert(path.isAbsolute(config.parser), "Parsers provided as strings to RuleTester must be absolute paths"); - linter.defineParser(config.parser, require(config.parser)); + } else { + config.parser = espreePath; } + linter.defineParser(config.parser, wrapParser(require(config.parser))); + if (schema) { ajv.validateSchema(schema); @@ -407,13 +554,9 @@ class RuleTester { // Verify the code. const messages = linter.verify(code, config, filename); + const fatalErrorMessage = messages.find(m => m.fatal); - // Ignore syntax errors for backward compatibility if `errors` is a number. - if (typeof item.errors !== "number") { - const errorMessage = messages.find(m => m.fatal); - - assert(!errorMessage, `A fatal parsing error occurred: ${errorMessage && errorMessage.message}`); - } + assert(!fatalErrorMessage, `A fatal parsing error occurred: ${fatalErrorMessage && fatalErrorMessage.message}`); // Verify if autofix makes a syntax error or not. if (messages.some(m => m.fix)) { @@ -496,10 +639,12 @@ class RuleTester { assert.ok(item.errors || item.errors === 0, `Did not specify errors for an invalid test of ${ruleName}`); + const ruleHasMetaMessages = hasOwnProperty(rule, "meta") && hasOwnProperty(rule.meta, "messages"); + const friendlyIDList = ruleHasMetaMessages ? `[${Object.keys(rule.meta.messages).map(key => `'${key}'`).join(", ")}]` : null; + const result = runRuleForItem(item); const messages = result.messages; - if (typeof item.errors === "number") { assert.strictEqual(messages.length, item.errors, util.format("Should have %d error%s but had %d: %s", item.errors, item.errors === 1 ? "" : "s", messages.length, util.inspect(messages))); @@ -524,25 +669,31 @@ class RuleTester { // Just an error message. assertMessageMatches(message.message, error); - } else if (typeof error === "object") { + } else if (typeof error === "object" && error !== null) { /* * Error object. * This may have a message, messageId, data, node type, line, and/or * column. */ + + Object.keys(error).forEach(propertyName => { + assert.ok( + errorObjectParameters.has(propertyName), + `Invalid error property name '${propertyName}'. Expected one of ${friendlyErrorObjectParameterList}.` + ); + }); + if (hasOwnProperty(error, "message")) { assert.ok(!hasOwnProperty(error, "messageId"), "Error should not specify both 'message' and a 'messageId'."); assert.ok(!hasOwnProperty(error, "data"), "Error should not specify both 'data' and 'message'."); assertMessageMatches(message.message, error.message); } else if (hasOwnProperty(error, "messageId")) { assert.ok( - hasOwnProperty(rule, "meta") && hasOwnProperty(rule.meta, "messages"), + ruleHasMetaMessages, "Error can not use 'messageId' if rule under test doesn't define 'meta.messages'." ); if (!hasOwnProperty(rule.meta.messages, error.messageId)) { - const friendlyIDList = `[${Object.keys(rule.meta.messages).map(key => `'${key}'`).join(", ")}]`; - assert(false, `Invalid messageId '${error.messageId}'. Expected one of ${friendlyIDList}.`); } assert.strictEqual( @@ -605,20 +756,62 @@ class RuleTester { assert.strictEqual(message.suggestions.length, error.suggestions.length, `Error should have ${error.suggestions.length} suggestions. Instead found ${message.suggestions.length} suggestions`); error.suggestions.forEach((expectedSuggestion, index) => { + assert.ok( + typeof expectedSuggestion === "object" && expectedSuggestion !== null, + "Test suggestion in 'suggestions' array must be an object." + ); + Object.keys(expectedSuggestion).forEach(propertyName => { + assert.ok( + suggestionObjectParameters.has(propertyName), + `Invalid suggestion property name '${propertyName}'. Expected one of ${friendlySuggestionObjectParameterList}.` + ); + }); + const actualSuggestion = message.suggestions[index]; + const suggestionPrefix = `Error Suggestion at index ${index} :`; + + if (hasOwnProperty(expectedSuggestion, "desc")) { + assert.ok( + !hasOwnProperty(expectedSuggestion, "data"), + `${suggestionPrefix} Test should not specify both 'desc' and 'data'.` + ); + assert.strictEqual( + actualSuggestion.desc, + expectedSuggestion.desc, + `${suggestionPrefix} desc should be "${expectedSuggestion.desc}" but got "${actualSuggestion.desc}" instead.` + ); + } - /** - * Tests equality of a suggestion key if that key is defined in the expected output. - * @param {string} key Key to validate from the suggestion object - * @returns {void} - */ - function assertSuggestionKeyEquals(key) { - if (hasOwnProperty(expectedSuggestion, key)) { - assert.deepStrictEqual(actualSuggestion[key], expectedSuggestion[key], `Error suggestion at index: ${index} should have desc of: "${actualSuggestion[key]}"`); + if (hasOwnProperty(expectedSuggestion, "messageId")) { + assert.ok( + ruleHasMetaMessages, + `${suggestionPrefix} Test can not use 'messageId' if rule under test doesn't define 'meta.messages'.` + ); + assert.ok( + hasOwnProperty(rule.meta.messages, expectedSuggestion.messageId), + `${suggestionPrefix} Test has invalid messageId '${expectedSuggestion.messageId}', the rule under test allows only one of ${friendlyIDList}.` + ); + assert.strictEqual( + actualSuggestion.messageId, + expectedSuggestion.messageId, + `${suggestionPrefix} messageId should be '${expectedSuggestion.messageId}' but got '${actualSuggestion.messageId}' instead.` + ); + if (hasOwnProperty(expectedSuggestion, "data")) { + const unformattedMetaMessage = rule.meta.messages[expectedSuggestion.messageId]; + const rehydratedDesc = interpolate(unformattedMetaMessage, expectedSuggestion.data); + + assert.strictEqual( + actualSuggestion.desc, + rehydratedDesc, + `${suggestionPrefix} Hydrated test desc "${rehydratedDesc}" does not match received desc "${actualSuggestion.desc}".` + ); } + } else { + assert.ok( + !hasOwnProperty(expectedSuggestion, "data"), + `${suggestionPrefix} Test must specify 'messageId' if 'data' is used.` + ); } - assertSuggestionKeyEquals("desc"); - assertSuggestionKeyEquals("messageId"); if (hasOwnProperty(expectedSuggestion, "output")) { const codeWithAppliedSuggestion = SourceCodeFixer.applyFixes(item.code, [actualSuggestion]).output; @@ -646,6 +839,12 @@ class RuleTester { } else { assert.strictEqual(result.output, item.output, "Output is incorrect."); } + } else { + assert.strictEqual( + result.output, + item.code, + "The rule fixed the code. Please add 'output' property." + ); } assertASTDidntChange(result.beforeAST, result.afterAST); diff --git a/tools/node_modules/eslint/lib/rules/accessor-pairs.js b/tools/node_modules/eslint/lib/rules/accessor-pairs.js index 3a32db6eac7214..02548258ca2e28 100644 --- a/tools/node_modules/eslint/lib/rules/accessor-pairs.js +++ b/tools/node_modules/eslint/lib/rules/accessor-pairs.js @@ -171,7 +171,7 @@ module.exports = { }, enforceForClassMembers: { type: "boolean", - default: false + default: true } }, additionalProperties: false @@ -190,7 +190,7 @@ module.exports = { const config = context.options[0] || {}; const checkGetWithoutSet = config.getWithoutSet === true; const checkSetWithoutGet = config.setWithoutGet !== false; - const enforceForClassMembers = config.enforceForClassMembers === true; + const enforceForClassMembers = config.enforceForClassMembers !== false; const sourceCode = context.getSourceCode(); /** diff --git a/tools/node_modules/eslint/lib/rules/array-callback-return.js b/tools/node_modules/eslint/lib/rules/array-callback-return.js index d632a3f30c28a3..eb38965024f05d 100644 --- a/tools/node_modules/eslint/lib/rules/array-callback-return.js +++ b/tools/node_modules/eslint/lib/rules/array-callback-return.js @@ -18,7 +18,7 @@ const astUtils = require("./utils/ast-utils"); //------------------------------------------------------------------------------ const TARGET_NODE_TYPE = /^(?:Arrow)?FunctionExpression$/u; -const TARGET_METHODS = /^(?:every|filter|find(?:Index)?|map|reduce(?:Right)?|some|sort)$/u; +const TARGET_METHODS = /^(?:every|filter|find(?:Index)?|flatMap|forEach|map|reduce(?:Right)?|some|sort)$/u; /** * Checks a given code path segment is reachable. @@ -61,12 +61,13 @@ function isTargetMethod(node) { /** * Checks whether or not a given node is a function expression which is the - * callback of an array method. + * callback of an array method, returning the method name. * @param {ASTNode} node A node to check. This is one of * FunctionExpression or ArrowFunctionExpression. - * @returns {boolean} `true` if the node is the callback of an array method. + * @returns {string} The method name if the node is a callback method, + * null otherwise. */ -function isCallbackOfArrayMethod(node) { +function getArrayMethodName(node) { let currentNode = node; while (currentNode) { @@ -95,7 +96,7 @@ function isCallbackOfArrayMethod(node) { const func = astUtils.getUpperFunction(parent); if (func === null || !astUtils.isCallee(func)) { - return false; + return null; } currentNode = func.parent; break; @@ -108,27 +109,31 @@ function isCallbackOfArrayMethod(node) { */ case "CallExpression": if (astUtils.isArrayFromMethod(parent.callee)) { - return ( + if ( parent.arguments.length >= 2 && parent.arguments[1] === currentNode - ); + ) { + return "from"; + } } if (isTargetMethod(parent.callee)) { - return ( + if ( parent.arguments.length >= 1 && parent.arguments[0] === currentNode - ); + ) { + return astUtils.getStaticPropertyName(parent.callee); + } } - return false; + return null; // Otherwise this node is not target. default: - return false; + return null; } } /* istanbul ignore next: unreachable */ - return false; + return null; } //------------------------------------------------------------------------------ @@ -153,6 +158,10 @@ module.exports = { allowImplicit: { type: "boolean", default: false + }, + checkForEach: { + type: "boolean", + default: false } }, additionalProperties: false @@ -162,15 +171,17 @@ module.exports = { messages: { expectedAtEnd: "Expected to return a value at the end of {{name}}.", expectedInside: "Expected to return a value in {{name}}.", - expectedReturnValue: "{{name}} expected a return value." + expectedReturnValue: "{{name}} expected a return value.", + expectedNoReturnValue: "{{name}} did not expect a return value." } }, create(context) { - const options = context.options[0] || { allowImplicit: false }; + const options = context.options[0] || { allowImplicit: false, checkForEach: false }; let funcInfo = { + arrayMethodName: null, upper: null, codePath: null, hasReturn: false, @@ -188,18 +199,32 @@ module.exports = { * @returns {void} */ function checkLastSegment(node) { - if (funcInfo.shouldCheck && - funcInfo.codePath.currentSegments.some(isReachable) - ) { + + if (!funcInfo.shouldCheck) { + return; + } + + let messageId = null; + + if (funcInfo.arrayMethodName === "forEach") { + if (options.checkForEach && node.type === "ArrowFunctionExpression" && node.expression) { + messageId = "expectedNoReturnValue"; + } + } else { + if (node.body.type === "BlockStatement" && funcInfo.codePath.currentSegments.some(isReachable)) { + messageId = funcInfo.hasReturn ? "expectedAtEnd" : "expectedInside"; + } + } + + if (messageId) { + let name = astUtils.getFunctionNameWithKind(funcInfo.node); + + name = messageId === "expectedNoReturnValue" ? lodash.upperFirst(name) : name; context.report({ node, loc: getLocation(node, context.getSourceCode()).loc.start, - messageId: funcInfo.hasReturn - ? "expectedAtEnd" - : "expectedInside", - data: { - name: astUtils.getFunctionNameWithKind(funcInfo.node) - } + messageId, + data: { name } }); } } @@ -208,14 +233,20 @@ module.exports = { // Stacks this function's information. onCodePathStart(codePath, node) { + + let methodName = null; + + if (TARGET_NODE_TYPE.test(node.type)) { + methodName = getArrayMethodName(node); + } + funcInfo = { + arrayMethodName: methodName, upper: funcInfo, codePath, hasReturn: false, shouldCheck: - TARGET_NODE_TYPE.test(node.type) && - node.body.type === "BlockStatement" && - isCallbackOfArrayMethod(node) && + methodName && !node.async && !node.generator, node @@ -229,20 +260,38 @@ module.exports = { // Checks the return statement is valid. ReturnStatement(node) { - if (funcInfo.shouldCheck) { - funcInfo.hasReturn = true; + + if (!funcInfo.shouldCheck) { + return; + } + + funcInfo.hasReturn = true; + + let messageId = null; + + if (funcInfo.arrayMethodName === "forEach") { + + // if checkForEach: true, returning a value at any path inside a forEach is not allowed + if (options.checkForEach && node.argument) { + messageId = "expectedNoReturnValue"; + } + } else { // if allowImplicit: false, should also check node.argument if (!options.allowImplicit && !node.argument) { - context.report({ - node, - messageId: "expectedReturnValue", - data: { - name: lodash.upperFirst(astUtils.getFunctionNameWithKind(funcInfo.node)) - } - }); + messageId = "expectedReturnValue"; } } + + if (messageId) { + context.report({ + node, + messageId, + data: { + name: lodash.upperFirst(astUtils.getFunctionNameWithKind(funcInfo.node)) + } + }); + } }, // Reports a given function if the last path is reachable. diff --git a/tools/node_modules/eslint/lib/rules/array-element-newline.js b/tools/node_modules/eslint/lib/rules/array-element-newline.js index 1da67667bee849..b7a967865b92a1 100644 --- a/tools/node_modules/eslint/lib/rules/array-element-newline.js +++ b/tools/node_modules/eslint/lib/rules/array-element-newline.js @@ -24,28 +24,52 @@ module.exports = { fixable: "whitespace", - schema: [ - { - oneOf: [ - { - enum: ["always", "never", "consistent"] - }, - { - type: "object", - properties: { - multiline: { - type: "boolean" + schema: { + definitions: { + basicConfig: { + oneOf: [ + { + enum: ["always", "never", "consistent"] + }, + { + type: "object", + properties: { + multiline: { + type: "boolean" + }, + minItems: { + type: ["integer", "null"], + minimum: 0 + } }, - minItems: { - type: ["integer", "null"], - minimum: 0 - } + additionalProperties: false + } + ] + } + }, + items: [ + { + oneOf: [ + { + $ref: "#/definitions/basicConfig" }, - additionalProperties: false - } - ] - } - ], + { + type: "object", + properties: { + ArrayExpression: { + $ref: "#/definitions/basicConfig" + }, + ArrayPattern: { + $ref: "#/definitions/basicConfig" + } + }, + additionalProperties: false, + minProperties: 1 + } + ] + } + ] + }, messages: { unexpectedLineBreak: "There should be no linebreak here.", @@ -93,6 +117,20 @@ module.exports = { * @returns {{ArrayExpression: {multiline: boolean, minItems: number}, ArrayPattern: {multiline: boolean, minItems: number}}} Normalized option object. */ function normalizeOptions(options) { + if (options && (options.ArrayExpression || options.ArrayPattern)) { + let expressionOptions, patternOptions; + + if (options.ArrayExpression) { + expressionOptions = normalizeOptionValue(options.ArrayExpression); + } + + if (options.ArrayPattern) { + patternOptions = normalizeOptionValue(options.ArrayPattern); + } + + return { ArrayExpression: expressionOptions, ArrayPattern: patternOptions }; + } + const value = normalizeOptionValue(options); return { ArrayExpression: value, ArrayPattern: value }; @@ -177,6 +215,10 @@ module.exports = { const normalizedOptions = normalizeOptions(context.options[0]); const options = normalizedOptions[node.type]; + if (!options) { + return; + } + let elementBreak = false; /* diff --git a/tools/node_modules/eslint/lib/rules/arrow-body-style.js b/tools/node_modules/eslint/lib/rules/arrow-body-style.js index 8d3b400037a6d5..9d5c77d8573d6a 100644 --- a/tools/node_modules/eslint/lib/rules/arrow-body-style.js +++ b/tools/node_modules/eslint/lib/rules/arrow-body-style.js @@ -91,7 +91,7 @@ module.exports = { * @returns {Token} The found closing parenthesis token. */ function findClosingParen(token) { - let node = sourceCode.getNodeByRangeIndex(token.range[1]); + let node = sourceCode.getNodeByRangeIndex(token.range[0]); while (!astUtils.isParenthesised(sourceCode, node)) { node = node.parent; @@ -206,24 +206,35 @@ module.exports = { fix(fixer) { const fixes = []; const arrowToken = sourceCode.getTokenBefore(arrowBody, astUtils.isArrowToken); - const firstBodyToken = sourceCode.getTokenAfter(arrowToken); - const lastBodyToken = sourceCode.getLastToken(node); + const [firstTokenAfterArrow, secondTokenAfterArrow] = sourceCode.getTokensAfter(arrowToken, { count: 2 }); + const lastToken = sourceCode.getLastToken(node); const isParenthesisedObjectLiteral = - astUtils.isOpeningParenToken(firstBodyToken) && - astUtils.isOpeningBraceToken(sourceCode.getTokenAfter(firstBodyToken)); - - // Wrap the value by a block and a return statement. - fixes.push( - fixer.insertTextBefore(firstBodyToken, "{return "), - fixer.insertTextAfter(lastBodyToken, "}") - ); + astUtils.isOpeningParenToken(firstTokenAfterArrow) && + astUtils.isOpeningBraceToken(secondTokenAfterArrow); // If the value is object literal, remove parentheses which were forced by syntax. if (isParenthesisedObjectLiteral) { - fixes.push( - fixer.remove(firstBodyToken), - fixer.remove(findClosingParen(firstBodyToken)) - ); + const openingParenToken = firstTokenAfterArrow; + const openingBraceToken = secondTokenAfterArrow; + + if (astUtils.isTokenOnSameLine(openingParenToken, openingBraceToken)) { + fixes.push(fixer.replaceText(openingParenToken, "{return ")); + } else { + + // Avoid ASI + fixes.push( + fixer.replaceText(openingParenToken, "{"), + fixer.insertTextBefore(openingBraceToken, "return ") + ); + } + + // Closing paren for the object doesn't have to be lastToken, e.g.: () => ({}).foo() + fixes.push(fixer.remove(findClosingParen(openingBraceToken))); + fixes.push(fixer.insertTextAfter(lastToken, "}")); + + } else { + fixes.push(fixer.insertTextBefore(firstTokenAfterArrow, "{return ")); + fixes.push(fixer.insertTextAfter(lastToken, "}")); } return fixes; diff --git a/tools/node_modules/eslint/lib/rules/camelcase.js b/tools/node_modules/eslint/lib/rules/camelcase.js index a06c7f94042ad4..04360837294a12 100644 --- a/tools/node_modules/eslint/lib/rules/camelcase.js +++ b/tools/node_modules/eslint/lib/rules/camelcase.js @@ -125,6 +125,40 @@ module.exports = { return false; } + /** + * Checks whether the given node represents assignment target property in destructuring. + * + * For examples: + * ({a: b.foo} = c); // => true for `foo` + * ([a.foo] = b); // => true for `foo` + * ([a.foo = 1] = b); // => true for `foo` + * ({...a.foo} = b); // => true for `foo` + * @param {ASTNode} node An Identifier node to check + * @returns {boolean} True if the node is an assignment target property in destructuring. + */ + function isAssignmentTargetPropertyInDestructuring(node) { + if ( + node.parent.type === "MemberExpression" && + node.parent.property === node && + !node.parent.computed + ) { + const effectiveParent = node.parent.parent; + + return ( + effectiveParent.type === "Property" && + effectiveParent.value === node.parent && + effectiveParent.parent.type === "ObjectPattern" || + effectiveParent.type === "ArrayPattern" || + effectiveParent.type === "RestElement" || + ( + effectiveParent.type === "AssignmentPattern" && + effectiveParent.left === node.parent + ) + ); + } + return false; + } + /** * Reports an AST node as a rule violation. * @param {ASTNode} node The node to report. @@ -170,6 +204,9 @@ module.exports = { // Report AssignmentExpressions only if they are the left side of the assignment } else if (effectiveParent.type === "AssignmentExpression" && nameIsUnderscored && (effectiveParent.right.type !== "MemberExpression" || effectiveParent.left.type === "MemberExpression" && effectiveParent.left.property.name === node.name)) { report(node); + + } else if (isAssignmentTargetPropertyInDestructuring(node) && nameIsUnderscored) { + report(node); } /* @@ -186,7 +223,7 @@ module.exports = { const assignmentKeyEqualsValue = node.parent.key.name === node.parent.value.name; - if (isUnderscored(name) && node.parent.computed) { + if (nameIsUnderscored && node.parent.computed) { report(node); } diff --git a/tools/node_modules/eslint/lib/rules/complexity.js b/tools/node_modules/eslint/lib/rules/complexity.js index 91180e989540ce..7fc8bf9bc2ea8c 100644 --- a/tools/node_modules/eslint/lib/rules/complexity.js +++ b/tools/node_modules/eslint/lib/rules/complexity.js @@ -1,6 +1,6 @@ /** * @fileoverview Counts the cyclomatic complexity of each function of the script. See http://en.wikipedia.org/wiki/Cyclomatic_complexity. - * Counts the number of if, conditional, for, whilte, try, switch/case, + * Counts the number of if, conditional, for, while, try, switch/case, * @author Patrick Brosset */ diff --git a/tools/node_modules/eslint/lib/rules/computed-property-spacing.js b/tools/node_modules/eslint/lib/rules/computed-property-spacing.js index a0bd7f48ced66b..53fdb8f4e41f95 100644 --- a/tools/node_modules/eslint/lib/rules/computed-property-spacing.js +++ b/tools/node_modules/eslint/lib/rules/computed-property-spacing.js @@ -32,7 +32,7 @@ module.exports = { properties: { enforceForClassMembers: { type: "boolean", - default: false + default: true } }, additionalProperties: false @@ -51,7 +51,7 @@ module.exports = { create(context) { const sourceCode = context.getSourceCode(); const propertyNameMustBeSpaced = context.options[0] === "always"; // default is "never" - const enforceForClassMembers = context.options[1] && context.options[1].enforceForClassMembers; + const enforceForClassMembers = !context.options[1] || context.options[1].enforceForClassMembers; //-------------------------------------------------------------------------- // Helpers @@ -67,7 +67,7 @@ module.exports = { function reportNoBeginningSpace(node, token, tokenAfter) { context.report({ node, - loc: token.loc.start, + loc: { start: token.loc.end, end: tokenAfter.loc.start }, messageId: "unexpectedSpaceAfter", data: { tokenValue: token.value @@ -88,7 +88,7 @@ module.exports = { function reportNoEndingSpace(node, token, tokenBefore) { context.report({ node, - loc: token.loc.start, + loc: { start: tokenBefore.loc.end, end: token.loc.start }, messageId: "unexpectedSpaceBefore", data: { tokenValue: token.value @@ -108,7 +108,7 @@ module.exports = { function reportRequiredBeginningSpace(node, token) { context.report({ node, - loc: token.loc.start, + loc: token.loc, messageId: "missingSpaceAfter", data: { tokenValue: token.value @@ -128,7 +128,7 @@ module.exports = { function reportRequiredEndingSpace(node, token) { context.report({ node, - loc: token.loc.start, + loc: token.loc, messageId: "missingSpaceBefore", data: { tokenValue: token.value diff --git a/tools/node_modules/eslint/lib/rules/consistent-this.js b/tools/node_modules/eslint/lib/rules/consistent-this.js index 16f53b5374cd24..e5bc9678daef3c 100644 --- a/tools/node_modules/eslint/lib/rules/consistent-this.js +++ b/tools/node_modules/eslint/lib/rules/consistent-this.js @@ -114,7 +114,7 @@ module.exports = { } /** - * Check each alias to ensure that is was assinged to the correct value. + * Check each alias to ensure that is was assigned to the correct value. * @returns {void} */ function ensureWasAssigned() { diff --git a/tools/node_modules/eslint/lib/rules/curly.js b/tools/node_modules/eslint/lib/rules/curly.js index ee2fe4dceb82bf..29f00c0ad0b617 100644 --- a/tools/node_modules/eslint/lib/rules/curly.js +++ b/tools/node_modules/eslint/lib/rules/curly.js @@ -141,33 +141,14 @@ module.exports = { } /** - * Checks a given IfStatement node requires braces of the consequent chunk. - * This returns `true` when below: - * - * 1. The given node has the `alternate` node. - * 2. There is a `IfStatement` which doesn't have `alternate` node in the - * trailing statement chain of the `consequent` node. - * @param {ASTNode} node A IfStatement node to check. - * @returns {boolean} `true` if the node requires braces of the consequent chunk. + * Determines whether the given node has an `else` keyword token as the first token after. + * @param {ASTNode} node The node to check. + * @returns {boolean} `true` if the node is followed by an `else` keyword token. */ - function requiresBraceOfConsequent(node) { - if (node.alternate && node.consequent.type === "BlockStatement") { - if (node.consequent.body.length >= 2) { - return true; - } - - for ( - let currentNode = node.consequent.body[0]; - currentNode; - currentNode = astUtils.getTrailingStatement(currentNode) - ) { - if (currentNode.type === "IfStatement" && !currentNode.alternate) { - return true; - } - } - } + function isFollowedByElseKeyword(node) { + const nextToken = sourceCode.getTokenAfter(node); - return false; + return Boolean(nextToken) && isElseKeywordToken(nextToken); } /** @@ -224,6 +205,110 @@ module.exports = { return false; } + /** + * Determines whether the code represented by the given node contains an `if` statement + * that would become associated with an `else` keyword directly appended to that code. + * + * Examples where it returns `true`: + * + * if (a) + * foo(); + * + * if (a) { + * foo(); + * } + * + * if (a) + * foo(); + * else if (b) + * bar(); + * + * while (a) + * if (b) + * if(c) + * foo(); + * else + * bar(); + * + * Examples where it returns `false`: + * + * if (a) + * foo(); + * else + * bar(); + * + * while (a) { + * if (b) + * if(c) + * foo(); + * else + * bar(); + * } + * + * while (a) + * if (b) { + * if(c) + * foo(); + * } + * else + * bar(); + * @param {ASTNode} node Node representing the code to check. + * @returns {boolean} `true` if an `if` statement within the code would become associated with an `else` appended to that code. + */ + function hasUnsafeIf(node) { + switch (node.type) { + case "IfStatement": + if (!node.alternate) { + return true; + } + return hasUnsafeIf(node.alternate); + case "ForStatement": + case "ForInStatement": + case "ForOfStatement": + case "LabeledStatement": + case "WithStatement": + case "WhileStatement": + return hasUnsafeIf(node.body); + default: + return false; + } + } + + /** + * Determines whether the existing curly braces around the single statement are necessary to preserve the semantics of the code. + * The braces, which make the given block body, are necessary in either of the following situations: + * + * 1. The statement is a lexical declaration. + * 2. Without the braces, an `if` within the statement would become associated with an `else` after the closing brace: + * + * if (a) { + * if (b) + * foo(); + * } + * else + * bar(); + * + * if (a) + * while (b) + * while (c) { + * while (d) + * if (e) + * while(f) + * foo(); + * } + * else + * bar(); + * @param {ASTNode} node `BlockStatement` body with exactly one statement directly inside. The statement can have its own nested statements. + * @returns {boolean} `true` if the braces are necessary - removing them (replacing the given `BlockStatement` body with its single statement content) + * would change the semantics of the code or produce a syntax error. + */ + function areBracesNecessary(node) { + const statement = node.body[0]; + + return isLexicalDeclaration(statement) || + hasUnsafeIf(statement) && isFollowedByElseKeyword(node); + } + /** * Prepares to check the body of a node to see if it's a block statement. * @param {ASTNode} node The node to report if there's a problem. @@ -242,30 +327,29 @@ module.exports = { const hasBlock = (body.type === "BlockStatement"); let expected = null; - if (node.type === "IfStatement" && node.consequent === body && requiresBraceOfConsequent(node)) { + if (hasBlock && (body.body.length !== 1 || areBracesNecessary(body))) { expected = true; } else if (multiOnly) { - if (hasBlock && body.body.length === 1 && !isLexicalDeclaration(body.body[0])) { - expected = false; - } + expected = false; } else if (multiLine) { if (!isCollapsedOneLiner(body)) { expected = true; } + + // otherwise, the body is allowed to have braces or not to have braces + } else if (multiOrNest) { - if (hasBlock && body.body.length === 1 && isOneLiner(body.body[0])) { - const leadingComments = sourceCode.getCommentsBefore(body.body[0]); - const isLexDef = isLexicalDeclaration(body.body[0]); - - if (isLexDef) { - expected = true; - } else { - expected = leadingComments.length > 0; - } - } else if (!isOneLiner(body)) { - expected = true; + if (hasBlock) { + const statement = body.body[0]; + const leadingCommentsInBlock = sourceCode.getCommentsBefore(statement); + + expected = !isOneLiner(statement) || leadingCommentsInBlock.length > 0; + } else { + expected = !isOneLiner(body); } } else { + + // default "all" expected = true; } diff --git a/tools/node_modules/eslint/lib/rules/default-case-last.js b/tools/node_modules/eslint/lib/rules/default-case-last.js new file mode 100644 index 00000000000000..80c5d6bda73958 --- /dev/null +++ b/tools/node_modules/eslint/lib/rules/default-case-last.js @@ -0,0 +1,44 @@ +/** + * @fileoverview Rule to enforce default clauses in switch statements to be last + * @author Milos Djermanovic + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +module.exports = { + meta: { + type: "suggestion", + + docs: { + description: "enforce default clauses in switch statements to be last", + category: "Best Practices", + recommended: false, + url: "https://eslint.org/docs/rules/default-case-last" + }, + + schema: [], + + messages: { + notLast: "Default clause should be the last clause." + } + }, + + create(context) { + return { + SwitchStatement(node) { + const cases = node.cases, + indexOfDefault = cases.findIndex(c => c.test === null); + + if (indexOfDefault !== -1 && indexOfDefault !== cases.length - 1) { + const defaultClause = cases[indexOfDefault]; + + context.report({ node: defaultClause, messageId: "notLast" }); + } + } + }; + } +}; diff --git a/tools/node_modules/eslint/lib/rules/func-names.js b/tools/node_modules/eslint/lib/rules/func-names.js index 1341d03630823f..ecfedb9e0e99c7 100644 --- a/tools/node_modules/eslint/lib/rules/func-names.js +++ b/tools/node_modules/eslint/lib/rules/func-names.js @@ -119,8 +119,7 @@ module.exports = { (parent.type === "VariableDeclarator" && parent.id.type === "Identifier" && parent.init === node) || (parent.type === "Property" && parent.value === node) || (parent.type === "AssignmentExpression" && parent.left.type === "Identifier" && parent.right === node) || - (parent.type === "ExportDefaultDeclaration" && parent.declaration === node) || - (parent.type === "AssignmentPattern" && parent.right === node); + (parent.type === "AssignmentPattern" && parent.left.type === "Identifier" && parent.right === node); } /** @@ -151,33 +150,41 @@ module.exports = { }); } - return { - "FunctionExpression:exit"(node) { + /** + * The listener for function nodes. + * @param {ASTNode} node function node + * @returns {void} + */ + function handleFunction(node) { - // Skip recursive functions. - const nameVar = context.getDeclaredVariables(node)[0]; + // Skip recursive functions. + const nameVar = context.getDeclaredVariables(node)[0]; - if (isFunctionName(nameVar) && nameVar.references.length > 0) { - return; - } + if (isFunctionName(nameVar) && nameVar.references.length > 0) { + return; + } - const hasName = Boolean(node.id && node.id.name); - const config = getConfigForNode(node); - - if (config === "never") { - if (hasName) { - reportUnexpectedNamedFunction(node); - } - } else if (config === "as-needed") { - if (!hasName && !hasInferredName(node)) { - reportUnexpectedUnnamedFunction(node); - } - } else { - if (!hasName && !isObjectOrClassMethod(node)) { - reportUnexpectedUnnamedFunction(node); - } + const hasName = Boolean(node.id && node.id.name); + const config = getConfigForNode(node); + + if (config === "never") { + if (hasName && node.type !== "FunctionDeclaration") { + reportUnexpectedNamedFunction(node); + } + } else if (config === "as-needed") { + if (!hasName && !hasInferredName(node)) { + reportUnexpectedUnnamedFunction(node); + } + } else { + if (!hasName && !isObjectOrClassMethod(node)) { + reportUnexpectedUnnamedFunction(node); } } + } + + return { + "FunctionExpression:exit": handleFunction, + "ExportDefaultDeclaration > FunctionDeclaration": handleFunction }; } }; diff --git a/tools/node_modules/eslint/lib/rules/id-blacklist.js b/tools/node_modules/eslint/lib/rules/id-blacklist.js index 53be62e68a3626..d77a35d41b670d 100644 --- a/tools/node_modules/eslint/lib/rules/id-blacklist.js +++ b/tools/node_modules/eslint/lib/rules/id-blacklist.js @@ -6,6 +6,105 @@ "use strict"; +//------------------------------------------------------------------------------ +// Helpers +//------------------------------------------------------------------------------ + +/** + * Checks whether the given node represents assignment target in a normal assignment or destructuring. + * @param {ASTNode} node The node to check. + * @returns {boolean} `true` if the node is assignment target. + */ +function isAssignmentTarget(node) { + const parent = node.parent; + + return ( + + // normal assignment + ( + parent.type === "AssignmentExpression" && + parent.left === node + ) || + + // destructuring + parent.type === "ArrayPattern" || + parent.type === "RestElement" || + ( + parent.type === "Property" && + parent.value === node && + parent.parent.type === "ObjectPattern" + ) || + ( + parent.type === "AssignmentPattern" && + parent.left === node + ) + ); +} + +/** + * Checks whether the given node represents an imported name that is renamed in the same import/export specifier. + * + * Examples: + * import { a as b } from 'mod'; // node `a` is renamed import + * export { a as b } from 'mod'; // node `a` is renamed import + * @param {ASTNode} node `Identifier` node to check. + * @returns {boolean} `true` if the node is a renamed import. + */ +function isRenamedImport(node) { + const parent = node.parent; + + return ( + ( + parent.type === "ImportSpecifier" && + parent.imported !== parent.local && + parent.imported === node + ) || + ( + parent.type === "ExportSpecifier" && + parent.parent.source && // re-export + parent.local !== parent.exported && + parent.local === node + ) + ); +} + +/** + * Checks whether the given node is a renamed identifier node in an ObjectPattern destructuring. + * + * Examples: + * const { a : b } = foo; // node `a` is renamed node. + * @param {ASTNode} node `Identifier` node to check. + * @returns {boolean} `true` if the node is a renamed node in an ObjectPattern destructuring. + */ +function isRenamedInDestructuring(node) { + const parent = node.parent; + + return ( + ( + !parent.computed && + parent.type === "Property" && + parent.parent.type === "ObjectPattern" && + parent.value !== node && + parent.key === node + ) + ); +} + +/** + * Checks whether the given node represents shorthand definition of a property in an object literal. + * @param {ASTNode} node `Identifier` node to check. + * @returns {boolean} `true` if the node is a shorthand property definition. + */ +function isShorthandPropertyDefinition(node) { + const parent = node.parent; + + return ( + parent.type === "Property" && + parent.parent.type === "ObjectExpression" && + parent.shorthand + ); +} + //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -35,35 +134,65 @@ module.exports = { create(context) { + const blacklist = new Set(context.options); + const reportedNodes = new Set(); - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - const blacklist = context.options; - + let globalScope; /** - * Checks if a string matches the provided pattern - * @param {string} name The string to check. - * @returns {boolean} if the string is a match + * Checks whether the given name is blacklisted. + * @param {string} name The name to check. + * @returns {boolean} `true` if the name is blacklisted. * @private */ - function isInvalid(name) { - return blacklist.indexOf(name) !== -1; + function isBlacklisted(name) { + return blacklist.has(name); } /** - * Verifies if we should report an error or not based on the effective - * parent node and the identifier name. - * @param {ASTNode} effectiveParent The effective parent node of the node to be reported - * @param {string} name The identifier name of the identifier node - * @returns {boolean} whether an error should be reported or not + * Checks whether the given node represents a reference to a global variable that is not declared in the source code. + * These identifiers will be allowed, as it is assumed that user has no control over the names of external global variables. + * @param {ASTNode} node `Identifier` node to check. + * @returns {boolean} `true` if the node is a reference to a global variable. */ - function shouldReport(effectiveParent, name) { - return effectiveParent.type !== "CallExpression" && - effectiveParent.type !== "NewExpression" && - isInvalid(name); + function isReferenceToGlobalVariable(node) { + const variable = globalScope.set.get(node.name); + + return variable && variable.defs.length === 0 && + variable.references.some(ref => ref.identifier === node); + } + + /** + * Determines whether the given node should be checked. + * @param {ASTNode} node `Identifier` node. + * @returns {boolean} `true` if the node should be checked. + */ + function shouldCheck(node) { + const parent = node.parent; + + /* + * Member access has special rules for checking property names. + * Read access to a property with a blacklisted name is allowed, because it can be on an object that user has no control over. + * Write access isn't allowed, because it potentially creates a new property with a blacklisted name. + */ + if ( + parent.type === "MemberExpression" && + parent.property === node && + !parent.computed + ) { + return isAssignmentTarget(parent); + } + + return ( + parent.type !== "CallExpression" && + parent.type !== "NewExpression" && + !isRenamedImport(node) && + !isRenamedInDestructuring(node) && + !( + isReferenceToGlobalVariable(node) && + !isShorthandPropertyDefinition(node) + ) + ); } /** @@ -73,55 +202,29 @@ module.exports = { * @private */ function report(node) { - context.report({ - node, - messageId: "blacklisted", - data: { - name: node.name - } - }); + if (!reportedNodes.has(node)) { + context.report({ + node, + messageId: "blacklisted", + data: { + name: node.name + } + }); + reportedNodes.add(node); + } } return { - Identifier(node) { - const name = node.name, - effectiveParent = (node.parent.type === "MemberExpression") ? node.parent.parent : node.parent; - - // MemberExpressions get special rules - if (node.parent.type === "MemberExpression") { - - // Always check object names - if (node.parent.object.type === "Identifier" && - node.parent.object.name === node.name) { - if (isInvalid(name)) { - report(node); - } - - // Report AssignmentExpressions only if they are the left side of the assignment - } else if (effectiveParent.type === "AssignmentExpression" && - (effectiveParent.right.type !== "MemberExpression" || - effectiveParent.left.type === "MemberExpression" && - effectiveParent.left.property.name === node.name)) { - if (isInvalid(name)) { - report(node); - } - } - - // Properties have their own rules - } else if (node.parent.type === "Property") { - - if (shouldReport(effectiveParent, name)) { - report(node); - } + Program() { + globalScope = context.getScope(); + }, - // Report anything that is a match and not a CallExpression - } else if (shouldReport(effectiveParent, name)) { + Identifier(node) { + if (isBlacklisted(node.name) && shouldCheck(node)) { report(node); } } - }; - } }; diff --git a/tools/node_modules/eslint/lib/rules/id-length.js b/tools/node_modules/eslint/lib/rules/id-length.js index c8586ea3481895..a68873ac06289b 100644 --- a/tools/node_modules/eslint/lib/rules/id-length.js +++ b/tools/node_modules/eslint/lib/rules/id-length.js @@ -63,6 +63,7 @@ module.exports = { return obj; }, {}); + const reportedNode = new Set(); const SUPPORTED_EXPRESSIONS = { MemberExpression: properties && function(parent) { @@ -82,8 +83,15 @@ module.exports = { VariableDeclarator(parent, node) { return parent.id === node; }, - Property: properties && function(parent, node) { - return parent.key === node; + Property(parent, node) { + + if (parent.parent.type === "ObjectPattern") { + return ( + parent.value !== parent.key && parent.value === node || + parent.value === parent.key && parent.key === node && properties + ); + } + return properties && !parent.computed && parent.key === node; }, ImportDefaultSpecifier: true, RestElement: true, @@ -92,7 +100,8 @@ module.exports = { ClassDeclaration: true, FunctionDeclaration: true, MethodDefinition: true, - CatchClause: true + CatchClause: true, + ArrayPattern: true }; return { @@ -109,7 +118,8 @@ module.exports = { const isValidExpression = SUPPORTED_EXPRESSIONS[parent.type]; - if (isValidExpression && (isValidExpression === true || isValidExpression(parent, node))) { + if (isValidExpression && !reportedNode.has(node) && (isValidExpression === true || isValidExpression(parent, node))) { + reportedNode.add(node); context.report({ node, messageId: isShort ? "tooShort" : "tooLong", diff --git a/tools/node_modules/eslint/lib/rules/indent-legacy.js b/tools/node_modules/eslint/lib/rules/indent-legacy.js index f1c024c368475d..50010d3f7acb16 100644 --- a/tools/node_modules/eslint/lib/rules/indent-legacy.js +++ b/tools/node_modules/eslint/lib/rules/indent-legacy.js @@ -696,20 +696,6 @@ module.exports = { return startLine === endLine; } - /** - * Check to see if the first element inside an array is an object and on the same line as the node - * If the node is not an array then it will return false. - * @param {ASTNode} node node to check - * @returns {boolean} success/failure - */ - function isFirstArrayElementOnSameLine(node) { - if (node.type === "ArrayExpression" && node.elements[0]) { - return node.elements[0].loc.start.line === node.loc.start.line && node.elements[0].type === "ObjectExpression"; - } - return false; - - } - /** * Check indent for array block content or object block content * @param {ASTNode} node node to examine @@ -776,8 +762,6 @@ module.exports = { nodeIndent += indentSize; } } - } else if (!parentVarNode && !isFirstArrayElementOnSameLine(parent) && parent.type !== "MemberExpression" && parent.type !== "ExpressionStatement" && parent.type !== "AssignmentExpression" && parent.type !== "Property") { - nodeIndent += indentSize; } checkFirstNodeLineIndent(node, nodeIndent); diff --git a/tools/node_modules/eslint/lib/rules/indent.js b/tools/node_modules/eslint/lib/rules/indent.js index 694cf7d9e6ed4f..d576fde0382461 100644 --- a/tools/node_modules/eslint/lib/rules/indent.js +++ b/tools/node_modules/eslint/lib/rules/indent.js @@ -540,8 +540,15 @@ module.exports = { ] }, outerIIFEBody: { - type: "integer", - minimum: 0 + oneOf: [ + { + type: "integer", + minimum: 0 + }, + { + enum: ["off"] + } + ] }, MemberExpression: { oneOf: [ @@ -590,6 +597,10 @@ module.exports = { type: "boolean", default: false }, + offsetTernaryExpressions: { + type: "boolean", + default: false + }, ignoredNodes: { type: "array", items: { @@ -922,7 +933,11 @@ module.exports = { parameterParens.add(openingParen); parameterParens.add(closingParen); - offsets.setDesiredOffset(openingParen, sourceCode.getTokenBefore(openingParen), 0); + + const offsetAfterToken = node.callee.type === "TaggedTemplateExpression" ? sourceCode.getFirstToken(node.callee.quasi) : openingParen; + const offsetToken = sourceCode.getTokenBefore(offsetAfterToken); + + offsets.setDesiredOffset(openingParen, offsetToken, 0); addElementListIndent(node.arguments, openingParen, closingParen, options.CallExpression.arguments); } @@ -1088,7 +1103,6 @@ module.exports = { }, "BlockStatement, ClassBody"(node) { - let blockIndentLevel; if (node.parent && isOuterIIFE(node.parent)) { @@ -1108,6 +1122,7 @@ module.exports = { if (!astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type)) { offsets.setDesiredOffset(sourceCode.getFirstToken(node), sourceCode.getFirstToken(node.parent), 0); } + addElementListIndent(node.body, sourceCode.getFirstToken(node), sourceCode.getLastToken(node), blockIndentLevel); }, @@ -1142,7 +1157,8 @@ module.exports = { offsets.setDesiredOffset(questionMarkToken, firstToken, 1); offsets.setDesiredOffset(colonToken, firstToken, 1); - offsets.setDesiredOffset(firstConsequentToken, firstToken, 1); + offsets.setDesiredOffset(firstConsequentToken, firstToken, + options.offsetTernaryExpressions ? 2 : 1); /* * The alternate and the consequent should usually have the same indentation. @@ -1167,7 +1183,9 @@ module.exports = { * If `baz` were aligned with `bar` rather than being offset by 1 from `foo`, `baz` would end up * having no expected indentation. */ - offsets.setDesiredOffset(firstAlternateToken, firstToken, 1); + offsets.setDesiredOffset(firstAlternateToken, firstToken, + firstAlternateToken.type === "Punctuator" && + options.offsetTernaryExpressions ? 2 : 1); } } }, diff --git a/tools/node_modules/eslint/lib/rules/index.js b/tools/node_modules/eslint/lib/rules/index.js index d3fbe412080360..7f563eb2ebfb96 100644 --- a/tools/node_modules/eslint/lib/rules/index.js +++ b/tools/node_modules/eslint/lib/rules/index.js @@ -37,6 +37,7 @@ module.exports = new LazyLoadingRuleMap(Object.entries({ "constructor-super": () => require("./constructor-super"), curly: () => require("./curly"), "default-case": () => require("./default-case"), + "default-case-last": () => require("./default-case-last"), "default-param-last": () => require("./default-param-last"), "dot-location": () => require("./dot-location"), "dot-notation": () => require("./dot-notation"), @@ -178,6 +179,7 @@ module.exports = new LazyLoadingRuleMap(Object.entries({ "no-prototype-builtins": () => require("./no-prototype-builtins"), "no-redeclare": () => require("./no-redeclare"), "no-regex-spaces": () => require("./no-regex-spaces"), + "no-restricted-exports": () => require("./no-restricted-exports"), "no-restricted-globals": () => require("./no-restricted-globals"), "no-restricted-imports": () => require("./no-restricted-imports"), "no-restricted-modules": () => require("./no-restricted-modules"), @@ -215,6 +217,7 @@ module.exports = new LazyLoadingRuleMap(Object.entries({ "no-unused-labels": () => require("./no-unused-labels"), "no-unused-vars": () => require("./no-unused-vars"), "no-use-before-define": () => require("./no-use-before-define"), + "no-useless-backreference": () => require("./no-useless-backreference"), "no-useless-call": () => require("./no-useless-call"), "no-useless-catch": () => require("./no-useless-catch"), "no-useless-computed-key": () => require("./no-useless-computed-key"), diff --git a/tools/node_modules/eslint/lib/rules/key-spacing.js b/tools/node_modules/eslint/lib/rules/key-spacing.js index 6d1b9121c78c5f..c405043794c7d1 100644 --- a/tools/node_modules/eslint/lib/rules/key-spacing.js +++ b/tools/node_modules/eslint/lib/rules/key-spacing.js @@ -414,8 +414,7 @@ module.exports = { if (property.computed) { return sourceCode.getText().slice(key.range[0], key.range[1]); } - - return property.key.name || property.key.value; + return astUtils.getStaticPropertyName(property); } /** diff --git a/tools/node_modules/eslint/lib/rules/linebreak-style.js b/tools/node_modules/eslint/lib/rules/linebreak-style.js index 97d552ea07c966..078eaf2cd268d2 100644 --- a/tools/node_modules/eslint/lib/rules/linebreak-style.js +++ b/tools/node_modules/eslint/lib/rules/linebreak-style.js @@ -64,7 +64,7 @@ module.exports = { //-------------------------------------------------------------------------- return { - Program: function checkForlinebreakStyle(node) { + Program: function checkForLinebreakStyle(node) { const linebreakStyle = context.options[0] || "unix", expectedLF = linebreakStyle === "unix", expectedLFChars = expectedLF ? "\n" : "\r\n", diff --git a/tools/node_modules/eslint/lib/rules/max-len.js b/tools/node_modules/eslint/lib/rules/max-len.js index b29099ed4c4f09..995e0c52026385 100644 --- a/tools/node_modules/eslint/lib/rules/max-len.js +++ b/tools/node_modules/eslint/lib/rules/max-len.js @@ -183,12 +183,27 @@ module.exports = { (end.line > lineNumber || (end.line === lineNumber && end.column === line.length)); } + /** + * Check if a node is a JSXEmptyExpression contained in a single line JSXExpressionContainer. + * @param {ASTNode} node A node to check. + * @returns {boolean} True if the node is a JSXEmptyExpression contained in a single line JSXExpressionContainer. + */ + function isJSXEmptyExpressionInSingleLineContainer(node) { + if (!node || !node.parent || node.type !== "JSXEmptyExpression" || node.parent.type !== "JSXExpressionContainer") { + return false; + } + + const parent = node.parent; + + return parent.loc.start.line === parent.loc.end.line; + } + /** * Gets the line after the comment and any remaining trailing whitespace is * stripped. * @param {string} line The source line with a trailing comment * @param {ASTNode} comment The comment to remove - * @returns {string} Line without comment and trailing whitepace + * @returns {string} Line without comment and trailing whitespace */ function stripTrailingComment(line, comment) { @@ -252,6 +267,33 @@ module.exports = { return acc; } + /** + * Returns an array of all comments in the source code. + * If the element in the array is a JSXEmptyExpression contained with a single line JSXExpressionContainer, + * the element is changed with JSXExpressionContainer node. + * @returns {ASTNode[]} An array of comment nodes + */ + function getAllComments() { + const comments = []; + + sourceCode.getAllComments() + .forEach(commentNode => { + const containingNode = sourceCode.getNodeByRangeIndex(commentNode.range[0]); + + if (isJSXEmptyExpressionInSingleLineContainer(containingNode)) { + + // push a unique node only + if (comments[comments.length - 1] !== containingNode.parent) { + comments.push(containingNode.parent); + } + } else { + comments.push(commentNode); + } + }); + + return comments; + } + /** * Check the program for max length * @param {ASTNode} node Node to examine @@ -264,7 +306,7 @@ module.exports = { const lines = sourceCode.lines, // list of comments to ignore - comments = ignoreComments || maxCommentLength || ignoreTrailingComments ? sourceCode.getAllComments() : []; + comments = ignoreComments || maxCommentLength || ignoreTrailingComments ? getAllComments() : []; // we iterate over comments in parallel with the lines let commentsIndex = 0; diff --git a/tools/node_modules/eslint/lib/rules/max-lines-per-function.js b/tools/node_modules/eslint/lib/rules/max-lines-per-function.js index 0cfc1f8da9e65e..03539fae470078 100644 --- a/tools/node_modules/eslint/lib/rules/max-lines-per-function.js +++ b/tools/node_modules/eslint/lib/rules/max-lines-per-function.js @@ -54,9 +54,6 @@ const OPTIONS_OR_INTEGER_SCHEMA = { function getCommentLineNumbers(comments) { const map = new Map(); - if (!comments) { - return map; - } comments.forEach(comment => { for (let i = comment.loc.start.line; i <= comment.loc.end.line; i++) { map.set(i, comment); diff --git a/tools/node_modules/eslint/lib/rules/multiline-comment-style.js b/tools/node_modules/eslint/lib/rules/multiline-comment-style.js index fb50e1522ea11d..9524818b8bd74d 100644 --- a/tools/node_modules/eslint/lib/rules/multiline-comment-style.js +++ b/tools/node_modules/eslint/lib/rules/multiline-comment-style.js @@ -316,6 +316,10 @@ module.exports = { const [, prefix = "", initialOffset = ""] = lineTextToAlignWith.match(/^(\s*(?:\/?\*)?(\s*))/u) || []; offset = `${commentTextPrefix.slice(prefix.length)}${initialOffset}`; + + if (/^\s*\//u.test(lineText) && offset.length === 0) { + offset += " "; + } break; } diff --git a/tools/node_modules/eslint/lib/rules/new-cap.js b/tools/node_modules/eslint/lib/rules/new-cap.js index cee979310ea7cc..7cce968c5aed0e 100644 --- a/tools/node_modules/eslint/lib/rules/new-cap.js +++ b/tools/node_modules/eslint/lib/rules/new-cap.js @@ -9,6 +9,8 @@ // Requirements //------------------------------------------------------------------------------ +const astUtils = require("./utils/ast-utils"); + //------------------------------------------------------------------------------ // Helpers //------------------------------------------------------------------------------ @@ -160,13 +162,7 @@ module.exports = { let name = ""; if (node.callee.type === "MemberExpression") { - const property = node.callee.property; - - if (property.type === "Literal" && (typeof property.value === "string")) { - name = property.value; - } else if (property.type === "Identifier" && !node.callee.computed) { - name = property.name; - } + name = astUtils.getStaticPropertyName(node.callee) || ""; } else { name = node.callee.name; } diff --git a/tools/node_modules/eslint/lib/rules/no-alert.js b/tools/node_modules/eslint/lib/rules/no-alert.js index 287cd2c35701f0..22d0dd57bdd82d 100644 --- a/tools/node_modules/eslint/lib/rules/no-alert.js +++ b/tools/node_modules/eslint/lib/rules/no-alert.js @@ -8,7 +8,10 @@ // Requirements //------------------------------------------------------------------------------ -const getPropertyName = require("./utils/ast-utils").getStaticPropertyName; +const { + getStaticPropertyName: getPropertyName, + getVariableByName +} = require("./utils/ast-utils"); //------------------------------------------------------------------------------ // Helpers @@ -61,7 +64,7 @@ function isGlobalThisReferenceOrGlobalWindow(scope, node) { if (scope.type === "global" && node.type === "ThisExpression") { return true; } - if (node.name === "window") { + if (node.name === "window" || (node.name === "globalThis" && getVariableByName(scope, "globalThis"))) { return !isShadowed(scope, node); } @@ -119,7 +122,6 @@ module.exports = { }); } } - } }; diff --git a/tools/node_modules/eslint/lib/rules/no-confusing-arrow.js b/tools/node_modules/eslint/lib/rules/no-confusing-arrow.js index b9a0e6ed0a70b5..9009b64fa1559a 100644 --- a/tools/node_modules/eslint/lib/rules/no-confusing-arrow.js +++ b/tools/node_modules/eslint/lib/rules/no-confusing-arrow.js @@ -1,6 +1,6 @@ /** * @fileoverview A rule to warn against using arrow functions when they could be - * confused with comparisions + * confused with comparisons * @author Jxck */ @@ -71,7 +71,7 @@ module.exports = { messageId: "confusing", fix(fixer) { - // if `allowParens` is not set to true dont bother wrapping in parens + // if `allowParens` is not set to true don't bother wrapping in parens return allowParens && fixer.replaceText(node.body, `(${sourceCode.getText(node.body)})`); } }); diff --git a/tools/node_modules/eslint/lib/rules/no-constant-condition.js b/tools/node_modules/eslint/lib/rules/no-constant-condition.js index d6d04174298cff..5e5838641028fe 100644 --- a/tools/node_modules/eslint/lib/rules/no-constant-condition.js +++ b/tools/node_modules/eslint/lib/rules/no-constant-condition.js @@ -90,13 +90,27 @@ module.exports = { * @private */ function isConstant(node, inBooleanPosition) { + + // node.elements can return null values in the case of sparse arrays ex. [,] + if (!node) { + return true; + } switch (node.type) { case "Literal": case "ArrowFunctionExpression": case "FunctionExpression": case "ObjectExpression": - case "ArrayExpression": return true; + case "TemplateLiteral": + return (inBooleanPosition && node.quasis.some(quasi => quasi.value.cooked.length)) || + node.expressions.every(exp => isConstant(exp, inBooleanPosition)); + + case "ArrayExpression": { + if (node.parent.type === "BinaryExpression" && node.parent.operator === "+") { + return node.elements.every(element => isConstant(element, false)); + } + return true; + } case "UnaryExpression": if (node.operator === "void") { diff --git a/tools/node_modules/eslint/lib/rules/no-control-regex.js b/tools/node_modules/eslint/lib/rules/no-control-regex.js index 24e6b197be0b44..b39f731c3cdf29 100644 --- a/tools/node_modules/eslint/lib/rules/no-control-regex.js +++ b/tools/node_modules/eslint/lib/rules/no-control-regex.js @@ -1,5 +1,5 @@ /** - * @fileoverview Rule to forbid control charactes from regular expressions. + * @fileoverview Rule to forbid control characters from regular expressions. * @author Nicholas C. Zakas */ diff --git a/tools/node_modules/eslint/lib/rules/no-dupe-class-members.js b/tools/node_modules/eslint/lib/rules/no-dupe-class-members.js index 6041e9e371ce5e..b12939d57bc884 100644 --- a/tools/node_modules/eslint/lib/rules/no-dupe-class-members.js +++ b/tools/node_modules/eslint/lib/rules/no-dupe-class-members.js @@ -5,6 +5,8 @@ "use strict"; +const astUtils = require("./utils/ast-utils"); + //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -53,21 +55,6 @@ module.exports = { return stateMap[key][isStatic ? "static" : "nonStatic"]; } - /** - * Gets the name text of a given node. - * @param {ASTNode} node A node to get the name. - * @returns {string} The name text of the node. - */ - function getName(node) { - switch (node.type) { - case "Identifier": return node.name; - case "Literal": return String(node.value); - - /* istanbul ignore next: syntax error */ - default: return ""; - } - } - return { // Initializes the stack of state of member declarations. @@ -87,11 +74,12 @@ module.exports = { // Reports the node if its name has been declared already. MethodDefinition(node) { - if (node.computed) { + const name = astUtils.getStaticPropertyName(node); + + if (name === null || node.kind === "constructor") { return; } - const name = getName(node.key); const state = getState(name, node.static); let isDuplicate = false; diff --git a/tools/node_modules/eslint/lib/rules/no-dupe-else-if.js b/tools/node_modules/eslint/lib/rules/no-dupe-else-if.js index a165e16607d2f0..cbeb437da1e7ec 100644 --- a/tools/node_modules/eslint/lib/rules/no-dupe-else-if.js +++ b/tools/node_modules/eslint/lib/rules/no-dupe-else-if.js @@ -53,7 +53,7 @@ module.exports = { docs: { description: "disallow duplicate conditions in if-else-if chains", category: "Possible Errors", - recommended: false, + recommended: true, url: "https://eslint.org/docs/rules/no-dupe-else-if" }, diff --git a/tools/node_modules/eslint/lib/rules/no-empty-function.js b/tools/node_modules/eslint/lib/rules/no-empty-function.js index c57e66fd534048..c74321158b3464 100644 --- a/tools/node_modules/eslint/lib/rules/no-empty-function.js +++ b/tools/node_modules/eslint/lib/rules/no-empty-function.js @@ -23,7 +23,9 @@ const ALLOW_OPTIONS = Object.freeze([ "generatorMethods", "getters", "setters", - "constructors" + "constructors", + "asyncFunctions", + "asyncMethods" ]); /** diff --git a/tools/node_modules/eslint/lib/rules/no-eval.js b/tools/node_modules/eslint/lib/rules/no-eval.js index 9e56fb00b9fc5b..811ad4e5d73dda 100644 --- a/tools/node_modules/eslint/lib/rules/no-eval.js +++ b/tools/node_modules/eslint/lib/rules/no-eval.js @@ -17,7 +17,8 @@ const astUtils = require("./utils/ast-utils"); const candidatesOfGlobalObject = Object.freeze([ "global", - "window" + "window", + "globalThis" ]); /** @@ -158,7 +159,7 @@ module.exports = { context.report({ node: reportNode, - loc: locationNode.loc.start, + loc: locationNode.loc, messageId: "unexpected" }); } diff --git a/tools/node_modules/eslint/lib/rules/no-extra-bind.js b/tools/node_modules/eslint/lib/rules/no-extra-bind.js index d938c0f51b06dd..df695924ab5299 100644 --- a/tools/node_modules/eslint/lib/rules/no-extra-bind.js +++ b/tools/node_modules/eslint/lib/rules/no-extra-bind.js @@ -64,7 +64,7 @@ module.exports = { context.report({ node: node.parent.parent, messageId: "unexpected", - loc: node.parent.property.loc.start, + loc: node.parent.property.loc, fix(fixer) { if (node.parent.parent.arguments.length && !isSideEffectFree(node.parent.parent.arguments[0])) { return null; diff --git a/tools/node_modules/eslint/lib/rules/no-extra-boolean-cast.js b/tools/node_modules/eslint/lib/rules/no-extra-boolean-cast.js index 336f601d1652de..aba8e63e086a41 100644 --- a/tools/node_modules/eslint/lib/rules/no-extra-boolean-cast.js +++ b/tools/node_modules/eslint/lib/rules/no-extra-boolean-cast.js @@ -10,6 +10,9 @@ //------------------------------------------------------------------------------ const astUtils = require("./utils/ast-utils"); +const eslintUtils = require("eslint-utils"); + +const precedence = astUtils.getPrecedence; //------------------------------------------------------------------------------ // Rule Definition @@ -26,7 +29,16 @@ module.exports = { url: "https://eslint.org/docs/rules/no-extra-boolean-cast" }, - schema: [], + schema: [{ + type: "object", + properties: { + enforceForLogicalOperands: { + type: "boolean", + default: false + } + }, + additionalProperties: false + }], fixable: "code", messages: { @@ -47,23 +59,67 @@ module.exports = { "ForStatement" ]; + /** + * Check if a node is a Boolean function or constructor. + * @param {ASTNode} node the node + * @returns {boolean} If the node is Boolean function or constructor + */ + function isBooleanFunctionOrConstructorCall(node) { + + // Boolean() and new Boolean() + return (node.type === "CallExpression" || node.type === "NewExpression") && + node.callee.type === "Identifier" && + node.callee.name === "Boolean"; + } + + /** + * Checks whether the node is a logical expression and that the option is enabled + * @param {ASTNode} node the node + * @returns {boolean} if the node is a logical expression and option is enabled + */ + function isLogicalContext(node) { + return node.type === "LogicalExpression" && + (node.operator === "||" || node.operator === "&&") && + (context.options.length && context.options[0].enforceForLogicalOperands === true); + + } + + /** * Check if a node is in a context where its value would be coerced to a boolean at runtime. * @param {ASTNode} node The node - * @param {ASTNode} parent Its parent * @returns {boolean} If it is in a boolean context */ - function isInBooleanContext(node, parent) { + function isInBooleanContext(node) { return ( - (BOOLEAN_NODE_TYPES.indexOf(parent.type) !== -1 && - node === parent.test) || + (isBooleanFunctionOrConstructorCall(node.parent) && + node === node.parent.arguments[0]) || + + (BOOLEAN_NODE_TYPES.indexOf(node.parent.type) !== -1 && + node === node.parent.test) || // ! - (parent.type === "UnaryExpression" && - parent.operator === "!") + (node.parent.type === "UnaryExpression" && + node.parent.operator === "!") ); } + /** + * Checks whether the node is a context that should report an error + * Acts recursively if it is in a logical context + * @param {ASTNode} node the node + * @returns {boolean} If the node is in one of the flagged contexts + */ + function isInFlaggedContext(node) { + return isInBooleanContext(node) || + (isLogicalContext(node.parent) && + + // For nested logical statements + isInFlaggedContext(node.parent) + ); + } + + /** * Check if a node has comments inside. * @param {ASTNode} node The node to check. @@ -73,40 +129,95 @@ module.exports = { return Boolean(sourceCode.getCommentsInside(node).length); } + /** + * Checks if the given node is wrapped in grouping parentheses. Parentheses for constructs such as if() don't count. + * @param {ASTNode} node The node to check. + * @returns {boolean} `true` if the node is parenthesized. + * @private + */ + function isParenthesized(node) { + return eslintUtils.isParenthesized(1, node, sourceCode); + } + + /** + * Determines whether the given node needs to be parenthesized when replacing the previous node. + * It assumes that `previousNode` is the node to be reported by this rule, so it has a limited list + * of possible parent node types. By the same assumption, the node's role in a particular parent is already known. + * For example, if the parent is `ConditionalExpression`, `previousNode` must be its `test` child. + * @param {ASTNode} previousNode Previous node. + * @param {ASTNode} node The node to check. + * @returns {boolean} `true` if the node needs to be parenthesized. + */ + function needsParens(previousNode, node) { + if (isParenthesized(previousNode)) { + + // parentheses around the previous node will stay, so there is no need for an additional pair + return false; + } + + // parent of the previous node will become parent of the replacement node + const parent = previousNode.parent; + + switch (parent.type) { + case "CallExpression": + case "NewExpression": + return node.type === "SequenceExpression"; + case "IfStatement": + case "DoWhileStatement": + case "WhileStatement": + case "ForStatement": + return false; + case "ConditionalExpression": + return precedence(node) <= precedence(parent); + case "UnaryExpression": + return precedence(node) < precedence(parent); + case "LogicalExpression": + if (previousNode === parent.left) { + return precedence(node) < precedence(parent); + } + return precedence(node) <= precedence(parent); + + /* istanbul ignore next */ + default: + throw new Error(`Unexpected parent type: ${parent.type}`); + } + } + return { UnaryExpression(node) { - const ancestors = context.getAncestors(), - parent = ancestors.pop(), - grandparent = ancestors.pop(); + const parent = node.parent; + // Exit early if it's guaranteed not to match if (node.operator !== "!" || - parent.type !== "UnaryExpression" || - parent.operator !== "!") { + parent.type !== "UnaryExpression" || + parent.operator !== "!") { return; } - if (isInBooleanContext(parent, grandparent) || - // Boolean() and new Boolean() - ((grandparent.type === "CallExpression" || grandparent.type === "NewExpression") && - grandparent.callee.type === "Identifier" && - grandparent.callee.name === "Boolean") - ) { + if (isInFlaggedContext(parent)) { context.report({ node: parent, messageId: "unexpectedNegation", - fix: fixer => { + fix(fixer) { if (hasCommentsInside(parent)) { return null; } + if (needsParens(parent, node.argument)) { + return fixer.replaceText(parent, `(${sourceCode.getText(node.argument)})`); + } + let prefix = ""; const tokenBefore = sourceCode.getTokenBefore(parent); const firstReplacementToken = sourceCode.getFirstToken(node.argument); - if (tokenBefore && tokenBefore.range[1] === parent.range[0] && - !astUtils.canTokensBeAdjacent(tokenBefore, firstReplacementToken)) { + if ( + tokenBefore && + tokenBefore.range[1] === parent.range[0] && + !astUtils.canTokensBeAdjacent(tokenBefore, firstReplacementToken) + ) { prefix = " "; } @@ -115,22 +226,25 @@ module.exports = { }); } }, - CallExpression(node) { - const parent = node.parent; + CallExpression(node) { if (node.callee.type !== "Identifier" || node.callee.name !== "Boolean") { return; } - if (isInBooleanContext(node, parent)) { + if (isInFlaggedContext(node)) { context.report({ node, messageId: "unexpectedCall", - fix: fixer => { - if (!node.arguments.length) { + fix(fixer) { + const parent = node.parent; + + if (node.arguments.length === 0) { if (parent.type === "UnaryExpression" && parent.operator === "!") { - // !Boolean() -> true + /* + * !Boolean() -> true + */ if (hasCommentsInside(parent)) { return null; @@ -140,32 +254,48 @@ module.exports = { let prefix = ""; const tokenBefore = sourceCode.getTokenBefore(parent); - if (tokenBefore && tokenBefore.range[1] === parent.range[0] && - !astUtils.canTokensBeAdjacent(tokenBefore, replacement)) { + if ( + tokenBefore && + tokenBefore.range[1] === parent.range[0] && + !astUtils.canTokensBeAdjacent(tokenBefore, replacement) + ) { prefix = " "; } return fixer.replaceText(parent, prefix + replacement); } - // Boolean() -> false + /* + * Boolean() -> false + */ + if (hasCommentsInside(node)) { return null; } + return fixer.replaceText(node, "false"); } - if (node.arguments.length > 1 || node.arguments[0].type === "SpreadElement" || - hasCommentsInside(node)) { - return null; - } + if (node.arguments.length === 1) { + const argument = node.arguments[0]; - const argument = node.arguments[0]; + if (argument.type === "SpreadElement" || hasCommentsInside(node)) { + return null; + } + + /* + * Boolean(expression) -> expression + */ - if (astUtils.getPrecedence(argument) < astUtils.getPrecedence(node.parent)) { - return fixer.replaceText(node, `(${sourceCode.getText(argument)})`); + if (needsParens(node, argument)) { + return fixer.replaceText(node, `(${sourceCode.getText(argument)})`); + } + + return fixer.replaceText(node, sourceCode.getText(argument)); } - return fixer.replaceText(node, sourceCode.getText(argument)); + + // two or more arguments + return null; } }); } diff --git a/tools/node_modules/eslint/lib/rules/no-extra-parens.js b/tools/node_modules/eslint/lib/rules/no-extra-parens.js index f96e572bfeef54..a3dd5bab699da3 100644 --- a/tools/node_modules/eslint/lib/rules/no-extra-parens.js +++ b/tools/node_modules/eslint/lib/rules/no-extra-parens.js @@ -169,6 +169,28 @@ module.exports = { return ruleApplies(node) && isParenthesisedTwice(node); } + /** + * Determines if a node that is expected to be parenthesised is surrounded by + * (potentially) invalid extra parentheses with considering precedence level of the node. + * If the preference level of the node is not higher or equal to precedence lower limit, it also checks + * whether the node is surrounded by parentheses twice or not. + * @param {ASTNode} node The node to be checked. + * @param {number} precedenceLowerLimit The lower limit of precedence. + * @returns {boolean} True if the node is has an unexpected extra pair of parentheses. + * @private + */ + function hasExcessParensWithPrecedence(node, precedenceLowerLimit) { + if (ruleApplies(node) && isParenthesised(node)) { + if ( + precedence(node) >= precedenceLowerLimit || + isParenthesisedTwice(node) + ) { + return true; + } + } + return false; + } + /** * Determines if a node test expression is allowed to have a parenthesised assignment * @param {ASTNode} node The node to be checked. @@ -285,13 +307,13 @@ module.exports = { */ function requiresLeadingSpace(node) { const leftParenToken = sourceCode.getTokenBefore(node); - const tokenBeforeLeftParen = sourceCode.getTokenBefore(node, 1); - const firstToken = sourceCode.getFirstToken(node); + const tokenBeforeLeftParen = sourceCode.getTokenBefore(leftParenToken, { includeComments: true }); + const tokenAfterLeftParen = sourceCode.getTokenAfter(leftParenToken, { includeComments: true }); return tokenBeforeLeftParen && tokenBeforeLeftParen.range[1] === leftParenToken.range[0] && - leftParenToken.range[1] === firstToken.range[0] && - !astUtils.canTokensBeAdjacent(tokenBeforeLeftParen, firstToken); + leftParenToken.range[1] === tokenAfterLeftParen.range[0] && + !astUtils.canTokensBeAdjacent(tokenBeforeLeftParen, tokenAfterLeftParen); } /** @@ -320,6 +342,17 @@ module.exports = { return node.type === "CallExpression" && node.callee.type === "FunctionExpression"; } + /** + * Determines if the given node can be the assignment target in destructuring or the LHS of an assignment. + * This is to avoid an autofix that could change behavior because parsers mistakenly allow invalid syntax, + * such as `(a = b) = c` and `[(a = b) = c] = []`. Ideally, this function shouldn't be necessary. + * @param {ASTNode} [node] The node to check + * @returns {boolean} `true` if the given node can be a valid assignment target + */ + function canBeAssignmentTarget(node) { + return node && (node.type === "Identifier" || node.type === "MemberExpression"); + } + /** * Report the node * @param {ASTNode} node node to evaluate @@ -370,17 +403,13 @@ module.exports = { } /** - * Evaluate Unary update + * Evaluate a argument of the node. * @param {ASTNode} node node to evaluate * @returns {void} * @private */ - function checkUnaryUpdate(node) { - if (node.type === "UnaryExpression" && node.argument.type === "BinaryExpression" && node.argument.operator === "**") { - return; - } - - if (hasExcessParens(node.argument) && precedence(node.argument) >= precedence(node)) { + function checkArgumentWithPrecedence(node) { + if (hasExcessParensWithPrecedence(node.argument, precedence(node))) { report(node.argument); } } @@ -411,25 +440,24 @@ module.exports = { function checkCallNew(node) { const callee = node.callee; - if (hasExcessParens(callee) && precedence(callee) >= precedence(node)) { + if (hasExcessParensWithPrecedence(callee, precedence(node))) { const hasNewParensException = callee.type === "NewExpression" && !isNewExpressionWithParens(callee); if ( hasDoubleExcessParens(callee) || !isIIFE(node) && !hasNewParensException && !( - /* - * Allow extra parens around a new expression if - * there are intervening parentheses. - */ - (callee.type === "MemberExpression" && doesMemberExpressionContainCallExpression(callee)) + // Allow extra parens around a new expression if they are intervening parentheses. + node.type === "NewExpression" && + callee.type === "MemberExpression" && + doesMemberExpressionContainCallExpression(callee) ) ) { report(node.callee); } } node.arguments - .filter(arg => hasExcessParens(arg) && precedence(arg) >= PRECEDENCE_OF_ASSIGNMENT_EXPR) + .filter(arg => hasExcessParensWithPrecedence(arg, PRECEDENCE_OF_ASSIGNMENT_EXPR)) .forEach(report); } @@ -444,15 +472,26 @@ module.exports = { const leftPrecedence = precedence(node.left); const rightPrecedence = precedence(node.right); const isExponentiation = node.operator === "**"; - const shouldSkipLeft = (NESTED_BINARY && (node.left.type === "BinaryExpression" || node.left.type === "LogicalExpression")) || - node.left.type === "UnaryExpression" && isExponentiation; + const shouldSkipLeft = NESTED_BINARY && (node.left.type === "BinaryExpression" || node.left.type === "LogicalExpression"); const shouldSkipRight = NESTED_BINARY && (node.right.type === "BinaryExpression" || node.right.type === "LogicalExpression"); - if (!shouldSkipLeft && hasExcessParens(node.left) && (leftPrecedence > prec || (leftPrecedence === prec && !isExponentiation))) { - report(node.left); + if (!shouldSkipLeft && hasExcessParens(node.left)) { + if ( + !(node.left.type === "UnaryExpression" && isExponentiation) && + (leftPrecedence > prec || (leftPrecedence === prec && !isExponentiation)) || + isParenthesisedTwice(node.left) + ) { + report(node.left); + } } - if (!shouldSkipRight && hasExcessParens(node.right) && (rightPrecedence > prec || (rightPrecedence === prec && isExponentiation))) { - report(node.right); + + if (!shouldSkipRight && hasExcessParens(node.right)) { + if ( + (rightPrecedence > prec || (rightPrecedence === prec && isExponentiation)) || + isParenthesisedTwice(node.right) + ) { + report(node.right); + } } } @@ -485,11 +524,7 @@ module.exports = { * @returns {void} */ function checkSpreadOperator(node) { - const hasExtraParens = precedence(node.argument) >= PRECEDENCE_OF_ASSIGNMENT_EXPR - ? hasExcessParens(node.argument) - : hasDoubleExcessParens(node.argument); - - if (hasExtraParens) { + if (hasExcessParensWithPrecedence(node.argument, PRECEDENCE_OF_ASSIGNMENT_EXPR)) { report(node.argument); } } @@ -651,7 +686,13 @@ module.exports = { return { ArrayExpression(node) { node.elements - .filter(e => e && hasExcessParens(e) && precedence(e) >= PRECEDENCE_OF_ASSIGNMENT_EXPR) + .filter(e => e && hasExcessParensWithPrecedence(e, PRECEDENCE_OF_ASSIGNMENT_EXPR)) + .forEach(report); + }, + + ArrayPattern(node) { + node.elements + .filter(e => canBeAssignmentTarget(e) && hasExcessParens(e)) .forEach(report); }, @@ -661,8 +702,7 @@ module.exports = { } if (node.body.type === "ConditionalExpression" && - IGNORE_ARROW_CONDITIONALS && - !isParenthesisedTwice(node.body) + IGNORE_ARROW_CONDITIONALS ) { return; } @@ -674,18 +714,18 @@ module.exports = { if (astUtils.isOpeningParenToken(tokenBeforeFirst) && astUtils.isOpeningBraceToken(firstBodyToken)) { tokensToIgnore.add(firstBodyToken); } - if (hasExcessParens(node.body) && precedence(node.body) >= PRECEDENCE_OF_ASSIGNMENT_EXPR) { + if (hasExcessParensWithPrecedence(node.body, PRECEDENCE_OF_ASSIGNMENT_EXPR)) { report(node.body); } } }, AssignmentExpression(node) { - if (isReturnAssignException(node)) { - return; + if (canBeAssignmentTarget(node.left) && hasExcessParens(node.left)) { + report(node.left); } - if (hasExcessParens(node.right) && precedence(node.right) >= precedence(node)) { + if (!isReturnAssignException(node) && hasExcessParensWithPrecedence(node.right, precedence(node))) { report(node.right); } }, @@ -702,8 +742,8 @@ module.exports = { ClassBody(node) { node.body - .filter(member => member.type === "MethodDefinition" && member.computed && - member.key && hasExcessParens(member.key) && precedence(member.key) >= PRECEDENCE_OF_ASSIGNMENT_EXPR) + .filter(member => member.type === "MethodDefinition" && member.computed && member.key) + .filter(member => hasExcessParensWithPrecedence(member.key, PRECEDENCE_OF_ASSIGNMENT_EXPR)) .forEach(member => report(member.key)); }, @@ -711,16 +751,18 @@ module.exports = { if (isReturnAssignException(node)) { return; } - - if (hasExcessParens(node.test) && precedence(node.test) >= precedence({ type: "LogicalExpression", operator: "||" })) { + if ( + !isCondAssignException(node) && + hasExcessParensWithPrecedence(node.test, precedence({ type: "LogicalExpression", operator: "||" })) + ) { report(node.test); } - if (hasExcessParens(node.consequent) && precedence(node.consequent) >= PRECEDENCE_OF_ASSIGNMENT_EXPR) { + if (hasExcessParensWithPrecedence(node.consequent, PRECEDENCE_OF_ASSIGNMENT_EXPR)) { report(node.consequent); } - if (hasExcessParens(node.alternate) && precedence(node.alternate) >= PRECEDENCE_OF_ASSIGNMENT_EXPR) { + if (hasExcessParensWithPrecedence(node.alternate, PRECEDENCE_OF_ASSIGNMENT_EXPR)) { report(node.alternate); } }, @@ -757,9 +799,19 @@ module.exports = { tokensToIgnore.add(firstLeftToken); } } - if (!(node.type === "ForOfStatement" && node.right.type === "SequenceExpression") && hasExcessParens(node.right)) { + + if (node.type === "ForOfStatement") { + const hasExtraParens = node.right.type === "SequenceExpression" + ? hasDoubleExcessParens(node.right) + : hasExcessParens(node.right); + + if (hasExtraParens) { + report(node.right); + } + } else if (hasExcessParens(node.right)) { report(node.right); } + if (hasExcessParens(node.left)) { report(node.left); } @@ -910,11 +962,17 @@ module.exports = { NewExpression: checkCallNew, ObjectExpression(node) { + node.properties + .filter(property => property.value && hasExcessParensWithPrecedence(property.value, PRECEDENCE_OF_ASSIGNMENT_EXPR)) + .forEach(property => report(property.value)); + }, + + ObjectPattern(node) { node.properties .filter(property => { const value = property.value; - return value && hasExcessParens(value) && precedence(value) >= PRECEDENCE_OF_ASSIGNMENT_EXPR; + return canBeAssignmentTarget(value) && hasExcessParens(value); }).forEach(property => report(property.value)); }, @@ -922,12 +980,20 @@ module.exports = { if (node.computed) { const { key } = node; - if (key && hasExcessParens(key) && precedence(key) >= PRECEDENCE_OF_ASSIGNMENT_EXPR) { + if (key && hasExcessParensWithPrecedence(key, PRECEDENCE_OF_ASSIGNMENT_EXPR)) { report(key); } } }, + RestElement(node) { + const argument = node.argument; + + if (canBeAssignmentTarget(argument) && hasExcessParens(argument)) { + report(argument); + } + }, + ReturnStatement(node) { const returnToken = sourceCode.getFirstToken(node); @@ -945,8 +1011,10 @@ module.exports = { }, SequenceExpression(node) { + const precedenceOfNode = precedence(node); + node.expressions - .filter(e => hasExcessParens(e) && precedence(e) >= precedence(node)) + .filter(e => hasExcessParensWithPrecedence(e, precedenceOfNode)) .forEach(report); }, @@ -970,16 +1038,17 @@ module.exports = { } }, - UnaryExpression: checkUnaryUpdate, - UpdateExpression: checkUnaryUpdate, - AwaitExpression: checkUnaryUpdate, + UnaryExpression: checkArgumentWithPrecedence, + UpdateExpression: checkArgumentWithPrecedence, + AwaitExpression: checkArgumentWithPrecedence, VariableDeclarator(node) { - if (node.init && hasExcessParens(node.init) && - precedence(node.init) >= PRECEDENCE_OF_ASSIGNMENT_EXPR && + if ( + node.init && hasExcessParensWithPrecedence(node.init, PRECEDENCE_OF_ASSIGNMENT_EXPR) && - // RegExp literal is allowed to have parens (#1589) - !(node.init.type === "Literal" && node.init.regex)) { + // RegExp literal is allowed to have parens (#1589) + !(node.init.type === "Literal" && node.init.regex) + ) { report(node.init); } }, @@ -1022,9 +1091,13 @@ module.exports = { }, AssignmentPattern(node) { - const { right } = node; + const { left, right } = node; + + if (canBeAssignmentTarget(left) && hasExcessParens(left)) { + report(left); + } - if (right && hasExcessParens(right) && precedence(right) >= PRECEDENCE_OF_ASSIGNMENT_EXPR) { + if (right && hasExcessParensWithPrecedence(right, PRECEDENCE_OF_ASSIGNMENT_EXPR)) { report(right); } } diff --git a/tools/node_modules/eslint/lib/rules/no-func-assign.js b/tools/node_modules/eslint/lib/rules/no-func-assign.js index 66756e62bef5b2..33d0ad9ecd1433 100644 --- a/tools/node_modules/eslint/lib/rules/no-func-assign.js +++ b/tools/node_modules/eslint/lib/rules/no-func-assign.js @@ -22,7 +22,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-func-assign" }, - schema: [] + schema: [], + + messages: { + isAFunction: "'{{name}}' is a function." + } }, create(context) { @@ -34,7 +38,13 @@ module.exports = { */ function checkReference(references) { astUtils.getModifyingReferences(references).forEach(reference => { - context.report({ node: reference.identifier, message: "'{{name}}' is a function.", data: { name: reference.identifier.name } }); + context.report({ + node: reference.identifier, + messageId: "isAFunction", + data: { + name: reference.identifier.name + } + }); }); } diff --git a/tools/node_modules/eslint/lib/rules/no-global-assign.js b/tools/node_modules/eslint/lib/rules/no-global-assign.js index 4ab0c706446256..ea854c4aa8cd9b 100644 --- a/tools/node_modules/eslint/lib/rules/no-global-assign.js +++ b/tools/node_modules/eslint/lib/rules/no-global-assign.js @@ -32,7 +32,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + globalShouldNotBeModified: "Read-only global '{{name}}' should not be modified." + } }, create(context) { @@ -60,8 +64,10 @@ module.exports = { ) { context.report({ node: identifier, - message: "Read-only global '{{name}}' should not be modified.", - data: identifier + messageId: "globalShouldNotBeModified", + data: { + name: identifier.name + } }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-implicit-coercion.js b/tools/node_modules/eslint/lib/rules/no-implicit-coercion.js index c80f9813020be5..6d5ee61e96bd5b 100644 --- a/tools/node_modules/eslint/lib/rules/no-implicit-coercion.js +++ b/tools/node_modules/eslint/lib/rules/no-implicit-coercion.js @@ -187,7 +187,11 @@ module.exports = { } }, additionalProperties: false - }] + }], + + messages: { + useRecommendation: "use `{{recommendation}}` instead." + } }, create(context) { @@ -204,7 +208,7 @@ module.exports = { function report(node, recommendation, shouldFix) { context.report({ node, - message: "use `{{recommendation}}` instead.", + messageId: "useRecommendation", data: { recommendation }, diff --git a/tools/node_modules/eslint/lib/rules/no-implied-eval.js b/tools/node_modules/eslint/lib/rules/no-implied-eval.js index e0764d8223db0a..1668a0432a5277 100644 --- a/tools/node_modules/eslint/lib/rules/no-implied-eval.js +++ b/tools/node_modules/eslint/lib/rules/no-implied-eval.js @@ -5,6 +5,13 @@ "use strict"; +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const astUtils = require("./utils/ast-utils"); +const { getStaticValue } = require("eslint-utils"); + //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -20,95 +27,105 @@ module.exports = { url: "https://eslint.org/docs/rules/no-implied-eval" }, - schema: [] + schema: [], + + messages: { + impliedEval: "Implied eval. Consider passing a function instead of a string." + } }, create(context) { - const CALLEE_RE = /^(setTimeout|setInterval|execScript)$/u; - - /* - * Figures out if we should inspect a given binary expression. Is a stack - * of stacks, where the first element in each substack is a CallExpression. - */ - const impliedEvalAncestorsStack = []; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- + const EVAL_LIKE_FUNCS = Object.freeze(["setTimeout", "execScript", "setInterval"]); + const GLOBAL_CANDIDATES = Object.freeze(["global", "window", "globalThis"]); /** - * Get the last element of an array, without modifying arr, like pop(), but non-destructive. - * @param {Array} arr What to inspect - * @returns {*} The last element of arr - * @private + * Checks whether a node is evaluated as a string or not. + * @param {ASTNode} node A node to check. + * @returns {boolean} True if the node is evaluated as a string. */ - function last(arr) { - return arr ? arr[arr.length - 1] : null; + function isEvaluatedString(node) { + if ( + (node.type === "Literal" && typeof node.value === "string") || + node.type === "TemplateLiteral" + ) { + return true; + } + if (node.type === "BinaryExpression" && node.operator === "+") { + return isEvaluatedString(node.left) || isEvaluatedString(node.right); + } + return false; } /** - * Checks if the given MemberExpression node is a potentially implied eval identifier on window. - * @param {ASTNode} node The MemberExpression node to check. - * @returns {boolean} Whether or not the given node is potentially an implied eval. - * @private + * Checks whether a node is an Identifier node named one of the specified names. + * @param {ASTNode} node A node to check. + * @param {string[]} specifiers Array of specified name. + * @returns {boolean} True if the node is a Identifier node which has specified name. */ - function isImpliedEvalMemberExpression(node) { - const object = node.object, - property = node.property, - hasImpliedEvalName = CALLEE_RE.test(property.name) || CALLEE_RE.test(property.value); - - return object.name === "window" && hasImpliedEvalName; + function isSpecifiedIdentifier(node, specifiers) { + return node.type === "Identifier" && specifiers.includes(node.name); } /** - * Determines if a node represents a call to a potentially implied eval. - * - * This checks the callee name and that there's an argument, but not the type of the argument. - * @param {ASTNode} node The CallExpression to check. - * @returns {boolean} True if the node matches, false if not. - * @private + * Checks a given node is a MemberExpression node which has the specified name's + * property. + * @param {ASTNode} node A node to check. + * @param {string[]} specifiers Array of specified name. + * @returns {boolean} `true` if the node is a MemberExpression node which has + * the specified name's property */ - function isImpliedEvalCallExpression(node) { - const isMemberExpression = (node.callee.type === "MemberExpression"), - isIdentifier = (node.callee.type === "Identifier"), - isImpliedEvalCallee = - (isIdentifier && CALLEE_RE.test(node.callee.name)) || - (isMemberExpression && isImpliedEvalMemberExpression(node.callee)); - - return isImpliedEvalCallee && node.arguments.length; + function isSpecifiedMember(node, specifiers) { + return node.type === "MemberExpression" && specifiers.includes(astUtils.getStaticPropertyName(node)); } /** - * Checks that the parent is a direct descendent of an potential implied eval CallExpression, and if the parent is a CallExpression, that we're the first argument. - * @param {ASTNode} node The node to inspect the parent of. - * @returns {boolean} Was the parent a direct descendent, and is the child therefore potentially part of a dangerous argument? - * @private + * Reports if the `CallExpression` node has evaluated argument. + * @param {ASTNode} node A CallExpression to check. + * @returns {void} */ - function hasImpliedEvalParent(node) { + function reportImpliedEvalCallExpression(node) { + const [firstArgument] = node.arguments; + + if (firstArgument) { - // make sure our parent is marked - return node.parent === last(last(impliedEvalAncestorsStack)) && + const staticValue = getStaticValue(firstArgument, context.getScope()); + const isStaticString = staticValue && typeof staticValue.value === "string"; + const isString = isStaticString || isEvaluatedString(firstArgument); + + if (isString) { + context.report({ + node, + messageId: "impliedEval" + }); + } + } - // if our parent is a CallExpression, make sure we're the first argument - (node.parent.type !== "CallExpression" || node === node.parent.arguments[0]); } /** - * Checks if our parent is marked as part of an implied eval argument. If - * so, collapses the top of impliedEvalAncestorsStack and reports on the - * original CallExpression. - * @param {ASTNode} node The CallExpression to check. - * @returns {boolean} True if the node matches, false if not. - * @private + * Reports calls of `implied eval` via the global references. + * @param {Variable} globalVar A global variable to check. + * @returns {void} */ - function checkString(node) { - if (hasImpliedEvalParent(node)) { + function reportImpliedEvalViaGlobal(globalVar) { + const { references, name } = globalVar; - // remove the entire substack, to avoid duplicate reports - const substack = impliedEvalAncestorsStack.pop(); + references.forEach(ref => { + const identifier = ref.identifier; + let node = identifier.parent; - context.report({ node: substack[0], message: "Implied eval. Consider passing a function instead of a string." }); - } + while (isSpecifiedMember(node, [name])) { + node = node.parent; + } + + if (isSpecifiedMember(node, EVAL_LIKE_FUNCS)) { + const parent = node.parent; + + if (parent.type === "CallExpression" && parent.callee === node) { + reportImpliedEvalCallExpression(parent); + } + } + }); } //-------------------------------------------------------------------------- @@ -117,45 +134,17 @@ module.exports = { return { CallExpression(node) { - if (isImpliedEvalCallExpression(node)) { - - // call expressions create a new substack - impliedEvalAncestorsStack.push([node]); - } - }, - - "CallExpression:exit"(node) { - if (node === last(last(impliedEvalAncestorsStack))) { - - /* - * Destroys the entire sub-stack, rather than just using - * last(impliedEvalAncestorsStack).pop(), as a CallExpression is - * always the bottom of a impliedEvalAncestorsStack substack. - */ - impliedEvalAncestorsStack.pop(); - } - }, - - BinaryExpression(node) { - if (node.operator === "+" && hasImpliedEvalParent(node)) { - last(impliedEvalAncestorsStack).push(node); - } - }, - - "BinaryExpression:exit"(node) { - if (node === last(last(impliedEvalAncestorsStack))) { - last(impliedEvalAncestorsStack).pop(); - } - }, - - Literal(node) { - if (typeof node.value === "string") { - checkString(node); + if (isSpecifiedIdentifier(node.callee, EVAL_LIKE_FUNCS)) { + reportImpliedEvalCallExpression(node); } }, + "Program:exit"() { + const globalScope = context.getScope(); - TemplateLiteral(node) { - checkString(node); + GLOBAL_CANDIDATES + .map(candidate => astUtils.getVariableByName(globalScope, candidate)) + .filter(globalVar => !!globalVar && globalVar.defs.length === 0) + .forEach(reportImpliedEvalViaGlobal); } }; diff --git a/tools/node_modules/eslint/lib/rules/no-import-assign.js b/tools/node_modules/eslint/lib/rules/no-import-assign.js index 0865cf9a97704d..32e445ff68b3ef 100644 --- a/tools/node_modules/eslint/lib/rules/no-import-assign.js +++ b/tools/node_modules/eslint/lib/rules/no-import-assign.js @@ -180,7 +180,7 @@ module.exports = { docs: { description: "disallow assigning to imported bindings", category: "Possible Errors", - recommended: false, + recommended: true, url: "https://eslint.org/docs/rules/no-import-assign" }, diff --git a/tools/node_modules/eslint/lib/rules/no-inline-comments.js b/tools/node_modules/eslint/lib/rules/no-inline-comments.js index bd226ecc35fde1..41b0f1e664c776 100644 --- a/tools/node_modules/eslint/lib/rules/no-inline-comments.js +++ b/tools/node_modules/eslint/lib/rules/no-inline-comments.js @@ -21,7 +21,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-inline-comments" }, - schema: [] + schema: [], + + messages: { + unexpectedInlineComment: "Unexpected comment inline with code." + } }, create(context) { @@ -64,7 +68,10 @@ module.exports = { return; } - context.report({ node, message: "Unexpected comment inline with code." }); + context.report({ + node, + messageId: "unexpectedInlineComment" + }); } //-------------------------------------------------------------------------- diff --git a/tools/node_modules/eslint/lib/rules/no-inner-declarations.js b/tools/node_modules/eslint/lib/rules/no-inner-declarations.js index 60508d3e864eda..e1c29e0a3b4f3f 100644 --- a/tools/node_modules/eslint/lib/rules/no-inner-declarations.js +++ b/tools/node_modules/eslint/lib/rules/no-inner-declarations.js @@ -24,7 +24,11 @@ module.exports = { { enum: ["functions", "both"] } - ] + ], + + messages: { + moveDeclToRoot: "Move {{type}} declaration to {{body}} root." + } }, create(context) { @@ -68,7 +72,7 @@ module.exports = { if (!valid) { context.report({ node, - message: "Move {{type}} declaration to {{body}} root.", + messageId: "moveDeclToRoot", data: { type: (node.type === "FunctionDeclaration" ? "function" : "variable"), body: (body.type === "Program" ? "program" : "function body") diff --git a/tools/node_modules/eslint/lib/rules/no-invalid-regexp.js b/tools/node_modules/eslint/lib/rules/no-invalid-regexp.js index 852efbbb935b90..c09e36fd017697 100644 --- a/tools/node_modules/eslint/lib/rules/no-invalid-regexp.js +++ b/tools/node_modules/eslint/lib/rules/no-invalid-regexp.js @@ -39,7 +39,11 @@ module.exports = { } }, additionalProperties: false - }] + }], + + messages: { + regexMessage: "{{message}}." + } }, create(context) { @@ -116,7 +120,7 @@ module.exports = { if (message) { context.report({ node, - message: "{{message}}.", + messageId: "regexMessage", data: { message } }); } diff --git a/tools/node_modules/eslint/lib/rules/no-invalid-this.js b/tools/node_modules/eslint/lib/rules/no-invalid-this.js index 5398fc3b5f842c..a79c586d719852 100644 --- a/tools/node_modules/eslint/lib/rules/no-invalid-this.js +++ b/tools/node_modules/eslint/lib/rules/no-invalid-this.js @@ -37,7 +37,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + unexpectedThis: "Unexpected 'this'." + } }, create(context) { @@ -130,7 +134,10 @@ module.exports = { const current = stack.getCurrent(); if (current && !current.valid) { - context.report({ node, message: "Unexpected 'this'." }); + context.report({ + node, + messageId: "unexpectedThis" + }); } } }; diff --git a/tools/node_modules/eslint/lib/rules/no-irregular-whitespace.js b/tools/node_modules/eslint/lib/rules/no-irregular-whitespace.js index f339fa6c8f34c9..21842331f21ff0 100644 --- a/tools/node_modules/eslint/lib/rules/no-irregular-whitespace.js +++ b/tools/node_modules/eslint/lib/rules/no-irregular-whitespace.js @@ -1,5 +1,5 @@ /** - * @fileoverview Rule to disalow whitespace that is not a tab or space, whitespace inside strings and comments are allowed + * @fileoverview Rule to disallow whitespace that is not a tab or space, whitespace inside strings and comments are allowed * @author Jonathan Kingston * @author Christophe Porteneuve */ @@ -59,7 +59,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + noIrregularWhitespace: "Irregular whitespace not allowed." + } }, create(context) { @@ -161,7 +165,11 @@ module.exports = { column: match.index }; - errors.push({ node, message: "Irregular whitespace not allowed.", loc: location }); + errors.push({ + node, + messageId: "noIrregularWhitespace", + loc: location + }); } }); } @@ -186,7 +194,11 @@ module.exports = { column: sourceLines[lineIndex].length }; - errors.push({ node, message: "Irregular whitespace not allowed.", loc: location }); + errors.push({ + node, + messageId: "noIrregularWhitespace", + loc: location + }); lastLineIndex = lineIndex; } } diff --git a/tools/node_modules/eslint/lib/rules/no-iterator.js b/tools/node_modules/eslint/lib/rules/no-iterator.js index 82319a3fb1dfb6..9ba1e7aefdbc3b 100644 --- a/tools/node_modules/eslint/lib/rules/no-iterator.js +++ b/tools/node_modules/eslint/lib/rules/no-iterator.js @@ -5,6 +5,12 @@ "use strict"; +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const { getStaticPropertyName } = require("./utils/ast-utils"); + //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -20,7 +26,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-iterator" }, - schema: [] + schema: [], + + messages: { + noIterator: "Reserved name '__iterator__'." + } }, create(context) { @@ -29,10 +39,11 @@ module.exports = { MemberExpression(node) { - if (node.property && - (node.property.type === "Identifier" && node.property.name === "__iterator__" && !node.computed) || - (node.property.type === "Literal" && node.property.value === "__iterator__")) { - context.report({ node, message: "Reserved name '__iterator__'." }); + if (getStaticPropertyName(node) === "__iterator__") { + context.report({ + node, + messageId: "noIterator" + }); } } }; diff --git a/tools/node_modules/eslint/lib/rules/no-label-var.js b/tools/node_modules/eslint/lib/rules/no-label-var.js index a9fd042a390225..570db03285cf97 100644 --- a/tools/node_modules/eslint/lib/rules/no-label-var.js +++ b/tools/node_modules/eslint/lib/rules/no-label-var.js @@ -26,7 +26,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-label-var" }, - schema: [] + schema: [], + + messages: { + identifierClashWithLabel: "Found identifier with same name as label." + } }, create(context) { @@ -62,7 +66,10 @@ module.exports = { * with the innermost scope. */ if (findIdentifier(scope, node.label.name)) { - context.report({ node, message: "Found identifier with same name as label." }); + context.report({ + node, + messageId: "identifierClashWithLabel" + }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-labels.js b/tools/node_modules/eslint/lib/rules/no-labels.js index 52f4b0f5168b71..85760d80dbedd7 100644 --- a/tools/node_modules/eslint/lib/rules/no-labels.js +++ b/tools/node_modules/eslint/lib/rules/no-labels.js @@ -40,7 +40,13 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + unexpectedLabel: "Unexpected labeled statement.", + unexpectedLabelInBreak: "Unexpected label in break statement.", + unexpectedLabelInContinue: "Unexpected label in continue statement." + } }, create(context) { @@ -113,7 +119,7 @@ module.exports = { if (!isAllowed(scopeInfo.kind)) { context.report({ node, - message: "Unexpected labeled statement." + messageId: "unexpectedLabel" }); } @@ -124,7 +130,7 @@ module.exports = { if (node.label && !isAllowed(getKind(node.label.name))) { context.report({ node, - message: "Unexpected label in break statement." + messageId: "unexpectedLabelInBreak" }); } }, @@ -133,7 +139,7 @@ module.exports = { if (node.label && !isAllowed(getKind(node.label.name))) { context.report({ node, - message: "Unexpected label in continue statement." + messageId: "unexpectedLabelInContinue" }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-lone-blocks.js b/tools/node_modules/eslint/lib/rules/no-lone-blocks.js index 37561b0f9a3055..d7069887b8e460 100644 --- a/tools/node_modules/eslint/lib/rules/no-lone-blocks.js +++ b/tools/node_modules/eslint/lib/rules/no-lone-blocks.js @@ -20,7 +20,12 @@ module.exports = { url: "https://eslint.org/docs/rules/no-lone-blocks" }, - schema: [] + schema: [], + + messages: { + redundantBlock: "Block is redundant.", + redundantNestedBlock: "Nested block is redundant." + } }, create(context) { @@ -35,9 +40,12 @@ module.exports = { * @returns {void} */ function report(node) { - const message = node.parent.type === "BlockStatement" ? "Nested block is redundant." : "Block is redundant."; + const messageId = node.parent.type === "BlockStatement" ? "redundantNestedBlock" : "redundantBlock"; - context.report({ node, message }); + context.report({ + node, + messageId + }); } /** diff --git a/tools/node_modules/eslint/lib/rules/no-lonely-if.js b/tools/node_modules/eslint/lib/rules/no-lonely-if.js index b62d176a264210..6552adc5752852 100644 --- a/tools/node_modules/eslint/lib/rules/no-lonely-if.js +++ b/tools/node_modules/eslint/lib/rules/no-lonely-if.js @@ -1,5 +1,5 @@ /** - * @fileoverview Rule to disallow if as the only statmenet in an else block + * @fileoverview Rule to disallow if as the only statement in an else block * @author Brandon Mills */ "use strict"; @@ -20,7 +20,11 @@ module.exports = { }, schema: [], - fixable: "code" + fixable: "code", + + messages: { + unexpectedLonelyIf: "Unexpected if as the only statement in an else block." + } }, create(context) { @@ -38,7 +42,7 @@ module.exports = { parent === grandparent.alternate) { context.report({ node, - message: "Unexpected if as the only statement in an else block.", + messageId: "unexpectedLonelyIf", fix(fixer) { const openingElseCurly = sourceCode.getFirstToken(parent); const closingElseCurly = sourceCode.getLastToken(parent); diff --git a/tools/node_modules/eslint/lib/rules/no-magic-numbers.js b/tools/node_modules/eslint/lib/rules/no-magic-numbers.js index 0909e3166d952e..cd07f5c3bda9d5 100644 --- a/tools/node_modules/eslint/lib/rules/no-magic-numbers.js +++ b/tools/node_modules/eslint/lib/rules/no-magic-numbers.js @@ -5,10 +5,27 @@ "use strict"; +const { isNumericLiteral } = require("./utils/ast-utils"); + +// Maximum array length by the ECMAScript Specification. +const MAX_ARRAY_LENGTH = 2 ** 32 - 1; + //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ +/** + * Convert the value to bigint if it's a string. Otherwise return the value as-is. + * @param {bigint|number|string} x The value to normalize. + * @returns {bigint|number} The normalized value. + */ +function normalizeIgnoreValue(x) { + if (typeof x === "string") { + return BigInt(x.slice(0, -1)); + } + return x; +} + module.exports = { meta: { type: "suggestion", @@ -34,7 +51,10 @@ module.exports = { ignore: { type: "array", items: { - type: "number" + anyOf: [ + { type: "number" }, + { type: "string", pattern: "^[+-]?(?:0|[1-9][0-9]*)n$" } + ] }, uniqueItems: true }, @@ -56,92 +76,118 @@ module.exports = { const config = context.options[0] || {}, detectObjects = !!config.detectObjects, enforceConst = !!config.enforceConst, - ignore = config.ignore || [], + ignore = (config.ignore || []).map(normalizeIgnoreValue), ignoreArrayIndexes = !!config.ignoreArrayIndexes; - /** - * Returns whether the node is number literal - * @param {Node} node the node literal being evaluated - * @returns {boolean} true if the node is a number literal - */ - function isNumber(node) { - return typeof node.value === "number"; - } + const okTypes = detectObjects ? [] : ["ObjectExpression", "Property", "AssignmentExpression"]; /** - * Returns whether the number should be ignored - * @param {number} num the number - * @returns {boolean} true if the number should be ignored + * Returns whether the rule is configured to ignore the given value + * @param {bigint|number} value The value to check + * @returns {boolean} true if the value is ignored */ - function shouldIgnoreNumber(num) { - return ignore.indexOf(num) !== -1; + function isIgnoredValue(value) { + return ignore.indexOf(value) !== -1; } /** - * Returns whether the number should be ignored when used as a radix within parseInt() or Number.parseInt() - * @param {ASTNode} parent the non-"UnaryExpression" parent - * @param {ASTNode} node the node literal being evaluated - * @returns {boolean} true if the number should be ignored + * Returns whether the given node is used as a radix within parseInt() or Number.parseInt() + * @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node + * @returns {boolean} true if the node is radix */ - function shouldIgnoreParseInt(parent, node) { - return parent.type === "CallExpression" && node === parent.arguments[1] && - (parent.callee.name === "parseInt" || - parent.callee.type === "MemberExpression" && - parent.callee.object.name === "Number" && - parent.callee.property.name === "parseInt"); + function isParseIntRadix(fullNumberNode) { + const parent = fullNumberNode.parent; + + return parent.type === "CallExpression" && fullNumberNode === parent.arguments[1] && + ( + parent.callee.name === "parseInt" || + ( + parent.callee.type === "MemberExpression" && + parent.callee.object.name === "Number" && + parent.callee.property.name === "parseInt" + ) + ); } /** - * Returns whether the number should be ignored when used to define a JSX prop - * @param {ASTNode} parent the non-"UnaryExpression" parent - * @returns {boolean} true if the number should be ignored + * Returns whether the given node is a direct child of a JSX node. + * In particular, it aims to detect numbers used as prop values in JSX tags. + * Example: + * @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node + * @returns {boolean} true if the node is a JSX number */ - function shouldIgnoreJSXNumbers(parent) { - return parent.type.indexOf("JSX") === 0; + function isJSXNumber(fullNumberNode) { + return fullNumberNode.parent.type.indexOf("JSX") === 0; } /** - * Returns whether the number should be ignored when used as an array index with enabled 'ignoreArrayIndexes' option. - * @param {ASTNode} parent the non-"UnaryExpression" parent. - * @returns {boolean} true if the number should be ignored + * Returns whether the given node is used as an array index. + * Value must coerce to a valid array index name: "0", "1", "2" ... "4294967294". + * + * All other values, like "-1", "2.5", or "4294967295", are just "normal" object properties, + * which can be created and accessed on an array in addition to the array index properties, + * but they don't affect array's length and are not considered by methods such as .map(), .forEach() etc. + * + * The maximum array length by the specification is 2 ** 32 - 1 = 4294967295, + * thus the maximum valid index is 2 ** 32 - 2 = 4294967294. + * + * All notations are allowed, as long as the value coerces to one of "0", "1", "2" ... "4294967294". + * + * Valid examples: + * a[0], a[1], a[1.2e1], a[0xAB], a[0n], a[1n] + * a[-0] (same as a[0] because -0 coerces to "0") + * a[-0n] (-0n evaluates to 0n) + * + * Invalid examples: + * a[-1], a[-0xAB], a[-1n], a[2.5], a[1.23e1], a[12e-1] + * a[4294967295] (above the max index, it's an access to a regular property a["4294967295"]) + * a[999999999999999999999] (even if it wasn't above the max index, it would be a["1e+21"]) + * a[1e310] (same as a["Infinity"]) + * @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node + * @param {bigint|number} value Value expressed by the fullNumberNode + * @returns {boolean} true if the node is a valid array index */ - function shouldIgnoreArrayIndexes(parent) { - return parent.type === "MemberExpression" && ignoreArrayIndexes; + function isArrayIndex(fullNumberNode, value) { + const parent = fullNumberNode.parent; + + return parent.type === "MemberExpression" && parent.property === fullNumberNode && + (Number.isInteger(value) || typeof value === "bigint") && + value >= 0 && value < MAX_ARRAY_LENGTH; } return { Literal(node) { - const okTypes = detectObjects ? [] : ["ObjectExpression", "Property", "AssignmentExpression"]; - - if (!isNumber(node)) { + if (!isNumericLiteral(node)) { return; } let fullNumberNode; - let parent; let value; let raw; - // For negative magic numbers: update the value and parent node + // Treat unary minus as a part of the number if (node.parent.type === "UnaryExpression" && node.parent.operator === "-") { fullNumberNode = node.parent; - parent = fullNumberNode.parent; value = -node.value; raw = `-${node.raw}`; } else { fullNumberNode = node; - parent = node.parent; value = node.value; raw = node.raw; } - if (shouldIgnoreNumber(value) || - shouldIgnoreParseInt(parent, fullNumberNode) || - shouldIgnoreArrayIndexes(parent) || - shouldIgnoreJSXNumbers(parent)) { + // Always allow radix arguments and JSX props + if ( + isIgnoredValue(value) || + isParseIntRadix(fullNumberNode) || + isJSXNumber(fullNumberNode) || + (ignoreArrayIndexes && isArrayIndex(fullNumberNode, value)) + ) { return; } + const parent = fullNumberNode.parent; + if (parent.type === "VariableDeclarator") { if (enforceConst && parent.parent.kind !== "const") { context.report({ diff --git a/tools/node_modules/eslint/lib/rules/no-mixed-operators.js b/tools/node_modules/eslint/lib/rules/no-mixed-operators.js index 80fac79affdb0e..37e8906e827a4c 100644 --- a/tools/node_modules/eslint/lib/rules/no-mixed-operators.js +++ b/tools/node_modules/eslint/lib/rules/no-mixed-operators.js @@ -112,7 +112,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + unexpectedMixedOperator: "Unexpected mix of '{{leftOperator}}' and '{{rightOperator}}'." + } }, create(context) { @@ -188,8 +192,6 @@ module.exports = { const parent = node.parent; const left = (getChildNode(parent) === node) ? node : parent; const right = (getChildNode(parent) !== node) ? node : parent; - const message = - "Unexpected mix of '{{leftOperator}}' and '{{rightOperator}}'."; const data = { leftOperator: left.operator || "?:", rightOperator: right.operator || "?:" @@ -198,13 +200,13 @@ module.exports = { context.report({ node: left, loc: getOperatorToken(left).loc, - message, + messageId: "unexpectedMixedOperator", data }); context.report({ node: right, loc: getOperatorToken(right).loc, - message, + messageId: "unexpectedMixedOperator", data }); } diff --git a/tools/node_modules/eslint/lib/rules/no-mixed-requires.js b/tools/node_modules/eslint/lib/rules/no-mixed-requires.js index fda8a11d9e2e74..8e988e32c24f84 100644 --- a/tools/node_modules/eslint/lib/rules/no-mixed-requires.js +++ b/tools/node_modules/eslint/lib/rules/no-mixed-requires.js @@ -40,7 +40,12 @@ module.exports = { } ] } - ] + ], + + messages: { + noMixRequire: "Do not mix 'require' and other declarations.", + noMixCoreModuleFileComputed: "Do not mix core, module, file and computed requires." + } }, create(context) { @@ -211,9 +216,15 @@ module.exports = { VariableDeclaration(node) { if (isMixed(node.declarations)) { - context.report({ node, message: "Do not mix 'require' and other declarations." }); + context.report({ + node, + messageId: "noMixRequire" + }); } else if (grouping && !isGrouped(node.declarations)) { - context.report({ node, message: "Do not mix core, module, file and computed requires." }); + context.report({ + node, + messageId: "noMixCoreModuleFileComputed" + }); } } }; diff --git a/tools/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js b/tools/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js index 7b1e2c4a2a760c..16c2bd4122e851 100644 --- a/tools/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js +++ b/tools/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js @@ -23,14 +23,17 @@ module.exports = { { enum: ["smart-tabs", true, false] } - ] + ], + + messages: { + mixedSpacesAndTabs: "Mixed spaces and tabs." + } }, create(context) { const sourceCode = context.getSourceCode(); let smartTabs; - const ignoredLocs = []; switch (context.options[0]) { case true: // Support old syntax, maybe add deprecation warning here @@ -41,47 +44,23 @@ module.exports = { smartTabs = false; } - /** - * Determines if a given line and column are before a location. - * @param {Location} loc The location object from an AST node. - * @param {int} line The line to check. - * @param {int} column The column to check. - * @returns {boolean} True if the line and column are before the location, false if not. - * @private - */ - function beforeLoc(loc, line, column) { - if (line < loc.start.line) { - return true; - } - return line === loc.start.line && column < loc.start.column; - } - - /** - * Determines if a given line and column are after a location. - * @param {Location} loc The location object from an AST node. - * @param {int} line The line to check. - * @param {int} column The column to check. - * @returns {boolean} True if the line and column are after the location, false if not. - * @private - */ - function afterLoc(loc, line, column) { - if (line > loc.end.line) { - return true; - } - return line === loc.end.line && column > loc.end.column; - } - //-------------------------------------------------------------------------- // Public //-------------------------------------------------------------------------- return { - TemplateElement(node) { - ignoredLocs.push(node.loc); - }, - "Program:exit"(node) { + const lines = sourceCode.lines, + comments = sourceCode.getAllComments(), + ignoredCommentLines = new Set(); + + // Add all lines except the first ones. + comments.forEach(comment => { + for (let i = comment.loc.start.line + 1; i <= comment.loc.end.line; i++) { + ignoredCommentLines.add(i); + } + }); /* * At least one space followed by a tab @@ -89,24 +68,6 @@ module.exports = { * characters begin. */ let regex = /^(?=[\t ]*(\t | \t))/u; - const lines = sourceCode.lines, - comments = sourceCode.getAllComments(); - - comments.forEach(comment => { - ignoredLocs.push(comment.loc); - }); - - ignoredLocs.sort((first, second) => { - if (beforeLoc(first, second.start.line, second.start.column)) { - return 1; - } - - if (beforeLoc(second, first.start.line, second.start.column)) { - return -1; - } - - return 0; - }); if (smartTabs) { @@ -122,25 +83,23 @@ module.exports = { if (match) { const lineNumber = i + 1, - column = match.index + 1; - - for (let j = 0; j < ignoredLocs.length; j++) { - if (beforeLoc(ignoredLocs[j], lineNumber, column)) { - continue; + column = match.index + 1, + loc = { line: lineNumber, column }; + + if (!ignoredCommentLines.has(lineNumber)) { + const containingNode = sourceCode.getNodeByRangeIndex(sourceCode.getIndexFromLoc(loc)); + + if (!(containingNode && ["Literal", "TemplateElement"].includes(containingNode.type))) { + context.report({ + node, + loc, + messageId: "mixedSpacesAndTabs" + }); } - if (afterLoc(ignoredLocs[j], lineNumber, column)) { - continue; - } - - return; } - - context.report({ node, loc: { line: lineNumber, column }, message: "Mixed spaces and tabs." }); } }); } - }; - } }; diff --git a/tools/node_modules/eslint/lib/rules/no-multi-assign.js b/tools/node_modules/eslint/lib/rules/no-multi-assign.js index 8524a1a571ef9e..ab6430c19ef070 100644 --- a/tools/node_modules/eslint/lib/rules/no-multi-assign.js +++ b/tools/node_modules/eslint/lib/rules/no-multi-assign.js @@ -21,7 +21,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-multi-assign" }, - schema: [] + schema: [], + + messages: { + unexpectedChain: "Unexpected chained assignment." + } }, create(context) { @@ -35,7 +39,7 @@ module.exports = { if (["AssignmentExpression", "VariableDeclarator"].indexOf(node.parent.type) !== -1) { context.report({ node, - message: "Unexpected chained assignment." + messageId: "unexpectedChain" }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-multi-spaces.js b/tools/node_modules/eslint/lib/rules/no-multi-spaces.js index 403d04da9dd9ec..d43ed736337945 100644 --- a/tools/node_modules/eslint/lib/rules/no-multi-spaces.js +++ b/tools/node_modules/eslint/lib/rules/no-multi-spaces.js @@ -44,7 +44,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + multipleSpaces: "Multiple spaces found before '{{displayValue}}'." + } }, create(context) { @@ -122,7 +126,7 @@ module.exports = { context.report({ node: rightToken, loc: { start: leftToken.loc.end, end: rightToken.loc.start }, - message: "Multiple spaces found before '{{displayValue}}'.", + messageId: "multipleSpaces", data: { displayValue }, fix: fixer => fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], " ") }); diff --git a/tools/node_modules/eslint/lib/rules/no-multi-str.js b/tools/node_modules/eslint/lib/rules/no-multi-str.js index f6832f3341777f..7cf1ae367942fe 100644 --- a/tools/node_modules/eslint/lib/rules/no-multi-str.js +++ b/tools/node_modules/eslint/lib/rules/no-multi-str.js @@ -26,7 +26,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-multi-str" }, - schema: [] + schema: [], + + messages: { + multilineString: "Multiline support is limited to browsers supporting ES5 only." + } }, create(context) { @@ -49,7 +53,10 @@ module.exports = { Literal(node) { if (astUtils.LINEBREAK_MATCHER.test(node.raw) && !isJSXElement(node.parent)) { - context.report({ node, message: "Multiline support is limited to browsers supporting ES5 only." }); + context.report({ + node, + messageId: "multilineString" + }); } } }; diff --git a/tools/node_modules/eslint/lib/rules/no-multiple-empty-lines.js b/tools/node_modules/eslint/lib/rules/no-multiple-empty-lines.js index 41e6be3a289584..9cccef3088a56e 100644 --- a/tools/node_modules/eslint/lib/rules/no-multiple-empty-lines.js +++ b/tools/node_modules/eslint/lib/rules/no-multiple-empty-lines.js @@ -42,7 +42,13 @@ module.exports = { required: ["max"], additionalProperties: false } - ] + ], + + messages: { + blankBeginningOfFile: "Too many blank lines at the beginning of file. Max of {{max}} allowed.", + blankEndOfFile: "Too many blank lines at the end of file. Max of {{max}} allowed.", + consecutiveBlank: "More than {{max}} blank {{pluralizedLines}} not allowed." + } }, create(context) { @@ -94,25 +100,31 @@ module.exports = { // Given two line numbers of non-empty lines, report the lines between if the difference is too large. .reduce((lastLineNumber, lineNumber) => { - let message, maxAllowed; + let messageId, maxAllowed; if (lastLineNumber === 0) { - message = "Too many blank lines at the beginning of file. Max of {{max}} allowed."; + messageId = "blankBeginningOfFile"; maxAllowed = maxBOF; } else if (lineNumber === allLines.length + 1) { - message = "Too many blank lines at the end of file. Max of {{max}} allowed."; + messageId = "blankEndOfFile"; maxAllowed = maxEOF; } else { - message = "More than {{max}} blank {{pluralizedLines}} not allowed."; + messageId = "consecutiveBlank"; maxAllowed = max; } if (lineNumber - lastLineNumber - 1 > maxAllowed) { context.report({ node, - loc: { start: { line: lastLineNumber + maxAllowed + 1, column: 0 }, end: { line: lineNumber, column: 0 } }, - message, - data: { max: maxAllowed, pluralizedLines: maxAllowed === 1 ? "line" : "lines" }, + loc: { + start: { line: lastLineNumber + maxAllowed + 1, column: 0 }, + end: { line: lineNumber, column: 0 } + }, + messageId, + data: { + max: maxAllowed, + pluralizedLines: maxAllowed === 1 ? "line" : "lines" + }, fix(fixer) { const rangeStart = sourceCode.getIndexFromLoc({ line: lastLineNumber + 1, column: 0 }); diff --git a/tools/node_modules/eslint/lib/rules/no-native-reassign.js b/tools/node_modules/eslint/lib/rules/no-native-reassign.js index eb233c80b1cca0..833e3b7ce409b3 100644 --- a/tools/node_modules/eslint/lib/rules/no-native-reassign.js +++ b/tools/node_modules/eslint/lib/rules/no-native-reassign.js @@ -37,7 +37,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + nativeReassign: "Read-only global '{{name}}' should not be modified." + } }, create(context) { @@ -65,7 +69,7 @@ module.exports = { ) { context.report({ node: identifier, - message: "Read-only global '{{name}}' should not be modified.", + messageId: "nativeReassign", data: identifier }); } diff --git a/tools/node_modules/eslint/lib/rules/no-negated-condition.js b/tools/node_modules/eslint/lib/rules/no-negated-condition.js index e55a8287487de3..8a9eba881df04c 100644 --- a/tools/node_modules/eslint/lib/rules/no-negated-condition.js +++ b/tools/node_modules/eslint/lib/rules/no-negated-condition.js @@ -19,7 +19,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-negated-condition" }, - schema: [] + schema: [], + + messages: { + unexpectedNegated: "Unexpected negated condition." + } }, create(context) { @@ -72,12 +76,18 @@ module.exports = { } if (isNegatedIf(node)) { - context.report({ node, message: "Unexpected negated condition." }); + context.report({ + node, + messageId: "unexpectedNegated" + }); } }, ConditionalExpression(node) { if (isNegatedIf(node)) { - context.report({ node, message: "Unexpected negated condition." }); + context.report({ + node, + messageId: "unexpectedNegated" + }); } } }; diff --git a/tools/node_modules/eslint/lib/rules/no-negated-in-lhs.js b/tools/node_modules/eslint/lib/rules/no-negated-in-lhs.js index 0084ad1570bb00..1229cedd1190dc 100644 --- a/tools/node_modules/eslint/lib/rules/no-negated-in-lhs.js +++ b/tools/node_modules/eslint/lib/rules/no-negated-in-lhs.js @@ -24,7 +24,11 @@ module.exports = { replacedBy: ["no-unsafe-negation"], deprecated: true, - schema: [] + schema: [], + + messages: { + negatedLHS: "The 'in' expression's left operand is negated." + } }, create(context) { @@ -33,7 +37,7 @@ module.exports = { BinaryExpression(node) { if (node.operator === "in" && node.left.type === "UnaryExpression" && node.left.operator === "!") { - context.report({ node, message: "The 'in' expression's left operand is negated." }); + context.report({ node, messageId: "negatedLHS" }); } } }; diff --git a/tools/node_modules/eslint/lib/rules/no-nested-ternary.js b/tools/node_modules/eslint/lib/rules/no-nested-ternary.js index 87a11e87962a8f..383bb238887d2a 100644 --- a/tools/node_modules/eslint/lib/rules/no-nested-ternary.js +++ b/tools/node_modules/eslint/lib/rules/no-nested-ternary.js @@ -20,7 +20,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-nested-ternary" }, - schema: [] + schema: [], + + messages: { + noNestedTernary: "Do not nest ternary expressions." + } }, create(context) { @@ -29,7 +33,10 @@ module.exports = { ConditionalExpression(node) { if (node.alternate.type === "ConditionalExpression" || node.consequent.type === "ConditionalExpression") { - context.report({ node, message: "Do not nest ternary expressions." }); + context.report({ + node, + messageId: "noNestedTernary" + }); } } }; diff --git a/tools/node_modules/eslint/lib/rules/no-new-func.js b/tools/node_modules/eslint/lib/rules/no-new-func.js index 23e92f7bf3030c..d1360e9dee036d 100644 --- a/tools/node_modules/eslint/lib/rules/no-new-func.js +++ b/tools/node_modules/eslint/lib/rules/no-new-func.js @@ -20,7 +20,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-new-func" }, - schema: [] + schema: [], + + messages: { + noFunctionConstructor: "The Function constructor is eval." + } }, create(context) { @@ -36,7 +40,10 @@ module.exports = { * @private */ function report(node) { - context.report({ node, message: "The Function constructor is eval." }); + context.report({ + node, + messageId: "noFunctionConstructor" + }); } return { diff --git a/tools/node_modules/eslint/lib/rules/no-new-object.js b/tools/node_modules/eslint/lib/rules/no-new-object.js index f5cc28664f4e1c..f3e99c9bd13502 100644 --- a/tools/node_modules/eslint/lib/rules/no-new-object.js +++ b/tools/node_modules/eslint/lib/rules/no-new-object.js @@ -20,7 +20,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-new-object" }, - schema: [] + schema: [], + + messages: { + preferLiteral: "The object literal notation {} is preferrable." + } }, create(context) { @@ -29,7 +33,10 @@ module.exports = { NewExpression(node) { if (node.callee.name === "Object") { - context.report({ node, message: "The object literal notation {} is preferrable." }); + context.report({ + node, + messageId: "preferLiteral" + }); } } }; diff --git a/tools/node_modules/eslint/lib/rules/no-new-require.js b/tools/node_modules/eslint/lib/rules/no-new-require.js index 1eae0659430fbd..df12a424e3527e 100644 --- a/tools/node_modules/eslint/lib/rules/no-new-require.js +++ b/tools/node_modules/eslint/lib/rules/no-new-require.js @@ -20,7 +20,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-new-require" }, - schema: [] + schema: [], + + messages: { + noNewRequire: "Unexpected use of new with require." + } }, create(context) { @@ -29,7 +33,10 @@ module.exports = { NewExpression(node) { if (node.callee.type === "Identifier" && node.callee.name === "require") { - context.report({ node, message: "Unexpected use of new with require." }); + context.report({ + node, + messageId: "noNewRequire" + }); } } }; diff --git a/tools/node_modules/eslint/lib/rules/no-new-symbol.js b/tools/node_modules/eslint/lib/rules/no-new-symbol.js index ccf757ed6a0cee..cb7e4f0fc88d69 100644 --- a/tools/node_modules/eslint/lib/rules/no-new-symbol.js +++ b/tools/node_modules/eslint/lib/rules/no-new-symbol.js @@ -20,7 +20,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-new-symbol" }, - schema: [] + schema: [], + + messages: { + noNewSymbol: "`Symbol` cannot be called as a constructor." + } }, create(context) { @@ -35,7 +39,10 @@ module.exports = { const node = ref.identifier; if (node.parent && node.parent.type === "NewExpression") { - context.report({ node, message: "`Symbol` cannot be called as a constructor." }); + context.report({ + node, + messageId: "noNewSymbol" + }); } }); } diff --git a/tools/node_modules/eslint/lib/rules/no-new-wrappers.js b/tools/node_modules/eslint/lib/rules/no-new-wrappers.js index ae2aeec0341243..d276c48d203fab 100644 --- a/tools/node_modules/eslint/lib/rules/no-new-wrappers.js +++ b/tools/node_modules/eslint/lib/rules/no-new-wrappers.js @@ -20,7 +20,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-new-wrappers" }, - schema: [] + schema: [], + + messages: { + noConstructor: "Do not use {{fn}} as a constructor." + } }, create(context) { @@ -28,10 +32,14 @@ module.exports = { return { NewExpression(node) { - const wrapperObjects = ["String", "Number", "Boolean", "Math", "JSON"]; + const wrapperObjects = ["String", "Number", "Boolean"]; if (wrapperObjects.indexOf(node.callee.name) > -1) { - context.report({ node, message: "Do not use {{fn}} as a constructor.", data: { fn: node.callee.name } }); + context.report({ + node, + messageId: "noConstructor", + data: { fn: node.callee.name } + }); } } }; diff --git a/tools/node_modules/eslint/lib/rules/no-new.js b/tools/node_modules/eslint/lib/rules/no-new.js index 2e0702597eade3..aa8a4e26876609 100644 --- a/tools/node_modules/eslint/lib/rules/no-new.js +++ b/tools/node_modules/eslint/lib/rules/no-new.js @@ -21,14 +21,21 @@ module.exports = { url: "https://eslint.org/docs/rules/no-new" }, - schema: [] + schema: [], + + messages: { + noNewStatement: "Do not use 'new' for side effects." + } }, create(context) { return { "ExpressionStatement > NewExpression"(node) { - context.report({ node: node.parent, message: "Do not use 'new' for side effects." }); + context.report({ + node: node.parent, + messageId: "noNewStatement" + }); } }; diff --git a/tools/node_modules/eslint/lib/rules/no-obj-calls.js b/tools/node_modules/eslint/lib/rules/no-obj-calls.js index 5102d5594949ba..6139ba2c182b8b 100644 --- a/tools/node_modules/eslint/lib/rules/no-obj-calls.js +++ b/tools/node_modules/eslint/lib/rules/no-obj-calls.js @@ -9,7 +9,8 @@ // Requirements //------------------------------------------------------------------------------ -const { CALL, ReferenceTracker } = require("eslint-utils"); +const { CALL, CONSTRUCT, ReferenceTracker } = require("eslint-utils"); +const getPropertyName = require("./utils/ast-utils").getStaticPropertyName; //------------------------------------------------------------------------------ // Helpers @@ -17,6 +18,18 @@ const { CALL, ReferenceTracker } = require("eslint-utils"); const nonCallableGlobals = ["Atomics", "JSON", "Math", "Reflect"]; +/** + * Returns the name of the node to report + * @param {ASTNode} node A node to report + * @returns {string} name to report + */ +function getReportNodeName(node) { + if (node.callee.type === "MemberExpression") { + return getPropertyName(node.callee); + } + return node.callee.name; +} + //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -35,7 +48,8 @@ module.exports = { schema: [], messages: { - unexpectedCall: "'{{name}}' is not a function." + unexpectedCall: "'{{name}}' is not a function.", + unexpectedRefCall: "'{{name}}' is reference to '{{ref}}', which is not a function." } }, @@ -47,14 +61,19 @@ module.exports = { const tracker = new ReferenceTracker(scope); const traceMap = {}; - for (const global of nonCallableGlobals) { - traceMap[global] = { - [CALL]: true + for (const g of nonCallableGlobals) { + traceMap[g] = { + [CALL]: true, + [CONSTRUCT]: true }; } - for (const { node } of tracker.iterateGlobalReferences(traceMap)) { - context.report({ node, messageId: "unexpectedCall", data: { name: node.callee.name } }); + for (const { node, path } of tracker.iterateGlobalReferences(traceMap)) { + const name = getReportNodeName(node); + const ref = path[0]; + const messageId = name === ref ? "unexpectedCall" : "unexpectedRefCall"; + + context.report({ node, messageId, data: { name, ref } }); } } }; diff --git a/tools/node_modules/eslint/lib/rules/no-octal.js b/tools/node_modules/eslint/lib/rules/no-octal.js index 5ee69f0309ee03..e9940befafa889 100644 --- a/tools/node_modules/eslint/lib/rules/no-octal.js +++ b/tools/node_modules/eslint/lib/rules/no-octal.js @@ -20,7 +20,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-octal" }, - schema: [] + schema: [], + + messages: { + noOcatal: "Octal literals should not be used." + } }, create(context) { @@ -29,7 +33,10 @@ module.exports = { Literal(node) { if (typeof node.value === "number" && /^0[0-9]/u.test(node.raw)) { - context.report({ node, message: "Octal literals should not be used." }); + context.report({ + node, + messageId: "noOcatal" + }); } } }; diff --git a/tools/node_modules/eslint/lib/rules/no-param-reassign.js b/tools/node_modules/eslint/lib/rules/no-param-reassign.js index d65eb34762aaf2..6874af44f389b7 100644 --- a/tools/node_modules/eslint/lib/rules/no-param-reassign.js +++ b/tools/node_modules/eslint/lib/rules/no-param-reassign.js @@ -58,7 +58,12 @@ module.exports = { } ] } - ] + ], + + messages: { + assignmentToFunctionParam: "Assignment to function parameter '{{name}}'.", + assignmentToFunctionParamProp: "Assignment to property of function parameter '{{name}}'." + } }, create(context) { @@ -177,9 +182,17 @@ module.exports = { (index === 0 || references[index - 1].identifier !== identifier) ) { if (reference.isWrite()) { - context.report({ node: identifier, message: "Assignment to function parameter '{{name}}'.", data: { name: identifier.name } }); + context.report({ + node: identifier, + messageId: "assignmentToFunctionParam", + data: { name: identifier.name } + }); } else if (props && isModifyingProp(reference) && !isIgnoredPropertyAssignment(identifier.name)) { - context.report({ node: identifier, message: "Assignment to property of function parameter '{{name}}'.", data: { name: identifier.name } }); + context.report({ + node: identifier, + messageId: "assignmentToFunctionParamProp", + data: { name: identifier.name } + }); } } } diff --git a/tools/node_modules/eslint/lib/rules/no-path-concat.js b/tools/node_modules/eslint/lib/rules/no-path-concat.js index abe0d5247db719..9fa8b852fe8358 100644 --- a/tools/node_modules/eslint/lib/rules/no-path-concat.js +++ b/tools/node_modules/eslint/lib/rules/no-path-concat.js @@ -19,7 +19,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-path-concat" }, - schema: [] + schema: [], + + messages: { + usePathFunctions: "Use path.join() or path.resolve() instead of + to create paths." + } }, create(context) { @@ -42,7 +46,10 @@ module.exports = { (right.type === "Identifier" && MATCHER.test(right.name))) ) { - context.report({ node, message: "Use path.join() or path.resolve() instead of + to create paths." }); + context.report({ + node, + messageId: "usePathFunctions" + }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-plusplus.js b/tools/node_modules/eslint/lib/rules/no-plusplus.js index 1d122dcd31f086..84d6c3e1f91d51 100644 --- a/tools/node_modules/eslint/lib/rules/no-plusplus.js +++ b/tools/node_modules/eslint/lib/rules/no-plusplus.js @@ -6,6 +6,41 @@ "use strict"; +//------------------------------------------------------------------------------ +// Helpers +//------------------------------------------------------------------------------ + +/** + * Determines whether the given node is the update node of a `ForStatement`. + * @param {ASTNode} node The node to check. + * @returns {boolean} `true` if the node is `ForStatement` update. + */ +function isForStatementUpdate(node) { + const parent = node.parent; + + return parent.type === "ForStatement" && parent.update === node; +} + +/** + * Determines whether the given node is considered to be a for loop "afterthought" by the logic of this rule. + * In particular, it returns `true` if the given node is either: + * - The update node of a `ForStatement`: for (;; i++) {} + * - An operand of a sequence expression that is the update node: for (;; foo(), i++) {} + * - An operand of a sequence expression that is child of another sequence expression, etc., + * up to the sequence expression that is the update node: for (;; foo(), (bar(), (baz(), i++))) {} + * @param {ASTNode} node The node to check. + * @returns {boolean} `true` if the node is a for loop afterthought. + */ +function isForLoopAfterthought(node) { + const parent = node.parent; + + if (parent.type === "SequenceExpression") { + return isForLoopAfterthought(parent); + } + + return isForStatementUpdate(node); +} + //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -32,27 +67,32 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + unexpectedUnaryOp: "Unary operator '{{operator}}' used." + } }, create(context) { const config = context.options[0]; - let allowInForAfterthought = false; + let allowForLoopAfterthoughts = false; if (typeof config === "object") { - allowInForAfterthought = config.allowForLoopAfterthoughts === true; + allowForLoopAfterthoughts = config.allowForLoopAfterthoughts === true; } return { UpdateExpression(node) { - if (allowInForAfterthought && node.parent.type === "ForStatement") { + if (allowForLoopAfterthoughts && isForLoopAfterthought(node)) { return; } + context.report({ node, - message: "Unary operator '{{operator}}' used.", + messageId: "unexpectedUnaryOp", data: { operator: node.operator } diff --git a/tools/node_modules/eslint/lib/rules/no-process-env.js b/tools/node_modules/eslint/lib/rules/no-process-env.js index a66d9709b09b4f..0f8d7f8a339d0e 100644 --- a/tools/node_modules/eslint/lib/rules/no-process-env.js +++ b/tools/node_modules/eslint/lib/rules/no-process-env.js @@ -19,7 +19,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-process-env" }, - schema: [] + schema: [], + + messages: { + unexpectedProcessEnv: "Unexpected use of process.env." + } }, create(context) { @@ -31,7 +35,7 @@ module.exports = { propertyName = node.property.name; if (objectName === "process" && !node.computed && propertyName && propertyName === "env") { - context.report({ node, message: "Unexpected use of process.env." }); + context.report({ node, messageId: "unexpectedProcessEnv" }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-process-exit.js b/tools/node_modules/eslint/lib/rules/no-process-exit.js index fcfc6b2af59d0e..29871660cc6ee1 100644 --- a/tools/node_modules/eslint/lib/rules/no-process-exit.js +++ b/tools/node_modules/eslint/lib/rules/no-process-exit.js @@ -19,7 +19,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-process-exit" }, - schema: [] + schema: [], + + messages: { + noProcessExit: "Don't use process.exit(); throw an error instead." + } }, create(context) { @@ -30,7 +34,7 @@ module.exports = { return { "CallExpression > MemberExpression.callee[object.name = 'process'][property.name = 'exit']"(node) { - context.report({ node: node.parent, message: "Don't use process.exit(); throw an error instead." }); + context.report({ node: node.parent, messageId: "noProcessExit" }); } }; diff --git a/tools/node_modules/eslint/lib/rules/no-proto.js b/tools/node_modules/eslint/lib/rules/no-proto.js index 80b9650941696d..82ce02fa4e3b9e 100644 --- a/tools/node_modules/eslint/lib/rules/no-proto.js +++ b/tools/node_modules/eslint/lib/rules/no-proto.js @@ -5,6 +5,12 @@ "use strict"; +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const { getStaticPropertyName } = require("./utils/ast-utils"); + //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -20,7 +26,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-proto" }, - schema: [] + schema: [], + + messages: { + unexpectedProto: "The '__proto__' property is deprecated." + } }, create(context) { @@ -28,11 +38,8 @@ module.exports = { return { MemberExpression(node) { - - if (node.property && - (node.property.type === "Identifier" && node.property.name === "__proto__" && !node.computed) || - (node.property.type === "Literal" && node.property.value === "__proto__")) { - context.report({ node, message: "The '__proto__' property is deprecated." }); + if (getStaticPropertyName(node) === "__proto__") { + context.report({ node, messageId: "unexpectedProto" }); } } }; diff --git a/tools/node_modules/eslint/lib/rules/no-prototype-builtins.js b/tools/node_modules/eslint/lib/rules/no-prototype-builtins.js index 87a760156e3693..a00d3707204ffd 100644 --- a/tools/node_modules/eslint/lib/rules/no-prototype-builtins.js +++ b/tools/node_modules/eslint/lib/rules/no-prototype-builtins.js @@ -19,7 +19,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-prototype-builtins" }, - schema: [] + schema: [], + + messages: { + prototypeBuildIn: "Do not access Object.prototype method '{{prop}}' from target object." + } }, create(context) { @@ -42,8 +46,8 @@ module.exports = { if (DISALLOWED_PROPS.indexOf(propName) > -1) { context.report({ - message: "Do not access Object.prototype method '{{prop}}' from target object.", - loc: node.callee.property.loc.start, + messageId: "prototypeBuildIn", + loc: node.callee.property.loc, data: { prop: propName }, node }); diff --git a/tools/node_modules/eslint/lib/rules/no-regex-spaces.js b/tools/node_modules/eslint/lib/rules/no-regex-spaces.js index 7581e9271fdf14..afb26d70259f1b 100644 --- a/tools/node_modules/eslint/lib/rules/no-regex-spaces.js +++ b/tools/node_modules/eslint/lib/rules/no-regex-spaces.js @@ -45,7 +45,11 @@ module.exports = { }, schema: [], - fixable: "code" + fixable: "code", + + messages: { + multipleSpaces: "Spaces are hard to count. Use {{{length}}}." + } }, create(context) { @@ -96,7 +100,7 @@ module.exports = { ) { context.report({ node: nodeToReport, - message: "Spaces are hard to count. Use {{{length}}}.", + messageId: "multipleSpaces", data: { length }, fix(fixer) { if (pattern !== rawPattern) { @@ -109,7 +113,7 @@ module.exports = { } }); - // Report only the first occurence of consecutive spaces + // Report only the first occurrence of consecutive spaces return; } } diff --git a/tools/node_modules/eslint/lib/rules/no-restricted-exports.js b/tools/node_modules/eslint/lib/rules/no-restricted-exports.js new file mode 100644 index 00000000000000..5b5c7d9bffb99c --- /dev/null +++ b/tools/node_modules/eslint/lib/rules/no-restricted-exports.js @@ -0,0 +1,84 @@ +/** + * @fileoverview Rule to disallow specified names in exports + * @author Milos Djermanovic + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +module.exports = { + meta: { + type: "suggestion", + + docs: { + description: "disallow specified names in exports", + category: "ECMAScript 6", + recommended: false, + url: "https://eslint.org/docs/rules/no-restricted-exports" + }, + + schema: [{ + type: "object", + properties: { + restrictedNamedExports: { + type: "array", + items: { + type: "string" + }, + uniqueItems: true + } + }, + additionalProperties: false + }], + + messages: { + restrictedNamed: "'{{name}}' is restricted from being used as an exported name." + } + }, + + create(context) { + + const restrictedNames = new Set(context.options[0] && context.options[0].restrictedNamedExports); + + /** + * Checks and reports given exported identifier. + * @param {ASTNode} node exported `Identifer` node to check. + * @returns {void} + */ + function checkExportedName(node) { + const name = node.name; + + if (restrictedNames.has(name)) { + context.report({ + node, + messageId: "restrictedNamed", + data: { name } + }); + } + } + + return { + ExportNamedDeclaration(node) { + const declaration = node.declaration; + + if (declaration) { + if (declaration.type === "FunctionDeclaration" || declaration.type === "ClassDeclaration") { + checkExportedName(declaration.id); + } else if (declaration.type === "VariableDeclaration") { + context.getDeclaredVariables(declaration) + .map(v => v.defs.find(d => d.parent === declaration)) + .map(d => d.name) // Identifier nodes + .forEach(checkExportedName); + } + } else { + node.specifiers + .map(s => s.exported) + .forEach(checkExportedName); + } + } + }; + } +}; diff --git a/tools/node_modules/eslint/lib/rules/no-restricted-globals.js b/tools/node_modules/eslint/lib/rules/no-restricted-globals.js index 1a2629a8ec95e8..2c932a7307c0b2 100644 --- a/tools/node_modules/eslint/lib/rules/no-restricted-globals.js +++ b/tools/node_modules/eslint/lib/rules/no-restricted-globals.js @@ -4,13 +4,6 @@ */ "use strict"; -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const DEFAULT_MESSAGE_TEMPLATE = "Unexpected use of '{{name}}'.", - CUSTOM_MESSAGE_TEMPLATE = "Unexpected use of '{{name}}'. {{customMessage}}"; - //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -46,6 +39,12 @@ module.exports = { }, uniqueItems: true, minItems: 0 + }, + + messages: { + defaultMessage: "Unexpected use of '{{name}}'.", + // eslint-disable-next-line eslint-plugin/report-message-format + customMessage: "Unexpected use of '{{name}}'. {{customMessage}}" } }, @@ -75,13 +74,13 @@ module.exports = { function reportReference(reference) { const name = reference.identifier.name, customMessage = restrictedGlobalMessages[name], - message = customMessage - ? CUSTOM_MESSAGE_TEMPLATE - : DEFAULT_MESSAGE_TEMPLATE; + messageId = customMessage + ? "customMessage" + : "defaultMessage"; context.report({ node: reference.identifier, - message, + messageId, data: { name, customMessage diff --git a/tools/node_modules/eslint/lib/rules/no-restricted-imports.js b/tools/node_modules/eslint/lib/rules/no-restricted-imports.js index ec0696f99a2de0..c205dad8bdb79d 100644 --- a/tools/node_modules/eslint/lib/rules/no-restricted-imports.js +++ b/tools/node_modules/eslint/lib/rules/no-restricted-imports.js @@ -64,7 +64,11 @@ module.exports = { everything: "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted.", // eslint-disable-next-line eslint-plugin/report-message-format - everythingWithCustomMessage: "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted. {{customMessage}}" + everythingWithCustomMessage: "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted. {{customMessage}}", + + importName: "'{{importName}}' import from '{{importSource}}' is restricted.", + // eslint-disable-next-line eslint-plugin/report-message-format + importNameWithCustomMessage: "'{{importName}}' import from '{{importSource}}' is restricted. {{customMessage}}" }, schema: { @@ -87,6 +91,7 @@ module.exports = { }, create(context) { + const sourceCode = context.getSourceCode(); const options = Array.isArray(context.options) ? context.options : []; const isPathAndPatternsObject = typeof options[0] === "object" && @@ -95,6 +100,11 @@ module.exports = { const restrictedPaths = (isPathAndPatternsObject ? options[0].paths : context.options) || []; const restrictedPatterns = (isPathAndPatternsObject ? options[0].patterns : []) || []; + // if no imports are restricted we don"t need to check + if (Object.keys(restrictedPaths).length === 0 && restrictedPatterns.length === 0) { + return {}; + } + const restrictedPathMessages = restrictedPaths.reduce((memo, importSource) => { if (typeof importSource === "string") { memo[importSource] = { message: null }; @@ -107,40 +117,68 @@ module.exports = { return memo; }, {}); - // if no imports are restricted we don"t need to check - if (Object.keys(restrictedPaths).length === 0 && restrictedPatterns.length === 0) { - return {}; - } - const restrictedPatternsMatcher = ignore().add(restrictedPatterns); - /** - * Checks to see if "*" is being used to import everything. - * @param {Set.} importNames Set of import names that are being imported - * @returns {boolean} whether everything is imported or not - */ - function isEverythingImported(importNames) { - return importNames.has("*"); - } - /** * Report a restricted path. + * @param {string} importSource path of the import + * @param {Map} importNames Map of import names that are being imported * @param {node} node representing the restricted path reference * @returns {void} * @private */ - function reportPath(node) { - const importSource = node.source.value.trim(); - const customMessage = restrictedPathMessages[importSource] && restrictedPathMessages[importSource].message; + function checkRestrictedPathAndReport(importSource, importNames, node) { + if (!Object.prototype.hasOwnProperty.call(restrictedPathMessages, importSource)) { + return; + } - context.report({ - node, - messageId: customMessage ? "pathWithCustomMessage" : "path", - data: { - importSource, - customMessage + const customMessage = restrictedPathMessages[importSource].message; + const restrictedImportNames = restrictedPathMessages[importSource].importNames; + + if (restrictedImportNames) { + if (importNames.has("*")) { + const specifierData = importNames.get("*")[0]; + + context.report({ + node, + messageId: customMessage ? "everythingWithCustomMessage" : "everything", + loc: specifierData.loc, + data: { + importSource, + importNames: restrictedImportNames, + customMessage + } + }); } - }); + + restrictedImportNames.forEach(importName => { + if (importNames.has(importName)) { + const specifiers = importNames.get(importName); + + specifiers.forEach(specifier => { + context.report({ + node, + messageId: customMessage ? "importNameWithCustomMessage" : "importName", + loc: specifier.loc, + data: { + importSource, + customMessage, + importName + } + }); + }); + } + }); + } else { + context.report({ + node, + messageId: customMessage ? "pathWithCustomMessage" : "path", + data: { + importSource, + customMessage + } + }); + } } /** @@ -161,75 +199,6 @@ module.exports = { }); } - /** - * Report a restricted path specifically when using the '*' import. - * @param {string} importSource path of the import - * @param {node} node representing the restricted path reference - * @returns {void} - * @private - */ - function reportPathForEverythingImported(importSource, node) { - const importNames = restrictedPathMessages[importSource].importNames; - const customMessage = restrictedPathMessages[importSource] && restrictedPathMessages[importSource].message; - - context.report({ - node, - messageId: customMessage ? "everythingWithCustomMessage" : "everything", - data: { - importSource, - importNames, - customMessage - } - }); - } - - /** - * Check if the given importSource is restricted because '*' is being imported. - * @param {string} importSource path of the import - * @param {Set.} importNames Set of import names that are being imported - * @returns {boolean} whether the path is restricted - * @private - */ - function isRestrictedForEverythingImported(importSource, importNames) { - return Object.prototype.hasOwnProperty.call(restrictedPathMessages, importSource) && - restrictedPathMessages[importSource].importNames && - isEverythingImported(importNames); - } - - /** - * Check if the given importNames are restricted given a list of restrictedImportNames. - * @param {Set.} importNames Set of import names that are being imported - * @param {string[]} restrictedImportNames array of import names that are restricted for this import - * @returns {boolean} whether the objectName is restricted - * @private - */ - function isRestrictedObject(importNames, restrictedImportNames) { - return restrictedImportNames.some(restrictedObjectName => ( - importNames.has(restrictedObjectName) - )); - } - - /** - * Check if the given importSource is a restricted path. - * @param {string} importSource path of the import - * @param {Set.} importNames Set of import names that are being imported - * @returns {boolean} whether the variable is a restricted path or not - * @private - */ - function isRestrictedPath(importSource, importNames) { - let isRestricted = false; - - if (Object.prototype.hasOwnProperty.call(restrictedPathMessages, importSource)) { - if (restrictedPathMessages[importSource].importNames) { - isRestricted = isRestrictedObject(importNames, restrictedPathMessages[importSource].importNames); - } else { - isRestricted = true; - } - } - - return isRestricted; - } - /** * Check if the given importSource is restricted by a pattern. * @param {string} importSource path of the import @@ -248,26 +217,39 @@ module.exports = { */ function checkNode(node) { const importSource = node.source.value.trim(); - const importNames = node.specifiers ? node.specifiers.reduce((set, specifier) => { - if (specifier.type === "ImportDefaultSpecifier") { - set.add("default"); - } else if (specifier.type === "ImportNamespaceSpecifier") { - set.add("*"); - } else if (specifier.imported) { - set.add(specifier.imported.name); - } else if (specifier.local) { - set.add(specifier.local.name); - } - return set; - }, new Set()) : new Set(); + const importNames = new Map(); + + if (node.type === "ExportAllDeclaration") { + const starToken = sourceCode.getFirstToken(node, 1); + + importNames.set("*", [{ loc: starToken.loc }]); + } else if (node.specifiers) { + for (const specifier of node.specifiers) { + let name; + const specifierData = { loc: specifier.loc }; + + if (specifier.type === "ImportDefaultSpecifier") { + name = "default"; + } else if (specifier.type === "ImportNamespaceSpecifier") { + name = "*"; + } else if (specifier.imported) { + name = specifier.imported.name; + } else if (specifier.local) { + name = specifier.local.name; + } - if (isRestrictedForEverythingImported(importSource, importNames)) { - reportPathForEverythingImported(importSource, node); + if (name) { + if (importNames.has(name)) { + importNames.get(name).push(specifierData); + } else { + importNames.set(name, [specifierData]); + } + } + } } - if (isRestrictedPath(importSource, importNames)) { - reportPath(node); - } + checkRestrictedPathAndReport(importSource, importNames, node); + if (isRestrictedPattern(importSource)) { reportPathForPatterns(node); } diff --git a/tools/node_modules/eslint/lib/rules/no-restricted-modules.js b/tools/node_modules/eslint/lib/rules/no-restricted-modules.js index ef8748a7d04baf..abd8d5cbe29381 100644 --- a/tools/node_modules/eslint/lib/rules/no-restricted-modules.js +++ b/tools/node_modules/eslint/lib/rules/no-restricted-modules.js @@ -4,13 +4,6 @@ */ "use strict"; -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const DEFAULT_MESSAGE_TEMPLATE = "'{{moduleName}}' module is restricted from being used."; -const CUSTOM_MESSAGE_TEMPLATE = "'{{moduleName}}' module is restricted from being used. {{customMessage}}"; - //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -72,6 +65,13 @@ module.exports = { additionalItems: false } ] + }, + + messages: { + defaultMessage: "'{{name}}' module is restricted from being used.", + // eslint-disable-next-line eslint-plugin/report-message-format + customMessage: "'{{name}}' module is restricted from being used. {{customMessage}}", + patternMessage: "'{{name}}' module is restricted from being used by a pattern." } }, @@ -106,10 +106,19 @@ module.exports = { * @param {ASTNode} node The node to check. * @returns {boolean} If the node is a string literal. */ - function isString(node) { + function isStringLiteral(node) { return node && node.type === "Literal" && typeof node.value === "string"; } + /** + * Function to check if a node is a static string template literal. + * @param {ASTNode} node The node to check. + * @returns {boolean} If the node is a string template literal. + */ + function isStaticTemplateLiteral(node) { + return node && node.type === "TemplateLiteral" && node.expressions.length === 0; + } + /** * Function to check if a node is a require call. * @param {ASTNode} node The node to check. @@ -119,24 +128,41 @@ module.exports = { return node.callee.type === "Identifier" && node.callee.name === "require"; } + /** + * Extract string from Literal or TemplateLiteral node + * @param {ASTNode} node The node to extract from + * @returns {string|null} Extracted string or null if node doesn't represent a string + */ + function getFirstArgumentString(node) { + if (isStringLiteral(node)) { + return node.value.trim(); + } + + if (isStaticTemplateLiteral(node)) { + return node.quasis[0].value.cooked.trim(); + } + + return null; + } + /** * Report a restricted path. * @param {node} node representing the restricted path reference + * @param {string} name restricted path * @returns {void} * @private */ - function reportPath(node) { - const moduleName = node.arguments[0].value.trim(); - const customMessage = restrictedPathMessages[moduleName]; - const message = customMessage - ? CUSTOM_MESSAGE_TEMPLATE - : DEFAULT_MESSAGE_TEMPLATE; + function reportPath(node, name) { + const customMessage = restrictedPathMessages[name]; + const messageId = customMessage + ? "customMessage" + : "defaultMessage"; context.report({ node, - message, + messageId, data: { - moduleName, + name, customMessage } }); @@ -156,21 +182,25 @@ module.exports = { CallExpression(node) { if (isRequireCall(node)) { - // node has arguments and first argument is string - if (node.arguments.length && isString(node.arguments[0])) { - const moduleName = node.arguments[0].value.trim(); - - // check if argument value is in restricted modules array - if (isRestrictedPath(moduleName)) { - reportPath(node); - } - - if (restrictedPatterns.length > 0 && ig.ignores(moduleName)) { - context.report({ - node, - message: "'{{moduleName}}' module is restricted from being used by a pattern.", - data: { moduleName } - }); + // node has arguments + if (node.arguments.length) { + const name = getFirstArgumentString(node.arguments[0]); + + // if first argument is a string literal or a static string template literal + if (name) { + + // check if argument value is in restricted modules array + if (isRestrictedPath(name)) { + reportPath(node, name); + } + + if (restrictedPatterns.length > 0 && ig.ignores(name)) { + context.report({ + node, + messageId: "patternMessage", + data: { name } + }); + } } } } diff --git a/tools/node_modules/eslint/lib/rules/no-restricted-properties.js b/tools/node_modules/eslint/lib/rules/no-restricted-properties.js index bdab22b19c4edc..7ab83995a3ebbf 100644 --- a/tools/node_modules/eslint/lib/rules/no-restricted-properties.js +++ b/tools/node_modules/eslint/lib/rules/no-restricted-properties.js @@ -61,6 +61,13 @@ module.exports = { ] }, uniqueItems: true + }, + + messages: { + // eslint-disable-next-line eslint-plugin/report-message-format + restrictedObjectProperty: "'{{objectName}}.{{propertyName}}' is restricted from being used.{{message}}", + // eslint-disable-next-line eslint-plugin/report-message-format + restrictedProperty: "'{{propertyName}}' is restricted from being used.{{message}}" } }, @@ -114,8 +121,7 @@ module.exports = { context.report({ node, - // eslint-disable-next-line eslint-plugin/report-message-format - message: "'{{objectName}}.{{propertyName}}' is restricted from being used.{{message}}", + messageId: "restrictedObjectProperty", data: { objectName, propertyName, @@ -127,8 +133,7 @@ module.exports = { context.report({ node, - // eslint-disable-next-line eslint-plugin/report-message-format - message: "'{{propertyName}}' is restricted from being used.{{message}}", + messageId: "restrictedProperty", data: { propertyName, message diff --git a/tools/node_modules/eslint/lib/rules/no-restricted-syntax.js b/tools/node_modules/eslint/lib/rules/no-restricted-syntax.js index 41aa9fa390a88d..9572603a82485a 100644 --- a/tools/node_modules/eslint/lib/rules/no-restricted-syntax.js +++ b/tools/node_modules/eslint/lib/rules/no-restricted-syntax.js @@ -39,6 +39,11 @@ module.exports = { }, uniqueItems: true, minItems: 0 + }, + + messages: { + // eslint-disable-next-line eslint-plugin/report-message-format + restrictedSyntax: "{{message}}" } }, @@ -48,14 +53,14 @@ module.exports = { const hasCustomMessage = !isStringFormat && Boolean(selectorOrObject.message); const selector = isStringFormat ? selectorOrObject : selectorOrObject.selector; - const message = hasCustomMessage ? selectorOrObject.message : "Using '{{selector}}' is not allowed."; + const message = hasCustomMessage ? selectorOrObject.message : `Using '${selector}' is not allowed.`; return Object.assign(result, { [selector](node) { context.report({ node, - message, - data: hasCustomMessage ? {} : { selector } + messageId: "restrictedSyntax", + data: { message } }); } }); diff --git a/tools/node_modules/eslint/lib/rules/no-return-assign.js b/tools/node_modules/eslint/lib/rules/no-return-assign.js index ea6a6bb49fcf6d..4b57d42eb9952b 100644 --- a/tools/node_modules/eslint/lib/rules/no-return-assign.js +++ b/tools/node_modules/eslint/lib/rules/no-return-assign.js @@ -35,7 +35,12 @@ module.exports = { { enum: ["except-parens", "always"] } - ] + ], + + messages: { + returnAssignment: "Return statement should not contain assignment.", + arrowAssignment: "Arrow function should not return assignment." + } }, create(context) { @@ -61,12 +66,12 @@ module.exports = { if (parent && parent.type === "ReturnStatement") { context.report({ node: parent, - message: "Return statement should not contain assignment." + messageId: "returnAssignment" }); } else if (parent && parent.type === "ArrowFunctionExpression" && parent.body === currentChild) { context.report({ node: parent, - message: "Arrow function should not return assignment." + messageId: "arrowAssignment" }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-return-await.js b/tools/node_modules/eslint/lib/rules/no-return-await.js index 6652b5932dc1b8..d1d89826856dc4 100644 --- a/tools/node_modules/eslint/lib/rules/no-return-await.js +++ b/tools/node_modules/eslint/lib/rules/no-return-await.js @@ -10,8 +10,6 @@ const astUtils = require("./utils/ast-utils"); // Rule Definition //------------------------------------------------------------------------------ -const message = "Redundant use of `await` on a return value."; - module.exports = { meta: { type: "suggestion", @@ -28,7 +26,11 @@ module.exports = { fixable: null, schema: [ - ] + ], + + messages: { + redundantUseOfAwait: "Redundant use of `await` on a return value." + } }, create(context) { @@ -42,7 +44,7 @@ module.exports = { context.report({ node: context.getSourceCode().getFirstToken(node), loc: node.loc, - message + messageId: "redundantUseOfAwait" }); } diff --git a/tools/node_modules/eslint/lib/rules/no-script-url.js b/tools/node_modules/eslint/lib/rules/no-script-url.js index 40e9bfe8b27544..2078fc1dcea122 100644 --- a/tools/node_modules/eslint/lib/rules/no-script-url.js +++ b/tools/node_modules/eslint/lib/rules/no-script-url.js @@ -22,7 +22,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-script-url" }, - schema: [] + schema: [], + + messages: { + unexpectedScriptURL: "Script URL is a form of eval." + } }, create(context) { @@ -34,7 +38,7 @@ module.exports = { const value = node.value.toLowerCase(); if (value.indexOf("javascript:") === 0) { - context.report({ node, message: "Script URL is a form of eval." }); + context.report({ node, messageId: "unexpectedScriptURL" }); } } } diff --git a/tools/node_modules/eslint/lib/rules/no-self-assign.js b/tools/node_modules/eslint/lib/rules/no-self-assign.js index 705d0f409c4128..170e46b05930d1 100644 --- a/tools/node_modules/eslint/lib/rules/no-self-assign.js +++ b/tools/node_modules/eslint/lib/rules/no-self-assign.js @@ -196,7 +196,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + selfAssignment: "'{{name}}' is assigned to itself." + } }, create(context) { @@ -211,7 +215,7 @@ module.exports = { function report(node) { context.report({ node, - message: "'{{name}}' is assigned to itself.", + messageId: "selfAssignment", data: { name: sourceCode.getText(node).replace(SPACES, "") } diff --git a/tools/node_modules/eslint/lib/rules/no-self-compare.js b/tools/node_modules/eslint/lib/rules/no-self-compare.js index 8986240ec5c842..79b6ac7ea0f28d 100644 --- a/tools/node_modules/eslint/lib/rules/no-self-compare.js +++ b/tools/node_modules/eslint/lib/rules/no-self-compare.js @@ -21,7 +21,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-self-compare" }, - schema: [] + schema: [], + + messages: { + comparingToSelf: "Comparing to itself is potentially pointless." + } }, create(context) { @@ -47,7 +51,7 @@ module.exports = { const operators = new Set(["===", "==", "!==", "!=", ">", "<", ">=", "<="]); if (operators.has(node.operator) && hasSameTokens(node.left, node.right)) { - context.report({ node, message: "Comparing to itself is potentially pointless." }); + context.report({ node, messageId: "comparingToSelf" }); } } }; diff --git a/tools/node_modules/eslint/lib/rules/no-sequences.js b/tools/node_modules/eslint/lib/rules/no-sequences.js index 8046a8711a3e9a..d67635d117549e 100644 --- a/tools/node_modules/eslint/lib/rules/no-sequences.js +++ b/tools/node_modules/eslint/lib/rules/no-sequences.js @@ -26,7 +26,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-sequences" }, - schema: [] + schema: [], + + messages: { + unexpectedCommaExpression: "Unexpected use of comma operator." + } }, create(context) { @@ -107,7 +111,7 @@ module.exports = { const firstCommaToken = sourceCode.getTokenAfter(node.expressions[0], astUtils.isCommaToken); - context.report({ node, loc: firstCommaToken.loc, message: "Unexpected use of comma operator." }); + context.report({ node, loc: firstCommaToken.loc, messageId: "unexpectedCommaExpression" }); } }; diff --git a/tools/node_modules/eslint/lib/rules/no-setter-return.js b/tools/node_modules/eslint/lib/rules/no-setter-return.js index e0948696c347f5..a558640c357d92 100644 --- a/tools/node_modules/eslint/lib/rules/no-setter-return.js +++ b/tools/node_modules/eslint/lib/rules/no-setter-return.js @@ -145,7 +145,7 @@ module.exports = { docs: { description: "disallow returning values from setters", category: "Possible Errors", - recommended: false, + recommended: true, url: "https://eslint.org/docs/rules/no-setter-return" }, diff --git a/tools/node_modules/eslint/lib/rules/no-shadow-restricted-names.js b/tools/node_modules/eslint/lib/rules/no-shadow-restricted-names.js index 9030d523b705d2..9647e9a1bcdd9e 100644 --- a/tools/node_modules/eslint/lib/rules/no-shadow-restricted-names.js +++ b/tools/node_modules/eslint/lib/rules/no-shadow-restricted-names.js @@ -32,7 +32,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-shadow-restricted-names" }, - schema: [] + schema: [], + + messages: { + shadowingRestrictedName: "Shadowing of global property '{{name}}'." + } }, create(context) { @@ -46,9 +50,9 @@ module.exports = { if (variable.defs.length > 0 && RESTRICTED.has(variable.name) && !safelyShadowsUndefined(variable)) { context.report({ node: variable.defs[0].name, - message: "Shadowing of global property '{{idName}}'.", + messageId: "shadowingRestrictedName", data: { - idName: variable.name + name: variable.name } }); } diff --git a/tools/node_modules/eslint/lib/rules/no-shadow.js b/tools/node_modules/eslint/lib/rules/no-shadow.js index bad6cb5f3094cc..1be8590e47abcb 100644 --- a/tools/node_modules/eslint/lib/rules/no-shadow.js +++ b/tools/node_modules/eslint/lib/rules/no-shadow.js @@ -41,7 +41,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + noShadow: "'{{name}}' is already declared in the upper scope." + } }, create(context) { @@ -163,7 +167,7 @@ module.exports = { ) { context.report({ node: variable.identifiers[0], - message: "'{{name}}' is already declared in the upper scope.", + messageId: "noShadow", data: variable }); } diff --git a/tools/node_modules/eslint/lib/rules/no-spaced-func.js b/tools/node_modules/eslint/lib/rules/no-spaced-func.js index 8535881f435e48..961bc681f7eac5 100644 --- a/tools/node_modules/eslint/lib/rules/no-spaced-func.js +++ b/tools/node_modules/eslint/lib/rules/no-spaced-func.js @@ -26,7 +26,11 @@ module.exports = { replacedBy: ["func-call-spacing"], fixable: "whitespace", - schema: [] + schema: [], + + messages: { + noSpacedFunction: "Unexpected space between function name and paren." + } }, create(context) { @@ -62,7 +66,7 @@ module.exports = { context.report({ node, loc: lastCalleeToken.loc.start, - message: "Unexpected space between function name and paren.", + messageId: "noSpacedFunction", fix(fixer) { return fixer.removeRange([prevToken.range[1], parenToken.range[0]]); } diff --git a/tools/node_modules/eslint/lib/rules/no-sparse-arrays.js b/tools/node_modules/eslint/lib/rules/no-sparse-arrays.js index 985109c36b267d..e8407c3faede2d 100644 --- a/tools/node_modules/eslint/lib/rules/no-sparse-arrays.js +++ b/tools/node_modules/eslint/lib/rules/no-sparse-arrays.js @@ -19,7 +19,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-sparse-arrays" }, - schema: [] + schema: [], + + messages: { + unexpectedSparseArray: "Unexpected comma in middle of array." + } }, create(context) { @@ -36,7 +40,7 @@ module.exports = { const emptySpot = node.elements.indexOf(null) > -1; if (emptySpot) { - context.report({ node, message: "Unexpected comma in middle of array." }); + context.report({ node, messageId: "unexpectedSparseArray" }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-sync.js b/tools/node_modules/eslint/lib/rules/no-sync.js index 578bac96d3d061..d8111059631734 100644 --- a/tools/node_modules/eslint/lib/rules/no-sync.js +++ b/tools/node_modules/eslint/lib/rules/no-sync.js @@ -33,7 +33,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + noSync: "Unexpected sync method: '{{propertyName}}'." + } }, create(context) { @@ -45,7 +49,7 @@ module.exports = { [selector](node) { context.report({ node, - message: "Unexpected sync method: '{{propertyName}}'.", + messageId: "noSync", data: { propertyName: node.property.name } diff --git a/tools/node_modules/eslint/lib/rules/no-tabs.js b/tools/node_modules/eslint/lib/rules/no-tabs.js index 3fc0b78b6e741c..ca7be261653c02 100644 --- a/tools/node_modules/eslint/lib/rules/no-tabs.js +++ b/tools/node_modules/eslint/lib/rules/no-tabs.js @@ -35,7 +35,11 @@ module.exports = { } }, additionalProperties: false - }] + }], + + messages: { + unexpectedTab: "Unexpected tab character." + } }, create(context) { @@ -64,7 +68,7 @@ module.exports = { column: match.index + match[0].length } }, - message: "Unexpected tab character." + messageId: "unexpectedTab" }); } }); diff --git a/tools/node_modules/eslint/lib/rules/no-template-curly-in-string.js b/tools/node_modules/eslint/lib/rules/no-template-curly-in-string.js index f7822e961cc1e7..539cd5be5ff9c5 100644 --- a/tools/node_modules/eslint/lib/rules/no-template-curly-in-string.js +++ b/tools/node_modules/eslint/lib/rules/no-template-curly-in-string.js @@ -19,7 +19,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-template-curly-in-string" }, - schema: [] + schema: [], + + messages: { + unexpectedTemplateExpression: "Unexpected template string expression." + } }, create(context) { @@ -30,7 +34,7 @@ module.exports = { if (typeof node.value === "string" && regex.test(node.value)) { context.report({ node, - message: "Unexpected template string expression." + messageId: "unexpectedTemplateExpression" }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-ternary.js b/tools/node_modules/eslint/lib/rules/no-ternary.js index 890f2abfa0c59a..b3ced86056614c 100644 --- a/tools/node_modules/eslint/lib/rules/no-ternary.js +++ b/tools/node_modules/eslint/lib/rules/no-ternary.js @@ -20,7 +20,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-ternary" }, - schema: [] + schema: [], + + messages: { + noTernaryOperator: "Ternary operator used." + } }, create(context) { @@ -28,7 +32,7 @@ module.exports = { return { ConditionalExpression(node) { - context.report({ node, message: "Ternary operator used." }); + context.report({ node, messageId: "noTernaryOperator" }); } }; diff --git a/tools/node_modules/eslint/lib/rules/no-this-before-super.js b/tools/node_modules/eslint/lib/rules/no-this-before-super.js index 6975ea060bf00d..44288c0c97136e 100644 --- a/tools/node_modules/eslint/lib/rules/no-this-before-super.js +++ b/tools/node_modules/eslint/lib/rules/no-this-before-super.js @@ -45,7 +45,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-this-before-super" }, - schema: [] + schema: [], + + messages: { + noBeforeSuper: "'{{kind}}' is not allowed before 'super()'." + } }, create(context) { @@ -187,7 +191,7 @@ module.exports = { const invalidNode = info.invalidNodes[i]; context.report({ - message: "'{{kind}}' is not allowed before 'super()'.", + messageId: "noBeforeSuper", node: invalidNode, data: { kind: invalidNode.type === "Super" ? "super" : "this" diff --git a/tools/node_modules/eslint/lib/rules/no-trailing-spaces.js b/tools/node_modules/eslint/lib/rules/no-trailing-spaces.js index 3a4124f4c0f7a4..98ae62c896359c 100644 --- a/tools/node_modules/eslint/lib/rules/no-trailing-spaces.js +++ b/tools/node_modules/eslint/lib/rules/no-trailing-spaces.js @@ -42,7 +42,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + trailingSpace: "Trailing spaces not allowed." + } }, create(context) { @@ -74,7 +78,7 @@ module.exports = { context.report({ node, loc: location, - message: "Trailing spaces not allowed.", + messageId: "trailingSpace", fix(fixer) { return fixer.removeRange(fixRange); } diff --git a/tools/node_modules/eslint/lib/rules/no-undef-init.js b/tools/node_modules/eslint/lib/rules/no-undef-init.js index 1fdccb867b3c24..5c240fef742b83 100644 --- a/tools/node_modules/eslint/lib/rules/no-undef-init.js +++ b/tools/node_modules/eslint/lib/rules/no-undef-init.js @@ -23,7 +23,11 @@ module.exports = { }, schema: [], - fixable: "code" + fixable: "code", + + messages: { + unnecessaryUndefinedInit: "It's not necessary to initialize '{{name}}' to undefined." + } }, create(context) { @@ -43,7 +47,7 @@ module.exports = { if (init === "undefined" && node.parent.kind !== "const" && !shadowed) { context.report({ node, - message: "It's not necessary to initialize '{{name}}' to undefined.", + messageId: "unnecessaryUndefinedInit", data: { name }, fix(fixer) { if (node.parent.kind === "var") { diff --git a/tools/node_modules/eslint/lib/rules/no-undefined.js b/tools/node_modules/eslint/lib/rules/no-undefined.js index b92f6700637c30..a075d903e21e98 100644 --- a/tools/node_modules/eslint/lib/rules/no-undefined.js +++ b/tools/node_modules/eslint/lib/rules/no-undefined.js @@ -19,7 +19,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-undefined" }, - schema: [] + schema: [], + + messages: { + unexpectedUndefined: "Unexpected use of undefined." + } }, create(context) { @@ -32,7 +36,7 @@ module.exports = { function report(node) { context.report({ node, - message: "Unexpected use of undefined." + messageId: "unexpectedUndefined" }); } diff --git a/tools/node_modules/eslint/lib/rules/no-underscore-dangle.js b/tools/node_modules/eslint/lib/rules/no-underscore-dangle.js index e910e2739a740a..cac594e10047e8 100644 --- a/tools/node_modules/eslint/lib/rules/no-underscore-dangle.js +++ b/tools/node_modules/eslint/lib/rules/no-underscore-dangle.js @@ -49,7 +49,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + unexpectedUnderscore: "Unexpected dangling '_' in '{{identifier}}'." + } }, create(context) { @@ -134,7 +138,7 @@ module.exports = { if (typeof identifier !== "undefined" && hasTrailingUnderscore(identifier) && !isAllowed(identifier)) { context.report({ node, - message: "Unexpected dangling '_' in '{{identifier}}'.", + messageId: "unexpectedUnderscore", data: { identifier } @@ -156,7 +160,7 @@ module.exports = { !isSpecialCaseIdentifierInVariableExpression(identifier) && !isAllowed(identifier)) { context.report({ node, - message: "Unexpected dangling '_' in '{{identifier}}'.", + messageId: "unexpectedUnderscore", data: { identifier } @@ -183,7 +187,7 @@ module.exports = { !isSpecialCaseIdentifierForMemberExpression(identifier) && !isAllowed(identifier)) { context.report({ node, - message: "Unexpected dangling '_' in '{{identifier}}'.", + messageId: "unexpectedUnderscore", data: { identifier } @@ -201,10 +205,10 @@ module.exports = { const identifier = node.key.name; const isMethod = node.type === "MethodDefinition" || node.type === "Property" && node.method; - if (typeof identifier !== "undefined" && enforceInMethodNames && isMethod && hasTrailingUnderscore(identifier)) { + if (typeof identifier !== "undefined" && enforceInMethodNames && isMethod && hasTrailingUnderscore(identifier) && !isAllowed(identifier)) { context.report({ node, - message: "Unexpected dangling '_' in '{{identifier}}'.", + messageId: "unexpectedUnderscore", data: { identifier } diff --git a/tools/node_modules/eslint/lib/rules/no-unmodified-loop-condition.js b/tools/node_modules/eslint/lib/rules/no-unmodified-loop-condition.js index 3b8e7417d5b586..7031a4dd8b83fc 100644 --- a/tools/node_modules/eslint/lib/rules/no-unmodified-loop-condition.js +++ b/tools/node_modules/eslint/lib/rules/no-unmodified-loop-condition.js @@ -167,7 +167,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-unmodified-loop-condition" }, - schema: [] + schema: [], + + messages: { + loopConditionNotModified: "'{{name}}' is not modified in this loop." + } }, create(context) { @@ -184,7 +188,7 @@ module.exports = { context.report({ node, - message: "'{{name}}' is not modified in this loop.", + messageId: "loopConditionNotModified", data: node }); } diff --git a/tools/node_modules/eslint/lib/rules/no-unneeded-ternary.js b/tools/node_modules/eslint/lib/rules/no-unneeded-ternary.js index 893baa34f74917..d4438e2fe08fbe 100644 --- a/tools/node_modules/eslint/lib/rules/no-unneeded-ternary.js +++ b/tools/node_modules/eslint/lib/rules/no-unneeded-ternary.js @@ -47,7 +47,12 @@ module.exports = { } ], - fixable: "code" + fixable: "code", + + messages: { + unnecessaryConditionalExpression: "Unnecessary use of boolean literals in conditional expression.", + unnecessaryConditionalAssignment: "Unnecessary use of conditional expression for default assignment." + } }, create(context) { @@ -118,7 +123,7 @@ module.exports = { context.report({ node, loc: node.consequent.loc.start, - message: "Unnecessary use of boolean literals in conditional expression.", + messageId: "unnecessaryConditionalExpression", fix(fixer) { if (node.consequent.value === node.alternate.value) { @@ -140,7 +145,7 @@ module.exports = { context.report({ node, loc: node.consequent.loc.start, - message: "Unnecessary use of conditional expression for default assignment.", + messageId: "unnecessaryConditionalAssignment", fix: fixer => { const shouldParenthesizeAlternate = ( astUtils.getPrecedence(node.alternate) < OR_PRECEDENCE && diff --git a/tools/node_modules/eslint/lib/rules/no-unreachable.js b/tools/node_modules/eslint/lib/rules/no-unreachable.js index 91c4ca7150903f..415631a6f7d726 100644 --- a/tools/node_modules/eslint/lib/rules/no-unreachable.js +++ b/tools/node_modules/eslint/lib/rules/no-unreachable.js @@ -110,7 +110,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-unreachable" }, - schema: [] + schema: [], + + messages: { + unreachableCode: "Unreachable code." + } }, create(context) { @@ -154,7 +158,7 @@ module.exports = { */ if (!range.isEmpty) { context.report({ - message: "Unreachable code.", + messageId: "unreachableCode", loc: range.location, node: range.startNode }); diff --git a/tools/node_modules/eslint/lib/rules/no-unsafe-finally.js b/tools/node_modules/eslint/lib/rules/no-unsafe-finally.js index a41dff9c80372f..11bf06e872a813 100644 --- a/tools/node_modules/eslint/lib/rules/no-unsafe-finally.js +++ b/tools/node_modules/eslint/lib/rules/no-unsafe-finally.js @@ -29,7 +29,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-unsafe-finally" }, - schema: [] + schema: [], + + messages: { + unsafeUsage: "Unsafe usage of {{nodeType}}." + } }, create(context) { @@ -86,7 +90,7 @@ module.exports = { function check(node) { if (isInFinallyBlock(node, node.label)) { context.report({ - message: "Unsafe usage of {{nodeType}}.", + messageId: "unsafeUsage", data: { nodeType: node.type }, diff --git a/tools/node_modules/eslint/lib/rules/no-unused-expressions.js b/tools/node_modules/eslint/lib/rules/no-unused-expressions.js index fd0440256be016..26a25b7584bc80 100644 --- a/tools/node_modules/eslint/lib/rules/no-unused-expressions.js +++ b/tools/node_modules/eslint/lib/rules/no-unused-expressions.js @@ -38,7 +38,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + unusedExpression: "Expected an assignment or function call and instead saw an expression." + } }, create(context) { @@ -127,7 +131,7 @@ module.exports = { return { ExpressionStatement(node) { if (!isValidExpression(node.expression) && !isDirective(node, context.getAncestors())) { - context.report({ node, message: "Expected an assignment or function call and instead saw an expression." }); + context.report({ node, messageId: "unusedExpression" }); } } }; diff --git a/tools/node_modules/eslint/lib/rules/no-unused-vars.js b/tools/node_modules/eslint/lib/rules/no-unused-vars.js index 63e6e048ef1e46..18c48bf0d7810c 100644 --- a/tools/node_modules/eslint/lib/rules/no-unused-vars.js +++ b/tools/node_modules/eslint/lib/rules/no-unused-vars.js @@ -11,6 +11,18 @@ const astUtils = require("./utils/ast-utils"); +//------------------------------------------------------------------------------ +// Typedefs +//------------------------------------------------------------------------------ + +/** + * Bag of data used for formatting the `unusedVar` lint message. + * @typedef {Object} UnusedVarMessageData + * @property {string} varName The name of the unused var. + * @property {'defined'|'assigned a value'} action Description of the vars state. + * @property {string} additional Any additional info to be appended at the end. + */ + //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -60,7 +72,11 @@ module.exports = { } ] } - ] + ], + + messages: { + unusedVar: "'{{varName}}' is {{action}} but never used{{additional}}." + } }, create(context) { @@ -101,12 +117,12 @@ module.exports = { } /** - * Generate the warning message about the variable being - * defined and unused, including the ignore pattern if configured. + * Generates the message data about the variable being defined and unused, + * including the ignore pattern if configured. * @param {Variable} unusedVar eslint-scope variable object. - * @returns {string} The warning message to be used with this unused variable. + * @returns {UnusedVarMessageData} The message data to be used with this unused variable. */ - function getDefinedMessage(unusedVar) { + function getDefinedMessageData(unusedVar) { const defType = unusedVar.defs && unusedVar.defs[0] && unusedVar.defs[0].type; let type; let pattern; @@ -122,20 +138,29 @@ module.exports = { pattern = config.varsIgnorePattern.toString(); } - const additional = type ? ` Allowed unused ${type} must match ${pattern}.` : ""; + const additional = type ? `. Allowed unused ${type} must match ${pattern}` : ""; - return `'{{name}}' is defined but never used.${additional}`; + return { + varName: unusedVar.name, + action: "defined", + additional + }; } /** * Generate the warning message about the variable being * assigned and unused, including the ignore pattern if configured. - * @returns {string} The warning message to be used with this unused variable. + * @param {Variable} unusedVar eslint-scope variable object. + * @returns {UnusedVarMessageData} The message data to be used with this unused variable. */ - function getAssignedMessage() { - const additional = config.varsIgnorePattern ? ` Allowed unused vars must match ${config.varsIgnorePattern.toString()}.` : ""; - - return `'{{name}}' is assigned a value but never used.${additional}`; + function getAssignedMessageData(unusedVar) { + const additional = config.varsIgnorePattern ? `. Allowed unused vars must match ${config.varsIgnorePattern.toString()}` : ""; + + return { + varName: unusedVar.name, + action: "assigned a value", + additional + }; } //-------------------------------------------------------------------------- @@ -282,7 +307,7 @@ module.exports = { function getRhsNode(ref, prevRhsNode) { const id = ref.identifier; const parent = id.parent; - const granpa = parent.parent; + const grandparent = parent.parent; const refScope = ref.from.variableScope; const varScope = ref.resolved.scope.variableScope; const canBeUsedLater = refScope !== varScope || astUtils.isInLoop(id); @@ -296,7 +321,7 @@ module.exports = { } if (parent.type === "AssignmentExpression" && - granpa.type === "ExpressionStatement" && + grandparent.type === "ExpressionStatement" && id === parent.left && !canBeUsedLater ) { @@ -342,7 +367,7 @@ module.exports = { /* * If it encountered statements, this is a complex pattern. - * Since analyzeing complex patterns is hard, this returns `true` to avoid false positive. + * Since analyzing complex patterns is hard, this returns `true` to avoid false positive. */ return true; } @@ -389,7 +414,7 @@ module.exports = { function isReadForItself(ref, rhsNode) { const id = ref.identifier; const parent = id.parent; - const granpa = parent.parent; + const grandparent = parent.parent; return ref.isRead() && ( @@ -397,12 +422,12 @@ module.exports = { (// in RHS of an assignment for itself. e.g. `a = a + 1` (( parent.type === "AssignmentExpression" && - granpa.type === "ExpressionStatement" && + grandparent.type === "ExpressionStatement" && parent.left === id ) || ( parent.type === "UpdateExpression" && - granpa.type === "ExpressionStatement" + grandparent.type === "ExpressionStatement" ) || rhsNode && isInside(id, rhsNode) && !isInsideOfStorableFunction(id, rhsNode))) @@ -595,10 +620,10 @@ module.exports = { if (unusedVar.defs.length > 0) { context.report({ node: unusedVar.identifiers[0], - message: unusedVar.references.some(ref => ref.isWrite()) - ? getAssignedMessage() - : getDefinedMessage(unusedVar), - data: unusedVar + messageId: "unusedVar", + data: unusedVar.references.some(ref => ref.isWrite()) + ? getAssignedMessageData(unusedVar) + : getDefinedMessageData(unusedVar) }); // If there are no regular declaration, report the first `/*globals*/` comment directive. @@ -608,8 +633,8 @@ module.exports = { context.report({ node: programNode, loc: astUtils.getNameLocationInGlobalDirectiveComment(sourceCode, directiveComment, unusedVar.name), - message: getDefinedMessage(unusedVar), - data: unusedVar + messageId: "unusedVar", + data: getDefinedMessageData(unusedVar) }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-use-before-define.js b/tools/node_modules/eslint/lib/rules/no-use-before-define.js index ed3540532f9095..c7300567ede0b7 100644 --- a/tools/node_modules/eslint/lib/rules/no-use-before-define.js +++ b/tools/node_modules/eslint/lib/rules/no-use-before-define.js @@ -157,7 +157,11 @@ module.exports = { } ] } - ] + ], + + messages: { + usedBeforeDefined: "'{{name}}' was used before it was defined." + } }, create(context) { @@ -212,7 +216,7 @@ module.exports = { // Reports. context.report({ node: reference.identifier, - message: "'{{name}}' was used before it was defined.", + messageId: "usedBeforeDefined", data: reference.identifier }); }); diff --git a/tools/node_modules/eslint/lib/rules/no-useless-backreference.js b/tools/node_modules/eslint/lib/rules/no-useless-backreference.js new file mode 100644 index 00000000000000..8a6fbe14daafe6 --- /dev/null +++ b/tools/node_modules/eslint/lib/rules/no-useless-backreference.js @@ -0,0 +1,193 @@ +/** + * @fileoverview Rule to disallow useless backreferences in regular expressions + * @author Milos Djermanovic + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const { CALL, CONSTRUCT, ReferenceTracker, getStringIfConstant } = require("eslint-utils"); +const { RegExpParser, visitRegExpAST } = require("regexpp"); +const lodash = require("lodash"); + +//------------------------------------------------------------------------------ +// Helpers +//------------------------------------------------------------------------------ + +const parser = new RegExpParser(); + +/** + * Finds the path from the given `regexpp` AST node to the root node. + * @param {regexpp.Node} node Node. + * @returns {regexpp.Node[]} Array that starts with the given node and ends with the root node. + */ +function getPathToRoot(node) { + const path = []; + let current = node; + + do { + path.push(current); + current = current.parent; + } while (current); + + return path; +} + +/** + * Determines whether the given `regexpp` AST node is a lookaround node. + * @param {regexpp.Node} node Node. + * @returns {boolean} `true` if it is a lookaround node. + */ +function isLookaround(node) { + return node.type === "Assertion" && + (node.kind === "lookahead" || node.kind === "lookbehind"); +} + +/** + * Determines whether the given `regexpp` AST node is a negative lookaround node. + * @param {regexpp.Node} node Node. + * @returns {boolean} `true` if it is a negative lookaround node. + */ +function isNegativeLookaround(node) { + return isLookaround(node) && node.negate; +} + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +module.exports = { + meta: { + type: "problem", + + docs: { + description: "disallow useless backreferences in regular expressions", + category: "Possible Errors", + recommended: false, + url: "https://eslint.org/docs/rules/no-useless-backreference" + }, + + schema: [], + + messages: { + nested: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}' from within that group.", + forward: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}' which appears later in the pattern.", + backward: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}' which appears before in the same lookbehind.", + disjunctive: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}' which is in another alternative.", + intoNegativeLookaround: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}' which is in a negative lookaround." + } + }, + + create(context) { + + /** + * Checks and reports useless backreferences in the given regular expression. + * @param {ASTNode} node Node that represents regular expression. A regex literal or RegExp constructor call. + * @param {string} pattern Regular expression pattern. + * @param {string} flags Regular expression flags. + * @returns {void} + */ + function checkRegex(node, pattern, flags) { + let regExpAST; + + try { + regExpAST = parser.parsePattern(pattern, 0, pattern.length, flags.includes("u")); + } catch (e) { + + // Ignore regular expressions with syntax errors + return; + } + + visitRegExpAST(regExpAST, { + onBackreferenceEnter(bref) { + const group = bref.resolved, + brefPath = getPathToRoot(bref), + groupPath = getPathToRoot(group); + let messageId = null; + + if (brefPath.includes(group)) { + + // group is bref's ancestor => bref is nested ('nested reference') => group hasn't matched yet when bref starts to match. + messageId = "nested"; + } else { + + // Start from the root to find the lowest common ancestor. + let i = brefPath.length - 1, + j = groupPath.length - 1; + + do { + i--; + j--; + } while (brefPath[i] === groupPath[j]); + + const indexOfLowestCommonAncestor = j + 1, + groupCut = groupPath.slice(0, indexOfLowestCommonAncestor), + commonPath = groupPath.slice(indexOfLowestCommonAncestor), + lowestCommonLookaround = commonPath.find(isLookaround), + isMatchingBackward = lowestCommonLookaround && lowestCommonLookaround.kind === "lookbehind"; + + if (!isMatchingBackward && bref.end <= group.start) { + + // bref is left, group is right ('forward reference') => group hasn't matched yet when bref starts to match. + messageId = "forward"; + } else if (isMatchingBackward && group.end <= bref.start) { + + // the opposite of the previous when the regex is matching backward in a lookbehind context. + messageId = "backward"; + } else if (lodash.last(groupCut).type === "Alternative") { + + // group's and bref's ancestor nodes below the lowest common ancestor are sibling alternatives => they're disjunctive. + messageId = "disjunctive"; + } else if (groupCut.some(isNegativeLookaround)) { + + // group is in a negative lookaround which isn't bref's ancestor => group has already failed when bref starts to match. + messageId = "intoNegativeLookaround"; + } + } + + if (messageId) { + context.report({ + node, + messageId, + data: { + bref: bref.raw, + group: group.raw + } + }); + } + } + }); + } + + return { + "Literal[regex]"(node) { + const { pattern, flags } = node.regex; + + checkRegex(node, pattern, flags); + }, + Program() { + const scope = context.getScope(), + tracker = new ReferenceTracker(scope), + traceMap = { + RegExp: { + [CALL]: true, + [CONSTRUCT]: true + } + }; + + for (const { node } of tracker.iterateGlobalReferences(traceMap)) { + const [patternNode, flagsNode] = node.arguments, + pattern = getStringIfConstant(patternNode, scope), + flags = getStringIfConstant(flagsNode, scope); + + if (typeof pattern === "string") { + checkRegex(node, pattern, flags || ""); + } + } + } + }; + } +}; diff --git a/tools/node_modules/eslint/lib/rules/no-useless-call.js b/tools/node_modules/eslint/lib/rules/no-useless-call.js index 11cf524d124211..afc729d5de0d9b 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-call.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-call.js @@ -58,7 +58,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-useless-call" }, - schema: [] + schema: [], + + messages: { + unnecessaryCall: "Unnecessary '.{{name}}()'." + } }, create(context) { @@ -75,7 +79,7 @@ module.exports = { const thisArg = node.arguments[0]; if (isValidThisArg(expectedThis, thisArg, sourceCode)) { - context.report({ node, message: "unnecessary '.{{name}}()'.", data: { name: node.callee.property.name } }); + context.report({ node, messageId: "unnecessaryCall", data: { name: node.callee.property.name } }); } } }; diff --git a/tools/node_modules/eslint/lib/rules/no-useless-catch.js b/tools/node_modules/eslint/lib/rules/no-useless-catch.js index 37bf453aecd932..f303c272948489 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-catch.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-catch.js @@ -20,7 +20,12 @@ module.exports = { url: "https://eslint.org/docs/rules/no-useless-catch" }, - schema: [] + schema: [], + + messages: { + unnecessaryCatchClause: "Unnecessary catch clause.", + unnecessaryCatch: "Unnecessary try/catch wrapper." + } }, create(context) { @@ -37,12 +42,12 @@ module.exports = { if (node.parent.finalizer) { context.report({ node, - message: "Unnecessary catch clause." + messageId: "unnecessaryCatchClause" }); } else { context.report({ node: node.parent, - message: "Unnecessary try/catch wrapper." + messageId: "unnecessaryCatch" }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-useless-computed-key.js b/tools/node_modules/eslint/lib/rules/no-useless-computed-key.js index b5e53174e42be7..e0505a318efaae 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-computed-key.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-computed-key.js @@ -15,8 +15,6 @@ const astUtils = require("./utils/ast-utils"); // Rule Definition //------------------------------------------------------------------------------ -const MESSAGE_UNNECESSARY_COMPUTED = "Unnecessarily computed property [{{property}}] found."; - module.exports = { meta: { type: "suggestion", @@ -38,7 +36,11 @@ module.exports = { }, additionalProperties: false }], - fixable: "code" + fixable: "code", + + messages: { + unnecessarilyComputedProperty: "Unnecessarily computed property [{{property}}] found." + } }, create(context) { const sourceCode = context.getSourceCode(); @@ -68,17 +70,14 @@ module.exports = { if (key.type === "Literal" && (nodeType === "string" || nodeType === "number") && key.value !== allowedKey) { context.report({ node, - message: MESSAGE_UNNECESSARY_COMPUTED, + messageId: "unnecessarilyComputedProperty", data: { property: sourceCode.getText(key) }, fix(fixer) { - const leftSquareBracket = sourceCode.getFirstToken(node, astUtils.isOpeningBracketToken); - const rightSquareBracket = sourceCode.getFirstTokenBetween(node.key, node.value, astUtils.isClosingBracketToken); - const tokensBetween = sourceCode.getTokensBetween(leftSquareBracket, rightSquareBracket, 1); - - if (tokensBetween.slice(0, -1).some((token, index) => - sourceCode.getText().slice(token.range[1], tokensBetween[index + 1].range[0]).trim())) { + const leftSquareBracket = sourceCode.getTokenBefore(key, astUtils.isOpeningBracketToken); + const rightSquareBracket = sourceCode.getTokenAfter(key, astUtils.isClosingBracketToken); - // If there are comments between the brackets and the property name, don't do a fix. + // If there are comments between the brackets and the property name, don't do a fix. + if (sourceCode.commentsExistBetween(leftSquareBracket, rightSquareBracket)) { return null; } diff --git a/tools/node_modules/eslint/lib/rules/no-useless-concat.js b/tools/node_modules/eslint/lib/rules/no-useless-concat.js index cdaca273eb003f..aa46742abdd5ca 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-concat.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-concat.js @@ -1,5 +1,5 @@ /** - * @fileoverview disallow unncessary concatenation of template strings + * @fileoverview disallow unnecessary concatenation of template strings * @author Henry Zhu */ "use strict"; @@ -75,7 +75,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-useless-concat" }, - schema: [] + schema: [], + + messages: { + unexpectedConcat: "Unexpected string concatenation of literals." + } }, create(context) { @@ -102,7 +106,7 @@ module.exports = { context.report({ node, loc: operatorToken.loc.start, - message: "Unexpected string concatenation of literals." + messageId: "unexpectedConcat" }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-useless-constructor.js b/tools/node_modules/eslint/lib/rules/no-useless-constructor.js index 7cf033805f99d9..4c34aeda715937 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-constructor.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-constructor.js @@ -115,7 +115,7 @@ function isPassingThrough(ctorParams, superArgs) { * Checks whether the constructor body is a redundant super call. * @param {Array} body constructor body content. * @param {Array} ctorParams The params to check against super call. - * @returns {boolean} true if the construtor body is redundant + * @returns {boolean} true if the constructor body is redundant */ function isRedundantSuperCall(body, ctorParams) { return ( @@ -143,7 +143,11 @@ module.exports = { url: "https://eslint.org/docs/rules/no-useless-constructor" }, - schema: [] + schema: [], + + messages: { + noUselessConstructor: "Useless constructor." + } }, create(context) { @@ -165,7 +169,7 @@ module.exports = { if (superClass ? isRedundantSuperCall(body, ctorParams) : (body.length === 0)) { context.report({ node, - message: "Useless constructor." + messageId: "noUselessConstructor" }); } } diff --git a/tools/node_modules/eslint/lib/rules/no-useless-rename.js b/tools/node_modules/eslint/lib/rules/no-useless-rename.js index eb570a3ef5c1d3..fa88f37f50b79c 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-rename.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-rename.js @@ -32,7 +32,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + unnecessarilyRenamed: "{{type}} {{name}} unnecessarily renamed." + } }, create(context) { @@ -59,7 +63,7 @@ module.exports = { return context.report({ node, - message: "{{type}} {{name}} unnecessarily renamed.", + messageId: "unnecessarilyRenamed", data: { name, type diff --git a/tools/node_modules/eslint/lib/rules/no-useless-return.js b/tools/node_modules/eslint/lib/rules/no-useless-return.js index 942d4eede9964e..111cb21015fb81 100644 --- a/tools/node_modules/eslint/lib/rules/no-useless-return.js +++ b/tools/node_modules/eslint/lib/rules/no-useless-return.js @@ -32,7 +32,7 @@ function remove(array, element) { /** * Checks whether it can remove the given return statement or not. * @param {ASTNode} node The return statement node to check. - * @returns {boolean} `true` if the node is removeable. + * @returns {boolean} `true` if the node is removable. */ function isRemovable(node) { return astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type); @@ -73,7 +73,11 @@ module.exports = { }, fixable: "code", - schema: [] + schema: [], + + messages: { + unnecessaryReturn: "Unnecessary return statement." + } }, create(context) { @@ -208,7 +212,7 @@ module.exports = { context.report({ node, loc: node.loc, - message: "Unnecessary return statement.", + messageId: "unnecessaryReturn", fix(fixer) { if (isRemovable(node) && !sourceCode.getCommentsInside(node).length) { diff --git a/tools/node_modules/eslint/lib/rules/no-var.js b/tools/node_modules/eslint/lib/rules/no-var.js index 74203f8bf3bebf..f2cb96b1f708e9 100644 --- a/tools/node_modules/eslint/lib/rules/no-var.js +++ b/tools/node_modules/eslint/lib/rules/no-var.js @@ -191,7 +191,11 @@ module.exports = { }, schema: [], - fixable: "code" + fixable: "code", + + messages: { + unexpectedVar: "Unexpected var, use let or const instead." + } }, create(context) { @@ -307,7 +311,7 @@ module.exports = { function report(node) { context.report({ node, - message: "Unexpected var, use let or const instead.", + messageId: "unexpectedVar", fix(fixer) { const varToken = sourceCode.getFirstToken(node, { filter: t => t.value === "var" }); diff --git a/tools/node_modules/eslint/lib/rules/no-void.js b/tools/node_modules/eslint/lib/rules/no-void.js index d2b5d2f9631dff..99c83785552ab8 100644 --- a/tools/node_modules/eslint/lib/rules/no-void.js +++ b/tools/node_modules/eslint/lib/rules/no-void.js @@ -19,22 +19,46 @@ module.exports = { url: "https://eslint.org/docs/rules/no-void" }, - schema: [] + messages: { + noVoid: "Expected 'undefined' and instead saw 'void'." + }, + + schema: [ + { + type: "object", + properties: { + allowAsStatement: { + type: "boolean", + default: false + } + }, + additionalProperties: false + } + ] }, create(context) { + const allowAsStatement = + context.options[0] && context.options[0].allowAsStatement; //-------------------------------------------------------------------------- // Public //-------------------------------------------------------------------------- return { - UnaryExpression(node) { - if (node.operator === "void") { - context.report({ node, message: "Expected 'undefined' and instead saw 'void'." }); + 'UnaryExpression[operator="void"]'(node) { + if ( + allowAsStatement && + node.parent && + node.parent.type === "ExpressionStatement" + ) { + return; } + context.report({ + node, + messageId: "noVoid" + }); } }; - } }; diff --git a/tools/node_modules/eslint/lib/rules/no-warning-comments.js b/tools/node_modules/eslint/lib/rules/no-warning-comments.js index a400c446767ff7..d70bd5dd5c4002 100644 --- a/tools/node_modules/eslint/lib/rules/no-warning-comments.js +++ b/tools/node_modules/eslint/lib/rules/no-warning-comments.js @@ -39,7 +39,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + unexpectedComment: "Unexpected '{{matchedTerm}}' comment." + } }, create(context) { @@ -140,7 +144,7 @@ module.exports = { matches.forEach(matchedTerm => { context.report({ node, - message: "Unexpected '{{matchedTerm}}' comment.", + messageId: "unexpectedComment", data: { matchedTerm } diff --git a/tools/node_modules/eslint/lib/rules/no-whitespace-before-property.js b/tools/node_modules/eslint/lib/rules/no-whitespace-before-property.js index 9541401a3176b7..ccd0b091b744e3 100644 --- a/tools/node_modules/eslint/lib/rules/no-whitespace-before-property.js +++ b/tools/node_modules/eslint/lib/rules/no-whitespace-before-property.js @@ -26,7 +26,11 @@ module.exports = { }, fixable: "whitespace", - schema: [] + schema: [], + + messages: { + unexpectedWhitespace: "Unexpected whitespace before property {{propName}}." + } }, create(context) { @@ -49,7 +53,7 @@ module.exports = { context.report({ node, - message: "Unexpected whitespace before property {{propName}}.", + messageId: "unexpectedWhitespace", data: { propName: sourceCode.getText(node.property) }, diff --git a/tools/node_modules/eslint/lib/rules/no-with.js b/tools/node_modules/eslint/lib/rules/no-with.js index 5763661584c061..d3e52e02f3d15a 100644 --- a/tools/node_modules/eslint/lib/rules/no-with.js +++ b/tools/node_modules/eslint/lib/rules/no-with.js @@ -20,14 +20,18 @@ module.exports = { url: "https://eslint.org/docs/rules/no-with" }, - schema: [] + schema: [], + + messages: { + unexpectedWith: "Unexpected use of 'with' statement." + } }, create(context) { return { WithStatement(node) { - context.report({ node, message: "Unexpected use of 'with' statement." }); + context.report({ node, messageId: "unexpectedWith" }); } }; diff --git a/tools/node_modules/eslint/lib/rules/nonblock-statement-body-position.js b/tools/node_modules/eslint/lib/rules/nonblock-statement-body-position.js index 01763cea92f381..34e6eeac39de50 100644 --- a/tools/node_modules/eslint/lib/rules/nonblock-statement-body-position.js +++ b/tools/node_modules/eslint/lib/rules/nonblock-statement-body-position.js @@ -40,7 +40,12 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + expectNoLinebreak: "Expected no linebreak before this statement.", + expectLinebreak: "Expected a linebreak before this statement." + } }, create(context) { @@ -79,13 +84,13 @@ module.exports = { if (tokenBefore.loc.end.line === node.loc.start.line && option === "below") { context.report({ node, - message: "Expected a linebreak before this statement.", + messageId: "expectLinebreak", fix: fixer => fixer.insertTextBefore(node, "\n") }); } else if (tokenBefore.loc.end.line !== node.loc.start.line && option === "beside") { context.report({ node, - message: "Expected no linebreak before this statement.", + messageId: "expectNoLinebreak", fix(fixer) { if (sourceCode.getText().slice(tokenBefore.range[1], node.range[0]).trim()) { return null; diff --git a/tools/node_modules/eslint/lib/rules/object-curly-newline.js b/tools/node_modules/eslint/lib/rules/object-curly-newline.js index e870a69a954180..b48b2526a0b2bd 100644 --- a/tools/node_modules/eslint/lib/rules/object-curly-newline.js +++ b/tools/node_modules/eslint/lib/rules/object-curly-newline.js @@ -159,7 +159,14 @@ module.exports = { } ] } - ] + ], + + messages: { + unexpectedLinebreakBeforeClosingBrace: "Unexpected line break before this closing brace.", + unexpectedLinebreakAfterOpeningBrace: "Unexpected line break after this opening brace.", + expectedLinebreakBeforeClosingBrace: "Expected a line break before this closing brace.", + expectedLinebreakAfterOpeningBrace: "Expected a line break after this opening brace." + } }, create(context) { @@ -215,7 +222,7 @@ module.exports = { if (needsLineBreaks) { if (astUtils.isTokenOnSameLine(openBrace, first)) { context.report({ - message: "Expected a line break after this opening brace.", + messageId: "expectedLinebreakAfterOpeningBrace", node, loc: openBrace.loc.start, fix(fixer) { @@ -229,7 +236,7 @@ module.exports = { } if (astUtils.isTokenOnSameLine(last, closeBrace)) { context.report({ - message: "Expected a line break before this closing brace.", + messageId: "expectedLinebreakBeforeClosingBrace", node, loc: closeBrace.loc.start, fix(fixer) { @@ -251,7 +258,7 @@ module.exports = { (consistent && hasLineBreakBetweenOpenBraceAndFirst && !hasLineBreakBetweenCloseBraceAndLast) ) { context.report({ - message: "Unexpected line break after this opening brace.", + messageId: "unexpectedLinebreakAfterOpeningBrace", node, loc: openBrace.loc.start, fix(fixer) { @@ -271,7 +278,7 @@ module.exports = { (consistent && !hasLineBreakBetweenOpenBraceAndFirst && hasLineBreakBetweenCloseBraceAndLast) ) { context.report({ - message: "Unexpected line break before this closing brace.", + messageId: "unexpectedLinebreakBeforeClosingBrace", node, loc: closeBrace.loc.start, fix(fixer) { diff --git a/tools/node_modules/eslint/lib/rules/object-curly-spacing.js b/tools/node_modules/eslint/lib/rules/object-curly-spacing.js index 117a7a35426103..c0044f5033c005 100644 --- a/tools/node_modules/eslint/lib/rules/object-curly-spacing.js +++ b/tools/node_modules/eslint/lib/rules/object-curly-spacing.js @@ -39,7 +39,14 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + requireSpaceBefore: "A space is required before '{{token}}'.", + requireSpaceAfter: "A space is required after '{{token}}'.", + unexpectedSpaceBefore: "There should be no space before '{{token}}'.", + unexpectedSpaceAfter: "There should be no space after '{{token}}'." + } }, create(context) { @@ -79,7 +86,7 @@ module.exports = { context.report({ node, loc: { start: token.loc.end, end: nextToken.loc.start }, - message: "There should be no space after '{{token}}'.", + messageId: "unexpectedSpaceAfter", data: { token: token.value }, @@ -101,7 +108,7 @@ module.exports = { context.report({ node, loc: { start: previousToken.loc.end, end: token.loc.start }, - message: "There should be no space before '{{token}}'.", + messageId: "unexpectedSpaceBefore", data: { token: token.value }, @@ -121,7 +128,7 @@ module.exports = { context.report({ node, loc: token.loc, - message: "A space is required after '{{token}}'.", + messageId: "requireSpaceAfter", data: { token: token.value }, @@ -141,7 +148,7 @@ module.exports = { context.report({ node, loc: token.loc, - message: "A space is required before '{{token}}'.", + messageId: "requireSpaceBefore", data: { token: token.value }, diff --git a/tools/node_modules/eslint/lib/rules/object-property-newline.js b/tools/node_modules/eslint/lib/rules/object-property-newline.js index bf777b5ff65ba2..074bc775ae35a3 100644 --- a/tools/node_modules/eslint/lib/rules/object-property-newline.js +++ b/tools/node_modules/eslint/lib/rules/object-property-newline.js @@ -37,16 +37,21 @@ module.exports = { } ], - fixable: "whitespace" + fixable: "whitespace", + + messages: { + propertiesOnNewlineAll: "Object properties must go on a new line if they aren't all on the same line.", + propertiesOnNewline: "Object properties must go on a new line." + } }, create(context) { const allowSameLine = context.options[0] && ( (context.options[0].allowAllPropertiesOnSameLine || context.options[0].allowMultiplePropertiesPerLine /* Deprecated */) ); - const errorMessage = allowSameLine - ? "Object properties must go on a new line if they aren't all on the same line." - : "Object properties must go on a new line."; + const messageId = allowSameLine + ? "propertiesOnNewlineAll" + : "propertiesOnNewline"; const sourceCode = context.getSourceCode(); @@ -73,7 +78,7 @@ module.exports = { context.report({ node, loc: firstTokenOfCurrentProperty.loc.start, - message: errorMessage, + messageId, fix(fixer) { const comma = sourceCode.getTokenBefore(firstTokenOfCurrentProperty); const rangeAfterComma = [comma.range[1], firstTokenOfCurrentProperty.range[0]]; diff --git a/tools/node_modules/eslint/lib/rules/object-shorthand.js b/tools/node_modules/eslint/lib/rules/object-shorthand.js index d4afd09c5a52c4..3999ff8b99fb29 100644 --- a/tools/node_modules/eslint/lib/rules/object-shorthand.js +++ b/tools/node_modules/eslint/lib/rules/object-shorthand.js @@ -92,6 +92,16 @@ module.exports = { maxItems: 2 } ] + }, + + messages: { + expectedAllPropertiesShorthanded: "Expected shorthand for all properties.", + expectedLiteralMethodLongform: "Expected longform method syntax for string literal keys.", + expectedPropertyShorthand: "Expected property shorthand.", + expectedPropertyLongform: "Expected longform property syntax.", + expectedMethodShorthand: "Expected method shorthand.", + expectedMethodLongform: "Expected longform method syntax.", + unexpectedMix: "Unexpected mix of shorthand and non-shorthand properties." } }, @@ -211,7 +221,7 @@ module.exports = { // We have at least 1 shorthand property if (shorthandProperties.length > 0) { - context.report({ node, message: "Unexpected mix of shorthand and non-shorthand properties." }); + context.report({ node, messageId: "unexpectedMix" }); } else if (checkRedundancy) { /* @@ -221,7 +231,7 @@ module.exports = { const canAlwaysUseShorthand = properties.every(isRedundant); if (canAlwaysUseShorthand) { - context.report({ node, message: "Expected shorthand for all properties." }); + context.report({ node, messageId: "expectedAllPropertiesShorthanded" }); } } } @@ -430,12 +440,12 @@ module.exports = { // Checks for property/method shorthand. if (isConciseProperty) { if (node.method && (APPLY_NEVER || AVOID_QUOTES && isStringLiteral(node.key))) { - const message = APPLY_NEVER ? "Expected longform method syntax." : "Expected longform method syntax for string literal keys."; + const messageId = APPLY_NEVER ? "expectedMethodLongform" : "expectedLiteralMethodLongform"; // { x() {} } should be written as { x: function() {} } context.report({ node, - message, + messageId, fix: fixer => makeFunctionLongform(fixer, node) }); } else if (APPLY_NEVER) { @@ -443,7 +453,7 @@ module.exports = { // { x } should be written as { x: x } context.report({ node, - message: "Expected longform property syntax.", + messageId: "expectedPropertyLongform", fix: fixer => fixer.insertTextAfter(node.key, `: ${node.key.name}`) }); } @@ -464,7 +474,7 @@ module.exports = { ) { context.report({ node, - message: "Expected method shorthand.", + messageId: "expectedMethodShorthand", fix: fixer => makeFunctionShorthand(fixer, node) }); } @@ -473,7 +483,7 @@ module.exports = { // {x: x} should be written as {x} context.report({ node, - message: "Expected property shorthand.", + messageId: "expectedPropertyShorthand", fix(fixer) { return fixer.replaceText(node, node.value.name); } @@ -486,7 +496,7 @@ module.exports = { // {"x": x} should be written as {x} context.report({ node, - message: "Expected property shorthand.", + messageId: "expectedPropertyShorthand", fix(fixer) { return fixer.replaceText(node, node.value.name); } diff --git a/tools/node_modules/eslint/lib/rules/one-var-declaration-per-line.js b/tools/node_modules/eslint/lib/rules/one-var-declaration-per-line.js index b64656eefed0a9..30ca2cf49834fe 100644 --- a/tools/node_modules/eslint/lib/rules/one-var-declaration-per-line.js +++ b/tools/node_modules/eslint/lib/rules/one-var-declaration-per-line.js @@ -25,12 +25,15 @@ module.exports = { } ], - fixable: "whitespace" + fixable: "whitespace", + + messages: { + expectVarOnNewline: "Expected variable declaration to be on a new line." + } }, create(context) { - const ERROR_MESSAGE = "Expected variable declaration to be on a new line."; const always = context.options[0] === "always"; //-------------------------------------------------------------------------- @@ -67,7 +70,7 @@ module.exports = { if (always || prev.init || current.init) { context.report({ node, - message: ERROR_MESSAGE, + messageId: "expectVarOnNewline", loc: current.loc.start, fix: fixer => fixer.insertTextBefore(current, "\n") }); diff --git a/tools/node_modules/eslint/lib/rules/one-var.js b/tools/node_modules/eslint/lib/rules/one-var.js index e79461ce46c5be..c31a0d2b13c187 100644 --- a/tools/node_modules/eslint/lib/rules/one-var.js +++ b/tools/node_modules/eslint/lib/rules/one-var.js @@ -60,7 +60,17 @@ module.exports = { } ] } - ] + ], + + messages: { + combineUninitialized: "Combine this with the previous '{{type}}' statement with uninitialized variables.", + combineInitialized: "Combine this with the previous '{{type}}' statement with initialized variables.", + splitUninitialized: "Split uninitialized '{{type}}' declarations into multiple statements.", + splitInitialized: "Split initialized '{{type}}' declarations into multiple statements.", + splitRequires: "Split requires to be separated into a single block.", + combine: "Combine this with the previous '{{type}}' statement.", + split: "Split '{{type}}' declarations into multiple statements." + } }, create(context) { @@ -361,7 +371,7 @@ module.exports = { if (options.separateRequires && mixedRequires) { context.report({ node, - message: "Split requires to be separated into a single block." + messageId: "splitRequires" }); } } @@ -384,7 +394,7 @@ module.exports = { if (options[type].initialized === MODE_CONSECUTIVE && options[type].uninitialized === MODE_CONSECUTIVE) { context.report({ node, - message: "Combine this with the previous '{{type}}' statement.", + messageId: "combine", data: { type }, @@ -393,7 +403,7 @@ module.exports = { } else if (options[type].initialized === MODE_CONSECUTIVE && declarationCounts.initialized > 0 && previousDeclCounts.initialized > 0) { context.report({ node, - message: "Combine this with the previous '{{type}}' statement with initialized variables.", + messageId: "combineInitialized", data: { type }, @@ -404,7 +414,7 @@ module.exports = { previousDeclCounts.uninitialized > 0) { context.report({ node, - message: "Combine this with the previous '{{type}}' statement with uninitialized variables.", + messageId: "combineUninitialized", data: { type }, @@ -419,7 +429,7 @@ module.exports = { if (options[type].initialized === MODE_ALWAYS && options[type].uninitialized === MODE_ALWAYS) { context.report({ node, - message: "Combine this with the previous '{{type}}' statement.", + messageId: "combine", data: { type }, @@ -429,7 +439,7 @@ module.exports = { if (options[type].initialized === MODE_ALWAYS && declarationCounts.initialized > 0) { context.report({ node, - message: "Combine this with the previous '{{type}}' statement with initialized variables.", + messageId: "combineInitialized", data: { type }, @@ -442,7 +452,7 @@ module.exports = { } context.report({ node, - message: "Combine this with the previous '{{type}}' statement with uninitialized variables.", + messageId: "combineUninitialized", data: { type }, @@ -462,7 +472,7 @@ module.exports = { // both initialized and uninitialized context.report({ node, - message: "Split '{{type}}' declarations into multiple statements.", + messageId: "split", data: { type }, @@ -473,7 +483,7 @@ module.exports = { // initialized context.report({ node, - message: "Split initialized '{{type}}' declarations into multiple statements.", + messageId: "splitInitialized", data: { type }, @@ -484,7 +494,7 @@ module.exports = { // uninitialized context.report({ node, - message: "Split uninitialized '{{type}}' declarations into multiple statements.", + messageId: "splitUninitialized", data: { type }, diff --git a/tools/node_modules/eslint/lib/rules/operator-assignment.js b/tools/node_modules/eslint/lib/rules/operator-assignment.js index b19ba0d02e1a1b..6820793439cb84 100644 --- a/tools/node_modules/eslint/lib/rules/operator-assignment.js +++ b/tools/node_modules/eslint/lib/rules/operator-assignment.js @@ -26,10 +26,10 @@ function isCommutativeOperatorWithShorthand(operator) { } /** - * Checks whether an operator is not commuatative and has an operator assignment + * Checks whether an operator is not commutative and has an operator assignment * shorthand form. * @param {string} operator Operator to check. - * @returns {boolean} True if the operator is not commuatative and has + * @returns {boolean} True if the operator is not commutative and has * a shorthand form. */ function isNonCommutativeOperatorWithShorthand(operator) { @@ -214,12 +214,12 @@ module.exports = { ) { rightText = `${sourceCode.text.slice(operatorToken.range[1], node.right.range[0])}(${sourceCode.getText(node.right)})`; } else { - const firstRightToken = sourceCode.getFirstToken(node.right); + const tokenAfterOperator = sourceCode.getTokenAfter(operatorToken, { includeComments: true }); let rightTextPrefix = ""; if ( - operatorToken.range[1] === firstRightToken.range[0] && - !astUtils.canTokensBeAdjacent(newOperator, firstRightToken) + operatorToken.range[1] === tokenAfterOperator.range[0] && + !astUtils.canTokensBeAdjacent({ type: "Punctuator", value: newOperator }, tokenAfterOperator) ) { rightTextPrefix = " "; // foo+=+bar -> foo= foo+ +bar } diff --git a/tools/node_modules/eslint/lib/rules/operator-linebreak.js b/tools/node_modules/eslint/lib/rules/operator-linebreak.js index bce0ef56a0cc6c..3395feae655f64 100644 --- a/tools/node_modules/eslint/lib/rules/operator-linebreak.js +++ b/tools/node_modules/eslint/lib/rules/operator-linebreak.js @@ -47,7 +47,14 @@ module.exports = { } ], - fixable: "code" + fixable: "code", + + messages: { + operatorAtBeginning: "'{{operator}}' should be placed at the beginning of the line.", + operatorAtEnd: "'{{operator}}' should be placed at the end of the line.", + badLinebreak: "Bad line breaking before and after '{{operator}}'.", + noLinebreak: "There should be no line break before or after '{{operator}}'." + } }, create(context) { @@ -165,11 +172,8 @@ module.exports = { // lone operator context.report({ node, - loc: { - line: operatorToken.loc.end.line, - column: operatorToken.loc.end.column - }, - message: "Bad line breaking before and after '{{operator}}'.", + loc: operatorToken.loc, + messageId: "badLinebreak", data: { operator }, @@ -180,11 +184,8 @@ module.exports = { context.report({ node, - loc: { - line: operatorToken.loc.end.line, - column: operatorToken.loc.end.column - }, - message: "'{{operator}}' should be placed at the beginning of the line.", + loc: operatorToken.loc, + messageId: "operatorAtBeginning", data: { operator }, @@ -195,11 +196,8 @@ module.exports = { context.report({ node, - loc: { - line: operatorToken.loc.end.line, - column: operatorToken.loc.end.column - }, - message: "'{{operator}}' should be placed at the end of the line.", + loc: operatorToken.loc, + messageId: "operatorAtEnd", data: { operator }, @@ -210,11 +208,8 @@ module.exports = { context.report({ node, - loc: { - line: operatorToken.loc.end.line, - column: operatorToken.loc.end.column - }, - message: "There should be no line break before or after '{{operator}}'.", + loc: operatorToken.loc, + messageId: "noLinebreak", data: { operator }, diff --git a/tools/node_modules/eslint/lib/rules/padded-blocks.js b/tools/node_modules/eslint/lib/rules/padded-blocks.js index dafa88115edd78..f58a7535ba86c2 100644 --- a/tools/node_modules/eslint/lib/rules/padded-blocks.js +++ b/tools/node_modules/eslint/lib/rules/padded-blocks.js @@ -60,7 +60,12 @@ module.exports = { } } } - ] + ], + + messages: { + alwaysPadBlock: "Block must be padded by blank lines.", + neverPadBlock: "Block must not be padded by blank lines." + } }, create(context) { @@ -90,9 +95,6 @@ module.exports = { options.allowSingleLineBlocks = exceptOptions.allowSingleLineBlocks === true; } - const ALWAYS_MESSAGE = "Block must be padded by blank lines.", - NEVER_MESSAGE = "Block must not be padded by blank lines."; - const sourceCode = context.getSourceCode(); /** @@ -145,9 +147,9 @@ module.exports = { } /** - * Checks if the given token is preceeded by a blank line. + * Checks if the given token is preceded by a blank line. * @param {Token} token The token to check - * @returns {boolean} Whether or not the token is preceeded by a blank line + * @returns {boolean} Whether or not the token is preceded by a blank line */ function getLastBlockToken(token) { let last = token, @@ -208,7 +210,7 @@ module.exports = { fix(fixer) { return fixer.insertTextAfter(tokenBeforeFirst, "\n"); }, - message: ALWAYS_MESSAGE + messageId: "alwaysPadBlock" }); } if (!blockHasBottomPadding) { @@ -218,7 +220,7 @@ module.exports = { fix(fixer) { return fixer.insertTextBefore(tokenAfterLast, "\n"); }, - message: ALWAYS_MESSAGE + messageId: "alwaysPadBlock" }); } } else { @@ -230,7 +232,7 @@ module.exports = { fix(fixer) { return fixer.replaceTextRange([tokenBeforeFirst.range[1], firstBlockToken.range[0] - firstBlockToken.loc.start.column], "\n"); }, - message: NEVER_MESSAGE + messageId: "neverPadBlock" }); } @@ -239,7 +241,7 @@ module.exports = { context.report({ node, loc: { line: tokenAfterLast.loc.end.line, column: tokenAfterLast.loc.end.column - 1 }, - message: NEVER_MESSAGE, + messageId: "neverPadBlock", fix(fixer) { return fixer.replaceTextRange([lastBlockToken.range[1], tokenAfterLast.range[0] - tokenAfterLast.loc.start.column], "\n"); } diff --git a/tools/node_modules/eslint/lib/rules/padding-line-between-statements.js b/tools/node_modules/eslint/lib/rules/padding-line-between-statements.js index 350a9dbf2aba15..eea19f5ce5811b 100644 --- a/tools/node_modules/eslint/lib/rules/padding-line-between-statements.js +++ b/tools/node_modules/eslint/lib/rules/padding-line-between-statements.js @@ -243,7 +243,7 @@ function verifyForNever(context, _, nextNode, paddingLines) { context.report({ node: nextNode, - message: "Unexpected blank line before this statement.", + messageId: "unexpectedBlankLine", fix(fixer) { if (paddingLines.length >= 2) { return null; @@ -282,7 +282,7 @@ function verifyForAlways(context, prevNode, nextNode, paddingLines) { context.report({ node: nextNode, - message: "Expected blank line before this statement.", + messageId: "expectedBlankLine", fix(fixer) { const sourceCode = context.getSourceCode(); let prevToken = getActualLastToken(sourceCode, prevNode); @@ -468,6 +468,11 @@ module.exports = { required: ["blankLine", "prev", "next"] }, additionalItems: false + }, + + messages: { + unexpectedBlankLine: "Unexpected blank line before this statement.", + expectedBlankLine: "Expected blank line before this statement." } }, diff --git a/tools/node_modules/eslint/lib/rules/prefer-arrow-callback.js b/tools/node_modules/eslint/lib/rules/prefer-arrow-callback.js index 08126e5b1a5459..d4e0251940c503 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-arrow-callback.js +++ b/tools/node_modules/eslint/lib/rules/prefer-arrow-callback.js @@ -56,7 +56,7 @@ function getVariableOfArguments(scope) { } /** - * Checkes whether or not a given node is a callback. + * Checks whether or not a given node is a callback. * @param {ASTNode} node A node to check. * @returns {Object} * {boolean} retv.isCallback - `true` if the node is a callback. @@ -158,7 +158,11 @@ module.exports = { } ], - fixable: "code" + fixable: "code", + + messages: { + preferArrowCallback: "Unexpected function expression." + } }, create(context) { @@ -267,7 +271,7 @@ module.exports = { ) { context.report({ node, - message: "Unexpected function expression.", + messageId: "preferArrowCallback", fix(fixer) { if ((!callbackInfo.isLexicalThis && scopeInfo.this) || hasDuplicateParams(node.params)) { diff --git a/tools/node_modules/eslint/lib/rules/prefer-destructuring.js b/tools/node_modules/eslint/lib/rules/prefer-destructuring.js index eff37294a9b6ef..1a51956dde53ff 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-destructuring.js +++ b/tools/node_modules/eslint/lib/rules/prefer-destructuring.js @@ -82,7 +82,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + preferDestructuring: "Use {{type}} destructuring." + } }, create(context) { @@ -137,7 +141,7 @@ module.exports = { function report(reportNode, type, fix) { context.report({ node: reportNode, - message: "Use {{type}} destructuring.", + messageId: "preferDestructuring", data: { type }, fix }); diff --git a/tools/node_modules/eslint/lib/rules/prefer-numeric-literals.js b/tools/node_modules/eslint/lib/rules/prefer-numeric-literals.js index c352d88dc07ca2..2a4fb5d954aad5 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-numeric-literals.js +++ b/tools/node_modules/eslint/lib/rules/prefer-numeric-literals.js @@ -79,13 +79,13 @@ module.exports = { "CallExpression[arguments.length=2]"(node) { const [strNode, radixNode] = node.arguments, - str = strNode.value, + str = astUtils.getStaticStringValue(strNode), radix = radixNode.value; if ( - strNode.type === "Literal" && + str !== null && + astUtils.isStringLiteral(strNode) && radixNode.type === "Literal" && - typeof str === "string" && typeof radix === "number" && radixMap.has(radix) && isParseInt(node.callee) diff --git a/tools/node_modules/eslint/lib/rules/prefer-object-spread.js b/tools/node_modules/eslint/lib/rules/prefer-object-spread.js index bbcd88bee3d071..ab252c73ae3aaf 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-object-spread.js +++ b/tools/node_modules/eslint/lib/rules/prefer-object-spread.js @@ -25,6 +25,36 @@ function hasArraySpread(node) { return node.arguments.some(arg => arg.type === "SpreadElement"); } +/** + * Determines whether the given node is an accessor property (getter/setter). + * @param {ASTNode} node Node to check. + * @returns {boolean} `true` if the node is a getter or a setter. + */ +function isAccessorProperty(node) { + return node.type === "Property" && + (node.kind === "get" || node.kind === "set"); +} + +/** + * Determines whether the given object expression node has accessor properties (getters/setters). + * @param {ASTNode} node `ObjectExpression` node to check. + * @returns {boolean} `true` if the node has at least one getter/setter. + */ +function hasAccessors(node) { + return node.properties.some(isAccessorProperty); +} + +/** + * Determines whether the given call expression node has object expression arguments with accessor properties (getters/setters). + * @param {ASTNode} node `CallExpression` node to check. + * @returns {boolean} `true` if the node has at least one argument that is an object expression with at least one getter/setter. + */ +function hasArgumentsWithAccessors(node) { + return node.arguments + .filter(arg => arg.type === "ObjectExpression") + .some(hasAccessors); +} + /** * Helper that checks if the node needs parentheses to be valid JS. * The default is to wrap the node in parentheses to avoid parsing errors. @@ -68,7 +98,7 @@ function argNeedsParens(node, sourceCode) { /** * Get the parenthesis tokens of a given ObjectExpression node. - * This incldues the braces of the object literal and enclosing parentheses. + * This includes the braces of the object literal and enclosing parentheses. * @param {ASTNode} node The node to get. * @param {Token} leftArgumentListParen The opening paren token of the argument list. * @param {SourceCode} sourceCode The source code object to get tokens. @@ -151,8 +181,8 @@ function defineFixer(node, sourceCode) { const leftParen = sourceCode.getTokenAfter(node.callee, isOpeningParenToken); const rightParen = sourceCode.getLastToken(node); - // Remove the callee `Object.assign` - yield fixer.remove(node.callee); + // Remove everything before the opening paren: callee `Object.assign`, type arguments, and whitespace between the callee and the paren. + yield fixer.removeRange([node.range[0], leftParen.range[0]]); // Replace the parens of argument list to braces. if (needsParens(node, sourceCode)) { @@ -249,7 +279,11 @@ module.exports = { if ( node.arguments.length >= 1 && node.arguments[0].type === "ObjectExpression" && - !hasArraySpread(node) + !hasArraySpread(node) && + !( + node.arguments.length > 1 && + hasArgumentsWithAccessors(node) + ) ) { const messageId = node.arguments.length === 1 ? "useLiteralMessage" diff --git a/tools/node_modules/eslint/lib/rules/prefer-promise-reject-errors.js b/tools/node_modules/eslint/lib/rules/prefer-promise-reject-errors.js index e142a96b55c78f..56911b67adcc99 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-promise-reject-errors.js +++ b/tools/node_modules/eslint/lib/rules/prefer-promise-reject-errors.js @@ -31,7 +31,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + rejectAnError: "Expected the Promise rejection reason to be an Error." + } }, create(context) { @@ -58,7 +62,7 @@ module.exports = { ) { context.report({ node: callExpression, - message: "Expected the Promise rejection reason to be an Error." + messageId: "rejectAnError" }); } } diff --git a/tools/node_modules/eslint/lib/rules/prefer-reflect.js b/tools/node_modules/eslint/lib/rules/prefer-reflect.js index 796bbdf05fd446..fb2de923bea379 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-reflect.js +++ b/tools/node_modules/eslint/lib/rules/prefer-reflect.js @@ -49,7 +49,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + preferReflect: "Avoid using {{existing}}, instead use {{substitute}}." + } }, create(context) { @@ -65,7 +69,7 @@ module.exports = { preventExtensions: "Object.preventExtensions" }; - const reflectSubsitutes = { + const reflectSubstitutes = { apply: "Reflect.apply", call: "Reflect.apply", defineProperty: "Reflect.defineProperty", @@ -89,7 +93,7 @@ module.exports = { function report(node, existing, substitute) { context.report({ node, - message: "Avoid using {{existing}}, instead use {{substitute}}.", + messageId: "preferReflect", data: { existing, substitute @@ -101,11 +105,11 @@ module.exports = { CallExpression(node) { const methodName = (node.callee.property || {}).name; const isReflectCall = (node.callee.object || {}).name === "Reflect"; - const hasReflectSubsitute = Object.prototype.hasOwnProperty.call(reflectSubsitutes, methodName); + const hasReflectSubsitute = Object.prototype.hasOwnProperty.call(reflectSubstitutes, methodName); const userConfiguredException = exceptions.indexOf(methodName) !== -1; if (hasReflectSubsitute && !isReflectCall && !userConfiguredException) { - report(node, existingNames[methodName], reflectSubsitutes[methodName]); + report(node, existingNames[methodName], reflectSubstitutes[methodName]); } }, UnaryExpression(node) { diff --git a/tools/node_modules/eslint/lib/rules/prefer-rest-params.js b/tools/node_modules/eslint/lib/rules/prefer-rest-params.js index 3a28584f6bc126..3ecea732af8b94 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-rest-params.js +++ b/tools/node_modules/eslint/lib/rules/prefer-rest-params.js @@ -70,7 +70,11 @@ module.exports = { url: "https://eslint.org/docs/rules/prefer-rest-params" }, - schema: [] + schema: [], + + messages: { + preferRestParams: "Use the rest parameters instead of 'arguments'." + } }, create(context) { @@ -84,7 +88,7 @@ module.exports = { context.report({ node: reference.identifier, loc: reference.identifier.loc, - message: "Use the rest parameters instead of 'arguments'." + messageId: "preferRestParams" }); } diff --git a/tools/node_modules/eslint/lib/rules/prefer-spread.js b/tools/node_modules/eslint/lib/rules/prefer-spread.js index 14c05bd97103de..bcb0dc0dd4c1a9 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-spread.js +++ b/tools/node_modules/eslint/lib/rules/prefer-spread.js @@ -59,7 +59,11 @@ module.exports = { }, schema: [], - fixable: null + fixable: null, + + messages: { + preferSpread: "Use the spread operator instead of '.apply()'." + } }, create(context) { @@ -78,7 +82,7 @@ module.exports = { if (isValidThisArg(expectedThis, thisArg, sourceCode)) { context.report({ node, - message: "Use the spread operator instead of '.apply()'." + messageId: "preferSpread" }); } } diff --git a/tools/node_modules/eslint/lib/rules/prefer-template.js b/tools/node_modules/eslint/lib/rules/prefer-template.js index fa6e58d9721e12..e8f980ebd38c6f 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-template.js +++ b/tools/node_modules/eslint/lib/rules/prefer-template.js @@ -142,7 +142,11 @@ module.exports = { }, schema: [], - fixable: "code" + fixable: "code", + + messages: { + unexpectedStringConcatenation: "Unexpected string concatenation." + } }, create(context) { @@ -261,7 +265,7 @@ module.exports = { if (hasNonStringLiteral(topBinaryExpr)) { context.report({ node: topBinaryExpr, - message: "Unexpected string concatenation.", + messageId: "unexpectedStringConcatenation", fix: fixer => fixNonStringBinaryExpression(fixer, node) }); } diff --git a/tools/node_modules/eslint/lib/rules/quote-props.js b/tools/node_modules/eslint/lib/rules/quote-props.js index ab09b8fa938e63..a2a4e1d47923ff 100644 --- a/tools/node_modules/eslint/lib/rules/quote-props.js +++ b/tools/node_modules/eslint/lib/rules/quote-props.js @@ -8,8 +8,9 @@ // Requirements //------------------------------------------------------------------------------ -const espree = require("espree"), - keywords = require("./utils/keywords"); +const espree = require("espree"); +const astUtils = require("./utils/ast-utils"); +const keywords = require("./utils/keywords"); //------------------------------------------------------------------------------ // Rule Definition @@ -66,7 +67,16 @@ module.exports = { ] }, - fixable: "code" + fixable: "code", + messages: { + requireQuotesDueToReservedWord: "Properties should be quoted as '{{property}}' is a reserved word.", + inconsistentlyQuotedProperty: "Inconsistently quoted property '{{key}}' found.", + unnecessarilyQuotedProperty: "Unnecessarily quoted property '{{property}}' found.", + unquotedReservedProperty: "Unquoted reserved word '{{property}}' used as key.", + unquotedNumericProperty: "Unquoted number literal '{{property}}' used as key.", + unquotedPropertyFound: "Unquoted property '{{property}}' found.", + redundantQuoting: "Properties shouldn't be quoted as all quotes are redundant." + } }, create(context) { @@ -76,10 +86,6 @@ module.exports = { CHECK_UNNECESSARY = !context.options[1] || context.options[1].unnecessary !== false, NUMBERS = context.options[1] && context.options[1].numbers, - MESSAGE_UNNECESSARY = "Unnecessarily quoted property '{{property}}' found.", - MESSAGE_UNQUOTED = "Unquoted property '{{property}}' found.", - MESSAGE_NUMERIC = "Unquoted number literal '{{property}}' used as key.", - MESSAGE_RESERVED = "Unquoted reserved word '{{property}}' used as key.", sourceCode = context.getSourceCode(); @@ -165,7 +171,7 @@ module.exports = { if (CHECK_UNNECESSARY && areQuotesRedundant(key.value, tokens, NUMBERS)) { context.report({ node, - message: MESSAGE_UNNECESSARY, + messageId: "unnecessarilyQuotedProperty", data: { property: key.value }, fix: fixer => fixer.replaceText(key, getUnquotedKey(key)) }); @@ -173,14 +179,14 @@ module.exports = { } else if (KEYWORDS && key.type === "Identifier" && isKeyword(key.name)) { context.report({ node, - message: MESSAGE_RESERVED, + messageId: "unquotedReservedProperty", data: { property: key.name }, fix: fixer => fixer.replaceText(key, getQuotedKey(key)) }); - } else if (NUMBERS && key.type === "Literal" && typeof key.value === "number") { + } else if (NUMBERS && key.type === "Literal" && astUtils.isNumericLiteral(key)) { context.report({ node, - message: MESSAGE_NUMERIC, + messageId: "unquotedNumericProperty", data: { property: key.value }, fix: fixer => fixer.replaceText(key, getQuotedKey(key)) }); @@ -198,7 +204,7 @@ module.exports = { if (!node.method && !node.computed && !node.shorthand && !(key.type === "Literal" && typeof key.value === "string")) { context.report({ node, - message: MESSAGE_UNQUOTED, + messageId: "unquotedPropertyFound", data: { property: key.name || key.value }, fix: fixer => fixer.replaceText(key, getQuotedKey(key)) }); @@ -253,7 +259,7 @@ module.exports = { quotedProps.forEach(property => { context.report({ node: property, - message: "Properties shouldn't be quoted as all quotes are redundant.", + messageId: "redundantQuoting", fix: fixer => fixer.replaceText(property.key, getUnquotedKey(property.key)) }); }); @@ -261,7 +267,7 @@ module.exports = { unquotedProps.forEach(property => { context.report({ node: property, - message: "Properties should be quoted as '{{property}}' is a reserved word.", + messageId: "requireQuotesDueToReservedWord", data: { property: keywordKeyName }, fix: fixer => fixer.replaceText(property.key, getQuotedKey(property.key)) }); @@ -270,7 +276,7 @@ module.exports = { unquotedProps.forEach(property => { context.report({ node: property, - message: "Inconsistently quoted property '{{key}}' found.", + messageId: "inconsistentlyQuotedProperty", data: { key: property.key.name || property.key.value }, fix: fixer => fixer.replaceText(property.key, getQuotedKey(property.key)) }); diff --git a/tools/node_modules/eslint/lib/rules/quotes.js b/tools/node_modules/eslint/lib/rules/quotes.js index f78d1129425633..d1f4443b9033c9 100644 --- a/tools/node_modules/eslint/lib/rules/quotes.js +++ b/tools/node_modules/eslint/lib/rules/quotes.js @@ -110,7 +110,11 @@ module.exports = { } ] } - ] + ], + + messages: { + wrongQuotes: "Strings must use {{description}}." + } }, create(context) { @@ -273,7 +277,7 @@ module.exports = { if (!isValid) { context.report({ node, - message: "Strings must use {{description}}.", + messageId: "wrongQuotes", data: { description: settings.description }, @@ -304,7 +308,7 @@ module.exports = { context.report({ node, - message: "Strings must use {{description}}.", + messageId: "wrongQuotes", data: { description: settings.description }, diff --git a/tools/node_modules/eslint/lib/rules/radix.js b/tools/node_modules/eslint/lib/rules/radix.js index ed3c5cb66b8cdc..3903cb2a6a2b01 100644 --- a/tools/node_modules/eslint/lib/rules/radix.js +++ b/tools/node_modules/eslint/lib/rules/radix.js @@ -18,6 +18,8 @@ const astUtils = require("./utils/ast-utils"); const MODE_ALWAYS = "always", MODE_AS_NEEDED = "as-needed"; +const validRadixValues = new Set(Array.from({ length: 37 - 2 }, (_, index) => index + 2)); + /** * Checks whether a given variable is shadowed or not. * @param {eslint-scope.Variable} variable A variable to check. @@ -47,14 +49,14 @@ function isParseIntMethod(node) { * * The following values are invalid. * - * - A literal except numbers. + * - A literal except integers between 2 and 36. * - undefined. * @param {ASTNode} radix A node of radix to check. * @returns {boolean} `true` if the node is valid. */ function isValidRadix(radix) { return !( - (radix.type === "Literal" && typeof radix.value !== "number") || + (radix.type === "Literal" && !validRadixValues.has(radix.value)) || (radix.type === "Identifier" && radix.name === "undefined") ); } @@ -87,7 +89,14 @@ module.exports = { { enum: ["always", "as-needed"] } - ] + ], + + messages: { + missingParameters: "Missing parameters.", + redundantRadix: "Redundant radix parameter.", + missingRadix: "Missing radix parameter.", + invalidRadix: "Invalid radix parameter, must be an integer between 2 and 36." + } }, create(context) { @@ -106,7 +115,7 @@ module.exports = { case 0: context.report({ node, - message: "Missing parameters." + messageId: "missingParameters" }); break; @@ -114,7 +123,7 @@ module.exports = { if (mode === MODE_ALWAYS) { context.report({ node, - message: "Missing radix parameter." + messageId: "missingRadix" }); } break; @@ -123,12 +132,12 @@ module.exports = { if (mode === MODE_AS_NEEDED && isDefaultRadix(args[1])) { context.report({ node, - message: "Redundant radix parameter." + messageId: "redundantRadix" }); } else if (!isValidRadix(args[1])) { context.report({ node, - message: "Invalid radix parameter." + messageId: "invalidRadix" }); } break; @@ -142,7 +151,7 @@ module.exports = { // Check `parseInt()` variable = astUtils.getVariableByName(scope, "parseInt"); - if (!isShadowed(variable)) { + if (variable && !isShadowed(variable)) { variable.references.forEach(reference => { const node = reference.identifier; @@ -154,7 +163,7 @@ module.exports = { // Check `Number.parseInt()` variable = astUtils.getVariableByName(scope, "Number"); - if (!isShadowed(variable)) { + if (variable && !isShadowed(variable)) { variable.references.forEach(reference => { const node = reference.identifier.parent; diff --git a/tools/node_modules/eslint/lib/rules/require-atomic-updates.js b/tools/node_modules/eslint/lib/rules/require-atomic-updates.js index bdd6d81ebc4758..4f6acceab804d1 100644 --- a/tools/node_modules/eslint/lib/rules/require-atomic-updates.js +++ b/tools/node_modules/eslint/lib/rules/require-atomic-updates.js @@ -223,7 +223,7 @@ module.exports = { /* * Register the variable to verify after ESLint traversed the `writeExpr` node - * if this reference is an assignment to a variable which is referred from other clausure. + * if this reference is an assignment to a variable which is referred from other closure. */ if (writeExpr && writeExpr.parent.right === writeExpr && // ← exclude variable declarations. diff --git a/tools/node_modules/eslint/lib/rules/require-await.js b/tools/node_modules/eslint/lib/rules/require-await.js index 22c111b6dc852e..9b5acc78c814ea 100644 --- a/tools/node_modules/eslint/lib/rules/require-await.js +++ b/tools/node_modules/eslint/lib/rules/require-await.js @@ -39,7 +39,11 @@ module.exports = { url: "https://eslint.org/docs/rules/require-await" }, - schema: [] + schema: [], + + messages: { + missingAwait: "{{name}} has no 'await' expression." + } }, create(context) { @@ -64,11 +68,11 @@ module.exports = { * @returns {void} */ function exitFunction(node) { - if (node.async && !scopeInfo.hasAwait && !astUtils.isEmptyFunction(node)) { + if (!node.generator && node.async && !scopeInfo.hasAwait && !astUtils.isEmptyFunction(node)) { context.report({ node, loc: astUtils.getFunctionHeadLoc(node, sourceCode), - message: "{{name}} has no 'await' expression.", + messageId: "missingAwait", data: { name: capitalizeFirstLetter( astUtils.getFunctionNameWithKind(node) diff --git a/tools/node_modules/eslint/lib/rules/require-jsdoc.js b/tools/node_modules/eslint/lib/rules/require-jsdoc.js index 416a22ce6c4375..e581b2bee4646a 100644 --- a/tools/node_modules/eslint/lib/rules/require-jsdoc.js +++ b/tools/node_modules/eslint/lib/rules/require-jsdoc.js @@ -52,7 +52,11 @@ module.exports = { ], deprecated: true, - replacedBy: [] + replacedBy: [], + + messages: { + missingJSDocComment: "Missing JSDoc comment." + } }, create(context) { @@ -72,7 +76,7 @@ module.exports = { * @returns {void} */ function report(node) { - context.report({ node, message: "Missing JSDoc comment." }); + context.report({ node, messageId: "missingJSDocComment" }); } /** diff --git a/tools/node_modules/eslint/lib/rules/require-yield.js b/tools/node_modules/eslint/lib/rules/require-yield.js index dbfd759948af78..af2344dfa6b8ff 100644 --- a/tools/node_modules/eslint/lib/rules/require-yield.js +++ b/tools/node_modules/eslint/lib/rules/require-yield.js @@ -20,7 +20,11 @@ module.exports = { url: "https://eslint.org/docs/rules/require-yield" }, - schema: [] + schema: [], + + messages: { + missingYield: "This generator function does not have 'yield'." + } }, create(context) { @@ -51,7 +55,7 @@ module.exports = { const countYield = stack.pop(); if (countYield === 0 && node.body.body.length > 0) { - context.report({ node, message: "This generator function does not have 'yield'." }); + context.report({ node, messageId: "missingYield" }); } } diff --git a/tools/node_modules/eslint/lib/rules/rest-spread-spacing.js b/tools/node_modules/eslint/lib/rules/rest-spread-spacing.js index cd740fd3a99057..4bb5f787c6c568 100644 --- a/tools/node_modules/eslint/lib/rules/rest-spread-spacing.js +++ b/tools/node_modules/eslint/lib/rules/rest-spread-spacing.js @@ -26,7 +26,12 @@ module.exports = { { enum: ["always", "never"] } - ] + ], + + messages: { + unexpectedWhitespace: "Unexpected whitespace after {{type}} operator.", + expectedWhitespace: "Expected whitespace after {{type}} operator." + } }, create(context) { @@ -78,7 +83,7 @@ module.exports = { line: operator.loc.end.line, column: operator.loc.end.column }, - message: "Expected whitespace after {{type}} operator.", + messageId: "expectedWhitespace", data: { type }, @@ -93,7 +98,7 @@ module.exports = { line: operator.loc.end.line, column: operator.loc.end.column }, - message: "Unexpected whitespace after {{type}} operator.", + messageId: "unexpectedWhitespace", data: { type }, diff --git a/tools/node_modules/eslint/lib/rules/semi-spacing.js b/tools/node_modules/eslint/lib/rules/semi-spacing.js index 083dc26199f7bd..92948533d2789e 100644 --- a/tools/node_modules/eslint/lib/rules/semi-spacing.js +++ b/tools/node_modules/eslint/lib/rules/semi-spacing.js @@ -39,7 +39,14 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + unexpectedWhitespaceBefore: "Unexpected whitespace before semicolon.", + unexpectedWhitespaceAfter: "Unexpected whitespace after semicolon.", + missingWhitespaceBefore: "Missing whitespace before semicolon.", + missingWhitespaceAfter: "Missing whitespace after semicolon." + } }, create(context) { @@ -124,7 +131,7 @@ module.exports = { context.report({ node, loc: location, - message: "Unexpected whitespace before semicolon.", + messageId: "unexpectedWhitespaceBefore", fix(fixer) { const tokenBefore = sourceCode.getTokenBefore(token); @@ -137,7 +144,7 @@ module.exports = { context.report({ node, loc: location, - message: "Missing whitespace before semicolon.", + messageId: "missingWhitespaceBefore", fix(fixer) { return fixer.insertTextBefore(token, " "); } @@ -151,7 +158,7 @@ module.exports = { context.report({ node, loc: location, - message: "Unexpected whitespace after semicolon.", + messageId: "unexpectedWhitespaceAfter", fix(fixer) { const tokenAfter = sourceCode.getTokenAfter(token); @@ -164,7 +171,7 @@ module.exports = { context.report({ node, loc: location, - message: "Missing whitespace after semicolon.", + messageId: "missingWhitespaceAfter", fix(fixer) { return fixer.insertTextAfter(token, " "); } diff --git a/tools/node_modules/eslint/lib/rules/semi-style.js b/tools/node_modules/eslint/lib/rules/semi-style.js index da3c4a38742b88..0c9bec4c85ede8 100644 --- a/tools/node_modules/eslint/lib/rules/semi-style.js +++ b/tools/node_modules/eslint/lib/rules/semi-style.js @@ -75,7 +75,11 @@ module.exports = { }, schema: [{ enum: ["last", "first"] }], - fixable: "whitespace" + fixable: "whitespace", + + messages: { + expectedSemiColon: "Expected this semicolon to be at {{pos}}." + } }, create(context) { @@ -97,7 +101,7 @@ module.exports = { if ((expected === "last" && !prevIsSameLine) || (expected === "first" && !nextIsSameLine)) { context.report({ loc: semiToken.loc, - message: "Expected this semicolon to be at {{pos}}.", + messageId: "expectedSemiColon", data: { pos: (expected === "last") ? "the end of the previous line" diff --git a/tools/node_modules/eslint/lib/rules/semi.js b/tools/node_modules/eslint/lib/rules/semi.js index 22e299efe72e49..d2f0670427b3ab 100644 --- a/tools/node_modules/eslint/lib/rules/semi.js +++ b/tools/node_modules/eslint/lib/rules/semi.js @@ -67,6 +67,11 @@ module.exports = { maxItems: 2 } ] + }, + + messages: { + missingSemi: "Missing semicolon.", + extraSemi: "Extra semicolon." } }, @@ -91,12 +96,12 @@ module.exports = { */ function report(node, missing) { const lastToken = sourceCode.getLastToken(node); - let message, + let messageId, fix, loc; if (!missing) { - message = "Missing semicolon."; + messageId = "missingSemi"; loc = { start: lastToken.loc.end, end: astUtils.getNextLocation(sourceCode, lastToken.loc.end) @@ -105,7 +110,7 @@ module.exports = { return fixer.insertTextAfter(lastToken, ";"); }; } else { - message = "Extra semicolon."; + messageId = "extraSemi"; loc = lastToken.loc; fix = function(fixer) { @@ -123,14 +128,14 @@ module.exports = { context.report({ node, loc, - message, + messageId, fix }); } /** - * Check whether a given semicolon token is redandant. + * Check whether a given semicolon token is redundant. * @param {Token} semiToken A semicolon token to check. * @returns {boolean} `true` if the next token is `;` or `}`. */ diff --git a/tools/node_modules/eslint/lib/rules/sort-imports.js b/tools/node_modules/eslint/lib/rules/sort-imports.js index 3b7f1d010348ad..65ad9a18a93112 100644 --- a/tools/node_modules/eslint/lib/rules/sort-imports.js +++ b/tools/node_modules/eslint/lib/rules/sort-imports.js @@ -50,7 +50,13 @@ module.exports = { } ], - fixable: "code" + fixable: "code", + + messages: { + sortImportsAlphabetically: "Imports should be sorted alphabetically.", + sortMembersAlphabetically: "Member '{{memberName}}' of the import declaration should be sorted alphabetically.", + unexpectedSyntaxOrder: "Expected '{{syntaxA}}' syntax before '{{syntaxB}}' syntax." + } }, create(context) { @@ -132,7 +138,7 @@ module.exports = { if (currentMemberSyntaxGroupIndex < previousMemberSyntaxGroupIndex) { context.report({ node, - message: "Expected '{{syntaxA}}' syntax before '{{syntaxB}}' syntax.", + messageId: "unexpectedSyntaxOrder", data: { syntaxA: memberSyntaxSortOrder[currentMemberSyntaxGroupIndex], syntaxB: memberSyntaxSortOrder[previousMemberSyntaxGroupIndex] @@ -146,7 +152,7 @@ module.exports = { ) { context.report({ node, - message: "Imports should be sorted alphabetically." + messageId: "sortImportsAlphabetically" }); } } @@ -163,7 +169,7 @@ module.exports = { if (firstUnsortedIndex !== -1) { context.report({ node: importSpecifiers[firstUnsortedIndex], - message: "Member '{{memberName}}' of the import declaration should be sorted alphabetically.", + messageId: "sortMembersAlphabetically", data: { memberName: importSpecifiers[firstUnsortedIndex].local.name }, fix(fixer) { if (importSpecifiers.some(specifier => diff --git a/tools/node_modules/eslint/lib/rules/sort-keys.js b/tools/node_modules/eslint/lib/rules/sort-keys.js index a5ce445f71ae93..8a95ee25d61948 100644 --- a/tools/node_modules/eslint/lib/rules/sort-keys.js +++ b/tools/node_modules/eslint/lib/rules/sort-keys.js @@ -41,7 +41,7 @@ function getPropertyName(node) { * Functions which check that the given 2 names are in specific order. * * Postfix `I` is meant insensitive. - * Postfix `N` is meant natual. + * Postfix `N` is meant natural. * @private */ const isValidOrders = { @@ -109,7 +109,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + sortKeys: "Expected object keys to be in {{natural}}{{insensitive}}{{order}}ending order. '{{thisName}}' should be before '{{prevName}}'." + } }, create(context) { @@ -118,10 +122,10 @@ module.exports = { const order = context.options[0] || "asc"; const options = context.options[1]; const insensitive = options && options.caseSensitive === false; - const natual = options && options.natural; + const natural = options && options.natural; const minKeys = options && options.minKeys; const isValidOrder = isValidOrders[ - order + (insensitive ? "I" : "") + (natual ? "N" : "") + order + (insensitive ? "I" : "") + (natural ? "N" : "") ]; // The stack to save the previous property's name for each object literals. @@ -167,13 +171,13 @@ module.exports = { context.report({ node, loc: node.key.loc, - message: "Expected object keys to be in {{natual}}{{insensitive}}{{order}}ending order. '{{thisName}}' should be before '{{prevName}}'.", + messageId: "sortKeys", data: { thisName, prevName, order, insensitive: insensitive ? "insensitive " : "", - natual: natual ? "natural " : "" + natural: natural ? "natural " : "" } }); } diff --git a/tools/node_modules/eslint/lib/rules/sort-vars.js b/tools/node_modules/eslint/lib/rules/sort-vars.js index e85c6534e3a189..7add2cf74b2940 100644 --- a/tools/node_modules/eslint/lib/rules/sort-vars.js +++ b/tools/node_modules/eslint/lib/rules/sort-vars.js @@ -33,7 +33,11 @@ module.exports = { } ], - fixable: "code" + fixable: "code", + + messages: { + sortVars: "Variables within the same declaration block should be sorted alphabetically." + } }, create(context) { @@ -56,7 +60,7 @@ module.exports = { if (currentVariableName < lastVariableName) { context.report({ node: decl, - message: "Variables within the same declaration block should be sorted alphabetically.", + messageId: "sortVars", fix(fixer) { if (unfixable || fixed) { return null; diff --git a/tools/node_modules/eslint/lib/rules/space-before-blocks.js b/tools/node_modules/eslint/lib/rules/space-before-blocks.js index 038e88db5215f5..9b56481bf355fb 100644 --- a/tools/node_modules/eslint/lib/rules/space-before-blocks.js +++ b/tools/node_modules/eslint/lib/rules/space-before-blocks.js @@ -47,7 +47,12 @@ module.exports = { } ] } - ] + ], + + messages: { + unexpectedSpace: "Unexpected space before opening brace.", + missingSpace: "Missing space before opening brace." + } }, create(context) { @@ -114,7 +119,7 @@ module.exports = { if (requireSpace && !hasSpace) { context.report({ node, - message: "Missing space before opening brace.", + messageId: "missingSpace", fix(fixer) { return fixer.insertTextBefore(node, " "); } @@ -122,7 +127,7 @@ module.exports = { } else if (requireNoSpace && hasSpace) { context.report({ node, - message: "Unexpected space before opening brace.", + messageId: "unexpectedSpace", fix(fixer) { return fixer.removeRange([precedingToken.range[1], node.range[0]]); } diff --git a/tools/node_modules/eslint/lib/rules/space-before-function-paren.js b/tools/node_modules/eslint/lib/rules/space-before-function-paren.js index 3a6d430f362051..af609c2e7c72fa 100644 --- a/tools/node_modules/eslint/lib/rules/space-before-function-paren.js +++ b/tools/node_modules/eslint/lib/rules/space-before-function-paren.js @@ -50,7 +50,12 @@ module.exports = { } ] } - ] + ], + + messages: { + unexpectedSpace: "Unexpected space before function parentheses.", + missingSpace: "Missing space before function parentheses." + } }, create(context) { @@ -123,7 +128,7 @@ module.exports = { context.report({ node, loc: leftToken.loc.end, - message: "Unexpected space before function parentheses.", + messageId: "unexpectedSpace", fix(fixer) { const comments = sourceCode.getCommentsBefore(rightToken); @@ -141,7 +146,7 @@ module.exports = { context.report({ node, loc: leftToken.loc.end, - message: "Missing space before function parentheses.", + messageId: "missingSpace", fix: fixer => fixer.insertTextAfter(leftToken, " ") }); } diff --git a/tools/node_modules/eslint/lib/rules/space-in-parens.js b/tools/node_modules/eslint/lib/rules/space-in-parens.js index 85ee74210d6007..b0a604d955d788 100644 --- a/tools/node_modules/eslint/lib/rules/space-in-parens.js +++ b/tools/node_modules/eslint/lib/rules/space-in-parens.js @@ -169,7 +169,7 @@ module.exports = { } /** - * Determines if a closing paren is immediately preceeded by a required space + * Determines if a closing paren is immediately preceded by a required space * @param {Object} tokenBeforeClosingParen The token before the paren * @param {Object} closingParenToken The paren token * @returns {boolean} True if the closing paren is missing a required space @@ -190,7 +190,7 @@ module.exports = { } /** - * Determines if a closer paren is immediately preceeded by a disallowed space + * Determines if a closer paren is immediately preceded by a disallowed space * @param {Object} tokenBeforeClosingParen The token before the paren * @param {Object} closingParenToken The paren token * @returns {boolean} True if the closing paren has a disallowed space diff --git a/tools/node_modules/eslint/lib/rules/space-infix-ops.js b/tools/node_modules/eslint/lib/rules/space-infix-ops.js index bd2c0ae0e1d3b7..471c22210eb613 100644 --- a/tools/node_modules/eslint/lib/rules/space-infix-ops.js +++ b/tools/node_modules/eslint/lib/rules/space-infix-ops.js @@ -32,7 +32,11 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + missingSpace: "Operator '{{operator}}' must be spaced." + } }, create(context) { @@ -70,7 +74,7 @@ module.exports = { context.report({ node: mainNode, loc: culpritToken.loc, - message: "Operator '{{operator}}' must be spaced.", + messageId: "missingSpace", data: { operator: culpritToken.value }, @@ -123,11 +127,11 @@ module.exports = { * @private */ function checkConditional(node) { - const nonSpacedConsequesntNode = getFirstNonSpacedToken(node.test, node.consequent, "?"); + const nonSpacedConsequentNode = getFirstNonSpacedToken(node.test, node.consequent, "?"); const nonSpacedAlternateNode = getFirstNonSpacedToken(node.consequent, node.alternate, ":"); - if (nonSpacedConsequesntNode) { - report(node, nonSpacedConsequesntNode); + if (nonSpacedConsequentNode) { + report(node, nonSpacedConsequentNode); } else if (nonSpacedAlternateNode) { report(node, nonSpacedAlternateNode); } diff --git a/tools/node_modules/eslint/lib/rules/spaced-comment.js b/tools/node_modules/eslint/lib/rules/spaced-comment.js index daf56cd6bb42d0..d3221f0ea798ac 100644 --- a/tools/node_modules/eslint/lib/rules/spaced-comment.js +++ b/tools/node_modules/eslint/lib/rules/spaced-comment.js @@ -221,7 +221,16 @@ module.exports = { }, additionalProperties: false } - ] + ], + + messages: { + unexpectedSpaceAfterMarker: "Unexpected space or tab after marker ({{refChar}}) in comment.", + expectedExceptionAfter: "Expected exception block, space or tab after '{{refChar}}' in comment.", + unexpectedSpaceBefore: "Unexpected space or tab before '*/' in comment.", + unexpectedSpaceAfter: "Unexpected space or tab after '{{refChar}}' in comment.", + expectedSpaceBefore: "Expected space or tab before '*/' in comment.", + expectedSpaceAfter: "Expected space or tab after '{{refChar}}' in comment." + } }, create(context) { @@ -259,12 +268,12 @@ module.exports = { /** * Reports a beginning spacing error with an appropriate message. * @param {ASTNode} node A comment node to check. - * @param {string} message An error message to report. + * @param {string} messageId An error message to report. * @param {Array} match An array of match results for markers. * @param {string} refChar Character used for reference in the error message. * @returns {void} */ - function reportBegin(node, message, match, refChar) { + function reportBegin(node, messageId, match, refChar) { const type = node.type.toLowerCase(), commentIdentifier = type === "block" ? "/*" : "//"; @@ -284,7 +293,7 @@ module.exports = { return fixer.replaceTextRange([start, end], commentIdentifier + (match[1] ? match[1] : "")); }, - message, + messageId, data: { refChar } }); } @@ -292,11 +301,11 @@ module.exports = { /** * Reports an ending spacing error with an appropriate message. * @param {ASTNode} node A comment node to check. - * @param {string} message An error message to report. + * @param {string} messageId An error message to report. * @param {string} match An array of the matched whitespace characters. * @returns {void} */ - function reportEnd(node, message, match) { + function reportEnd(node, messageId, match) { context.report({ node, fix(fixer) { @@ -309,7 +318,7 @@ module.exports = { return fixer.replaceTextRange([start, end], ""); }, - message + messageId }); } @@ -338,26 +347,26 @@ module.exports = { const marker = hasMarker ? commentIdentifier + hasMarker[0] : commentIdentifier; if (rule.hasExceptions) { - reportBegin(node, "Expected exception block, space or tab after '{{refChar}}' in comment.", hasMarker, marker); + reportBegin(node, "expectedExceptionAfter", hasMarker, marker); } else { - reportBegin(node, "Expected space or tab after '{{refChar}}' in comment.", hasMarker, marker); + reportBegin(node, "expectedSpaceAfter", hasMarker, marker); } } if (balanced && type === "block" && !endMatch) { - reportEnd(node, "Expected space or tab before '*/' in comment."); + reportEnd(node, "expectedSpaceBefore"); } } else { if (beginMatch) { if (!beginMatch[1]) { - reportBegin(node, "Unexpected space or tab after '{{refChar}}' in comment.", beginMatch, commentIdentifier); + reportBegin(node, "unexpectedSpaceAfter", beginMatch, commentIdentifier); } else { - reportBegin(node, "Unexpected space or tab after marker ({{refChar}}) in comment.", beginMatch, beginMatch[1]); + reportBegin(node, "unexpectedSpaceAfterMarker", beginMatch, beginMatch[1]); } } if (balanced && type === "block" && endMatch) { - reportEnd(node, "Unexpected space or tab before '*/' in comment.", endMatch); + reportEnd(node, "unexpectedSpaceBefore", endMatch); } } } diff --git a/tools/node_modules/eslint/lib/rules/template-curly-spacing.js b/tools/node_modules/eslint/lib/rules/template-curly-spacing.js index 07da6a39b0e9bb..26043bc912210a 100644 --- a/tools/node_modules/eslint/lib/rules/template-curly-spacing.js +++ b/tools/node_modules/eslint/lib/rules/template-curly-spacing.js @@ -11,13 +11,6 @@ const astUtils = require("./utils/ast-utils"); -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const OPEN_PAREN = /\$\{$/u; -const CLOSE_PAREN = /^\}/u; - //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -49,7 +42,6 @@ module.exports = { create(context) { const sourceCode = context.getSourceCode(); const always = context.options[0] === "always"; - const prefix = always ? "expected" : "unexpected"; /** * Checks spacing before `}` of a given token. @@ -57,25 +49,39 @@ module.exports = { * @returns {void} */ function checkSpacingBefore(token) { - const prevToken = sourceCode.getTokenBefore(token); + if (!token.value.startsWith("}")) { + return; // starts with a backtick, this is the first template element in the template literal + } + + const prevToken = sourceCode.getTokenBefore(token, { includeComments: true }), + hasSpace = sourceCode.isSpaceBetween(prevToken, token); + + if (!astUtils.isTokenOnSameLine(prevToken, token)) { + return; + } - if (prevToken && - CLOSE_PAREN.test(token.value) && - astUtils.isTokenOnSameLine(prevToken, token) && - sourceCode.isSpaceBetweenTokens(prevToken, token) !== always - ) { + if (always && !hasSpace) { context.report({ - loc: token.loc.start, - messageId: `${prefix}Before`, - fix(fixer) { - if (always) { - return fixer.insertTextBefore(token, " "); + loc: { + start: token.loc.start, + end: { + line: token.loc.start.line, + column: token.loc.start.column + 1 } - return fixer.removeRange([ - prevToken.range[1], - token.range[0] - ]); - } + }, + messageId: "expectedBefore", + fix: fixer => fixer.insertTextBefore(token, " ") + }); + } + + if (!always && hasSpace) { + context.report({ + loc: { + start: prevToken.loc.end, + end: token.loc.start + }, + messageId: "unexpectedBefore", + fix: fixer => fixer.removeRange([prevToken.range[1], token.range[0]]) }); } } @@ -86,28 +92,39 @@ module.exports = { * @returns {void} */ function checkSpacingAfter(token) { - const nextToken = sourceCode.getTokenAfter(token); + if (!token.value.endsWith("${")) { + return; // ends with a backtick, this is the last template element in the template literal + } + + const nextToken = sourceCode.getTokenAfter(token, { includeComments: true }), + hasSpace = sourceCode.isSpaceBetween(token, nextToken); - if (nextToken && - OPEN_PAREN.test(token.value) && - astUtils.isTokenOnSameLine(token, nextToken) && - sourceCode.isSpaceBetweenTokens(token, nextToken) !== always - ) { + if (!astUtils.isTokenOnSameLine(token, nextToken)) { + return; + } + + if (always && !hasSpace) { context.report({ loc: { - line: token.loc.end.line, - column: token.loc.end.column - 2 + start: { + line: token.loc.end.line, + column: token.loc.end.column - 2 + }, + end: token.loc.end }, - messageId: `${prefix}After`, - fix(fixer) { - if (always) { - return fixer.insertTextAfter(token, " "); - } - return fixer.removeRange([ - token.range[1], - nextToken.range[0] - ]); - } + messageId: "expectedAfter", + fix: fixer => fixer.insertTextAfter(token, " ") + }); + } + + if (!always && hasSpace) { + context.report({ + loc: { + start: token.loc.end, + end: nextToken.loc.start + }, + messageId: "unexpectedAfter", + fix: fixer => fixer.removeRange([token.range[1], nextToken.range[0]]) }); } } diff --git a/tools/node_modules/eslint/lib/rules/use-isnan.js b/tools/node_modules/eslint/lib/rules/use-isnan.js index cd9ccdbaf898ee..7b466be75f2e5e 100644 --- a/tools/node_modules/eslint/lib/rules/use-isnan.js +++ b/tools/node_modules/eslint/lib/rules/use-isnan.js @@ -45,7 +45,7 @@ module.exports = { properties: { enforceForSwitchCase: { type: "boolean", - default: false + default: true }, enforceForIndexOf: { type: "boolean", @@ -66,7 +66,7 @@ module.exports = { create(context) { - const enforceForSwitchCase = context.options[0] && context.options[0].enforceForSwitchCase; + const enforceForSwitchCase = !context.options[0] || context.options[0].enforceForSwitchCase; const enforceForIndexOf = context.options[0] && context.options[0].enforceForIndexOf; /** diff --git a/tools/node_modules/eslint/lib/rules/utils/ast-utils.js b/tools/node_modules/eslint/lib/rules/utils/ast-utils.js index 01c6b47b82eefc..e6a3cb4cac58be 100644 --- a/tools/node_modules/eslint/lib/rules/utils/ast-utils.js +++ b/tools/node_modules/eslint/lib/rules/utils/ast-utils.js @@ -865,6 +865,47 @@ module.exports = { return isFunction(node) && module.exports.isEmptyBlock(node.body); }, + /** + * Returns the result of the string conversion applied to the evaluated value of the given expression node, + * if it can be determined statically. + * + * This function returns a `string` value for all `Literal` nodes and simple `TemplateLiteral` nodes only. + * In all other cases, this function returns `null`. + * @param {ASTNode} node Expression node. + * @returns {string|null} String value if it can be determined. Otherwise, `null`. + */ + getStaticStringValue(node) { + switch (node.type) { + case "Literal": + if (node.value === null) { + if (module.exports.isNullLiteral(node)) { + return String(node.value); // "null" + } + if (node.regex) { + return `/${node.regex.pattern}/${node.regex.flags}`; + } + if (node.bigint) { + return node.bigint; + } + + // Otherwise, this is an unknown literal. The function will return null. + + } else { + return String(node.value); + } + break; + case "TemplateLiteral": + if (node.expressions.length === 0 && node.quasis.length === 1) { + return node.quasis[0].value.cooked; + } + break; + + // no default + } + + return null; + }, + /** * Gets the property name of a given node. * The node can be a MemberExpression, a Property, or a MethodDefinition. @@ -911,23 +952,12 @@ module.exports = { // no default } - switch (prop && prop.type) { - case "Literal": - return String(prop.value); - - case "TemplateLiteral": - if (prop.expressions.length === 0 && prop.quasis.length === 1) { - return prop.quasis[0].value.cooked; - } - break; - - case "Identifier": - if (!node.computed) { - return prop.name; - } - break; + if (prop) { + if (prop.type === "Identifier" && !node.computed) { + return prop.name; + } - // no default + return module.exports.getStaticStringValue(prop); } return null; @@ -987,6 +1017,7 @@ module.exports = { * 0o5 // false * 5e0 // false * '5' // false + * 5n // false */ isDecimalInteger(node) { return node.type === "Literal" && typeof node.value === "number" && @@ -1306,6 +1337,18 @@ module.exports = { return node.type === "Literal" && node.value === null && !node.regex && !node.bigint; }, + /** + * Check if a given node is a numeric literal or not. + * @param {ASTNode} node The node to check. + * @returns {boolean} `true` if the node is a number or bigint literal. + */ + isNumericLiteral(node) { + return ( + node.type === "Literal" && + (typeof node.value === "number" || Boolean(node.bigint)) + ); + }, + /** * Determines whether two tokens can safely be placed next to each other without merging into a single token * @param {Token|string} leftValue The left token. If this is a string, it will be tokenized and the last token will be used. @@ -1314,17 +1357,65 @@ module.exports = { * next to each other, behavior is undefined (although it should return `true` in most cases). */ canTokensBeAdjacent(leftValue, rightValue) { + const espreeOptions = { + ecmaVersion: espree.latestEcmaVersion, + comment: true, + range: true + }; + let leftToken; if (typeof leftValue === "string") { - const leftTokens = espree.tokenize(leftValue, { ecmaVersion: 2015 }); + let tokens; + + try { + tokens = espree.tokenize(leftValue, espreeOptions); + } catch (e) { + return false; + } + + const comments = tokens.comments; - leftToken = leftTokens[leftTokens.length - 1]; + leftToken = tokens[tokens.length - 1]; + if (comments.length) { + const lastComment = comments[comments.length - 1]; + + if (lastComment.range[0] > leftToken.range[0]) { + leftToken = lastComment; + } + } } else { leftToken = leftValue; } - const rightToken = typeof rightValue === "string" ? espree.tokenize(rightValue, { ecmaVersion: 2015 })[0] : rightValue; + if (leftToken.type === "Shebang") { + return false; + } + + let rightToken; + + if (typeof rightValue === "string") { + let tokens; + + try { + tokens = espree.tokenize(rightValue, espreeOptions); + } catch (e) { + return false; + } + + const comments = tokens.comments; + + rightToken = tokens[0]; + if (comments.length) { + const firstComment = comments[0]; + + if (firstComment.range[0] < rightToken.range[0]) { + rightToken = firstComment; + } + } + } else { + rightToken = rightValue; + } if (leftToken.type === "Punctuator" || rightToken.type === "Punctuator") { if (leftToken.type === "Punctuator" && rightToken.type === "Punctuator") { @@ -1336,6 +1427,9 @@ module.exports = { MINUS_TOKENS.has(leftToken.value) && MINUS_TOKENS.has(rightToken.value) ); } + if (leftToken.type === "Punctuator" && leftToken.value === "/") { + return !["Block", "Line", "RegularExpression"].includes(rightToken.type); + } return true; } @@ -1350,6 +1444,10 @@ module.exports = { return true; } + if (leftToken.type === "Block" || rightToken.type === "Block" || rightToken.type === "Line") { + return true; + } + return false; }, @@ -1370,11 +1468,17 @@ module.exports = { const match = namePattern.exec(comment.value); // Convert the index to loc. - return sourceCode.getLocFromIndex( + const start = sourceCode.getLocFromIndex( comment.range[0] + "/*".length + (match ? match.index + 1 : 0) ); + const end = { + line: start.line, + column: start.column + (match ? name.length : 1) + }; + + return { start, end }; }, /** diff --git a/tools/node_modules/eslint/lib/rules/utils/unicode/is-combining-character.js b/tools/node_modules/eslint/lib/rules/utils/unicode/is-combining-character.js index 0fa40ee4ae8630..0498b99a21ed45 100644 --- a/tools/node_modules/eslint/lib/rules/utils/unicode/is-combining-character.js +++ b/tools/node_modules/eslint/lib/rules/utils/unicode/is-combining-character.js @@ -1,13 +1,13 @@ -// THIS FILE WAS GENERATED BY 'tools/update-unicode-utils.js' +/** + * @author Toru Nagashima + */ "use strict"; -const combiningChars = new Set([768,769,770,771,772,773,774,775,776,777,778,779,780,781,782,783,784,785,786,787,788,789,790,791,792,793,794,795,796,797,798,799,800,801,802,803,804,805,806,807,808,809,810,811,812,813,814,815,816,817,818,819,820,821,822,823,824,825,826,827,828,829,830,831,832,833,834,835,836,837,838,839,840,841,842,843,844,845,846,847,848,849,850,851,852,853,854,855,856,857,858,859,860,861,862,863,864,865,866,867,868,869,870,871,872,873,874,875,876,877,878,879,1155,1156,1157,1158,1159,1160,1161,1425,1426,1427,1428,1429,1430,1431,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441,1442,1443,1444,1445,1446,1447,1448,1449,1450,1451,1452,1453,1454,1455,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1471,1473,1474,1476,1477,1479,1552,1553,1554,1555,1556,1557,1558,1559,1560,1561,1562,1611,1612,1613,1614,1615,1616,1617,1618,1619,1620,1621,1622,1623,1624,1625,1626,1627,1628,1629,1630,1631,1648,1750,1751,1752,1753,1754,1755,1756,1759,1760,1761,1762,1763,1764,1767,1768,1770,1771,1772,1773,1809,1840,1841,1842,1843,1844,1845,1846,1847,1848,1849,1850,1851,1852,1853,1854,1855,1856,1857,1858,1859,1860,1861,1862,1863,1864,1865,1866,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,2027,2028,2029,2030,2031,2032,2033,2034,2035,2070,2071,2072,2073,2075,2076,2077,2078,2079,2080,2081,2082,2083,2085,2086,2087,2089,2090,2091,2092,2093,2137,2138,2139,2260,2261,2262,2263,2264,2265,2266,2267,2268,2269,2270,2271,2272,2273,2275,2276,2277,2278,2279,2280,2281,2282,2283,2284,2285,2286,2287,2288,2289,2290,2291,2292,2293,2294,2295,2296,2297,2298,2299,2300,2301,2302,2303,2304,2305,2306,2307,2362,2363,2364,2366,2367,2368,2369,2370,2371,2372,2373,2374,2375,2376,2377,2378,2379,2380,2381,2382,2383,2385,2386,2387,2388,2389,2390,2391,2402,2403,2433,2434,2435,2492,2494,2495,2496,2497,2498,2499,2500,2503,2504,2507,2508,2509,2519,2530,2531,2561,2562,2563,2620,2622,2623,2624,2625,2626,2631,2632,2635,2636,2637,2641,2672,2673,2677,2689,2690,2691,2748,2750,2751,2752,2753,2754,2755,2756,2757,2759,2760,2761,2763,2764,2765,2786,2787,2810,2811,2812,2813,2814,2815,2817,2818,2819,2876,2878,2879,2880,2881,2882,2883,2884,2887,2888,2891,2892,2893,2902,2903,2914,2915,2946,3006,3007,3008,3009,3010,3014,3015,3016,3018,3019,3020,3021,3031,3072,3073,3074,3075,3134,3135,3136,3137,3138,3139,3140,3142,3143,3144,3146,3147,3148,3149,3157,3158,3170,3171,3201,3202,3203,3260,3262,3263,3264,3265,3266,3267,3268,3270,3271,3272,3274,3275,3276,3277,3285,3286,3298,3299,3328,3329,3330,3331,3387,3388,3390,3391,3392,3393,3394,3395,3396,3398,3399,3400,3402,3403,3404,3405,3415,3426,3427,3458,3459,3530,3535,3536,3537,3538,3539,3540,3542,3544,3545,3546,3547,3548,3549,3550,3551,3570,3571,3633,3636,3637,3638,3639,3640,3641,3642,3655,3656,3657,3658,3659,3660,3661,3662,3761,3764,3765,3766,3767,3768,3769,3771,3772,3784,3785,3786,3787,3788,3789,3864,3865,3893,3895,3897,3902,3903,3953,3954,3955,3956,3957,3958,3959,3960,3961,3962,3963,3964,3965,3966,3967,3968,3969,3970,3971,3972,3974,3975,3981,3982,3983,3984,3985,3986,3987,3988,3989,3990,3991,3993,3994,3995,3996,3997,3998,3999,4000,4001,4002,4003,4004,4005,4006,4007,4008,4009,4010,4011,4012,4013,4014,4015,4016,4017,4018,4019,4020,4021,4022,4023,4024,4025,4026,4027,4028,4038,4139,4140,4141,4142,4143,4144,4145,4146,4147,4148,4149,4150,4151,4152,4153,4154,4155,4156,4157,4158,4182,4183,4184,4185,4190,4191,4192,4194,4195,4196,4199,4200,4201,4202,4203,4204,4205,4209,4210,4211,4212,4226,4227,4228,4229,4230,4231,4232,4233,4234,4235,4236,4237,4239,4250,4251,4252,4253,4957,4958,4959,5906,5907,5908,5938,5939,5940,5970,5971,6002,6003,6068,6069,6070,6071,6072,6073,6074,6075,6076,6077,6078,6079,6080,6081,6082,6083,6084,6085,6086,6087,6088,6089,6090,6091,6092,6093,6094,6095,6096,6097,6098,6099,6109,6155,6156,6157,6277,6278,6313,6432,6433,6434,6435,6436,6437,6438,6439,6440,6441,6442,6443,6448,6449,6450,6451,6452,6453,6454,6455,6456,6457,6458,6459,6679,6680,6681,6682,6683,6741,6742,6743,6744,6745,6746,6747,6748,6749,6750,6752,6753,6754,6755,6756,6757,6758,6759,6760,6761,6762,6763,6764,6765,6766,6767,6768,6769,6770,6771,6772,6773,6774,6775,6776,6777,6778,6779,6780,6783,6832,6833,6834,6835,6836,6837,6838,6839,6840,6841,6842,6843,6844,6845,6846,6912,6913,6914,6915,6916,6964,6965,6966,6967,6968,6969,6970,6971,6972,6973,6974,6975,6976,6977,6978,6979,6980,7019,7020,7021,7022,7023,7024,7025,7026,7027,7040,7041,7042,7073,7074,7075,7076,7077,7078,7079,7080,7081,7082,7083,7084,7085,7142,7143,7144,7145,7146,7147,7148,7149,7150,7151,7152,7153,7154,7155,7204,7205,7206,7207,7208,7209,7210,7211,7212,7213,7214,7215,7216,7217,7218,7219,7220,7221,7222,7223,7376,7377,7378,7380,7381,7382,7383,7384,7385,7386,7387,7388,7389,7390,7391,7392,7393,7394,7395,7396,7397,7398,7399,7400,7405,7410,7411,7412,7415,7416,7417,7616,7617,7618,7619,7620,7621,7622,7623,7624,7625,7626,7627,7628,7629,7630,7631,7632,7633,7634,7635,7636,7637,7638,7639,7640,7641,7642,7643,7644,7645,7646,7647,7648,7649,7650,7651,7652,7653,7654,7655,7656,7657,7658,7659,7660,7661,7662,7663,7664,7665,7666,7667,7668,7669,7670,7671,7672,7673,7675,7676,7677,7678,7679,8400,8401,8402,8403,8404,8405,8406,8407,8408,8409,8410,8411,8412,8413,8414,8415,8416,8417,8418,8419,8420,8421,8422,8423,8424,8425,8426,8427,8428,8429,8430,8431,8432,11503,11504,11505,11647,11744,11745,11746,11747,11748,11749,11750,11751,11752,11753,11754,11755,11756,11757,11758,11759,11760,11761,11762,11763,11764,11765,11766,11767,11768,11769,11770,11771,11772,11773,11774,11775,12330,12331,12332,12333,12334,12335,12441,12442,42607,42608,42609,42610,42612,42613,42614,42615,42616,42617,42618,42619,42620,42621,42654,42655,42736,42737,43010,43014,43019,43043,43044,43045,43046,43047,43136,43137,43188,43189,43190,43191,43192,43193,43194,43195,43196,43197,43198,43199,43200,43201,43202,43203,43204,43205,43232,43233,43234,43235,43236,43237,43238,43239,43240,43241,43242,43243,43244,43245,43246,43247,43248,43249,43302,43303,43304,43305,43306,43307,43308,43309,43335,43336,43337,43338,43339,43340,43341,43342,43343,43344,43345,43346,43347,43392,43393,43394,43395,43443,43444,43445,43446,43447,43448,43449,43450,43451,43452,43453,43454,43455,43456,43493,43561,43562,43563,43564,43565,43566,43567,43568,43569,43570,43571,43572,43573,43574,43587,43596,43597,43643,43644,43645,43696,43698,43699,43700,43703,43704,43710,43711,43713,43755,43756,43757,43758,43759,43765,43766,44003,44004,44005,44006,44007,44008,44009,44010,44012,44013,64286,65024,65025,65026,65027,65028,65029,65030,65031,65032,65033,65034,65035,65036,65037,65038,65039,65056,65057,65058,65059,65060,65061,65062,65063,65064,65065,65066,65067,65068,65069,65070,65071,66045,66272,66422,66423,66424,66425,66426,68097,68098,68099,68101,68102,68108,68109,68110,68111,68152,68153,68154,68159,68325,68326,69632,69633,69634,69688,69689,69690,69691,69692,69693,69694,69695,69696,69697,69698,69699,69700,69701,69702,69759,69760,69761,69762,69808,69809,69810,69811,69812,69813,69814,69815,69816,69817,69818,69888,69889,69890,69927,69928,69929,69930,69931,69932,69933,69934,69935,69936,69937,69938,69939,69940,70003,70016,70017,70018,70067,70068,70069,70070,70071,70072,70073,70074,70075,70076,70077,70078,70079,70080,70090,70091,70092,70188,70189,70190,70191,70192,70193,70194,70195,70196,70197,70198,70199,70206,70367,70368,70369,70370,70371,70372,70373,70374,70375,70376,70377,70378,70400,70401,70402,70403,70460,70462,70463,70464,70465,70466,70467,70468,70471,70472,70475,70476,70477,70487,70498,70499,70502,70503,70504,70505,70506,70507,70508,70512,70513,70514,70515,70516,70709,70710,70711,70712,70713,70714,70715,70716,70717,70718,70719,70720,70721,70722,70723,70724,70725,70726,70832,70833,70834,70835,70836,70837,70838,70839,70840,70841,70842,70843,70844,70845,70846,70847,70848,70849,70850,70851,71087,71088,71089,71090,71091,71092,71093,71096,71097,71098,71099,71100,71101,71102,71103,71104,71132,71133,71216,71217,71218,71219,71220,71221,71222,71223,71224,71225,71226,71227,71228,71229,71230,71231,71232,71339,71340,71341,71342,71343,71344,71345,71346,71347,71348,71349,71350,71351,71453,71454,71455,71456,71457,71458,71459,71460,71461,71462,71463,71464,71465,71466,71467,72193,72194,72195,72196,72197,72198,72199,72200,72201,72202,72243,72244,72245,72246,72247,72248,72249,72251,72252,72253,72254,72263,72273,72274,72275,72276,72277,72278,72279,72280,72281,72282,72283,72330,72331,72332,72333,72334,72335,72336,72337,72338,72339,72340,72341,72342,72343,72344,72345,72751,72752,72753,72754,72755,72756,72757,72758,72760,72761,72762,72763,72764,72765,72766,72767,72850,72851,72852,72853,72854,72855,72856,72857,72858,72859,72860,72861,72862,72863,72864,72865,72866,72867,72868,72869,72870,72871,72873,72874,72875,72876,72877,72878,72879,72880,72881,72882,72883,72884,72885,72886,73009,73010,73011,73012,73013,73014,73018,73020,73021,73023,73024,73025,73026,73027,73028,73029,73031,92912,92913,92914,92915,92916,92976,92977,92978,92979,92980,92981,92982,94033,94034,94035,94036,94037,94038,94039,94040,94041,94042,94043,94044,94045,94046,94047,94048,94049,94050,94051,94052,94053,94054,94055,94056,94057,94058,94059,94060,94061,94062,94063,94064,94065,94066,94067,94068,94069,94070,94071,94072,94073,94074,94075,94076,94077,94078,94095,94096,94097,94098,113821,113822,119141,119142,119143,119144,119145,119149,119150,119151,119152,119153,119154,119163,119164,119165,119166,119167,119168,119169,119170,119173,119174,119175,119176,119177,119178,119179,119210,119211,119212,119213,119362,119363,119364,121344,121345,121346,121347,121348,121349,121350,121351,121352,121353,121354,121355,121356,121357,121358,121359,121360,121361,121362,121363,121364,121365,121366,121367,121368,121369,121370,121371,121372,121373,121374,121375,121376,121377,121378,121379,121380,121381,121382,121383,121384,121385,121386,121387,121388,121389,121390,121391,121392,121393,121394,121395,121396,121397,121398,121403,121404,121405,121406,121407,121408,121409,121410,121411,121412,121413,121414,121415,121416,121417,121418,121419,121420,121421,121422,121423,121424,121425,121426,121427,121428,121429,121430,121431,121432,121433,121434,121435,121436,121437,121438,121439,121440,121441,121442,121443,121444,121445,121446,121447,121448,121449,121450,121451,121452,121461,121476,121499,121500,121501,121502,121503,121505,121506,121507,121508,121509,121510,121511,121512,121513,121514,121515,121516,121517,121518,121519,122880,122881,122882,122883,122884,122885,122886,122888,122889,122890,122891,122892,122893,122894,122895,122896,122897,122898,122899,122900,122901,122902,122903,122904,122907,122908,122909,122910,122911,122912,122913,122915,122916,122918,122919,122920,122921,122922,125136,125137,125138,125139,125140,125141,125142,125252,125253,125254,125255,125256,125257,125258,917760,917761,917762,917763,917764,917765,917766,917767,917768,917769,917770,917771,917772,917773,917774,917775,917776,917777,917778,917779,917780,917781,917782,917783,917784,917785,917786,917787,917788,917789,917790,917791,917792,917793,917794,917795,917796,917797,917798,917799,917800,917801,917802,917803,917804,917805,917806,917807,917808,917809,917810,917811,917812,917813,917814,917815,917816,917817,917818,917819,917820,917821,917822,917823,917824,917825,917826,917827,917828,917829,917830,917831,917832,917833,917834,917835,917836,917837,917838,917839,917840,917841,917842,917843,917844,917845,917846,917847,917848,917849,917850,917851,917852,917853,917854,917855,917856,917857,917858,917859,917860,917861,917862,917863,917864,917865,917866,917867,917868,917869,917870,917871,917872,917873,917874,917875,917876,917877,917878,917879,917880,917881,917882,917883,917884,917885,917886,917887,917888,917889,917890,917891,917892,917893,917894,917895,917896,917897,917898,917899,917900,917901,917902,917903,917904,917905,917906,917907,917908,917909,917910,917911,917912,917913,917914,917915,917916,917917,917918,917919,917920,917921,917922,917923,917924,917925,917926,917927,917928,917929,917930,917931,917932,917933,917934,917935,917936,917937,917938,917939,917940,917941,917942,917943,917944,917945,917946,917947,917948,917949,917950,917951,917952,917953,917954,917955,917956,917957,917958,917959,917960,917961,917962,917963,917964,917965,917966,917967,917968,917969,917970,917971,917972,917973,917974,917975,917976,917977,917978,917979,917980,917981,917982,917983,917984,917985,917986,917987,917988,917989,917990,917991,917992,917993,917994,917995,917996,917997,917998,917999]) - /** * Check whether a given character is a combining mark or not. - * @param {number} c The character code to check. - * @returns {boolean} `true` if the character belongs to the category, one of `Mc`, `Me`, and `Mn`. + * @param {number} codePoint The character code to check. + * @returns {boolean} `true` if the character belongs to the category, any of `Mc`, `Me`, and `Mn`. */ -module.exports = function isCombiningCharacter(c) { - return combiningChars.has(c); +module.exports = function isCombiningCharacter(codePoint) { + return /^[\p{Mc}\p{Me}\p{Mn}]$/u.test(String.fromCodePoint(codePoint)); }; diff --git a/tools/node_modules/eslint/lib/rules/wrap-iife.js b/tools/node_modules/eslint/lib/rules/wrap-iife.js index 5e590be13e28b5..896aed63de5222 100644 --- a/tools/node_modules/eslint/lib/rules/wrap-iife.js +++ b/tools/node_modules/eslint/lib/rules/wrap-iife.js @@ -10,6 +10,21 @@ //------------------------------------------------------------------------------ const astUtils = require("./utils/ast-utils"); +const eslintUtils = require("eslint-utils"); + +//---------------------------------------------------------------------- +// Helpers +//---------------------------------------------------------------------- + +/** + * Check if the given node is callee of a `NewExpression` node + * @param {ASTNode} node node to check + * @returns {boolean} True if the node is callee of a `NewExpression` node + * @private + */ +function isCalleeOfNewExpression(node) { + return node.parent.type === "NewExpression" && node.parent.callee === node; +} //------------------------------------------------------------------------------ // Rule Definition @@ -58,15 +73,25 @@ module.exports = { const sourceCode = context.getSourceCode(); /** - * Check if the node is wrapped in () + * Check if the node is wrapped in any (). All parens count: grouping parens and parens for constructs such as if() * @param {ASTNode} node node to evaluate - * @returns {boolean} True if it is wrapped + * @returns {boolean} True if it is wrapped in any parens * @private */ - function wrapped(node) { + function isWrappedInAnyParens(node) { return astUtils.isParenthesised(sourceCode, node); } + /** + * Check if the node is wrapped in grouping (). Parens for constructs such as if() don't count + * @param {ASTNode} node node to evaluate + * @returns {boolean} True if it is wrapped in grouping parens + * @private + */ + function isWrappedInGroupingParens(node) { + return eslintUtils.isParenthesized(1, node, sourceCode); + } + /** * Get the function node from an IIFE * @param {ASTNode} node node to evaluate @@ -99,10 +124,10 @@ module.exports = { return; } - const callExpressionWrapped = wrapped(node), - functionExpressionWrapped = wrapped(innerNode); + const isCallExpressionWrapped = isWrappedInAnyParens(node), + isFunctionExpressionWrapped = isWrappedInAnyParens(innerNode); - if (!callExpressionWrapped && !functionExpressionWrapped) { + if (!isCallExpressionWrapped && !isFunctionExpressionWrapped) { context.report({ node, messageId: "wrapInvocation", @@ -112,27 +137,39 @@ module.exports = { return fixer.replaceText(nodeToSurround, `(${sourceCode.getText(nodeToSurround)})`); } }); - } else if (style === "inside" && !functionExpressionWrapped) { + } else if (style === "inside" && !isFunctionExpressionWrapped) { context.report({ node, messageId: "wrapExpression", fix(fixer) { + // The outer call expression will always be wrapped at this point. + + if (isWrappedInGroupingParens(node) && !isCalleeOfNewExpression(node)) { + + /* + * Parenthesize the function expression and remove unnecessary grouping parens around the call expression. + * Replace the range between the end of the function expression and the end of the call expression. + * for example, in `(function(foo) {}(bar))`, the range `(bar))` should get replaced with `)(bar)`. + */ + + const parenAfter = sourceCode.getTokenAfter(node); + + return fixer.replaceTextRange( + [innerNode.range[1], parenAfter.range[1]], + `)${sourceCode.getText().slice(innerNode.range[1], parenAfter.range[0])}` + ); + } + /* - * The outer call expression will always be wrapped at this point. - * Replace the range between the end of the function expression and the end of the call expression. - * for example, in `(function(foo) {}(bar))`, the range `(bar))` should get replaced with `)(bar)`. - * Replace the parens from the outer expression, and parenthesize the function expression. + * Call expression is wrapped in mandatory parens such as if(), or in necessary grouping parens. + * These parens cannot be removed, so just parenthesize the function expression. */ - const parenAfter = sourceCode.getTokenAfter(node); - return fixer.replaceTextRange( - [innerNode.range[1], parenAfter.range[1]], - `)${sourceCode.getText().slice(innerNode.range[1], parenAfter.range[0])}` - ); + return fixer.replaceText(innerNode, `(${sourceCode.getText(innerNode)})`); } }); - } else if (style === "outside" && !callExpressionWrapped) { + } else if (style === "outside" && !isCallExpressionWrapped) { context.report({ node, messageId: "moveInvocation", diff --git a/tools/node_modules/eslint/lib/rules/yoda.js b/tools/node_modules/eslint/lib/rules/yoda.js index b00acf82c702b0..c4ff3f81938595 100644 --- a/tools/node_modules/eslint/lib/rules/yoda.js +++ b/tools/node_modules/eslint/lib/rules/yoda.js @@ -49,12 +49,30 @@ function isRangeTestOperator(operator) { * @returns {boolean} True if the node is a negative number that looks like a * real literal and should be treated as such. */ -function looksLikeLiteral(node) { +function isNegativeNumericLiteral(node) { return (node.type === "UnaryExpression" && node.operator === "-" && node.prefix && - node.argument.type === "Literal" && - typeof node.argument.value === "number"); + astUtils.isNumericLiteral(node.argument)); +} + +/** + * Determines whether a node is a Template Literal which can be determined statically. + * @param {ASTNode} node Node to test + * @returns {boolean} True if the node is a Template Literal without expression. + */ +function isStaticTemplateLiteral(node) { + return node.type === "TemplateLiteral" && node.expressions.length === 0; +} + +/** + * Determines whether a non-Literal node should be treated as a single Literal node. + * @param {ASTNode} node Node to test + * @returns {boolean} True if the node should be treated as a single Literal node. + */ +function looksLikeLiteral(node) { + return isNegativeNumericLiteral(node) || + isStaticTemplateLiteral(node); } /** @@ -66,15 +84,17 @@ function looksLikeLiteral(node) { * 1. The original node if the node is already a Literal * 2. A normalized Literal node with the negative number as the value if the * node represents a negative number literal. - * 3. The Literal node which has the `defaultValue` argument if it exists. - * 4. Otherwise `null`. + * 3. A normalized Literal node with the string as the value if the node is + * a Template Literal without expression. + * 4. The Literal node which has the `defaultValue` argument if it exists. + * 5. Otherwise `null`. */ function getNormalizedLiteral(node, defaultValue) { if (node.type === "Literal") { return node; } - if (looksLikeLiteral(node)) { + if (isNegativeNumericLiteral(node)) { return { type: "Literal", value: -node.argument.value, @@ -82,6 +102,14 @@ function getNormalizedLiteral(node, defaultValue) { }; } + if (isStaticTemplateLiteral(node)) { + return { + type: "Literal", + value: node.quasis[0].value.cooked, + raw: node.quasis[0].value.raw + }; + } + if (defaultValue) { return { type: "Literal", diff --git a/tools/node_modules/eslint/lib/shared/config-validator.js b/tools/node_modules/eslint/lib/shared/config-validator.js index aca6e1fb274fdb..458bd2a802b95c 100644 --- a/tools/node_modules/eslint/lib/shared/config-validator.js +++ b/tools/node_modules/eslint/lib/shared/config-validator.js @@ -10,13 +10,12 @@ //------------------------------------------------------------------------------ const - path = require("path"), util = require("util"), - lodash = require("lodash"), configSchema = require("../../conf/config-schema"), BuiltInEnvironments = require("../../conf/environments"), BuiltInRules = require("../rules"), - ConfigOps = require("./config-ops"); + ConfigOps = require("./config-ops"), + { emitDeprecationWarning } = require("./deprecation-warnings"); const ajv = require("./ajv")(); const ruleValidators = new WeakMap(); @@ -26,11 +25,6 @@ const noop = Function.prototype; // Private //------------------------------------------------------------------------------ let validateSchema; - -// Defitions for deprecation warnings. -const deprecationWarningMessages = { - ESLINT_LEGACY_ECMAFEATURES: "The 'ecmaFeatures' config file property is deprecated, and has no effect." -}; const severityMap = { error: 2, warn: 1, @@ -196,7 +190,7 @@ function validateRules( /** * Validates a `globals` section of a config file - * @param {Object} globalsConfig The `glboals` section + * @param {Object} globalsConfig The `globals` section * @param {string|null} source The name of the configuration source to report in the event of an error. * @returns {void} */ @@ -254,25 +248,6 @@ function formatErrors(errors) { }).map(message => `\t- ${message}.\n`).join(""); } -/** - * Emits a deprecation warning containing a given filepath. A new deprecation warning is emitted - * for each unique file path, but repeated invocations with the same file path have no effect. - * No warnings are emitted if the `--no-deprecation` or `--no-warnings` Node runtime flags are active. - * @param {string} source The name of the configuration source to report the warning for. - * @param {string} errorCode The warning message to show. - * @returns {void} - */ -const emitDeprecationWarning = lodash.memoize((source, errorCode) => { - const rel = path.relative(process.cwd(), source); - const message = deprecationWarningMessages[errorCode]; - - process.emitWarning( - `${message} (found in "${rel}")`, - "DeprecationWarning", - errorCode - ); -}); - /** * Validates the top level properties of the config object. * @param {Object} config The config object to validate. diff --git a/tools/node_modules/eslint/lib/shared/deprecation-warnings.js b/tools/node_modules/eslint/lib/shared/deprecation-warnings.js new file mode 100644 index 00000000000000..e1481a2e9aa0b8 --- /dev/null +++ b/tools/node_modules/eslint/lib/shared/deprecation-warnings.js @@ -0,0 +1,56 @@ +/** + * @fileoverview Provide the function that emits deprecation warnings. + * @author Toru Nagashima + */ +"use strict"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const path = require("path"); +const lodash = require("lodash"); + +//------------------------------------------------------------------------------ +// Private +//------------------------------------------------------------------------------ + +// Defitions for deprecation warnings. +const deprecationWarningMessages = { + ESLINT_LEGACY_ECMAFEATURES: + "The 'ecmaFeatures' config file property is deprecated and has no effect.", + ESLINT_PERSONAL_CONFIG_LOAD: + "'~/.eslintrc.*' config files have been deprecated. " + + "Please use a config file per project or the '--config' option.", + ESLINT_PERSONAL_CONFIG_SUPPRESS: + "'~/.eslintrc.*' config files have been deprecated. " + + "Please remove it or add 'root:true' to the config files in your " + + "projects in order to avoid loading '~/.eslintrc.*' accidentally." +}; + +/** + * Emits a deprecation warning containing a given filepath. A new deprecation warning is emitted + * for each unique file path, but repeated invocations with the same file path have no effect. + * No warnings are emitted if the `--no-deprecation` or `--no-warnings` Node runtime flags are active. + * @param {string} source The name of the configuration source to report the warning for. + * @param {string} errorCode The warning message to show. + * @returns {void} + */ +const emitDeprecationWarning = lodash.memoize((source, errorCode) => { + const rel = path.relative(process.cwd(), source); + const message = deprecationWarningMessages[errorCode]; + + process.emitWarning( + `${message} (found in "${rel}")`, + "DeprecationWarning", + errorCode + ); +}, (...args) => JSON.stringify(args)); + +//------------------------------------------------------------------------------ +// Public Interface +//------------------------------------------------------------------------------ + +module.exports = { + emitDeprecationWarning +}; diff --git a/tools/node_modules/eslint/lib/shared/naming.js b/tools/node_modules/eslint/lib/shared/naming.js index b99155f15cafa7..32cff94538af22 100644 --- a/tools/node_modules/eslint/lib/shared/naming.js +++ b/tools/node_modules/eslint/lib/shared/naming.js @@ -78,7 +78,7 @@ function getShorthandName(fullname, prefix) { /** * Gets the scope (namespace) of a term. * @param {string} term The term which may have the namespace. - * @returns {string} The namepace of the term if it has one. + * @returns {string} The namespace of the term if it has one. */ function getNamespaceFromTerm(term) { const match = term.match(NAMESPACE_REGEX); diff --git a/tools/node_modules/eslint/lib/shared/relative-module-resolver.js b/tools/node_modules/eslint/lib/shared/relative-module-resolver.js index 5b25fa111214ed..fa6cca72361df5 100644 --- a/tools/node_modules/eslint/lib/shared/relative-module-resolver.js +++ b/tools/node_modules/eslint/lib/shared/relative-module-resolver.js @@ -6,35 +6,18 @@ "use strict"; const Module = require("module"); -const path = require("path"); -// Polyfill Node's `Module.createRequire` if not present. We only support the case where the argument is a filepath, not a URL. -const createRequire = ( - - // Added in v12.2.0 - Module.createRequire || - - // Added in v10.12.0, but deprecated in v12.2.0. - Module.createRequireFromPath || - - // Polyfill - This is not executed on the tests on node@>=10. - /* istanbul ignore next */ - (filename => { - const mod = new Module(filename, null); - - mod.filename = filename; - mod.paths = Module._nodeModulePaths(path.dirname(filename)); // eslint-disable-line no-underscore-dangle - mod._compile("module.exports = require;", filename); // eslint-disable-line no-underscore-dangle - return mod.exports; - }) -); +/* + * `Module.createRequire` is added in v12.2.0. It supports URL as well. + * We only support the case where the argument is a filepath, not a URL. + */ +const createRequire = Module.createRequire || Module.createRequireFromPath; module.exports = { /** * Resolves a Node module relative to another module * @param {string} moduleName The name of a Node module, or a path to a Node module. - * * @param {string} relativeToPath An absolute path indicating the module that `moduleName` should be resolved relative to. This must be * a file rather than a directory, but the file need not actually exist. * @returns {string} The absolute path that would result from calling `require.resolve(moduleName)` in a file located at `relativeToPath` @@ -43,6 +26,8 @@ module.exports = { try { return createRequire(relativeToPath).resolve(moduleName); } catch (error) { + + // This `if` block is for older Node.js than 12.0.0. We can remove this block in the future. if ( typeof error === "object" && error !== null && diff --git a/tools/node_modules/eslint/lib/shared/types.js b/tools/node_modules/eslint/lib/shared/types.js index a5bd0200e2792a..bf37327fa240ca 100644 --- a/tools/node_modules/eslint/lib/shared/types.js +++ b/tools/node_modules/eslint/lib/shared/types.js @@ -21,7 +21,7 @@ module.exports = {}; /** * @typedef {Object} ParserOptions * @property {EcmaFeatures} [ecmaFeatures] The optional features. - * @property {3|5|6|7|8|9|10|2015|2016|2017|2018|2019} [ecmaVersion] The ECMAScript version (or revision number). + * @property {3|5|6|7|8|9|10|11|2015|2016|2017|2018|2019|2020} [ecmaVersion] The ECMAScript version (or revision number). * @property {"script"|"module"} [sourceType] The source code type. */ @@ -37,7 +37,7 @@ module.exports = {}; * @property {ParserOptions} [parserOptions] The parser options. * @property {string[]} [plugins] The plugin specifiers. * @property {string} [processor] The processor specifier. - * @property {boolean|undefined} reportUnusedDisableDirectives The flag to report unused `eslint-disable` comments. + * @property {boolean} [reportUnusedDisableDirectives] The flag to report unused `eslint-disable` comments. * @property {boolean} [root] The root flag. * @property {Record} [rules] The rule settings. * @property {Object} [settings] The shared settings. @@ -56,7 +56,7 @@ module.exports = {}; * @property {ParserOptions} [parserOptions] The parser options. * @property {string[]} [plugins] The plugin specifiers. * @property {string} [processor] The processor specifier. - * @property {boolean|undefined} reportUnusedDisableDirectives The flag to report unused `eslint-disable` comments. + * @property {boolean} [reportUnusedDisableDirectives] The flag to report unused `eslint-disable` comments. * @property {Record} [rules] The rule settings. * @property {Object} [settings] The shared settings. */ diff --git a/tools/node_modules/eslint/lib/source-code/source-code.js b/tools/node_modules/eslint/lib/source-code/source-code.js index 30b4e9ab5c26e3..591d5a7e454ee2 100644 --- a/tools/node_modules/eslint/lib/source-code/source-code.js +++ b/tools/node_modules/eslint/lib/source-code/source-code.js @@ -121,7 +121,7 @@ function isSpaceBetween(sourceCode, first, second, checkInsideOfJSXText) { currentToken.range[1] !== nextToken.range[0] || /* - * For backward compatibility, check speces in JSXText. + * For backward compatibility, check spaces in JSXText. * https://github.com/eslint/eslint/issues/12614 */ ( diff --git a/tools/node_modules/eslint/lib/source-code/token-store/utils.js b/tools/node_modules/eslint/lib/source-code/token-store/utils.js index 444684b52f1bb0..21e1d6ff7c3b6d 100644 --- a/tools/node_modules/eslint/lib/source-code/token-store/utils.js +++ b/tools/node_modules/eslint/lib/source-code/token-store/utils.js @@ -1,5 +1,5 @@ /** - * @fileoverview Define utilify functions for token store. + * @fileoverview Define utility functions for token store. * @author Toru Nagashima */ "use strict"; diff --git a/tools/node_modules/eslint/messages/plugin-conflict.txt b/tools/node_modules/eslint/messages/plugin-conflict.txt new file mode 100644 index 00000000000000..6fcf7c83115d70 --- /dev/null +++ b/tools/node_modules/eslint/messages/plugin-conflict.txt @@ -0,0 +1,7 @@ +ESLint couldn't determine the plugin "<%- pluginId %>" uniquely. +<% for (const { filePath, importerName } of plugins) { %> +- <%= filePath %> (loaded in "<%= importerName %>")<% } %> + +Please remove the "plugins" setting from either config or remove either plugin installation. + +If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team. diff --git a/tools/node_modules/eslint/node_modules/@babel/code-frame/lib/index.js b/tools/node_modules/eslint/node_modules/@babel/code-frame/lib/index.js index 35176fbc0682ca..62945f7782a774 100644 --- a/tools/node_modules/eslint/node_modules/@babel/code-frame/lib/index.js +++ b/tools/node_modules/eslint/node_modules/@babel/code-frame/lib/index.js @@ -6,17 +6,11 @@ Object.defineProperty(exports, "__esModule", { exports.codeFrameColumns = codeFrameColumns; exports.default = _default; -function _highlight() { - const data = _interopRequireWildcard(require("@babel/highlight")); +var _highlight = _interopRequireWildcard(require("@babel/highlight")); - _highlight = function () { - return data; - }; - - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } let deprecationWarningShown = false; @@ -35,7 +29,7 @@ function getMarkerLines(loc, source, opts) { column: 0, line: -1 }, loc.start); - const endLoc = Object.assign({}, startLoc, loc.end); + const endLoc = Object.assign({}, startLoc, {}, loc.end); const { linesAbove = 2, linesBelow = 3 @@ -94,8 +88,8 @@ function getMarkerLines(loc, source, opts) { } function codeFrameColumns(rawLines, loc, opts = {}) { - const highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight().shouldHighlight)(opts); - const chalk = (0, _highlight().getChalk)(opts); + const highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight.shouldHighlight)(opts); + const chalk = (0, _highlight.getChalk)(opts); const defs = getDefs(chalk); const maybeHighlight = (chalkFn, string) => { @@ -110,7 +104,7 @@ function codeFrameColumns(rawLines, loc, opts = {}) { } = getMarkerLines(loc, lines, opts); const hasColumns = loc.start && typeof loc.start.column === "number"; const numberMaxWidth = String(end).length; - const highlightedLines = highlighted ? (0, _highlight().default)(rawLines, opts) : rawLines; + const highlightedLines = highlighted ? (0, _highlight.default)(rawLines, opts) : rawLines; let frame = highlightedLines.split(NEWLINE).slice(start, end).map((line, index) => { const number = start + 1 + index; const paddedNumber = ` ${number}`.slice(-numberMaxWidth); diff --git a/tools/node_modules/eslint/node_modules/@babel/code-frame/package.json b/tools/node_modules/eslint/node_modules/@babel/code-frame/package.json index d619d9a8f53194..7508b5b1402c94 100644 --- a/tools/node_modules/eslint/node_modules/@babel/code-frame/package.json +++ b/tools/node_modules/eslint/node_modules/@babel/code-frame/package.json @@ -5,7 +5,7 @@ }, "bundleDependencies": false, "dependencies": { - "@babel/highlight": "^7.0.0" + "@babel/highlight": "^7.8.3" }, "deprecated": false, "description": "Generate errors that contain a code frame that point to source locations.", @@ -13,7 +13,7 @@ "chalk": "^2.0.0", "strip-ansi": "^4.0.0" }, - "gitHead": "0407f034f09381b95e9cabefbf6b176c76485a43", + "gitHead": "a7620bd266ae1345975767bbc7abf09034437017", "homepage": "https://babeljs.io/", "license": "MIT", "main": "lib/index.js", @@ -25,5 +25,5 @@ "type": "git", "url": "https://github.com/babel/babel/tree/master/packages/babel-code-frame" }, - "version": "7.5.5" + "version": "7.8.3" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/LICENSE b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/LICENSE new file mode 100644 index 00000000000000..f31575ec773bb1 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2014-present Sebastian McKenzie and other contributors + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/README.md b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/README.md new file mode 100644 index 00000000000000..ab2dad173149e8 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/README.md @@ -0,0 +1,19 @@ +# @babel/helper-validator-identifier + +> Validate identifier/keywords name + +See our website [@babel/helper-validator-identifier](https://babeljs.io/docs/en/next/babel-helper-validator-identifier.html) for more information. + +## Install + +Using npm: + +```sh +npm install --save-dev @babel/helper-validator-identifier +``` + +or using yarn: + +```sh +yarn add @babel/helper-validator-identifier --dev +``` diff --git a/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/lib/identifier.js b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/lib/identifier.js new file mode 100644 index 00000000000000..92043ce6630710 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/lib/identifier.js @@ -0,0 +1,77 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.isIdentifierStart = isIdentifierStart; +exports.isIdentifierChar = isIdentifierChar; +exports.isIdentifierName = isIdentifierName; +let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08c7\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\u9ffc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7ca\ua7f5-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; +let nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf\u1ac0\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"; +const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); +const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); +nonASCIIidentifierStartChars = nonASCIIidentifierChars = null; +const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 157, 310, 10, 21, 11, 7, 153, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 107, 20, 28, 22, 13, 52, 76, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 85, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 230, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 35, 56, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 190, 0, 80, 921, 103, 110, 18, 195, 2749, 1070, 4050, 582, 8634, 568, 8, 30, 114, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8952, 286, 50, 2, 18, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 2357, 44, 11, 6, 17, 0, 370, 43, 1301, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42717, 35, 4148, 12, 221, 3, 5761, 15, 7472, 3104, 541, 1507, 4938]; +const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 154, 10, 176, 2, 54, 14, 32, 9, 16, 3, 46, 10, 54, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 19306, 9, 135, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 5319, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 262, 6, 10, 9, 419, 13, 1495, 6, 110, 6, 6, 9, 4759, 9, 787719, 239]; + +function isInAstralSet(code, set) { + let pos = 0x10000; + + for (let i = 0, length = set.length; i < length; i += 2) { + pos += set[i]; + if (pos > code) return false; + pos += set[i + 1]; + if (pos >= code) return true; + } + + return false; +} + +function isIdentifierStart(code) { + if (code < 65) return code === 36; + if (code <= 90) return true; + if (code < 97) return code === 95; + if (code <= 122) return true; + + if (code <= 0xffff) { + return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)); + } + + return isInAstralSet(code, astralIdentifierStartCodes); +} + +function isIdentifierChar(code) { + if (code < 48) return code === 36; + if (code < 58) return true; + if (code < 65) return false; + if (code <= 90) return true; + if (code < 97) return code === 95; + if (code <= 122) return true; + + if (code <= 0xffff) { + return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)); + } + + return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes); +} + +function isIdentifierName(name) { + let isFirst = true; + + for (let _i = 0, _Array$from = Array.from(name); _i < _Array$from.length; _i++) { + const char = _Array$from[_i]; + const cp = char.codePointAt(0); + + if (isFirst) { + if (!isIdentifierStart(cp)) { + return false; + } + + isFirst = false; + } else if (!isIdentifierChar(cp)) { + return false; + } + } + + return true; +} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/lib/index.js b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/lib/index.js new file mode 100644 index 00000000000000..7b623c90a6e164 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/lib/index.js @@ -0,0 +1,57 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "isIdentifierName", { + enumerable: true, + get: function () { + return _identifier.isIdentifierName; + } +}); +Object.defineProperty(exports, "isIdentifierChar", { + enumerable: true, + get: function () { + return _identifier.isIdentifierChar; + } +}); +Object.defineProperty(exports, "isIdentifierStart", { + enumerable: true, + get: function () { + return _identifier.isIdentifierStart; + } +}); +Object.defineProperty(exports, "isReservedWord", { + enumerable: true, + get: function () { + return _keyword.isReservedWord; + } +}); +Object.defineProperty(exports, "isStrictBindOnlyReservedWord", { + enumerable: true, + get: function () { + return _keyword.isStrictBindOnlyReservedWord; + } +}); +Object.defineProperty(exports, "isStrictBindReservedWord", { + enumerable: true, + get: function () { + return _keyword.isStrictBindReservedWord; + } +}); +Object.defineProperty(exports, "isStrictReservedWord", { + enumerable: true, + get: function () { + return _keyword.isStrictReservedWord; + } +}); +Object.defineProperty(exports, "isKeyword", { + enumerable: true, + get: function () { + return _keyword.isKeyword; + } +}); + +var _identifier = require("./identifier"); + +var _keyword = require("./keyword"); \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/lib/keyword.js b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/lib/keyword.js new file mode 100644 index 00000000000000..110cee4002896b --- /dev/null +++ b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/lib/keyword.js @@ -0,0 +1,38 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.isReservedWord = isReservedWord; +exports.isStrictReservedWord = isStrictReservedWord; +exports.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord; +exports.isStrictBindReservedWord = isStrictBindReservedWord; +exports.isKeyword = isKeyword; +const reservedWords = { + keyword: ["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"], + strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"], + strictBind: ["eval", "arguments"] +}; +const keywords = new Set(reservedWords.keyword); +const reservedWordsStrictSet = new Set(reservedWords.strict); +const reservedWordsStrictBindSet = new Set(reservedWords.strictBind); + +function isReservedWord(word, inModule) { + return inModule && word === "await" || word === "enum"; +} + +function isStrictReservedWord(word, inModule) { + return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word); +} + +function isStrictBindOnlyReservedWord(word) { + return reservedWordsStrictBindSet.has(word); +} + +function isStrictBindReservedWord(word, inModule) { + return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word); +} + +function isKeyword(word) { + return keywords.has(word); +} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/package.json b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/package.json new file mode 100644 index 00000000000000..bdc69e6c6f8926 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/package.json @@ -0,0 +1,22 @@ +{ + "bundleDependencies": false, + "deprecated": false, + "description": "Validate identifier/keywords name", + "devDependencies": { + "charcodes": "^0.2.0", + "unicode-13.0.0": "^0.8.0" + }, + "exports": "./lib/index.js", + "gitHead": "8d5e422be27251cfaadf8dd2536b31b4a5024b02", + "license": "MIT", + "main": "./lib/index.js", + "name": "@babel/helper-validator-identifier", + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/babel/babel/tree/master/packages/babel-helper-validator-identifier" + }, + "version": "7.9.0" +} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/scripts/generate-identifier-regex.js b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/scripts/generate-identifier-regex.js new file mode 100644 index 00000000000000..e0f5b1656b97de --- /dev/null +++ b/tools/node_modules/eslint/node_modules/@babel/helper-validator-identifier/scripts/generate-identifier-regex.js @@ -0,0 +1,75 @@ +"use strict"; + +// Always use the latest available version of Unicode! +// https://tc39.github.io/ecma262/#sec-conformance +const version = "13.0.0"; + +const start = require("unicode-" + + version + + "/Binary_Property/ID_Start/code-points.js").filter(function(ch) { + return ch > 0x7f; +}); +let last = -1; +const cont = [0x200c, 0x200d].concat( + require("unicode-" + + version + + "/Binary_Property/ID_Continue/code-points.js").filter(function(ch) { + return ch > 0x7f && search(start, ch, last + 1) == -1; + }) +); + +function search(arr, ch, starting) { + for (let i = starting; arr[i] <= ch && i < arr.length; last = i++) { + if (arr[i] === ch) return i; + } + return -1; +} + +function pad(str, width) { + while (str.length < width) str = "0" + str; + return str; +} + +function esc(code) { + const hex = code.toString(16); + if (hex.length <= 2) return "\\x" + pad(hex, 2); + else return "\\u" + pad(hex, 4); +} + +function generate(chars) { + const astral = []; + let re = ""; + for (let i = 0, at = 0x10000; i < chars.length; i++) { + const from = chars[i]; + let to = from; + while (i < chars.length - 1 && chars[i + 1] == to + 1) { + i++; + to++; + } + if (to <= 0xffff) { + if (from == to) re += esc(from); + else if (from + 1 == to) re += esc(from) + esc(to); + else re += esc(from) + "-" + esc(to); + } else { + astral.push(from - at, to - from); + at = to; + } + } + return { nonASCII: re, astral: astral }; +} + +const startData = generate(start); +const contData = generate(cont); + +console.log("/* prettier-ignore */"); +console.log('let nonASCIIidentifierStartChars = "' + startData.nonASCII + '";'); +console.log("/* prettier-ignore */"); +console.log('let nonASCIIidentifierChars = "' + contData.nonASCII + '";'); +console.log("/* prettier-ignore */"); +console.log( + "const astralIdentifierStartCodes = " + JSON.stringify(startData.astral) + ";" +); +console.log("/* prettier-ignore */"); +console.log( + "const astralIdentifierCodes = " + JSON.stringify(contData.astral) + ";" +); diff --git a/tools/node_modules/eslint/node_modules/@babel/highlight/lib/index.js b/tools/node_modules/eslint/node_modules/@babel/highlight/lib/index.js index 6ac5b4a350b8e6..b0d1be7f553b64 100644 --- a/tools/node_modules/eslint/node_modules/@babel/highlight/lib/index.js +++ b/tools/node_modules/eslint/node_modules/@babel/highlight/lib/index.js @@ -7,39 +7,17 @@ exports.shouldHighlight = shouldHighlight; exports.getChalk = getChalk; exports.default = highlight; -function _jsTokens() { - const data = _interopRequireWildcard(require("js-tokens")); +var _jsTokens = _interopRequireWildcard(require("js-tokens")); - _jsTokens = function () { - return data; - }; - - return data; -} - -function _esutils() { - const data = _interopRequireDefault(require("esutils")); +var _helperValidatorIdentifier = require("@babel/helper-validator-identifier"); - _esutils = function () { - return data; - }; - - return data; -} - -function _chalk() { - const data = _interopRequireDefault(require("chalk")); - - _chalk = function () { - return data; - }; - - return data; -} +var _chalk = _interopRequireDefault(require("chalk")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function getDefs(chalk) { return { @@ -61,10 +39,10 @@ const BRACKET = /^[()[\]{}]$/; function getTokenType(match) { const [offset, text] = match.slice(-2); - const token = (0, _jsTokens().matchToToken)(match); + const token = (0, _jsTokens.matchToToken)(match); if (token.type === "name") { - if (_esutils().default.keyword.isReservedWordES6(token.value)) { + if ((0, _helperValidatorIdentifier.isKeyword)(token.value) || (0, _helperValidatorIdentifier.isReservedWord)(token.value)) { return "keyword"; } @@ -89,7 +67,7 @@ function getTokenType(match) { } function highlightTokens(defs, text) { - return text.replace(_jsTokens().default, function (...args) { + return text.replace(_jsTokens.default, function (...args) { const type = getTokenType(args); const colorize = defs[type]; @@ -102,14 +80,14 @@ function highlightTokens(defs, text) { } function shouldHighlight(options) { - return _chalk().default.supportsColor || options.forceColor; + return _chalk.default.supportsColor || options.forceColor; } function getChalk(options) { - let chalk = _chalk().default; + let chalk = _chalk.default; if (options.forceColor) { - chalk = new (_chalk().default.constructor)({ + chalk = new _chalk.default.constructor({ enabled: true, level: 1 }); diff --git a/tools/node_modules/eslint/node_modules/chalk/index.js b/tools/node_modules/eslint/node_modules/@babel/highlight/node_modules/chalk/index.js similarity index 100% rename from tools/node_modules/eslint/node_modules/chalk/index.js rename to tools/node_modules/eslint/node_modules/@babel/highlight/node_modules/chalk/index.js diff --git a/tools/node_modules/eslint/node_modules/chalk/index.js.flow b/tools/node_modules/eslint/node_modules/@babel/highlight/node_modules/chalk/index.js.flow similarity index 100% rename from tools/node_modules/eslint/node_modules/chalk/index.js.flow rename to tools/node_modules/eslint/node_modules/@babel/highlight/node_modules/chalk/index.js.flow diff --git a/tools/node_modules/eslint/node_modules/string-width/node_modules/strip-ansi/license b/tools/node_modules/eslint/node_modules/@babel/highlight/node_modules/chalk/license similarity index 100% rename from tools/node_modules/eslint/node_modules/string-width/node_modules/strip-ansi/license rename to tools/node_modules/eslint/node_modules/@babel/highlight/node_modules/chalk/license diff --git a/tools/node_modules/eslint/node_modules/@babel/highlight/node_modules/chalk/package.json b/tools/node_modules/eslint/node_modules/@babel/highlight/node_modules/chalk/package.json new file mode 100644 index 00000000000000..270fecdc347d42 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/@babel/highlight/node_modules/chalk/package.json @@ -0,0 +1,80 @@ +{ + "bugs": { + "url": "https://github.com/chalk/chalk/issues" + }, + "bundleDependencies": false, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "deprecated": false, + "description": "Terminal string styling done right", + "devDependencies": { + "ava": "*", + "coveralls": "^3.0.0", + "execa": "^0.9.0", + "flow-bin": "^0.68.0", + "import-fresh": "^2.0.0", + "matcha": "^0.7.0", + "nyc": "^11.0.2", + "resolve-from": "^4.0.0", + "typescript": "^2.5.3", + "xo": "*" + }, + "engines": { + "node": ">=4" + }, + "files": [ + "index.js", + "templates.js", + "types/index.d.ts", + "index.js.flow" + ], + "homepage": "https://github.com/chalk/chalk#readme", + "keywords": [ + "color", + "colour", + "colors", + "terminal", + "console", + "cli", + "string", + "str", + "ansi", + "style", + "styles", + "tty", + "formatting", + "rgb", + "256", + "shell", + "xterm", + "log", + "logging", + "command-line", + "text" + ], + "license": "MIT", + "name": "chalk", + "repository": { + "type": "git", + "url": "git+https://github.com/chalk/chalk.git" + }, + "scripts": { + "bench": "matcha benchmark.js", + "coveralls": "nyc report --reporter=text-lcov | coveralls", + "test": "xo && tsc --project types && flow --max-warnings=0 && nyc ava" + }, + "types": "types/index.d.ts", + "version": "2.4.2", + "xo": { + "envs": [ + "node", + "mocha" + ], + "ignores": [ + "test/_flow.js" + ] + } +} \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/@babel/highlight/node_modules/chalk/readme.md b/tools/node_modules/eslint/node_modules/@babel/highlight/node_modules/chalk/readme.md new file mode 100644 index 00000000000000..d298e2c48d64a0 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/@babel/highlight/node_modules/chalk/readme.md @@ -0,0 +1,314 @@ +

+
+
+ Chalk +
+
+
+

+ +> Terminal string styling done right + +[![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk) [![Coverage Status](https://coveralls.io/repos/github/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/github/chalk/chalk?branch=master) [![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) [![Mentioned in Awesome Node.js](https://awesome.re/mentioned-badge.svg)](https://github.com/sindresorhus/awesome-nodejs) + +### [See what's new in Chalk 2](https://github.com/chalk/chalk/releases/tag/v2.0.0) + + + + +## Highlights + +- Expressive API +- Highly performant +- Ability to nest styles +- [256/Truecolor color support](#256-and-truecolor-color-support) +- Auto-detects color support +- Doesn't extend `String.prototype` +- Clean and focused +- Actively maintained +- [Used by ~23,000 packages](https://www.npmjs.com/browse/depended/chalk) as of December 31, 2017 + + +## Install + +```console +$ npm install chalk +``` + + + + + + +## Usage + +```js +const chalk = require('chalk'); + +console.log(chalk.blue('Hello world!')); +``` + +Chalk comes with an easy to use composable API where you just chain and nest the styles you want. + +```js +const chalk = require('chalk'); +const log = console.log; + +// Combine styled and normal strings +log(chalk.blue('Hello') + ' World' + chalk.red('!')); + +// Compose multiple styles using the chainable API +log(chalk.blue.bgRed.bold('Hello world!')); + +// Pass in multiple arguments +log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz')); + +// Nest styles +log(chalk.red('Hello', chalk.underline.bgBlue('world') + '!')); + +// Nest styles of the same type even (color, underline, background) +log(chalk.green( + 'I am a green line ' + + chalk.blue.underline.bold('with a blue substring') + + ' that becomes green again!' +)); + +// ES2015 template literal +log(` +CPU: ${chalk.red('90%')} +RAM: ${chalk.green('40%')} +DISK: ${chalk.yellow('70%')} +`); + +// ES2015 tagged template literal +log(chalk` +CPU: {red ${cpu.totalPercent}%} +RAM: {green ${ram.used / ram.total * 100}%} +DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%} +`); + +// Use RGB colors in terminal emulators that support it. +log(chalk.keyword('orange')('Yay for orange colored text!')); +log(chalk.rgb(123, 45, 67).underline('Underlined reddish color')); +log(chalk.hex('#DEADED').bold('Bold gray!')); +``` + +Easily define your own themes: + +```js +const chalk = require('chalk'); + +const error = chalk.bold.red; +const warning = chalk.keyword('orange'); + +console.log(error('Error!')); +console.log(warning('Warning!')); +``` + +Take advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args): + +```js +const name = 'Sindre'; +console.log(chalk.green('Hello %s'), name); +//=> 'Hello Sindre' +``` + + +## API + +### chalk.`