diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index bbb1fd0adc5..15936e05aa9 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -35,7 +35,6 @@ # net -/deps/ada @nodejs/url /deps/cares @nodejs/net /doc/api/dgram.md @nodejs/net /doc/api/dns.md @nodejs/net @@ -47,14 +46,11 @@ /lib/internal/js_stream_socket.js @nodejs/net /lib/internal/net.js @nodejs/net /lib/internal/socket_list.js @nodejs/net -/lib/internal/url.js @nodejs/url /lib/net.js @nodejs/net -/lib/url.js @nodejs/url /src/cares_wrap.cc @nodejs/net /src/connect_wrap.* @nodejs/net /src/connection_wrap.* @nodejs/net /src/node_sockaddr* @nodejs/net -/src/node_url.* @nodejs/url /src/tcp_wrap.* @nodejs/net /src/udp_wrap.* @nodejs/net @@ -186,3 +182,10 @@ /lib/internal/navigator.js @nodejs/web-standards /test/fixtures/wpt/ @nodejs/web-standards /test/wpt/ @nodejs/web-standards + +# URL +/deps/ada @nodejs/url +/lib/internal/url.js @nodejs/url +/lib/url.js @nodejs/url +/src/node_url.* @nodejs/url +/test/fixtures/wpt/url @nodejs/url diff --git a/.github/workflows/auto-start-ci.yml b/.github/workflows/auto-start-ci.yml index 3703a28abbc..2588bc82da3 100644 --- a/.github/workflows/auto-start-ci.yml +++ b/.github/workflows/auto-start-ci.yml @@ -50,7 +50,7 @@ jobs: persist-credentials: false - name: Install Node.js - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: ${{ env.NODE_VERSION }} diff --git a/.github/workflows/build-tarball.yml b/.github/workflows/build-tarball.yml index 0c739387641..14121a09cc4 100644 --- a/.github/workflows/build-tarball.yml +++ b/.github/workflows/build-tarball.yml @@ -46,7 +46,7 @@ jobs: with: persist-credentials: false - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0 + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: python-version: ${{ env.PYTHON_VERSION }} - name: Set up sccache @@ -76,7 +76,7 @@ jobs: with: persist-credentials: false - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0 + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: python-version: ${{ env.PYTHON_VERSION }} - name: Set up sccache @@ -86,7 +86,7 @@ jobs: - name: Environment Information run: npx envinfo - name: Download tarball - uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1 + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 with: name: tarballs path: tarballs diff --git a/.github/workflows/close-stale-feature-requests.yml b/.github/workflows/close-stale-feature-requests.yml index 301dbff620c..17bac3b83f5 100644 --- a/.github/workflows/close-stale-feature-requests.yml +++ b/.github/workflows/close-stale-feature-requests.yml @@ -41,7 +41,7 @@ jobs: if: github.repository == 'nodejs/node' runs-on: ubuntu-latest steps: - - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0 + - uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0 with: repo-token: ${{ secrets.GITHUB_TOKEN }} days-before-stale: 180 diff --git a/.github/workflows/close-stalled.yml b/.github/workflows/close-stalled.yml index 7ece19e2e2d..6bf526baf01 100644 --- a/.github/workflows/close-stalled.yml +++ b/.github/workflows/close-stalled.yml @@ -20,7 +20,7 @@ jobs: if: github.repository == 'nodejs/node' runs-on: ubuntu-latest steps: - - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0 + - uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0 with: repo-token: ${{ secrets.GITHUB_TOKEN }} days-before-close: 30 diff --git a/.github/workflows/commit-lint.yml b/.github/workflows/commit-lint.yml index 1eb5622358e..4cd44c6d185 100644 --- a/.github/workflows/commit-lint.yml +++ b/.github/workflows/commit-lint.yml @@ -23,7 +23,7 @@ jobs: persist-credentials: false - run: git reset HEAD^2 - name: Install Node.js - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: ${{ env.NODE_VERSION }} - name: Validate commit message diff --git a/.github/workflows/commit-queue.yml b/.github/workflows/commit-queue.yml index 3276e4ec793..498f60f0c92 100644 --- a/.github/workflows/commit-queue.yml +++ b/.github/workflows/commit-queue.yml @@ -72,7 +72,7 @@ jobs: # Install dependencies - name: Install Node.js - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: ${{ env.NODE_VERSION }} - name: Install @node-core/utils diff --git a/.github/workflows/coverage-linux-without-intl.yml b/.github/workflows/coverage-linux-without-intl.yml index 99295a96764..23b7a3fc7cd 100644 --- a/.github/workflows/coverage-linux-without-intl.yml +++ b/.github/workflows/coverage-linux-without-intl.yml @@ -47,14 +47,15 @@ permissions: jobs: coverage-linux-without-intl: - if: github.event.pull_request.draft == false + # Disabled because "Report JS" step was crashing. + if: false runs-on: ubuntu-24.04 steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0 + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: python-version: ${{ env.PYTHON_VERSION }} - name: Set up sccache @@ -77,6 +78,6 @@ jobs: - name: Clean tmp run: rm -rf coverage/tmp && rm -rf out - name: Upload - uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5.4.0 + uses: codecov/codecov-action@39a2af19d997be74586469d4062e173ecae614f6 # v5.4.3+ with: directory: ./coverage diff --git a/.github/workflows/coverage-linux.yml b/.github/workflows/coverage-linux.yml index 06013222037..8b85c2946cd 100644 --- a/.github/workflows/coverage-linux.yml +++ b/.github/workflows/coverage-linux.yml @@ -47,14 +47,15 @@ permissions: jobs: coverage-linux: - if: github.event.pull_request.draft == false + # Disabled because "Report JS" step was crashing. + if: false runs-on: ubuntu-24.04 steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0 + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: python-version: ${{ env.PYTHON_VERSION }} - name: Set up sccache @@ -77,6 +78,6 @@ jobs: - name: Clean tmp run: rm -rf coverage/tmp && rm -rf out - name: Upload - uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5.4.0 + uses: codecov/codecov-action@39a2af19d997be74586469d4062e173ecae614f6 # v5.4.3+ with: directory: ./coverage diff --git a/.github/workflows/coverage-windows.yml b/.github/workflows/coverage-windows.yml index dd28730657e..8d41809b395 100644 --- a/.github/workflows/coverage-windows.yml +++ b/.github/workflows/coverage-windows.yml @@ -51,7 +51,7 @@ jobs: with: persist-credentials: false - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: python-version: ${{ env.PYTHON_VERSION }} - name: Install deps @@ -73,6 +73,6 @@ jobs: - name: Clean tmp run: npx rimraf ./coverage/tmp - name: Upload - uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7 + uses: codecov/codecov-action@39a2af19d997be74586469d4062e173ecae614f6 # v5.4.3+ with: directory: ./coverage diff --git a/.github/workflows/create-release-proposal.yml b/.github/workflows/create-release-proposal.yml index 0b580eab81a..58cf5a0bba5 100644 --- a/.github/workflows/create-release-proposal.yml +++ b/.github/workflows/create-release-proposal.yml @@ -40,7 +40,7 @@ jobs: # Install dependencies - name: Install Node.js - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: ${{ env.NODE_VERSION }} diff --git a/.github/workflows/daily-wpt-fyi.yml b/.github/workflows/daily-wpt-fyi.yml index ebac102f63e..3cc6e6c54cd 100644 --- a/.github/workflows/daily-wpt-fyi.yml +++ b/.github/workflows/daily-wpt-fyi.yml @@ -39,7 +39,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: python-version: ${{ env.PYTHON_VERSION }} - name: Environment Information @@ -51,7 +51,7 @@ jobs: run: echo "NIGHTLY=$(curl -s https://nodejs.org/download/nightly/index.json | jq -r '[.[] | select(.files[] | contains("linux-x64"))][0].version')" >> $GITHUB_ENV - name: Install Node.js id: setup-node - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: ${{ env.NIGHTLY || matrix.node-version }} check-latest: true @@ -127,7 +127,7 @@ jobs: run: cp wptreport.json wptreport-${{ steps.setup-node.outputs.node-version }}.json - name: Upload GitHub Actions artifact if: ${{ env.WPT_REPORT != '' }} - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: path: out/wpt/wptreport-*.json name: WPT Report for ${{ steps.setup-node.outputs.node-version }} diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index e929e8168b0..ae2b7a577f7 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -19,7 +19,7 @@ jobs: with: persist-credentials: false - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: ${{ env.NODE_VERSION }} - name: Environment Information diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 6bf6254abf3..481224e670a 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -28,14 +28,14 @@ jobs: with: persist-credentials: false - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: ${{ env.NODE_VERSION }} - name: Environment Information run: npx envinfo - name: Build run: NODE=$(command -v node) make doc-only - - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: docs path: out/doc diff --git a/.github/workflows/find-inactive-collaborators.yml b/.github/workflows/find-inactive-collaborators.yml index 30ae63ee115..269bc2db172 100644 --- a/.github/workflows/find-inactive-collaborators.yml +++ b/.github/workflows/find-inactive-collaborators.yml @@ -25,7 +25,7 @@ jobs: persist-credentials: false - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: ${{ env.NODE_VERSION }} diff --git a/.github/workflows/find-inactive-tsc.yml b/.github/workflows/find-inactive-tsc.yml index 85c16ad0648..9e294994ba8 100644 --- a/.github/workflows/find-inactive-tsc.yml +++ b/.github/workflows/find-inactive-tsc.yml @@ -34,7 +34,7 @@ jobs: repository: nodejs/TSC - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: ${{ env.NODE_VERSION }} diff --git a/.github/workflows/notify-on-push.yml b/.github/workflows/notify-on-push.yml index 14b184deb51..a05738f0c5d 100644 --- a/.github/workflows/notify-on-push.yml +++ b/.github/workflows/notify-on-push.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Slack Notification - uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 # 2.3.2 + uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # 2.3.3 env: SLACK_COLOR: '#DE512A' SLACK_ICON: https://github.com/nodejs.png?size=48 @@ -56,7 +56,7 @@ jobs: GH_TOKEN: ${{ github.token }} - name: Slack Notification if: ${{ env.INVALID_COMMIT_MESSAGE }} - uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 # 2.3.2 + uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # 2.3.3 env: SLACK_COLOR: '#DE512A' SLACK_ICON: https://github.com/nodejs.png?size=48 diff --git a/.github/workflows/notify-on-review-wanted.yml b/.github/workflows/notify-on-review-wanted.yml index b4e3490f31f..96eee3096d8 100644 --- a/.github/workflows/notify-on-review-wanted.yml +++ b/.github/workflows/notify-on-review-wanted.yml @@ -33,7 +33,7 @@ jobs: fi - name: Slack Notification - uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 # 2.3.2 + uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # 2.3.3 env: MSG_MINIMAL: actions url SLACK_COLOR: '#3d85c6' diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 75c67cc238d..45a5ab30e74 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -33,7 +33,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + uses: step-security/harden-runner@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2 with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs @@ -43,7 +43,7 @@ jobs: persist-credentials: false - name: Run analysis - uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0 + uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2 with: results_file: results.sarif results_format: sarif @@ -65,7 +65,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: Upload artifact - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: SARIF file path: results.sarif @@ -73,6 +73,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: Upload to code-scanning - uses: github/codeql-action/upload-sarif@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5 + uses: github/codeql-action/upload-sarif@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2 with: sarif_file: results.sarif diff --git a/.github/workflows/test-internet.yml b/.github/workflows/test-internet.yml index eced01cfbda..7d25113c024 100644 --- a/.github/workflows/test-internet.yml +++ b/.github/workflows/test-internet.yml @@ -48,7 +48,7 @@ jobs: with: persist-credentials: false - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: python-version: ${{ env.PYTHON_VERSION }} - name: Environment Information diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index 6e8ff1fd649..bd8569c8dc6 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -3,6 +3,7 @@ name: Test Linux on: pull_request: paths-ignore: + - .mailmap - README.md - .github/** - '!.github/workflows/test-linux.yml' @@ -14,6 +15,7 @@ on: - v[0-9]+.x-staging - v[0-9]+.x paths-ignore: + - .mailmap - README.md - .github/** - '!.github/workflows/test-linux.yml' @@ -41,7 +43,7 @@ jobs: with: persist-credentials: false - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0 + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: python-version: ${{ env.PYTHON_VERSION }} - name: Set up sccache diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml index 285d67bdb85..969b73e0c3a 100644 --- a/.github/workflows/test-macos.yml +++ b/.github/workflows/test-macos.yml @@ -52,7 +52,7 @@ jobs: with: persist-credentials: false - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: python-version: ${{ env.PYTHON_VERSION }} - name: Set up sccache diff --git a/.github/workflows/tools.yml b/.github/workflows/tools.yml index c4bf9d16151..7ec9da38630 100644 --- a/.github/workflows/tools.yml +++ b/.github/workflows/tools.yml @@ -298,7 +298,7 @@ jobs: persist-credentials: false - name: Set up Python ${{ env.PYTHON_VERSION }} if: matrix.id == 'icu' && (github.event_name == 'schedule' || inputs.id == 'all' || inputs.id == matrix.id) - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: python-version: ${{ env.PYTHON_VERSION }} - run: ${{ matrix.run }} @@ -309,7 +309,7 @@ jobs: if: env.COMMIT_MSG == '' && (github.event_name == 'schedule' || inputs.id == 'all' || inputs.id == matrix.id) run: | echo "COMMIT_MSG=${{ matrix.subsystem }}: update ${{ matrix.id }} to ${{ env.NEW_VERSION }}" >> "$GITHUB_ENV" - - uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5 + - uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 if: github.event_name == 'schedule' || inputs.id == 'all' || inputs.id == matrix.id # Creates a PR or update the Action's existing PR, or # no-op if the base branch is already up-to-date. diff --git a/.github/workflows/update-v8.yml b/.github/workflows/update-v8.yml index 2d28ae5d602..70977609d29 100644 --- a/.github/workflows/update-v8.yml +++ b/.github/workflows/update-v8.yml @@ -20,7 +20,7 @@ jobs: with: persist-credentials: false - name: Cache node modules and update-v8 - uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 id: cache-v8-npm env: cache-name: cache-v8-npm @@ -30,7 +30,7 @@ jobs: ~/.npm key: ${{ runner.os }}-build-${{ env.cache-name }} - name: Install Node.js - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: ${{ env.NODE_VERSION }} - name: Install @node-core/utils @@ -45,7 +45,7 @@ jobs: cat temp-output tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true rm temp-output - - uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5 + - uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 # Creates a PR or update the Action's existing PR, or # no-op if the base branch is already up-to-date. with: diff --git a/.github/workflows/update-wpt.yml b/.github/workflows/update-wpt.yml index 72ec030e9d6..aba9b274120 100644 --- a/.github/workflows/update-wpt.yml +++ b/.github/workflows/update-wpt.yml @@ -32,7 +32,7 @@ jobs: persist-credentials: false - name: Install Node.js - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: ${{ env.NODE_VERSION }} diff --git a/.mailmap b/.mailmap index c197dd83e27..ec877b4c767 100644 --- a/.mailmap +++ b/.mailmap @@ -204,6 +204,7 @@ George Adams Gerhard Stöbich Gibson Fahnestock Gil Pedersen +Giovanni Bucci Graham Fairweather Greg Sabia Tucker Gregor Martynus @@ -240,7 +241,8 @@ James Ide James M Snell James Nimlos James Sumners -Jan Krems +Jan Martin +Jan Martin Jem Bezooyen Jem Bezooyen Jenna Vuong @@ -269,6 +271,7 @@ John McGuirk John Musgrave Johnny Ray Austin Jon Tippens +Jonas Badalic Jonas Pfenniger Jonathan Gourlay Jonathan Ong diff --git a/CHANGELOG.md b/CHANGELOG.md index b19299d2e56..a561912c77d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,7 +35,8 @@ release. -20.19.4
+20.19.5
+20.19.4
20.19.3
20.19.2
20.19.1
diff --git a/GOVERNANCE.md b/GOVERNANCE.md index 382b6391956..b100b58701f 100644 --- a/GOVERNANCE.md +++ b/GOVERNANCE.md @@ -148,10 +148,71 @@ Contributions can be: * Participation in other projects, teams, and working groups of the Node.js organization. +Collaborators should be people volunteering to do unglamorous work because it's +the right thing to do, they find the work itself satisfying, and they care about +Node.js and its users. People should get collaborator status because they're +doing work and are likely to continue doing work where having the abilities that +come with collaborator status are helpful (abilities like starting CI jobs, +reviewing and approving PRs, etc.). That will usually--but, very importantly, not +always--be work involving committing to the `nodejs/node` repository. For an example +of an exception, someone working primarily on the website might benefit from being +able to start Jenkins CI jobs to test changes to documentation tooling. That, +along with signals indicating commitment to Node.js, personal integrity, etc., +should be enough for a successful nomination. + +It is important to understand that potential collaborators may have vastly +different areas and levels of expertise, interest, and skill. The Node.js +project is large and complex, and it is not expected that every collaborator +will have the same level of expertise in every area of the project. The +complexity or "sophistication" of an individual’s contributions, or even their +relative engineering "skill" level, are not primary factors in determining +whether they should be a collaborator. The primary factors do include the quality +of their contributions (do the contributions make sense, do they add value, do +they follow documented guidelines, are they authentic and well-intentioned, +etc.), their commitment to the project, can their judgement be trusted, and do +they have the ability to work well with others. + +#### The Authenticity of Contributors + +The Node.js project does not require that contributors use their legal names or +provide any personal information verifying their identity. + +It is not uncommon for malicious actors to attempt to gain commit access to +open-source projects in order to inject malicious code or for other nefarious +purposes. The Node.js project has a number of mechanisms in place to prevent +this, but it is important to be vigilant. If you have concerns about the +authenticity of a contributor, please raise them with the TSC. Anyone nominating +a new collaborator should take reasonable steps to verify that the contributions +of the nominee are authentic and made in good faith. This is not always easy, +but it is important. + ### Nominating a new Collaborator -To nominate a new Collaborator, open an issue in the [nodejs/node][] repository. -Provide a summary of the nominee's contributions. For example: +To nominate a new Collaborator: + +1. **Optional but strongly recommended**: open a + [discussion in the nodejs/collaborators][] repository. Provide a summary of + the nominee's contributions (see below for an example). +2. **Optional but strongly recommended**: After sufficient wait time (e.g. 72 + hours), if the nomination proposal has received some support and no explicit + block, and any questions/concerns have been addressed, add a comment in the + private discussion stating you're planning on opening a public issue, e.g. + "I see a number of approvals and no block, I'll be opening a public + nomination issue if I don't hear any objections in the next 72 hours". +3. **Optional but strongly recommended**: Privately contact the nominee to make + sure they're comfortable with the nomination. +4. Open an issue in the [nodejs/node][] repository. Provide a summary of + the nominee's contributions (see below for an example). Mention + @nodejs/collaborators in the issue to notify other collaborators about + the nomination. + +The _Optional but strongly recommended_ steps are optional in the sense that +skipping them would not invalidate the nomination, but it could put the nominee +in a very awkward situation if a nomination they didn't ask for pops out of +nowhere only to be rejected. Do not skip those steps unless you're absolutely +certain the nominee is fine with the public scrutiny. + +Example of list of contributions: * Commits in the [nodejs/node][] repository. * Use the link `https://github.com/nodejs/node/commits?author=GITHUB_ID` @@ -170,22 +231,93 @@ Provide a summary of the nominee's contributions. For example: organization * Other participation in the wider Node.js community -Mention @nodejs/collaborators in the issue to notify other collaborators about -the nomination. - -The nomination passes if no collaborators oppose it after one week. In the case -of an objection, the TSC is responsible for working with the individuals -involved and finding a resolution. - -There are steps a nominator can take in advance to make a nomination as -frictionless as possible. To request feedback from other collaborators in -private, use the [collaborators discussion page][] -(which only collaborators may view). A nominator may also work with the -nominee to improve their contribution profile. - -Collaborators might overlook someone with valuable contributions. In that case, -the contributor may open an issue or contact a collaborator to request a -nomination. +The nomination passes if no collaborators oppose it (as described in the +following section) after one week. In the case of an objection, the TSC is +responsible for working with the individuals involved and finding a resolution. +The TSC may, following typical TSC consensus seeking processes, choose to +advance a nomination that has otherwise failed to reach a natural consensus or +clear path forward even if there are outstanding objections. The TSC may also +choose to prevent a nomination from advancing if the TSC determines that any +objections have not been adequately addressed. + +#### How to review a collaborator nomination + +A collaborator nomination can be reviewed in the same way one would review a PR +adding a feature: + +* If you see the nomination as something positive to the project, say so! +* If you are neutral, or feel you don't know enough to have an informed opinion, + it's certainly OK to not interact with the nomination. +* If you think the nomination was made too soon, or can be detrimental to the + project, share your concerns. See the section "How to oppose a collaborator + nomination" below. + +Our goal is to keep gate-keeping at a minimal, but it cannot be zero since being +a collaborator requires trust (collaborators can start CI jobs, use their veto, +push commits, etc.), so what's the minimal amount is subjective, and there will +be cases where collaborators disagree on whether a nomination should move +forward. + +Refrain from discussing or debating aspects of the nomination process +itself directly within a nomination private discussion or public issue. +Such discussions can derail and frustrate the nomination causing unnecessary +friction. Move such discussions to a separate issue or discussion thread. + +##### How to oppose a collaborator nomination + +An important rule of thumb is that the nomination process is intended to be +biased strongly towards implicit approval of the nomination. This means +discussion and review around the proposal should be more geared towards "I have +reasons to say no..." as opposed to "Give me reasons to say yes...". + +Given that there is no "Request for changes" feature in discussions and issues, +try to be explicit when your comment is expressing a blocking concern. +Similarly, once the blocking concern has been addressed, explicitly say so. + +Explicit opposition would typically be signaled as some form of clear +and unambiguous comment like, "I don't believe this nomination should pass". +Asking clarifying questions or expressing general concerns is not the same as +explicit opposition; however, a best effort should be made to answer such +questions or addressing those concerns before advancing the nomination. + +Opposition does not need to be public. Ideally, the comment showing opposition, +and any discussion thereof, should be done in the private discussion _before_ +the public issue is opened. Opposition _should_ be paired with clear suggestions +for positive, concrete, and unambiguous next steps that the nominee can take to +overcome the objection and allow it to move forward. While such suggestions are +technically optional, they are _strongly encouraged_ to prevent the nomination +from stalling indefinitely or objections from being overridden by the TSC. + +Remember that all private discussions about a nomination will be visible to +the nominee once they are onboarded. + +#### How to review a collaborator nomination + +A collaborator nomination can be reviewed in the same way one would review a PR +adding a feature: + +* If you see the nomination as something positive to the project, say so! +* If you are neutral, or feel you don't know enough to have an informed opinion, + it's certainly OK to not interact with the nomination. +* If you think the nomination was made too soon, or can be detrimental to the + project, share your concerns, ideally before the public nomination is opened, + and avoid sharing those concerns outside of the Collaborator discussion area. + Ideally, list what step(s) the nominee could take that would make you + approve their nomination. + Given that there is no "Request for changes" feature in discussions and issues, + try to be explicit when your comment is expressing a blocking concern. + Similarly, once the blocking concern has been addressed, explicitly say so. + +Our goal is to keep gate-keeping at a minimal, but it cannot be zero since being +a collaborator requires trust (collaborators can start CI jobs, use their veto, +push commits, etc.), so what's the minimal amount is subjective, and there will +be cases where collaborators disagree on whether a nomination should move +forward. + +When concerns have been raised on the private discussion, refrain from opening +the public issue. If no one has explicitly blocked the nomination and you'd like +it to move forward, comment something like "If I don't hear any objections +before (some time), I will open the public issue". ### Onboarding @@ -200,6 +332,6 @@ The TSC follows a [Consensus Seeking][] decision-making model per the [Consensus Seeking]: https://en.wikipedia.org/wiki/Consensus-seeking_decision-making [TSC Charter]: https://github.com/nodejs/TSC/blob/HEAD/TSC-Charter.md -[collaborators discussion page]: https://github.com/nodejs/collaborators/discussions/categories/collaborator-nominations +[discussion in the nodejs/collaborators]: https://github.com/nodejs/collaborators/discussions/categories/collaborator-nominations [nodejs/help]: https://github.com/nodejs/help [nodejs/node]: https://github.com/nodejs/node diff --git a/Makefile b/Makefile index 237f9096b7b..085025424bb 100644 --- a/Makefile +++ b/Makefile @@ -1645,7 +1645,7 @@ test-agents-prereqs: env npm_config_nodedir=$(PWD) $(NODE) ./deps/npm install zeromq@5 base85 --prefix test/common/nsolid-zmq-agent --no-save --no-package-lock env npm_config_nodedir=$(PWD) $(NODE) ./deps/npm run build:libzmq --prefix test/common/nsolid-zmq-agent/node_modules/zeromq env npm_config_nodedir=$(PWD) $(NODE) ./deps/npm install @opentelemetry/otlp-proto-exporter-base @grpc/grpc-js @grpc/proto-loader --prefix test/common/nsolid-otlp-agent --no-save --no-package-lock - env npm_config_nodedir=$(PWD) $(NODE) ./deps/npm install @grpc/grpc-js @grpc/proto-loader@0.7 --prefix test/common/nsolid-grpc-agent --no-save --no-package-lock + env npm_config_nodedir=$(PWD) $(NODE) ./deps/npm install @grpc/grpc-js @grpc/proto-loader --prefix test/common/nsolid-grpc-agent --no-save --no-package-lock .PHONY: test-agents-prereqs-clean test-agents-prereqs-clean: diff --git a/agents/grpc/src/asset_stream.cc b/agents/grpc/src/asset_stream.cc index a9136e7e257..2d4f3e38354 100644 --- a/agents/grpc/src/asset_stream.cc +++ b/agents/grpc/src/asset_stream.cc @@ -1,6 +1,10 @@ #include "asset_stream.h" -#include "debug_utils-inl.h" + +#include + #include "asserts-cpp/asserts.h" +#include "grpc_utils.h" +#include "uv.h" using grpc::Status; using grpcagent::NSolidService; @@ -9,12 +13,6 @@ namespace node { namespace nsolid { namespace grpc { -template -inline void Debug(Args&&... args) { - per_process::Debug(DebugCategory::NSOLID_GRPC_AGENT, - std::forward(args)...); -} - AssetStream::AssetStream( NSolidService::StubInterface* stub, AssetStor&& stor, @@ -44,8 +42,21 @@ AssetStream::~AssetStream() { } void AssetStream::OnDone(const Status& s) { - if (!s.ok()) { - Debug("AssetStream::OnDone error: %d. %s:%s\n", + const bool debug_enabled = + per_process::enabled_debug_list.enabled(DebugCategory::NSOLID_GRPC_AGENT); + if (debug_enabled) { + uint64_t total_duration = 0; + if (stream_stats_.stream_start > 0) { + total_duration = uv_hrtime() - stream_stats_.stream_start; + } + + Debug("[AssetStream] completion status=%s duration_ns=%" PRIu64 + " writes=%zu total_bytes=%zu error_code=%d error_message=%s " + "error_details=%s\n", + s.ok() ? "ok" : "error", + total_duration, + stream_stats_.write_count, + stream_stats_.total_bytes, s.error_code(), s.error_message().c_str(), s.error_details().c_str()); @@ -64,11 +75,32 @@ void AssetStream::OnDone(const Status& s) { void AssetStream::OnWriteDone(bool ok/*ok*/) { nsuv::ns_mutex::scoped_lock lock(lock_); write_state_.write_done = true; + + // Calculate and log latency for this write only when debug is enabled + if (per_process::enabled_debug_list.enabled( + DebugCategory::NSOLID_GRPC_AGENT) && + write_state_.write_start > 0) { + uint64_t latency = uv_hrtime() - write_state_.write_start; + Debug("[out] [%" PRIu64 "] %s command=%s requestId=%s data.length=%zu\n", + latency, + ok ? "ok" : "not ok", + write_state_.asset.common().command().c_str(), + write_state_.asset.common().requestid().c_str(), + write_state_.asset.data().length()); + write_state_.write_start = 0; + + // Update stream statistics + stream_stats_.write_count++; + stream_stats_.total_bytes += write_state_.asset.data().length(); + } + if (!ok) { - Debug("AssetStream::OnWriteDone not ok\n"); write_state_.done = true; - StartWritesDone(); - RemoveHold(); + if (!write_state_.writes_done) { + write_state_.writes_done = true; + StartWritesDone(); + RemoveHold(); + } } else { NextWrite(); } @@ -77,11 +109,22 @@ void AssetStream::OnWriteDone(bool ok/*ok*/) { void AssetStream::NextWrite() { if (!write_state_.done && write_state_.write_done) { if (assets_q_.dequeue(write_state_.asset)) { + if (per_process::enabled_debug_list.enabled( + DebugCategory::NSOLID_GRPC_AGENT)) { + // Capture stream start time on first write + if (stream_stats_.stream_start == 0) { + stream_stats_.stream_start = uv_hrtime(); + } + write_state_.write_start = uv_hrtime(); + } StartWrite(&write_state_.asset); write_state_.write_done = false; } else if (write_state_.write_done_called) { - StartWritesDone(); - RemoveHold(); + if (!write_state_.writes_done) { + write_state_.writes_done = true; + StartWritesDone(); + RemoveHold(); + } } } } diff --git a/agents/grpc/src/asset_stream.h b/agents/grpc/src/asset_stream.h index d561fc2d2eb..587eac37b18 100644 --- a/agents/grpc/src/asset_stream.h +++ b/agents/grpc/src/asset_stream.h @@ -39,7 +39,15 @@ class AssetStream: public ::grpc::ClientWriteReactor { bool done = false; bool write_done = true; bool write_done_called = false; + bool writes_done = false; grpcagent::Asset asset; + uint64_t write_start = 0; + }; + + struct StreamStats { + uint64_t stream_start = 0; + size_t write_count = 0; + size_t total_bytes = 0; }; public: @@ -69,6 +77,7 @@ class AssetStream: public ::grpc::ClientWriteReactor { ::grpc::ClientContext context_; grpcagent::EventResponse event_response_; WriteState write_state_; + StreamStats stream_stats_; TSQueue assets_q_; nsuv::ns_mutex lock_; }; diff --git a/agents/grpc/src/command_stream.cc b/agents/grpc/src/command_stream.cc index ce30d39f0ae..6a1de61c2ed 100644 --- a/agents/grpc/src/command_stream.cc +++ b/agents/grpc/src/command_stream.cc @@ -1,6 +1,7 @@ #include "command_stream.h" -#include "debug_utils-inl.h" + #include "asserts-cpp/asserts.h" +#include "grpc_utils.h" using grpc::Status; using grpcagent::NSolidService; @@ -9,12 +10,6 @@ namespace node { namespace nsolid { namespace grpc { -template -inline void Debug(Args&&... args) { - per_process::Debug(DebugCategory::NSOLID_GRPC_AGENT, - std::forward(args)...); -} - CommandStream::CommandStream(NSolidService::StubInterface* stub, std::weak_ptr observer, const std::string& agent_id, @@ -79,8 +74,14 @@ void CommandStream::OnReadDone(bool ok) { Debug("CommandStream::OnReadDone not ok\n"); } - StartWritesDone(); - RemoveHold(); + { + nsuv::ns_mutex::scoped_lock lock(lock_); + if (!write_state_.writes_done) { + write_state_.writes_done = true; + StartWritesDone(); + RemoveHold(); + } + } } void CommandStream::OnWriteDone(bool ok/*ok*/) { @@ -88,8 +89,11 @@ void CommandStream::OnWriteDone(bool ok/*ok*/) { write_state_.write_done = true; if (!ok) { Debug("CommandStream::OnWriteDone not ok\n"); - StartWritesDone(); - RemoveHold(); + if (!write_state_.writes_done) { + write_state_.writes_done = true; + StartWritesDone(); + RemoveHold(); + } } else { NextWrite(); } diff --git a/agents/grpc/src/command_stream.h b/agents/grpc/src/command_stream.h index 200baed0388..6dea9ff7689 100644 --- a/agents/grpc/src/command_stream.h +++ b/agents/grpc/src/command_stream.h @@ -23,6 +23,7 @@ class CommandStream: grpcagent::CommandRequest> { struct WriteState { bool write_done = true; + bool writes_done = false; bool done = false; grpcagent::CommandResponse resp; }; diff --git a/agents/grpc/src/grpc_agent.cc b/agents/grpc/src/grpc_agent.cc index 23567fc4492..eff2553b6bc 100644 --- a/agents/grpc/src/grpc_agent.cc +++ b/agents/grpc/src/grpc_agent.cc @@ -1,7 +1,6 @@ #include "grpc_agent.h" #include "asserts-cpp/asserts.h" -#include "debug_utils-inl.h" #include "nsolid/nsolid_api.h" #include "nsolid/nsolid_util.h" #include "../../otlp/src/otlp_common.h" @@ -74,20 +73,6 @@ const size_t GRPC_MAX_SIZE = 4L * 1024 * 1024; // 4GB const int PUB_KEY_SIZE = 40; const int CONSOLE_ID_SIZE = 36; -template -inline void Debug(Args&&... args) { - per_process::Debug(DebugCategory::NSOLID_GRPC_AGENT, - std::forward(args)...); -} - - -inline void DebugJSON(const char* str, const json& msg) { - if (UNLIKELY(per_process::enabled_debug_list.enabled( - DebugCategory::NSOLID_GRPC_AGENT))) { - Debug(str, msg.dump(4).c_str()); - } -} - JSThreadMetrics::JSThreadMetrics(SharedEnvInst envinst): metrics_(ThreadMetrics::Create(envinst)) { } @@ -144,6 +129,8 @@ void PopulateCommon(grpcagent::CommonResponse* common, time->set_nanoseconds(recorded.second); if (req_id) { common->set_requestid(req_id); + } else { + common->set_requestid(utils::generate_unique_id()); } } @@ -191,8 +178,6 @@ void PopulateBlockedLoopEvent(grpcagent::BlockedLoopEvent* blocked_loop_event, void PopulateInfoEvent(grpcagent::InfoEvent* info_event, const nlohmann::json& info, const char* req_id) { - DebugJSON("Process Info: \n%s\n", info); - // Fill in the fields of the InfoResponse. PopulateCommon(info_event->mutable_common(), "info", req_id); @@ -302,7 +287,6 @@ void PopulatePackagesEvent(grpcagent::PackagesEvent* packages_event, grpcagent::PackagesBody* body = packages_event->mutable_body(); for (const auto& package : packages) { - DebugJSON("Populating Package: \n%s\n", package); grpcagent::Package* proto_package = body->add_packages(); if (package.contains("path") && package["path"].is_string()) { proto_package->set_path(package["path"].get()); @@ -1613,7 +1597,7 @@ void GrpcAgent::got_continuous_profile( void GrpcAgent::handle_command_request(CommandRequestStor&& req) { const grpcagent::CommandRequest& request = req.request; - Debug("Command Received: %s\n", request.DebugString().c_str()); + DebugProtobufMsg("[in] ", request); command_stream_->Write(grpcagent::CommandResponse()); const std::string cmd = request.command(); if (cmd == "info") { diff --git a/agents/grpc/src/grpc_agent.h b/agents/grpc/src/grpc_agent.h index 4b3516dcdb7..73495579270 100644 --- a/agents/grpc/src/grpc_agent.h +++ b/agents/grpc/src/grpc_agent.h @@ -4,7 +4,6 @@ #include #include #include -#include "nlohmann/json.hpp" #include #include "grpcpp/grpcpp.h" #include "./proto/nsolid_service.grpc.pb.h" diff --git a/agents/grpc/src/grpc_client.cc b/agents/grpc/src/grpc_client.cc index fae49d52912..b65773bdbb0 100644 --- a/agents/grpc/src/grpc_client.cc +++ b/agents/grpc/src/grpc_client.cc @@ -16,12 +16,6 @@ namespace node { namespace nsolid { namespace grpc { -template -inline void Debug(Args&&... args) { - per_process::Debug(DebugCategory::NSOLID_GRPC_AGENT, - std::forward(args)...); -} - /** * Create gRPC channel. */ diff --git a/agents/grpc/src/grpc_client.h b/agents/grpc/src/grpc_client.h index 2b49f304e37..6d27472d0e0 100644 --- a/agents/grpc/src/grpc_client.h +++ b/agents/grpc/src/grpc_client.h @@ -1,9 +1,13 @@ #ifndef AGENTS_GRPC_SRC_GRPC_CLIENT_H_ #define AGENTS_GRPC_SRC_GRPC_CLIENT_H_ +#include + #include "asserts-cpp/asserts.h" #include "../../src/profile_collector.h" #include "./proto/nsolid_service.grpc.pb.h" +#include "google/protobuf/util/json_util.h" +#include "grpc_utils.h" #include "grpcpp/grpcpp.h" #include "opentelemetry/version.h" @@ -39,6 +43,7 @@ class GrpcAsyncCallData { EventType* event = nullptr; grpcagent::EventResponse* event_response = nullptr; + uint64_t start; GrpcAsyncCallData() = default; ~GrpcAsyncCallData() = default; @@ -107,6 +112,10 @@ class GrpcClient { return -1; } + if (per_process::enabled_debug_list.enabled( + DebugCategory::NSOLID_GRPC_AGENT)) { + call_data->start = uv_hrtime(); + } call_data->grpc_context.swap(context); // Call the correct async export method on the stub @@ -115,6 +124,20 @@ class GrpcClient { call_data->event_response, [call_data](::grpc::Status status) { call_data->grpc_status = status; + if (per_process::enabled_debug_list.enabled( + DebugCategory::NSOLID_GRPC_AGENT) && + call_data->start > 0) { + uint64_t latency = uv_hrtime() - call_data->start; + if (!call_data->grpc_status.ok()) { + DebugProtobufMsg("[out] [%" PRIu64 "] error code %d - %s ", + *call_data->event, + latency, + call_data->grpc_status.error_code(), + call_data->grpc_status.error_message().c_str()); + } else { + DebugProtobufMsg("[out] [%" PRIu64 "]", *call_data->event, latency); + } + } call_data->result_callback(call_data->grpc_status, std::move(call_data->arena), *call_data->event, diff --git a/agents/grpc/src/grpc_utils.h b/agents/grpc/src/grpc_utils.h new file mode 100644 index 00000000000..2a5dca172d6 --- /dev/null +++ b/agents/grpc/src/grpc_utils.h @@ -0,0 +1,56 @@ +#ifndef AGENTS_GRPC_SRC_GRPC_UTILS_H_ +#define AGENTS_GRPC_SRC_GRPC_UTILS_H_ + +#include "debug_utils-inl.h" +#include "google/protobuf/util/json_util.h" +#include "nlohmann/json.hpp" + +using google::protobuf::Message; +using google::protobuf::util::MessageToJsonString; + +namespace node { +namespace nsolid { +namespace grpc { + +template +inline void Debug(Args&&... args) { + per_process::Debug(DebugCategory::NSOLID_GRPC_AGENT, + std::forward(args)...); +} + +inline void DebugJSON(const char* str, const nlohmann::json& msg) { + if (per_process::enabled_debug_list.enabled( + DebugCategory::NSOLID_GRPC_AGENT)) { + Debug(str, msg.dump(4).c_str()); + } +} + +template +inline void DebugProtobufMsg(const char* format, + const Message& msg, + Args&&... args) { + if (per_process::enabled_debug_list.enabled( + DebugCategory::NSOLID_GRPC_AGENT)) { + std::string json_payload; + const auto status = MessageToJsonString(msg, &json_payload); + if (status.ok()) { + // Build complete message with format args + JSON + std::string formatted_prefix; + if constexpr (sizeof...(args) > 0) { + char buffer[512]; + snprintf(buffer, sizeof(buffer), format, std::forward(args)...); + formatted_prefix = buffer; + } else { + formatted_prefix = format; + } + Debug("%s%s\n", formatted_prefix.c_str(), json_payload.c_str()); + return; + } + } +} + +} // namespace grpc +} // namespace nsolid +} // namespace node + +#endif // AGENTS_GRPC_SRC_GRPC_UTILS_H_ diff --git a/benchmark/fixtures/simple-error-stack.js b/benchmark/fixtures/simple-error-stack.js index 0057807795b..74aae191800 100644 --- a/benchmark/fixtures/simple-error-stack.js +++ b/benchmark/fixtures/simple-error-stack.js @@ -1,15 +1,16 @@ 'use strict'; -exports.__esModule = true; -exports.simpleErrorStack = void 0; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.simpleErrorStack = simpleErrorStack; // Compile with `tsc --inlineSourceMap benchmark/fixtures/simple-error-stack.ts`. var lorem = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'; function simpleErrorStack() { - try { - lorem.BANG(); - } - catch (e) { - return e.stack; - } + [1].map(function () { + try { + lorem.BANG(); + } + catch (e) { + return e.stack; + } + }); } -exports.simpleErrorStack = simpleErrorStack; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2ltcGxlLWVycm9yLXN0YWNrLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsic2ltcGxlLWVycm9yLXN0YWNrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLFlBQVksQ0FBQzs7O0FBRWIsaUZBQWlGO0FBRWpGLElBQU0sS0FBSyxHQUFHLCtiQUErYixDQUFDO0FBRTljLFNBQVMsZ0JBQWdCO0lBQ3ZCLElBQUk7UUFDRCxLQUFhLENBQUMsSUFBSSxFQUFFLENBQUM7S0FDdkI7SUFBQyxPQUFPLENBQUMsRUFBRTtRQUNWLE9BQU8sQ0FBQyxDQUFDLEtBQUssQ0FBQztLQUNoQjtBQUNILENBQUM7QUFHQyw0Q0FBZ0IifQ== +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2ltcGxlLWVycm9yLXN0YWNrLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsic2ltcGxlLWVycm9yLXN0YWNrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLFlBQVksQ0FBQzs7QUFpQlgsNENBQWdCO0FBZmxCLGlGQUFpRjtBQUVqRixJQUFNLEtBQUssR0FBRywrYkFBK2IsQ0FBQztBQUU5YyxTQUFTLGdCQUFnQjtJQUN2QixDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsQ0FBQztRQUNOLElBQUksQ0FBQztZQUNGLEtBQWEsQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUN4QixDQUFDO1FBQUMsT0FBTyxDQUFDLEVBQUUsQ0FBQztZQUNYLE9BQU8sQ0FBQyxDQUFDLEtBQUssQ0FBQztRQUNqQixDQUFDO0lBQ0gsQ0FBQyxDQUFDLENBQUE7QUFDSixDQUFDIn0= \ No newline at end of file diff --git a/benchmark/fixtures/simple-error-stack.ts b/benchmark/fixtures/simple-error-stack.ts index 58034e92f24..1335df3478b 100644 --- a/benchmark/fixtures/simple-error-stack.ts +++ b/benchmark/fixtures/simple-error-stack.ts @@ -5,11 +5,13 @@ const lorem = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'; function simpleErrorStack() { - try { - (lorem as any).BANG(); - } catch (e) { - return e.stack; - } + [1].map(() => { + try { + (lorem as any).BANG(); + } catch (e) { + return e.stack; + } + }) } export { diff --git a/benchmark/fixtures/valid.env b/benchmark/fixtures/valid.env index 120488d5791..6df454da653 100644 --- a/benchmark/fixtures/valid.env +++ b/benchmark/fixtures/valid.env @@ -6,6 +6,8 @@ BASIC=basic # previous line intentionally left blank AFTER_LINE=after_line +A="B=C" +B=C=D EMPTY= EMPTY_SINGLE_QUOTES='' EMPTY_DOUBLE_QUOTES="" diff --git a/common.gypi b/common.gypi index b487998f79b..b8b46dba3a8 100644 --- a/common.gypi +++ b/common.gypi @@ -36,7 +36,7 @@ # 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.29', + 'v8_embedder_string': '-node.30', ##### V8 defaults for Node.js ##### @@ -80,6 +80,7 @@ 'v8_enable_direct_local%': 0, 'v8_enable_map_packing%': 0, 'v8_enable_pointer_compression_shared_cage%': 0, + 'v8_enable_external_code_space%': 0, 'v8_enable_sandbox%': 0, 'v8_enable_v8_checks%': 0, 'v8_enable_zone_compression%': 0, @@ -115,7 +116,9 @@ # V8 pointer compression only supports 64bit architectures. ['target_arch in "arm ia32 mips mipsel ppc"', { 'v8_enable_pointer_compression': 0, + 'v8_enable_pointer_compression_shared_cage': 0, 'v8_enable_31bit_smis_on_64bit_arch': 0, + 'v8_enable_external_code_space': 0, 'v8_enable_sandbox': 0 }], ['target_arch in "ppc64 s390x"', { @@ -426,6 +429,9 @@ ['v8_enable_sandbox == 1', { 'defines': ['V8_ENABLE_SANDBOX',], }], + ['v8_enable_external_code_space == 1', { + 'defines': ['V8_EXTERNAL_CODE_SPACE',], + }], ['v8_deprecation_warnings == 1', { 'defines': ['V8_DEPRECATION_WARNINGS',], }], diff --git a/configure.py b/configure.py index caea1673282..5f7044be38d 100755 --- a/configure.py +++ b/configure.py @@ -1626,7 +1626,15 @@ def configure_v8(o): o['variables']['v8_use_siphash'] = 0 if options.without_siphash else 1 o['variables']['v8_enable_maglev'] = 1 if options.v8_enable_maglev else 0 o['variables']['v8_enable_pointer_compression'] = 1 if options.enable_pointer_compression else 0 - o['variables']['v8_enable_sandbox'] = 1 if options.enable_pointer_compression else 0 + # Using the sandbox requires always allocating array buffer backing stores in the sandbox. + # We currently have many backing stores tied to pointers from C++ land that are not + # even necessarily dynamic (e.g. in static storage) for fast communication between JS and C++. + # Until we manage to get rid of all those, v8_enable_sandbox cannot be used. + # Note that enabling pointer compression without enabling sandbox is unsupported by V8, + # so this can be broken at any time. + o['variables']['v8_enable_sandbox'] = 0 + o['variables']['v8_enable_pointer_compression_shared_cage'] = 1 if options.enable_pointer_compression else 0 + o['variables']['v8_enable_external_code_space'] = 1 if options.enable_pointer_compression else 0 o['variables']['v8_enable_31bit_smis_on_64bit_arch'] = 1 if options.enable_pointer_compression else 0 o['variables']['v8_enable_shared_ro_heap'] = 0 if options.enable_pointer_compression or options.disable_shared_ro_heap else 1 o['variables']['v8_enable_extensible_ro_snapshot'] = 0 @@ -2171,7 +2179,7 @@ def make_bin_override(): configure_library('nghttp2', output, pkgname='libnghttp2') configure_library('nghttp3', output, pkgname='libnghttp3') configure_library('ngtcp2', output, pkgname='libngtcp2') -configure_library('uvwasi', output, pkgname='libuvwasi') +configure_library('uvwasi', output) configure_v8(output) configure_openssl(output) configure_intl(output) diff --git a/deps/acorn/acorn/CHANGELOG.md b/deps/acorn/acorn/CHANGELOG.md index 313718616b5..c86068cd71a 100644 --- a/deps/acorn/acorn/CHANGELOG.md +++ b/deps/acorn/acorn/CHANGELOG.md @@ -1,3 +1,29 @@ +## 8.15.0 (2025-06-08) + +### New features + +Support `using` and `await using` syntax. + +The `AnyNode` type is now defined in such a way that plugins can extend it. + +### Bug fixes + +Fix an issue where the `bigint` property of literal nodes for non-decimal bigints had the wrong format. + +The `acorn` CLI tool no longer crashes when emitting a tree that contains a bigint. + +## 8.14.1 (2025-03-05) + +### Bug fixes + +Fix an issue where `await` expressions in class field initializers were inappropriately allowed. + +Properly allow await inside an async arrow function inside a class field initializer. + +Mention the source file name in syntax error messages when given. + +Properly add an empty `attributes` property to every form of `ExportNamedDeclaration`. + ## 8.14.0 (2024-10-27) ### New features diff --git a/deps/acorn/acorn/dist/acorn.d.mts b/deps/acorn/acorn/dist/acorn.d.mts index 81f4e38fdbf..f2ec5243bcb 100644 --- a/deps/acorn/acorn/dist/acorn.d.mts +++ b/deps/acorn/acorn/dist/acorn.d.mts @@ -169,7 +169,7 @@ export interface FunctionDeclaration extends Function { export interface VariableDeclaration extends Node { type: "VariableDeclaration" declarations: Array - kind: "var" | "let" | "const" + kind: "var" | "let" | "const" | "using" | "await using" } export interface VariableDeclarator extends Node { @@ -572,7 +572,24 @@ export type ModuleDeclaration = | ExportDefaultDeclaration | ExportAllDeclaration -export type AnyNode = Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportAttribute | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator +/** + * This interface is only used for defining {@link AnyNode}. + * It exists so that it can be extended by plugins: + * + * @example + * ```typescript + * declare module 'acorn' { + * interface NodeTypes { + * pluginName: FirstNode | SecondNode | ThirdNode | ... | LastNode + * } + * } + * ``` + */ +interface NodeTypes { + core: Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportAttribute | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator +} + +export type AnyNode = NodeTypes[keyof NodeTypes] export function parse(input: string, options: Options): Program @@ -583,7 +600,7 @@ export function tokenizer(input: string, options: Options): { [Symbol.iterator](): Iterator } -export type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | "latest" +export type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | 2026 | "latest" export interface Options { /** diff --git a/deps/acorn/acorn/dist/acorn.d.ts b/deps/acorn/acorn/dist/acorn.d.ts index 81f4e38fdbf..f2ec5243bcb 100644 --- a/deps/acorn/acorn/dist/acorn.d.ts +++ b/deps/acorn/acorn/dist/acorn.d.ts @@ -169,7 +169,7 @@ export interface FunctionDeclaration extends Function { export interface VariableDeclaration extends Node { type: "VariableDeclaration" declarations: Array - kind: "var" | "let" | "const" + kind: "var" | "let" | "const" | "using" | "await using" } export interface VariableDeclarator extends Node { @@ -572,7 +572,24 @@ export type ModuleDeclaration = | ExportDefaultDeclaration | ExportAllDeclaration -export type AnyNode = Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportAttribute | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator +/** + * This interface is only used for defining {@link AnyNode}. + * It exists so that it can be extended by plugins: + * + * @example + * ```typescript + * declare module 'acorn' { + * interface NodeTypes { + * pluginName: FirstNode | SecondNode | ThirdNode | ... | LastNode + * } + * } + * ``` + */ +interface NodeTypes { + core: Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportAttribute | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator +} + +export type AnyNode = NodeTypes[keyof NodeTypes] export function parse(input: string, options: Options): Program @@ -583,7 +600,7 @@ export function tokenizer(input: string, options: Options): { [Symbol.iterator](): Iterator } -export type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | "latest" +export type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | 2026 | "latest" export interface Options { /** diff --git a/deps/acorn/acorn/dist/acorn.js b/deps/acorn/acorn/dist/acorn.js index 2bfc15b5ef2..cb5628bf83c 100644 --- a/deps/acorn/acorn/dist/acorn.js +++ b/deps/acorn/acorn/dist/acorn.js @@ -493,6 +493,7 @@ SCOPE_SUPER = 64, SCOPE_DIRECT_SUPER = 128, SCOPE_CLASS_STATIC_BLOCK = 256, + SCOPE_CLASS_FIELD_INIT = 512, SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK; function functionFlags(async, generator) { @@ -603,15 +604,16 @@ prototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 }; - prototypeAccessors.inGenerator.get = function () { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 && !this.currentVarScope().inClassFieldInit }; + prototypeAccessors.inGenerator.get = function () { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 }; - prototypeAccessors.inAsync.get = function () { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 && !this.currentVarScope().inClassFieldInit }; + prototypeAccessors.inAsync.get = function () { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 }; prototypeAccessors.canAwait.get = function () { for (var i = this.scopeStack.length - 1; i >= 0; i--) { - var scope = this.scopeStack[i]; - if (scope.inClassFieldInit || scope.flags & SCOPE_CLASS_STATIC_BLOCK) { return false } - if (scope.flags & SCOPE_FUNCTION) { return (scope.flags & SCOPE_ASYNC) > 0 } + var ref = this.scopeStack[i]; + var flags = ref.flags; + if (flags & (SCOPE_CLASS_STATIC_BLOCK | SCOPE_CLASS_FIELD_INIT)) { return false } + if (flags & SCOPE_FUNCTION) { return (flags & SCOPE_ASYNC) > 0 } } return (this.inModule && this.options.ecmaVersion >= 13) || this.options.allowAwaitOutsideFunction }; @@ -619,8 +621,7 @@ prototypeAccessors.allowSuper.get = function () { var ref = this.currentThisScope(); var flags = ref.flags; - var inClassFieldInit = ref.inClassFieldInit; - return (flags & SCOPE_SUPER) > 0 || inClassFieldInit || this.options.allowSuperOutsideMethod + return (flags & SCOPE_SUPER) > 0 || this.options.allowSuperOutsideMethod }; prototypeAccessors.allowDirectSuper.get = function () { return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0 }; @@ -628,10 +629,13 @@ prototypeAccessors.treatFunctionsAsVar.get = function () { return this.treatFunctionsAsVarInScope(this.currentScope()) }; prototypeAccessors.allowNewDotTarget.get = function () { - var ref = this.currentThisScope(); - var flags = ref.flags; - var inClassFieldInit = ref.inClassFieldInit; - return (flags & (SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK)) > 0 || inClassFieldInit + for (var i = this.scopeStack.length - 1; i >= 0; i--) { + var ref = this.scopeStack[i]; + var flags = ref.flags; + if (flags & (SCOPE_CLASS_STATIC_BLOCK | SCOPE_CLASS_FIELD_INIT) || + ((flags & SCOPE_FUNCTION) && !(flags & SCOPE_ARROW))) { return true } + } + return false }; prototypeAccessors.inClassStaticBlock.get = function () { @@ -883,6 +887,49 @@ !(isIdentifierChar(after = this.input.charCodeAt(next + 8)) || after > 0xd7ff && after < 0xdc00)) }; + pp$8.isUsingKeyword = function(isAwaitUsing, isFor) { + if (this.options.ecmaVersion < 17 || !this.isContextual(isAwaitUsing ? "await" : "using")) + { return false } + + skipWhiteSpace.lastIndex = this.pos; + var skip = skipWhiteSpace.exec(this.input); + var next = this.pos + skip[0].length; + + if (lineBreak.test(this.input.slice(this.pos, next))) { return false } + + if (isAwaitUsing) { + var awaitEndPos = next + 5 /* await */, after; + if (this.input.slice(next, awaitEndPos) !== "using" || + awaitEndPos === this.input.length || + isIdentifierChar(after = this.input.charCodeAt(awaitEndPos)) || + (after > 0xd7ff && after < 0xdc00) + ) { return false } + + skipWhiteSpace.lastIndex = awaitEndPos; + var skipAfterUsing = skipWhiteSpace.exec(this.input); + if (skipAfterUsing && lineBreak.test(this.input.slice(awaitEndPos, awaitEndPos + skipAfterUsing[0].length))) { return false } + } + + if (isFor) { + var ofEndPos = next + 2 /* of */, after$1; + if (this.input.slice(next, ofEndPos) === "of") { + if (ofEndPos === this.input.length || + (!isIdentifierChar(after$1 = this.input.charCodeAt(ofEndPos)) && !(after$1 > 0xd7ff && after$1 < 0xdc00))) { return false } + } + } + + var ch = this.input.charCodeAt(next); + return isIdentifierStart(ch, true) || ch === 92 // '\' + }; + + pp$8.isAwaitUsing = function(isFor) { + return this.isUsingKeyword(true, isFor) + }; + + pp$8.isUsing = function(isFor) { + return this.isUsingKeyword(false, isFor) + }; + // Parse a single statement. // // If expecting a statement and finding a slash operator, parse a @@ -959,6 +1006,23 @@ return this.parseFunctionStatement(node, true, !context) } + var usingKind = this.isAwaitUsing(false) ? "await using" : this.isUsing(false) ? "using" : null; + if (usingKind) { + if (topLevel && this.options.sourceType === "script") { + this.raise(this.start, "Using declaration cannot appear in the top level when source type is `script`"); + } + if (usingKind === "await using") { + if (!this.canAwait) { + this.raise(this.start, "Await using cannot appear outside of async function"); + } + this.next(); + } + this.next(); + this.parseVar(node, false, usingKind); + this.semicolon(); + return this.finishNode(node, "VariableDeclaration") + } + var maybeName = this.value, expr = this.parseExpression(); if (starttype === types$1.name && expr.type === "Identifier" && this.eat(types$1.colon)) { return this.parseLabeledStatement(node, maybeName, expr, context) } @@ -1034,18 +1098,19 @@ this.next(); this.parseVar(init$1, true, kind); this.finishNode(init$1, "VariableDeclaration"); - if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1) { - if (this.options.ecmaVersion >= 9) { - if (this.type === types$1._in) { - if (awaitAt > -1) { this.unexpected(awaitAt); } - } else { node.await = awaitAt > -1; } - } - return this.parseForIn(node, init$1) - } - if (awaitAt > -1) { this.unexpected(awaitAt); } - return this.parseFor(node, init$1) + return this.parseForAfterInit(node, init$1, awaitAt) } var startsWithLet = this.isContextual("let"), isForOf = false; + + var usingKind = this.isUsing(true) ? "using" : this.isAwaitUsing(true) ? "await using" : null; + if (usingKind) { + var init$2 = this.startNode(); + this.next(); + if (usingKind === "await using") { this.next(); } + this.parseVar(init$2, true, usingKind); + this.finishNode(init$2, "VariableDeclaration"); + return this.parseForAfterInit(node, init$2, awaitAt) + } var containsEsc = this.containsEsc; var refDestructuringErrors = new DestructuringErrors; var initPos = this.start; @@ -1071,6 +1136,20 @@ return this.parseFor(node, init) }; + // Helper method to parse for loop after variable initialization + pp$8.parseForAfterInit = function(node, init, awaitAt) { + if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init.declarations.length === 1) { + if (this.options.ecmaVersion >= 9) { + if (this.type === types$1._in) { + if (awaitAt > -1) { this.unexpected(awaitAt); } + } else { node.await = awaitAt > -1; } + } + return this.parseForIn(node, init) + } + if (awaitAt > -1) { this.unexpected(awaitAt); } + return this.parseFor(node, init) + }; + pp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) { this.next(); return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync) @@ -1327,6 +1406,8 @@ decl.init = this.parseMaybeAssign(isFor); } else if (!allowMissingInitializer && kind === "const" && !(this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of")))) { this.unexpected(); + } else if (!allowMissingInitializer && (kind === "using" || kind === "await using") && this.options.ecmaVersion >= 17 && this.type !== types$1._in && !this.isContextual("of")) { + this.raise(this.lastTokEnd, ("Missing initializer in " + kind + " declaration")); } else if (!allowMissingInitializer && decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of")))) { this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value"); } else { @@ -1339,7 +1420,10 @@ }; pp$8.parseVarId = function(decl, kind) { - decl.id = this.parseBindingAtom(); + decl.id = kind === "using" || kind === "await using" + ? this.parseIdent() + : this.parseBindingAtom(); + this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false); }; @@ -1558,11 +1642,9 @@ if (this.eat(types$1.eq)) { // To raise SyntaxError if 'arguments' exists in the initializer. - var scope = this.currentThisScope(); - var inClassFieldInit = scope.inClassFieldInit; - scope.inClassFieldInit = true; + this.enterScope(SCOPE_CLASS_FIELD_INIT | SCOPE_SUPER); field.value = this.parseMaybeAssign(); - scope.inClassFieldInit = inClassFieldInit; + this.exitScope(); } else { field.value = null; } @@ -1704,6 +1786,8 @@ { this.checkExport(exports, node.declaration.id, node.declaration.id.start); } node.specifiers = []; node.source = null; + if (this.options.ecmaVersion >= 16) + { node.attributes = []; } } else { // export { x, y as z } [from '...'] node.declaration = null; node.specifiers = this.parseExportSpecifiers(exports); @@ -1727,6 +1811,8 @@ } node.source = null; + if (this.options.ecmaVersion >= 16) + { node.attributes = []; } } this.semicolon(); } @@ -3068,7 +3154,8 @@ var node = this.startNode(); node.value = value; node.raw = this.input.slice(this.start, this.end); - if (node.raw.charCodeAt(node.raw.length - 1) === 110) { node.bigint = node.raw.slice(0, -1).replace(/_/g, ""); } + if (node.raw.charCodeAt(node.raw.length - 1) === 110) + { node.bigint = node.value != null ? node.value.toString() : node.raw.slice(0, -1).replace(/_/g, ""); } this.next(); return this.finishNode(node, "Literal") }; @@ -3306,9 +3393,10 @@ }; pp$5.parseGetterSetter = function(prop) { - prop.kind = prop.key.name; + var kind = prop.key.name; this.parsePropertyName(prop); prop.value = this.parseMethod(false); + prop.kind = kind; var paramCount = prop.kind === "get" ? 0 : 1; if (prop.value.params.length !== paramCount) { var start = prop.value.start; @@ -3331,9 +3419,9 @@ prop.kind = "init"; } else if (this.options.ecmaVersion >= 6 && this.type === types$1.parenL) { if (isPattern) { this.unexpected(); } - prop.kind = "init"; prop.method = true; prop.value = this.parseMethod(isGenerator, isAsync); + prop.kind = "init"; } else if (!isPattern && !containsEsc && this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && @@ -3345,7 +3433,6 @@ this.checkUnreserved(prop.key); if (prop.key.name === "await" && !this.awaitIdentPos) { this.awaitIdentPos = startPos; } - prop.kind = "init"; if (isPattern) { prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key)); } else if (this.type === types$1.eq && refDestructuringErrors) { @@ -3355,6 +3442,7 @@ } else { prop.value = this.copyNode(prop.key); } + prop.kind = "init"; prop.shorthand = true; } else { this.unexpected(); } }; @@ -3530,7 +3618,7 @@ { this.raiseRecoverable(start, "Cannot use 'yield' as identifier inside a generator"); } if (this.inAsync && name === "await") { this.raiseRecoverable(start, "Cannot use 'await' as identifier inside an async function"); } - if (this.currentThisScope().inClassFieldInit && name === "arguments") + if (!(this.currentThisScope().flags & SCOPE_VAR) && name === "arguments") { this.raiseRecoverable(start, "Cannot use 'arguments' in class field initializer"); } if (this.inClassStaticBlock && (name === "arguments" || name === "await")) { this.raise(start, ("Cannot use " + name + " in class static initialization block")); } @@ -3643,6 +3731,9 @@ pp$4.raise = function(pos, message) { var loc = getLineInfo(this.input, pos); message += " (" + loc.line + ":" + loc.column + ")"; + if (this.sourceFile) { + message += " in " + this.sourceFile; + } var err = new SyntaxError(message); err.pos = pos; err.loc = loc; err.raisedAt = this.pos; throw err @@ -3666,8 +3757,6 @@ this.lexical = []; // A list of lexically-declared FunctionDeclaration names in the current lexical scope this.functions = []; - // A switch to disallow the identifier reference 'arguments' - this.inClassFieldInit = false; }; // The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names. @@ -3737,7 +3826,7 @@ pp$3.currentVarScope = function() { for (var i = this.scopeStack.length - 1;; i--) { var scope = this.scopeStack[i]; - if (scope.flags & SCOPE_VAR) { return scope } + if (scope.flags & (SCOPE_VAR | SCOPE_CLASS_FIELD_INIT | SCOPE_CLASS_STATIC_BLOCK)) { return scope } } }; @@ -3745,7 +3834,8 @@ pp$3.currentThisScope = function() { for (var i = this.scopeStack.length - 1;; i--) { var scope = this.scopeStack[i]; - if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) { return scope } + if (scope.flags & (SCOPE_VAR | SCOPE_CLASS_FIELD_INIT | SCOPE_CLASS_STATIC_BLOCK) && + !(scope.flags & SCOPE_ARROW)) { return scope } } }; @@ -6095,11 +6185,9 @@ // Please use the [github bug tracker][ghbt] to report issues. // // [ghbt]: https://github.com/acornjs/acorn/issues - // - // [walk]: util/walk.js - var version = "8.14.0"; + var version = "8.15.0"; Parser.acorn = { Parser: Parser, diff --git a/deps/acorn/acorn/dist/acorn.mjs b/deps/acorn/acorn/dist/acorn.mjs index 43e58efe7f0..74d5fc431be 100644 --- a/deps/acorn/acorn/dist/acorn.mjs +++ b/deps/acorn/acorn/dist/acorn.mjs @@ -487,6 +487,7 @@ var SCOPE_SUPER = 64, SCOPE_DIRECT_SUPER = 128, SCOPE_CLASS_STATIC_BLOCK = 256, + SCOPE_CLASS_FIELD_INIT = 512, SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK; function functionFlags(async, generator) { @@ -597,15 +598,16 @@ Parser.prototype.parse = function parse () { prototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 }; -prototypeAccessors.inGenerator.get = function () { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 && !this.currentVarScope().inClassFieldInit }; +prototypeAccessors.inGenerator.get = function () { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 }; -prototypeAccessors.inAsync.get = function () { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 && !this.currentVarScope().inClassFieldInit }; +prototypeAccessors.inAsync.get = function () { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 }; prototypeAccessors.canAwait.get = function () { for (var i = this.scopeStack.length - 1; i >= 0; i--) { - var scope = this.scopeStack[i]; - if (scope.inClassFieldInit || scope.flags & SCOPE_CLASS_STATIC_BLOCK) { return false } - if (scope.flags & SCOPE_FUNCTION) { return (scope.flags & SCOPE_ASYNC) > 0 } + var ref = this.scopeStack[i]; + var flags = ref.flags; + if (flags & (SCOPE_CLASS_STATIC_BLOCK | SCOPE_CLASS_FIELD_INIT)) { return false } + if (flags & SCOPE_FUNCTION) { return (flags & SCOPE_ASYNC) > 0 } } return (this.inModule && this.options.ecmaVersion >= 13) || this.options.allowAwaitOutsideFunction }; @@ -613,8 +615,7 @@ prototypeAccessors.canAwait.get = function () { prototypeAccessors.allowSuper.get = function () { var ref = this.currentThisScope(); var flags = ref.flags; - var inClassFieldInit = ref.inClassFieldInit; - return (flags & SCOPE_SUPER) > 0 || inClassFieldInit || this.options.allowSuperOutsideMethod + return (flags & SCOPE_SUPER) > 0 || this.options.allowSuperOutsideMethod }; prototypeAccessors.allowDirectSuper.get = function () { return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0 }; @@ -622,10 +623,13 @@ prototypeAccessors.allowDirectSuper.get = function () { return (this.currentThis prototypeAccessors.treatFunctionsAsVar.get = function () { return this.treatFunctionsAsVarInScope(this.currentScope()) }; prototypeAccessors.allowNewDotTarget.get = function () { - var ref = this.currentThisScope(); - var flags = ref.flags; - var inClassFieldInit = ref.inClassFieldInit; - return (flags & (SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK)) > 0 || inClassFieldInit + for (var i = this.scopeStack.length - 1; i >= 0; i--) { + var ref = this.scopeStack[i]; + var flags = ref.flags; + if (flags & (SCOPE_CLASS_STATIC_BLOCK | SCOPE_CLASS_FIELD_INIT) || + ((flags & SCOPE_FUNCTION) && !(flags & SCOPE_ARROW))) { return true } + } + return false }; prototypeAccessors.inClassStaticBlock.get = function () { @@ -877,6 +881,49 @@ pp$8.isAsyncFunction = function() { !(isIdentifierChar(after = this.input.charCodeAt(next + 8)) || after > 0xd7ff && after < 0xdc00)) }; +pp$8.isUsingKeyword = function(isAwaitUsing, isFor) { + if (this.options.ecmaVersion < 17 || !this.isContextual(isAwaitUsing ? "await" : "using")) + { return false } + + skipWhiteSpace.lastIndex = this.pos; + var skip = skipWhiteSpace.exec(this.input); + var next = this.pos + skip[0].length; + + if (lineBreak.test(this.input.slice(this.pos, next))) { return false } + + if (isAwaitUsing) { + var awaitEndPos = next + 5 /* await */, after; + if (this.input.slice(next, awaitEndPos) !== "using" || + awaitEndPos === this.input.length || + isIdentifierChar(after = this.input.charCodeAt(awaitEndPos)) || + (after > 0xd7ff && after < 0xdc00) + ) { return false } + + skipWhiteSpace.lastIndex = awaitEndPos; + var skipAfterUsing = skipWhiteSpace.exec(this.input); + if (skipAfterUsing && lineBreak.test(this.input.slice(awaitEndPos, awaitEndPos + skipAfterUsing[0].length))) { return false } + } + + if (isFor) { + var ofEndPos = next + 2 /* of */, after$1; + if (this.input.slice(next, ofEndPos) === "of") { + if (ofEndPos === this.input.length || + (!isIdentifierChar(after$1 = this.input.charCodeAt(ofEndPos)) && !(after$1 > 0xd7ff && after$1 < 0xdc00))) { return false } + } + } + + var ch = this.input.charCodeAt(next); + return isIdentifierStart(ch, true) || ch === 92 // '\' +}; + +pp$8.isAwaitUsing = function(isFor) { + return this.isUsingKeyword(true, isFor) +}; + +pp$8.isUsing = function(isFor) { + return this.isUsingKeyword(false, isFor) +}; + // Parse a single statement. // // If expecting a statement and finding a slash operator, parse a @@ -953,6 +1000,23 @@ pp$8.parseStatement = function(context, topLevel, exports) { return this.parseFunctionStatement(node, true, !context) } + var usingKind = this.isAwaitUsing(false) ? "await using" : this.isUsing(false) ? "using" : null; + if (usingKind) { + if (topLevel && this.options.sourceType === "script") { + this.raise(this.start, "Using declaration cannot appear in the top level when source type is `script`"); + } + if (usingKind === "await using") { + if (!this.canAwait) { + this.raise(this.start, "Await using cannot appear outside of async function"); + } + this.next(); + } + this.next(); + this.parseVar(node, false, usingKind); + this.semicolon(); + return this.finishNode(node, "VariableDeclaration") + } + var maybeName = this.value, expr = this.parseExpression(); if (starttype === types$1.name && expr.type === "Identifier" && this.eat(types$1.colon)) { return this.parseLabeledStatement(node, maybeName, expr, context) } @@ -1028,18 +1092,19 @@ pp$8.parseForStatement = function(node) { this.next(); this.parseVar(init$1, true, kind); this.finishNode(init$1, "VariableDeclaration"); - if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1) { - if (this.options.ecmaVersion >= 9) { - if (this.type === types$1._in) { - if (awaitAt > -1) { this.unexpected(awaitAt); } - } else { node.await = awaitAt > -1; } - } - return this.parseForIn(node, init$1) - } - if (awaitAt > -1) { this.unexpected(awaitAt); } - return this.parseFor(node, init$1) + return this.parseForAfterInit(node, init$1, awaitAt) } var startsWithLet = this.isContextual("let"), isForOf = false; + + var usingKind = this.isUsing(true) ? "using" : this.isAwaitUsing(true) ? "await using" : null; + if (usingKind) { + var init$2 = this.startNode(); + this.next(); + if (usingKind === "await using") { this.next(); } + this.parseVar(init$2, true, usingKind); + this.finishNode(init$2, "VariableDeclaration"); + return this.parseForAfterInit(node, init$2, awaitAt) + } var containsEsc = this.containsEsc; var refDestructuringErrors = new DestructuringErrors; var initPos = this.start; @@ -1065,6 +1130,20 @@ pp$8.parseForStatement = function(node) { return this.parseFor(node, init) }; +// Helper method to parse for loop after variable initialization +pp$8.parseForAfterInit = function(node, init, awaitAt) { + if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init.declarations.length === 1) { + if (this.options.ecmaVersion >= 9) { + if (this.type === types$1._in) { + if (awaitAt > -1) { this.unexpected(awaitAt); } + } else { node.await = awaitAt > -1; } + } + return this.parseForIn(node, init) + } + if (awaitAt > -1) { this.unexpected(awaitAt); } + return this.parseFor(node, init) +}; + pp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) { this.next(); return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync) @@ -1321,6 +1400,8 @@ pp$8.parseVar = function(node, isFor, kind, allowMissingInitializer) { decl.init = this.parseMaybeAssign(isFor); } else if (!allowMissingInitializer && kind === "const" && !(this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of")))) { this.unexpected(); + } else if (!allowMissingInitializer && (kind === "using" || kind === "await using") && this.options.ecmaVersion >= 17 && this.type !== types$1._in && !this.isContextual("of")) { + this.raise(this.lastTokEnd, ("Missing initializer in " + kind + " declaration")); } else if (!allowMissingInitializer && decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of")))) { this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value"); } else { @@ -1333,7 +1414,10 @@ pp$8.parseVar = function(node, isFor, kind, allowMissingInitializer) { }; pp$8.parseVarId = function(decl, kind) { - decl.id = this.parseBindingAtom(); + decl.id = kind === "using" || kind === "await using" + ? this.parseIdent() + : this.parseBindingAtom(); + this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false); }; @@ -1552,11 +1636,9 @@ pp$8.parseClassField = function(field) { if (this.eat(types$1.eq)) { // To raise SyntaxError if 'arguments' exists in the initializer. - var scope = this.currentThisScope(); - var inClassFieldInit = scope.inClassFieldInit; - scope.inClassFieldInit = true; + this.enterScope(SCOPE_CLASS_FIELD_INIT | SCOPE_SUPER); field.value = this.parseMaybeAssign(); - scope.inClassFieldInit = inClassFieldInit; + this.exitScope(); } else { field.value = null; } @@ -1698,6 +1780,8 @@ pp$8.parseExport = function(node, exports) { { this.checkExport(exports, node.declaration.id, node.declaration.id.start); } node.specifiers = []; node.source = null; + if (this.options.ecmaVersion >= 16) + { node.attributes = []; } } else { // export { x, y as z } [from '...'] node.declaration = null; node.specifiers = this.parseExportSpecifiers(exports); @@ -1721,6 +1805,8 @@ pp$8.parseExport = function(node, exports) { } node.source = null; + if (this.options.ecmaVersion >= 16) + { node.attributes = []; } } this.semicolon(); } @@ -3062,7 +3148,8 @@ pp$5.parseLiteral = function(value) { var node = this.startNode(); node.value = value; node.raw = this.input.slice(this.start, this.end); - if (node.raw.charCodeAt(node.raw.length - 1) === 110) { node.bigint = node.raw.slice(0, -1).replace(/_/g, ""); } + if (node.raw.charCodeAt(node.raw.length - 1) === 110) + { node.bigint = node.value != null ? node.value.toString() : node.raw.slice(0, -1).replace(/_/g, ""); } this.next(); return this.finishNode(node, "Literal") }; @@ -3300,9 +3387,10 @@ pp$5.parseProperty = function(isPattern, refDestructuringErrors) { }; pp$5.parseGetterSetter = function(prop) { - prop.kind = prop.key.name; + var kind = prop.key.name; this.parsePropertyName(prop); prop.value = this.parseMethod(false); + prop.kind = kind; var paramCount = prop.kind === "get" ? 0 : 1; if (prop.value.params.length !== paramCount) { var start = prop.value.start; @@ -3325,9 +3413,9 @@ pp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startP prop.kind = "init"; } else if (this.options.ecmaVersion >= 6 && this.type === types$1.parenL) { if (isPattern) { this.unexpected(); } - prop.kind = "init"; prop.method = true; prop.value = this.parseMethod(isGenerator, isAsync); + prop.kind = "init"; } else if (!isPattern && !containsEsc && this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && @@ -3339,7 +3427,6 @@ pp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startP this.checkUnreserved(prop.key); if (prop.key.name === "await" && !this.awaitIdentPos) { this.awaitIdentPos = startPos; } - prop.kind = "init"; if (isPattern) { prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key)); } else if (this.type === types$1.eq && refDestructuringErrors) { @@ -3349,6 +3436,7 @@ pp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startP } else { prop.value = this.copyNode(prop.key); } + prop.kind = "init"; prop.shorthand = true; } else { this.unexpected(); } }; @@ -3524,7 +3612,7 @@ pp$5.checkUnreserved = function(ref) { { this.raiseRecoverable(start, "Cannot use 'yield' as identifier inside a generator"); } if (this.inAsync && name === "await") { this.raiseRecoverable(start, "Cannot use 'await' as identifier inside an async function"); } - if (this.currentThisScope().inClassFieldInit && name === "arguments") + if (!(this.currentThisScope().flags & SCOPE_VAR) && name === "arguments") { this.raiseRecoverable(start, "Cannot use 'arguments' in class field initializer"); } if (this.inClassStaticBlock && (name === "arguments" || name === "await")) { this.raise(start, ("Cannot use " + name + " in class static initialization block")); } @@ -3637,6 +3725,9 @@ var pp$4 = Parser.prototype; pp$4.raise = function(pos, message) { var loc = getLineInfo(this.input, pos); message += " (" + loc.line + ":" + loc.column + ")"; + if (this.sourceFile) { + message += " in " + this.sourceFile; + } var err = new SyntaxError(message); err.pos = pos; err.loc = loc; err.raisedAt = this.pos; throw err @@ -3660,8 +3751,6 @@ var Scope = function Scope(flags) { this.lexical = []; // A list of lexically-declared FunctionDeclaration names in the current lexical scope this.functions = []; - // A switch to disallow the identifier reference 'arguments' - this.inClassFieldInit = false; }; // The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names. @@ -3731,7 +3820,7 @@ pp$3.currentScope = function() { pp$3.currentVarScope = function() { for (var i = this.scopeStack.length - 1;; i--) { var scope = this.scopeStack[i]; - if (scope.flags & SCOPE_VAR) { return scope } + if (scope.flags & (SCOPE_VAR | SCOPE_CLASS_FIELD_INIT | SCOPE_CLASS_STATIC_BLOCK)) { return scope } } }; @@ -3739,7 +3828,8 @@ pp$3.currentVarScope = function() { pp$3.currentThisScope = function() { for (var i = this.scopeStack.length - 1;; i--) { var scope = this.scopeStack[i]; - if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) { return scope } + if (scope.flags & (SCOPE_VAR | SCOPE_CLASS_FIELD_INIT | SCOPE_CLASS_STATIC_BLOCK) && + !(scope.flags & SCOPE_ARROW)) { return scope } } }; @@ -6089,11 +6179,9 @@ pp.readWord = function() { // Please use the [github bug tracker][ghbt] to report issues. // // [ghbt]: https://github.com/acornjs/acorn/issues -// -// [walk]: util/walk.js -var version = "8.14.0"; +var version = "8.15.0"; Parser.acorn = { Parser: Parser, diff --git a/deps/acorn/acorn/dist/bin.js b/deps/acorn/acorn/dist/bin.js index 0bf3e5f8d12..c7d9b9f8ed8 100644 --- a/deps/acorn/acorn/dist/bin.js +++ b/deps/acorn/acorn/dist/bin.js @@ -77,7 +77,7 @@ function run(codeList) { console.error(fileMode ? e.message.replace(/\(\d+:\d+\)$/, function (m) { return m.slice(0, 1) + inputFilePaths[fileIdx] + " " + m.slice(1); }) : e.message); process.exit(1); } - if (!silent) { console.log(JSON.stringify(result, null, compact ? null : 2)); } + if (!silent) { console.log(JSON.stringify(result, function (_, value) { return typeof value === "bigint" ? null : value; }, compact ? null : 2)); } } if (fileMode = inputFilePaths.length && (forceFileName || !inputFilePaths.includes("-") || inputFilePaths.length !== 1)) { diff --git a/deps/acorn/acorn/package.json b/deps/acorn/acorn/package.json index 795cf83eff6..6f63ddbf620 100644 --- a/deps/acorn/acorn/package.json +++ b/deps/acorn/acorn/package.json @@ -16,7 +16,7 @@ ], "./package.json": "./package.json" }, - "version": "8.14.0", + "version": "8.15.0", "engines": { "node": ">=0.4.0" }, diff --git a/deps/cjs-module-lexer/LICENSE b/deps/cjs-module-lexer/LICENSE index b31c17aa33c..935b357962d 100644 --- a/deps/cjs-module-lexer/LICENSE +++ b/deps/cjs-module-lexer/LICENSE @@ -1,10 +1,10 @@ -MIT License ------------ - -Copyright (C) 2018-2020 Guy Bedford - -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. +MIT License +----------- + +Copyright (C) 2018-2020 Guy Bedford + +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/deps/cjs-module-lexer/README.md b/deps/cjs-module-lexer/README.md index 2af01279ed2..addf5edc6b1 100644 --- a/deps/cjs-module-lexer/README.md +++ b/deps/cjs-module-lexer/README.md @@ -1,462 +1,483 @@ -# CJS Module Lexer - -[![Build Status][travis-image]][travis-url] - -A [very fast](#benchmarks) JS CommonJS module syntax lexer used to detect the most likely list of named exports of a CommonJS module. - -Outputs the list of named exports (`exports.name = ...`) and possible module reexports (`module.exports = require('...')`), including the common transpiler variations of these cases. - -Forked from https://github.com/guybedford/es-module-lexer. - -_Comprehensively handles the JS language grammar while remaining small and fast. - ~90ms per MB of JS cold and ~15ms per MB of JS warm, [see benchmarks](#benchmarks) for more info._ - -### Project Status - -This project is used in Node.js core for detecting the named exports available when importing a CJS module into ESM, and is maintained for this purpose. - -PRs will be accepted and upstreamed for parser bugs, performance improvements or new syntax support only. - -_Detection patterns for this project are **frozen**_. This is because adding any new export detection patterns would result in fragmented backwards-compatibility. Specifically, it would be very difficult to figure out why an ES module named export for CommonJS might work in newer Node.js versions but not older versions. This problem would only be discovered downstream of module authors, with the fix for module authors being to then have to understand which patterns in this project provide full backwards-compatibily. Rather, by fully freezing the detected patterns, if it works in any Node.js version it will work in any other. Build tools can also reliably treat the supported syntax for this project as a part of their output target for ensuring syntax support. - -### Usage - -``` -npm install cjs-module-lexer -``` - -For use in CommonJS: - -```js -const { parse } = require('cjs-module-lexer'); - -// `init` return a promise for parity with the ESM API, but you do not have to call it - -const { exports, reexports } = parse(` - // named exports detection - module.exports.a = 'a'; - (function () { - exports.b = 'b'; - })(); - Object.defineProperty(exports, 'c', { value: 'c' }); - /* exports.d = 'not detected'; */ - - // reexports detection - if (maybe) module.exports = require('./dep1.js'); - if (another) module.exports = require('./dep2.js'); - - // literal exports assignments - module.exports = { a, b: c, d, 'e': f } - - // __esModule detection - Object.defineProperty(module.exports, '__esModule', { value: true }) -`); - -// exports === ['a', 'b', 'c', '__esModule'] -// reexports === ['./dep1.js', './dep2.js'] -``` - -When using the ESM version, Wasm is supported instead: - -```js -import { parse, init } from 'cjs-module-lexer'; -// init() needs to be called and waited upon, or use initSync() to compile -// Wasm blockingly and synchronously. -await init(); -const { exports, reexports } = parse(source); -``` - -The Wasm build is around 1.5x faster and without a cold start. - -### Grammar - -CommonJS exports matches are run against the source token stream. - -The token grammar is: - -``` -IDENTIFIER: As defined by ECMA-262, without support for identifier `\` escapes, filtered to remove strict reserved words: - "implements", "interface", "let", "package", "private", "protected", "public", "static", "yield", "enum" - -STRING_LITERAL: A `"` or `'` bounded ECMA-262 string literal. - -MODULE_EXPORTS: `module` `.` `exports` - -EXPORTS_IDENTIFIER: MODULE_EXPORTS_IDENTIFIER | `exports` - -EXPORTS_DOT_ASSIGN: EXPORTS_IDENTIFIER `.` IDENTIFIER `=` - -EXPORTS_LITERAL_COMPUTED_ASSIGN: EXPORTS_IDENTIFIER `[` STRING_LITERAL `]` `=` - -EXPORTS_LITERAL_PROP: (IDENTIFIER (`:` IDENTIFIER)?) | (STRING_LITERAL `:` IDENTIFIER) - -EXPORTS_SPREAD: `...` (IDENTIFIER | REQUIRE) - -EXPORTS_MEMBER: EXPORTS_DOT_ASSIGN | EXPORTS_LITERAL_COMPUTED_ASSIGN - -EXPORTS_DEFINE: `Object` `.` `defineProperty `(` EXPORTS_IDENFITIER `,` STRING_LITERAL - -EXPORTS_DEFINE_VALUE: EXPORTS_DEFINE `, {` - (`enumerable: true,`)? - ( - `value:` | - `get` (`: function` IDENTIFIER? )? `() {` return IDENTIFIER (`.` IDENTIFIER | `[` STRING_LITERAL `]`)? `;`? `}` `,`? - ) - `})` - -EXPORTS_LITERAL: MODULE_EXPORTS `=` `{` (EXPORTS_LITERAL_PROP | EXPORTS_SPREAD) `,`)+ `}` - -REQUIRE: `require` `(` STRING_LITERAL `)` - -EXPORTS_ASSIGN: (`var` | `const` | `let`) IDENTIFIER `=` (`_interopRequireWildcard (`)? REQUIRE - -MODULE_EXPORTS_ASSIGN: MODULE_EXPORTS `=` REQUIRE - -EXPORT_STAR: (`__export` | `__exportStar`) `(` REQUIRE - -EXPORT_STAR_LIB: `Object.keys(` IDENTIFIER$1 `).forEach(function (` IDENTIFIER$2 `) {` - ( - ( - `if (` IDENTIFIER$2 `===` ( `'default'` | `"default"` ) `||` IDENTIFIER$2 `===` ( '__esModule' | `"__esModule"` ) `) return` `;`? - ( - (`if (Object` `.prototype`? `.hasOwnProperty.call(` IDENTIFIER `, ` IDENTIFIER$2 `)) return` `;`?)? - (`if (` IDENTIFIER$2 `in` EXPORTS_IDENTIFIER `&&` EXPORTS_IDENTIFIER `[` IDENTIFIER$2 `] ===` IDENTIFIER$1 `[` IDENTIFIER$2 `]) return` `;`)? - )? - ) | - `if (` IDENTIFIER$2 `!==` ( `'default'` | `"default"` ) (`&& !` (`Object` `.prototype`? `.hasOwnProperty.call(` IDENTIFIER `, ` IDENTIFIER$2 `)` | IDENTIFIER `.hasOwnProperty(` IDENTIFIER$2 `)`))? `)` - ) - ( - EXPORTS_IDENTIFIER `[` IDENTIFIER$2 `] =` IDENTIFIER$1 `[` IDENTIFIER$2 `]` `;`? | - `Object.defineProperty(` EXPORTS_IDENTIFIER `, ` IDENTIFIER$2 `, { enumerable: true, get` (`: function` IDENTIFIER? )? `() { return ` IDENTIFIER$1 `[` IDENTIFIER$2 `]` `;`? `}` `,`? `})` `;`? - ) - `})` -``` - -Spacing between tokens is taken to be any ECMA-262 whitespace, ECMA-262 block comment or ECMA-262 line comment. - -* The returned export names are taken to be the combination of: - 1. All `IDENTIFIER` and `STRING_LITERAL` slots for `EXPORTS_MEMBER` and `EXPORTS_LITERAL` matches. - 2. The first `STRING_LITERAL` slot for all `EXPORTS_DEFINE_VALUE` matches where that same string is not an `EXPORTS_DEFINE` match that is not also an `EXPORTS_DEFINE_VALUE` match. -* The reexport specifiers are taken to be the combination of: - 1. The `REQUIRE` matches of the last matched of either `MODULE_EXPORTS_ASSIGN` or `EXPORTS_LITERAL`. - 2. All _top-level_ `EXPORT_STAR` `REQUIRE` matches and `EXPORTS_ASSIGN` matches whose `IDENTIFIER` also matches the first `IDENTIFIER` in `EXPORT_STAR_LIB`. - -### Parsing Examples - -#### Named Exports Parsing - -The basic matching rules for named exports are `exports.name`, `exports['name']` or `Object.defineProperty(exports, 'name', ...)`. This matching is done without scope analysis and regardless of the expression position: - -```js -// DETECTS EXPORTS: a, b -(function (exports) { - exports.a = 'a'; - exports['b'] = 'b'; -})(exports); -``` - -Because there is no scope analysis, the above detection may overclassify: - -```js -// DETECTS EXPORTS: a, b, c -(function (exports, Object) { - exports.a = 'a'; - exports['b'] = 'b'; - if (false) - exports.c = 'c'; -})(NOT_EXPORTS, NOT_OBJECT); -``` - -It will in turn underclassify in cases where the identifiers are renamed: - -```js -// DETECTS: NO EXPORTS -(function (e) { - e.a = 'a'; - e['b'] = 'b'; -})(exports); -``` - -#### Getter Exports Parsing - -`Object.defineProperty` is detected for specifically value and getter forms returning an identifier or member expression: - -```js -// DETECTS: a, b, c, d, __esModule -Object.defineProperty(exports, 'a', { - enumerable: true, - get: function () { - return q.p; - } -}); -Object.defineProperty(exports, 'b', { - enumerable: true, - get: function () { - return q['p']; - } -}); -Object.defineProperty(exports, 'c', { - enumerable: true, - get () { - return b; - } -}); -Object.defineProperty(exports, 'd', { value: 'd' }); -Object.defineProperty(exports, '__esModule', { value: true }); -``` - -Value properties are also detected specifically: - -```js -Object.defineProperty(exports, 'a', { - value: 'no problem' -}); -``` - -To avoid matching getters that have side effects, any getter for an export name that does not support the forms above will -opt-out of the getter matching: - -```js -// DETECTS: NO EXPORTS -Object.defineProperty(exports, 'a', { - get () { - return 'nope'; - } -}); - -if (false) { - Object.defineProperty(module.exports, 'a', { - get () { - return dynamic(); - } - }) -} -``` - -Alternative object definition structures or getter function bodies are not detected: - -```js -// DETECTS: NO EXPORTS -Object.defineProperty(exports, 'a', { - enumerable: false, - get () { - return p; - } -}); -Object.defineProperty(exports, 'b', { - configurable: true, - get () { - return p; - } -}); -Object.defineProperty(exports, 'c', { - get: () => p -}); -Object.defineProperty(exports, 'd', { - enumerable: true, - get: function () { - return dynamic(); - } -}); -Object.defineProperty(exports, 'e', { - enumerable: true, - get () { - return 'str'; - } -}); -``` - -`Object.defineProperties` is also not supported. - -#### Exports Object Assignment - -A best-effort is made to detect `module.exports` object assignments, but because this is not a full parser, arbitrary expressions are not handled in the -object parsing process. - -Simple object definitions are supported: - -```js -// DETECTS EXPORTS: a, b, c -module.exports = { - a, - 'b': b, - c: c, - ...d -}; -``` - -Object properties that are not identifiers or string expressions will bail out of the object detection, while spreads are ignored: - -```js -// DETECTS EXPORTS: a, b -module.exports = { - a, - ...d, - b: require('c'), - c: "not detected since require('c') above bails the object detection" -} -``` - -`Object.defineProperties` is not currently supported either. - -#### module.exports reexport assignment - -Any `module.exports = require('mod')` assignment is detected as a reexport, but only the last one is returned: - -```js -// DETECTS REEXPORTS: c -module.exports = require('a'); -(module => module.exports = require('b'))(NOT_MODULE); -if (false) module.exports = require('c'); -``` - -This is to avoid over-classification in Webpack bundles with externals which include `module.exports = require('external')` in their source for every external dependency. - -In exports object assignment, any spread of `require()` are detected as multiple separate reexports: - -```js -// DETECTS REEXPORTS: a, b -module.exports = require('ignored'); -module.exports = { - ...require('a'), - ...require('b') -}; -``` - -#### Transpiler Re-exports - -For named exports, transpiler output works well with the rules described above. - -But for star re-exports, special care is taken to support common patterns of transpiler outputs from Babel and TypeScript as well as bundlers like RollupJS. -These reexport and star reexport patterns are restricted to only be detected at the top-level as provided by the direct output of these tools. - -For example, `export * from 'external'` is output by Babel as: - -```js -"use strict"; - -exports.__esModule = true; - -var _external = require("external"); - -Object.keys(_external).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - exports[key] = _external[key]; -}); -``` - -Where the `var _external = require("external")` is specifically detected as well as the `Object.keys(_external)` statement, down to the exact -for of that entire expression including minor variations of the output. The `_external` and `key` identifiers are carefully matched in this -detection. - -Similarly for TypeScript, `export * from 'external'` is output as: - -```js -"use strict"; -function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; -} -Object.defineProperty(exports, "__esModule", { value: true }); -__export(require("external")); -``` - -Where the `__export(require("external"))` statement is explicitly detected as a reexport, including variations `tslib.__export` and `__exportStar`. - -### Environment Support - -Node.js 10+, and [all browsers with Web Assembly support](https://caniuse.com/#feat=wasm). - -### JS Grammar Support - -* Token state parses all line comments, block comments, strings, template strings, blocks, parens and punctuators. -* Division operator / regex token ambiguity is handled via backtracking checks against punctuator prefixes, including closing brace or paren backtracking. -* Always correctly parses valid JS source, but may parse invalid JS source without errors. - -### Benchmarks - -Benchmarks can be run with `npm run bench`. - -Current results: - -JS Build: - -``` -Module load time -> 4ms -Cold Run, All Samples -test/samples/*.js (3635 KiB) -> 299ms - -Warm Runs (average of 25 runs) -test/samples/angular.js (1410 KiB) -> 13.96ms -test/samples/angular.min.js (303 KiB) -> 4.72ms -test/samples/d3.js (553 KiB) -> 6.76ms -test/samples/d3.min.js (250 KiB) -> 4ms -test/samples/magic-string.js (34 KiB) -> 0.64ms -test/samples/magic-string.min.js (20 KiB) -> 0ms -test/samples/rollup.js (698 KiB) -> 8.48ms -test/samples/rollup.min.js (367 KiB) -> 5.36ms - -Warm Runs, All Samples (average of 25 runs) -test/samples/*.js (3635 KiB) -> 40.28ms -``` - -Wasm Build: -``` -Module load time -> 10ms -Cold Run, All Samples -test/samples/*.js (3635 KiB) -> 43ms - -Warm Runs (average of 25 runs) -test/samples/angular.js (1410 KiB) -> 9.32ms -test/samples/angular.min.js (303 KiB) -> 3.16ms -test/samples/d3.js (553 KiB) -> 5ms -test/samples/d3.min.js (250 KiB) -> 2.32ms -test/samples/magic-string.js (34 KiB) -> 0.16ms -test/samples/magic-string.min.js (20 KiB) -> 0ms -test/samples/rollup.js (698 KiB) -> 6.28ms -test/samples/rollup.min.js (367 KiB) -> 3.6ms - -Warm Runs, All Samples (average of 25 runs) -test/samples/*.js (3635 KiB) -> 27.76ms -``` - -### Wasm Build Steps - -To build download the WASI SDK from https://github.com/WebAssembly/wasi-sdk/releases. - -The Makefile assumes the existence of "wasi-sdk-11.0" and "wabt" (optional) as sibling folders to this project. - -The build through the Makefile is then run via `make lib/lexer.wasm`, which can also be triggered via `npm run build-wasm` to create `dist/lexer.js`. - -On Windows it may be preferable to use the Linux subsystem. - -After the Web Assembly build, the CJS build can be triggered via `npm run build`. - -Optimization passes are run with [Binaryen](https://github.com/WebAssembly/binaryen) prior to publish to reduce the Web Assembly footprint. - -### License - -MIT - -[travis-url]: https://travis-ci.org/guybedford/es-module-lexer -[travis-image]: https://travis-ci.org/guybedford/es-module-lexer.svg?branch=master +# CJS Module Lexer + +[![Build Status][travis-image]][travis-url] + +A [very fast](#benchmarks) JS CommonJS module syntax lexer used to detect the most likely list of named exports of a CommonJS module. + +Outputs the list of named exports (`exports.name = ...`) and possible module reexports (`module.exports = require('...')`), including the common transpiler variations of these cases. + +Forked from https://github.com/guybedford/es-module-lexer. + +_Comprehensively handles the JS language grammar while remaining small and fast. - ~90ms per MB of JS cold and ~15ms per MB of JS warm, [see benchmarks](#benchmarks) for more info._ + +### Project Status + +This project is used in Node.js core for detecting the named exports available when importing a CJS module into ESM, and is maintained for this purpose. + +PRs will be accepted and upstreamed for parser bugs, performance improvements or new syntax support only. + +_Detection patterns for this project are **frozen**_. This is because adding any new export detection patterns would result in fragmented backwards-compatibility. Specifically, it would be very difficult to figure out why an ES module named export for CommonJS might work in newer Node.js versions but not older versions. This problem would only be discovered downstream of module authors, with the fix for module authors being to then have to understand which patterns in this project provide full backwards-compatibily. Rather, by fully freezing the detected patterns, if it works in any Node.js version it will work in any other. Build tools can also reliably treat the supported syntax for this project as a part of their output target for ensuring syntax support. + +### Usage + +``` +npm install cjs-module-lexer +``` + +For use in CommonJS: + +```js +const { parse } = require('cjs-module-lexer'); + +// `init` return a promise for parity with the ESM API, but you do not have to call it + +const { exports, reexports } = parse(` + // named exports detection + module.exports.a = 'a'; + (function () { + exports.b = 'b'; + })(); + Object.defineProperty(exports, 'c', { value: 'c' }); + /* exports.d = 'not detected'; */ + + // reexports detection + if (maybe) module.exports = require('./dep1.js'); + if (another) module.exports = require('./dep2.js'); + + // literal exports assignments + module.exports = { a, b: c, d, 'e': f } + + // __esModule detection + Object.defineProperty(module.exports, '__esModule', { value: true }) +`); + +// exports === ['a', 'b', 'c', '__esModule'] +// reexports === ['./dep1.js', './dep2.js'] +``` + +When using the ESM version, Wasm is supported instead: + +```js +import { parse, init } from 'cjs-module-lexer'; +// init() needs to be called and waited upon, or use initSync() to compile +// Wasm blockingly and synchronously. +await init(); +const { exports, reexports } = parse(source); +``` + +The Wasm build is around 1.5x faster and without a cold start. + +### Grammar + +CommonJS exports matches are run against the source token stream. + +The token grammar is: + +``` +IDENTIFIER: As defined by ECMA-262, without support for identifier `\` escapes, filtered to remove strict reserved words: + "implements", "interface", "let", "package", "private", "protected", "public", "static", "yield", "enum" + +STRING_LITERAL: A `"` or `'` bounded ECMA-262 string literal. + +MODULE_EXPORTS: `module` `.` `exports` + +EXPORTS_IDENTIFIER: MODULE_EXPORTS_IDENTIFIER | `exports` + +EXPORTS_DOT_ASSIGN: EXPORTS_IDENTIFIER `.` IDENTIFIER `=` + +EXPORTS_LITERAL_COMPUTED_ASSIGN: EXPORTS_IDENTIFIER `[` STRING_LITERAL `]` `=` + +EXPORTS_LITERAL_PROP: (IDENTIFIER (`:` IDENTIFIER)?) | (STRING_LITERAL `:` IDENTIFIER) + +EXPORTS_SPREAD: `...` (IDENTIFIER | REQUIRE) + +EXPORTS_MEMBER: EXPORTS_DOT_ASSIGN | EXPORTS_LITERAL_COMPUTED_ASSIGN + +EXPORTS_DEFINE: `Object` `.` `defineProperty `(` EXPORTS_IDENFITIER `,` STRING_LITERAL + +EXPORTS_DEFINE_VALUE: EXPORTS_DEFINE `, {` + (`enumerable: true,`)? + ( + `value:` | + `get` (`: function` IDENTIFIER? )? `() {` return IDENTIFIER (`.` IDENTIFIER | `[` STRING_LITERAL `]`)? `;`? `}` `,`? + ) + `})` + +EXPORTS_LITERAL: MODULE_EXPORTS `=` `{` (EXPORTS_LITERAL_PROP | EXPORTS_SPREAD) `,`)+ `}` + +REQUIRE: `require` `(` STRING_LITERAL `)` + +EXPORTS_ASSIGN: (`var` | `const` | `let`) IDENTIFIER `=` (`_interopRequireWildcard (`)? REQUIRE + +MODULE_EXPORTS_ASSIGN: MODULE_EXPORTS `=` REQUIRE + +EXPORT_STAR: (`__export` | `__exportStar`) `(` REQUIRE + +EXPORT_STAR_LIB: `Object.keys(` IDENTIFIER$1 `).forEach(function (` IDENTIFIER$2 `) {` + ( + ( + `if (` IDENTIFIER$2 `===` ( `'default'` | `"default"` ) `||` IDENTIFIER$2 `===` ( '__esModule' | `"__esModule"` ) `) return` `;`? + ( + (`if (Object` `.prototype`? `.hasOwnProperty.call(` IDENTIFIER `, ` IDENTIFIER$2 `)) return` `;`?)? + (`if (` IDENTIFIER$2 `in` EXPORTS_IDENTIFIER `&&` EXPORTS_IDENTIFIER `[` IDENTIFIER$2 `] ===` IDENTIFIER$1 `[` IDENTIFIER$2 `]) return` `;`)? + )? + ) | + `if (` IDENTIFIER$2 `!==` ( `'default'` | `"default"` ) (`&& !` (`Object` `.prototype`? `.hasOwnProperty.call(` IDENTIFIER `, ` IDENTIFIER$2 `)` | IDENTIFIER `.hasOwnProperty(` IDENTIFIER$2 `)`))? `)` + ) + ( + EXPORTS_IDENTIFIER `[` IDENTIFIER$2 `] =` IDENTIFIER$1 `[` IDENTIFIER$2 `]` `;`? | + `Object.defineProperty(` EXPORTS_IDENTIFIER `, ` IDENTIFIER$2 `, { enumerable: true, get` (`: function` IDENTIFIER? )? `() { return ` IDENTIFIER$1 `[` IDENTIFIER$2 `]` `;`? `}` `,`? `})` `;`? + ) + `})` +``` + +Spacing between tokens is taken to be any ECMA-262 whitespace, ECMA-262 block comment or ECMA-262 line comment. + +* The returned export names are taken to be the combination of: + 1. All `IDENTIFIER` and `STRING_LITERAL` slots for `EXPORTS_MEMBER` and `EXPORTS_LITERAL` matches. + 2. The first `STRING_LITERAL` slot for all `EXPORTS_DEFINE_VALUE` matches where that same string is not an `EXPORTS_DEFINE` match that is not also an `EXPORTS_DEFINE_VALUE` match. +* The reexport specifiers are taken to be the combination of: + 1. The `REQUIRE` matches of the last matched of either `MODULE_EXPORTS_ASSIGN` or `EXPORTS_LITERAL`. + 2. All _top-level_ `EXPORT_STAR` `REQUIRE` matches and `EXPORTS_ASSIGN` matches whose `IDENTIFIER` also matches the first `IDENTIFIER` in `EXPORT_STAR_LIB`. + +### Parsing Examples + +#### Named Exports Parsing + +The basic matching rules for named exports are `exports.name`, `exports['name']` or `Object.defineProperty(exports, 'name', ...)`. This matching is done without scope analysis and regardless of the expression position: + +```js +// DETECTS EXPORTS: a, b +(function (exports) { + exports.a = 'a'; + exports['b'] = 'b'; +})(exports); +``` + +Because there is no scope analysis, the above detection may overclassify: + +```js +// DETECTS EXPORTS: a, b, c +(function (exports, Object) { + exports.a = 'a'; + exports['b'] = 'b'; + if (false) + exports.c = 'c'; +})(NOT_EXPORTS, NOT_OBJECT); +``` + +It will in turn underclassify in cases where the identifiers are renamed: + +```js +// DETECTS: NO EXPORTS +(function (e) { + e.a = 'a'; + e['b'] = 'b'; +})(exports); +``` + +#### Getter Exports Parsing + +`Object.defineProperty` is detected for specifically value and getter forms returning an identifier or member expression: + +```js +// DETECTS: a, b, c, d, __esModule +Object.defineProperty(exports, 'a', { + enumerable: true, + get: function () { + return q.p; + } +}); +Object.defineProperty(exports, 'b', { + enumerable: true, + get: function () { + return q['p']; + } +}); +Object.defineProperty(exports, 'c', { + enumerable: true, + get () { + return b; + } +}); +Object.defineProperty(exports, 'd', { value: 'd' }); +Object.defineProperty(exports, '__esModule', { value: true }); +``` + +Value properties are also detected specifically: + +```js +Object.defineProperty(exports, 'a', { + value: 'no problem' +}); +``` + +To avoid matching getters that have side effects, any getter for an export name that does not support the forms above will +opt-out of the getter matching: + +```js +// DETECTS: NO EXPORTS +Object.defineProperty(exports, 'a', { + get () { + return 'nope'; + } +}); + +if (false) { + Object.defineProperty(module.exports, 'a', { + get () { + return dynamic(); + } + }) +} +``` + +Alternative object definition structures or getter function bodies are not detected: + +```js +// DETECTS: NO EXPORTS +Object.defineProperty(exports, 'a', { + enumerable: false, + get () { + return p; + } +}); +Object.defineProperty(exports, 'b', { + configurable: true, + get () { + return p; + } +}); +Object.defineProperty(exports, 'c', { + get: () => p +}); +Object.defineProperty(exports, 'd', { + enumerable: true, + get: function () { + return dynamic(); + } +}); +Object.defineProperty(exports, 'e', { + enumerable: true, + get () { + return 'str'; + } +}); +``` + +`Object.defineProperties` is also not supported. + +#### Exports Object Assignment + +A best-effort is made to detect `module.exports` object assignments, but because this is not a full parser, arbitrary expressions are not handled in the +object parsing process. + +Simple object definitions are supported: + +```js +// DETECTS EXPORTS: a, b, c +module.exports = { + a, + 'b': b, + c: c, + ...d +}; +``` + +Object properties that are not identifiers or string expressions will bail out of the object detection, while spreads are ignored: + +```js +// DETECTS EXPORTS: a, b +module.exports = { + a, + ...d, + b: require('c'), + c: "not detected since require('c') above bails the object detection" +} +``` + +`Object.defineProperties` is not currently supported either. + +#### module.exports reexport assignment + +Any `module.exports = require('mod')` assignment is detected as a reexport, but only the last one is returned: + +```js +// DETECTS REEXPORTS: c +module.exports = require('a'); +(module => module.exports = require('b'))(NOT_MODULE); +if (false) module.exports = require('c'); +``` + +This is to avoid over-classification in Webpack bundles with externals which include `module.exports = require('external')` in their source for every external dependency. + +In exports object assignment, any spread of `require()` are detected as multiple separate reexports: + +```js +// DETECTS REEXPORTS: a, b +module.exports = require('ignored'); +module.exports = { + ...require('a'), + ...require('b') +}; +``` + +#### Transpiler Re-exports + +For named exports, transpiler output works well with the rules described above. + +But for star re-exports, special care is taken to support common patterns of transpiler outputs from Babel and TypeScript as well as bundlers like RollupJS. +These reexport and star reexport patterns are restricted to only be detected at the top-level as provided by the direct output of these tools. + +For example, `export * from 'external'` is output by Babel as: + +```js +"use strict"; + +exports.__esModule = true; + +var _external = require("external"); + +Object.keys(_external).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + exports[key] = _external[key]; +}); +``` + +Where the `var _external = require("external")` is specifically detected as well as the `Object.keys(_external)` statement, down to the exact +for of that entire expression including minor variations of the output. The `_external` and `key` identifiers are carefully matched in this +detection. + +Similarly for TypeScript, `export * from 'external'` is output as: + +```js +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +__export(require("external")); +``` + +Where the `__export(require("external"))` statement is explicitly detected as a reexport, including variations `tslib.__export` and `__exportStar`. + +### Environment Support + +Node.js 10+, and [all browsers with Web Assembly support](https://caniuse.com/#feat=wasm). + +### JS Grammar Support + +* Token state parses all line comments, block comments, strings, template strings, blocks, parens and punctuators. +* Division operator / regex token ambiguity is handled via backtracking checks against punctuator prefixes, including closing brace or paren backtracking. +* Always correctly parses valid JS source, but may parse invalid JS source without errors. + +### Benchmarks + +Benchmarks can be run with `npm run bench`. + +Current results: + +JS Build: + +``` +Module load time +> 4ms +Cold Run, All Samples +test/samples/*.js (3635 KiB) +> 299ms + +Warm Runs (average of 25 runs) +test/samples/angular.js (1410 KiB) +> 13.96ms +test/samples/angular.min.js (303 KiB) +> 4.72ms +test/samples/d3.js (553 KiB) +> 6.76ms +test/samples/d3.min.js (250 KiB) +> 4ms +test/samples/magic-string.js (34 KiB) +> 0.64ms +test/samples/magic-string.min.js (20 KiB) +> 0ms +test/samples/rollup.js (698 KiB) +> 8.48ms +test/samples/rollup.min.js (367 KiB) +> 5.36ms + +Warm Runs, All Samples (average of 25 runs) +test/samples/*.js (3635 KiB) +> 40.28ms +``` + +Wasm Build: +``` +Module load time +> 10ms +Cold Run, All Samples +test/samples/*.js (3635 KiB) +> 43ms + +Warm Runs (average of 25 runs) +test/samples/angular.js (1410 KiB) +> 9.32ms +test/samples/angular.min.js (303 KiB) +> 3.16ms +test/samples/d3.js (553 KiB) +> 5ms +test/samples/d3.min.js (250 KiB) +> 2.32ms +test/samples/magic-string.js (34 KiB) +> 0.16ms +test/samples/magic-string.min.js (20 KiB) +> 0ms +test/samples/rollup.js (698 KiB) +> 6.28ms +test/samples/rollup.min.js (367 KiB) +> 3.6ms + +Warm Runs, All Samples (average of 25 runs) +test/samples/*.js (3635 KiB) +> 27.76ms +``` + +### Wasm Build Steps + +The build uses docker and make, they must be installed first. + +To build the lexer wasm run `npm run build-wasm`. + +Optimization passes are run with [Binaryen](https://github.com/WebAssembly/binaryen) +prior to publish to reduce the Web Assembly footprint. + +After building the lexer wasm, build the final distribution components +(lexer.js and lexer.mjs) by running `npm run build`. + +If you need to build lib/lexer.wat (optional) you must first install +[wabt](https://github.com/WebAssembly/wabt) as a sibling folder to this +project. The wat file is then build by running `make lib/lexer.wat` + +### Creating a Release +These are the steps to create and publish a release. You will need docker +installed as well as having installed [wabt](https://github.com/WebAssembly/wabt) +as outlined above: + +- [ ] Figure out if the release should be semver patch, minor or major based on the changes since + the last release and determine the new version. +- [ ] Update the package.json version, and run a full build and test + - npm install + - npm run build + - npm run test +- [ ] Commit and tag the changes, pushing up to main and the tag + - For example + - `git tag -a 1.4.2 -m "1.4.2"` + - `git push origin tag 1.4.2` +- [ ] Create the GitHub release +- [ ] Run npm publish from an account with access (asking somebody with access + the nodejs-foundation account is an option if you don't have access. + +### License + +MIT + +[travis-url]: https://travis-ci.org/guybedford/es-module-lexer +[travis-image]: https://travis-ci.org/guybedford/es-module-lexer.svg?branch=master diff --git a/deps/cjs-module-lexer/dist/lexer-external.js b/deps/cjs-module-lexer/dist/lexer-external.js deleted file mode 100644 index 1e5f49de622..00000000000 --- a/deps/cjs-module-lexer/dist/lexer-external.js +++ /dev/null @@ -1,91 +0,0 @@ -"use strict"; - -exports.init = init; -exports.parse = parse; -let wasm; -const isLE = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1; -function parse(source, name = '@') { - if (!wasm) throw new Error('Not initialized'); - const len = source.length + 1; - - // need 2 bytes per code point plus analysis space so we double again - const extraMem = (wasm.__heap_base.value || wasm.__heap_base) + len * 4 - wasm.memory.buffer.byteLength; - if (extraMem > 0) wasm.memory.grow(Math.ceil(extraMem / 65536)); - const addr = wasm.sa(len); - (isLE ? copyLE : copyBE)(source, new Uint16Array(wasm.memory.buffer, addr, len)); - const err_code = wasm.parseCJS(addr, source.length, 0, 0, 0); - if (err_code) { - const err = new Error(`Parse error ${name}${wasm.e()}:${source.slice(0, wasm.e()).split('\n').length}:${wasm.e() - source.lastIndexOf('\n', wasm.e() - 1)}`); - Object.assign(err, { - idx: wasm.e() - }); - if (err_code === 5 || err_code === 6 || err_code === 7) Object.assign(err, { - code: 'ERR_LEXER_ESM_SYNTAX' - }); - throw err; - } - let exports = new Set(), - reexports = new Set(), - unsafeGetters = new Set(); - while (wasm.rre()) { - const reexptStr = decode(source.slice(wasm.res(), wasm.ree())); - if (reexptStr) reexports.add(reexptStr); - } - while (wasm.ru()) unsafeGetters.add(decode(source.slice(wasm.us(), wasm.ue()))); - while (wasm.re()) { - let exptStr = decode(source.slice(wasm.es(), wasm.ee())); - if (exptStr !== undefined && !unsafeGetters.has(exptStr)) exports.add(exptStr); - } - return { - exports: [...exports], - reexports: [...reexports] - }; -} -function decode(str) { - if (str[0] === '"' || str[0] === '\'') { - try { - const decoded = (0, eval)(str); - // Filter to exclude non-matching UTF-16 surrogate strings - for (let i = 0; i < decoded.length; i++) { - const surrogatePrefix = decoded.charCodeAt(i) & 0xFC00; - if (surrogatePrefix < 0xD800) { - // Not a surrogate - continue; - } else if (surrogatePrefix === 0xD800) { - // Validate surrogate pair - if ((decoded.charCodeAt(++i) & 0xFC00) !== 0xDC00) return; - } else { - // Out-of-range surrogate code (above 0xD800) - return; - } - } - return decoded; - } catch {} - } else { - return str; - } -} -function copyBE(src, outBuf16) { - const len = src.length; - let i = 0; - while (i < len) { - const ch = src.charCodeAt(i); - outBuf16[i++] = (ch & 0xff) << 8 | ch >>> 8; - } -} -function copyLE(src, outBuf16) { - const len = src.length; - let i = 0; - while (i < len) outBuf16[i] = src.charCodeAt(i++); -} -let initPromise; -function init() { - if (initPromise) return initPromise; - return initPromise = (async () => { - const compiled = await WebAssembly.compile((await import('node:fs')).readFileSync(new URL(import.meta.resolve('../lib/lexer.wasm')))); - const { - exports - } = await WebAssembly.instantiate(compiled); - wasm = exports; - })(); -} \ No newline at end of file diff --git a/deps/cjs-module-lexer/dist/lexer.js b/deps/cjs-module-lexer/dist/lexer.js index 7c9b7124ae2..d59aaf1bc47 100644 --- a/deps/cjs-module-lexer/dist/lexer.js +++ b/deps/cjs-module-lexer/dist/lexer.js @@ -1 +1 @@ -"use strict";exports.init=init;exports.initSync=initSync;exports.parse=parse;let A;const Q=1===new Uint8Array(new Uint16Array([1]).buffer)[0];function parse(g,I="@"){if(!A)throw new Error("Not initialized");const D=g.length+1,N=(A.__heap_base.value||A.__heap_base)+4*D-A.memory.buffer.byteLength;N>0&&A.memory.grow(Math.ceil(N/65536));const k=A.sa(D);(Q?C:E)(g,new Uint16Array(A.memory.buffer,k,D));const w=A.parseCJS(k,g.length,0,0,0);if(w){const Q=new Error(`Parse error ${I}${A.e()}:${g.slice(0,A.e()).split("\n").length}:${A.e()-g.lastIndexOf("\n",A.e()-1)}`);throw Object.assign(Q,{idx:A.e()}),5!==w&&6!==w&&7!==w||Object.assign(Q,{code:"ERR_LEXER_ESM_SYNTAX"}),Q}let H=new Set,J=new Set,o=new Set;for(;A.rre();){const Q=B(g.slice(A.res(),A.ree()));Q&&J.add(Q)}for(;A.ru();)o.add(B(g.slice(A.us(),A.ue())));for(;A.re();){let Q=B(g.slice(A.es(),A.ee()));void 0===Q||o.has(Q)||H.add(Q)}return{exports:[...H],reexports:[...J]}}function B(A){if('"'!==A[0]&&"'"!==A[0])return A;try{const Q=(0,eval)(A);for(let A=0;A>>8}}function C(A,Q){const B=A.length;let E=0;for(;EA.charCodeAt(0))}let I;function init(){return I||(I=(async()=>{const Q=await WebAssembly.compile(g()),{exports:B}=await WebAssembly.instantiate(Q);A=B})())}function initSync(){if(A)return;const Q=new WebAssembly.Module(g()),{exports:B}=new WebAssembly.Instance(Q);A=B} \ No newline at end of file +"use strict";exports.init=init;exports.initSync=initSync;exports.parse=parse;let A;const B=1===new Uint8Array(new Uint16Array([1]).buffer)[0];function parse(I,C="@"){if(!A)throw new Error("Not initialized");const w=I.length+1,D=(A.__heap_base.value||A.__heap_base)+4*w-A.memory.buffer.byteLength;D>0&&A.memory.grow(Math.ceil(D/65536));const G=A.sa(w);(B?g:E)(I,new Uint16Array(A.memory.buffer,G,w));const S=A.parseCJS(G,I.length,0,0,0);if(S){const B=new Error(`Parse error ${C}${A.e()}:${I.slice(0,A.e()).split("\n").length}:${A.e()-I.lastIndexOf("\n",A.e()-1)}`);throw Object.assign(B,{idx:A.e()}),5!==S&&6!==S&&7!==S||Object.assign(B,{code:"ERR_LEXER_ESM_SYNTAX"}),B}let R=new Set,o=new Set,H=new Set;for(;A.rre();){const B=Q(I.slice(A.res(),A.ree()));B&&o.add(B)}for(;A.ru();)H.add(Q(I.slice(A.us(),A.ue())));for(;A.re();){let B=Q(I.slice(A.es(),A.ee()));void 0===B||H.has(B)||R.add(B)}return{exports:[...R],reexports:[...o]}}function Q(A){if('"'!==A[0]&&"'"!==A[0])return A;try{const B=(0,eval)(A);for(let A=0;A>>8}}function g(A,B){const Q=A.length;let E=0;for(;EA.charCodeAt(0))}let C;function init(){return C||(C=(async()=>{const B=await WebAssembly.compile(I()),{exports:Q}=await WebAssembly.instantiate(B);A=Q})())}function initSync(){if(A)return;const B=new WebAssembly.Module(I()),{exports:Q}=new WebAssembly.Instance(B);A=Q} \ No newline at end of file diff --git a/deps/cjs-module-lexer/dist/lexer.mjs b/deps/cjs-module-lexer/dist/lexer.mjs index 964b74cfa78..b6f5fb548bb 100644 --- a/deps/cjs-module-lexer/dist/lexer.mjs +++ b/deps/cjs-module-lexer/dist/lexer.mjs @@ -1,2 +1,2 @@ -/* cjs-module-lexer 1.4.1 */ -let A;const Q=1===new Uint8Array(new Uint16Array([1]).buffer)[0];export function parse(g,I="@"){if(!A)throw new Error("Not initialized");const D=g.length+1,N=(A.__heap_base.value||A.__heap_base)+4*D-A.memory.buffer.byteLength;N>0&&A.memory.grow(Math.ceil(N/65536));const k=A.sa(D);(Q?C:E)(g,new Uint16Array(A.memory.buffer,k,D));const w=A.parseCJS(k,g.length,0,0,0);if(w){const Q=new Error(`Parse error ${I}${A.e()}:${g.slice(0,A.e()).split("\n").length}:${A.e()-g.lastIndexOf("\n",A.e()-1)}`);throw Object.assign(Q,{idx:A.e()}),5!==w&&6!==w&&7!==w||Object.assign(Q,{code:"ERR_LEXER_ESM_SYNTAX"}),Q}let H=new Set,J=new Set,o=new Set;for(;A.rre();){const Q=B(g.slice(A.res(),A.ree()));Q&&J.add(Q)}for(;A.ru();)o.add(B(g.slice(A.us(),A.ue())));for(;A.re();){let Q=B(g.slice(A.es(),A.ee()));void 0===Q||o.has(Q)||H.add(Q)}return{exports:[...H],reexports:[...J]}}function B(A){if('"'!==A[0]&&"'"!==A[0])return A;try{const Q=(0,eval)(A);for(let A=0;A>>8}}function C(A,Q){const B=A.length;let E=0;for(;EA.charCodeAt(0))}let I;export function init(){return I||(I=(async()=>{const Q=await WebAssembly.compile(g()),{exports:B}=await WebAssembly.instantiate(Q);A=B})())}export function initSync(){if(A)return;const Q=new WebAssembly.Module(g()),{exports:B}=new WebAssembly.Instance(Q);A=B} \ No newline at end of file +/* cjs-module-lexer 2.1.0 */ +let A;const B=1===new Uint8Array(new Uint16Array([1]).buffer)[0];export function parse(I,C="@"){if(!A)throw new Error("Not initialized");const w=I.length+1,D=(A.__heap_base.value||A.__heap_base)+4*w-A.memory.buffer.byteLength;D>0&&A.memory.grow(Math.ceil(D/65536));const G=A.sa(w);(B?g:E)(I,new Uint16Array(A.memory.buffer,G,w));const S=A.parseCJS(G,I.length,0,0,0);if(S){const B=new Error(`Parse error ${C}${A.e()}:${I.slice(0,A.e()).split("\n").length}:${A.e()-I.lastIndexOf("\n",A.e()-1)}`);throw Object.assign(B,{idx:A.e()}),5!==S&&6!==S&&7!==S||Object.assign(B,{code:"ERR_LEXER_ESM_SYNTAX"}),B}let R=new Set,o=new Set,H=new Set;for(;A.rre();){const B=Q(I.slice(A.res(),A.ree()));B&&o.add(B)}for(;A.ru();)H.add(Q(I.slice(A.us(),A.ue())));for(;A.re();){let B=Q(I.slice(A.es(),A.ee()));void 0===B||H.has(B)||R.add(B)}return{exports:[...R],reexports:[...o]}}function Q(A){if('"'!==A[0]&&"'"!==A[0])return A;try{const B=(0,eval)(A);for(let A=0;A>>8}}function g(A,B){const Q=A.length;let E=0;for(;EA.charCodeAt(0))}let C;export function init(){return C||(C=(async()=>{const B=await WebAssembly.compile(I()),{exports:Q}=await WebAssembly.instantiate(B);A=Q})())}export function initSync(){if(A)return;const B=new WebAssembly.Module(I()),{exports:Q}=new WebAssembly.Instance(B);A=Q} \ No newline at end of file diff --git a/deps/cjs-module-lexer/lexer.js b/deps/cjs-module-lexer/lexer.js old mode 100644 new mode 100755 diff --git a/deps/cjs-module-lexer/src/.babelrc b/deps/cjs-module-lexer/src/.babelrc new file mode 100755 index 00000000000..ac89f952694 --- /dev/null +++ b/deps/cjs-module-lexer/src/.babelrc @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "@babel/plugin-transform-modules-commonjs", + { + "strict": true + }, + ] + ] +} diff --git a/deps/cjs-module-lexer/src/CHANGELOG.md b/deps/cjs-module-lexer/src/CHANGELOG.md new file mode 100644 index 00000000000..5a24d193fd4 --- /dev/null +++ b/deps/cjs-module-lexer/src/CHANGELOG.md @@ -0,0 +1,40 @@ +1.2.2 +- Fix RollupJS reexports bug (https://github.com/nodejs/cjs-module-lexer/pull/59) + +1.2.1 +- Support Unicode escapes in strings (https://github.com/nodejs/cjs-module-lexer/pull/55) +- Filter export strings to valid surrogate pairs (https://github.com/nodejs/cjs-module-lexer/pull/56) + +1.2.0 +- Support for non-identifier exports (https://github.com/nodejs/cjs-module-lexer/pull/54, @nicolo-ribaudo) + +1.1.1 +- Better support for Babel reexport getter function forms (https://github.com/nodejs/cjs-module-lexer/issues/50) +- Support Babel interopRequireWildcard reexports patterns (https://github.com/nodejs/cjs-module-lexer/issues/52) + +1.1.0 +- Support for Babel reexport conflict filter (https://github.com/nodejs/cjs-module-lexer/issues/36, @nicolo-ribaudo) +- Support trailing commas in getter patterns (https://github.com/nodejs/cjs-module-lexer/issues/31) +- Support for RollupJS reexports property checks (https://github.com/nodejs/cjs-module-lexer/issues/38) + +1.0.0 +- Unsafe getter tracking (https://github.com/nodejs/cjs-module-lexer/pull/29) + +0.6.0 +- API-only breaking change: Unify JS and Wasm interfaces (https://github.com/nodejs/cjs-module-lexer/pull/27) +- Add type definitions (https://github.com/nodejs/cjs-module-lexer/pull/28) + +0.5.2 +- Support named getter functions (https://github.com/nodejs/cjs-module-lexer/pull/26) + +0.5.1: +- Feature: Implement specific reexport getter forms (https://github.com/nodejs/cjs-module-lexer/pull/25) + +0.5.0 +- Breaking Change: No longer emit Object.defineProperty exports (https://github.com/nodejs/cjs-module-lexer/pull/24) +- Doc: Update link to WASI SDK (https://github.com/nodejs/cjs-module-lexer/pull/19) + +0.4.3 +- Support for Babel 7.12 reexports (https://github.com/nodejs/cjs-module-lexer/pull/16) +- Support module.exports = { ...require('x') } reexports (https://github.com/nodejs/cjs-module-lexer/pull/18) +- "if" keyword space parsing in exports matching (https://github.com/nodejs/cjs-module-lexer/pull/17) diff --git a/deps/cjs-module-lexer/src/LICENSE b/deps/cjs-module-lexer/src/LICENSE new file mode 100755 index 00000000000..935b357962d --- /dev/null +++ b/deps/cjs-module-lexer/src/LICENSE @@ -0,0 +1,10 @@ +MIT License +----------- + +Copyright (C) 2018-2020 Guy Bedford + +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/deps/cjs-module-lexer/src/Makefile b/deps/cjs-module-lexer/src/Makefile new file mode 100755 index 00000000000..9a75850f73a --- /dev/null +++ b/deps/cjs-module-lexer/src/Makefile @@ -0,0 +1,16 @@ +WASM2WAT := ../wabt/bin/wasm2wat +WASM_OPT := ../binaryen/bin/wasm-opt + +.PHONY: optimize clean + +lib/lexer.wat: lib/lexer.wasm + $(WASM2WAT) lib/lexer.wasm -o lib/lexer.wat + +lib/lexer.wasm: include-wasm/cjs-module-lexer.h src/lexer.c | lib/ + node build/wasm.js --docker + +lib/: + @mkdir -p $@ + +clean: + $(RM) lib/* diff --git a/deps/cjs-module-lexer/src/README.md b/deps/cjs-module-lexer/src/README.md new file mode 100755 index 00000000000..addf5edc6b1 --- /dev/null +++ b/deps/cjs-module-lexer/src/README.md @@ -0,0 +1,483 @@ +# CJS Module Lexer + +[![Build Status][travis-image]][travis-url] + +A [very fast](#benchmarks) JS CommonJS module syntax lexer used to detect the most likely list of named exports of a CommonJS module. + +Outputs the list of named exports (`exports.name = ...`) and possible module reexports (`module.exports = require('...')`), including the common transpiler variations of these cases. + +Forked from https://github.com/guybedford/es-module-lexer. + +_Comprehensively handles the JS language grammar while remaining small and fast. - ~90ms per MB of JS cold and ~15ms per MB of JS warm, [see benchmarks](#benchmarks) for more info._ + +### Project Status + +This project is used in Node.js core for detecting the named exports available when importing a CJS module into ESM, and is maintained for this purpose. + +PRs will be accepted and upstreamed for parser bugs, performance improvements or new syntax support only. + +_Detection patterns for this project are **frozen**_. This is because adding any new export detection patterns would result in fragmented backwards-compatibility. Specifically, it would be very difficult to figure out why an ES module named export for CommonJS might work in newer Node.js versions but not older versions. This problem would only be discovered downstream of module authors, with the fix for module authors being to then have to understand which patterns in this project provide full backwards-compatibily. Rather, by fully freezing the detected patterns, if it works in any Node.js version it will work in any other. Build tools can also reliably treat the supported syntax for this project as a part of their output target for ensuring syntax support. + +### Usage + +``` +npm install cjs-module-lexer +``` + +For use in CommonJS: + +```js +const { parse } = require('cjs-module-lexer'); + +// `init` return a promise for parity with the ESM API, but you do not have to call it + +const { exports, reexports } = parse(` + // named exports detection + module.exports.a = 'a'; + (function () { + exports.b = 'b'; + })(); + Object.defineProperty(exports, 'c', { value: 'c' }); + /* exports.d = 'not detected'; */ + + // reexports detection + if (maybe) module.exports = require('./dep1.js'); + if (another) module.exports = require('./dep2.js'); + + // literal exports assignments + module.exports = { a, b: c, d, 'e': f } + + // __esModule detection + Object.defineProperty(module.exports, '__esModule', { value: true }) +`); + +// exports === ['a', 'b', 'c', '__esModule'] +// reexports === ['./dep1.js', './dep2.js'] +``` + +When using the ESM version, Wasm is supported instead: + +```js +import { parse, init } from 'cjs-module-lexer'; +// init() needs to be called and waited upon, or use initSync() to compile +// Wasm blockingly and synchronously. +await init(); +const { exports, reexports } = parse(source); +``` + +The Wasm build is around 1.5x faster and without a cold start. + +### Grammar + +CommonJS exports matches are run against the source token stream. + +The token grammar is: + +``` +IDENTIFIER: As defined by ECMA-262, without support for identifier `\` escapes, filtered to remove strict reserved words: + "implements", "interface", "let", "package", "private", "protected", "public", "static", "yield", "enum" + +STRING_LITERAL: A `"` or `'` bounded ECMA-262 string literal. + +MODULE_EXPORTS: `module` `.` `exports` + +EXPORTS_IDENTIFIER: MODULE_EXPORTS_IDENTIFIER | `exports` + +EXPORTS_DOT_ASSIGN: EXPORTS_IDENTIFIER `.` IDENTIFIER `=` + +EXPORTS_LITERAL_COMPUTED_ASSIGN: EXPORTS_IDENTIFIER `[` STRING_LITERAL `]` `=` + +EXPORTS_LITERAL_PROP: (IDENTIFIER (`:` IDENTIFIER)?) | (STRING_LITERAL `:` IDENTIFIER) + +EXPORTS_SPREAD: `...` (IDENTIFIER | REQUIRE) + +EXPORTS_MEMBER: EXPORTS_DOT_ASSIGN | EXPORTS_LITERAL_COMPUTED_ASSIGN + +EXPORTS_DEFINE: `Object` `.` `defineProperty `(` EXPORTS_IDENFITIER `,` STRING_LITERAL + +EXPORTS_DEFINE_VALUE: EXPORTS_DEFINE `, {` + (`enumerable: true,`)? + ( + `value:` | + `get` (`: function` IDENTIFIER? )? `() {` return IDENTIFIER (`.` IDENTIFIER | `[` STRING_LITERAL `]`)? `;`? `}` `,`? + ) + `})` + +EXPORTS_LITERAL: MODULE_EXPORTS `=` `{` (EXPORTS_LITERAL_PROP | EXPORTS_SPREAD) `,`)+ `}` + +REQUIRE: `require` `(` STRING_LITERAL `)` + +EXPORTS_ASSIGN: (`var` | `const` | `let`) IDENTIFIER `=` (`_interopRequireWildcard (`)? REQUIRE + +MODULE_EXPORTS_ASSIGN: MODULE_EXPORTS `=` REQUIRE + +EXPORT_STAR: (`__export` | `__exportStar`) `(` REQUIRE + +EXPORT_STAR_LIB: `Object.keys(` IDENTIFIER$1 `).forEach(function (` IDENTIFIER$2 `) {` + ( + ( + `if (` IDENTIFIER$2 `===` ( `'default'` | `"default"` ) `||` IDENTIFIER$2 `===` ( '__esModule' | `"__esModule"` ) `) return` `;`? + ( + (`if (Object` `.prototype`? `.hasOwnProperty.call(` IDENTIFIER `, ` IDENTIFIER$2 `)) return` `;`?)? + (`if (` IDENTIFIER$2 `in` EXPORTS_IDENTIFIER `&&` EXPORTS_IDENTIFIER `[` IDENTIFIER$2 `] ===` IDENTIFIER$1 `[` IDENTIFIER$2 `]) return` `;`)? + )? + ) | + `if (` IDENTIFIER$2 `!==` ( `'default'` | `"default"` ) (`&& !` (`Object` `.prototype`? `.hasOwnProperty.call(` IDENTIFIER `, ` IDENTIFIER$2 `)` | IDENTIFIER `.hasOwnProperty(` IDENTIFIER$2 `)`))? `)` + ) + ( + EXPORTS_IDENTIFIER `[` IDENTIFIER$2 `] =` IDENTIFIER$1 `[` IDENTIFIER$2 `]` `;`? | + `Object.defineProperty(` EXPORTS_IDENTIFIER `, ` IDENTIFIER$2 `, { enumerable: true, get` (`: function` IDENTIFIER? )? `() { return ` IDENTIFIER$1 `[` IDENTIFIER$2 `]` `;`? `}` `,`? `})` `;`? + ) + `})` +``` + +Spacing between tokens is taken to be any ECMA-262 whitespace, ECMA-262 block comment or ECMA-262 line comment. + +* The returned export names are taken to be the combination of: + 1. All `IDENTIFIER` and `STRING_LITERAL` slots for `EXPORTS_MEMBER` and `EXPORTS_LITERAL` matches. + 2. The first `STRING_LITERAL` slot for all `EXPORTS_DEFINE_VALUE` matches where that same string is not an `EXPORTS_DEFINE` match that is not also an `EXPORTS_DEFINE_VALUE` match. +* The reexport specifiers are taken to be the combination of: + 1. The `REQUIRE` matches of the last matched of either `MODULE_EXPORTS_ASSIGN` or `EXPORTS_LITERAL`. + 2. All _top-level_ `EXPORT_STAR` `REQUIRE` matches and `EXPORTS_ASSIGN` matches whose `IDENTIFIER` also matches the first `IDENTIFIER` in `EXPORT_STAR_LIB`. + +### Parsing Examples + +#### Named Exports Parsing + +The basic matching rules for named exports are `exports.name`, `exports['name']` or `Object.defineProperty(exports, 'name', ...)`. This matching is done without scope analysis and regardless of the expression position: + +```js +// DETECTS EXPORTS: a, b +(function (exports) { + exports.a = 'a'; + exports['b'] = 'b'; +})(exports); +``` + +Because there is no scope analysis, the above detection may overclassify: + +```js +// DETECTS EXPORTS: a, b, c +(function (exports, Object) { + exports.a = 'a'; + exports['b'] = 'b'; + if (false) + exports.c = 'c'; +})(NOT_EXPORTS, NOT_OBJECT); +``` + +It will in turn underclassify in cases where the identifiers are renamed: + +```js +// DETECTS: NO EXPORTS +(function (e) { + e.a = 'a'; + e['b'] = 'b'; +})(exports); +``` + +#### Getter Exports Parsing + +`Object.defineProperty` is detected for specifically value and getter forms returning an identifier or member expression: + +```js +// DETECTS: a, b, c, d, __esModule +Object.defineProperty(exports, 'a', { + enumerable: true, + get: function () { + return q.p; + } +}); +Object.defineProperty(exports, 'b', { + enumerable: true, + get: function () { + return q['p']; + } +}); +Object.defineProperty(exports, 'c', { + enumerable: true, + get () { + return b; + } +}); +Object.defineProperty(exports, 'd', { value: 'd' }); +Object.defineProperty(exports, '__esModule', { value: true }); +``` + +Value properties are also detected specifically: + +```js +Object.defineProperty(exports, 'a', { + value: 'no problem' +}); +``` + +To avoid matching getters that have side effects, any getter for an export name that does not support the forms above will +opt-out of the getter matching: + +```js +// DETECTS: NO EXPORTS +Object.defineProperty(exports, 'a', { + get () { + return 'nope'; + } +}); + +if (false) { + Object.defineProperty(module.exports, 'a', { + get () { + return dynamic(); + } + }) +} +``` + +Alternative object definition structures or getter function bodies are not detected: + +```js +// DETECTS: NO EXPORTS +Object.defineProperty(exports, 'a', { + enumerable: false, + get () { + return p; + } +}); +Object.defineProperty(exports, 'b', { + configurable: true, + get () { + return p; + } +}); +Object.defineProperty(exports, 'c', { + get: () => p +}); +Object.defineProperty(exports, 'd', { + enumerable: true, + get: function () { + return dynamic(); + } +}); +Object.defineProperty(exports, 'e', { + enumerable: true, + get () { + return 'str'; + } +}); +``` + +`Object.defineProperties` is also not supported. + +#### Exports Object Assignment + +A best-effort is made to detect `module.exports` object assignments, but because this is not a full parser, arbitrary expressions are not handled in the +object parsing process. + +Simple object definitions are supported: + +```js +// DETECTS EXPORTS: a, b, c +module.exports = { + a, + 'b': b, + c: c, + ...d +}; +``` + +Object properties that are not identifiers or string expressions will bail out of the object detection, while spreads are ignored: + +```js +// DETECTS EXPORTS: a, b +module.exports = { + a, + ...d, + b: require('c'), + c: "not detected since require('c') above bails the object detection" +} +``` + +`Object.defineProperties` is not currently supported either. + +#### module.exports reexport assignment + +Any `module.exports = require('mod')` assignment is detected as a reexport, but only the last one is returned: + +```js +// DETECTS REEXPORTS: c +module.exports = require('a'); +(module => module.exports = require('b'))(NOT_MODULE); +if (false) module.exports = require('c'); +``` + +This is to avoid over-classification in Webpack bundles with externals which include `module.exports = require('external')` in their source for every external dependency. + +In exports object assignment, any spread of `require()` are detected as multiple separate reexports: + +```js +// DETECTS REEXPORTS: a, b +module.exports = require('ignored'); +module.exports = { + ...require('a'), + ...require('b') +}; +``` + +#### Transpiler Re-exports + +For named exports, transpiler output works well with the rules described above. + +But for star re-exports, special care is taken to support common patterns of transpiler outputs from Babel and TypeScript as well as bundlers like RollupJS. +These reexport and star reexport patterns are restricted to only be detected at the top-level as provided by the direct output of these tools. + +For example, `export * from 'external'` is output by Babel as: + +```js +"use strict"; + +exports.__esModule = true; + +var _external = require("external"); + +Object.keys(_external).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + exports[key] = _external[key]; +}); +``` + +Where the `var _external = require("external")` is specifically detected as well as the `Object.keys(_external)` statement, down to the exact +for of that entire expression including minor variations of the output. The `_external` and `key` identifiers are carefully matched in this +detection. + +Similarly for TypeScript, `export * from 'external'` is output as: + +```js +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +__export(require("external")); +``` + +Where the `__export(require("external"))` statement is explicitly detected as a reexport, including variations `tslib.__export` and `__exportStar`. + +### Environment Support + +Node.js 10+, and [all browsers with Web Assembly support](https://caniuse.com/#feat=wasm). + +### JS Grammar Support + +* Token state parses all line comments, block comments, strings, template strings, blocks, parens and punctuators. +* Division operator / regex token ambiguity is handled via backtracking checks against punctuator prefixes, including closing brace or paren backtracking. +* Always correctly parses valid JS source, but may parse invalid JS source without errors. + +### Benchmarks + +Benchmarks can be run with `npm run bench`. + +Current results: + +JS Build: + +``` +Module load time +> 4ms +Cold Run, All Samples +test/samples/*.js (3635 KiB) +> 299ms + +Warm Runs (average of 25 runs) +test/samples/angular.js (1410 KiB) +> 13.96ms +test/samples/angular.min.js (303 KiB) +> 4.72ms +test/samples/d3.js (553 KiB) +> 6.76ms +test/samples/d3.min.js (250 KiB) +> 4ms +test/samples/magic-string.js (34 KiB) +> 0.64ms +test/samples/magic-string.min.js (20 KiB) +> 0ms +test/samples/rollup.js (698 KiB) +> 8.48ms +test/samples/rollup.min.js (367 KiB) +> 5.36ms + +Warm Runs, All Samples (average of 25 runs) +test/samples/*.js (3635 KiB) +> 40.28ms +``` + +Wasm Build: +``` +Module load time +> 10ms +Cold Run, All Samples +test/samples/*.js (3635 KiB) +> 43ms + +Warm Runs (average of 25 runs) +test/samples/angular.js (1410 KiB) +> 9.32ms +test/samples/angular.min.js (303 KiB) +> 3.16ms +test/samples/d3.js (553 KiB) +> 5ms +test/samples/d3.min.js (250 KiB) +> 2.32ms +test/samples/magic-string.js (34 KiB) +> 0.16ms +test/samples/magic-string.min.js (20 KiB) +> 0ms +test/samples/rollup.js (698 KiB) +> 6.28ms +test/samples/rollup.min.js (367 KiB) +> 3.6ms + +Warm Runs, All Samples (average of 25 runs) +test/samples/*.js (3635 KiB) +> 27.76ms +``` + +### Wasm Build Steps + +The build uses docker and make, they must be installed first. + +To build the lexer wasm run `npm run build-wasm`. + +Optimization passes are run with [Binaryen](https://github.com/WebAssembly/binaryen) +prior to publish to reduce the Web Assembly footprint. + +After building the lexer wasm, build the final distribution components +(lexer.js and lexer.mjs) by running `npm run build`. + +If you need to build lib/lexer.wat (optional) you must first install +[wabt](https://github.com/WebAssembly/wabt) as a sibling folder to this +project. The wat file is then build by running `make lib/lexer.wat` + +### Creating a Release +These are the steps to create and publish a release. You will need docker +installed as well as having installed [wabt](https://github.com/WebAssembly/wabt) +as outlined above: + +- [ ] Figure out if the release should be semver patch, minor or major based on the changes since + the last release and determine the new version. +- [ ] Update the package.json version, and run a full build and test + - npm install + - npm run build + - npm run test +- [ ] Commit and tag the changes, pushing up to main and the tag + - For example + - `git tag -a 1.4.2 -m "1.4.2"` + - `git push origin tag 1.4.2` +- [ ] Create the GitHub release +- [ ] Run npm publish from an account with access (asking somebody with access + the nodejs-foundation account is an option if you don't have access. + +### License + +MIT + +[travis-url]: https://travis-ci.org/guybedford/es-module-lexer +[travis-image]: https://travis-ci.org/guybedford/es-module-lexer.svg?branch=master diff --git a/deps/cjs-module-lexer/src/build.js b/deps/cjs-module-lexer/src/build.js new file mode 100755 index 00000000000..da024d1a6cb --- /dev/null +++ b/deps/cjs-module-lexer/src/build.js @@ -0,0 +1,25 @@ +const fs = require('fs'); +const terser = require('terser'); + +const MINIFY = true; + +try { fs.mkdirSync('./dist'); } +catch (e) {} + +const wasmBuffer = fs.readFileSync('./lib/lexer.wasm'); +const jsSource = fs.readFileSync('./src/lexer.js').toString(); +const pjson = JSON.parse(fs.readFileSync('./package.json').toString()); + +const jsSourceProcessed = jsSource.replace('WASM_BINARY', wasmBuffer.toString('base64')); + +const minified = MINIFY && terser.minify(jsSourceProcessed, { + module: true, + output: { + preamble: `/* cjs-module-lexer ${pjson.version} */` + } +}); + +if (minified.error) + throw minified.error; + +fs.writeFileSync('./dist/lexer.mjs', minified ? minified.code : jsSourceProcessed); diff --git a/deps/cjs-module-lexer/src/build/Makefile b/deps/cjs-module-lexer/src/build/Makefile new file mode 100755 index 00000000000..b8e96d82534 --- /dev/null +++ b/deps/cjs-module-lexer/src/build/Makefile @@ -0,0 +1,24 @@ +# These flags depend on the system and may be overridden +WASM_CC := clang +WASM_CFLAGS := --sysroot=/usr/share/wasi-sysroot +WASM_LDFLAGS := -nostartfiles + +# These are project-specific and are expected to be kept intact +WASM_TARGET := -target wasm32-unknown-wasi +WASM_EXTRA_CFLAGS := -I include-wasm/ -Wno-logical-op-parentheses -Wno-parentheses -Oz +WASM_EXTRA_LDFLAGS := -Wl,-z,stack-size=13312,--no-entry,--compress-relocations,--strip-all +WASM_EXTRA_LDFLAGS += -Wl,--export=__heap_base,--export=parseCJS,--export=sa +WASM_EXTRA_LDFLAGS += -Wl,--export=e,--export=re,--export=es,--export=ee +WASM_EXTRA_LDFLAGS += -Wl,--export=rre,--export=ree,--export=res,--export=ru,--export=us,--export=ue + +lib/lexer.wasm: include-wasm/cjs-module-lexer.h src/lexer.c + @mkdir -p lib + $(WASM_CC) $(WASM_CFLAGS) $(WASM_TARGET) $(WASM_EXTRA_CFLAGS) \ + src/lexer.c -o lib/lexer.wasm \ + $(WASM_LDFLAGS) $(WASM_EXTRA_LDFLAGS) + +optimize: lib/lexer.wasm + ${WASM_OPT} -Oz lib/lexer.wasm -o lib/lexer.wasm + +clean: + rm lib/* diff --git a/deps/cjs-module-lexer/src/build/wasm.js b/deps/cjs-module-lexer/src/build/wasm.js new file mode 100644 index 00000000000..58fb64041d7 --- /dev/null +++ b/deps/cjs-module-lexer/src/build/wasm.js @@ -0,0 +1,54 @@ +'use strict' + +const WASM_BUILDER_CONTAINER = 'ghcr.io/nodejs/wasm-builder@sha256:975f391d907e42a75b8c72eb77c782181e941608687d4d8694c3e9df415a0970' // v0.0.9 + +const WASM_OPT = './wasm-opt' + +const { execSync } = require('node:child_process') +const { writeFileSync, readFileSync, existsSync, mkdirSync } = require('node:fs') +const { join, resolve } = require('node:path') + +const ROOT = resolve(__dirname, '../') + +let platform = process.env.WASM_PLATFORM +if (!platform && process.argv[2]) { + platform = execSync('docker info -f "{{.OSType}}/{{.Architecture}}"').toString().trim() +} + +if (process.argv[2] === '--docker') { + let cmd = `docker run --rm --platform=${platform.toString().trim()} ` + if (process.platform === 'linux') { + cmd += ` --user ${process.getuid()}:${process.getegid()}` + } + + if (!existsSync(`${ROOT}/dist`)){ + mkdirSync(`${ROOT}/dist`); + } + + cmd += ` --mount type=bind,source=${ROOT}/lib,target=/home/node/build/lib \ + --mount type=bind,source=${ROOT}/src,target=/home/node/build/src \ + --mount type=bind,source=${ROOT}/dist,target=/home/node/build/dist \ + --mount type=bind,source=${ROOT}/node_modules,target=/home/node/build/node_modules \ + --mount type=bind,source=${ROOT}/build/wasm.js,target=/home/node/build/wasm.js \ + --mount type=bind,source=${ROOT}/build/Makefile,target=/home/node/build/Makefile \ + --mount type=bind,source=${ROOT}/build.js,target=/home/node/build/build.js \ + --mount type=bind,source=${ROOT}/package.json,target=/home/node/build/package.json \ + --mount type=bind,source=${ROOT}/include-wasm,target=/home/node/build/include-wasm \ + -t ${WASM_BUILDER_CONTAINER} node wasm.js` + console.log(`> ${cmd}\n\n`) + execSync(cmd, { stdio: 'inherit' }) + process.exit(0) +} + +const hasOptimizer = (function () { + try { execSync(`${WASM_OPT} --version`); return true } catch (error) { return false } +})() + +// Build wasm binary +console.log('Building wasm'); +execSync(`make lib/lexer.wasm`, { stdio: 'inherit' }) +if (hasOptimizer) { + console.log('Optimizing wasm'); + execSync(`make optimize`, { stdio: 'inherit' }) +} +execSync(`node build.js`, { stdio: 'inherit' }) diff --git a/deps/cjs-module-lexer/src/include-wasm/cjs-module-lexer.h b/deps/cjs-module-lexer/src/include-wasm/cjs-module-lexer.h new file mode 100755 index 00000000000..ab2adca3c75 --- /dev/null +++ b/deps/cjs-module-lexer/src/include-wasm/cjs-module-lexer.h @@ -0,0 +1,238 @@ +#include +#include +#include +#include +#include + +extern unsigned char __heap_base; + +const uint16_t* source = (void*)&__heap_base; +uint32_t parse_error; + +struct Slice { + const uint16_t* start; + const uint16_t* end; + struct Slice* next; +}; +typedef struct Slice Slice; + +struct StarExportBinding { + const uint16_t* specifier_start; + const uint16_t* specifier_end; + const uint16_t* id_start; + const uint16_t* id_end; +}; +typedef struct StarExportBinding StarExportBinding; + +Slice* first_export = NULL; +Slice* export_read_head = NULL; +Slice* export_write_head = NULL; +Slice* first_reexport = NULL; +Slice* reexport_read_head = NULL; +Slice* reexport_write_head = NULL; +Slice* first_unsafe_getter = NULL; +Slice* unsafe_getter_read_head = NULL; +Slice* unsafe_getter_write_head = NULL; +void* analysis_base; +void* analysis_head; + +void bail (uint32_t err); + +// allocateSource +const uint16_t* sa (uint32_t utf16Len) { + const uint16_t* sourceEnd = source + utf16Len + 1; + // ensure source is null terminated + *(uint16_t*)(source + utf16Len) = '\0'; + analysis_base = (void*)sourceEnd; + analysis_head = analysis_base; + first_export = NULL; + export_write_head = NULL; + export_read_head = NULL; + first_reexport = NULL; + reexport_write_head = NULL; + reexport_read_head = NULL; + first_unsafe_getter = NULL; + unsafe_getter_write_head = NULL; + unsafe_getter_read_head = NULL; + return source; +} + +// getErr +uint32_t e () { + return parse_error; +} + +// getExportStart +uint32_t es () { + return export_read_head->start - source; +} +// getExportEnd +uint32_t ee () { + return export_read_head->end - source; +} +// getReexportStart +uint32_t res () { + return reexport_read_head->start - source; +} +// getReexportEnd +uint32_t ree () { + return reexport_read_head->end - source; +} +// getUnsafeGetterStart +uint32_t us () { + return unsafe_getter_read_head->start - source; +} +// getUnsafeGetterEnd +uint32_t ue () { + return unsafe_getter_read_head->end - source; +} +// readExport +bool re () { + if (export_read_head == NULL) + export_read_head = first_export; + else + export_read_head = export_read_head->next; + if (export_read_head == NULL) + return false; + return true; +} +// readReexport +bool rre () { + if (reexport_read_head == NULL) + reexport_read_head = first_reexport; + else + reexport_read_head = reexport_read_head->next; + if (reexport_read_head == NULL) + return false; + return true; +} +// readUnsafeGetter +bool ru () { + if (unsafe_getter_read_head == NULL) + unsafe_getter_read_head = first_unsafe_getter; + else + unsafe_getter_read_head = unsafe_getter_read_head->next; + if (unsafe_getter_read_head == NULL) + return false; + return true; +} + +void _addExport (const uint16_t* start, const uint16_t* end) { + Slice* export = (Slice*)(analysis_head); + analysis_head = analysis_head + sizeof(Slice); + if (export_write_head == NULL) + first_export = export; + else + export_write_head->next = export; + export_write_head = export; + export->start = start; + export->end = end; + export->next = NULL; +} +void _addReexport (const uint16_t* start, const uint16_t* end) { + Slice* reexport = (Slice*)(analysis_head); + analysis_head = analysis_head + sizeof(Slice); + if (reexport_write_head == NULL) + first_reexport = reexport; + else + reexport_write_head->next = reexport; + reexport_write_head = reexport; + reexport->start = start; + reexport->end = end; + reexport->next = NULL; +} +void _addUnsafeGetter (const uint16_t* start, const uint16_t* end) { + Slice* unsafe_getter = (Slice*)(analysis_head); + analysis_head = analysis_head + sizeof(Slice); + if (unsafe_getter_write_head == NULL) + first_unsafe_getter = unsafe_getter; + else + unsafe_getter_write_head->next = unsafe_getter; + unsafe_getter_write_head = unsafe_getter; + unsafe_getter->start = start; + unsafe_getter->end = end; + unsafe_getter->next = NULL; +} +void _clearReexports () { + reexport_write_head = NULL; + first_reexport = NULL; +} +void (*addExport)(const uint16_t*, const uint16_t*) = &_addExport; +void (*addReexport)(const uint16_t*, const uint16_t*) = &_addReexport; +void (*addUnsafeGetter)(const uint16_t*, const uint16_t*) = &_addUnsafeGetter; +void (*clearReexports)() = &_clearReexports; +uint32_t parseCJS (uint16_t* source, uint32_t sourceLen, void (*addExport)(const uint16_t* start, const uint16_t* end), void (*addReexport)(const uint16_t* start, const uint16_t* end), void (*addUnsafeGetter)(const uint16_t*, const uint16_t*), void (*clearReexports)()); + +enum RequireType { + Import, + ExportAssign, + ExportStar +}; + +void tryBacktrackAddStarExportBinding (uint16_t* pos); +bool tryParseRequire (enum RequireType requireType); +void tryParseLiteralExports (); +bool readExportsOrModuleDotExports (uint16_t ch); +void tryParseModuleExportsDotAssign (); +void tryParseExportsDotAssign (bool assign); +void tryParseObjectDefineOrKeys (bool keys); +bool identifier (uint16_t ch); + +void throwIfImportStatement (); +void throwIfExportStatement (); + +void readImportString (const uint16_t* ss, uint16_t ch); +uint16_t readExportAs (uint16_t* startPos, uint16_t* endPos); + +uint16_t commentWhitespace (); +void stringLiteral (uint16_t quote); +void regularExpression (); +void templateString (); +void blockComment (); +void lineComment (); + +uint16_t readToWsOrPunctuator (uint16_t ch); + +uint32_t fullCharCode (uint16_t ch); +uint32_t fullCharCodeAtLast (uint16_t* pos); +bool isIdentifierStart (uint32_t code); +bool isIdentifierChar (uint32_t code); +int charCodeByteLen (uint32_t ch); + +bool isBr (uint16_t c); +bool isBrOrWs (uint16_t c); +bool isBrOrWsOrPunctuator (uint16_t c); +bool isBrOrWsOrPunctuatorNotDot (uint16_t c); + +bool str_eq2 (uint16_t* pos, uint16_t c1, uint16_t c2); +bool str_eq3 (uint16_t* pos, uint16_t c1, uint16_t c2, uint16_t c3); +bool str_eq4 (uint16_t* pos, uint16_t c1, uint16_t c2, uint16_t c3, uint16_t c4); +bool str_eq5 (uint16_t* pos, uint16_t c1, uint16_t c2, uint16_t c3, uint16_t c4, uint16_t c5); +bool str_eq6 (uint16_t* pos, uint16_t c1, uint16_t c2, uint16_t c3, uint16_t c4, uint16_t c5, uint16_t c6); +bool str_eq7 (uint16_t* pos, uint16_t c1, uint16_t c2, uint16_t c3, uint16_t c4, uint16_t c5, uint16_t c6, uint16_t c7); +bool str_eq8 (uint16_t* pos, uint16_t c1, uint16_t c2, uint16_t c3, uint16_t c4, uint16_t c5, uint16_t c6, uint16_t c7, uint16_t c8); +bool str_eq9 (uint16_t* pos, uint16_t c1, uint16_t c2, uint16_t c3, uint16_t c4, uint16_t c5, uint16_t c6, uint16_t c7, uint16_t c8, uint16_t c9); +bool str_eq10 (uint16_t* pos, uint16_t c1, uint16_t c2, uint16_t c3, uint16_t c4, uint16_t c5, uint16_t c6, uint16_t c7, uint16_t c8, uint16_t c9, uint16_t c10); +bool str_eq13 (uint16_t* pos, uint16_t c1, uint16_t c2, uint16_t c3, uint16_t c4, uint16_t c5, uint16_t c6, uint16_t c7, uint16_t c8, uint16_t c9, uint16_t c10, uint16_t c11, uint16_t c12, uint16_t c13); +bool str_eq18 (uint16_t* pos, uint16_t c1, uint16_t c2, uint16_t c3, uint16_t c4, uint16_t c5, uint16_t c6, uint16_t c7, uint16_t c8, uint16_t c9, uint16_t c10, uint16_t c11, uint16_t c12, uint16_t c13, uint16_t c14, uint16_t c15, uint16_t c16, uint16_t c17, uint16_t c18); +bool str_eq22 (uint16_t* pos, uint16_t c1, uint16_t c2, uint16_t c3, uint16_t c4, uint16_t c5, uint16_t c6, uint16_t c7, uint16_t c8, uint16_t c9, uint16_t c10, uint16_t c11, uint16_t c12, uint16_t c13, uint16_t c14, uint16_t c15, uint16_t c16, uint16_t c17, uint16_t c18, uint16_t c19, uint16_t c20, uint16_t c21, uint16_t c22); + +bool readPrecedingKeyword2(uint16_t* pos, uint16_t c1, uint16_t c2); +bool readPrecedingKeyword3(uint16_t* pos, uint16_t c1, uint16_t c2, uint16_t c3); +bool readPrecedingKeyword4(uint16_t* pos, uint16_t c1, uint16_t c2, uint16_t c3, uint16_t c4); +bool readPrecedingKeyword5(uint16_t* pos, uint16_t c1, uint16_t c2, uint16_t c3, uint16_t c4, uint16_t c5); +bool readPrecedingKeyword6(uint16_t* pos, uint16_t c1, uint16_t c2, uint16_t c3, uint16_t c4, uint16_t c5, uint16_t c6); +bool readPrecedingKeyword7(uint16_t* pos, uint16_t c1, uint16_t c2, uint16_t c3, uint16_t c4, uint16_t c5, uint16_t c6, uint16_t c7); + +bool keywordStart (uint16_t* pos); +bool isExpressionKeyword (uint16_t* pos); +bool isParenKeyword (uint16_t* pos); +bool isPunctuator (uint16_t charCode); +bool isExpressionPunctuator (uint16_t charCode); +bool isExpressionTerminator (uint16_t* pos); + +void nextChar (uint16_t ch); +void nextCharSurrogate (uint16_t ch); +uint16_t readChar (); + +void syntaxError (uint32_t code); diff --git a/deps/cjs-module-lexer/src/lexer.d.mts b/deps/cjs-module-lexer/src/lexer.d.mts new file mode 100644 index 00000000000..98e01424641 --- /dev/null +++ b/deps/cjs-module-lexer/src/lexer.d.mts @@ -0,0 +1 @@ +export * from './lexer.js' diff --git a/deps/cjs-module-lexer/lexer.d.ts b/deps/cjs-module-lexer/src/lexer.d.ts old mode 100644 new mode 100755 similarity index 96% rename from deps/cjs-module-lexer/lexer.d.ts rename to deps/cjs-module-lexer/src/lexer.d.ts index c7d8a523f36..cda07d80af9 --- a/deps/cjs-module-lexer/lexer.d.ts +++ b/deps/cjs-module-lexer/src/lexer.d.ts @@ -1,8 +1,8 @@ -export interface Exports { - exports: string[]; - reexports: string[]; -} - -export declare function parse(source: string, name?: string): Exports; -export declare function init(): Promise; -export declare function initSync(): void; +export interface Exports { + exports: string[]; + reexports: string[]; +} + +export declare function parse(source: string, name?: string): Exports; +export declare function init(): Promise; +export declare function initSync(): void; diff --git a/deps/cjs-module-lexer/src/lexer.js b/deps/cjs-module-lexer/src/lexer.js new file mode 100755 index 00000000000..aaf7dde807f --- /dev/null +++ b/deps/cjs-module-lexer/src/lexer.js @@ -0,0 +1,1443 @@ +let source, pos, end; +let openTokenDepth, + templateDepth, + lastTokenPos, + lastSlashWasDivision, + templateStack, + templateStackDepth, + openTokenPosStack, + openClassPosStack, + nextBraceIsClass, + starExportMap, + lastStarExportSpecifier, + _exports, + unsafeGetters, + reexports; + +function resetState () { + openTokenDepth = 0; + templateDepth = -1; + lastTokenPos = -1; + lastSlashWasDivision = false; + templateStack = new Array(1024); + templateStackDepth = 0; + openTokenPosStack = new Array(1024); + openClassPosStack = new Array(1024); + nextBraceIsClass = false; + starExportMap = Object.create(null); + lastStarExportSpecifier = null; + + _exports = new Set(); + unsafeGetters = new Set(); + reexports = new Set(); +} + +// RequireType +const Import = 0; +const ExportAssign = 1; +const ExportStar = 2; + +function parseCJS (source, name = '@') { + resetState(); + try { + parseSource(source); + } + catch (e) { + e.message += `\n at ${name}:${source.slice(0, pos).split('\n').length}:${pos - source.lastIndexOf('\n', pos - 1)}`; + e.loc = pos; + throw e; + } + const result = { exports: [..._exports].filter(expt => expt !== undefined && !unsafeGetters.has(expt)), reexports: [...reexports].filter(reexpt => reexpt !== undefined) }; + resetState(); + return result; +} + +function decode (str) { + if (str[0] === '"' || str[0] === '\'') { + try { + const decoded = (0, eval)(str); + // Filter to exclude non-matching UTF-16 surrogate strings + for (let i = 0; i < decoded.length; i++) { + const surrogatePrefix = decoded.charCodeAt(i) & 0xFC00; + if (surrogatePrefix < 0xD800) { + // Not a surrogate + continue; + } + else if (surrogatePrefix === 0xD800) { + // Validate surrogate pair + if ((decoded.charCodeAt(++i) & 0xFC00) !== 0xDC00) + return; + } + else { + // Out-of-range surrogate code (above 0xD800) + return; + } + } + return decoded; + } + catch {} + } + else { + return str; + } +} + +function parseSource (cjsSource) { + source = cjsSource; + pos = -1; + end = source.length - 1; + let ch = 0; + + // Handle #! + if (source.charCodeAt(0) === 35/*#*/ && source.charCodeAt(1) === 33/*!*/) { + if (source.length === 2) + return true; + pos += 2; + while (pos++ < end) { + ch = source.charCodeAt(pos); + if (ch === 10/*\n*/ || ch === 13/*\r*/) + break; + } + } + + while (pos++ < end) { + ch = source.charCodeAt(pos); + + if (ch === 32 || ch < 14 && ch > 8) + continue; + + if (openTokenDepth === 0) { + switch (ch) { + case 105/*i*/: + if (source.startsWith('mport', pos + 1) && keywordStart(pos)) + throwIfImportStatement(); + lastTokenPos = pos; + continue; + case 114/*r*/: + const startPos = pos; + if (tryParseRequire(Import) && keywordStart(startPos)) + tryBacktrackAddStarExportBinding(startPos - 1); + lastTokenPos = pos; + continue; + case 95/*_*/: + if (source.startsWith('interopRequireWildcard', pos + 1) && (keywordStart(pos) || source.charCodeAt(pos - 1) === 46/*.*/)) { + const startPos = pos; + pos += 23; + if (source.charCodeAt(pos) === 40/*(*/) { + pos++; + openTokenPosStack[openTokenDepth++] = lastTokenPos; + if (tryParseRequire(Import) && keywordStart(startPos)) { + tryBacktrackAddStarExportBinding(startPos - 1); + } + } + } + else if (source.startsWith('_export', pos + 1) && (keywordStart(pos) || source.charCodeAt(pos - 1) === 46/*.*/)) { + pos += 8; + if (source.startsWith('Star', pos)) + pos += 4; + if (source.charCodeAt(pos) === 40/*(*/) { + openTokenPosStack[openTokenDepth++] = lastTokenPos; + if (source.charCodeAt(++pos) === 114/*r*/) + tryParseRequire(ExportStar); + } + } + lastTokenPos = pos; + continue; + } + } + + switch (ch) { + case 101/*e*/: + if (source.startsWith('xport', pos + 1) && keywordStart(pos)) { + if (source.charCodeAt(pos + 6) === 115/*s*/) + tryParseExportsDotAssign(false); + else if (openTokenDepth === 0) + throwIfExportStatement(); + } + break; + case 99/*c*/: + if (keywordStart(pos) && source.startsWith('lass', pos + 1) && isBrOrWs(source.charCodeAt(pos + 5))) + nextBraceIsClass = true; + break; + case 109/*m*/: + if (source.startsWith('odule', pos + 1) && keywordStart(pos)) + tryParseModuleExportsDotAssign(); + break; + case 79/*O*/: + if (source.startsWith('bject', pos + 1) && keywordStart(pos)) + tryParseObjectDefineOrKeys(openTokenDepth === 0); + break; + case 40/*(*/: + openTokenPosStack[openTokenDepth++] = lastTokenPos; + break; + case 41/*)*/: + if (openTokenDepth === 0) + throw new Error('Unexpected closing bracket.'); + openTokenDepth--; + break; + case 123/*{*/: + openClassPosStack[openTokenDepth] = nextBraceIsClass; + nextBraceIsClass = false; + openTokenPosStack[openTokenDepth++] = lastTokenPos; + break; + case 125/*}*/: + if (openTokenDepth === 0) + throw new Error('Unexpected closing brace.'); + if (openTokenDepth-- === templateDepth) { + templateDepth = templateStack[--templateStackDepth]; + templateString(); + } + else { + if (templateDepth !== -1 && openTokenDepth < templateDepth) + throw new Error('Unexpected closing brace.'); + } + break; + case 60/*>*/: + // TODO: +[CVE-2024-13176]: https://www.openssl.org/news/vulnerabilities.html#CVE-2024-13176 +[CVE-2024-9143]: https://www.openssl.org/news/vulnerabilities.html#CVE-2024-9143 [CVE-2024-6119]: https://www.openssl.org/news/vulnerabilities.html#CVE-2024-6119 [CVE-2024-5535]: https://www.openssl.org/news/vulnerabilities.html#CVE-2024-5535 [CVE-2024-4741]: https://www.openssl.org/news/vulnerabilities.html#CVE-2024-4741 diff --git a/deps/openssl/openssl/Configurations/unix-Makefile.tmpl b/deps/openssl/openssl/Configurations/unix-Makefile.tmpl index 644540397de..d2b0797a7ed 100644 --- a/deps/openssl/openssl/Configurations/unix-Makefile.tmpl +++ b/deps/openssl/openssl/Configurations/unix-Makefile.tmpl @@ -1688,7 +1688,7 @@ EOF } elsif ($makedep_scheme eq 'gcc' && !grep /\.rc$/, @srcs) { $recipe .= <<"EOF"; $obj: $deps - $cmd $incs $defs $cmdflags -MMD -MF $dep.tmp -MT \$\@ -c -o \$\@ $srcs + $cmd $incs $defs $cmdflags -MMD -MF $dep.tmp -c -o \$\@ $srcs \@touch $dep.tmp \@if cmp $dep.tmp $dep > /dev/null 2> /dev/null; then \\ rm -f $dep.tmp; \\ diff --git a/deps/openssl/openssl/Configure b/deps/openssl/openssl/Configure index 1aa660a46c4..0c60d1da165 100755 --- a/deps/openssl/openssl/Configure +++ b/deps/openssl/openssl/Configure @@ -467,7 +467,6 @@ my @disablables = ( "poly1305", "posix-io", "psk", - "quic", "rc2", "rc4", "rc5", @@ -578,7 +577,6 @@ my @disable_cascades = ( "sm3", "sm4", "srp", "srtp", "ssl3-method", "ssl-trace", "ts", "ui-console", "whirlpool", - "quic", "fips-securitychecks" ], sub { $config{processor} eq "386" } => [ "sse2" ], @@ -586,7 +584,7 @@ my @disable_cascades = ( "ssl3-method" => [ "ssl3" ], "zlib" => [ "zlib-dynamic" ], "des" => [ "mdc2" ], - "ec" => [ "ec2m", "ecdsa", "ecdh", "sm2", "gost", "quic" ], + "ec" => [ "ec2m", "ecdsa", "ecdh", "sm2", "gost" ], "dgram" => [ "dtls", "sctp" ], "sock" => [ "dgram" ], "dtls" => [ @dtls ], @@ -637,7 +635,6 @@ my @disable_cascades = ( "legacy" => [ "md2" ], "cmp" => [ "crmf" ], - "tls1_3" => [ "quic" ], "fips" => [ "fips-securitychecks", "acvp-tests" ], diff --git a/deps/openssl/openssl/INSTALL.md b/deps/openssl/openssl/INSTALL.md index 107a9b56e4c..47d64b1a39d 100644 --- a/deps/openssl/openssl/INSTALL.md +++ b/deps/openssl/openssl/INSTALL.md @@ -829,10 +829,6 @@ Don't use POSIX IO capabilities. Don't build support for Pre-Shared Key based ciphersuites. -### no-quic - -Don't build support for QUIC API from BoringSSL. - ### no-rdrand Don't use hardware RDRAND capabilities. diff --git a/deps/openssl/openssl/NEWS.md b/deps/openssl/openssl/NEWS.md index e0a81703ee8..007fc9786ef 100644 --- a/deps/openssl/openssl/NEWS.md +++ b/deps/openssl/openssl/NEWS.md @@ -18,6 +18,20 @@ OpenSSL Releases OpenSSL 3.0 ----------- +### Major changes between OpenSSL 3.0.15 and OpenSSL 3.0.16 [11 Feb 2025] + +OpenSSL 3.0.16 is a security patch release. The most severe CVE fixed in this +release is Low. + +This release incorporates the following bug fixes and mitigations: + + * Fixed timing side-channel in ECDSA signature computation. + ([CVE-2024-13176]) + + * Fixed possible OOB memory access with invalid low-level GF(2^m) elliptic + curve parameters. + ([CVE-2024-9143]) + ### Major changes between OpenSSL 3.0.14 and OpenSSL 3.0.15 [3 Sep 2024] OpenSSL 3.0.15 is a security patch release. The most severe CVE fixed in this @@ -1495,6 +1509,8 @@ OpenSSL 0.9.x +[CVE-2024-13176]: https://www.openssl.org/news/vulnerabilities.html#CVE-2024-13176 +[CVE-2024-9143]: https://www.openssl.org/news/vulnerabilities.html#CVE-2024-9143 [CVE-2024-6119]: https://www.openssl.org/news/vulnerabilities.html#CVE-2024-6119 [CVE-2024-5535]: https://www.openssl.org/news/vulnerabilities.html#CVE-2024-5535 [CVE-2024-4741]: https://www.openssl.org/news/vulnerabilities.html#CVE-2024-4741 diff --git a/deps/openssl/openssl/NOTES-NONSTOP.md b/deps/openssl/openssl/NOTES-NONSTOP.md index ab13de7d3a7..9441647604c 100644 --- a/deps/openssl/openssl/NOTES-NONSTOP.md +++ b/deps/openssl/openssl/NOTES-NONSTOP.md @@ -119,12 +119,9 @@ correctly, you also need the `COMP_ROOT` set, as in: `COMP_ROOT` needs to be in Windows form. -`Configure` must specify the `no-makedepend` option otherwise errors will -result when running the build because the c99 cross-compiler does not support -the `gcc -MT` option. An example of a `Configure` command to be run from the -OpenSSL directory is: +An example of a `Configure` command to be run from the OpenSSL directory is: - ./Configure nonstop-nsx_64 no-makedepend --with-rand-seed=rdcpu + ./Configure nonstop-nsx_64 --with-rand-seed=rdcpu Do not forget to include any OpenSSL cross-compiling prefix and certificate options when creating your libraries. diff --git a/deps/openssl/openssl/README-OpenSSL.md b/deps/openssl/openssl/README-OpenSSL.md deleted file mode 100644 index 5184a461bb1..00000000000 --- a/deps/openssl/openssl/README-OpenSSL.md +++ /dev/null @@ -1,224 +0,0 @@ -Welcome to the OpenSSL Project -============================== - -[![openssl logo]][www.openssl.org] - -[![github actions ci badge]][github actions ci] -[![appveyor badge]][appveyor jobs] - -OpenSSL is a robust, commercial-grade, full-featured Open Source Toolkit -for the Transport Layer Security (TLS) protocol formerly known as the -Secure Sockets Layer (SSL) protocol. The protocol implementation is based -on a full-strength general purpose cryptographic library, which can also -be used stand-alone. - -OpenSSL is descended from the SSLeay library developed by Eric A. Young -and Tim J. Hudson. - -The official Home Page of the OpenSSL Project is [www.openssl.org]. - -Table of Contents -================= - - - [Overview](#overview) - - [Download](#download) - - [Build and Install](#build-and-install) - - [Documentation](#documentation) - - [License](#license) - - [Support](#support) - - [Contributing](#contributing) - - [Legalities](#legalities) - -Overview -======== - -The OpenSSL toolkit includes: - -- **libssl** - an implementation of all TLS protocol versions up to TLSv1.3 ([RFC 8446]). - -- **libcrypto** - a full-strength general purpose cryptographic library. It constitutes the - basis of the TLS implementation, but can also be used independently. - -- **openssl** - the OpenSSL command line tool, a swiss army knife for cryptographic tasks, - testing and analyzing. It can be used for - - creation of key parameters - - creation of X.509 certificates, CSRs and CRLs - - calculation of message digests - - encryption and decryption - - SSL/TLS client and server tests - - handling of S/MIME signed or encrypted mail - - and more... - -Download -======== - -For Production Use ------------------- - -Source code tarballs of the official releases can be downloaded from -[www.openssl.org/source](https://www.openssl.org/source). -The OpenSSL project does not distribute the toolkit in binary form. - -However, for a large variety of operating systems precompiled versions -of the OpenSSL toolkit are available. In particular on Linux and other -Unix operating systems it is normally recommended to link against the -precompiled shared libraries provided by the distributor or vendor. - -For Testing and Development ---------------------------- - -Although testing and development could in theory also be done using -the source tarballs, having a local copy of the git repository with -the entire project history gives you much more insight into the -code base. - -The official OpenSSL Git Repository is located at [git.openssl.org]. -There is a GitHub mirror of the repository at [github.com/openssl/openssl], -which is updated automatically from the former on every commit. - -A local copy of the Git Repository can be obtained by cloning it from -the original OpenSSL repository using - - git clone git://git.openssl.org/openssl.git - -or from the GitHub mirror using - - git clone https://github.com/openssl/openssl.git - -If you intend to contribute to OpenSSL, either to fix bugs or contribute -new features, you need to fork the OpenSSL repository openssl/openssl on -GitHub and clone your public fork instead. - - git clone https://github.com/yourname/openssl.git - -This is necessary, because all development of OpenSSL nowadays is done via -GitHub pull requests. For more details, see [Contributing](#contributing). - -Build and Install -================= - -After obtaining the Source, have a look at the [INSTALL](INSTALL.md) file for -detailed instructions about building and installing OpenSSL. For some -platforms, the installation instructions are amended by a platform specific -document. - - * [Notes for UNIX-like platforms](NOTES-UNIX.md) - * [Notes for Android platforms](NOTES-ANDROID.md) - * [Notes for Windows platforms](NOTES-WINDOWS.md) - * [Notes for the DOS platform with DJGPP](NOTES-DJGPP.md) - * [Notes for the OpenVMS platform](NOTES-VMS.md) - * [Notes on Perl](NOTES-PERL.md) - * [Notes on Valgrind](NOTES-VALGRIND.md) - -Specific notes on upgrading to OpenSSL 3.0 from previous versions can be found -in the [migration_guide(7ossl)] manual page. - -Documentation -============= - -Manual Pages ------------- - -The manual pages for the master branch and all current stable releases are -available online. - -- [OpenSSL master](https://www.openssl.org/docs/manmaster) -- [OpenSSL 3.0](https://www.openssl.org/docs/man3.0) -- [OpenSSL 1.1.1](https://www.openssl.org/docs/man1.1.1) - -Wiki ----- - -There is a Wiki at [wiki.openssl.org] which is currently not very active. -It contains a lot of useful information, not all of which is up to date. - -License -======= - -OpenSSL is licensed under the Apache License 2.0, which means that -you are free to get and use it for commercial and non-commercial -purposes as long as you fulfill its conditions. - -See the [LICENSE.txt](LICENSE.txt) file for more details. - -Support -======= - -There are various ways to get in touch. The correct channel depends on -your requirement. see the [SUPPORT](SUPPORT.md) file for more details. - -Contributing -============ - -If you are interested and willing to contribute to the OpenSSL project, -please take a look at the [CONTRIBUTING](CONTRIBUTING.md) file. - -Legalities -========== - -A number of nations restrict the use or export of cryptography. If you are -potentially subject to such restrictions you should seek legal advice before -attempting to develop or distribute cryptographic code. - -Copyright -========= - -Copyright (c) 1998-2024 The OpenSSL Project - -Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson - -All rights reserved. - - - -[www.openssl.org]: - - "OpenSSL Homepage" - -[git.openssl.org]: - - "OpenSSL Git Repository" - -[git.openssl.org]: - - "OpenSSL Git Repository" - -[github.com/openssl/openssl]: - - "OpenSSL GitHub Mirror" - -[wiki.openssl.org]: - - "OpenSSL Wiki" - -[migration_guide(7ossl)]: - - "OpenSSL Migration Guide" - -[RFC 8446]: - - - - -[openssl logo]: - doc/images/openssl.svg - "OpenSSL Logo" - -[github actions ci badge]: - - "GitHub Actions CI Status" - -[github actions ci]: - - "GitHub Actions CI" - -[appveyor badge]: - - "AppVeyor Build Status" - -[appveyor jobs]: - - "AppVeyor Jobs" diff --git a/deps/openssl/openssl/README.md b/deps/openssl/openssl/README.md index 702cc3979a1..477f5cbb7d1 100644 --- a/deps/openssl/openssl/README.md +++ b/deps/openssl/openssl/README.md @@ -1,113 +1,212 @@ -What This Is -============ +Welcome to the OpenSSL Project +============================== -This is a fork of [OpenSSL](https://www.openssl.org) to enable QUIC. In addition -to the website, the official source distribution is at -. The OpenSSL `README` can be found at -[README-OpenSSL.md](https://github.com/quictls/openssl/blob/openssl-3.0.15%2Bquic/README-OpenSSL.md) +[![openssl logo]][www.openssl.org] -This fork adds APIs that can be used by QUIC implementations for connection -handshakes. Quoting the IETF Working group -[charter](https://datatracker.ietf.org/wg/quic/about/), QUIC is a "UDP-based, -stream-multiplexing, encrypted transport protocol." If you don't need QUIC, you -should use the official OpenSSL distributions. +[![github actions ci badge]][github actions ci] +[![appveyor badge]][appveyor jobs] -The APIs here are used by Microsoft's -[MsQuic](https://github.com/microsoft/msquic) and Google's -[Chromium QUIC](https://chromium.googlesource.com/chromium/src/+/master/net/quic/) +OpenSSL is a robust, commercial-grade, full-featured Open Source Toolkit +for the Transport Layer Security (TLS) protocol formerly known as the +Secure Sockets Layer (SSL) protocol. The protocol implementation is based +on a full-strength general purpose cryptographic library, which can also +be used stand-alone. -We are not in competition with OpenSSL project. We informed them of -our plans to fork the code before we went public. We do not speak for the -OpenSSL project, and can only point to a -[blog post](https://www.openssl.org/blog/blog/2020/02/17/QUIC-and-OpenSSL/) and -[openssl-project email](https://github.com/quictls/openssl/discussions/54) -that provides their view of QUIC support. +OpenSSL is descended from the SSLeay library developed by Eric A. Young +and Tim J. Hudson. -As stated in their blog post, the OpenSSL team is focused on their 3.0 release -(released 2021-09-07), and does not intend to add QUIC functionality to 1.1.x. -There is a community need for a QUIC-capable TLS library. This fork is intended -as stopgap solution to enable higher level frameworks and runtimes to use QUIC -with the proven and reliable TLS functionality from OpenSSL. This fork will be -maintained until OpenSSL officially provides reasonable support for QUIC -implementations. +The official Home Page of the OpenSSL Project is [www.openssl.org]. -This fork can be considered a supported version of -[OpenSSL PR 8797](https://github.com/openssl/openssl/pull/8797). -We will endeavor to track OpenSSL releases within a day or so, and there is an -item below about how we'll follow their tagging. +Table of Contents +================= -On to the questions and answers. + - [Overview](#overview) + - [Download](#download) + - [Build and Install](#build-and-install) + - [Documentation](#documentation) + - [License](#license) + - [Support](#support) + - [Contributing](#contributing) + - [Legalities](#legalities) -What about branches? --------------------- +Overview +======== -We don't want to conflict with OpenSSL branch names. Our current plan is to append -`+quic`. Release tags are likely to be the QUIC branch with `-releaseX` appended. -For example, the OpenSSL tag `openssl-3.0.0` would have a branch named -`openssl-3.0.0+quic` and a release tag of `openssl-3.0.0+quic-release1`. +The OpenSSL toolkit includes: -How are you keeping current with OpenSSL? ------------------------------------------ +- **libssl** + an implementation of all TLS protocol versions up to TLSv1.3 ([RFC 8446]). -(In other words, "What about rebasing?") +- **libcrypto** + a full-strength general purpose cryptographic library. It constitutes the + basis of the TLS implementation, but can also be used independently. -Our plan is to always rebase on top of an upstream release tag. In particular: +- **openssl** + the OpenSSL command line tool, a swiss army knife for cryptographic tasks, + testing and analyzing. It can be used for + - creation of key parameters + - creation of X.509 certificates, CSRs and CRLs + - calculation of message digests + - encryption and decryption + - SSL/TLS client and server tests + - handling of S/MIME signed or encrypted mail + - and more... -- The changes for QUIC will always be at the tip of the branch -- you will know what - is from the original OpenSSL and what is for QUIC. -- New versions are quickly created once upstream creates a new tag. -- The use of git commands (such as `cherry`) can be used to ensure that all changes - have moved forward with minimal or no changes. You will be able to see - "QUIC: Add X" on all branches and the commit itself will be nearly identical on - all branches, and any changes to that can be easily identified. +Download +======== -What about library names? -------------------------- +For Production Use +------------------ -Library names will be the same, but will use a different version number. The version -numbers for the current OpenSSL libraries are `1.1` (for the 1.1.0 and 1.1.1 branches) -and `3` (for the 3.0 branch). We will be prefixing `81` (ASCII for 'Q') to -the version numbers to generate a unique version number. +Source code tarballs of the official releases can be downloaded from +[openssl-library.org/source/](https://openssl-library.org/source/). +The OpenSSL project does not distribute the toolkit in binary form. -- `libcrypto.so.81.3` vs `libcrypto.so.3` -- `libcrypto.so.81.1.1` vs `libcrypto.so.1.1` -- `libssl.so.81.3` vs `libssl.so.3` -- `libssl.so.81.1.1` vs `libssl.so.1.1` +However, for a large variety of operating systems precompiled versions +of the OpenSSL toolkit are available. In particular on Linux and other +Unix operating systems it is normally recommended to link against the +precompiled shared libraries provided by the distributor or vendor. -The SONAME of these libraries are all different, guaranteeing the correct library -will be used. +For Testing and Development +--------------------------- -...and the executable? ----------------------- +Although testing and development could in theory also be done using +the source tarballs, having a local copy of the git repository with +the entire project history gives you much more insight into the +code base. -We currently do not have any plans to change the name, mainly because we -haven't made any changes there. If you see a need, please open an issue. +The main OpenSSL Git repository is private. +There is a public GitHub mirror of it at [github.com/openssl/openssl], +which is updated automatically from the former on every commit. -The `openssl version` command will report that it is `+quic` enabled. +A local copy of the Git repository can be obtained by cloning it from +the GitHub mirror using -...and FIPS? ------------- + git clone https://github.com/openssl/openssl.git + +If you intend to contribute to OpenSSL, either to fix bugs or contribute +new features, you need to fork the GitHub mirror and clone your public fork +instead. + + git clone https://github.com/yourname/openssl.git + +This is necessary, because all development of OpenSSL nowadays is done via +GitHub pull requests. For more details, see [Contributing](#contributing). + +Build and Install +================= + +After obtaining the Source, have a look at the [INSTALL](INSTALL.md) file for +detailed instructions about building and installing OpenSSL. For some +platforms, the installation instructions are amended by a platform specific +document. + + * [Notes for UNIX-like platforms](NOTES-UNIX.md) + * [Notes for Android platforms](NOTES-ANDROID.md) + * [Notes for Windows platforms](NOTES-WINDOWS.md) + * [Notes for the DOS platform with DJGPP](NOTES-DJGPP.md) + * [Notes for the OpenVMS platform](NOTES-VMS.md) + * [Notes on Perl](NOTES-PERL.md) + * [Notes on Valgrind](NOTES-VALGRIND.md) + +Specific notes on upgrading to OpenSSL 3.0 from previous versions can be found +in the [migration_guide(7ossl)] manual page. + +Documentation +============= -We are not doing anything with FIPS. This is actually good news: you should -be able to load the OpenSSL 3.0 FIPS module into an application built against -this fork and everything should Just Work™. - -How can I contribute? ---------------------- - -We want any code here to be acceptable to OpenSSL. This means that all contributors -must have signed the appropriate -[contributor license agreements](https://www.openssl.org/policies/cla.html). We -will not ask for copies of any paperwork, you just need to tell us that you've -done so (and we might verify with OpenSSL). We are only interested in making it -easier and better for at least the mentioned QUIC implementations to use a variant -of OpenSSL. If you have a pull request that changes the TLS protocol, or adds -assembly support for a new CPU, or otherwise is not specific to enabling QUIC, -please contribute that to OpenSSL. This fork is intended to be a clean extension -to OpenSSL, with the deltas being specific to QUIC. - -Who are you? +Manual Pages ------------ -This is a collaborative effort between [Akamai](https://www.akamai.com) and -[Microsoft](https://www.microsoft.com). We welcome anyone to contribute! +The manual pages for the master branch and all current stable releases are +available online. + +- [OpenSSL master](https://www.openssl.org/docs/manmaster) +- [OpenSSL 3.0](https://www.openssl.org/docs/man3.0) +- [OpenSSL 1.1.1](https://www.openssl.org/docs/man1.1.1) + +Wiki +---- + +There is a Wiki at [wiki.openssl.org] which is currently not very active. +It contains a lot of useful information, not all of which is up to date. + +License +======= + +OpenSSL is licensed under the Apache License 2.0, which means that +you are free to get and use it for commercial and non-commercial +purposes as long as you fulfill its conditions. + +See the [LICENSE.txt](LICENSE.txt) file for more details. + +Support +======= + +There are various ways to get in touch. The correct channel depends on +your requirement. see the [SUPPORT](SUPPORT.md) file for more details. + +Contributing +============ + +If you are interested and willing to contribute to the OpenSSL project, +please take a look at the [CONTRIBUTING](CONTRIBUTING.md) file. + +Legalities +========== + +A number of nations restrict the use or export of cryptography. If you are +potentially subject to such restrictions you should seek legal advice before +attempting to develop or distribute cryptographic code. + +Copyright +========= + +Copyright (c) 1998-2025 The OpenSSL Project + +Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson + +All rights reserved. + + + +[www.openssl.org]: + + "OpenSSL Homepage" + +[github.com/openssl/openssl]: + + "OpenSSL GitHub Mirror" + +[wiki.openssl.org]: + + "OpenSSL Wiki" + +[migration_guide(7ossl)]: + + "OpenSSL Migration Guide" + +[RFC 8446]: + + + + +[openssl logo]: + doc/images/openssl.svg + "OpenSSL Logo" + +[github actions ci badge]: + + "GitHub Actions CI Status" + +[github actions ci]: + + "GitHub Actions CI" + +[appveyor badge]: + + "AppVeyor Build Status" + +[appveyor jobs]: + + "AppVeyor Jobs" diff --git a/deps/openssl/openssl/VERSION.dat b/deps/openssl/openssl/VERSION.dat index 9f3b18e8899..4b7eb91a451 100644 --- a/deps/openssl/openssl/VERSION.dat +++ b/deps/openssl/openssl/VERSION.dat @@ -1,7 +1,7 @@ MAJOR=3 MINOR=0 -PATCH=15 +PATCH=16 PRE_RELEASE_TAG= -BUILD_METADATA=quic -RELEASE_DATE="3 Sep 2024" -SHLIB_VERSION=81.3 +BUILD_METADATA= +RELEASE_DATE="11 Feb 2025" +SHLIB_VERSION=3 diff --git a/deps/openssl/openssl/apps/asn1parse.c b/deps/openssl/openssl/apps/asn1parse.c index f0bfd1d45fc..129b867c8cc 100644 --- a/deps/openssl/openssl/apps/asn1parse.c +++ b/deps/openssl/openssl/apps/asn1parse.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2025 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 @@ -127,7 +127,8 @@ int asn1parse_main(int argc, char **argv) dump = strtol(opt_arg(), NULL, 0); break; case OPT_STRPARSE: - sk_OPENSSL_STRING_push(osk, opt_arg()); + if (sk_OPENSSL_STRING_push(osk, opt_arg()) <= 0) + goto end; break; case OPT_GENSTR: genstr = opt_arg(); diff --git a/deps/openssl/openssl/apps/cms.c b/deps/openssl/openssl/apps/cms.c index abb9f196a76..dce227ef2db 100644 --- a/deps/openssl/openssl/apps/cms.c +++ b/deps/openssl/openssl/apps/cms.c @@ -1,5 +1,5 @@ /* - * Copyright 2008-2024 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2008-2025 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 @@ -494,13 +494,15 @@ int cms_main(int argc, char **argv) if (rr_from == NULL && (rr_from = sk_OPENSSL_STRING_new_null()) == NULL) goto end; - sk_OPENSSL_STRING_push(rr_from, opt_arg()); + if (sk_OPENSSL_STRING_push(rr_from, opt_arg()) <= 0) + goto end; break; case OPT_RR_TO: if (rr_to == NULL && (rr_to = sk_OPENSSL_STRING_new_null()) == NULL) goto end; - sk_OPENSSL_STRING_push(rr_to, opt_arg()); + if (sk_OPENSSL_STRING_push(rr_to, opt_arg()) <= 0) + goto end; break; case OPT_PRINT: noout = print = 1; @@ -577,13 +579,15 @@ int cms_main(int argc, char **argv) if (sksigners == NULL && (sksigners = sk_OPENSSL_STRING_new_null()) == NULL) goto end; - sk_OPENSSL_STRING_push(sksigners, signerfile); + if (sk_OPENSSL_STRING_push(sksigners, signerfile) <= 0) + goto end; if (keyfile == NULL) keyfile = signerfile; if (skkeys == NULL && (skkeys = sk_OPENSSL_STRING_new_null()) == NULL) goto end; - sk_OPENSSL_STRING_push(skkeys, keyfile); + if (sk_OPENSSL_STRING_push(skkeys, keyfile) <= 0) + goto end; keyfile = NULL; } signerfile = opt_arg(); @@ -601,12 +605,14 @@ int cms_main(int argc, char **argv) if (sksigners == NULL && (sksigners = sk_OPENSSL_STRING_new_null()) == NULL) goto end; - sk_OPENSSL_STRING_push(sksigners, signerfile); + if (sk_OPENSSL_STRING_push(sksigners, signerfile) <= 0) + goto end; signerfile = NULL; if (skkeys == NULL && (skkeys = sk_OPENSSL_STRING_new_null()) == NULL) goto end; - sk_OPENSSL_STRING_push(skkeys, keyfile); + if (sk_OPENSSL_STRING_push(skkeys, keyfile) <= 0) + goto end; } keyfile = opt_arg(); break; @@ -660,7 +666,8 @@ int cms_main(int argc, char **argv) key_param->next = nparam; key_param = nparam; } - sk_OPENSSL_STRING_push(key_param->param, opt_arg()); + if (sk_OPENSSL_STRING_push(key_param->param, opt_arg()) <= 0) + goto end; break; case OPT_V_CASES: if (!opt_verify(o, vpm)) @@ -749,12 +756,14 @@ int cms_main(int argc, char **argv) if (sksigners == NULL && (sksigners = sk_OPENSSL_STRING_new_null()) == NULL) goto end; - sk_OPENSSL_STRING_push(sksigners, signerfile); + if (sk_OPENSSL_STRING_push(sksigners, signerfile) <= 0) + goto end; if (skkeys == NULL && (skkeys = sk_OPENSSL_STRING_new_null()) == NULL) goto end; if (keyfile == NULL) keyfile = signerfile; - sk_OPENSSL_STRING_push(skkeys, keyfile); + if (sk_OPENSSL_STRING_push(skkeys, keyfile) <= 0) + goto end; } if (sksigners == NULL) { BIO_printf(bio_err, "No signer certificate specified\n"); @@ -1014,8 +1023,15 @@ int cms_main(int argc, char **argv) pwri_tmp = NULL; } if (!(flags & CMS_STREAM)) { - if (!CMS_final(cms, in, NULL, flags)) + if (!CMS_final(cms, in, NULL, flags)) { + if (originator != NULL + && ERR_GET_REASON(ERR_peek_error()) + == CMS_R_ERROR_UNSUPPORTED_STATIC_KEY_AGREEMENT) { + BIO_printf(bio_err, "Cannot use originator for encryption\n"); + goto end; + } goto end; + } } } else if (operation == SMIME_ENCRYPTED_ENCRYPT) { cms = CMS_EncryptedData_encrypt_ex(in, cipher, secret_key, @@ -1261,6 +1277,7 @@ int cms_main(int argc, char **argv) X509_free(cert); X509_free(recip); X509_free(signer); + X509_free(originator); EVP_PKEY_free(key); EVP_CIPHER_free(cipher); EVP_CIPHER_free(wrap_cipher); diff --git a/deps/openssl/openssl/apps/engine.c b/deps/openssl/openssl/apps/engine.c index 1b0f64309c6..c83bdfc150c 100644 --- a/deps/openssl/openssl/apps/engine.c +++ b/deps/openssl/openssl/apps/engine.c @@ -1,5 +1,5 @@ /* - * Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2000-2025 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 @@ -352,10 +352,12 @@ int engine_main(int argc, char **argv) test_avail++; break; case OPT_PRE: - sk_OPENSSL_STRING_push(pre_cmds, opt_arg()); + if (sk_OPENSSL_STRING_push(pre_cmds, opt_arg()) <= 0) + goto end; break; case OPT_POST: - sk_OPENSSL_STRING_push(post_cmds, opt_arg()); + if (sk_OPENSSL_STRING_push(post_cmds, opt_arg()) <= 0) + goto end; break; } } diff --git a/deps/openssl/openssl/apps/info.c b/deps/openssl/openssl/apps/info.c index 66f3ef2587e..c68603652f2 100644 --- a/deps/openssl/openssl/apps/info.c +++ b/deps/openssl/openssl/apps/info.c @@ -10,15 +10,11 @@ #include #include "apps.h" #include "progs.h" -#include typedef enum OPTION_choice { OPT_COMMON, OPT_CONFIGDIR, OPT_ENGINESDIR, OPT_MODULESDIR, OPT_DSOEXT, OPT_DIRNAMESEP, OPT_LISTSEP, OPT_SEEDS, OPT_CPUSETTINGS -#ifndef OPENSSL_NO_QUIC - , OPT_QUIC -#endif } OPTION_CHOICE; const OPTIONS info_options[] = { @@ -36,9 +32,6 @@ const OPTIONS info_options[] = { {"listsep", OPT_LISTSEP, '-', "List separator character"}, {"seeds", OPT_SEEDS, '-', "Seed sources"}, {"cpusettings", OPT_CPUSETTINGS, '-', "CPU settings info"}, -#ifndef OPENSSL_NO_QUIC - {"quic", OPT_QUIC, '-', "QUIC info"}, -#endif {NULL} }; @@ -91,12 +84,6 @@ int info_main(int argc, char **argv) type = OPENSSL_INFO_CPU_SETTINGS; dirty++; break; -#ifndef OPENSSL_NO_QUIC - case OPT_QUIC: - type = OPENSSL_INFO_QUIC; - dirty++; - break; -#endif } } if (opt_num_rest() != 0) diff --git a/deps/openssl/openssl/apps/lib/http_server.c b/deps/openssl/openssl/apps/lib/http_server.c index a7fe5e1a58b..33ae886d4a1 100644 --- a/deps/openssl/openssl/apps/lib/http_server.c +++ b/deps/openssl/openssl/apps/lib/http_server.c @@ -220,14 +220,17 @@ BIO *http_server_init_bio(const char *prog, const char *port) { BIO *acbio = NULL, *bufbio; int asock; + char name[40]; + snprintf(name, sizeof(name), "[::]:%s", port); /* port may be "0" */ bufbio = BIO_new(BIO_f_buffer()); if (bufbio == NULL) goto err; acbio = BIO_new(BIO_s_accept()); if (acbio == NULL - || BIO_set_bind_mode(acbio, BIO_BIND_REUSEADDR) < 0 - || BIO_set_accept_port(acbio, port) < 0) { + || BIO_set_accept_ip_family(acbio, BIO_FAMILY_IPANY) <= 0 /* IPv4/6 */ + || BIO_set_bind_mode(acbio, BIO_BIND_REUSEADDR) <= 0 + || BIO_set_accept_name(acbio, name) <= 0) { log_message(prog, LOG_ERR, "Error setting up accept BIO"); goto err; } diff --git a/deps/openssl/openssl/apps/lib/s_cb.c b/deps/openssl/openssl/apps/lib/s_cb.c index 6440b496099..9f33c24c4e3 100644 --- a/deps/openssl/openssl/apps/lib/s_cb.c +++ b/deps/openssl/openssl/apps/lib/s_cb.c @@ -240,10 +240,10 @@ static const char *get_sigtype(int nid) return "ECDSA"; case NID_ED25519: - return "Ed25519"; + return "ed25519"; case NID_ED448: - return "Ed448"; + return "ed448"; case NID_id_GostR3410_2001: return "gost2001"; @@ -288,6 +288,26 @@ static int do_print_sigalgs(BIO *out, SSL *s, int shared) SSL_get_sigalgs(s, i, &sign_nid, &hash_nid, NULL, &rsign, &rhash); if (i) BIO_puts(out, ":"); + switch (rsign | rhash << 8) { + case 0x0809: + BIO_puts(out, "rsa_pss_pss_sha256"); + continue; + case 0x080a: + BIO_puts(out, "rsa_pss_pss_sha384"); + continue; + case 0x080b: + BIO_puts(out, "rsa_pss_pss_sha512"); + continue; + case 0x081a: + BIO_puts(out, "ecdsa_brainpoolP256r1_sha256"); + continue; + case 0x081b: + BIO_puts(out, "ecdsa_brainpoolP384r1_sha384"); + continue; + case 0x081c: + BIO_puts(out, "ecdsa_brainpoolP512r1_sha512"); + continue; + } sstr = get_sigtype(sign_nid); if (sstr) BIO_printf(out, "%s", sstr); diff --git a/deps/openssl/openssl/apps/lib/s_socket.c b/deps/openssl/openssl/apps/lib/s_socket.c index 059afe47b90..8c6020d0169 100644 --- a/deps/openssl/openssl/apps/lib/s_socket.c +++ b/deps/openssl/openssl/apps/lib/s_socket.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2025 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 @@ -380,6 +380,12 @@ int do_server(int *accept_sock, const char *host, const char *port, BIO_closesocket(asock); break; } + + if (naccept != -1) + naccept--; + if (naccept == 0) + BIO_closesocket(asock); + BIO_set_tcp_ndelay(sock, 1); i = (*cb)(sock, type, protocol, context); @@ -410,11 +416,12 @@ int do_server(int *accept_sock, const char *host, const char *port, BIO_closesocket(sock); } else { + if (naccept != -1) + naccept--; + i = (*cb)(asock, type, protocol, context); } - if (naccept != -1) - naccept--; if (i < 0 || naccept == 0) { BIO_closesocket(asock); ret = i; diff --git a/deps/openssl/openssl/apps/lib/vms_term_sock.c b/deps/openssl/openssl/apps/lib/vms_term_sock.c index 97fb3943265..1a413376b20 100644 --- a/deps/openssl/openssl/apps/lib/vms_term_sock.c +++ b/deps/openssl/openssl/apps/lib/vms_term_sock.c @@ -353,7 +353,7 @@ static int CreateSocketPair (int SocketFamily, /* ** Get the binary (64-bit) time of the specified timeout value */ - sprintf (AscTimeBuff, "0 0:0:%02d.00", SOCKET_PAIR_TIMEOUT_VALUE); + BIO_snprintf(AscTimeBuff, sizeof(AscTimeBuff), "0 0:0:%02d.00", SOCKET_PAIR_TIMEOUT_VALUE); AscTimeDesc.dsc$w_length = strlen (AscTimeBuff); AscTimeDesc.dsc$a_pointer = AscTimeBuff; status = sys$bintim (&AscTimeDesc, BinTimeBuff); @@ -567,10 +567,10 @@ static void LogMessage (char *msg, ...) /* ** Format the message buffer */ - sprintf (MsgBuff, "%02d-%s-%04d %02d:%02d:%02d [%08X] %s\n", - LocTime->tm_mday, Month[LocTime->tm_mon], - (LocTime->tm_year + 1900), LocTime->tm_hour, LocTime->tm_min, - LocTime->tm_sec, pid, msg); + BIO_snprintf(MsgBuff, sizeof(MsgBuff), "%02d-%s-%04d %02d:%02d:%02d [%08X] %s\n", + LocTime->tm_mday, Month[LocTime->tm_mon], + (LocTime->tm_year + 1900), LocTime->tm_hour, LocTime->tm_min, + LocTime->tm_sec, pid, msg); /* ** Get any variable arguments and add them to the print of the message diff --git a/deps/openssl/openssl/apps/passwd.c b/deps/openssl/openssl/apps/passwd.c index 64b2e76c147..31d8bdd87cb 100644 --- a/deps/openssl/openssl/apps/passwd.c +++ b/deps/openssl/openssl/apps/passwd.c @@ -589,7 +589,8 @@ static char *shacrypt(const char *passwd, const char *magic, const char *salt) OPENSSL_strlcat(out_buf, ascii_dollar, sizeof(out_buf)); if (rounds_custom) { char tmp_buf[80]; /* "rounds=999999999" */ - sprintf(tmp_buf, "rounds=%u", rounds); + + BIO_snprintf(tmp_buf, sizeof(tmp_buf), "rounds=%u", rounds); #ifdef CHARSET_EBCDIC /* In case we're really on a ASCII based platform and just pretend */ if (tmp_buf[0] != 0x72) /* ASCII 'r' */ diff --git a/deps/openssl/openssl/apps/pkcs12.c b/deps/openssl/openssl/apps/pkcs12.c index ab78903ee9c..5146699f167 100644 --- a/deps/openssl/openssl/apps/pkcs12.c +++ b/deps/openssl/openssl/apps/pkcs12.c @@ -1,5 +1,5 @@ /* - * Copyright 1999-2024 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-2025 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 @@ -305,7 +305,8 @@ int pkcs12_main(int argc, char **argv) if (canames == NULL && (canames = sk_OPENSSL_STRING_new_null()) == NULL) goto end; - sk_OPENSSL_STRING_push(canames, opt_arg()); + if (sk_OPENSSL_STRING_push(canames, opt_arg()) <= 0) + goto end; break; case OPT_IN: infile = opt_arg(); diff --git a/deps/openssl/openssl/apps/pkeyutl.c b/deps/openssl/openssl/apps/pkeyutl.c index 3c9f9025a16..5e504713763 100644 --- a/deps/openssl/openssl/apps/pkeyutl.c +++ b/deps/openssl/openssl/apps/pkeyutl.c @@ -81,10 +81,11 @@ const OPTIONS pkeyutl_options[] = { OPT_SECTION("Output"), {"out", OPT_OUT, '>', "Output file - default stdout"}, - {"asn1parse", OPT_ASN1PARSE, '-', "asn1parse the output data"}, + {"asn1parse", OPT_ASN1PARSE, '-', + "parse the output as ASN.1 data to check its DER encoding and print errors"}, {"hexdump", OPT_HEXDUMP, '-', "Hex dump output"}, {"verifyrecover", OPT_VERIFYRECOVER, '-', - "Verify with public key, recover original data"}, + "Verify RSA signature, recovering original signature input data"}, OPT_SECTION("Signing/Derivation"), {"digest", OPT_DIGEST, 's', diff --git a/deps/openssl/openssl/apps/rehash.c b/deps/openssl/openssl/apps/rehash.c index 85eee385794..6e0ca3642c4 100644 --- a/deps/openssl/openssl/apps/rehash.c +++ b/deps/openssl/openssl/apps/rehash.c @@ -559,6 +559,11 @@ int rehash_main(int argc, char **argv) } else if ((env = getenv(X509_get_default_cert_dir_env())) != NULL) { char lsc[2] = { LIST_SEPARATOR_CHAR, '\0' }; m = OPENSSL_strdup(env); + if (m == NULL) { + BIO_puts(bio_err, "out of memory\n"); + errs = 1; + goto end; + } for (e = strtok(m, lsc); e != NULL; e = strtok(NULL, lsc)) errs += do_dir(e, h); OPENSSL_free(m); diff --git a/deps/openssl/openssl/apps/smime.c b/deps/openssl/openssl/apps/smime.c index 651294e46da..790a8d06ad0 100644 --- a/deps/openssl/openssl/apps/smime.c +++ b/deps/openssl/openssl/apps/smime.c @@ -1,5 +1,5 @@ /* - * Copyright 1999-2024 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-2025 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 @@ -279,13 +279,15 @@ int smime_main(int argc, char **argv) if (sksigners == NULL && (sksigners = sk_OPENSSL_STRING_new_null()) == NULL) goto end; - sk_OPENSSL_STRING_push(sksigners, signerfile); + if (sk_OPENSSL_STRING_push(sksigners, signerfile) <= 0) + goto end; if (keyfile == NULL) keyfile = signerfile; if (skkeys == NULL && (skkeys = sk_OPENSSL_STRING_new_null()) == NULL) goto end; - sk_OPENSSL_STRING_push(skkeys, keyfile); + if (sk_OPENSSL_STRING_push(skkeys, keyfile) <= 0) + goto end; keyfile = NULL; } signerfile = opt_arg(); @@ -310,12 +312,14 @@ int smime_main(int argc, char **argv) if (sksigners == NULL && (sksigners = sk_OPENSSL_STRING_new_null()) == NULL) goto end; - sk_OPENSSL_STRING_push(sksigners, signerfile); + if (sk_OPENSSL_STRING_push(sksigners, signerfile) <= 0) + goto end; signerfile = NULL; if (skkeys == NULL && (skkeys = sk_OPENSSL_STRING_new_null()) == NULL) goto end; - sk_OPENSSL_STRING_push(skkeys, keyfile); + if (sk_OPENSSL_STRING_push(skkeys, keyfile) <= 0) + goto end; } keyfile = opt_arg(); break; @@ -390,12 +394,14 @@ int smime_main(int argc, char **argv) if (sksigners == NULL && (sksigners = sk_OPENSSL_STRING_new_null()) == NULL) goto end; - sk_OPENSSL_STRING_push(sksigners, signerfile); + if (sk_OPENSSL_STRING_push(sksigners, signerfile) <= 0) + goto end; if (!skkeys && (skkeys = sk_OPENSSL_STRING_new_null()) == NULL) goto end; if (!keyfile) keyfile = signerfile; - sk_OPENSSL_STRING_push(skkeys, keyfile); + if (sk_OPENSSL_STRING_push(skkeys, keyfile) <= 0) + goto end; } if (sksigners == NULL) { BIO_printf(bio_err, "No signer certificate specified\n"); diff --git a/deps/openssl/openssl/apps/speed.c b/deps/openssl/openssl/apps/speed.c index d8e2c70e612..bafcacf7775 100644 --- a/deps/openssl/openssl/apps/speed.c +++ b/deps/openssl/openssl/apps/speed.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the Apache License 2.0 (the "License"). You may not use @@ -456,6 +456,14 @@ static double sm2_results[SM2_NUM][2]; /* 2 ops: sign then verify */ #define COND(unused_cond) (run && count < INT_MAX) #define COUNT(d) (count) +#define TAG_LEN 16 + +static unsigned int mode_op; /* AE Mode of operation */ +static unsigned int aead = 0; /* AEAD flag */ +static unsigned char aead_iv[12]; /* For AEAD modes */ +static unsigned char aad[EVP_AEAD_TLS1_AAD_LEN] = { 0xcc }; +static int aead_ivlen = sizeof(aead_iv); + typedef struct loopargs_st { ASYNC_JOB *inprogress_job; ASYNC_WAIT_CTX *wait_ctx; @@ -464,6 +472,7 @@ typedef struct loopargs_st { unsigned char *buf_malloc; unsigned char *buf2_malloc; unsigned char *key; + unsigned char tag[TAG_LEN]; size_t buflen; size_t sigsize; EVP_PKEY_CTX *rsa_sign_ctx[RSA_NUM]; @@ -727,12 +736,8 @@ static int EVP_Update_loop(void *args) unsigned char *buf = tempargs->buf; EVP_CIPHER_CTX *ctx = tempargs->ctx; int outl, count, rc; - unsigned char faketag[16] = { 0xcc }; if (decrypt) { - if (EVP_CIPHER_get_flags(EVP_CIPHER_CTX_get0_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER) { - (void)EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, sizeof(faketag), faketag); - } for (count = 0; COND(c[D_EVP][testnum]); count++) { rc = EVP_DecryptUpdate(ctx, buf, &outl, buf, lengths[testnum]); if (rc != 1) { @@ -757,74 +762,159 @@ static int EVP_Update_loop(void *args) } /* + * To make AEAD benchmarking more relevant perform TLS-like operations, + * 13-byte AAD followed by payload. But don't use TLS-formatted AAD, as + * payload length is not actually limited by 16KB... * CCM does not support streaming. For the purpose of performance measurement, * each message is encrypted using the same (key,iv)-pair. Do not use this * code in your application. */ -static int EVP_Update_loop_ccm(void *args) +static int EVP_Update_loop_aead_enc(void *args) { loopargs_t *tempargs = *(loopargs_t **) args; unsigned char *buf = tempargs->buf; + unsigned char *key = tempargs->key; EVP_CIPHER_CTX *ctx = tempargs->ctx; - int outl, count; - unsigned char tag[12]; - - if (decrypt) { - for (count = 0; COND(c[D_EVP][testnum]); count++) { - (void)EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, sizeof(tag), - tag); - /* reset iv */ - (void)EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv); - /* counter is reset on every update */ - (void)EVP_DecryptUpdate(ctx, buf, &outl, buf, lengths[testnum]); + int outl, count, realcount = 0; + + for (count = 0; COND(c[D_EVP][testnum]); count++) { + /* Set length of iv (Doesn't apply to SIV mode) */ + if (mode_op != EVP_CIPH_SIV_MODE) { + if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, + aead_ivlen, NULL)) { + BIO_printf(bio_err, "\nFailed to set iv length\n"); + ERR_print_errors(bio_err); + exit(1); + } } - } else { - for (count = 0; COND(c[D_EVP][testnum]); count++) { - /* restore iv length field */ - (void)EVP_EncryptUpdate(ctx, NULL, &outl, NULL, lengths[testnum]); - /* counter is reset on every update */ - (void)EVP_EncryptUpdate(ctx, buf, &outl, buf, lengths[testnum]); + /* Set tag_len (Not for GCM/SIV at encryption stage) */ + if (mode_op != EVP_CIPH_GCM_MODE + && mode_op != EVP_CIPH_SIV_MODE) { + if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, + TAG_LEN, NULL)) { + BIO_printf(bio_err, "\nFailed to set tag length\n"); + ERR_print_errors(bio_err); + exit(1); + } + } + if (!EVP_CipherInit_ex(ctx, NULL, NULL, key, aead_iv, -1)) { + BIO_printf(bio_err, "\nFailed to set key and iv\n"); + ERR_print_errors(bio_err); + exit(1); + } + /* Set total length of input. Only required for CCM */ + if (mode_op == EVP_CIPH_CCM_MODE) { + if (!EVP_EncryptUpdate(ctx, NULL, &outl, + NULL, lengths[testnum])) { + BIO_printf(bio_err, "\nCouldn't set input text length\n"); + ERR_print_errors(bio_err); + exit(1); + } } + if (aead) { + if (!EVP_EncryptUpdate(ctx, NULL, &outl, aad, sizeof(aad))) { + BIO_printf(bio_err, "\nCouldn't insert AAD when encrypting\n"); + ERR_print_errors(bio_err); + exit(1); + } + } + if (!EVP_EncryptUpdate(ctx, buf, &outl, buf, lengths[testnum])) { + BIO_printf(bio_err, "\nFailed to encrypt the data\n"); + ERR_print_errors(bio_err); + exit(1); + } + if (EVP_EncryptFinal_ex(ctx, buf, &outl)) + realcount++; } - if (decrypt) - (void)EVP_DecryptFinal_ex(ctx, buf, &outl); - else - (void)EVP_EncryptFinal_ex(ctx, buf, &outl); - return count; + return realcount; } /* * To make AEAD benchmarking more relevant perform TLS-like operations, * 13-byte AAD followed by payload. But don't use TLS-formatted AAD, as * payload length is not actually limited by 16KB... + * CCM does not support streaming. For the purpose of performance measurement, + * each message is decrypted using the same (key,iv)-pair. Do not use this + * code in your application. + * For decryption, we will use buf2 to preserve the input text in buf. */ -static int EVP_Update_loop_aead(void *args) +static int EVP_Update_loop_aead_dec(void *args) { loopargs_t *tempargs = *(loopargs_t **) args; unsigned char *buf = tempargs->buf; + unsigned char *outbuf = tempargs->buf2; + unsigned char *key = tempargs->key; + unsigned char tag[TAG_LEN]; EVP_CIPHER_CTX *ctx = tempargs->ctx; - int outl, count; - unsigned char aad[13] = { 0xcc }; - unsigned char faketag[16] = { 0xcc }; + int outl, count, realcount = 0; + + for (count = 0; COND(c[D_EVP][testnum]); count++) { + /* Set the length of iv (Doesn't apply to SIV mode) */ + if (mode_op != EVP_CIPH_SIV_MODE) { + if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, + aead_ivlen, NULL)) { + BIO_printf(bio_err, "\nFailed to set iv length\n"); + ERR_print_errors(bio_err); + exit(1); + } + } - if (decrypt) { - for (count = 0; COND(c[D_EVP][testnum]); count++) { - (void)EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv); - (void)EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, - sizeof(faketag), faketag); - (void)EVP_DecryptUpdate(ctx, NULL, &outl, aad, sizeof(aad)); - (void)EVP_DecryptUpdate(ctx, buf, &outl, buf, lengths[testnum]); - (void)EVP_DecryptFinal_ex(ctx, buf + outl, &outl); + /* Set the tag length (Doesn't apply to SIV mode) */ + if (mode_op != EVP_CIPH_SIV_MODE + && mode_op != EVP_CIPH_GCM_MODE) { + if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, + TAG_LEN, NULL)) { + BIO_printf(bio_err, "\nFailed to set tag length\n"); + ERR_print_errors(bio_err); + exit(1); + } } - } else { - for (count = 0; COND(c[D_EVP][testnum]); count++) { - (void)EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv); - (void)EVP_EncryptUpdate(ctx, NULL, &outl, aad, sizeof(aad)); - (void)EVP_EncryptUpdate(ctx, buf, &outl, buf, lengths[testnum]); - (void)EVP_EncryptFinal_ex(ctx, buf + outl, &outl); + if (!EVP_CipherInit_ex(ctx, NULL, NULL, key, aead_iv, -1)) { + BIO_printf(bio_err, "\nFailed to set key and iv\n"); + ERR_print_errors(bio_err); + exit(1); + } + /* Set iv before decryption (Doesn't apply to SIV mode) */ + if (mode_op != EVP_CIPH_SIV_MODE) { + if (!EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, aead_iv)) { + BIO_printf(bio_err, "\nFailed to set iv\n"); + ERR_print_errors(bio_err); + exit(1); + } + } + memcpy(tag, tempargs->tag, TAG_LEN); + + if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, + TAG_LEN, tag)) { + BIO_printf(bio_err, "\nFailed to set tag\n"); + ERR_print_errors(bio_err); + exit(1); + } + /* Set the total length of cipher text. Only required for CCM */ + if (mode_op == EVP_CIPH_CCM_MODE) { + if (!EVP_DecryptUpdate(ctx, NULL, &outl, + NULL, lengths[testnum])) { + BIO_printf(bio_err, "\nCouldn't set cipher text length\n"); + ERR_print_errors(bio_err); + exit(1); + } + } + if (aead) { + if (!EVP_DecryptUpdate(ctx, NULL, &outl, aad, sizeof(aad))) { + BIO_printf(bio_err, "\nCouldn't insert AAD when decrypting\n"); + ERR_print_errors(bio_err); + exit(1); + } + } + if (!EVP_DecryptUpdate(ctx, outbuf, &outl, buf, lengths[testnum])) { + BIO_printf(bio_err, "\nFailed to decrypt the data\n"); + ERR_print_errors(bio_err); + exit(1); } + if (EVP_DecryptFinal_ex(ctx, outbuf, &outl)) + realcount++; } - return count; + return realcount; } static long rsa_c[RSA_NUM][2]; /* # RSA iteration test */ @@ -1370,11 +1460,11 @@ int speed_main(int argc, char **argv) OPTION_CHOICE o; int async_init = 0, multiblock = 0, pr_header = 0; uint8_t doit[ALGOR_NUM] = { 0 }; - int ret = 1, misalign = 0, lengths_single = 0, aead = 0; + int ret = 1, misalign = 0, lengths_single = 0; long count = 0; unsigned int size_num = SIZE_NUM; unsigned int i, k, loopargs_len = 0, async_jobs = 0; - int keylen; + int keylen = 0; int buflen; BIGNUM *bn = NULL; EVP_PKEY_CTX *genctx = NULL; @@ -2001,15 +2091,14 @@ int speed_main(int argc, char **argv) if (doit[D_HMAC]) { static const char hmac_key[] = "This is a key..."; int len = strlen(hmac_key); + size_t hmac_name_len = sizeof("hmac()") + strlen(evp_mac_mdname); OSSL_PARAM params[3]; mac = EVP_MAC_fetch(app_get0_libctx(), "HMAC", app_get0_propq()); if (mac == NULL || evp_mac_mdname == NULL) goto end; - - evp_hmac_name = app_malloc(sizeof("hmac()") + strlen(evp_mac_mdname), - "HMAC name"); - sprintf(evp_hmac_name, "hmac(%s)", evp_mac_mdname); + evp_hmac_name = app_malloc(hmac_name_len, "HMAC name"); + BIO_snprintf(evp_hmac_name, hmac_name_len, "hmac(%s)", evp_mac_mdname); names[D_HMAC] = evp_hmac_name; params[0] = @@ -2213,12 +2302,20 @@ int speed_main(int argc, char **argv) } } + /*- + * There are three scenarios for D_EVP: + * 1- Using authenticated encryption (AE) e.g. CCM, GCM, OCB etc. + * 2- Using AE + associated data (AD) i.e. AEAD using CCM, GCM, OCB etc. + * 3- Not using AE or AD e.g. ECB, CBC, CFB etc. + */ if (doit[D_EVP]) { if (evp_cipher != NULL) { - int (*loopfunc) (void *) = EVP_Update_loop; + int (*loopfunc) (void *); + int outlen = 0; + unsigned int ae_mode = 0; - if (multiblock && (EVP_CIPHER_get_flags(evp_cipher) & - EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK)) { + if (multiblock && (EVP_CIPHER_get_flags(evp_cipher) + & EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK)) { multiblock_speed(evp_cipher, lengths_single, &seconds); ret = 0; goto end; @@ -2226,16 +2323,26 @@ int speed_main(int argc, char **argv) names[D_EVP] = EVP_CIPHER_get0_name(evp_cipher); - if (EVP_CIPHER_get_mode(evp_cipher) == EVP_CIPH_CCM_MODE) { - loopfunc = EVP_Update_loop_ccm; - } else if (aead && (EVP_CIPHER_get_flags(evp_cipher) & - EVP_CIPH_FLAG_AEAD_CIPHER)) { - loopfunc = EVP_Update_loop_aead; + mode_op = EVP_CIPHER_get_mode(evp_cipher); + + if (aead) { if (lengths == lengths_list) { lengths = aead_lengths_list; size_num = OSSL_NELEM(aead_lengths_list); } } + if (mode_op == EVP_CIPH_GCM_MODE + || mode_op == EVP_CIPH_CCM_MODE + || mode_op == EVP_CIPH_OCB_MODE + || mode_op == EVP_CIPH_SIV_MODE) { + ae_mode = 1; + if (decrypt) + loopfunc = EVP_Update_loop_aead_dec; + else + loopfunc = EVP_Update_loop_aead_enc; + } else { + loopfunc = EVP_Update_loop; + } for (testnum = 0; testnum < size_num; testnum++) { print_message(names[D_EVP], c[D_EVP][testnum], lengths[testnum], @@ -2247,37 +2354,144 @@ int speed_main(int argc, char **argv) BIO_printf(bio_err, "\nEVP_CIPHER_CTX_new failure\n"); exit(1); } - if (!EVP_CipherInit_ex(loopargs[k].ctx, evp_cipher, NULL, - NULL, iv, decrypt ? 0 : 1)) { - BIO_printf(bio_err, "\nEVP_CipherInit_ex failure\n"); + + /* + * For AE modes, we must first encrypt the data to get + * a valid tag that enables us to decrypt. If we don't + * encrypt first, we won't have a valid tag that enables + * authenticity and hence decryption will fail. + */ + if (!EVP_CipherInit_ex(loopargs[k].ctx, + evp_cipher, NULL, NULL, NULL, + ae_mode ? 1 : !decrypt)) { + BIO_printf(bio_err, "\nCouldn't init the context\n"); ERR_print_errors(bio_err); exit(1); } + /* Padding isn't needed */ EVP_CIPHER_CTX_set_padding(loopargs[k].ctx, 0); keylen = EVP_CIPHER_CTX_get_key_length(loopargs[k].ctx); loopargs[k].key = app_malloc(keylen, "evp_cipher key"); EVP_CIPHER_CTX_rand_key(loopargs[k].ctx, loopargs[k].key); - if (!EVP_CipherInit_ex(loopargs[k].ctx, NULL, NULL, - loopargs[k].key, NULL, -1)) { - BIO_printf(bio_err, "\nEVP_CipherInit_ex failure\n"); - ERR_print_errors(bio_err); - exit(1); - } - OPENSSL_clear_free(loopargs[k].key, keylen); - /* SIV mode only allows for a single Update operation */ - if (EVP_CIPHER_get_mode(evp_cipher) == EVP_CIPH_SIV_MODE) - (void)EVP_CIPHER_CTX_ctrl(loopargs[k].ctx, - EVP_CTRL_SET_SPEED, 1, NULL); + if (!ae_mode) { + if (!EVP_CipherInit_ex(loopargs[k].ctx, NULL, NULL, + loopargs[k].key, iv, -1)) { + BIO_printf(bio_err, "\nFailed to set the key\n"); + ERR_print_errors(bio_err); + exit(1); + } + } else if (mode_op == EVP_CIPH_SIV_MODE) { + EVP_CIPHER_CTX_ctrl(loopargs[k].ctx, + EVP_CTRL_SET_SPEED, 1, NULL); + } + if (ae_mode && decrypt) { + /* Set length of iv (Doesn't apply to SIV mode) */ + if (mode_op != EVP_CIPH_SIV_MODE) { + if (!EVP_CIPHER_CTX_ctrl(loopargs[k].ctx, + EVP_CTRL_AEAD_SET_IVLEN, + aead_ivlen, NULL)) { + BIO_printf(bio_err, "\nFailed to set iv length\n"); + ERR_print_errors(bio_err); + exit(1); + } + } + /* Set tag_len (Not for SIV at encryption stage) */ + if (mode_op != EVP_CIPH_GCM_MODE + && mode_op != EVP_CIPH_SIV_MODE) { + if (!EVP_CIPHER_CTX_ctrl(loopargs[k].ctx, + EVP_CTRL_AEAD_SET_TAG, + TAG_LEN, NULL)) { + BIO_printf(bio_err, + "\nFailed to set tag length\n"); + ERR_print_errors(bio_err); + exit(1); + } + } + if (!EVP_CipherInit_ex(loopargs[k].ctx, NULL, NULL, + loopargs[k].key, aead_iv, -1)) { + BIO_printf(bio_err, "\nFailed to set the key\n"); + ERR_print_errors(bio_err); + exit(1); + } + /* Set total length of input. Only required for CCM */ + if (mode_op == EVP_CIPH_CCM_MODE) { + if (!EVP_EncryptUpdate(loopargs[k].ctx, NULL, + &outlen, NULL, + lengths[testnum])) { + BIO_printf(bio_err, + "\nCouldn't set input text length\n"); + ERR_print_errors(bio_err); + exit(1); + } + } + if (aead) { + if (!EVP_EncryptUpdate(loopargs[k].ctx, NULL, + &outlen, aad, sizeof(aad))) { + BIO_printf(bio_err, + "\nCouldn't insert AAD when encrypting\n"); + ERR_print_errors(bio_err); + exit(1); + } + } + if (!EVP_EncryptUpdate(loopargs[k].ctx, loopargs[k].buf, + &outlen, loopargs[k].buf, + lengths[testnum])) { + BIO_printf(bio_err, + "\nFailed to to encrypt the data\n"); + ERR_print_errors(bio_err); + exit(1); + } + + if (!EVP_EncryptFinal_ex(loopargs[k].ctx, + loopargs[k].buf, &outlen)) { + BIO_printf(bio_err, + "\nFailed finalize the encryption\n"); + ERR_print_errors(bio_err); + exit(1); + } + + if (!EVP_CIPHER_CTX_ctrl(loopargs[k].ctx, + EVP_CTRL_AEAD_GET_TAG, + TAG_LEN, &loopargs[k].tag)) { + BIO_printf(bio_err, "\nFailed to get the tag\n"); + ERR_print_errors(bio_err); + exit(1); + } + + EVP_CIPHER_CTX_free(loopargs[k].ctx); + loopargs[k].ctx = EVP_CIPHER_CTX_new(); + if (loopargs[k].ctx == NULL) { + BIO_printf(bio_err, + "\nEVP_CIPHER_CTX_new failure\n"); + exit(1); + } + if (!EVP_CipherInit_ex(loopargs[k].ctx, evp_cipher, + NULL, NULL, NULL, 0)) { + BIO_printf(bio_err, + "\nFailed initializing the context\n"); + ERR_print_errors(bio_err); + exit(1); + } + + EVP_CIPHER_CTX_set_padding(loopargs[k].ctx, 0); + + /* SIV only allows for one Update operation */ + if (mode_op == EVP_CIPH_SIV_MODE) + EVP_CIPHER_CTX_ctrl(loopargs[k].ctx, + EVP_CTRL_SET_SPEED, 1, NULL); + } } Time_F(START); count = run_benchmark(async_jobs, loopfunc, loopargs); d = Time_F(STOP); - for (k = 0; k < loopargs_len; k++) + for (k = 0; k < loopargs_len; k++) { + OPENSSL_clear_free(loopargs[k].key, keylen); EVP_CIPHER_CTX_free(loopargs[k].ctx); + } print_result(D_EVP, testnum, count, d); } } else if (evp_md_name != NULL) { @@ -2297,6 +2511,7 @@ int speed_main(int argc, char **argv) } if (doit[D_EVP_CMAC]) { + size_t len = sizeof("cmac()") + strlen(evp_mac_ciphername); OSSL_PARAM params[3]; EVP_CIPHER *cipher = NULL; @@ -2312,9 +2527,8 @@ int speed_main(int argc, char **argv) BIO_printf(bio_err, "\nRequested CMAC cipher with unsupported key length.\n"); goto end; } - evp_cmac_name = app_malloc(sizeof("cmac()") - + strlen(evp_mac_ciphername), "CMAC name"); - sprintf(evp_cmac_name, "cmac(%s)", evp_mac_ciphername); + evp_cmac_name = app_malloc(len, "CMAC name"); + BIO_snprintf(evp_cmac_name, len, "cmac(%s)", evp_mac_ciphername); names[D_EVP_CMAC] = evp_cmac_name; params[0] = OSSL_PARAM_construct_utf8_string(OSSL_ALG_PARAM_CIPHER, @@ -3675,7 +3889,6 @@ static void multiblock_speed(const EVP_CIPHER *evp_cipher, int lengths_single, print_message(alg_name, 0, mblengths[j], seconds->sym); Time_F(START); for (count = 0; run && count < INT_MAX; count++) { - unsigned char aad[EVP_AEAD_TLS1_AAD_LEN]; EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM mb_param; size_t len = mblengths[j]; int packlen; diff --git a/deps/openssl/openssl/configdata.pm.in b/deps/openssl/openssl/configdata.pm.in index 04b901144f4..a4ae9072999 100644 --- a/deps/openssl/openssl/configdata.pm.in +++ b/deps/openssl/openssl/configdata.pm.in @@ -145,7 +145,7 @@ _____ # defined in one template stick around for the # next, making them combinable PACKAGE => 'OpenSSL::safe') - or die $Text::Template::ERROR; + or die $OpenSSL::Template::ERROR; close BUILDFILE; rename("$buildfile.new", $buildfile) or die "Trying to rename $buildfile.new to $buildfile: $!"; @@ -167,7 +167,7 @@ _____ # defined in one template stick around for the # next, making them combinable PACKAGE => 'OpenSSL::safe') - or die $Text::Template::ERROR; + or die $OpenSSL::Template::ERROR; close CONFIGURATION_H; # When using stat() on Windows, we can get it to perform better by diff --git a/deps/openssl/openssl/crypto/asn1/a_bitstr.c b/deps/openssl/openssl/crypto/asn1/a_bitstr.c index 4930d5022ee..549c0e88554 100644 --- a/deps/openssl/openssl/crypto/asn1/a_bitstr.c +++ b/deps/openssl/openssl/crypto/asn1/a_bitstr.c @@ -36,25 +36,30 @@ int ossl_i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp) if (a->data[len - 1]) break; } - j = a->data[len - 1]; - if (j & 0x01) + + if (len == 0) { bits = 0; - else if (j & 0x02) - bits = 1; - else if (j & 0x04) - bits = 2; - else if (j & 0x08) - bits = 3; - else if (j & 0x10) - bits = 4; - else if (j & 0x20) - bits = 5; - else if (j & 0x40) - bits = 6; - else if (j & 0x80) - bits = 7; - else - bits = 0; /* should not happen */ + } else { + j = a->data[len - 1]; + if (j & 0x01) + bits = 0; + else if (j & 0x02) + bits = 1; + else if (j & 0x04) + bits = 2; + else if (j & 0x08) + bits = 3; + else if (j & 0x10) + bits = 4; + else if (j & 0x20) + bits = 5; + else if (j & 0x40) + bits = 6; + else if (j & 0x80) + bits = 7; + else + bits = 0; /* should not happen */ + } } } else bits = 0; diff --git a/deps/openssl/openssl/crypto/asn1/a_strnid.c b/deps/openssl/openssl/crypto/asn1/a_strnid.c index d052935661d..20cfabc8a7a 100644 --- a/deps/openssl/openssl/crypto/asn1/a_strnid.c +++ b/deps/openssl/openssl/crypto/asn1/a_strnid.c @@ -1,5 +1,5 @@ /* - * Copyright 1999-2023 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-2025 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 @@ -39,10 +39,10 @@ unsigned long ASN1_STRING_get_default_mask(void) * This function sets the default to various "flavours" of configuration. * based on an ASCII string. Currently this is: * MASK:XXXX : a numerical mask value. - * nobmp : Don't use BMPStrings (just Printable, T61). - * pkix : PKIX recommendation in RFC2459. - * utf8only : only use UTF8Strings (RFC2459 recommendation for 2004). - * default: the default value, Printable, T61, BMP. + * default : use Printable, IA5, T61, BMP, and UTF8 string types + * nombstr : any string type except variable-sized BMPStrings or UTF8Strings + * pkix : PKIX recommendation in RFC2459 + * utf8only : this is the default, use UTF8Strings */ int ASN1_STRING_set_default_mask_asc(const char *p) diff --git a/deps/openssl/openssl/crypto/asn1/a_time.c b/deps/openssl/openssl/crypto/asn1/a_time.c index 9b3074e47e8..5ef6d0d1cd1 100644 --- a/deps/openssl/openssl/crypto/asn1/a_time.c +++ b/deps/openssl/openssl/crypto/asn1/a_time.c @@ -1,5 +1,5 @@ /* - * Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-2025 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 @@ -488,9 +488,9 @@ int ASN1_TIME_print_ex(BIO *bp, const ASN1_TIME *tm, unsigned long flags) int ossl_asn1_time_print_ex(BIO *bp, const ASN1_TIME *tm, unsigned long flags) { char *v; - int gmt = 0, l; + int l; struct tm stm; - const char upper_z = 0x5A, period = 0x2E; + const char period = 0x2E; /* ossl_asn1_time_to_tm will check the time type */ if (!ossl_asn1_time_to_tm(&stm, tm)) @@ -498,8 +498,6 @@ int ossl_asn1_time_print_ex(BIO *bp, const ASN1_TIME *tm, unsigned long flags) l = tm->length; v = (char *)tm->data; - if (v[l - 1] == upper_z) - gmt = 1; if (tm->type == V_ASN1_GENERALIZEDTIME) { char *f = NULL; @@ -510,39 +508,36 @@ int ossl_asn1_time_print_ex(BIO *bp, const ASN1_TIME *tm, unsigned long flags) * 'fraction point' in a GeneralizedTime string. */ if (tm->length > 15 && v[14] == period) { - f = &v[14]; - f_len = 1; - while (14 + f_len < l && ossl_ascii_isdigit(f[f_len])) + /* exclude the . itself */ + f = &v[15]; + f_len = 0; + while (15 + f_len < l && ossl_ascii_isdigit(f[f_len])) ++f_len; } - if ((flags & ASN1_DTFLGS_TYPE_MASK) == ASN1_DTFLGS_ISO8601) { - return BIO_printf(bp, "%4d-%02d-%02d %02d:%02d:%02d%.*s%s", - stm.tm_year + 1900, stm.tm_mon + 1, - stm.tm_mday, stm.tm_hour, - stm.tm_min, stm.tm_sec, f_len, f, - (gmt ? "Z" : "")) > 0; - } - else { - return BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s", - _asn1_mon[stm.tm_mon], stm.tm_mday, stm.tm_hour, - stm.tm_min, stm.tm_sec, f_len, f, stm.tm_year + 1900, - (gmt ? " GMT" : "")) > 0; + if (f_len > 0) { + if ((flags & ASN1_DTFLGS_TYPE_MASK) == ASN1_DTFLGS_ISO8601) { + return BIO_printf(bp, "%4d-%02d-%02d %02d:%02d:%02d.%.*sZ", + stm.tm_year + 1900, stm.tm_mon + 1, + stm.tm_mday, stm.tm_hour, + stm.tm_min, stm.tm_sec, f_len, f) > 0; + } else { + return BIO_printf(bp, "%s %2d %02d:%02d:%02d.%.*s %d GMT", + _asn1_mon[stm.tm_mon], stm.tm_mday, stm.tm_hour, + stm.tm_min, stm.tm_sec, f_len, f, + stm.tm_year + 1900) > 0; + } } - } else { - if ((flags & ASN1_DTFLGS_TYPE_MASK) == ASN1_DTFLGS_ISO8601) { - return BIO_printf(bp, "%4d-%02d-%02d %02d:%02d:%02d%s", + } + if ((flags & ASN1_DTFLGS_TYPE_MASK) == ASN1_DTFLGS_ISO8601) { + return BIO_printf(bp, "%4d-%02d-%02d %02d:%02d:%02dZ", stm.tm_year + 1900, stm.tm_mon + 1, stm.tm_mday, stm.tm_hour, - stm.tm_min, stm.tm_sec, - (gmt ? "Z" : "")) > 0; - } - else { - return BIO_printf(bp, "%s %2d %02d:%02d:%02d %d%s", + stm.tm_min, stm.tm_sec) > 0; + } else { + return BIO_printf(bp, "%s %2d %02d:%02d:%02d %d GMT", _asn1_mon[stm.tm_mon], stm.tm_mday, stm.tm_hour, - stm.tm_min, stm.tm_sec, stm.tm_year + 1900, - (gmt ? " GMT" : "")) > 0; - } + stm.tm_min, stm.tm_sec, stm.tm_year + 1900) > 0; } } diff --git a/deps/openssl/openssl/crypto/asn1/asn1_gen.c b/deps/openssl/openssl/crypto/asn1/asn1_gen.c index 402ab34e6a4..152dc870a55 100644 --- a/deps/openssl/openssl/crypto/asn1/asn1_gen.c +++ b/deps/openssl/openssl/crypto/asn1/asn1_gen.c @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2002-2025 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 @@ -498,7 +498,8 @@ static int append_exp(tag_exp_arg *arg, int exp_tag, int exp_class, static int asn1_str2tag(const char *tagstr, int len) { unsigned int i; - static const struct tag_name_st *tntmp, tnst[] = { + const struct tag_name_st *tntmp; + static const struct tag_name_st tnst[] = { ASN1_GEN_STR("BOOL", V_ASN1_BOOLEAN), ASN1_GEN_STR("BOOLEAN", V_ASN1_BOOLEAN), ASN1_GEN_STR("NULL", V_ASN1_NULL), diff --git a/deps/openssl/openssl/crypto/asn1/asn_mime.c b/deps/openssl/openssl/crypto/asn1/asn_mime.c index 9fc52d04762..8bb7089292d 100644 --- a/deps/openssl/openssl/crypto/asn1/asn_mime.c +++ b/deps/openssl/openssl/crypto/asn1/asn_mime.c @@ -300,6 +300,8 @@ int SMIME_write_ASN1_ex(BIO *bio, ASN1_VALUE *val, BIO *data, int flags, if (ctype_nid == NID_pkcs7_enveloped) { msg_type = "enveloped-data"; + } else if (ctype_nid == NID_id_smime_ct_authEnvelopedData) { + msg_type = "authEnveloped-data"; } else if (ctype_nid == NID_pkcs7_signed) { if (econt_nid == NID_id_smime_ct_receipt) msg_type = "signed-receipt"; diff --git a/deps/openssl/openssl/crypto/bio/bio_addr.c b/deps/openssl/openssl/crypto/bio/bio_addr.c index 04d62f45b19..d462f424d3a 100644 --- a/deps/openssl/openssl/crypto/bio/bio_addr.c +++ b/deps/openssl/openssl/crypto/bio/bio_addr.c @@ -1,5 +1,5 @@ /* - * Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2025 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 @@ -547,8 +547,13 @@ int BIO_parse_hostserv(const char *hostserv, char **host, char **service, *service = NULL; } else { *service = OPENSSL_strndup(p, pl); - if (*service == NULL) + if (*service == NULL) { + if (h != NULL && host != NULL) { + OPENSSL_free(*host); + *host = NULL; + } goto memerr; + } } } diff --git a/deps/openssl/openssl/crypto/bio/bio_sock.c b/deps/openssl/openssl/crypto/bio/bio_sock.c index 12e6a68e3a2..84496de6f6b 100644 --- a/deps/openssl/openssl/crypto/bio/bio_sock.c +++ b/deps/openssl/openssl/crypto/bio/bio_sock.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2025 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 @@ -222,7 +222,7 @@ int BIO_get_accept_socket(char *host, int bind_mode) return INVALID_SOCKET; if (BIO_sock_init() != 1) - return INVALID_SOCKET; + goto err; if (BIO_lookup(h, p, BIO_LOOKUP_SERVER, AF_UNSPEC, SOCK_STREAM, &res) != 0) goto err; diff --git a/deps/openssl/openssl/crypto/bio/bss_log.c b/deps/openssl/openssl/crypto/bio/bss_log.c index 82abfd5cec6..63b30e300fe 100644 --- a/deps/openssl/openssl/crypto/bio/bss_log.c +++ b/deps/openssl/openssl/crypto/bio/bss_log.c @@ -281,7 +281,7 @@ static void xsyslog(BIO *bp, int priority, const char *string) break; } - sprintf(pidbuf, "[%lu] ", GetCurrentProcessId()); + BIO_snprintf(pidbuf, sizeof(pidbuf), "[%lu] ", GetCurrentProcessId()); lpszStrings[0] = pidbuf; lpszStrings[1] = string; diff --git a/deps/openssl/openssl/crypto/bn/asm/armv8-mont.pl b/deps/openssl/openssl/crypto/bn/asm/armv8-mont.pl index 54d2e8245f1..3192eab3092 100755 --- a/deps/openssl/openssl/crypto/bn/asm/armv8-mont.pl +++ b/deps/openssl/openssl/crypto/bn/asm/armv8-mont.pl @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2015-2025 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 @@ -84,10 +84,12 @@ cmp $num,#32 b.le .Lscalar_impl #ifndef __KERNEL__ +#ifndef __AARCH64EB__ adrp x17,OPENSSL_armv8_rsa_neonized ldr w17,[x17,#:lo12:OPENSSL_armv8_rsa_neonized] cbnz w17, bn_mul8x_mont_neon #endif +#endif .Lscalar_impl: tst $num,#7 diff --git a/deps/openssl/openssl/crypto/bn/bn_exp.c b/deps/openssl/openssl/crypto/bn/bn_exp.c index 598a592ca13..0e563ad823c 100644 --- a/deps/openssl/openssl/crypto/bn/bn_exp.c +++ b/deps/openssl/openssl/crypto/bn/bn_exp.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2025 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 @@ -606,7 +606,7 @@ static int MOD_EXP_CTIME_COPY_FROM_PREBUF(BIGNUM *b, int top, * out by Colin Percival, * http://www.daemonology.net/hyperthreading-considered-harmful/) */ -int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, +int bn_mod_exp_mont_fixed_top(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) { @@ -623,10 +623,6 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, unsigned int t4 = 0; #endif - bn_check_top(a); - bn_check_top(p); - bn_check_top(m); - if (!BN_is_odd(m)) { ERR_raise(ERR_LIB_BN, BN_R_CALLED_WITH_EVEN_MODULUS); return 0; @@ -1146,7 +1142,7 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, goto err; } else #endif - if (!BN_from_montgomery(rr, &tmp, mont, ctx)) + if (!bn_from_mont_fixed_top(rr, &tmp, mont, ctx)) goto err; ret = 1; err: @@ -1160,6 +1156,19 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, return ret; } +int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *in_mont) +{ + bn_check_top(a); + bn_check_top(p); + bn_check_top(m); + if (!bn_mod_exp_mont_fixed_top(rr, a, p, m, ctx, in_mont)) + return 0; + bn_correct_top(rr); + return 1; +} + int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) { diff --git a/deps/openssl/openssl/crypto/bn/bn_gf2m.c b/deps/openssl/openssl/crypto/bn/bn_gf2m.c index c811ae82d6b..bcc66613cc1 100644 --- a/deps/openssl/openssl/crypto/bn/bn_gf2m.c +++ b/deps/openssl/openssl/crypto/bn/bn_gf2m.c @@ -15,6 +15,7 @@ #include "bn_local.h" #ifndef OPENSSL_NO_EC2M +# include /* * Maximum number of iterations before BN_GF2m_mod_solve_quad_arr should @@ -1140,16 +1141,26 @@ int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, /* * Convert the bit-string representation of a polynomial ( \sum_{i=0}^n a_i * * x^i) into an array of integers corresponding to the bits with non-zero - * coefficient. Array is terminated with -1. Up to max elements of the array - * will be filled. Return value is total number of array elements that would - * be filled if array was large enough. + * coefficient. The array is intended to be suitable for use with + * `BN_GF2m_mod_arr()`, and so the constant term of the polynomial must not be + * zero. This translates to a requirement that the input BIGNUM `a` is odd. + * + * Given sufficient room, the array is terminated with -1. Up to max elements + * of the array will be filled. + * + * The return value is total number of array elements that would be filled if + * array was large enough, including the terminating `-1`. It is `0` when `a` + * is not odd or the constant term is zero contrary to requirement. + * + * The return value is also `0` when the leading exponent exceeds + * `OPENSSL_ECC_MAX_FIELD_BITS`, this guards against CPU exhaustion attacks, */ int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max) { int i, j, k = 0; BN_ULONG mask; - if (BN_is_zero(a)) + if (!BN_is_odd(a)) return 0; for (i = a->top - 1; i >= 0; i--) { @@ -1167,12 +1178,13 @@ int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max) } } - if (k < max) { + if (k > 0 && p[0] > OPENSSL_ECC_MAX_FIELD_BITS) + return 0; + + if (k < max) p[k] = -1; - k++; - } - return k; + return k + 1; } /* diff --git a/deps/openssl/openssl/crypto/bn/rsaz_exp_x2.c b/deps/openssl/openssl/crypto/bn/rsaz_exp_x2.c index b19050dfee8..4a2a6752f67 100644 --- a/deps/openssl/openssl/crypto/bn/rsaz_exp_x2.c +++ b/deps/openssl/openssl/crypto/bn/rsaz_exp_x2.c @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2020-2025 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2020, Intel Corporation. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use @@ -495,11 +495,7 @@ static void to_words52(BN_ULONG *out, int out_len, out_len--; } - while (out_len > 0) { - *out = 0; - out_len--; - out++; - } + memset(out, 0, out_len * sizeof(BN_ULONG)); } static ossl_inline void put_digit52(uint8_t *pStr, int strLen, uint64_t digit) diff --git a/deps/openssl/openssl/crypto/cmp/cmp_client.c b/deps/openssl/openssl/crypto/cmp/cmp_client.c index df334cc0019..4c8dbfdcd73 100644 --- a/deps/openssl/openssl/crypto/cmp/cmp_client.c +++ b/deps/openssl/openssl/crypto/cmp/cmp_client.c @@ -107,9 +107,12 @@ static int save_statusInfo(OSSL_CMP_CTX *ctx, OSSL_CMP_PKISI *si) ss = si->statusString; /* may be NULL */ for (i = 0; i < sk_ASN1_UTF8STRING_num(ss); i++) { ASN1_UTF8STRING *str = sk_ASN1_UTF8STRING_value(ss, i); + ASN1_UTF8STRING *dup = ASN1_STRING_dup(str); - if (!sk_ASN1_UTF8STRING_push(ctx->statusString, ASN1_STRING_dup(str))) + if (dup == NULL || !sk_ASN1_UTF8STRING_push(ctx->statusString, dup)) { + ASN1_UTF8STRING_free(dup); return 0; + } } return 1; } diff --git a/deps/openssl/openssl/crypto/cms/cms_asn1.c b/deps/openssl/openssl/crypto/cms/cms_asn1.c index 72cd14317d4..95095201592 100644 --- a/deps/openssl/openssl/crypto/cms/cms_asn1.c +++ b/deps/openssl/openssl/crypto/cms/cms_asn1.c @@ -51,6 +51,7 @@ static int cms_si_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, EVP_PKEY_free(si->pkey); X509_free(si->signer); EVP_MD_CTX_free(si->mctx); + EVP_PKEY_CTX_free(si->pctx); } return 1; } @@ -89,11 +90,21 @@ ASN1_SEQUENCE(CMS_OriginatorInfo) = { ASN1_IMP_SET_OF_OPT(CMS_OriginatorInfo, crls, CMS_RevocationInfoChoice, 1) } static_ASN1_SEQUENCE_END(CMS_OriginatorInfo) -ASN1_NDEF_SEQUENCE(CMS_EncryptedContentInfo) = { +static int cms_ec_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, + void *exarg) +{ + CMS_EncryptedContentInfo *ec = (CMS_EncryptedContentInfo *)*pval; + + if (operation == ASN1_OP_FREE_POST) + OPENSSL_clear_free(ec->key, ec->keylen); + return 1; +} + +ASN1_NDEF_SEQUENCE_cb(CMS_EncryptedContentInfo, cms_ec_cb) = { ASN1_SIMPLE(CMS_EncryptedContentInfo, contentType, ASN1_OBJECT), ASN1_SIMPLE(CMS_EncryptedContentInfo, contentEncryptionAlgorithm, X509_ALGOR), ASN1_IMP_OPT(CMS_EncryptedContentInfo, encryptedContent, ASN1_OCTET_STRING_NDEF, 0) -} static_ASN1_NDEF_SEQUENCE_END(CMS_EncryptedContentInfo) +} ASN1_NDEF_SEQUENCE_END_cb(CMS_EncryptedContentInfo, CMS_EncryptedContentInfo) ASN1_SEQUENCE(CMS_KeyTransRecipientInfo) = { ASN1_EMBED(CMS_KeyTransRecipientInfo, version, INT32), @@ -317,6 +328,10 @@ static int cms_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, return 0; break; + case ASN1_OP_FREE_POST: + OPENSSL_free(cms->ctx.propq); + break; + } return 1; } diff --git a/deps/openssl/openssl/crypto/cms/cms_dh.c b/deps/openssl/openssl/crypto/cms/cms_dh.c index 2f54ed2673a..3f931d6e6fe 100644 --- a/deps/openssl/openssl/crypto/cms/cms_dh.c +++ b/deps/openssl/openssl/crypto/cms/cms_dh.c @@ -34,7 +34,7 @@ static int dh_cms_set_peerkey(EVP_PKEY_CTX *pctx, if (OBJ_obj2nid(aoid) != NID_dhpublicnumber) goto err; /* Only absent parameters allowed in RFC XXXX */ - if (atype != V_ASN1_UNDEF && atype == V_ASN1_NULL) + if (atype != V_ASN1_UNDEF && atype != V_ASN1_NULL) goto err; pk = EVP_PKEY_CTX_get0_pkey(pctx); diff --git a/deps/openssl/openssl/crypto/cms/cms_env.c b/deps/openssl/openssl/crypto/cms/cms_env.c index 99cf1dcb396..445a16fb771 100644 --- a/deps/openssl/openssl/crypto/cms/cms_env.c +++ b/deps/openssl/openssl/crypto/cms/cms_env.c @@ -51,15 +51,6 @@ static int cms_get_enveloped_type(const CMS_ContentInfo *cms) return ret; } -void ossl_cms_env_enc_content_free(const CMS_ContentInfo *cinf) -{ - if (cms_get_enveloped_type_simple(cinf) != 0) { - CMS_EncryptedContentInfo *ec = ossl_cms_get0_env_enc_content(cinf); - if (ec != NULL) - OPENSSL_clear_free(ec->key, ec->keylen); - } -} - CMS_EnvelopedData *ossl_cms_get0_enveloped(CMS_ContentInfo *cms) { if (OBJ_obj2nid(cms->contentType) != NID_pkcs7_enveloped) { diff --git a/deps/openssl/openssl/crypto/cms/cms_err.c b/deps/openssl/openssl/crypto/cms/cms_err.c index 4bd6a0dc1bf..e67d783be29 100644 --- a/deps/openssl/openssl/crypto/cms/cms_err.c +++ b/deps/openssl/openssl/crypto/cms/cms_err.c @@ -1,6 +1,6 @@ /* * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2025 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 @@ -20,77 +20,79 @@ static const ERR_STRING_DATA CMS_str_reasons[] = { {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_ADD_SIGNER_ERROR), "add signer error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_ATTRIBUTE_ERROR), "attribute error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CERTIFICATE_ALREADY_PRESENT), - "certificate already present"}, + "certificate already present"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CERTIFICATE_HAS_NO_KEYID), - "certificate has no keyid"}, + "certificate has no keyid"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CERTIFICATE_VERIFY_ERROR), - "certificate verify error"}, + "certificate verify error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CIPHER_AEAD_SET_TAG_ERROR), - "cipher aead set tag error"}, + "cipher aead set tag error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CIPHER_GET_TAG), "cipher get tag"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CIPHER_INITIALISATION_ERROR), - "cipher initialisation error"}, + "cipher initialisation error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR), - "cipher parameter initialisation error"}, + "cipher parameter initialisation error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CMS_DATAFINAL_ERROR), - "cms datafinal error"}, + "cms datafinal error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CMS_LIB), "cms lib"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CONTENTIDENTIFIER_MISMATCH), - "contentidentifier mismatch"}, + "contentidentifier mismatch"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CONTENT_NOT_FOUND), "content not found"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CONTENT_TYPE_MISMATCH), - "content type mismatch"}, + "content type mismatch"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CONTENT_TYPE_NOT_COMPRESSED_DATA), - "content type not compressed data"}, + "content type not compressed data"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA), - "content type not enveloped data"}, + "content type not enveloped data"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CONTENT_TYPE_NOT_SIGNED_DATA), - "content type not signed data"}, + "content type not signed data"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CONTENT_VERIFY_ERROR), - "content verify error"}, + "content verify error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CTRL_ERROR), "ctrl error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CTRL_FAILURE), "ctrl failure"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_DECODE_ERROR), "decode error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_DECRYPT_ERROR), "decrypt error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_ERROR_GETTING_PUBLIC_KEY), - "error getting public key"}, + "error getting public key"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE), - "error reading messagedigest attribute"}, + "error reading messagedigest attribute"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_ERROR_SETTING_KEY), "error setting key"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_ERROR_SETTING_RECIPIENTINFO), - "error setting recipientinfo"}, + "error setting recipientinfo"}, + {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_ERROR_UNSUPPORTED_STATIC_KEY_AGREEMENT), + "error unsupported static key agreement"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_ESS_SIGNING_CERTID_MISMATCH_ERROR), - "ess signing certid mismatch error"}, + "ess signing certid mismatch error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_INVALID_ENCRYPTED_KEY_LENGTH), - "invalid encrypted key length"}, + "invalid encrypted key length"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER), - "invalid key encryption parameter"}, + "invalid key encryption parameter"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_INVALID_KEY_LENGTH), "invalid key length"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_INVALID_LABEL), "invalid label"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_INVALID_OAEP_PARAMETERS), - "invalid oaep parameters"}, + "invalid oaep parameters"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_KDF_PARAMETER_ERROR), - "kdf parameter error"}, + "kdf parameter error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_MD_BIO_INIT_ERROR), "md bio init error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_MESSAGEDIGEST_ATTRIBUTE_WRONG_LENGTH), - "messagedigest attribute wrong length"}, + "messagedigest attribute wrong length"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_MESSAGEDIGEST_WRONG_LENGTH), - "messagedigest wrong length"}, + "messagedigest wrong length"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_MSGSIGDIGEST_ERROR), "msgsigdigest error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE), - "msgsigdigest verification failure"}, + "msgsigdigest verification failure"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_MSGSIGDIGEST_WRONG_LENGTH), - "msgsigdigest wrong length"}, + "msgsigdigest wrong length"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NEED_ONE_SIGNER), "need one signer"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NOT_A_SIGNED_RECEIPT), - "not a signed receipt"}, + "not a signed receipt"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NOT_ENCRYPTED_DATA), "not encrypted data"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NOT_KEK), "not kek"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NOT_KEY_AGREEMENT), "not key agreement"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NOT_KEY_TRANSPORT), "not key transport"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NOT_PWRI), "not pwri"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE), - "not supported for this key type"}, + "not supported for this key type"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_CIPHER), "no cipher"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_CONTENT), "no content"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_CONTENT_TYPE), "no content type"}, @@ -100,9 +102,9 @@ static const ERR_STRING_DATA CMS_str_reasons[] = { {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_KEY_OR_CERT), "no key or cert"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_MATCHING_DIGEST), "no matching digest"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_MATCHING_RECIPIENT), - "no matching recipient"}, + "no matching recipient"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_MATCHING_SIGNATURE), - "no matching signature"}, + "no matching signature"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_MSGSIGDIGEST), "no msgsigdigest"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_PASSWORD), "no password"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_PRIVATE_KEY), "no private key"}, @@ -111,56 +113,56 @@ static const ERR_STRING_DATA CMS_str_reasons[] = { {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_SIGNERS), "no signers"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_PEER_KEY_ERROR), "peer key error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE), - "private key does not match certificate"}, + "private key does not match certificate"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_RECEIPT_DECODE_ERROR), - "receipt decode error"}, + "receipt decode error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_RECIPIENT_ERROR), "recipient error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_SHARED_INFO_ERROR), "shared info error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_SIGNER_CERTIFICATE_NOT_FOUND), - "signer certificate not found"}, + "signer certificate not found"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_SIGNFINAL_ERROR), "signfinal error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_SMIME_TEXT_ERROR), "smime text error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_STORE_INIT_ERROR), "store init error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_TYPE_NOT_COMPRESSED_DATA), - "type not compressed data"}, + "type not compressed data"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_TYPE_NOT_DATA), "type not data"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_TYPE_NOT_DIGESTED_DATA), - "type not digested data"}, + "type not digested data"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_TYPE_NOT_ENCRYPTED_DATA), - "type not encrypted data"}, + "type not encrypted data"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_TYPE_NOT_ENVELOPED_DATA), - "type not enveloped data"}, + "type not enveloped data"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNABLE_TO_FINALIZE_CONTEXT), - "unable to finalize context"}, + "unable to finalize context"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNKNOWN_CIPHER), "unknown cipher"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNKNOWN_DIGEST_ALGORITHM), - "unknown digest algorithm"}, + "unknown digest algorithm"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNKNOWN_ID), "unknown id"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM), - "unsupported compression algorithm"}, + "unsupported compression algorithm"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNSUPPORTED_CONTENT_ENCRYPTION_ALGORITHM), - "unsupported content encryption algorithm"}, + "unsupported content encryption algorithm"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNSUPPORTED_CONTENT_TYPE), - "unsupported content type"}, + "unsupported content type"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNSUPPORTED_ENCRYPTION_TYPE), - "unsupported encryption type"}, + "unsupported encryption type"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNSUPPORTED_KEK_ALGORITHM), - "unsupported kek algorithm"}, + "unsupported kek algorithm"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM), - "unsupported key encryption algorithm"}, + "unsupported key encryption algorithm"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNSUPPORTED_LABEL_SOURCE), - "unsupported label source"}, + "unsupported label source"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE), - "unsupported recipientinfo type"}, + "unsupported recipientinfo type"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNSUPPORTED_RECIPIENT_TYPE), - "unsupported recipient type"}, + "unsupported recipient type"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNSUPPORTED_SIGNATURE_ALGORITHM), - "unsupported signature algorithm"}, + "unsupported signature algorithm"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNSUPPORTED_TYPE), "unsupported type"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNWRAP_ERROR), "unwrap error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNWRAP_FAILURE), "unwrap failure"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_VERIFICATION_FAILURE), - "verification failure"}, + "verification failure"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_WRAP_ERROR), "wrap error"}, {0, NULL} }; diff --git a/deps/openssl/openssl/crypto/cms/cms_kari.c b/deps/openssl/openssl/crypto/cms/cms_kari.c index a2f422a78d8..8e9e6a5d148 100644 --- a/deps/openssl/openssl/crypto/cms/cms_kari.c +++ b/deps/openssl/openssl/crypto/cms/cms_kari.c @@ -1,5 +1,5 @@ /* - * Copyright 2013-2021 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2013-2025 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 @@ -502,6 +502,13 @@ int ossl_cms_RecipientInfo_kari_encrypt(const CMS_ContentInfo *cms, oik->d.originatorKey = M_ASN1_new_of(CMS_OriginatorPublicKey); if (!oik->d.originatorKey) return 0; + } else { + /* + * Currently it is not possible to get public key as it is not stored + * during kari initialization. + */ + ERR_raise(ERR_LIB_CMS, CMS_R_ERROR_UNSUPPORTED_STATIC_KEY_AGREEMENT); + return 0; } /* Initialise KDF algorithm */ if (!ossl_cms_env_asn1_ctrl(ri, 0)) diff --git a/deps/openssl/openssl/crypto/cms/cms_lib.c b/deps/openssl/openssl/crypto/cms/cms_lib.c index 8b135e95aac..67b35627ba5 100644 --- a/deps/openssl/openssl/crypto/cms/cms_lib.c +++ b/deps/openssl/openssl/crypto/cms/cms_lib.c @@ -22,6 +22,7 @@ static STACK_OF(CMS_CertificateChoices) **cms_get0_certificate_choices(CMS_ContentInfo *cms); +IMPLEMENT_ASN1_ALLOC_FUNCTIONS(CMS_ContentInfo) IMPLEMENT_ASN1_PRINT_FUNCTION(CMS_ContentInfo) CMS_ContentInfo *d2i_CMS_ContentInfo(CMS_ContentInfo **a, @@ -68,20 +69,6 @@ CMS_ContentInfo *CMS_ContentInfo_new_ex(OSSL_LIB_CTX *libctx, const char *propq) return ci; } -CMS_ContentInfo *CMS_ContentInfo_new(void) -{ - return CMS_ContentInfo_new_ex(NULL, NULL); -} - -void CMS_ContentInfo_free(CMS_ContentInfo *cms) -{ - if (cms != NULL) { - ossl_cms_env_enc_content_free(cms); - OPENSSL_free(cms->ctx.propq); - ASN1_item_free((ASN1_VALUE *)cms, ASN1_ITEM_rptr(CMS_ContentInfo)); - } -} - const CMS_CTX *ossl_cms_get0_cmsctx(const CMS_ContentInfo *cms) { return cms != NULL ? &cms->ctx : NULL; diff --git a/deps/openssl/openssl/crypto/cms/cms_local.h b/deps/openssl/openssl/crypto/cms/cms_local.h index 253f6819e43..1e0e0910d1d 100644 --- a/deps/openssl/openssl/crypto/cms/cms_local.h +++ b/deps/openssl/openssl/crypto/cms/cms_local.h @@ -368,6 +368,7 @@ struct CMS_Receipt_st { DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo) DECLARE_ASN1_ITEM(CMS_SignerInfo) +DECLARE_ASN1_ITEM(CMS_EncryptedContentInfo) DECLARE_ASN1_ITEM(CMS_IssuerAndSerialNumber) DECLARE_ASN1_ITEM(CMS_Attributes_Sign) DECLARE_ASN1_ITEM(CMS_Attributes_Verify) @@ -444,7 +445,6 @@ BIO *ossl_cms_EnvelopedData_init_bio(CMS_ContentInfo *cms); int ossl_cms_EnvelopedData_final(CMS_ContentInfo *cms, BIO *chain); BIO *ossl_cms_AuthEnvelopedData_init_bio(CMS_ContentInfo *cms); int ossl_cms_AuthEnvelopedData_final(CMS_ContentInfo *cms, BIO *cmsbio); -void ossl_cms_env_enc_content_free(const CMS_ContentInfo *cinf); CMS_EnvelopedData *ossl_cms_get0_enveloped(CMS_ContentInfo *cms); CMS_AuthEnvelopedData *ossl_cms_get0_auth_enveloped(CMS_ContentInfo *cms); CMS_EncryptedContentInfo *ossl_cms_get0_env_enc_content(const CMS_ContentInfo *cms); diff --git a/deps/openssl/openssl/crypto/cms/cms_rsa.c b/deps/openssl/openssl/crypto/cms/cms_rsa.c index 12bc8184389..5e26e89d501 100644 --- a/deps/openssl/openssl/crypto/cms/cms_rsa.c +++ b/deps/openssl/openssl/crypto/cms/cms_rsa.c @@ -223,7 +223,10 @@ static int rsa_cms_sign(CMS_SignerInfo *si) os = ossl_rsa_ctx_to_pss_string(pkctx); if (os == NULL) return 0; - return X509_ALGOR_set0(alg, OBJ_nid2obj(EVP_PKEY_RSA_PSS), V_ASN1_SEQUENCE, os); + if (X509_ALGOR_set0(alg, OBJ_nid2obj(EVP_PKEY_RSA_PSS), V_ASN1_SEQUENCE, os)) + return 1; + ASN1_STRING_free(os); + return 0; } params[0] = OSSL_PARAM_construct_octet_string( diff --git a/deps/openssl/openssl/crypto/cms/cms_sd.c b/deps/openssl/openssl/crypto/cms/cms_sd.c index 3a21664e9da..4758d048386 100644 --- a/deps/openssl/openssl/crypto/cms/cms_sd.c +++ b/deps/openssl/openssl/crypto/cms/cms_sd.c @@ -482,8 +482,12 @@ CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms, ossl_cms_ctx_get0_libctx(ctx), ossl_cms_ctx_get0_propq(ctx), pk, NULL) <= 0) { + si->pctx = NULL; goto err; } + else { + EVP_MD_CTX_set_flags(si->mctx, EVP_MD_CTX_FLAG_KEEP_PKEY_CTX); + } } if (!sd->signerInfos) @@ -725,6 +729,7 @@ static int cms_SignerInfo_content_sign(CMS_ContentInfo *cms, unsigned int mdlen; pctx = si->pctx; + si->pctx = NULL; if (!EVP_DigestFinal_ex(mctx, md, &mdlen)) goto err; siglen = EVP_PKEY_get_size(si->pkey); @@ -813,6 +818,7 @@ int CMS_SignerInfo_sign(CMS_SignerInfo *si) ossl_cms_ctx_get0_propq(ctx), si->pkey, NULL) <= 0) goto err; + EVP_MD_CTX_set_flags(mctx, EVP_MD_CTX_FLAG_KEEP_PKEY_CTX); si->pctx = pctx; } @@ -884,9 +890,16 @@ int CMS_SignerInfo_verify(CMS_SignerInfo *si) goto err; } mctx = si->mctx; + if (si->pctx != NULL) { + EVP_PKEY_CTX_free(si->pctx); + si->pctx = NULL; + } if (EVP_DigestVerifyInit_ex(mctx, &si->pctx, EVP_MD_get0_name(md), libctx, - propq, si->pkey, NULL) <= 0) + propq, si->pkey, NULL) <= 0) { + si->pctx = NULL; goto err; + } + EVP_MD_CTX_set_flags(mctx, EVP_MD_CTX_FLAG_KEEP_PKEY_CTX); if (!cms_sd_asn1_ctrl(si, 1)) goto err; @@ -1003,8 +1016,11 @@ int CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain) if (EVP_PKEY_CTX_set_signature_md(pkctx, md) <= 0) goto err; si->pctx = pkctx; - if (!cms_sd_asn1_ctrl(si, 1)) + if (!cms_sd_asn1_ctrl(si, 1)) { + si->pctx = NULL; goto err; + } + si->pctx = NULL; r = EVP_PKEY_verify(pkctx, si->signature->data, si->signature->length, mval, mlen); if (r <= 0) { diff --git a/deps/openssl/openssl/crypto/cms/cms_smime.c b/deps/openssl/openssl/crypto/cms/cms_smime.c index d7719267c8c..65da2452fce 100644 --- a/deps/openssl/openssl/crypto/cms/cms_smime.c +++ b/deps/openssl/openssl/crypto/cms/cms_smime.c @@ -236,7 +236,7 @@ CMS_ContentInfo *CMS_EncryptedData_encrypt_ex(BIO *in, const EVP_CIPHER *cipher, if (cms == NULL) return NULL; if (!CMS_EncryptedData_set1_key(cms, cipher, key, keylen)) - return NULL; + goto err; if (!(flags & CMS_DETACHED)) CMS_set_detached(cms, 0); @@ -245,6 +245,7 @@ CMS_ContentInfo *CMS_EncryptedData_encrypt_ex(BIO *in, const EVP_CIPHER *cipher, || CMS_final(cms, in, NULL, flags)) return cms; + err: CMS_ContentInfo_free(cms); return NULL; } diff --git a/deps/openssl/openssl/crypto/core_fetch.c b/deps/openssl/openssl/crypto/core_fetch.c index 38db36ee1f7..c063515fc04 100644 --- a/deps/openssl/openssl/crypto/core_fetch.c +++ b/deps/openssl/openssl/crypto/core_fetch.c @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2019-2025 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 @@ -120,7 +120,8 @@ static void ossl_method_construct_this(OSSL_PROVIDER *provider, * It is *expected* that the put function increments the refcnt * of the passed method. */ - data->mcm->put(data->store, method, provider, algo->algorithm_names, + data->mcm->put(no_store ? data->store : NULL, + method, provider, algo->algorithm_names, algo->property_definition, data->mcm_data); /* refcnt-- because we're dropping the reference */ diff --git a/deps/openssl/openssl/crypto/dso/dso_dl.c b/deps/openssl/openssl/crypto/dso/dso_dl.c index f4e6e5f4573..05b63cf1d9c 100644 --- a/deps/openssl/openssl/crypto/dso/dso_dl.c +++ b/deps/openssl/openssl/crypto/dso/dso_dl.c @@ -235,13 +235,12 @@ static char *dl_name_converter(DSO *dso, const char *filename) ERR_raise(ERR_LIB_DSO, DSO_R_NAME_TRANSLATION_FAILED); return NULL; } - if (transform) { - if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0) - sprintf(translated, "lib%s%s", filename, DSO_EXTENSION); - else - sprintf(translated, "%s%s", filename, DSO_EXTENSION); - } else - sprintf(translated, "%s", filename); + if (transform) + BIO_snprintf(translated, rsize, + (DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0 + ? "lib%s%s" : "%s%s", filename, DSO_EXTENSION); + else + BIO_snprintf(translated, rsize, "%s", filename); return translated; } diff --git a/deps/openssl/openssl/crypto/dso/dso_dlfcn.c b/deps/openssl/openssl/crypto/dso/dso_dlfcn.c index 6a988cc7279..1107da5fe65 100644 --- a/deps/openssl/openssl/crypto/dso/dso_dlfcn.c +++ b/deps/openssl/openssl/crypto/dso/dso_dlfcn.c @@ -271,11 +271,12 @@ static char *dlfcn_name_converter(DSO *dso, const char *filename) } if (transform) { if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0) - sprintf(translated, "lib%s" DSO_EXTENSION, filename); + BIO_snprintf(translated, rsize, "lib%s" DSO_EXTENSION, filename); else - sprintf(translated, "%s" DSO_EXTENSION, filename); - } else - sprintf(translated, "%s", filename); + BIO_snprintf(translated, rsize, "%s" DSO_EXTENSION, filename); + } else { + BIO_snprintf(translated, rsize, "%s", filename); + } return translated; } diff --git a/deps/openssl/openssl/crypto/dso/dso_win32.c b/deps/openssl/openssl/crypto/dso/dso_win32.c index 4d3059d4387..91a1a9d9aeb 100644 --- a/deps/openssl/openssl/crypto/dso/dso_win32.c +++ b/deps/openssl/openssl/crypto/dso/dso_win32.c @@ -454,24 +454,20 @@ static char *win32_name_converter(DSO *dso, const char *filename) char *translated; int len, transform; - len = strlen(filename); transform = ((strstr(filename, "/") == NULL) && (strstr(filename, "\\") == NULL) && (strstr(filename, ":") == NULL)); + /* If transform != 0, then we convert to %s.dll, else just dupe filename */ + + len = strlen(filename) + 1; if (transform) - /* We will convert this to "%s.dll" */ - translated = OPENSSL_malloc(len + 5); - else - /* We will simply duplicate filename */ - translated = OPENSSL_malloc(len + 1); + len += strlen(".dll"); + translated = OPENSSL_malloc(len); if (translated == NULL) { ERR_raise(ERR_LIB_DSO, DSO_R_NAME_TRANSLATION_FAILED); return NULL; } - if (transform) - sprintf(translated, "%s.dll", filename); - else - sprintf(translated, "%s", filename); + BIO_snprintf(translated, len, "%s%s", filename, transform ? ".dll" : ""); return translated; } diff --git a/deps/openssl/openssl/crypto/ec/ec_asn1.c b/deps/openssl/openssl/crypto/ec/ec_asn1.c index 7a0b35a5943..c018f392894 100644 --- a/deps/openssl/openssl/crypto/ec/ec_asn1.c +++ b/deps/openssl/openssl/crypto/ec/ec_asn1.c @@ -1161,7 +1161,7 @@ int i2o_ECPublicKey(const EC_KEY *a, unsigned char **out) size_t buf_len = 0; int new_buffer = 0; - if (a == NULL) { + if (a == NULL || a->pub_key == NULL) { ERR_raise(ERR_LIB_EC, ERR_R_PASSED_NULL_PARAMETER); return 0; } diff --git a/deps/openssl/openssl/crypto/ec/ec_backend.c b/deps/openssl/openssl/crypto/ec/ec_backend.c index 98e2c418e41..cad576fc48a 100644 --- a/deps/openssl/openssl/crypto/ec/ec_backend.c +++ b/deps/openssl/openssl/crypto/ec/ec_backend.c @@ -616,14 +616,8 @@ EC_KEY *ossl_ec_key_dup(const EC_KEY *src, int selection) || !EC_GROUP_copy(ret->group, src->group)) goto err; - if (src->meth != NULL) { -#if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE) - if (src->engine != NULL && ENGINE_init(src->engine) == 0) - goto err; - ret->engine = src->engine; -#endif + if (src->meth != NULL) ret->meth = src->meth; - } } /* copy the public key */ diff --git a/deps/openssl/openssl/crypto/ec/ec_lib.c b/deps/openssl/openssl/crypto/ec/ec_lib.c index b1696d93bd6..a082876fb47 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-2022 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2001-2025 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the Apache License 2.0 (the "License"). You may not use @@ -20,6 +20,7 @@ #include #include #include "crypto/ec.h" +#include "crypto/bn.h" #include "internal/nelem.h" #include "ec_local.h" @@ -1262,10 +1263,10 @@ static int ec_field_inverse_mod_ord(const EC_GROUP *group, BIGNUM *r, if (!BN_sub(e, group->order, e)) goto err; /*- - * Exponent e is public. - * No need for scatter-gather or BN_FLG_CONSTTIME. + * Although the exponent is public we want the result to be + * fixed top. */ - if (!BN_mod_exp_mont(r, x, e, group->order, ctx, group->mont_data)) + if (!bn_mod_exp_mont_fixed_top(r, x, e, group->order, ctx, group->mont_data)) goto err; ret = 1; diff --git a/deps/openssl/openssl/crypto/ec/ec_oct.c b/deps/openssl/openssl/crypto/ec/ec_oct.c index 790a0b29077..2b77e973888 100644 --- a/deps/openssl/openssl/crypto/ec/ec_oct.c +++ b/deps/openssl/openssl/crypto/ec/ec_oct.c @@ -74,6 +74,10 @@ size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form, unsigned char *buf, size_t len, BN_CTX *ctx) { + if (point == NULL) { + ERR_raise(ERR_LIB_EC, ERR_R_PASSED_NULL_PARAMETER); + return 0; + } if (group->meth->point2oct == 0 && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) { ERR_raise(ERR_LIB_EC, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); diff --git a/deps/openssl/openssl/crypto/encode_decode/encoder_pkey.c b/deps/openssl/openssl/crypto/encode_decode/encoder_pkey.c index 3a24317cf4d..39266a95309 100644 --- a/deps/openssl/openssl/crypto/encode_decode/encoder_pkey.c +++ b/deps/openssl/openssl/crypto/encode_decode/encoder_pkey.c @@ -186,9 +186,13 @@ encoder_construct_pkey(OSSL_ENCODER_INSTANCE *encoder_inst, void *arg) const OSSL_PROVIDER *e_prov = OSSL_ENCODER_get0_provider(encoder); if (k_prov != e_prov) { + int selection = data->selection; + + if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) + selection |= OSSL_KEYMGMT_SELECT_PUBLIC_KEY; data->encoder_inst = encoder_inst; - if (!evp_keymgmt_export(pk->keymgmt, pk->keydata, data->selection, + if (!evp_keymgmt_export(pk->keymgmt, pk->keydata, selection, &encoder_import_cb, data)) return NULL; data->obj = data->constructed_obj; diff --git a/deps/openssl/openssl/crypto/err/openssl.txt b/deps/openssl/openssl/crypto/err/openssl.txt index 003e2981095..756fafdfa24 100644 --- a/deps/openssl/openssl/crypto/err/openssl.txt +++ b/deps/openssl/openssl/crypto/err/openssl.txt @@ -1,4 +1,4 @@ -# Copyright 1999-2023 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 1999-2025 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 @@ -307,6 +307,8 @@ CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE:114:\ error reading messagedigest attribute CMS_R_ERROR_SETTING_KEY:115:error setting key CMS_R_ERROR_SETTING_RECIPIENTINFO:116:error setting recipientinfo +CMS_R_ERROR_UNSUPPORTED_STATIC_KEY_AGREEMENT:196:\ + error unsupported static key agreement CMS_R_ESS_SIGNING_CERTID_MISMATCH_ERROR:183:ess signing certid mismatch error CMS_R_INVALID_ENCRYPTED_KEY_LENGTH:117:invalid encrypted key length CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER:176:invalid key encryption parameter @@ -1388,8 +1390,6 @@ SSL_R_MISSING_ECDSA_SIGNING_CERT:381:missing ecdsa signing cert SSL_R_MISSING_FATAL:256:missing fatal SSL_R_MISSING_PARAMETERS:290:missing parameters SSL_R_MISSING_PSK_KEX_MODES_EXTENSION:310:missing psk kex modes extension -SSL_R_MISSING_QUIC_TRANSPORT_PARAMETERS_EXTENSION:801:\ - missing quic transport parameters extension SSL_R_MISSING_RSA_CERTIFICATE:168:missing rsa certificate SSL_R_MISSING_RSA_ENCRYPTING_CERT:169:missing rsa encrypting cert SSL_R_MISSING_RSA_SIGNING_CERT:170:missing rsa signing cert @@ -1540,7 +1540,6 @@ SSL_R_VERSION_TOO_LOW:396:version too low SSL_R_WRONG_CERTIFICATE_TYPE:383:wrong certificate type SSL_R_WRONG_CIPHER_RETURNED:261:wrong cipher returned SSL_R_WRONG_CURVE:378:wrong curve -SSL_R_WRONG_ENCRYPTION_LEVEL_RECEIVED:800:wrong encryption level received SSL_R_WRONG_SIGNATURE_LENGTH:264:wrong signature length SSL_R_WRONG_SIGNATURE_SIZE:265:wrong signature size SSL_R_WRONG_SIGNATURE_TYPE:370:wrong signature type diff --git a/deps/openssl/openssl/crypto/evp/ctrl_params_translate.c b/deps/openssl/openssl/crypto/evp/ctrl_params_translate.c index de6c215e205..44d0895bcf1 100644 --- a/deps/openssl/openssl/crypto/evp/ctrl_params_translate.c +++ b/deps/openssl/openssl/crypto/evp/ctrl_params_translate.c @@ -1210,6 +1210,8 @@ static int fix_ecdh_cofactor(enum state state, /* The initial value for |ctx->action_type| must not be zero. */ if (!ossl_assert(ctx->action_type != NONE)) return 0; + } else if (state == POST_PARAMS_TO_CTRL && ctx->action_type == NONE) { + ctx->action_type = GET; } if ((ret = default_check(state, translation, ctx)) <= 0) @@ -1235,6 +1237,8 @@ static int fix_ecdh_cofactor(enum state state, } } else if (state == PRE_PARAMS_TO_CTRL && ctx->action_type == GET) { ctx->p1 = -2; + } else if (state == POST_PARAMS_TO_CTRL && ctx->action_type == GET) { + ctx->p1 = ret; } return ret; @@ -2800,8 +2804,14 @@ static int evp_pkey_ctx_setget_params_to_ctrl(EVP_PKEY_CTX *pctx, /* * In POST, we pass the return value as p1, allowing the fixup_args * function to put it to good use, or maybe affect it. + * + * NOTE: even though EVP_PKEY_CTX_ctrl return value is documented + * as return positive on Success and 0 or negative on falure. There + * maybe parameters (e.g. ecdh_cofactor), which actually return 0 + * as success value. That is why we do POST_PARAMS_TO_CTRL for 0 + * value as well */ - if (ret > 0) { + if (ret >= 0) { ctx.p1 = ret; fixup(POST_PARAMS_TO_CTRL, translation, &ctx); ret = ctx.p1; diff --git a/deps/openssl/openssl/crypto/evp/m_sigver.c b/deps/openssl/openssl/crypto/evp/m_sigver.c index 76a6814b424..efd2c05c85c 100644 --- a/deps/openssl/openssl/crypto/evp/m_sigver.c +++ b/deps/openssl/openssl/crypto/evp/m_sigver.c @@ -662,8 +662,12 @@ int EVP_DigestVerify(EVP_MD_CTX *ctx, const unsigned char *sigret, { EVP_PKEY_CTX *pctx = ctx->pctx; - if (pctx != NULL - && pctx->operation == EVP_PKEY_OP_VERIFYCTX + if (pctx == NULL) { + ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR); + return -1; + } + + if (pctx->operation == EVP_PKEY_OP_VERIFYCTX && pctx->op.sig.algctx != NULL && pctx->op.sig.signature != NULL) { if (pctx->op.sig.signature->digest_verify != NULL) @@ -672,8 +676,8 @@ int EVP_DigestVerify(EVP_MD_CTX *ctx, const unsigned char *sigret, tbs, tbslen); } else { /* legacy */ - if (ctx->pctx->pmeth != NULL && ctx->pctx->pmeth->digestverify != NULL) - return ctx->pctx->pmeth->digestverify(ctx, sigret, siglen, tbs, tbslen); + if (pctx->pmeth != NULL && pctx->pmeth->digestverify != NULL) + return pctx->pmeth->digestverify(ctx, sigret, siglen, tbs, tbslen); } if (EVP_DigestVerifyUpdate(ctx, tbs, tbslen) <= 0) diff --git a/deps/openssl/openssl/crypto/http/http_client.c b/deps/openssl/openssl/crypto/http/http_client.c index 4b96a6b9e9e..c86db4405b8 100644 --- a/deps/openssl/openssl/crypto/http/http_client.c +++ b/deps/openssl/openssl/crypto/http/http_client.c @@ -851,6 +851,20 @@ int OSSL_HTTP_REQ_CTX_nbio_d2i(OSSL_HTTP_REQ_CTX *rctx, #ifndef OPENSSL_NO_SOCK +static const char *explict_or_default_port(const char *hostserv, const char *port, int use_ssl) +{ + if (port == NULL) { + char *service = NULL; + + if (!BIO_parse_hostserv(hostserv, NULL, &service, BIO_PARSE_PRIO_HOST)) + return NULL; + if (service == NULL) /* implicit port */ + port = use_ssl ? OSSL_HTTPS_PORT : OSSL_HTTP_PORT; + OPENSSL_free(service); + } /* otherwise take the explicitly given port */ + return port; +} + /* set up a new connection BIO, to HTTP server or to HTTP(S) proxy if given */ static BIO *http_new_bio(const char *server /* optionally includes ":port" */, const char *server_port /* explicit server port */, @@ -870,8 +884,7 @@ static BIO *http_new_bio(const char *server /* optionally includes ":port" */, port = proxy_port; } - if (port == NULL && strchr(host, ':') == NULL) - port = use_ssl ? OSSL_HTTPS_PORT : OSSL_HTTP_PORT; + port = explict_or_default_port(host, port, use_ssl); cbio = BIO_new_connect(host /* optionally includes ":port" */); if (cbio == NULL) @@ -958,8 +971,6 @@ OSSL_HTTP_REQ_CTX *OSSL_HTTP_open(const char *server, const char *port, } if (port != NULL && *port == '\0') port = NULL; - if (port == NULL && strchr(server, ':') == NULL) - port = use_ssl ? OSSL_HTTPS_PORT : OSSL_HTTP_PORT; proxy = OSSL_HTTP_adapt_proxy(proxy, no_proxy, server, use_ssl); if (proxy != NULL && !OSSL_HTTP_parse_url(proxy, NULL /* use_ssl */, NULL /* user */, diff --git a/deps/openssl/openssl/crypto/http/http_lib.c b/deps/openssl/openssl/crypto/http/http_lib.c index 30c1cd04fc0..9c41f57541d 100644 --- a/deps/openssl/openssl/crypto/http/http_lib.c +++ b/deps/openssl/openssl/crypto/http/http_lib.c @@ -1,5 +1,5 @@ /* - * Copyright 2001-2023 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2001-2025 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 @@ -9,11 +9,18 @@ #include /* for sscanf() */ #include +#ifndef OPENSSL_NO_SOCK +# include "../bio/bio_local.h" /* for NI_MAXHOST */ +#endif #include #include #include /* for BIO_snprintf() */ #include #include "internal/cryptlib.h" /* for ossl_assert() */ +#ifndef NI_MAXHOST +# define NI_MAXHOST 255 +#endif +#include "crypto/ctype.h" /* for ossl_isspace() */ static void init_pstring(char **pstr) { @@ -251,10 +258,17 @@ static int use_proxy(const char *no_proxy, const char *server) { size_t sl; const char *found = NULL; + char host[NI_MAXHOST]; if (!ossl_assert(server != NULL)) return 0; sl = strlen(server); + if (sl >= 2 && sl < sizeof(host) + 2 && server[0] == '[' && server[sl - 1] == ']') { + /* strip leading '[' and trailing ']' from escaped IPv6 address */ + sl -= 2; + strncpy(host, server + 1, sl); + server = host; + } /* * using environment variable names, both lowercase and uppercase variants, @@ -268,8 +282,8 @@ static int use_proxy(const char *no_proxy, const char *server) if (no_proxy != NULL) found = strstr(no_proxy, server); while (found != NULL - && ((found != no_proxy && found[-1] != ' ' && found[-1] != ',') - || (found[sl] != '\0' && found[sl] != ' ' && found[sl] != ','))) + && ((found != no_proxy && !ossl_isspace(found[-1]) && found[-1] != ',') + || (found[sl] != '\0' && !ossl_isspace(found[sl]) && found[sl] != ','))) found = strstr(found + 1, server); return found == NULL; } @@ -285,7 +299,7 @@ const char *OSSL_HTTP_adapt_proxy(const char *proxy, const char *no_proxy, if (proxy == NULL) proxy = ossl_safe_getenv(use_ssl ? "https_proxy" : "http_proxy"); if (proxy == NULL) - proxy = ossl_safe_getenv(use_ssl ? OPENSSL_HTTP_PROXY : OPENSSL_HTTPS_PROXY); + proxy = ossl_safe_getenv(use_ssl ? OPENSSL_HTTPS_PROXY : OPENSSL_HTTP_PROXY); if (proxy == NULL || *proxy == '\0' || !use_proxy(no_proxy, server)) return NULL; diff --git a/deps/openssl/openssl/crypto/info.c b/deps/openssl/openssl/crypto/info.c index f5fa92e1580..a0dc2e80136 100644 --- a/deps/openssl/openssl/crypto/info.c +++ b/deps/openssl/openssl/crypto/info.c @@ -14,7 +14,6 @@ #include "internal/cryptlib.h" #include "e_os.h" #include "buildinf.h" -#include #if defined(__arm__) || defined(__arm) || defined(__aarch64__) # include "arm_arch.h" @@ -200,10 +199,6 @@ const char *OPENSSL_info(int t) if (ossl_cpu_info_str[0] != '\0') return ossl_cpu_info_str + strlen(CPUINFO_PREFIX); break; -#ifndef OPENSSL_NO_QUIC - case OPENSSL_INFO_QUIC: - return "QUIC"; -#endif default: break; } diff --git a/deps/openssl/openssl/crypto/pem/pem_pk8.c b/deps/openssl/openssl/crypto/pem/pem_pk8.c index 1592e351ede..6e84f0afd05 100644 --- a/deps/openssl/openssl/crypto/pem/pem_pk8.c +++ b/deps/openssl/openssl/crypto/pem/pem_pk8.c @@ -173,7 +173,7 @@ EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, X509_SIG *p8 = NULL; int klen; EVP_PKEY *ret; - char psbuf[PEM_BUFSIZE]; + char psbuf[PEM_BUFSIZE + 1]; /* reserve one byte at the end */ p8 = d2i_PKCS8_bio(bp, NULL); if (p8 == NULL) @@ -182,7 +182,7 @@ EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, klen = cb(psbuf, PEM_BUFSIZE, 0, u); else klen = PEM_def_callback(psbuf, PEM_BUFSIZE, 0, u); - if (klen < 0) { + if (klen < 0 || klen > PEM_BUFSIZE) { ERR_raise(ERR_LIB_PEM, PEM_R_BAD_PASSWORD_READ); X509_SIG_free(p8); return NULL; diff --git a/deps/openssl/openssl/crypto/pkcs12/p12_crt.c b/deps/openssl/openssl/crypto/pkcs12/p12_crt.c index 1a48e5c611d..3c7d5ff97c5 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-2024 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-2025 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 @@ -210,8 +210,10 @@ PKCS12_SAFEBAG *PKCS12_add_key_ex(STACK_OF(PKCS12_SAFEBAG) **pbags, /* Make a PKCS#8 structure */ if ((p8 = EVP_PKEY2PKCS8(key)) == NULL) goto err; - if (key_usage && !PKCS8_add_keyusage(p8, key_usage)) + if (key_usage && !PKCS8_add_keyusage(p8, key_usage)) { + PKCS8_PRIV_KEY_INFO_free(p8); goto err; + } if (nid_key != -1) { /* This call does not take ownership of p8 */ bag = PKCS12_SAFEBAG_create_pkcs8_encrypt_ex(nid_key, pass, -1, NULL, 0, diff --git a/deps/openssl/openssl/crypto/pkcs7/pk7_doit.c b/deps/openssl/openssl/crypto/pkcs7/pk7_doit.c index d7791e5c4f4..e9de097da18 100644 --- a/deps/openssl/openssl/crypto/pkcs7/pk7_doit.c +++ b/deps/openssl/openssl/crypto/pkcs7/pk7_doit.c @@ -1023,6 +1023,7 @@ int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si, STACK_OF(X509_ATTRIBUTE) *sk; BIO *btmp; EVP_PKEY *pkey; + unsigned char *abuf = NULL; const PKCS7_CTX *ctx = ossl_pkcs7_get0_ctx(p7); OSSL_LIB_CTX *libctx = ossl_pkcs7_ctx_get0_libctx(ctx); const char *propq = ossl_pkcs7_ctx_get0_propq(ctx); @@ -1072,7 +1073,7 @@ int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si, sk = si->auth_attr; if ((sk != NULL) && (sk_X509_ATTRIBUTE_num(sk) != 0)) { - unsigned char md_dat[EVP_MAX_MD_SIZE], *abuf = NULL; + unsigned char md_dat[EVP_MAX_MD_SIZE]; unsigned int md_len; int alen; ASN1_OCTET_STRING *message_digest; @@ -1114,8 +1115,6 @@ int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si, } if (!EVP_VerifyUpdate(mdc_tmp, abuf, alen)) goto err; - - OPENSSL_free(abuf); } os = si->enc_digest; @@ -1133,6 +1132,7 @@ int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si, } ret = 1; err: + OPENSSL_free(abuf); EVP_MD_CTX_free(mdc_tmp); EVP_MD_free(fetched_md); return ret; diff --git a/deps/openssl/openssl/crypto/pkcs7/pk7_lib.c b/deps/openssl/openssl/crypto/pkcs7/pk7_lib.c index 5ce591f758f..bdd62052696 100644 --- a/deps/openssl/openssl/crypto/pkcs7/pk7_lib.c +++ b/deps/openssl/openssl/crypto/pkcs7/pk7_lib.c @@ -28,6 +28,11 @@ long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg) /* NOTE(emilia): does not support detached digested data. */ case PKCS7_OP_SET_DETACHED_SIGNATURE: if (nid == NID_pkcs7_signed) { + if (p7->d.sign == NULL) { + ERR_raise(ERR_LIB_PKCS7, PKCS7_R_NO_CONTENT); + ret = 0; + break; + } ret = p7->detached = (int)larg; if (ret && PKCS7_type_is_data(p7->d.sign->contents)) { ASN1_OCTET_STRING *os; diff --git a/deps/openssl/openssl/crypto/sm2/sm2_sign.c b/deps/openssl/openssl/crypto/sm2/sm2_sign.c index 71ccfcfc4c3..2097cd2fca8 100644 --- a/deps/openssl/openssl/crypto/sm2/sm2_sign.c +++ b/deps/openssl/openssl/crypto/sm2/sm2_sign.c @@ -331,12 +331,10 @@ static int sm2_sig_verify(const EC_KEY *key, const ECDSA_SIG *sig, OSSL_LIB_CTX *libctx = ossl_ec_key_get_libctx(key); ctx = BN_CTX_new_ex(libctx); - pt = EC_POINT_new(group); - if (ctx == NULL || pt == NULL) { + if (ctx == NULL) { ERR_raise(ERR_LIB_SM2, ERR_R_MALLOC_FAILURE); goto done; } - BN_CTX_start(ctx); t = BN_CTX_get(ctx); x1 = BN_CTX_get(ctx); @@ -345,6 +343,12 @@ static int sm2_sig_verify(const EC_KEY *key, const ECDSA_SIG *sig, goto done; } + pt = EC_POINT_new(group); + if (pt == NULL) { + ERR_raise(ERR_LIB_SM2, ERR_R_MALLOC_FAILURE); + goto done; + } + /* * B1: verify whether r' in [1,n-1], verification failed if not * B2: verify whether s' in [1,n-1], verification failed if not diff --git a/deps/openssl/openssl/crypto/srp/srp_vfy.c b/deps/openssl/openssl/crypto/srp/srp_vfy.c index 96d511ffe63..4b842dfd912 100644 --- a/deps/openssl/openssl/crypto/srp/srp_vfy.c +++ b/deps/openssl/openssl/crypto/srp/srp_vfy.c @@ -216,6 +216,8 @@ int SRP_user_pwd_set1_ids(SRP_user_pwd *vinfo, const char *id, { OPENSSL_free(vinfo->id); OPENSSL_free(vinfo->info); + vinfo->id = NULL; + vinfo->info = NULL; if (id != NULL && NULL == (vinfo->id = OPENSSL_strdup(id))) return 0; return (info == NULL || NULL != (vinfo->info = OPENSSL_strdup(info))); diff --git a/deps/openssl/openssl/crypto/threads_win.c b/deps/openssl/openssl/crypto/threads_win.c index dbeda74d73a..43f36ee6a33 100644 --- a/deps/openssl/openssl/crypto/threads_win.c +++ b/deps/openssl/openssl/crypto/threads_win.c @@ -212,7 +212,8 @@ 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 = (int)InterlockedExchangeAdd((long volatile *)val, (long)amount) + amount; + *ret = (int)InterlockedExchangeAdd((LONG volatile *)val, (LONG)amount) + + amount; return 1; } diff --git a/deps/openssl/openssl/crypto/trace.c b/deps/openssl/openssl/crypto/trace.c index 3df9b5a51e9..90a6350beba 100644 --- a/deps/openssl/openssl/crypto/trace.c +++ b/deps/openssl/openssl/crypto/trace.c @@ -473,7 +473,7 @@ BIO *OSSL_trace_begin(int category) char *prefix = NULL; category = ossl_trace_get_category(category); - if (category < 0) + if (category < 0 || !OSSL_trace_enabled(category)) return NULL; channel = trace_channels[category].bio; diff --git a/deps/openssl/openssl/crypto/ui/ui_util.c b/deps/openssl/openssl/crypto/ui/ui_util.c index 59b00b225ad..554bf798565 100644 --- a/deps/openssl/openssl/crypto/ui/ui_util.c +++ b/deps/openssl/openssl/crypto/ui/ui_util.c @@ -105,14 +105,18 @@ static int ui_read(UI *ui, UI_STRING *uis) switch (UI_get_string_type(uis)) { case UIT_PROMPT: { - char result[PEM_BUFSIZE + 1]; + int len; + char result[PEM_BUFSIZE + 1]; /* reserve one byte at the end */ const struct pem_password_cb_data *data = UI_method_get_ex_data(UI_get_method(ui), ui_method_data_index); int maxsize = UI_get_result_maxsize(uis); - int len = data->cb(result, - maxsize > PEM_BUFSIZE ? PEM_BUFSIZE : maxsize, - data->rwflag, UI_get0_user_data(ui)); + if (maxsize > PEM_BUFSIZE) + maxsize = PEM_BUFSIZE; + len = data->cb(result, maxsize, data->rwflag, + UI_get0_user_data(ui)); + if (len > maxsize) + return -1; if (len >= 0) result[len] = '\0'; if (len < 0) diff --git a/deps/openssl/openssl/crypto/x509/v3_admis.c b/deps/openssl/openssl/crypto/x509/v3_admis.c index 3bce232ed2f..53259c29f56 100644 --- a/deps/openssl/openssl/crypto/x509/v3_admis.c +++ b/deps/openssl/openssl/crypto/x509/v3_admis.c @@ -67,11 +67,10 @@ const X509V3_EXT_METHOD ossl_v3_ext_admission = { NULL /* extension-specific data */ }; - static int i2r_NAMING_AUTHORITY(const struct v3_ext_method *method, void *in, BIO *bp, int ind) { - NAMING_AUTHORITY * namingAuthority = (NAMING_AUTHORITY*) in; + NAMING_AUTHORITY *namingAuthority = (NAMING_AUTHORITY *) in; if (namingAuthority == NULL) return 0; @@ -81,14 +80,14 @@ static int i2r_NAMING_AUTHORITY(const struct v3_ext_method *method, void *in, && namingAuthority->namingAuthorityUrl == NULL) return 0; - if (BIO_printf(bp, "%*snamingAuthority: ", ind, "") <= 0) + if (BIO_printf(bp, "%*snamingAuthority:\n", ind, "") <= 0) goto err; if (namingAuthority->namingAuthorityId != NULL) { char objbuf[128]; const char *ln = OBJ_nid2ln(OBJ_obj2nid(namingAuthority->namingAuthorityId)); - if (BIO_printf(bp, "%*s admissionAuthorityId: ", ind, "") <= 0) + if (BIO_printf(bp, "%*s namingAuthorityId: ", ind, "") <= 0) goto err; OBJ_obj2txt(objbuf, sizeof(objbuf), namingAuthority->namingAuthorityId, 1); @@ -130,9 +129,10 @@ static int i2r_ADMISSION_SYNTAX(const struct v3_ext_method *method, void *in, } for (i = 0; i < sk_ADMISSIONS_num(admission->contentsOfAdmissions); i++) { - ADMISSIONS* entry = sk_ADMISSIONS_value(admission->contentsOfAdmissions, i); + ADMISSIONS *entry = sk_ADMISSIONS_value(admission->contentsOfAdmissions, i); - if (BIO_printf(bp, "%*sEntry %0d:\n", ind, "", 1 + i) <= 0) goto err; + if (BIO_printf(bp, "%*sEntry %0d:\n", ind, "", 1 + i) <= 0) + goto err; if (entry->admissionAuthority != NULL) { if (BIO_printf(bp, "%*s admissionAuthority:\n", ind, "") <= 0 @@ -143,12 +143,12 @@ static int i2r_ADMISSION_SYNTAX(const struct v3_ext_method *method, void *in, } if (entry->namingAuthority != NULL) { - if (i2r_NAMING_AUTHORITY(method, entry->namingAuthority, bp, ind) <= 0) + if (i2r_NAMING_AUTHORITY(method, entry->namingAuthority, bp, ind + 2) <= 0) goto err; } for (j = 0; j < sk_PROFESSION_INFO_num(entry->professionInfos); j++) { - PROFESSION_INFO* pinfo = sk_PROFESSION_INFO_value(entry->professionInfos, j); + PROFESSION_INFO *pinfo = sk_PROFESSION_INFO_value(entry->professionInfos, j); if (BIO_printf(bp, "%*s Profession Info Entry %0d:\n", ind, "", 1 + j) <= 0) goto err; @@ -161,7 +161,7 @@ static int i2r_ADMISSION_SYNTAX(const struct v3_ext_method *method, void *in, } if (pinfo->namingAuthority != NULL) { - if (i2r_NAMING_AUTHORITY(method, pinfo->namingAuthority, bp, ind + 2) <= 0) + if (i2r_NAMING_AUTHORITY(method, pinfo->namingAuthority, bp, ind + 4) <= 0) goto err; } @@ -170,7 +170,7 @@ static int i2r_ADMISSION_SYNTAX(const struct v3_ext_method *method, void *in, if (BIO_printf(bp, "%*s Info Entries:\n", ind, "") <= 0) goto err; for (k = 0; k < sk_ASN1_STRING_num(pinfo->professionItems); k++) { - ASN1_STRING* val = sk_ASN1_STRING_value(pinfo->professionItems, k); + ASN1_STRING *val = sk_ASN1_STRING_value(pinfo->professionItems, k); if (BIO_printf(bp, "%*s ", ind, "") <= 0 || ASN1_STRING_print(bp, val) <= 0 @@ -183,7 +183,7 @@ static int i2r_ADMISSION_SYNTAX(const struct v3_ext_method *method, void *in, if (BIO_printf(bp, "%*s Profession OIDs:\n", ind, "") <= 0) goto err; for (k = 0; k < sk_ASN1_OBJECT_num(pinfo->professionOIDs); k++) { - ASN1_OBJECT* obj = sk_ASN1_OBJECT_value(pinfo->professionOIDs, k); + ASN1_OBJECT *obj = sk_ASN1_OBJECT_value(pinfo->professionOIDs, k); const char *ln = OBJ_nid2ln(OBJ_obj2nid(obj)); char objbuf[128]; @@ -207,31 +207,29 @@ const ASN1_OBJECT *NAMING_AUTHORITY_get0_authorityId(const NAMING_AUTHORITY *n) return n->namingAuthorityId; } -void NAMING_AUTHORITY_set0_authorityId(NAMING_AUTHORITY *n, ASN1_OBJECT* id) +void NAMING_AUTHORITY_set0_authorityId(NAMING_AUTHORITY *n, ASN1_OBJECT *id) { ASN1_OBJECT_free(n->namingAuthorityId); n->namingAuthorityId = id; } -const ASN1_IA5STRING *NAMING_AUTHORITY_get0_authorityURL( - const NAMING_AUTHORITY *n) +const ASN1_IA5STRING *NAMING_AUTHORITY_get0_authorityURL(const NAMING_AUTHORITY *n) { return n->namingAuthorityUrl; } -void NAMING_AUTHORITY_set0_authorityURL(NAMING_AUTHORITY *n, ASN1_IA5STRING* u) +void NAMING_AUTHORITY_set0_authorityURL(NAMING_AUTHORITY *n, ASN1_IA5STRING *u) { ASN1_IA5STRING_free(n->namingAuthorityUrl); n->namingAuthorityUrl = u; } -const ASN1_STRING *NAMING_AUTHORITY_get0_authorityText( - const NAMING_AUTHORITY *n) +const ASN1_STRING *NAMING_AUTHORITY_get0_authorityText(const NAMING_AUTHORITY *n) { return n->namingAuthorityText; } -void NAMING_AUTHORITY_set0_authorityText(NAMING_AUTHORITY *n, ASN1_STRING* t) +void NAMING_AUTHORITY_set0_authorityText(NAMING_AUTHORITY *n, ASN1_STRING *t) { ASN1_IA5STRING_free(n->namingAuthorityText); n->namingAuthorityText = t; diff --git a/deps/openssl/openssl/crypto/x509/v3_san.c b/deps/openssl/openssl/crypto/x509/v3_san.c index 34ca16a6d72..d4999f1fc6c 100644 --- a/deps/openssl/openssl/crypto/x509/v3_san.c +++ b/deps/openssl/openssl/crypto/x509/v3_san.c @@ -336,7 +336,7 @@ static GENERAL_NAMES *v2i_issuer_alt(X509V3_EXT_METHOD *method, static int copy_issuer(X509V3_CTX *ctx, GENERAL_NAMES *gens) { - GENERAL_NAMES *ialt; + GENERAL_NAMES *ialt = NULL; GENERAL_NAME *gen; X509_EXTENSION *ext; int i, num; @@ -371,6 +371,7 @@ static int copy_issuer(X509V3_CTX *ctx, GENERAL_NAMES *gens) return 1; err: + sk_GENERAL_NAME_free(ialt); return 0; } diff --git a/deps/openssl/openssl/crypto/x509/x509_cmp.c b/deps/openssl/openssl/crypto/x509/x509_cmp.c index 989fb8faa9f..f2c3a568198 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-2023 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2025 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 @@ -196,6 +196,8 @@ int X509_add_cert(STACK_OF(X509) *sk, X509 *cert, int flags) ERR_raise(ERR_LIB_X509, ERR_R_PASSED_NULL_PARAMETER); return 0; } + if (cert == NULL) + return 0; if ((flags & X509_ADD_FLAG_NO_DUP) != 0) { /* * not using sk_X509_set_cmp_func() and sk_X509_find() diff --git a/deps/openssl/openssl/crypto/x509/x_all.c b/deps/openssl/openssl/crypto/x509/x_all.c index e58c9ab1c11..158e11a8649 100644 --- a/deps/openssl/openssl/crypto/x509/x_all.c +++ b/deps/openssl/openssl/crypto/x509/x_all.c @@ -92,11 +92,13 @@ int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx) static ASN1_VALUE *simple_get_asn1(const char *url, BIO *bio, BIO *rbio, int timeout, const ASN1_ITEM *it) { + size_t max_resp_len = (it == ASN1_ITEM_rptr(X509_CRL)) ? + OSSL_HTTP_DEFAULT_MAX_CRL_LEN : OSSL_HTTP_DEFAULT_MAX_RESP_LEN; BIO *mem = OSSL_HTTP_get(url, NULL /* proxy */, NULL /* no_proxy */, bio, rbio, NULL /* cb */, NULL /* arg */, 1024 /* buf_size */, NULL /* headers */, NULL /* expected_ct */, 1 /* expect_asn1 */, - OSSL_HTTP_DEFAULT_MAX_RESP_LEN, timeout); + max_resp_len, timeout); ASN1_VALUE *res = ASN1_item_d2i_bio(it, mem, NULL); BIO_free(mem); diff --git a/deps/openssl/openssl/demos/cipher/aesccm.c b/deps/openssl/openssl/demos/cipher/aesccm.c index 5a2d4281506..f4430e727b2 100644 --- a/deps/openssl/openssl/demos/cipher/aesccm.c +++ b/deps/openssl/openssl/demos/cipher/aesccm.c @@ -94,7 +94,7 @@ int aes_ccm_encrypt(void) if ((cipher = EVP_CIPHER_fetch(libctx, "AES-192-CCM", propq)) == NULL) goto err; - /* Set nonce length if default 96 bits is not appropriate */ + /* Default nonce length for AES-CCM is 7 bytes (56 bits). */ params[0] = OSSL_PARAM_construct_size_t(OSSL_CIPHER_PARAM_AEAD_IVLEN, &ccm_nonce_len); /* Set tag length */ diff --git a/deps/openssl/openssl/doc/build.info b/deps/openssl/openssl/doc/build.info index f7791462739..0279e2390a3 100644 --- a/deps/openssl/openssl/doc/build.info +++ b/deps/openssl/openssl/doc/build.info @@ -2271,10 +2271,6 @@ DEPEND[html/man3/SSL_CTX_set_psk_client_callback.html]=man3/SSL_CTX_set_psk_clie GENERATE[html/man3/SSL_CTX_set_psk_client_callback.html]=man3/SSL_CTX_set_psk_client_callback.pod DEPEND[man/man3/SSL_CTX_set_psk_client_callback.3]=man3/SSL_CTX_set_psk_client_callback.pod GENERATE[man/man3/SSL_CTX_set_psk_client_callback.3]=man3/SSL_CTX_set_psk_client_callback.pod -DEPEND[html/man3/SSL_CTX_set_quic_method.html]=man3/SSL_CTX_set_quic_method.pod -GENERATE[html/man3/SSL_CTX_set_quic_method.html]=man3/SSL_CTX_set_quic_method.pod -DEPEND[man/man3/SSL_CTX_set_quic_method.3]=man3/SSL_CTX_set_quic_method.pod -GENERATE[man/man3/SSL_CTX_set_quic_method.3]=man3/SSL_CTX_set_quic_method.pod DEPEND[html/man3/SSL_CTX_set_quiet_shutdown.html]=man3/SSL_CTX_set_quiet_shutdown.pod GENERATE[html/man3/SSL_CTX_set_quiet_shutdown.html]=man3/SSL_CTX_set_quiet_shutdown.pod DEPEND[man/man3/SSL_CTX_set_quiet_shutdown.3]=man3/SSL_CTX_set_quiet_shutdown.pod @@ -3355,7 +3351,6 @@ html/man3/SSL_CTX_set_msg_callback.html \ html/man3/SSL_CTX_set_num_tickets.html \ html/man3/SSL_CTX_set_options.html \ html/man3/SSL_CTX_set_psk_client_callback.html \ -html/man3/SSL_CTX_set_quic_method.html \ html/man3/SSL_CTX_set_quiet_shutdown.html \ html/man3/SSL_CTX_set_read_ahead.html \ html/man3/SSL_CTX_set_record_padding_callback.html \ @@ -3964,7 +3959,6 @@ man/man3/SSL_CTX_set_msg_callback.3 \ man/man3/SSL_CTX_set_num_tickets.3 \ man/man3/SSL_CTX_set_options.3 \ man/man3/SSL_CTX_set_psk_client_callback.3 \ -man/man3/SSL_CTX_set_quic_method.3 \ man/man3/SSL_CTX_set_quiet_shutdown.3 \ man/man3/SSL_CTX_set_read_ahead.3 \ man/man3/SSL_CTX_set_record_padding_callback.3 \ diff --git a/deps/openssl/openssl/doc/man1/openssl-ca.pod.in b/deps/openssl/openssl/doc/man1/openssl-ca.pod.in index 1d497e848e7..1c07db3c8ef 100644 --- a/deps/openssl/openssl/doc/man1/openssl-ca.pod.in +++ b/deps/openssl/openssl/doc/man1/openssl-ca.pod.in @@ -701,7 +701,7 @@ A sample configuration file with the relevant sections for this command: default_days = 365 # how long to certify for default_crl_days= 30 # how long before next CRL - default_md = md5 # md to use + default_md = sha256 # md to use policy = policy_any # default policy email_in_dn = no # Don't add the email into cert DN diff --git a/deps/openssl/openssl/doc/man1/openssl-cmp.pod.in b/deps/openssl/openssl/doc/man1/openssl-cmp.pod.in index 9240916fce4..889a59cd497 100644 --- a/deps/openssl/openssl/doc/man1/openssl-cmp.pod.in +++ b/deps/openssl/openssl/doc/man1/openssl-cmp.pod.in @@ -453,8 +453,11 @@ Reason numbers defined in RFC 5280 are: =item B<-server> I<[http[s]://][userinfo@]host[:port][/path][?query][#fragment]> -The DNS hostname or IP address and optionally port +The I domain name or IP address and optionally I of the CMP server to connect to using HTTP(S). +IP address may be for v4 or v6, such as C<127.0.0.1> or C<[::1]> for localhost. +If the host string is an IPv6 address, it must be enclosed in C<[> and C<]>. + This option excludes I<-port> and I<-use_mock_srv>. It is ignored if I<-rspin> is given with enough filename arguments. @@ -468,6 +471,7 @@ If a path is included it provides the default value for the B<-path> option. The HTTP(S) proxy server to use for reaching the CMP server unless B<-no_proxy> applies, see below. +If the host string is an IPv6 address, it must be enclosed in C<[> and C<]>. The proxy port defaults to 80 or 443 if the scheme is C; apart from that the optional C or C prefix is ignored (note that TLS may be selected by B<-tls_used>), as well as any path, userinfo, and query, and fragment @@ -969,8 +973,9 @@ This excludes the B<-server> and B<-port> options. =item B<-port> I -Act as HTTP-based CMP server mock-up listening on the given port. -This excludes the B<-server> and B<-use_mock_srv> options. +Act as HTTP-based CMP server mock-up listening on the given local port. +The client may address the server via, e.g., C<127.0.0.1> or C<[::1]>. +This option excludes the B<-server> and B<-use_mock_srv> options. The B<-rspin>, B<-rspout>, B<-reqin>, and B<-reqout> options so far are not supported in this mode. diff --git a/deps/openssl/openssl/doc/man1/openssl-cms.pod.in b/deps/openssl/openssl/doc/man1/openssl-cms.pod.in index 65a61ee97f1..f4d12312b7c 100644 --- a/deps/openssl/openssl/doc/man1/openssl-cms.pod.in +++ b/deps/openssl/openssl/doc/man1/openssl-cms.pod.in @@ -191,6 +191,10 @@ to the output file. Verify signed data. Expects a signed data on input and outputs the signed data. Both clear text and opaque signing is supported. +By default, validation of signer certificates and their chain +is done w.r.t. the S/MIME signing (C) purpose. +For details see L. + =item B<-resign> Resign a message: take an existing message and one or more new signers. @@ -374,7 +378,8 @@ See L for details. =item B<-originator> I A certificate of the originator of the encrypted message. Necessary for -decryption when Key Agreement is in use for a shared key. +decryption when Key Agreement is in use for a shared key. Currently, not +allowed for encryption. =item B<-recip> I @@ -902,7 +907,7 @@ The B<-engine> option was deprecated in OpenSSL 3.0. =head1 COPYRIGHT -Copyright 2008-2023 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2008-2025 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 diff --git a/deps/openssl/openssl/doc/man1/openssl-fipsinstall.pod.in b/deps/openssl/openssl/doc/man1/openssl-fipsinstall.pod.in index 97e2ae910c1..57758597cda 100644 --- a/deps/openssl/openssl/doc/man1/openssl-fipsinstall.pod.in +++ b/deps/openssl/openssl/doc/man1/openssl-fipsinstall.pod.in @@ -239,6 +239,10 @@ L, L, L +=head1 HISTORY + +The B application was added in OpenSSL 3.0. + =head1 COPYRIGHT Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved. diff --git a/deps/openssl/openssl/doc/man1/openssl-info.pod.in b/deps/openssl/openssl/doc/man1/openssl-info.pod.in index fe7abee4867..0e91bb28ee1 100644 --- a/deps/openssl/openssl/doc/man1/openssl-info.pod.in +++ b/deps/openssl/openssl/doc/man1/openssl-info.pod.in @@ -17,7 +17,6 @@ B [B<-listsep>] [B<-seeds>] [B<-cpusettings>] -[B<-quic>] =head1 DESCRIPTION @@ -74,10 +73,6 @@ Outputs the randomness seed sources. Outputs the OpenSSL CPU settings info. -=item B<-quic> - -Outputs the OpenSSL QUIC info. - =back =head1 HISTORY diff --git a/deps/openssl/openssl/doc/man1/openssl-ocsp.pod.in b/deps/openssl/openssl/doc/man1/openssl-ocsp.pod.in index fbad5079af6..fd23a44df06 100644 --- a/deps/openssl/openssl/doc/man1/openssl-ocsp.pod.in +++ b/deps/openssl/openssl/doc/man1/openssl-ocsp.pod.in @@ -30,8 +30,8 @@ B B [B<-respin> I] [B<-url> I] [B<-host> I:I] -[B<-path>] -[B<-proxy> I<[http[s]://][userinfo@]host[:port][/path]>] +[B<-path> I] +[B<-proxy> I<[http[s]://][userinfo@]host[:port][/path][?query][#fragment]>] [B<-no_proxy> I] [B<-header>] [B<-timeout> I] @@ -160,24 +160,32 @@ with B<-serial>, B<-cert> and B<-host> options). =item B<-url> I -Specify the responder URL. Both HTTP and HTTPS (SSL/TLS) URLs can be specified. +Specify the responder host and optionally port and path via a URL. +Both HTTP and HTTPS (SSL/TLS) URLs can be specified. The optional userinfo and fragment components are ignored. Any given query component is handled as part of the path component. +For details, see the B<-host> and B<-path> options described next. -=item B<-host> I:I, B<-path> I +=item B<-host> I:I, B<-path> I If the B<-host> option is present then the OCSP request is sent to the host -I on port I. The B<-path> option specifies the HTTP pathname -to use or "/" by default. This is equivalent to specifying B<-url> with scheme -http:// and the given hostname, port, and pathname. +I on port I. +The I may be a domain name or an IP (v4 or v6) address, +such as C<127.0.0.1> or C<[::1]> for localhost. +If it is an IPv6 address, it must be enclosed in C<[> and C<]>. -=item B<-proxy> I<[http[s]://][userinfo@]host[:port][/path]> +The B<-path> option specifies the HTTP pathname to use or "/" by default. +This is equivalent to specifying B<-url> with scheme +http:// and the given I, I, and optional I. + +=item B<-proxy> I<[http[s]://][userinfo@]host[:port][/path][?query][#fragment]> The HTTP(S) proxy server to use for reaching the OCSP server unless B<-no_proxy> applies, see below. +If the host string is an IPv6 address, it must be enclosed in C<[> and C<]>. The proxy port defaults to 80 or 443 if the scheme is C; apart from that the optional C or C prefix is ignored, -as well as any userinfo and path components. +as well as any userinfo, path, query, and fragment components. Defaults to the environment variable C if set, else C in case no TLS is used, otherwise C if set, else C. @@ -369,8 +377,8 @@ subject name. =item B<-port> I -Port to listen for OCSP requests on. The port may also be specified -using the B option. +Port to listen for OCSP requests on. Both IPv4 and IPv6 are possible. +The port may also be specified using the B<-url> option. A C<0> argument indicates that any available port shall be chosen automatically. =item B<-ignore_err> diff --git a/deps/openssl/openssl/doc/man1/openssl-pkeyutl.pod.in b/deps/openssl/openssl/doc/man1/openssl-pkeyutl.pod.in index cf3427a35c0..2f6ef0021d1 100644 --- a/deps/openssl/openssl/doc/man1/openssl-pkeyutl.pod.in +++ b/deps/openssl/openssl/doc/man1/openssl-pkeyutl.pod.in @@ -44,6 +44,8 @@ B B This command can be used to perform low-level public key operations using any supported algorithm. +By default the signing operation (see B<-sign> option) is assumed. + =head1 OPTIONS =over 4 @@ -59,20 +61,29 @@ if this option is not specified. =item B<-rawin> -This indicates that the input data is raw data, which is not hashed by any -message digest algorithm. The user can specify a digest algorithm by using -the B<-digest> option. This option can only be used with B<-sign> and -B<-verify> and must be used with the Ed25519 and Ed448 algorithms. +This indicates that the signature or verification input data is raw data, +which is not hashed by any message digest algorithm. +Except with EdDSA, +the user can specify a digest algorithm by using the B<-digest> option. +For signature algorithms like RSA, DSA and ECDSA, +the default digest algorithm is SHA-256. For SM2, it is SM3. + +This option can only be used with B<-sign> and B<-verify>. +For EdDSA (the Ed25519 and Ed448 algorithms) this option is required. =item B<-digest> I -This specifies the digest algorithm which is used to hash the input data before -signing or verifying it with the input key. This option could be omitted if the -signature algorithm does not require one (for instance, EdDSA). If this option -is omitted but the signature algorithm requires one, a default value will be -used. For signature algorithms like RSA, DSA and ECDSA, SHA-256 will be the -default digest algorithm. For SM2, it will be SM3. If this option is present, -then the B<-rawin> option must be also specified. +This option can only be used with B<-sign> and B<-verify>. +It specifies the digest algorithm that is used to hash the input data +before signing or verifying it with the input key. This option could be omitted +if the signature algorithm does not require preprocessing the input through +a pluggable hash function before signing (for instance, EdDSA). If this option +is omitted but the signature algorithm requires one and the B<-rawin> option +is given, a default value will be used (see B<-rawin> for details). +If this option is present, then the B<-rawin> option is required. + +At this time, HashEdDSA (the ph or "prehash" variant of EdDSA) is not supported, +so the B<-digest> option cannot be used with EdDSA. =item B<-out> I @@ -81,7 +92,7 @@ default. =item B<-sigfile> I -Signature file, required for B<-verify> operations only +Signature file, required and allowed for B<-verify> operations only =item B<-inkey> I|I @@ -117,21 +128,42 @@ The input is a certificate containing a public key. =item B<-rev> Reverse the order of the input buffer. This is useful for some libraries -(such as CryptoAPI) which represent the buffer in little endian format. +(such as CryptoAPI) which represent the buffer in little-endian format. +This cannot be used in conjunction with B<-rawin>. =item B<-sign> -Sign the input data (which must be a hash) and output the signed result. This -requires a private key. +Sign the input data and output the signed result. This requires a private key. +Using a message digest operation along with this is recommended, +when applicable, see the B<-rawin> and B<-digest> options for details. +Otherwise, the input data given with the B<-in> option is assumed to already +be a digest, but this may then require an additional B<-pkeyopt> CI +in some cases (e.g., RSA with the default PKCS#1 padding mode). +Even for other algorithms like ECDSA, where the additional B<-pkeyopt> option +does not affect signature output, it is recommended, as it enables +checking that the input length is consistent with the intended digest. =item B<-verify> -Verify the input data (which must be a hash) against the signature file and -indicate if the verification succeeded or failed. +Verify the input data against the signature given with the B<-sigfile> option +and indicate if the verification succeeded or failed. +The input data given with the B<-in> option is assumed to be a hash value +unless the B<-rawin> option is specified or implied. +With raw data, when a digest algorithm is applicable, though it may be inferred +from the signature or take a default value, it should also be specified. =item B<-verifyrecover> -Verify the input data (which must be a hash) and output the recovered data. +Verify the given signature and output the recovered data (signature payload). +For example, in case of RSA PKCS#1 the recovered data is the B +DER encoding of the digest algorithm OID and value as specified in +L. + +Note that here the input given with the B<-in> option is not a signature input +(as with the B<-sign> and B<-verify> options) but a signature output value, +typically produced using the B<-sign> option. + +This option is available only for use with RSA keys. =item B<-encrypt> @@ -175,8 +207,9 @@ hex dump the output data. =item B<-asn1parse> -Parse the ASN.1 output data, this is useful when combined with the -B<-verifyrecover> option when an ASN1 structure is signed. +Parse the ASN.1 output data to check its DER encoding and print any errors. +When combined with the B<-verifyrecover> option, this may be useful only in case +an ASN.1 DER-encoded structure had been signed directly (without hashing it). {- $OpenSSL::safe::opt_engine_item -} @@ -200,8 +233,8 @@ engine I for crypto operations. The operations and options supported vary according to the key algorithm and its implementation. The OpenSSL operations and options are indicated below. -Unless otherwise mentioned all algorithms support the BI option -which specifies the digest in use for sign, verify and verifyrecover operations. +Unless otherwise mentioned, all algorithms support the BI option, +which specifies the digest in use for the signing and verification operations. The value I should represent a digest name as used in the EVP_get_digestbyname() function for example B. This value is not used to hash the input data. It is used (by some algorithms) for sanity-checking the diff --git a/deps/openssl/openssl/doc/man1/openssl-req.pod.in b/deps/openssl/openssl/doc/man1/openssl-req.pod.in index a56f548de8e..7ba599b54a0 100644 --- a/deps/openssl/openssl/doc/man1/openssl-req.pod.in +++ b/deps/openssl/openssl/doc/man1/openssl-req.pod.in @@ -638,7 +638,7 @@ Sample configuration file prompting for field values: attributes = req_attributes req_extensions = v3_ca - dirstring_type = nobmp + dirstring_type = nombstr [ req_distinguished_name ] countryName = Country Name (2 letter code) @@ -778,7 +778,7 @@ The <-nodes> option was deprecated in OpenSSL 3.0, too; use B<-noenc> instead. =head1 COPYRIGHT -Copyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-2025 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 diff --git a/deps/openssl/openssl/doc/man1/openssl-s_client.pod.in b/deps/openssl/openssl/doc/man1/openssl-s_client.pod.in index bd6171aa265..caebe10bffb 100644 --- a/deps/openssl/openssl/doc/man1/openssl-s_client.pod.in +++ b/deps/openssl/openssl/doc/man1/openssl-s_client.pod.in @@ -10,11 +10,11 @@ openssl-s_client - SSL/TLS client program B B [B<-help>] [B<-ssl_config> I
] -[B<-connect> I] +[B<-connect> I:I] [B<-host> I] [B<-port> I] -[B<-bind> I] -[B<-proxy> I] +[B<-bind> I:I] +[B<-proxy> I:I] [B<-proxy_user> I] [B<-proxy_pass> I] [B<-unix> I] @@ -157,6 +157,7 @@ This specifies the host and optional port to connect to. It is possible to select the host and port using the optional target positional argument instead. If neither this nor the target positional argument are specified then an attempt is made to connect to the local host on port 4433. +If the host string is an IPv6 address, it must be enclosed in C<[> and C<]>. =item B<-host> I @@ -166,17 +167,19 @@ Host to connect to; use B<-connect> instead. Connect to the specified port; use B<-connect> instead. -=item B<-bind> I +=item B<-bind> I:I This specifies the host address and or port to bind as the source for the connection. For Unix-domain sockets the port is ignored and the host is used as the source socket address. +If the host string is an IPv6 address, it must be enclosed in C<[> and C<]>. -=item B<-proxy> I +=item B<-proxy> I:I When used with the B<-connect> flag, the program uses the host and port specified with this flag and issues an HTTP CONNECT command to connect to the desired server. +If the host string is an IPv6 address, it must be enclosed in C<[> and C<]>. =item B<-proxy_user> I @@ -260,7 +263,9 @@ See L for details. =item B<-crl_download> -Download CRL from distribution points in the certificate. +Download CRL from distribution points in the certificate. Note that this option +is ignored if B<-crl_check> option is not provided. Note that the maximum size +of CRL is limited by L function. =item B<-key> I|I @@ -282,14 +287,20 @@ see L. The verify depth to use. This specifies the maximum length of the server certificate chain and turns on server certificate verification. -Currently the verify operation continues after errors so all the problems +Unless the B<-verify_return_error> option is given, +the verify operation continues after errors so all the problems with a certificate chain can be seen. As a side effect the connection will never fail due to a server certificate verify failure. +By default, validation of server certificates and their chain +is done w.r.t. the (D)TLS Server (C) purpose. +For details see L. + =item B<-verify_return_error> -Return verification errors instead of continuing. This will typically -abort the handshake with a fatal error. +Turns on server certificate verification, like with B<-verify>, +but returns verification errors instead of continuing. +This will typically abort the handshake with a fatal error. =item B<-verify_quiet> @@ -799,10 +810,11 @@ proceed unless the B<-verify_return_error> option is used. =item I:I -Rather than providing B<-connect>, the target hostname and optional port may +Rather than providing B<-connect>, the target host and optional port may be provided as a single positional argument after all options. If neither this nor B<-connect> are provided, falls back to attempting to connect to I on port I<4433>. +If the host string is an IPv6 address, it must be enclosed in C<[> and C<]>. =back @@ -881,6 +893,51 @@ option: any verify errors are then returned aborting the handshake. The B<-bind> option may be useful if the server or a firewall requires connections to come from some particular address and or port. +=head2 Note on Non-Interactive Use + +When B is run in a non-interactive environment (e.g., a cron job or +a script without a valid I), it may close the connection prematurely, +especially with TLS 1.3. To prevent this, you can use the B<-ign_eof> flag, +which keeps B running even after reaching EOF from I. + +For example: + + openssl s_client -connect :443 -tls1_3 + -sess_out /path/to/tls_session_params_file + -ign_eof can lead to issues if the server keeps +the connection open, expecting the client to close first. In such cases, the +client may hang indefinitely. This behavior is not uncommon, particularly with +protocols where the server waits for a graceful disconnect from the client. + +For example, when connecting to an SMTP server, the session may pause if the +server expects a QUIT command before closing: + + $ openssl s_client -brief -ign_eof -starttls smtp + -connect :25 :25 + -starttls smtp -brief -ign_eof + +Similarly, for HTTP/1.1 connections, including a `Connection: close` header +ensures the server closes the connection after responding: + + printf 'GET / HTTP/1.1\r\nHost: \r\nConnection: close\r\n\r\n' + | openssl s_client -connect :443 -brief + +These approaches help manage the connection closure gracefully and prevent +hangs caused by the server waiting for the client to initiate the disconnect. + =head1 BUGS Because this program has a lot of options and also because some of the diff --git a/deps/openssl/openssl/doc/man1/openssl-s_server.pod.in b/deps/openssl/openssl/doc/man1/openssl-s_server.pod.in index 99a252a8225..f0825ad33d1 100644 --- a/deps/openssl/openssl/doc/man1/openssl-s_server.pod.in +++ b/deps/openssl/openssl/doc/man1/openssl-s_server.pod.in @@ -74,7 +74,7 @@ B B [B<-status>] [B<-status_verbose>] [B<-status_timeout> I] -[B<-proxy> I<[http[s]://][userinfo@]host[:port][/path]>] +[B<-proxy> I<[http[s]://][userinfo@]host[:port][/path][?query][#fragment]>] [B<-no_proxy> I] [B<-status_url> I] [B<-status_file> I] @@ -202,6 +202,10 @@ must supply a certificate or an error occurs. If the cipher suite cannot request a client certificate (for example an anonymous cipher suite or PSK) this option has no effect. +By default, validation of any supplied client certificate and its chain +is done w.r.t. the (D)TLS Client (C) purpose. +For details see L. + =item B<-cert> I The certificate to use, most servers cipher suites require the use of a @@ -504,13 +508,14 @@ a verbose printout of the OCSP response. Sets the timeout for OCSP response to I seconds. -=item B<-proxy> I<[http[s]://][userinfo@]host[:port][/path]> +=item B<-proxy> I<[http[s]://][userinfo@]host[:port][/path][?query][#fragment]> The HTTP(S) proxy server to use for reaching the OCSP server unless B<-no_proxy> applies, see below. +If the host string is an IPv6 address, it must be enclosed in C<[> and C<]>. The proxy port defaults to 80 or 443 if the scheme is C; apart from that the optional C or C prefix is ignored, -as well as any userinfo and path components. +as well as any userinfo, path, query, and fragment components. Defaults to the environment variable C if set, else C in case no TLS is used, otherwise C if set, else C. diff --git a/deps/openssl/openssl/doc/man1/openssl-s_time.pod.in b/deps/openssl/openssl/doc/man1/openssl-s_time.pod.in index 2b82cf1e983..ca41f59362f 100644 --- a/deps/openssl/openssl/doc/man1/openssl-s_time.pod.in +++ b/deps/openssl/openssl/doc/man1/openssl-s_time.pod.in @@ -50,6 +50,7 @@ Print out a usage message. =item B<-connect> I:I This specifies the host and optional port to connect to. +If the host string is an IPv6 address, it must be enclosed in C<[> and C<]>. =item B<-www> I diff --git a/deps/openssl/openssl/doc/man1/openssl-smime.pod.in b/deps/openssl/openssl/doc/man1/openssl-smime.pod.in index 0b5dbb5df8f..ffd09704f83 100644 --- a/deps/openssl/openssl/doc/man1/openssl-smime.pod.in +++ b/deps/openssl/openssl/doc/man1/openssl-smime.pod.in @@ -394,9 +394,9 @@ Verify a message and extract the signer's certificate if successful: Send encrypted mail using triple DES: - openssl smime -encrypt -in in.txt -from steve@openssl.org \ + openssl smime -encrypt -in in.txt -out mail.msg -from steve@openssl.org \ -to someone@somewhere -subject "Encrypted message" \ - -des3 user.pem -out mail.msg + -des3 user.pem Sign and encrypt mail: diff --git a/deps/openssl/openssl/doc/man1/openssl-ts.pod.in b/deps/openssl/openssl/doc/man1/openssl-ts.pod.in index 5f4895b34d6..cd6dfd5305f 100644 --- a/deps/openssl/openssl/doc/man1/openssl-ts.pod.in +++ b/deps/openssl/openssl/doc/man1/openssl-ts.pod.in @@ -584,10 +584,12 @@ To verify a timestamp reply that includes the certificate chain: -CAfile cacert.pem To verify a timestamp token against the original data file: + openssl ts -verify -data design2.txt -in design2.tsr \ -CAfile cacert.pem To verify a timestamp token against a message imprint: + openssl ts -verify -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \ -in design2.tsr -CAfile cacert.pem diff --git a/deps/openssl/openssl/doc/man1/openssl-verification-options.pod b/deps/openssl/openssl/doc/man1/openssl-verification-options.pod index bf9ed9c1a62..17fcd4eb79f 100644 --- a/deps/openssl/openssl/doc/man1/openssl-verification-options.pod +++ b/deps/openssl/openssl/doc/man1/openssl-verification-options.pod @@ -24,8 +24,9 @@ The most important of them are detailed in the following sections. In a nutshell, a valid chain of certificates needs to be built up and verified starting from the I that is to be verified and ending in a certificate that due to some policy is trusted. -Verification is done relative to the given I, which is the intended use -of the target certificate, such as SSL server, or by default for any purpose. +Certificate validation can be performed in the context of a I, which +is a high-level specification of the intended use of the target certificate, +such as C for TLS servers, or (by default) for any purpose. The details of how each OpenSSL command handles errors are documented on the specific command page. @@ -150,16 +151,17 @@ the chain components and their links are checked thoroughly. The first step is to check that each certificate is well-formed. Part of these checks are enabled only if the B<-x509_strict> option is given. -The second step is to check the extensions of every untrusted certificate -for consistency with the supplied purpose. -If the B<-purpose> option is not given then no such checks are done -except for SSL/TLS connection setup, -where by default C or C, are checked. -The target or "leaf" certificate, as well as any other untrusted certificates, -must have extensions compatible with the specified purpose. -All certificates except the target or "leaf" must also be valid CA certificates. -The precise extensions required are described in more detail in -L. +The second step is to check the X.509v3 extensions of every certificate +for consistency with the intended specific purpose, if any. +If the B<-purpose> option is not given then no such checks are done except for +CMS signature checking, where by default C is checked, and SSL/(D)TLS +connection setup, where by default C or C are checked. +The X.509v3 extensions of the target or "leaf" certificate +must be compatible with the specified purpose. +All other certificates down the chain are checked to be valid CA certificates, +and possibly also further non-standard checks are performed. +The precise extensions required are described in detail +in the L section below. The third step is to check the trust settings on the last certificate (which typically is a self-signed root CA certificate). @@ -455,13 +457,16 @@ Set policy variable inhibit-policy-mapping (see RFC5280). =item B<-purpose> I -The intended use for the certificate. -Currently defined purposes are C, C, C, +A high-level specification of the intended use of the target certificate. +Currently predefined purposes are C, C, C, C, C, C, C, C, and C. If peer certificate verification is enabled, by default the TLS implementation -as well as the commands B and B check for consistency -with TLS server or TLS client use, respectively. +and thus the commands L and L +check for consistency with +TLS server (C) or TLS client use (C), respectively. +By default, CMS signature validation, which can be done via L, +checks for consistency with S/MIME signing use (C). While IETF RFC 5280 says that B and B are only for WWW use, in practice they are used for all kinds of TLS clients @@ -491,19 +496,20 @@ the subject certificate. =item B<-verify_name> I -Use default verification policies like trust model and required certificate -policies identified by I. +Use a set of verification parameters, also known as verification method, +identified by I. The currently predefined methods are named C, +C, C with alias C, and C. +These mimic the combinations of purpose and trust settings used in SSL/(D)TLS, +and CMS/PKCS7 (including S/MIME). + +The verification parameters include the trust model, various flags that can +partly be set also via other command-line options, and the verification purpose, +which in turn implies certificate key usage and extended key usage requirements. + The trust model determines which auxiliary trust or reject OIDs are applicable to verifying the given certificate chain. They can be given using the B<-addtrust> and B<-addreject> options for L. -Supported policy names include: B, B, B, -B, B. -These mimics the combinations of purpose and trust settings used in SSL, CMS -and S/MIME. -As of OpenSSL 1.1.0, the trust model is inferred from the purpose when not -specified, so the B<-verify_name> options are functionally equivalent to the -corresponding B<-purpose> settings. =back @@ -548,9 +554,8 @@ This option has no effect and is retained for backward compatibility only. =head2 Certificate Extensions -Options like B<-purpose> lead to checking the certificate extensions, -which determine what the target certificate and intermediate CA certificates -can be used for. +Options like B<-purpose> and B<-verify_name> trigger the processing of specific +certificate extensions, which determine what certificates can be used for. =head3 Basic Constraints @@ -574,87 +579,117 @@ keyCertSign bit set if the keyUsage extension is present. =head3 Extended Key Usage -The extKeyUsage (EKU) extension places additional restrictions on the -certificate uses. If this extension is present (whether critical or not) -the key can only be used for the purposes specified. - -A complete description of each check is given below. The comments about +The extKeyUsage (EKU) extension places additional restrictions on +certificate use. If this extension is present (whether critical or not) +in an end-entity certficiate, the key is allowed only for the uses specified, +while the special EKU B allows for all uses. + +Note that according to RFC 5280 section 4.2.1.12, +the Extended Key Usage extension will appear only in end-entity certificates, +and consequently the standard certification path validation described +in its section 6 does not include EKU checks for CA certificates. +The CA/Browser Forum requires for TLS server, S/MIME, and code signing use +the presence of respective EKUs in subordinate CA certificates (while excluding +them for root CA certificates), while taking over from RFC 5280 +the certificate validity concept and certificate path validation. + +For historic reasons, OpenSSL has its own way of interpreting and checking +EKU extensions on CA certificates, which may change in the future. +It does not require the presence of EKU extensions in CA certificates, +but in case the verification purpose is +C, C, C, C, or C, +it checks that any present EKU extension (that does not contain +B) contains the respective EKU as detailed below. +Moreover, it does these checks even for trust anchor certificates. + +=head3 Checks Implied by Specific Predefined Policies + +A specific description of each check is given below. The comments about basicConstraints and keyUsage and X.509v1 certificates above apply to B CA certificates. - =over 4 -=item B +=item B<(D)TLS Client> (C) -The extended key usage extension must be absent or include the "web client -authentication" OID. The keyUsage extension must be absent or it must have the -digitalSignature bit set. The Netscape certificate type must be absent -or it must have the SSL client bit set. +Any given extended key usage extension must allow for C +("TLS WWW client authentication"). -=item B +For target certificates, +the key usage must allow for C and/or C. +The Netscape certificate type must be absent or have the SSL client bit set. -The extended key usage extension must be absent or include the "web client -authentication" OID. -The Netscape certificate type must be absent or it must have the SSL CA bit set. -This is used as a work around if the basicConstraints extension is absent. +For all other certificates the normal CA checks apply. In addition, +the Netscape certificate type must be absent or have the SSL CA bit set. +This is used as a workaround if the basicConstraints extension is absent. -=item B +=item B<(D)TLS Server> (C) -The extended key usage extension must be absent or include the "web server -authentication" and/or one of the SGC OIDs. The keyUsage extension must be -absent or it -must have the digitalSignature, the keyEncipherment set or both bits set. -The Netscape certificate type must be absent or have the SSL server bit set. +Any given extended key usage extension must allow for C +("TLS WWW server authentication") and/or include one of the SGC OIDs. -=item B +For target certificates, the key usage must +allow for C, C, and/or C. +The Netscape certificate type must be absent or have the SSL server bit set. -The extended key usage extension must be absent or include the "web server -authentication" and/or one of the SGC OIDs. The Netscape certificate type must -be absent or the SSL CA bit must be set. -This is used as a work around if the basicConstraints extension is absent. +For all other certificates the normal CA checks apply. In addition, +the Netscape certificate type must be absent or have the SSL CA bit set. +This is used as a workaround if the basicConstraints extension is absent. -=item B +=item B (C) -For Netscape SSL clients to connect to an SSL server it must have the -keyEncipherment bit set if the keyUsage extension is present. This isn't +In addition to what has been described for B, for a Netscape +SSL client to connect to an SSL server, its EE certficate must have the +B bit set if the keyUsage extension is present. This isn't always valid because some cipher suites use the key for digital signing. Otherwise it is the same as a normal SSL server. -=item B +=item B -The extended key usage extension must be absent or include the "email -protection" OID. The Netscape certificate type must be absent or should have the -S/MIME bit set. If the S/MIME bit is not set in the Netscape certificate type +Any given extended key usage extension must allow for C. + +For target certificates, +the Netscape certificate type must be absent or should have the S/MIME bit set. +If the S/MIME bit is not set in the Netscape certificate type then the SSL client bit is tolerated as an alternative but a warning is shown. This is because some Verisign certificates don't set the S/MIME bit. -=item B +For all other certificates the normal CA checks apply. In addition, +the Netscape certificate type must be absent or have the S/MIME CA bit set. +This is used as a workaround if the basicConstraints extension is absent. + +=item B (C) + +In addition to the common S/MIME checks, for target certficiates +the key usage must allow for C and/or B. + +=item B (C) + +In addition to the common S/MIME checks, for target certficiates +the key usage must allow for C. -In addition to the common S/MIME client tests the digitalSignature bit or -the nonRepudiation bit must be set if the keyUsage extension is present. +=item B (C) -=item B +For target certificates, the key usage must allow for C. -In addition to the common S/MIME tests the keyEncipherment bit must be set -if the keyUsage extension is present. +For all other certifcates the normal CA checks apply. +Except in this case the basicConstraints extension must be present. -=item B +=item B (C) -The extended key usage extension must be absent or include the "email -protection" OID. The Netscape certificate type must be absent or must have the -S/MIME CA bit set. -This is used as a work around if the basicConstraints extension is absent. +For target certificates, no checks are performed at this stage, +but special checks apply; see L. -=item B +For all other certifcates the normal CA checks apply. -The keyUsage extension must be absent or it must have the CRL signing bit -set. +=item B (C) -=item B +For target certificates, if the key usage extension is present, it must include +C and/or C and must not include other bits. +The EKU extension must be present and contain C only. +Moreover, it must be marked as critical. -The normal CA tests apply. Except in this case the basicConstraints extension -must be present. +For all other certifcates the normal CA checks apply. =back @@ -671,6 +706,7 @@ only the first one (in the mentioned order of locations) is recognised. =head1 SEE ALSO L, +L, L, L, L, diff --git a/deps/openssl/openssl/doc/man1/openssl.pod b/deps/openssl/openssl/doc/man1/openssl.pod index 201428e8700..4865e5c33e6 100644 --- a/deps/openssl/openssl/doc/man1/openssl.pod +++ b/deps/openssl/openssl/doc/man1/openssl.pod @@ -653,111 +653,22 @@ See L for a more detailed description. =head1 ENVIRONMENT -The OpenSSL library can be take some configuration parameters from the -environment. Some of these variables are listed below. For information -about specific commands, see L, -L, and L. - -For information about the use of environment variables in configuration, -see L. - -For information about querying or specifying CPU architecture flags, see -L, and L. +The OpenSSL libraries can take some configuration parameters from the +environment. For information about all environment variables used by the OpenSSL libraries, +such as B, B, and B, see L. -=over 4 - -=item BI[,...] - -Enable tracing output of OpenSSL library, by name. -This output will only make sense if you know OpenSSL internals well. -Also, it might not give you any output at all, depending on how -OpenSSL was built. - -The value is a comma separated list of names, with the following -available: - -=over 4 - -=item B - -Traces the OpenSSL trace API itself. - -=item B - -Traces OpenSSL library initialization and cleanup. - -=item B - -Traces the TLS/SSL protocol. - -=item B - -Traces the ciphers used by the TLS/SSL protocol. - -=item B - -Show details about provider and engine configuration. - -=item B - -The function that is used by RSA, DSA (etc) code to select registered -ENGINEs, cache defaults and functional references (etc), will generate -debugging summaries. - -=item B - -Reference counts in the ENGINE structure will be monitored with a line -of generated for each change. - -=item B - -Traces PKCS#5 v2 key generation. - -=item B - -Traces PKCS#12 key generation. - -=item B - -Traces PKCS#12 decryption. - -=item B - -Generates the complete policy tree at various points during X.509 v3 -policy evaluation. - -=item B - -Traces BIGNUM context operations. - -=item B - -Traces CMP client and server activity. - -=item B - -Traces STORE operations. - -=item B - -Traces decoder operations. - -=item B - -Traces encoder operations. - -=item B - -Traces decrementing certain ASN.1 structure references. +For information about the use of environment variables in configuration, +see L. -=back +For information about specific commands, see L, +L, and L. -=back +For information about querying or specifying CPU architecture flags, see +L, and L. -=head1 SEE ALSO L, L, diff --git a/deps/openssl/openssl/doc/man3/ASN1_TIME_set.pod b/deps/openssl/openssl/doc/man3/ASN1_TIME_set.pod index 66d9fefe1af..bdef3fdbb15 100644 --- a/deps/openssl/openssl/doc/man3/ASN1_TIME_set.pod +++ b/deps/openssl/openssl/doc/man3/ASN1_TIME_set.pod @@ -102,8 +102,8 @@ functions check the syntax of the time structure I. The ASN1_TIME_print(), ASN1_UTCTIME_print() and ASN1_GENERALIZEDTIME_print() functions print the time structure I to BIO I in human readable -format. It will be of the format MMM DD HH:MM:SS YYYY [GMT], for example -"Feb 3 00:55:52 2015 GMT", which does not include a newline. +format. It will be of the format MMM DD HH:MM:SS[.s*] YYYY GMT, for example +"Feb E<32>3 00:55:52 2015 GMT", which does not include a newline. If the time structure has invalid format it prints out "Bad time value" and returns an error. The output for generalized time may include a fractional part following the second. @@ -179,6 +179,10 @@ starting with B and B act only on that specific time format. The functions starting with B will operate on either format. +Users familiar with RFC822 should note that when specifying the flag +B the year will be formatted as documented above, +i.e., using 4 digits, not 2 as specified in RFC822. + =head1 BUGS ASN1_TIME_print(), ASN1_UTCTIME_print() and ASN1_GENERALIZEDTIME_print() do @@ -272,7 +276,7 @@ The ASN1_TIME_compare() function was added in OpenSSL 1.1.1. =head1 COPYRIGHT -Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2015-2025 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 diff --git a/deps/openssl/openssl/doc/man3/ASN1_aux_cb.pod b/deps/openssl/openssl/doc/man3/ASN1_aux_cb.pod index f87b51d5efa..9963ea13502 100644 --- a/deps/openssl/openssl/doc/man3/ASN1_aux_cb.pod +++ b/deps/openssl/openssl/doc/man3/ASN1_aux_cb.pod @@ -87,7 +87,7 @@ found for the purposes of reference counting. =item I A callback that will be invoked at various points during the processing of -the the B. See below for further details. +the B. See below for further details. =item I @@ -97,7 +97,7 @@ will be saved if the B flag has been set. =item I A callback that will be invoked at various points during the processing of -the the B. This is used in preference to the I callback if +the B. This is used in preference to the I callback if the B flag is set. See below for further details. =back @@ -274,7 +274,7 @@ B operation types were added in OpenSSL 3.0. =head1 COPYRIGHT -Copyright 2021-2023 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2021-2025 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 diff --git a/deps/openssl/openssl/doc/man3/BIO_s_accept.pod b/deps/openssl/openssl/doc/man3/BIO_s_accept.pod index 25a752998ca..22b3d35b737 100644 --- a/deps/openssl/openssl/doc/man3/BIO_s_accept.pod +++ b/deps/openssl/openssl/doc/man3/BIO_s_accept.pod @@ -169,16 +169,16 @@ BIO_set_bind_mode(), BIO_get_bind_mode() and BIO_do_accept() are macros. BIO_do_accept(), BIO_set_accept_name(), BIO_set_accept_port(), BIO_set_nbio_accept(), BIO_set_accept_bios(), BIO_set_accept_ip_family(), and BIO_set_bind_mode() -return 1 for success and <=0 for failure. +return 1 for success and <= 0 for failure. BIO_get_accept_name() returns the accept name or NULL on error. BIO_get_peer_name() returns the peer name or NULL on error. BIO_get_accept_port() returns the accept port as a string or NULL on error. BIO_get_peer_port() returns the peer port as a string or NULL on error. -BIO_get_accept_ip_family() returns the IP family or <=0 on error. +BIO_get_accept_ip_family() returns the IP family or <= 0 on error. -BIO_get_bind_mode() returns the set of B flags, or <=0 on failure. +BIO_get_bind_mode() returns the set of B flags, or <= 0 on failure. BIO_new_accept() returns a BIO or NULL on error. diff --git a/deps/openssl/openssl/doc/man3/BIO_s_connect.pod b/deps/openssl/openssl/doc/man3/BIO_s_connect.pod index ab813b32d03..a3c9e6428e4 100644 --- a/deps/openssl/openssl/doc/man3/BIO_s_connect.pod +++ b/deps/openssl/openssl/doc/man3/BIO_s_connect.pod @@ -59,7 +59,7 @@ a single call: that is it creates a new connect BIO with hostname B. BIO_set_conn_hostname() uses the string B to set the hostname. The hostname can be an IP address; if the address is an IPv6 one, it -must be enclosed with brackets C<[> and C<]>. +must be enclosed in brackets C<[> and C<]>. The hostname can also include the port in the form hostname:port; see L and BIO_set_conn_port() for details. diff --git a/deps/openssl/openssl/doc/man3/ECDSA_sign.pod b/deps/openssl/openssl/doc/man3/ECDSA_sign.pod index 7e564666533..88e851885a0 100644 --- a/deps/openssl/openssl/doc/man3/ECDSA_sign.pod +++ b/deps/openssl/openssl/doc/man3/ECDSA_sign.pod @@ -52,7 +52,7 @@ size use L with a NULL I parameter. ECDSA_sign() computes a digital signature of the I bytes hash value I using the private EC key I. The DER encoded signatures is -stored in I and its length is returned in I. Note: I must +stored in I and its length is returned in I. Note: I must point to ECDSA_size(eckey) bytes of memory. The parameter I is currently ignored. ECDSA_sign() is wrapper function for ECDSA_sign_ex() with I and I set to NULL. @@ -82,7 +82,7 @@ used in a later call to ECDSA_sign_ex() or ECDSA_do_sign_ex(). ECDSA_sign_ex() computes a digital signature of the I bytes hash value I using the private EC key I and the optional pre-computed values I and I. The DER encoded signature is stored in I and its -length is returned in I. Note: I must point to ECDSA_size(eckey) +length is returned in I. Note: I must point to ECDSA_size(eckey) bytes of memory. The parameter I is ignored. ECDSA_do_sign_ex() is similar to ECDSA_sign_ex() except the signature is diff --git a/deps/openssl/openssl/doc/man3/EVP_EncryptInit.pod b/deps/openssl/openssl/doc/man3/EVP_EncryptInit.pod index f037d135c9d..a4635f994c2 100644 --- a/deps/openssl/openssl/doc/man3/EVP_EncryptInit.pod +++ b/deps/openssl/openssl/doc/man3/EVP_EncryptInit.pod @@ -1284,6 +1284,15 @@ indicates whether the operation was successful. If it does not indicate success, the authentication operation has failed and any output data B be used as it is corrupted. +Please note that the number of authenticated bytes returned by +EVP_CipherUpdate() depends on the cipher used. Stream ciphers, such as ChaCha20 +or ciphers in GCM mode, can handle 1 byte at a time, resulting in an effective +"block" size of 1. Conversely, ciphers in OCB mode must process data one block +at a time, and the block size is returned. + +Regardless of the returned size, it is safe to pass unpadded data to an +EVP_CipherUpdate() call in a single operation. + =head2 GCM and OCB Modes The following Is are supported in GCM and OCB modes. @@ -1319,10 +1328,9 @@ For GCM, this call is only valid when decrypting data. For OCB, this call is valid when decrypting data to set the expected tag, and when encrypting to set the desired tag length. -In OCB mode, calling this when encrypting with C set to C sets the -tag length. The tag length can only be set before specifying an IV. If this is -not called prior to setting the IV during encryption, then a default tag length -is used. +In OCB mode, calling this with C set to C sets the tag length. +The tag length can only be set before specifying an IV. If this is not called +prior to setting the IV, then a default tag length is used. For OCB AES, the default tag length is 16 (i.e. 128 bits). It is also the maximum tag length for OCB. diff --git a/deps/openssl/openssl/doc/man3/EVP_PKEY_decapsulate.pod b/deps/openssl/openssl/doc/man3/EVP_PKEY_decapsulate.pod index 819291627bb..cd6f5f0221a 100644 --- a/deps/openssl/openssl/doc/man3/EVP_PKEY_decapsulate.pod +++ b/deps/openssl/openssl/doc/man3/EVP_PKEY_decapsulate.pod @@ -25,10 +25,13 @@ specifying the private key to use. The EVP_PKEY_decapsulate() function performs a private key decapsulation operation using I. The data to be decapsulated is specified using the I and I parameters. -If I is NULL then the maximum size of the output secret buffer +If I is NULL then the size of the output secret buffer is written to I<*unwrappedlen>. If I is not NULL and the call is successful then the decapsulated secret data is written to I -and the amount of data written to I<*unwrappedlen>. +and the amount of data written to I<*unwrappedlen>. Note that, if I +is not NULL in this call, the value it points to must be initialised to the length of +I, so that the call can validate it is of sufficient size to hold the +result of the operation. =head1 NOTES @@ -57,7 +60,7 @@ Decapsulate data using RSA: unsigned char *secret = NULL;; ctx = EVP_PKEY_CTX_new_from_pkey(libctx, rsa_priv_key, NULL); - if (ctx = NULL) + if (ctx == NULL) /* Error */ if (EVP_PKEY_decapsulate_init(ctx, NULL) <= 0) /* Error */ diff --git a/deps/openssl/openssl/doc/man3/EVP_PKEY_encapsulate.pod b/deps/openssl/openssl/doc/man3/EVP_PKEY_encapsulate.pod index 0ee7d627904..eb51836d795 100644 --- a/deps/openssl/openssl/doc/man3/EVP_PKEY_encapsulate.pod +++ b/deps/openssl/openssl/doc/man3/EVP_PKEY_encapsulate.pod @@ -35,7 +35,10 @@ unless I is NULL. If I is not NULL and the call is successful then the internally generated key is written to I and its size is written to I<*genkeylen>. The encapsulated version of the generated key is written to -I and its size is written to I<*wrappedkeylen>. +I and its size is written to I<*wrappedkeylen>. Note that if +I is not NULL, then the value it points to must initially hold the size of +the I buffer so that its size can be validated by the call, ensuring +it is large enough to hold the result written to I. =head1 NOTES @@ -63,7 +66,7 @@ Encapsulate an RSASVE key (for RSA keys). unsigned char *out = NULL, *secret = NULL; ctx = EVP_PKEY_CTX_new_from_pkey(libctx, rsa_pub_key, NULL); - if (ctx = NULL) + if (ctx == NULL) /* Error */ if (EVP_PKEY_encapsulate_init(ctx, NULL) <= 0) /* Error */ diff --git a/deps/openssl/openssl/doc/man3/OSSL_CMP_CTX_new.pod b/deps/openssl/openssl/doc/man3/OSSL_CMP_CTX_new.pod index cab88ae88c9..f2a38b0adef 100644 --- a/deps/openssl/openssl/doc/man3/OSSL_CMP_CTX_new.pod +++ b/deps/openssl/openssl/doc/man3/OSSL_CMP_CTX_new.pod @@ -355,8 +355,10 @@ If TLS is not used this defaults to the value of the environment variable C if set, else C. Otherwise defaults to the value of C if set, else C. An empty proxy string specifies not to use a proxy. -Else the format is C<[http[s]://]address[:port][/path]>, -where any path given is ignored. +Otherwise the format is +C<[http[s]://][userinfo@]host[:port][/path][?query][#fragment]>, +where any given userinfo, path, query, and fragment is ignored. +If the host string is an IPv6 address, it must be enclosed in C<[> and C<]>. The default port number is 80, or 443 in case C is given. OSSL_CMP_CTX_set1_no_proxy() sets the list of server hostnames not to use diff --git a/deps/openssl/openssl/doc/man3/OSSL_CMP_validate_msg.pod b/deps/openssl/openssl/doc/man3/OSSL_CMP_validate_msg.pod index 555624a4035..c5e68065bef 100644 --- a/deps/openssl/openssl/doc/man3/OSSL_CMP_validate_msg.pod +++ b/deps/openssl/openssl/doc/man3/OSSL_CMP_validate_msg.pod @@ -44,7 +44,7 @@ any self-issued certificate from the I extraCerts field may be used as a trust anchor for the path verification of an 'acceptable' cert if it can be used also to validate the issued certificate returned in the IP message. This is according to TS 33.310 [Network Domain Security (NDS); Authentication Framework -(AF)] document specified by the The 3rd Generation Partnership Project (3GPP). +(AF)] document specified by The 3rd Generation Partnership Project (3GPP). Note that using this option is dangerous as the certificate obtained this way has not been authenticated (at least not at CMP level). Taking it over as a trust anchor implements trust-on-first-use (TOFU). @@ -77,7 +77,7 @@ The OpenSSL CMP support was added in OpenSSL 3.0. =head1 COPYRIGHT -Copyright 2007-2024 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2007-2025 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 diff --git a/deps/openssl/openssl/doc/man3/OSSL_HTTP_parse_url.pod b/deps/openssl/openssl/doc/man3/OSSL_HTTP_parse_url.pod index 768f0acdb14..4379c122d66 100644 --- a/deps/openssl/openssl/doc/man3/OSSL_HTTP_parse_url.pod +++ b/deps/openssl/openssl/doc/man3/OSSL_HTTP_parse_url.pod @@ -42,20 +42,25 @@ take any further default value from the C environment variable, or from C if I is nonzero. If I is NULL, take any default exclusion value from the C environment variable, or else from C. -Return the determined proxy hostname unless the exclusion contains I. +Return the determined proxy host unless the exclusion value, +which is a list of proxy hosts separated by C<,> and/or whitespace, +contains I. Otherwise return NULL. +When I is a string delimited by C<[> and C<]>, which are used for IPv6 +addresses, the enclosing C<[> and C<]> are stripped prior to comparison. OSSL_parse_url() parses its input string I as a URL of the form C<[scheme://][userinfo@]host[:port][/path][?query][#fragment]> and splits it up into scheme, userinfo, host, port, path, query, and fragment components. The host (or server) component may be a DNS name or an IP address -where IPv6 addresses should be enclosed in square brackets C<[> and C<]>. +where IPv6 addresses must be enclosed in square brackets C<[> and C<]>. The port component is optional and defaults to C<0>. If given, it must be in decimal form. If the I argument is not NULL the integer value of the port number is assigned to I<*pport_num> on success. The path component is also optional and defaults to C. Each non-NULL result pointer argument I, I, I, I, I, I, and I, is assigned the respective url component. +Any IPv6 address in I<*phost> is enclosed in C<[> and C<]>. On success, they are guaranteed to contain non-NULL string pointers, else NULL. It is the responsibility of the caller to free them using L. If I is NULL, any given query component is handled as part of the path. @@ -70,7 +75,7 @@ and the scheme is C, else 0. The port component is optional and defaults to C<443> if the scheme is C, else C<80>. Note that relative paths must be given with a leading C, -otherwise the first path element is interpreted as the hostname. +otherwise the first path element is interpreted as the host. Calling the deprecated function OCSP_parse_url(url, host, port, path, ssl) is equivalent to diff --git a/deps/openssl/openssl/doc/man3/OSSL_HTTP_transfer.pod b/deps/openssl/openssl/doc/man3/OSSL_HTTP_transfer.pod index 716e365ef50..6da1d91b9f3 100644 --- a/deps/openssl/openssl/doc/man3/OSSL_HTTP_transfer.pod +++ b/deps/openssl/openssl/doc/man3/OSSL_HTTP_transfer.pod @@ -77,12 +77,14 @@ If TLS is not used this defaults to the environment variable C if set, else C. If I != 0 it defaults to C if set, else C. An empty proxy string C<""> forbids using a proxy. -Else the format is +Otherwise, the format is C<[http[s]://][userinfo@]host[:port][/path][?query][#fragment]>, where any userinfo, path, query, and fragment given is ignored. +If the host string is an IPv6 address, it must be enclosed in C<[> and C<]>. The default proxy port number is 80, or 443 in case "https:" is given. The HTTP client functions connect via the given proxy unless the I -is found in the optional list I of proxy hostnames (if not NULL; +is found in the optional list I of proxy hostnames or IP addresses +separated by C<,> and/or whitespace (if not NULL; default is the environment variable C if set, else C). Proxying plain HTTP is supported directly, while using a proxy for HTTPS connections requires a suitable callback function diff --git a/deps/openssl/openssl/doc/man3/OSSL_PARAM.pod b/deps/openssl/openssl/doc/man3/OSSL_PARAM.pod index 1e5bf06cf76..22fd0f0d7dd 100644 --- a/deps/openssl/openssl/doc/man3/OSSL_PARAM.pod +++ b/deps/openssl/openssl/doc/man3/OSSL_PARAM.pod @@ -11,7 +11,7 @@ OSSL_PARAM - a structure to pass or request object parameters typedef struct ossl_param_st OSSL_PARAM; struct ossl_param_st { const char *key; /* the name of the parameter */ - unsigned char data_type; /* declare what kind of content is in data */ + unsigned int data_type; /* declare what kind of content is in data */ void *data; /* value being passed in or out */ size_t data_size; /* data size */ size_t return_size; /* returned size */ diff --git a/deps/openssl/openssl/doc/man3/OSSL_trace_enabled.pod b/deps/openssl/openssl/doc/man3/OSSL_trace_enabled.pod index f9c9dffd8c6..bad5b151535 100644 --- a/deps/openssl/openssl/doc/man3/OSSL_trace_enabled.pod +++ b/deps/openssl/openssl/doc/man3/OSSL_trace_enabled.pod @@ -88,9 +88,10 @@ but rather uses a set of convenience macros, see the L section below. OSSL_trace_enabled() can be used to check if tracing for the given I is enabled. -OSSL_trace_begin() is used to starts a tracing section, and get the -channel for the given I in form of a BIO. +OSSL_trace_begin() is used to start a tracing section, +and get the channel for the given I in form of a BIO. This BIO can only be used for output. +The pointer returned is NULL if the category is invalid or not enabled. OSSL_trace_end() is used to end a tracing section. @@ -187,6 +188,9 @@ expands to =head1 NOTES +It is not needed to guard trace output function calls like +I by I. + If producing the trace output requires carrying out auxiliary calculations, this auxiliary code should be placed inside a conditional block which is executed only if the trace category is enabled. diff --git a/deps/openssl/openssl/doc/man3/OpenSSL_version.pod b/deps/openssl/openssl/doc/man3/OpenSSL_version.pod index 946bb151baf..e1cf16e2a10 100644 --- a/deps/openssl/openssl/doc/man3/OpenSSL_version.pod +++ b/deps/openssl/openssl/doc/man3/OpenSSL_version.pod @@ -211,14 +211,6 @@ automatically configured but may be set via an environment variable. The value has the same syntax as the environment variable. For x86 the string looks like C. -=item OPENSSL_INFO_QUIC - -This is only defined when compiling with a QUIC-enabled version of -OpenSSL. At run time, this will return "QUIC" if QUIC is supported. - -This can be used as a build time flag to determine if OpenSSL has -QUIC enabled. - =back For an unknown I, NULL is returned. diff --git a/deps/openssl/openssl/doc/man3/SSL_CIPHER_get_name.pod b/deps/openssl/openssl/doc/man3/SSL_CIPHER_get_name.pod index a55ad4d980f..09b7280bdd5 100644 --- a/deps/openssl/openssl/doc/man3/SSL_CIPHER_get_name.pod +++ b/deps/openssl/openssl/doc/man3/SSL_CIPHER_get_name.pod @@ -13,7 +13,6 @@ SSL_CIPHER_get_digest_nid, SSL_CIPHER_get_handshake_digest, SSL_CIPHER_get_kx_nid, SSL_CIPHER_get_auth_nid, -SSL_CIPHER_get_prf_nid, SSL_CIPHER_is_aead, SSL_CIPHER_find, SSL_CIPHER_get_id, @@ -35,7 +34,6 @@ SSL_CIPHER_get_protocol_id const EVP_MD *SSL_CIPHER_get_handshake_digest(const SSL_CIPHER *c); int SSL_CIPHER_get_kx_nid(const SSL_CIPHER *c); int SSL_CIPHER_get_auth_nid(const SSL_CIPHER *c); - int SSL_CIPHER_get_prf_nid(const SSL_CIPHER *c); int SSL_CIPHER_is_aead(const SSL_CIPHER *c); const SSL_CIPHER *SSL_CIPHER_find(SSL *ssl, const unsigned char *ptr); uint32_t SSL_CIPHER_get_id(const SSL_CIPHER *c); @@ -93,15 +91,6 @@ TLS 1.3 cipher suites) B is returned. Examples (not comprehensive) NID_auth_ecdsa NID_auth_psk -SSL_CIPHER_get_prf_nid() retuns the pseudo-random function NID for B. If B is -a pre-TLS-1.2 cipher, it returns B but note these ciphers use -SHA-256 in TLS 1.2. Other return values may be treated uniformly in all -applicable versions. Examples (not comprehensive): - - NID_md5_sha1 - NID_sha256 - NID_sha384 - SSL_CIPHER_is_aead() returns 1 if the cipher B is AEAD (e.g. GCM or ChaCha20/Poly1305), and 0 if it is not AEAD. @@ -212,8 +201,6 @@ required to enable this function. The OPENSSL_cipher_name() function was added in OpenSSL 1.1.1. -The SSL_CIPHER_get_prf_nid() function was added in OpenSSL 3.0.0. - =head1 COPYRIGHT Copyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved. diff --git a/deps/openssl/openssl/doc/man3/SSL_CTX_new.pod b/deps/openssl/openssl/doc/man3/SSL_CTX_new.pod index f467f93659b..627d9e7f0dc 100644 --- a/deps/openssl/openssl/doc/man3/SSL_CTX_new.pod +++ b/deps/openssl/openssl/doc/man3/SSL_CTX_new.pod @@ -104,10 +104,12 @@ On session establishment, by default, no peer credentials verification is done. This must be explicitly requested, typically using L. For verifying peer certificates many options can be set using various functions such as L and L. -The L function can be used, also in conjunction -with L, to set the intended purpose of the session. -The default is B on the client side + +The SSL/(D)TLS implementation uses the L +function to prepare checks for B on the client side and B on the server side. +The L function can be used, also in conjunction +with L, to override the default purpose of the session. The SSL_CTX object uses I as the connection method. Three method variants are available: a generic method (for either client or @@ -228,7 +230,7 @@ SSL_CTX_up_ref() returns 1 for success and 0 for failure. =head1 SEE ALSO -L, L, +L, L, L, SSL_CTX_set_verify(3), L, L, L, L, L, L, L diff --git a/deps/openssl/openssl/doc/man3/SSL_CTX_set_quic_method.pod b/deps/openssl/openssl/doc/man3/SSL_CTX_set_quic_method.pod deleted file mode 100644 index aab5e38889b..00000000000 --- a/deps/openssl/openssl/doc/man3/SSL_CTX_set_quic_method.pod +++ /dev/null @@ -1,262 +0,0 @@ -=pod - -=head1 NAME - -SSL_QUIC_METHOD, -OSSL_ENCRYPTION_LEVEL, -SSL_CTX_set_quic_method, -SSL_set_quic_method, -SSL_set_quic_transport_params, -SSL_get_peer_quic_transport_params, -SSL_quic_max_handshake_flight_len, -SSL_quic_read_level, -SSL_quic_write_level, -SSL_provide_quic_data, -SSL_process_quic_post_handshake, -SSL_is_quic, -SSL_get_peer_quic_transport_version, -SSL_get_quic_transport_version, -SSL_set_quic_transport_version, -SSL_set_quic_use_legacy_codepoint, -SSL_set_quic_early_data_enabled -- QUIC support - -=head1 SYNOPSIS - - #include - - typedef struct ssl_quic_method_st SSL_QUIC_METHOD; - typedef enum ssl_encryption_level_t OSSL_ENCRYPTION_LEVEL; - - int SSL_CTX_set_quic_method(SSL_CTX *ctx, const SSL_QUIC_METHOD *quic_method); - int SSL_set_quic_method(SSL *ssl, const SSL_QUIC_METHOD *quic_method); - int SSL_set_quic_transport_params(SSL *ssl, - const uint8_t *params, - size_t params_len); - void SSL_get_peer_quic_transport_params(const SSL *ssl, - const uint8_t **out_params, - size_t *out_params_len); - size_t SSL_quic_max_handshake_flight_len(const SSL *ssl, OSSL_ENCRYPTION_LEVEL level); - OSSL_ENCRYPTION_LEVEL SSL_quic_read_level(const SSL *ssl); - OSSL_ENCRYPTION_LEVEL SSL_quic_write_level(const SSL *ssl); - int SSL_provide_quic_data(SSL *ssl, OSSL_ENCRYPTION_LEVEL level, - const uint8_t *data, size_t len); - int SSL_process_quic_post_handshake(SSL *ssl); - int SSL_is_quic(SSL *ssl); - - void SSL_set_quic_use_legacy_codepoint(SSL *ssl, int use_legacy); - void SSL_set_quic_transport_version(SSL *ssl, int version); - int SSL_get_quic_transport_version(const SSL *ssl); - int SSL_get_peer_quic_transport_version(const SSL *ssl); - void SSL_set_quic_early_data_enabled(SSL *ssl, int enabled); - -=head1 DESCRIPTION - -SSL_CTX_set_quic_method() and SSL_set_quic_method() configures the QUIC methods. -This should only be configured with a minimum version of TLS 1.3. B -must remain valid for the lifetime of B or B. Calling this disables -the SSL_OP_ENABLE_MIDDLEBOX_COMPAT option, which is not required for QUIC. - -SSL_set_quic_transport_params() configures B to send B (of length -B) in the quic_transport_parameters extension in either the -ClientHello or EncryptedExtensions handshake message. This extension will -only be sent if the TLS version is at least 1.3, and for a server, only if -the client sent the extension. The buffer pointed to by B only need be -valid for the duration of the call to this function. - -SSL_get_peer_quic_transport_params() provides the caller with the value of the -quic_transport_parameters extension sent by the peer. A pointer to the buffer -containing the TransportParameters will be put in B<*out_params>, and its -length in B<*out_params_len>. This buffer will be valid for the lifetime of the -B. If no params were received from the peer, B<*out_params_len> will be 0. - -SSL_quic_max_handshake_flight_len() returns the maximum number of bytes -that may be received at the given encryption level. This function should be -used to limit buffering in the QUIC implementation. - -See L. - -SSL_quic_read_level() returns the current read encryption level. - -SSL_quic_write_level() returns the current write encryption level. - -SSL_provide_quic_data() is used to provide data from QUIC CRYPTO frames to the -state machine, at a particular encryption level B. It is an error to -call this function with an encryption level less than the current read level. -It returns one on success and zero on error. - -SSL_process_quic_post_handshake() processes any data that QUIC has provided -after the handshake has completed. This includes NewSessionTicket messages -sent by the server. - -SSL_is_quic() indicates whether a connection uses QUIC. A given B -or B can only be used with QUIC or TLS, but not both. - -SSL_set_quic_use_legacy_codepoint() specifies the legacy extension codepoint -in manner compatible with some versions of BoringSSL. - -SSL_set_quic_transport_version() specifies the quic transport version that -allows for backwards and forwards compatibility. If set to 0 (default) the -server will use the highest version the client sent. If set to 0 (default) -the client will send both extensions. - -SSL_get_quic_transport_version() returns the value set by -SSL_set_quic_transport_version(). - -SSL_get_peer_quic_transport_version() returns the version the that was -negotiated. - -SSL_set_quic_early_data_enabled() enables QUIC early data if a nonzero -value is passed. Clients must set a resumed session before calling this -function. Servers must additionally call SSL_CTX_set_max_early_data() or -SSL_set_max_early_data() with 0xffffffffu as the argument, so that any -issued session tickets indicate that server is able to accept early data. - -=head1 NOTES - -These APIs are implementations of BoringSSL's QUIC APIs. - -QUIC acts as an underlying transport for the TLS 1.3 handshake. The following -functions allow a QUIC implementation to serve as the underlying transport as -described in RFC9001. - -When configured for QUIC, SSL_do_handshake() will drive the handshake as -before, but it will not use the configured B. It will call functions from -the configured B to configure secrets and send data. If data -is needed from the peer, it will return B. When received, -the caller should call SSL_provide_quic_data() and then SSL_do_handshake() to -continue the handshake. After the handshake is complete, the caller should call -SSL_provide_quic_data() for any post-handshake data, followed by -SSL_process_quic_post_handshake() to process it. It is an error to call -SSL_read()/SSL_read_ex() and SSL_write()/SSL_write_ex() in QUIC. - -Note that secrets for an encryption level may be available to QUIC before the -level is active in TLS. Callers should use SSL_quic_read_level() to determine -the active read level for SSL_provide_quic_data(). SSL_do_handshake() will -pass the active write level to add_handshake_data() when writing data. Callers -can use SSL_quic_write_level() to query the active write level when -generating their own errors. - -See L for more details. - -To avoid amplifying DoS attacks, the QUIC implementation must limit the amount -of data being queued up. The implementation can call -SSL_quic_max_handshake_flight_len() to get the maximum buffer length at each -encryption level. - -RFC9001 defines a new TLS extension "quic_transport_parameters" -used by QUIC for each endpoint to unilaterally declare its supported -transport parameters. The contents of the extension are specified in -L (as -a sequence of tag/length/value parameters) along with the interpretation of the -various parameters and the rules for their processing. - -OpenSSL handles this extension as an opaque byte string. The caller is -responsible for serializing and parsing it. - -=head2 OSSL_ENCRYPTION_LEVEL - -B (B) represents the -encryption levels: - -=over 4 - -=item ssl_encryption_initial - -The initial encryption level that is used for client and server hellos. - -=item ssl_encryption_early_data - -The encryption level for early data. This is a write-level for the client -and a read-level for the server. - -=item ssl_encryption_handshake - -The encryption level for the remainder of the handshake. - -=item ssl_encryption_application - -The encryption level for the application data. - -=back - -=head2 SSL_QUIC_METHOD - -The B (B) describes the -QUIC methods. - - struct ssl_quic_method_st { - int (*set_encryption_secrets)(SSL *ssl, OSSL_ENCRYPTION_LEVEL level, - const uint8_t *read_secret, - const uint8_t *write_secret, size_t secret_len); - int (*add_handshake_data)(SSL *ssl, OSSL_ENCRYPTION_LEVEL level, - const uint8_t *data, size_t len); - int (*flush_flight)(SSL *ssl); - int (*send_alert)(SSL *ssl, enum ssl_encryption_level_t level, uint8_t alert); - }; - typedef struct ssl_quic_method_st SSL_QUIC_METHOD; - -set_encryption_secrets() configures the read and write secrets for the given -encryption level. This function will always be called before an encryption -level other than B is used. Note, however, that -secrets for a level may be configured before TLS is ready to send or accept -data at that level. - -When reading packets at a given level, the QUIC implementation must send -ACKs at the same level, so this function provides read and write secrets -together. The exception is B, where secrets are -only available in the client to server direction. The other secret will be -NULL. The server acknowledges such data at B, -which will be configured in the same SSL_do_handshake() call. - -add_handshake_data() adds handshake data to the current flight at the given -encryption level. It returns one on success and zero on error. - -OpenSSL will pack data from a single encryption level together, but a -single handshake flight may include multiple encryption levels. Callers -should defer writing data to the network until flush_flight() to better -pack QUIC packets into transport datagrams. - -flush_flight() is called when the current flight is complete and should be -written to the transport. Note a flight may contain data at several -encryption levels. - -send_alert() sends a fatal alert at the specified encryption level. - -All QUIC methods return 1 on success and 0 on error. - -=head1 RETURN VALUES - -SSL_CTX_set_quic_method(), -SSL_set_quic_method(), -SSL_set_quic_transport_params(), and -SSL_process_quic_post_handshake() -return 1 on success, and 0 on error. - -SSL_quic_read_level() and SSL_quic_write_level() return the current -encryption level as an B -(B). - -SSL_quic_max_handshake_flight_len() returns the maximum length in bytes of a -flight for a given encryption level. - -SSL_is_quic() returns 1 if QUIC is being used, 0 if not. - -=head1 SEE ALSO - -L, L, L - -=head1 HISTORY - -These functions were added in OpenSSL 3.0.0. - -=head1 COPYRIGHT - -Copyright 2019-2021 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/SSL_get_shared_sigalgs.pod b/deps/openssl/openssl/doc/man3/SSL_get_shared_sigalgs.pod index c18114cdf47..cb9ce025002 100644 --- a/deps/openssl/openssl/doc/man3/SSL_get_shared_sigalgs.pod +++ b/deps/openssl/openssl/doc/man3/SSL_get_shared_sigalgs.pod @@ -64,7 +64,7 @@ ordered according to configuration and peer preferences. The raw values correspond to the on the wire form as defined by RFC5246 et al. The NIDs are OpenSSL equivalents. For example if the peer sent sha256(4) and rsa(1) then B<*rhash> would be 4, B<*rsign> 1, B<*phash> NID_sha256, B<*psig> -NID_rsaEncryption and B<*psighash> NID_sha256WithRSAEncryption. +NID_rsaEncryption and B<*psignhash> NID_sha256WithRSAEncryption. If a signature algorithm is not recognised the corresponding NIDs will be set to B. This may be because the value is not supported, diff --git a/deps/openssl/openssl/doc/man3/SSL_set_bio.pod b/deps/openssl/openssl/doc/man3/SSL_set_bio.pod index c666dc466ec..aaffeedf779 100644 --- a/deps/openssl/openssl/doc/man3/SSL_set_bio.pod +++ b/deps/openssl/openssl/doc/man3/SSL_set_bio.pod @@ -23,6 +23,9 @@ function, any existing B that was previously set will also be freed via a call to L (this includes the case where the B is set to the same value as previously). +If using a custom BIO, B must implement either +L or L. + SSL_set0_wbio() works in the same as SSL_set0_rbio() except that it connects the BIO B for the write operations of the B object. Note that if the rbio and wbio are the same then SSL_set0_rbio() and SSL_set0_wbio() each take @@ -30,6 +33,12 @@ ownership of one reference. Therefore, it may be necessary to increment the number of references available using L before calling the set0 functions. +If using a custom BIO, B must implement +L or L. It additionally must +implement L using B and L. +If flushing is unnecessary with B, L should return one and +do nothing. + SSL_set_bio() is similar to SSL_set0_rbio() and SSL_set0_wbio() except that it connects both the B and the B at the same time, and transfers the ownership of B and B to B according to diff --git a/deps/openssl/openssl/doc/man3/X509V3_set_ctx.pod b/deps/openssl/openssl/doc/man3/X509V3_set_ctx.pod index 8287802e41b..7819c344f75 100644 --- a/deps/openssl/openssl/doc/man3/X509V3_set_ctx.pod +++ b/deps/openssl/openssl/doc/man3/X509V3_set_ctx.pod @@ -42,8 +42,7 @@ or not) to provide fallback data for the authority key identifier extension. =head1 RETURN VALUES -X509V3_set_ctx() and X509V3_set_issuer_pkey() -return 1 on success and 0 on error. +X509V3_set_issuer_pkey() returns 1 on success and 0 on error. =head1 SEE ALSO @@ -57,7 +56,7 @@ CTX_TEST was deprecated in OpenSSL 3.0; use X509V3_CTX_TEST instead. =head1 COPYRIGHT -Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2015-2025 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 diff --git a/deps/openssl/openssl/doc/man3/X509_STORE_CTX_new.pod b/deps/openssl/openssl/doc/man3/X509_STORE_CTX_new.pod index c508a1d3fc1..9929a98e0cf 100644 --- a/deps/openssl/openssl/doc/man3/X509_STORE_CTX_new.pod +++ b/deps/openssl/openssl/doc/man3/X509_STORE_CTX_new.pod @@ -74,6 +74,12 @@ X509_STORE_CTX_free() completely frees up I. After this call I is no longer valid. If I is NULL nothing is done. +X509_STORE_CTX_init() sets up I for a subsequent verification operation. + +X509_STORE_CTX_init() initializes the internal state and resources of the +given I. Among others, it sets the verification parameters associcated +with the method name C, which includes the C purpose, +and takes over callback function pointers from I (unless NULL). It must be called before each call to L or L, i.e., a context is only good for one verification. If you want to verify a further certificate or chain with the same I @@ -144,12 +150,13 @@ by I to be I. Ownership of the chain is transferred to I, and so it should not be free'd by the caller. -X509_STORE_CTX_set_default() looks up and sets the default verification -method to I. This uses the function X509_VERIFY_PARAM_lookup() to -find an appropriate set of parameters from the purpose identifier I. -Currently defined purposes are C, C, C, -C, C, C, C, C, -and C. +X509_STORE_CTX_set_default() looks up and sets the default verification method. +This uses the function X509_VERIFY_PARAM_lookup() to find +the set of parameters associated with the given verification method I. +Among others, the parameters determine the trust model and verification purpose. +More detail, including the list of currently predefined methods, +is described for the B<-verify_name> command-line option +in L. X509_STORE_CTX_set_verify() provides the capability for overriding the default verify function. This function is responsible for verifying chain signatures and diff --git a/deps/openssl/openssl/doc/man3/X509_add_cert.pod b/deps/openssl/openssl/doc/man3/X509_add_cert.pod index 907164e9710..f59b93ba54d 100644 --- a/deps/openssl/openssl/doc/man3/X509_add_cert.pod +++ b/deps/openssl/openssl/doc/man3/X509_add_cert.pod @@ -16,6 +16,7 @@ X509 certificate list addition functions =head1 DESCRIPTION X509_add_cert() adds a certificate I to the given list I. +It is an error for the I argument to be NULL. X509_add_certs() adds a list of certificate I to the given list I. The I argument may be NULL, which implies no effect. @@ -66,7 +67,7 @@ were added in OpenSSL 3.0. =head1 COPYRIGHT -Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2019-2025 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 diff --git a/deps/openssl/openssl/doc/man3/X509_load_http.pod b/deps/openssl/openssl/doc/man3/X509_load_http.pod index a147c43caa3..e17330b0558 100644 --- a/deps/openssl/openssl/doc/man3/X509_load_http.pod +++ b/deps/openssl/openssl/doc/man3/X509_load_http.pod @@ -27,6 +27,9 @@ see L: X509_load_http() and X509_CRL_load_http() loads a certificate or a CRL, respectively, in ASN.1 format using HTTP from the given B. +Maximum size of the HTTP response is 100 kB for certificates and 32 MB for CRLs +and hard coded in the functions. + If B is given and B is NULL then this BIO is used instead of an internal one for connecting, writing the request, and reading the response. If both B and B are given (which may be memory BIOs, for instance) diff --git a/deps/openssl/openssl/doc/man7/EVP_KDF-HKDF.pod b/deps/openssl/openssl/doc/man7/EVP_KDF-HKDF.pod index 5fc0a73241c..b563efa5f5d 100644 --- a/deps/openssl/openssl/doc/man7/EVP_KDF-HKDF.pod +++ b/deps/openssl/openssl/doc/man7/EVP_KDF-HKDF.pod @@ -15,6 +15,8 @@ and "extracts" from it a fixed-length pseudorandom key K. The second stage "expands" the key K into several additional pseudorandom keys (the output of the KDF). +The output is considered to be keying material. + =head2 Identity "HKDF" is the name for this implementation; it diff --git a/deps/openssl/openssl/doc/man7/EVP_KDF-KB.pod b/deps/openssl/openssl/doc/man7/EVP_KDF-KB.pod index 6e25882d674..78b81673a5b 100644 --- a/deps/openssl/openssl/doc/man7/EVP_KDF-KB.pod +++ b/deps/openssl/openssl/doc/man7/EVP_KDF-KB.pod @@ -10,6 +10,8 @@ The EVP_KDF-KB algorithm implements the Key-Based key derivation function (KBKDF). KBKDF derives a key from repeated application of a keyed MAC to an input secret (and other optional values). +The output is considered to be keying material. + =head2 Identity "KBKDF" is the name for this implementation; it can be used with the diff --git a/deps/openssl/openssl/doc/man7/EVP_KDF-PBKDF2.pod b/deps/openssl/openssl/doc/man7/EVP_KDF-PBKDF2.pod index e6cadc8b826..9a90f7583ab 100644 --- a/deps/openssl/openssl/doc/man7/EVP_KDF-PBKDF2.pod +++ b/deps/openssl/openssl/doc/man7/EVP_KDF-PBKDF2.pod @@ -13,6 +13,8 @@ The EVP_KDF-PBKDF2 algorithm implements the PBKDF2 password-based key derivation function, as described in SP800-132; it derives a key from a password using a salt and iteration count. +The output is considered to be a cryptographic key. + =head2 Identity "PBKDF2" is the name for this implementation; it diff --git a/deps/openssl/openssl/doc/man7/EVP_KDF-SS.pod b/deps/openssl/openssl/doc/man7/EVP_KDF-SS.pod index c8d19691a79..6640703eef1 100644 --- a/deps/openssl/openssl/doc/man7/EVP_KDF-SS.pod +++ b/deps/openssl/openssl/doc/man7/EVP_KDF-SS.pod @@ -11,6 +11,8 @@ SSKDF derives a key using input such as a shared secret key (that was generated during the execution of a key establishment scheme) and fixedinfo. SSKDF is also informally referred to as 'Concat KDF'. +The output is considered to be keying material. + =head2 Auxiliary function The implementation uses a selectable auxiliary function H, which can be one of: diff --git a/deps/openssl/openssl/doc/man7/EVP_KDF-SSHKDF.pod b/deps/openssl/openssl/doc/man7/EVP_KDF-SSHKDF.pod index c7a3263f455..a5b15394755 100644 --- a/deps/openssl/openssl/doc/man7/EVP_KDF-SSHKDF.pod +++ b/deps/openssl/openssl/doc/man7/EVP_KDF-SSHKDF.pod @@ -15,6 +15,8 @@ Five inputs are required to perform key derivation: The hashing function (for example SHA256), the Initial Key, the Exchange Hash, the Session ID, and the derivation key type. +The output is considered to be keying material. + =head2 Identity "SSHKDF" is the name for this implementation; it diff --git a/deps/openssl/openssl/doc/man7/EVP_KDF-TLS13_KDF.pod b/deps/openssl/openssl/doc/man7/EVP_KDF-TLS13_KDF.pod index d588b121faf..7fad55ca61f 100644 --- a/deps/openssl/openssl/doc/man7/EVP_KDF-TLS13_KDF.pod +++ b/deps/openssl/openssl/doc/man7/EVP_KDF-TLS13_KDF.pod @@ -12,6 +12,8 @@ the B API. The EVP_KDF-TLS13_KDF algorithm implements the HKDF key derivation function as used by TLS 1.3. +The output is considered to be keying material. + =head2 Identity "TLS13-KDF" is the name for this implementation; it diff --git a/deps/openssl/openssl/doc/man7/EVP_KDF-TLS1_PRF.pod b/deps/openssl/openssl/doc/man7/EVP_KDF-TLS1_PRF.pod index 8a60e973155..90b357e70f0 100644 --- a/deps/openssl/openssl/doc/man7/EVP_KDF-TLS1_PRF.pod +++ b/deps/openssl/openssl/doc/man7/EVP_KDF-TLS1_PRF.pod @@ -11,6 +11,8 @@ Support for computing the B PRF through the B API. The EVP_KDF-TLS1_PRF algorithm implements the PRF used by TLS versions up to and including TLS 1.2. +The output is considered to be keying material. + =head2 Identity "TLS1-PRF" is the name for this implementation; it diff --git a/deps/openssl/openssl/doc/man7/EVP_KDF-X942-ASN1.pod b/deps/openssl/openssl/doc/man7/EVP_KDF-X942-ASN1.pod index a5786ab83fa..17464738b51 100644 --- a/deps/openssl/openssl/doc/man7/EVP_KDF-X942-ASN1.pod +++ b/deps/openssl/openssl/doc/man7/EVP_KDF-X942-ASN1.pod @@ -13,6 +13,8 @@ contains a 32 bit counter as well as optional fields for "partyu-info", "partyv-info", "supp-pubinfo" and "supp-privinfo". This kdf is used by Cryptographic Message Syntax (CMS). +The output is considered to be keying material. + =head2 Identity "X942KDF-ASN1" or "X942KDF" is the name for this implementation; it diff --git a/deps/openssl/openssl/doc/man7/EVP_KDF-X963.pod b/deps/openssl/openssl/doc/man7/EVP_KDF-X963.pod index 3d6f4372cf3..ca2f7c1df0e 100644 --- a/deps/openssl/openssl/doc/man7/EVP_KDF-X963.pod +++ b/deps/openssl/openssl/doc/man7/EVP_KDF-X963.pod @@ -10,6 +10,8 @@ The EVP_KDF-X963 algorithm implements the key derivation function (X963KDF). X963KDF is used by Cryptographic Message Syntax (CMS) for EC KeyAgreement, to derive a key using input such as a shared secret key and shared info. +The output is considered to be keying material. + =head2 Identity "X963KDF" is the name for this implementation; it diff --git a/deps/openssl/openssl/doc/man7/EVP_SIGNATURE-DSA.pod b/deps/openssl/openssl/doc/man7/EVP_SIGNATURE-DSA.pod index 5a42d6b1cd2..326a86ee0b4 100644 --- a/deps/openssl/openssl/doc/man7/EVP_SIGNATURE-DSA.pod +++ b/deps/openssl/openssl/doc/man7/EVP_SIGNATURE-DSA.pod @@ -7,7 +7,9 @@ EVP_SIGNATURE-DSA =head1 DESCRIPTION -Support for computing DSA signatures. +Support for computing DSA signatures. The signature produced with +L is DER encoded ASN.1 in the form described in +RFC 3279, section 2.2.2. See L for information related to DSA keys. =head2 Signature Parameters diff --git a/deps/openssl/openssl/doc/man7/openssl-env.pod b/deps/openssl/openssl/doc/man7/openssl-env.pod index a2443d54d82..c7dbd2277dc 100644 --- a/deps/openssl/openssl/doc/man7/openssl-env.pod +++ b/deps/openssl/openssl/doc/man7/openssl-env.pod @@ -51,6 +51,99 @@ See L. Specifies the directory from which cryptographic providers are loaded. Equivalently, the generic B<-provider-path> command-line option may be used. +=item B + +By default the OpenSSL trace feature is disabled statically. +To enable it, OpenSSL must be built with tracing support, +which may be configured like this: C<./config enable-trace> + +Unless OpenSSL tracing support is generally disabled, +enable trace output of specific parts of OpenSSL libraries, by name. +This output usually makes sense only if you know OpenSSL internals well. + +The value of this environment varialble is a comma-separated list of names, +with the following available: + +=over 4 + +=item B + +Traces the OpenSSL trace API itself. + +=item B + +Traces OpenSSL library initialization and cleanup. + +=item B + +Traces the TLS/SSL protocol. + +=item B + +Traces the ciphers used by the TLS/SSL protocol. + +=item B + +Show details about provider and engine configuration. + +=item B + +The function that is used by RSA, DSA (etc) code to select registered +ENGINEs, cache defaults and functional references (etc), will generate +debugging summaries. + +=item B + +Reference counts in the ENGINE structure will be monitored with a line +of generated for each change. + +=item B + +Traces PKCS#5 v2 key generation. + +=item B + +Traces PKCS#12 key generation. + +=item B + +Traces PKCS#12 decryption. + +=item B + +Generates the complete policy tree at various points during X.509 v3 +policy evaluation. + +=item B + +Traces BIGNUM context operations. + +=item B + +Traces CMP client and server activity. + +=item B + +Traces STORE operations. + +=item B + +Traces decoder operations. + +=item B + +Traces encoder operations. + +=item B + +Traces decrementing certain ASN.1 structure references. + +=item B + +Traces the HTTP client and server, such as messages being sent and received. + +=back + =item B If set, then L returns UTF-8 encoded strings, rather than diff --git a/deps/openssl/openssl/doc/man7/provider.pod b/deps/openssl/openssl/doc/man7/provider.pod index a061fc4709d..08ac1d02907 100644 --- a/deps/openssl/openssl/doc/man7/provider.pod +++ b/deps/openssl/openssl/doc/man7/provider.pod @@ -227,6 +227,18 @@ MODE is only present where applicable. Other aliases may exist for example where standards bodies or common practice use alternative names or names that OpenSSL has used historically. +=head3 Provider dependencies + +Providers may depend for their proper operation on the availability of +(functionality implemented in) other providers. As there is no mechanism to +express such dependencies towards the OpenSSL core, provider authors must +take care that such dependencies are either completely avoided or made visible +to users, e.g., by documentation and/or defensive programming, e.g., +outputting error messages if required external dependencies are not available, +e.g., when no provider implementing the required functionality has been +activated. In particular, provider initialization should not depend on other +providers already having been initialized. + =head1 OPENSSL PROVIDERS OpenSSL provides a number of its own providers. These are the default, base, diff --git a/deps/openssl/openssl/engines/e_afalg.c b/deps/openssl/openssl/engines/e_afalg.c index ec4e21c582c..58d58ef24ec 100644 --- a/deps/openssl/openssl/engines/e_afalg.c +++ b/deps/openssl/openssl/engines/e_afalg.c @@ -1,5 +1,5 @@ /* - * Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2025 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 @@ -165,7 +165,7 @@ static ossl_inline int io_getevents(aio_context_t ctx, long min, long max, ts32.tv_sec = (__kernel_long_t) timeout->tv_sec; ts32.tv_nsec = (__kernel_long_t) timeout->tv_nsec; - return syscall(__NR_io_getevents, ctx, min, max, events, ts32); + return syscall(__NR_io_getevents, ctx, min, max, events, &ts32); } else { return syscall(__NR_io_getevents, ctx, min, max, events, NULL); } diff --git a/deps/openssl/openssl/engines/e_loader_attic.c b/deps/openssl/openssl/engines/e_loader_attic.c index a20e04da1a5..08c9c16cbbf 100644 --- a/deps/openssl/openssl/engines/e_loader_attic.c +++ b/deps/openssl/openssl/engines/e_loader_attic.c @@ -988,7 +988,7 @@ static OSSL_STORE_LOADER_CTX *file_open_ex #ifdef _WIN32 /* Windows file: URIs with a drive letter start with a / */ if (p[0] == '/' && p[2] == ':' && p[3] == '/') { - char c = tolower(p[1]); + char c = tolower((unsigned char)p[1]); if (c >= 'a' && c <= 'z') { p++; diff --git a/deps/openssl/openssl/include/crypto/bn.h b/deps/openssl/openssl/include/crypto/bn.h index c5f328156d3..0b8489bb755 100644 --- a/deps/openssl/openssl/include/crypto/bn.h +++ b/deps/openssl/openssl/include/crypto/bn.h @@ -1,5 +1,5 @@ /* - * Copyright 2014-2024 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2014-2025 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 @@ -73,6 +73,9 @@ int bn_set_words(BIGNUM *a, const BN_ULONG *words, int num_words); */ int bn_mul_mont_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_MONT_CTX *mont, BN_CTX *ctx); +int bn_mod_exp_mont_fixed_top(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *in_mont); int bn_to_mont_fixed_top(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, BN_CTX *ctx); int bn_from_mont_fixed_top(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, diff --git a/deps/openssl/openssl/include/crypto/cmserr.h b/deps/openssl/openssl/include/crypto/cmserr.h index 1de2f9c7d51..f53530ae235 100644 --- a/deps/openssl/openssl/include/crypto/cmserr.h +++ b/deps/openssl/openssl/include/crypto/cmserr.h @@ -1,6 +1,6 @@ /* * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2020-2025 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 diff --git a/deps/openssl/openssl/include/openssl/cmserr.h b/deps/openssl/openssl/include/openssl/cmserr.h index f2d7708f10c..52a186520fe 100644 --- a/deps/openssl/openssl/include/openssl/cmserr.h +++ b/deps/openssl/openssl/include/openssl/cmserr.h @@ -1,6 +1,6 @@ /* * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2025 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 @@ -49,6 +49,7 @@ # define CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE 114 # define CMS_R_ERROR_SETTING_KEY 115 # define CMS_R_ERROR_SETTING_RECIPIENTINFO 116 +# define CMS_R_ERROR_UNSUPPORTED_STATIC_KEY_AGREEMENT 196 # define CMS_R_ESS_SIGNING_CERTID_MISMATCH_ERROR 183 # define CMS_R_INVALID_ENCRYPTED_KEY_LENGTH 117 # define CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER 176 diff --git a/deps/openssl/openssl/include/openssl/http.h b/deps/openssl/openssl/include/openssl/http.h index f7ab214265e..c63762b70de 100644 --- a/deps/openssl/openssl/include/openssl/http.h +++ b/deps/openssl/openssl/include/openssl/http.h @@ -33,8 +33,9 @@ extern "C" { # define OPENSSL_HTTP_PROXY "HTTP_PROXY" # define OPENSSL_HTTPS_PROXY "HTTPS_PROXY" -#define OSSL_HTTP_DEFAULT_MAX_LINE_LEN (4 * 1024) -#define OSSL_HTTP_DEFAULT_MAX_RESP_LEN (100 * 1024) +# define OSSL_HTTP_DEFAULT_MAX_LINE_LEN (4 * 1024) +# define OSSL_HTTP_DEFAULT_MAX_RESP_LEN (100 * 1024) +# define OSSL_HTTP_DEFAULT_MAX_CRL_LEN (32 * 1024 * 1024) /* Low-level HTTP API */ OSSL_HTTP_REQ_CTX *OSSL_HTTP_REQ_CTX_new(BIO *wbio, BIO *rbio, int buf_size); diff --git a/deps/openssl/openssl/include/openssl/quic.h b/deps/openssl/openssl/include/openssl/quic.h deleted file mode 100644 index f95e9e8819e..00000000000 --- a/deps/openssl/openssl/include/openssl/quic.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2018-2021 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 - * https://www.openssl.org/source/license.html - */ - -#ifndef OPENSSL_QUIC_H -# define OPENSSL_QUIC_H -# pragma once -# ifndef OPENSSL_NO_QUIC - -/* moved from crypto.h.in to avoid breaking FIPS checksums */ -# define OPENSSL_INFO_QUIC 2000 - -# endif /* OPENSSL_NO_QUIC */ -#endif /* OPENSSL_QUIC_H */ diff --git a/deps/openssl/openssl/include/openssl/ssl.h.in b/deps/openssl/openssl/include/openssl/ssl.h.in index 677a20be15d..105b4a4a3c8 100644 --- a/deps/openssl/openssl/include/openssl/ssl.h.in +++ b/deps/openssl/openssl/include/openssl/ssl.h.in @@ -2521,75 +2521,6 @@ void SSL_set_allow_early_data_cb(SSL *s, const char *OSSL_default_cipher_list(void); const char *OSSL_default_ciphersuites(void); -# ifndef OPENSSL_NO_QUIC -/* - * QUIC integration - The QUIC interface matches BoringSSL - * - * ssl_encryption_level_t represents a specific QUIC encryption level used to - * transmit handshake messages. BoringSSL has this as an 'enum'. - */ -#include - -/* Used by Chromium/QUIC - moved from evp.h to avoid breaking FIPS checksums */ -# define X25519_PRIVATE_KEY_LEN 32 -# define X25519_PUBLIC_VALUE_LEN 32 - -/* moved from types.h to avoid breaking FIPS checksums */ -typedef struct ssl_quic_method_st SSL_QUIC_METHOD; - -typedef enum ssl_encryption_level_t { - ssl_encryption_initial = 0, - ssl_encryption_early_data, - ssl_encryption_handshake, - ssl_encryption_application -} OSSL_ENCRYPTION_LEVEL; - -struct ssl_quic_method_st { - int (*set_encryption_secrets)(SSL *ssl, OSSL_ENCRYPTION_LEVEL level, - const uint8_t *read_secret, - const uint8_t *write_secret, size_t secret_len); - int (*add_handshake_data)(SSL *ssl, OSSL_ENCRYPTION_LEVEL level, - const uint8_t *data, size_t len); - int (*flush_flight)(SSL *ssl); - int (*send_alert)(SSL *ssl, enum ssl_encryption_level_t level, uint8_t alert); -}; - -__owur int SSL_CTX_set_quic_method(SSL_CTX *ctx, const SSL_QUIC_METHOD *quic_method); -__owur int SSL_set_quic_method(SSL *ssl, const SSL_QUIC_METHOD *quic_method); -__owur int SSL_set_quic_transport_params(SSL *ssl, - const uint8_t *params, - size_t params_len); -void SSL_get_peer_quic_transport_params(const SSL *ssl, - const uint8_t **out_params, - size_t *out_params_len); -__owur size_t SSL_quic_max_handshake_flight_len(const SSL *ssl, OSSL_ENCRYPTION_LEVEL level); -__owur OSSL_ENCRYPTION_LEVEL SSL_quic_read_level(const SSL *ssl); -__owur OSSL_ENCRYPTION_LEVEL SSL_quic_write_level(const SSL *ssl); -__owur int SSL_provide_quic_data(SSL *ssl, OSSL_ENCRYPTION_LEVEL level, - const uint8_t *data, size_t len); -__owur int SSL_process_quic_post_handshake(SSL *ssl); - -__owur int SSL_is_quic(SSL *ssl); - -/* BoringSSL API */ -void SSL_set_quic_use_legacy_codepoint(SSL *ssl, int use_legacy); - -/* - * Set an explicit value that you want to use - * If 0 (default) the server will use the highest extenstion the client sent - * If 0 (default) the client will send both extensions - */ -void SSL_set_quic_transport_version(SSL *ssl, int version); -__owur int SSL_get_quic_transport_version(const SSL *ssl); -/* Returns the negotiated version, or -1 on error */ -__owur int SSL_get_peer_quic_transport_version(const SSL *ssl); - -int SSL_CIPHER_get_prf_nid(const SSL_CIPHER *c); - -void SSL_set_quic_early_data_enabled(SSL *ssl, int enabled); - -# endif - # ifdef __cplusplus } # endif diff --git a/deps/openssl/openssl/include/openssl/sslerr.h b/deps/openssl/openssl/include/openssl/sslerr.h index b159ef8127c..1e36405e32c 100644 --- a/deps/openssl/openssl/include/openssl/sslerr.h +++ b/deps/openssl/openssl/include/openssl/sslerr.h @@ -161,7 +161,6 @@ # define SSL_R_MISSING_FATAL 256 # define SSL_R_MISSING_PARAMETERS 290 # define SSL_R_MISSING_PSK_KEX_MODES_EXTENSION 310 -# define SSL_R_MISSING_QUIC_TRANSPORT_PARAMETERS_EXTENSION 801 # define SSL_R_MISSING_RSA_CERTIFICATE 168 # define SSL_R_MISSING_RSA_ENCRYPTING_CERT 169 # define SSL_R_MISSING_RSA_SIGNING_CERT 170 @@ -336,7 +335,6 @@ # define SSL_R_WRONG_CERTIFICATE_TYPE 383 # define SSL_R_WRONG_CIPHER_RETURNED 261 # define SSL_R_WRONG_CURVE 378 -# define SSL_R_WRONG_ENCRYPTION_LEVEL_RECEIVED 800 # define SSL_R_WRONG_SIGNATURE_LENGTH 264 # define SSL_R_WRONG_SIGNATURE_SIZE 265 # define SSL_R_WRONG_SIGNATURE_TYPE 370 diff --git a/deps/openssl/openssl/include/openssl/tls1.h b/deps/openssl/openssl/include/openssl/tls1.h index d005d3c16df..91558fa8d1a 100644 --- a/deps/openssl/openssl/include/openssl/tls1.h +++ b/deps/openssl/openssl/include/openssl/tls1.h @@ -151,10 +151,6 @@ extern "C" { /* Temporary extension type */ # define TLSEXT_TYPE_renegotiate 0xff01 - /* ExtensionType value from RFC9001 */ -# define TLSEXT_TYPE_quic_transport_parameters_draft 0xffa5 -# define TLSEXT_TYPE_quic_transport_parameters 0x0039 - # ifndef OPENSSL_NO_NEXTPROTONEG /* This is not an IANA defined extension number */ # define TLSEXT_TYPE_next_proto_neg 13172 diff --git a/deps/openssl/openssl/providers/fips-sources.checksums b/deps/openssl/openssl/providers/fips-sources.checksums index 2075eca274d..1ab5d0348c6 100644 --- a/deps/openssl/openssl/providers/fips-sources.checksums +++ b/deps/openssl/openssl/providers/fips-sources.checksums @@ -4,71 +4,71 @@ c049a936d74100fcced225f575d46662792a6a0039777d2d4df0cf61eff90a68 crypto/aes/aes c1e674d08683a25bc053f6233f73a0d0b3a90aafe591ff57b702c7da1582e4a5 crypto/aes/aes_local.h a2466f18da5847c7d9fbced17524633c10ce024671a72f53f9c9c55b9b9923dd crypto/aes/aes_misc.c 6979c133f76f4623e62e6e970deae70fa025e713a72b71aead5a048d49e47f6f crypto/aes/asm/aes-586.pl -2eef5f20f1410b48bdaaafa24ded24f56f34c4ca79db1d38fa6bf1b3b19535bf crypto/aes/asm/aes-armv4.pl -38c2cf8ed3910efd89d8721e1b0763a8fde073b91f6529d251165a0496ef9555 crypto/aes/asm/aes-c64xplus.pl +92be9ff608331a432e95247a8f4fb9e46897d0cb76f2b6db809b61d44287964a crypto/aes/asm/aes-armv4.pl +953897f86e2de9fa27ef411155ab3aed133af94885f1507e76449c142da78656 crypto/aes/asm/aes-c64xplus.pl 00196f01f5218ad731e6a058d406078f7228a9756d9d73f51c0d0c2a68f885af crypto/aes/asm/aes-ia64.S -b4ef595194fe1692e1ab2b561f385da01b277cf004902e8fc99e8ac5389bbd35 crypto/aes/asm/aes-mips.pl -123c4498c94040b70708fdd911cb08c6411b020b4cf3eb761d6fa22c583c3e6f crypto/aes/asm/aes-parisc.pl -7a7f2f90791415ef4ffc1ba2a6f6b6fe994bfe0e03d3bf9dab6e428e6874695c crypto/aes/asm/aes-ppc.pl -d139e5ad69560fd0ffd8aa2e72304e463650cea4c657be7a90e0d1eb782d580a crypto/aes/asm/aes-s390x.pl -133ba35d77002abcd430414749c4e98c4a319630da898e45ff8dbc5800176df1 crypto/aes/asm/aes-sparcv9.pl -c98690249d490d23e6fee84f672f1463ffc029427110a4329244a59e4e4aaed8 crypto/aes/asm/aes-x86_64.pl -7ec99947b47e56595f0b085b8bda0b3113112f694e78b1f71b63ecd1f0fa2c67 crypto/aes/asm/aesfx-sparcv9.pl -ab94a27e533e164bcf09898a6f6019f43609d51a3b374cf75482dcf2914d464e crypto/aes/asm/aesni-mb-x86_64.pl -74939261340a0056eb9333fff1c843c8758b9f93de3d94650cd6d2899c6790d8 crypto/aes/asm/aesni-sha1-x86_64.pl -ce91f0893a2a35fdf4c024ccb0fd8329b30fdbd955f0ae011ab948101ee14951 crypto/aes/asm/aesni-sha256-x86_64.pl +88b6f8396cd9d86004743d5c3b0f72b7b8c3d5a2b00b0bbb761ba91ae5a7cdc8 crypto/aes/asm/aes-mips.pl +7ff9c96ef3d591d45d776fa4b244601ea0d9328e289aeab1e1b92436ce7d02ad crypto/aes/asm/aes-parisc.pl +f1244cdeadcb4e48f35bc5df19d4cfaf07e0086ad951b84f07ff6966501faa5b crypto/aes/asm/aes-ppc.pl +ecbfe826f4c514810c3ee20e265f4f621149694c298554b2682e5de4f029f14f crypto/aes/asm/aes-s390x.pl +ee4e8cacef972942d2a89c1a83c984df9cad87c61a54383403c5c4864c403ba1 crypto/aes/asm/aes-sparcv9.pl +2b3b9ac56bf54334d053857a24bdb08592151e8a7a60b89b8195846b7f8ee7b5 crypto/aes/asm/aes-x86_64.pl +c56c324667b67d726e040d70379efba5b270e2937f403c1b5979018b836903c7 crypto/aes/asm/aesfx-sparcv9.pl +14359dc32b7f4e5c08227fb9ac8f9232c1287399463b233fec4a2ab0c19f68d1 crypto/aes/asm/aesni-mb-x86_64.pl +2fe016e8098d1c959b6199ce98e91dfed9a3a543d6b068daf88d4c4c402701ec crypto/aes/asm/aesni-sha1-x86_64.pl +1d3acabadedb88d1327eeb76201ea9b3f4814f44898018ffae6c73e3f400b89b crypto/aes/asm/aesni-sha256-x86_64.pl 4ff74d4e629a88ef5a9e3d3f5b340fc0a4793d16d7cc7f1b70da62512a856248 crypto/aes/asm/aesni-x86.pl -30103cfe3b29d06b34feff48a927e0fa649e9109d35a3db64b09cfeb15426fa2 crypto/aes/asm/aesni-x86_64.pl -f3490c936a80e012c49e577ec6e1d4d36df324dfef6264e788e6225e20b5fd52 crypto/aes/asm/aesp8-ppc.pl -a5807ed92ec8a16d123061487c385bf1f65e50878cee95c8e8096844454129f8 crypto/aes/asm/aest4-sparcv9.pl -d34cf129a8c63e2b77a74117ed4440a4f35408dabd90e21e70eae92d208fa516 crypto/aes/asm/aesv8-armx.pl -a0b578b7d2787c91013547df07dfa73d8d7a420446dd624c66f7c55159817eb2 crypto/aes/asm/bsaes-armv7.pl -34accd08242a6bf4a751105f89b0c4de2cd7e54320753587815647abff7124de crypto/aes/asm/bsaes-x86_64.pl -d9bc047db9b2f54f27fe0d6e2ede9239b4a1f57a14bf89fa3cfba6b836599386 crypto/aes/asm/vpaes-armv8.pl -516421b1a321b842f879ad69e7b82ae3e1f3efc8288c83bb34d6577996e85787 crypto/aes/asm/vpaes-ppc.pl +c7c6694480bb5319690f94826139a93f5c460ebea6dba101b520a76cb956ec93 crypto/aes/asm/aesni-x86_64.pl +0489a10fbb1a8ca3652848d5c1e14e519501e189bad3e5827a573c26df359691 crypto/aes/asm/aesp8-ppc.pl +e397a5781893e97dd90a5a52049633be12a43f379ec5751bca2a6350c39444c8 crypto/aes/asm/aest4-sparcv9.pl +e3955352a92d56905d63e68937e4758f13190a14a10a3dcb1e5c641c49913c0c crypto/aes/asm/aesv8-armx.pl +5e8005fdb6641df465bdda20c3476f7176e6bcd63d5073044a0c02a327c7f172 crypto/aes/asm/bsaes-armv7.pl +0726a2c4c15c27a12b2f7d5e16863df4a1b1daa7b7d9b728f621b2b224d290e6 crypto/aes/asm/bsaes-x86_64.pl +1ff94d6bf6c8ae4809f64657eb89260fe3cb22137f649d3c73f72cb190258196 crypto/aes/asm/vpaes-armv8.pl +c3541865cd02d81101cdbab4877ed82772e6980d2c677b9008b38fa1b26d36d4 crypto/aes/asm/vpaes-ppc.pl 3ec24185750a995377516bc2fb2eae8b1c52094c6fff093bff591837fc12d6c3 crypto/aes/asm/vpaes-x86.pl -47bedbe6a04254eede121e71f11a657b1f1940aee1916bbfc04fa9fb8454f9b8 crypto/aes/asm/vpaes-x86_64.pl -1c9a2a0e8cee4a1283c74b2e306f46f79890f6d236394de2a80d1994fd411d1d crypto/alphacpuid.pl -7a37cadacdbecb50304228dfcb087ad7fbb6e31f6ab69c52dd161e79afb2f9ca crypto/arm64cpuid.pl +060bb6620f50af9afecdf97df051b45b9a50be9daf343dfec1cbb29693ce00a4 crypto/aes/asm/vpaes-x86_64.pl +2bc67270155e2d6c7da87d9070e005ee79cea18311004907edfd6a078003532a crypto/alphacpuid.pl +0255a480b78bdcc71f76676f496962a9828eb900f53b7be13be96ae3f67fe6db crypto/arm64cpuid.pl e0daf54f72dd8fd1bc537d93f34e2a6a887a9ed6027bb33e15a327ef5ff37a42 crypto/armcap.c -24cc7611225df0e20e414c14e80516c36d48bf99659946e85a876d8757356686 crypto/armv4cpuid.pl +a43f2c1eef16146943745f684f2add7d186924932a47abf7fb0760cba02804e6 crypto/armv4cpuid.pl 16739d54200fb81ca7835b5814f965022a2ab41589c7787e2697e3ea72d4fafa crypto/asn1_dsa.c -155eff9d747eed808398cfa2af4b276dfc1f9aac8a0f9d801b314ab3f2bf5b56 crypto/bn/asm/alpha-mont.pl -894cc71b2d783e4e1b54dbef45e9e9280165a2c43981ebdd03282f0e90914928 crypto/bn/asm/armv4-gf2m.pl -0d2e31dc9cdce02c619adfc9ac720ccf7171384e76a84cdf0e686a805dd7006e crypto/bn/asm/armv4-mont.pl -d7df31176f725c1ae7241fee8f681fdcf2ab9eb4d3cc6c80d49c2248ae40a56a crypto/bn/asm/armv8-mont.pl +819c9fd2b0cae9aab81c3cbd1815c2e22949d75f132f649b5883812d0bbaa39a crypto/bn/asm/alpha-mont.pl +0070595128b250b9ebdebe48ce53d2d27ca16ec4f7c6c8bd169ab2e4a913b2d1 crypto/bn/asm/armv4-gf2m.pl +8c1c53a725b8a4f92b8a353bfeeb393be94198df41c912e3270f9e654417b250 crypto/bn/asm/armv4-mont.pl +a0d926004bddb4613552ffa325fac57ab64b085255f2e72881d8478f55890f5a crypto/bn/asm/armv8-mont.pl cb4ad7b7461fcb8e2a0d52881158d0211b79544842d4eae36fc566869a2d62c8 crypto/bn/asm/bn-586.pl -10fb73a6cc1bc064ebdcf6d7fe3c7407ea1c28b0d65ad0123046f8b1518fa75a crypto/bn/asm/c64xplus-gf2m.pl +636da7e2a66272a81f9c99e90b36c6f132ad6236c739e8b9f2e7315f30b72edd crypto/bn/asm/c64xplus-gf2m.pl c86664fb974362ee52a454c83c2c4b23fd5b7d64b3c9e23ef1e0dfd130a46ee5 crypto/bn/asm/co-586.pl -b88190d748056e6a64988bf1a3d19efc4c292e3d338a65f4505cf769a2041077 crypto/bn/asm/ia64-mont.pl +199b9b100f194a2a128c14f2a71be5a04d50d069666d90ca5b69baee1318ccb7 crypto/bn/asm/ia64-mont.pl a511aafbf76647a0c83705d4491c898a5584d300aa449fa6166c8803372946eb crypto/bn/asm/ia64.S -fee42cabeeb87cdf0fa0a6ff3698b2fe98a8a47d10a756052df572097161a8b9 crypto/bn/asm/mips-mont.pl -b197a8e1be79b8c21f8d26b34b9a282ca42ec4bcd1f3212fde3889747082a1f7 crypto/bn/asm/mips.pl -13df09cee06a21669137294f92e5c31b4bf05a8035be6800c1cb4403d7cd8290 crypto/bn/asm/parisc-mont.pl -25c96e545b4981d45557eb14ea5c83aa2d6375ae0df806cb6e6ded2f59ddfed3 crypto/bn/asm/ppc-mont.pl -1c057083546fa1a3bb1b9819dc5110f5a3b11b7bf5a2fb275012323bd7412403 crypto/bn/asm/ppc.pl +687c5d6606fdfd0e242005972d15db74a9cbac2b8a9a54a56fcb1e99d3880ff3 crypto/bn/asm/mips-mont.pl +8aca83d2ec45a40af15e59cff1ac2dc33737a3d25f0a0b74d401fa778a5c5eb8 crypto/bn/asm/mips.pl +b27ec5181e387e812925bb26823b830f49d7a6e4971b6d11ea583f5632a1504b crypto/bn/asm/parisc-mont.pl +9973523b361db963eea4938a7a8a3adc692e1a4e1aec4fa1f1e57dc93da37921 crypto/bn/asm/ppc-mont.pl +59cd27e1e10c4984b7fb684b27f491e7634473b1bcff197a07e0ca653124aa9a crypto/bn/asm/ppc.pl e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 crypto/bn/asm/ppc64-mont-fixed.pl -fe9278a2504fb40257637a4718081775c29c4eb81f87a8528e5c85f8d0c6281a crypto/bn/asm/ppc64-mont.pl -94b2d5cf0faf2efddeb5fb7c575dabc35c1791715cc9299d59a01d9f96cb2d6f crypto/bn/asm/rsaz-avx2.pl -cd0861a565231f67252e172420f6914fe47a324b35916c29f6304491447fe84c crypto/bn/asm/rsaz-avx512.pl -c19c717d87dd1ba74f138af05c044c05f5d025e26323637f46ba54a8c871a378 crypto/bn/asm/rsaz-x86_64.pl -ae26becda9f6d30e9edde8bb89c251a0c40a9a6c879c4cdaec273d8c09af9cd6 crypto/bn/asm/s390x-gf2m.pl -2700337ef133d6688047a1a8e1c671db06016aae777679923ce2b301896762cf crypto/bn/asm/s390x-mont.pl +a25be64867ab837d93855af232e2bfa71b85b2c6f00e35e620fdc5618187fb6f crypto/bn/asm/ppc64-mont.pl +231579e532443665020d4d522d9f11713d9c5d5c814b95b434b0f65452e16de4 crypto/bn/asm/rsaz-avx2.pl +1657600d320ea549b527b2d878a7658533d60d26eeb38f42ea470fc612f9bb53 crypto/bn/asm/rsaz-avx512.pl +31e84dc905b13e38850071528d3abbfcaf8910bbc8b46f38d19c2b386a5f838e crypto/bn/asm/rsaz-x86_64.pl +30fedf48dfc5fec1c2044b6c226dd9fc42a92522cc589797a23a79d452bdd2cf crypto/bn/asm/s390x-gf2m.pl +590388d69d7ac3a0e9af4014792f4f0fdb9552719e8fb48ebc7e5dfca2a491d4 crypto/bn/asm/s390x-mont.pl aa02597f3dc09cfbc190aedb75711859ba0f3efff87067ebfba1ec78ebee40d7 crypto/bn/asm/s390x.S -87d49e83a7df467097fdfc577aa206be9ee622c40fcbbbe5133b35d9783b7816 crypto/bn/asm/sparct4-mont.pl +2f7cbc2c3d93b1bbc4953dda38b9ae0ab3a0a8331a0418d94d9b286183736c9e crypto/bn/asm/sparct4-mont.pl ca21a9ccbc54e19fb7c2e6cdf286ce7cb08b0fba960c777c6edce5c57ccc2101 crypto/bn/asm/sparcv8.S fbc93c8dbbecefe66086f58fe9719ed87b13b2cdc61454a10e841228296fecef crypto/bn/asm/sparcv8plus.S -2ec1497fa06826f7bc574239e425dd8dda0d4a2743e1fe87669ede900291fcb6 crypto/bn/asm/sparcv9-gf2m.pl -1f490fe184c7a51b2d0646a59e69aa659bfe51270ad21594951b8d7b785bac38 crypto/bn/asm/sparcv9-mont.pl -277dcb7faa1913b25fd43946c50039bcdd45cb643fd9ddeedd6c207cefa4dd50 crypto/bn/asm/sparcv9a-mont.pl +127832c1e3d298aad805236776488f5f8836b6a0fdbce3f6b42678163df3909f crypto/bn/asm/sparcv9-gf2m.pl +1622f04a8918724ac0e8804baf285fdafa0eeaaecc36c7facd459d0ff13a8cac crypto/bn/asm/sparcv9-mont.pl +b69083f78b4b4f7097de4462d16649532fb82c453a82cdd9cc1393122661d6e2 crypto/bn/asm/sparcv9a-mont.pl d404375a21d33396824a3da212d6646d4f3150dd141ee4b4a250aefae3482efb crypto/bn/asm/via-mont.pl -d632edf9b9bab7d2cd2d616512a98d15cf4b3ebba7a8e7b83650d654ceb52ecb crypto/bn/asm/vis3-mont.pl +d24f3e97239c8eed5efc721521b025b7256c15e67a54ea6b5c4cf8f7cd0f89ea crypto/bn/asm/vis3-mont.pl 89278854f44d95be916516609ce6f79dcd346bab52574b9b6336a9952aa94bee crypto/bn/asm/x86-gf2m.pl 90d4ae234c08267adce9ed38d56e0edc223f7480cb9605f5d7399d0b3914c6be crypto/bn/asm/x86-mont.pl d444ca73875e97e0ea88b20e4c02f2fcf3850e8b9311e3b67a2d04fe2796d543 crypto/bn/asm/x86_64-gcc.c -a5481ca55d94dc7ebdc93173610d38ae2569cea1fe9b5180debe0ab94e455ce1 crypto/bn/asm/x86_64-gf2m.pl -d8cc080824a72774cb3343a3d50ddf8f41a5b8321203d4c9a764762b62498b96 crypto/bn/asm/x86_64-mont.pl -03788cb685268e6a50ddfa742ea1fe937570c9b86f2ebc88ee35f3304f67c045 crypto/bn/asm/x86_64-mont5.pl +709ddee92e9222ee0ed27bfb90db556e85e2d302e4a9131afa25fdc14c4d858f crypto/bn/asm/x86_64-gf2m.pl +da7f7780d27eed164797e5334cd45b35d9c113e86afaca051463aef9a8fd787c crypto/bn/asm/x86_64-mont.pl +259fb8d7f40c0dba46920b1f169d5b37de03b0fda645463d19e3ae2b56de851d crypto/bn/asm/x86_64-mont5.pl 0ea8185a037a2951bb3d1e590bbbdeac305176d5e618f3e43a04c09733a9de34 crypto/bn/bn_add.c 759c2b9df808b3562fe8b0c7778dbadbf35f261e14fc2d5090d18c35b4181760 crypto/bn/bn_asm.c 14bd5a35c05fcf454854b92fb30b356d7ac618c1eb699dd798f6ad2936d1f5ee crypto/bn/bn_blind.c @@ -77,10 +77,10 @@ d8cc080824a72774cb3343a3d50ddf8f41a5b8321203d4c9a764762b62498b96 crypto/bn/asm/ 2893b6d03d4850d09c15959941b0759bbb50d8c20e873bed088e7cde4e15a65a crypto/bn/bn_ctx.c d94295953ab91469fe2b9da2a542b8ea11ac38551ecde8f8202b7f645c2dea16 crypto/bn/bn_dh.c 74b63a4515894592b7241fb30b91b21510beaa3d397809e3d74bc9a73e879d18 crypto/bn/bn_div.c -49e59eac540db304ab0ca7bee3ba9d45f89548fff98155561bbdb6602d0aab1d crypto/bn/bn_exp.c +46357d2d30109ae59482332adf604a5ef1bd64c7de08cc808db028c45190ba93 crypto/bn/bn_exp.c ec2b6e3af6df473a23e7f1a8522f2554cb0eb5d34e3282458c4a66d242278434 crypto/bn/bn_exp2.c baba7c8ae95af6aa36bc9f4be3a2eed33d500451e568ca4bfc6bc7cb48d4f7ea crypto/bn/bn_gcd.c -5fbb1ab8463cd5544a1d95cf7996b6387ae634984a42256b7a21482ce3ac30a2 crypto/bn/bn_gf2m.c +99325cf50bf72b5d77048c20d7fa4f80a179dc6357023745f9a58c8e914ae136 crypto/bn/bn_gf2m.c 081e8a6abc23599307dab3b1a92113a65e0bf8717cbc40c970c7469350bc4581 crypto/bn/bn_intern.c 602ed46fbfe12c899dfb7d9d99ff0dbfff96b454fce3cd02817f3e2488dd9192 crypto/bn/bn_kron.c 81a4afc27dd1e90c4bfa81c8d385214ce8a2b5884537752944a71ebebd91f4b0 crypto/bn/bn_lib.c @@ -101,14 +101,14 @@ a5c5c9f99961a5a7f22a3dcdce964c8a330f822be17f08652223a20fed747d0a crypto/bn/bn_r 24e62baa56e02f2db6454e10168b7c7fa7638db9221b9acda1803d43f38f36e0 crypto/bn/bn_word.c be27115efd36f0077a3ec26b1ff1f586b0b8969ba05d8ffa34b2ff4badf227bf crypto/bn/rsaz_exp.c c4d64da1cdc732ea918fccd6a7bb2746b03365dd26f7ba1e74e08c307ca4c58e crypto/bn/rsaz_exp.h -5b82cb8dbf3087c2e671871cb0a92e4039223a51af533a2ee996f3bfd47453a7 crypto/bn/rsaz_exp_x2.c +9bc3bf8965f98915f9019d2f516345e73c435c5bd8ad94bb4b7057809a7d1383 crypto/bn/rsaz_exp_x2.c 834db8ff36006e5cb53e09ca6c44290124bd23692f4341ea6563b66fcade4cea crypto/bsearch.c c39334b70e1394e43f378ae8d31b6e6dc125e4d9181e6536d38e649c4eaadb75 crypto/buffer/buffer.c -d2bfdfd96b182741d2d51f91478ffcc48491b0da44662bc1c32bc506b3eef1ba crypto/c64xpluscpuid.pl +5f43844b5d8665de9ab895f93599150a327d73ec2674bbf7d7c512d30163022d crypto/c64xpluscpuid.pl 0e1a41a2d81b5765bca3df448f60bf1fad91e485fe89dd65a7300ffc419e316d crypto/cmac/cmac.c 5113d8d12d884f845cad3d35d92f0a1ee20ebafd7a169273642f4e8178711de9 crypto/context.c c309d81ea991ddf5be4337afad2fd132169f7443c76f863349d3f3c82f3374e4 crypto/core_algorithm.c -f0fd9eb38bf7f196bbb4d26ce8fdf86d0a4f9db219157e66b2c0ffefb4f42005 crypto/core_fetch.c +65ba41169f8fec7cb8466c3458721e3150057fb587db087a70752e5e08201381 crypto/core_fetch.c 799c84d224639c6760c5c28e0e287500a973ca6d0c3d7c1bdcd61b0da4018b3c crypto/core_namemap.c 469e2f53b5f76cd487a60d3d4c44c8fc3a6c4d08405597ba664661ba485508d3 crypto/cpuid.c 71f0fff881eb4c5505fb17662f0ea4bbff24c6858c045a013ad8f786b07da5c4 crypto/cryptlib.c @@ -138,15 +138,15 @@ f4d52d3897219786c6046bf76abb2f174655c584caa50272bf5d281720df5022 crypto/dsa/dsa 196dc024873e413d92672c3a9b6c062ed6269250b0da6d41c0da1c03cfec9ef8 crypto/dsa/dsa_ossl.c 9f501a59c09fc3cb3caafaff25abd44397a94d1062950a4d62e855d2c8986b5a crypto/dsa/dsa_sign.c 53fa10cc87ac63e35df661882852dc46ae68e6fee83b842f1aeefe00b8900ee1 crypto/dsa/dsa_vrf.c -786779d7014bc04846832f80638743784a3850c7ee36e4a8062fe8eb7ac31c9b crypto/ec/asm/ecp_nistp521-ppc64.pl -2e3056ea14fab8b306b0281d6a6f4317a6e86dbf652a79ade726e716cd79bb1e crypto/ec/asm/ecp_nistz256-armv4.pl -a02edef19d22c5aba196080942111ab0172fc2ebe6d6c40db2beb6a1a2d885c6 crypto/ec/asm/ecp_nistz256-armv8.pl -729729f8233c95138158f4647b33a36cf175e707ce29563db0eedc811f324ec0 crypto/ec/asm/ecp_nistz256-ppc64.pl -78a5b172f7c13ae8ac622439ffb9d99b240dbb4bbda3f5c88d1533ae74a445ad crypto/ec/asm/ecp_nistz256-sparcv9.pl +d9722ad8c6b6e209865a921f3cda831d09bf54a55cacd1edd9802edb6559190a crypto/ec/asm/ecp_nistp521-ppc64.pl +78ad06b88fcc8689a3a846b82f9ee01546e5734acd1bccf2494e523b71dc74d1 crypto/ec/asm/ecp_nistz256-armv4.pl +4617351d2de4d0b2abfd358c58050cee00702d0b4c1acca09312ec870e351c7d crypto/ec/asm/ecp_nistz256-armv8.pl +3715ddd921425f3018741037f01455ed26a840ace08691a800708170a66cf4d2 crypto/ec/asm/ecp_nistz256-ppc64.pl +cfe7e75a2fddc87a7251684469a8808b9da82b2f5725eafad5806920f89932bd crypto/ec/asm/ecp_nistz256-sparcv9.pl 922725c4761cfa567af6ed9ecab04f2c7729ae2595f2fc0fa46dc67879dc87b0 crypto/ec/asm/ecp_nistz256-x86.pl -19ba01af58788e2873ebc1d5b503a76604bec0b9b6296fa794946e141fc945a4 crypto/ec/asm/ecp_nistz256-x86_64.pl -e806141073aa3792e2748f6feeee6d3017124b3bc6059a9eca0d53a2f5785346 crypto/ec/asm/x25519-ppc64.pl -a397592dc9fdb13016311db6184b4a3a4f2e198aacb03528f770f30ea4966cc4 crypto/ec/asm/x25519-x86_64.pl +ac327475c7ec828d11aa05628b4e3b81ec3b1400f30fe7bec01daf3cf71f2dc9 crypto/ec/asm/ecp_nistz256-x86_64.pl +cc727533130f5f1a29229929b3d4e8454585d647be25d6344f3c6a0240998368 crypto/ec/asm/x25519-ppc64.pl +ee897e230964511baa0d1bf95fb938312407a40a88ebe01476879c2763e5f732 crypto/ec/asm/x25519-x86_64.pl 340336e01aa04fcde9bfd56536f90c9bc0ad56a002b6cfa321a1e421f1e93ceb crypto/ec/curve25519.c 9a95ec8366154bb20aeb24f4767a8cbb9953ca0380708eb2f39caca6078cd59e crypto/ec/curve448/arch_32/f_impl32.c 063dac1e4a9573c47532123e9e03e3532a7473cc3e146521ba9ec6f486ddf3b1 crypto/ec/curve448/arch_64/arch_intrinsics.h @@ -166,16 +166,16 @@ f6447921a0031fa5beddedd298e82096fb3fdb189b712fab328b61f6beae0c23 crypto/ec/curv ae1637d89287c9d22a34bdc0d67f6e01262a2f8dcef9b61369dba8c334f5a80d crypto/ec/ec2_oct.c 6bbbf570ce31f5b579f7e03ec9f8a774663c7c1eb5e475bd31f8fee94a021ffc crypto/ec/ec2_smpl.c 2a71bd8dbe4f427c117d990581709a4ddce07fa8e530794b5a9574fef7c48a0c crypto/ec/ec_asn1.c -69b1b3acb4295f5fff961b339e8ace913176ca63fcedf4af0da4c27171f24f94 crypto/ec/ec_backend.c +e959960fe9a78ea67346048c9c02428203819d5b443d18fe7bb26cd1ca28fcdc crypto/ec/ec_backend.c 86e2becf9b3870979e2abefa1bd318e1a31820d275e2b50e03b17fc287abb20a crypto/ec/ec_check.c 265f911b9d4aada326a2d52cd8a589b556935c8b641598dcd36c6f85d29ce655 crypto/ec/ec_curve.c 8cfd0dcfb5acbf6105691a2d5e2826dba1ff3906707bc9dd6ff9bffcc306468f crypto/ec/ec_cvt.c 95ce53663ab8a1d05bd6f4999f30113e1edce771fb6d218a772fe02de7bdaf4d crypto/ec/ec_key.c 7e40fc646863e0675bbb90f075b809f61bdf0600d8095c8366858d9533ab7700 crypto/ec/ec_kmeth.c -bbd6f618c3dfe425ce0ba1c6710fe59418130e06351881162a590475e6438c44 crypto/ec/ec_lib.c +fea5cd863cd94b4e543b72942ed8c23175359cfab99ca65203af4ebecb001a15 crypto/ec/ec_lib.c a8a4690e42b4af60aad822aa8b16196df337906af53ea4db926707f7b596ff27 crypto/ec/ec_local.h fa901b996eb0e460359cd470843bdb03af7a77a2f1136c5e1d30daef70f3e4d2 crypto/ec/ec_mult.c -129c6b42417bfcf582f4a959cfd65433e6f85b158274f4fa38f9c62615ac9166 crypto/ec/ec_oct.c +205b17b41e6678f40ec2a92e7856e87904e57121e7dc3120d14a4c4eeafb15b0 crypto/ec/ec_oct.c c7fba2f2c33f67dafa23caef8c3abd12f5336274a9a07d412b83be0366969ee6 crypto/ec/ecdh_kdf.c b2cf8f052a5716137da7b0e857ed7a5df5fb513b6d14534199a05e32f2b5a866 crypto/ec/ecdh_ossl.c 2e00c2e0e6f6d58b81fc23fe500f59e98793dc828ca87d64eba10cc0fddd0dc1 crypto/ec/ecdsa_ossl.c @@ -228,19 +228,19 @@ f897493b50f4e9dd4cacb2a7accda6683c10ece602641874cdff1dac7128a751 crypto/initthr 7290d8d7ec31a98b17618f218d4f27b393501c7606c814a43db8af1975ad1d10 crypto/lhash/lhash.c 5d49ce00fc06df1b64cbc139ef45c71e0faf08a33f966bc608c82d574521a49e crypto/lhash/lhash_local.h f866aafae928db1b439ac950dc90744a2397dfe222672fe68b3798396190c8b0 crypto/mem_clr.c -78a20112586dbce2b8b6e509a0f46f6a36f2a4acf53c3f3511daf7932a71c391 crypto/modes/asm/aes-gcm-armv8_64.pl -e482f02932d77d61142548ca4f3c8d5709d88ec14ab84723d82331444c0f57da crypto/modes/asm/aesni-gcm-x86_64.pl -8fdcb4313fa3a6e541a697525856b9527a06ddf4c794f9393e843f86d67f543c crypto/modes/asm/ghash-alpha.pl -ace8c376b394439301cecaf468d2a9a8adae21eff1d43191cefbf6765023452d crypto/modes/asm/ghash-armv4.pl -c22f4945e7de3bd7bfef73447f09983e40a3e4dd0938244d902a1c44c98a8467 crypto/modes/asm/ghash-c64xplus.pl -315a76491cdba48c88df6549c9efd96b50515400810b185a568b7a871681e03d crypto/modes/asm/ghash-ia64.pl -25e9f494fcb6eb636c04af2f322736fae8aa339037e199332c96b8c9c3a50afa crypto/modes/asm/ghash-parisc.pl -f22d5fa646b4fc2db008b6b05ec07c8790d3ad5485d2b10218fd11d0e81030ba crypto/modes/asm/ghash-s390x.pl -de97107e0c19ff9dd4069f0761eccb00e0b3ced345e1f119ab3b918dd2f9c5f6 crypto/modes/asm/ghash-sparcv9.pl +e14f48d4112c0efe3826b4aa390cc24045a85298cc551ec7f3f36ac4236d7d81 crypto/modes/asm/aes-gcm-armv8_64.pl +1d686af304f94743038f916125effcb51790c025f3165d8d37b526bbeee781f0 crypto/modes/asm/aesni-gcm-x86_64.pl +c2e874a8deb418b5d8c935b2e256370566a5150e040c9fa008cdb5b463c26904 crypto/modes/asm/ghash-alpha.pl +6bc7d63569c73d7020ede481f2de05221ac92403c7cc11e7263ada7644f6aa9b crypto/modes/asm/ghash-armv4.pl +097975df63370de7ebea012d17de14fc1f361fb83acf03b432a99ae7d5bceb24 crypto/modes/asm/ghash-c64xplus.pl +fdde3bc48b37790c6e0006014da71e7a831bbb4fdbfcda2d01dbe0ceb0ba88fa crypto/modes/asm/ghash-ia64.pl +e472d73d06933667a51a0af973479993eed333c71b43af03095450acb36dbeb4 crypto/modes/asm/ghash-parisc.pl +6fb4332ac88113a20915ad4de1931ef88b0114b5379b16e1d967820e1229fbb0 crypto/modes/asm/ghash-s390x.pl +6af1a05981e1d41e4dea51e58938360e3abc4a4f58e179908242466d032b1a8a crypto/modes/asm/ghash-sparcv9.pl 26f55a57e77f774d17dfba93d757f78edfa3a03f68a71ffa37ccf3bfc468b1e2 crypto/modes/asm/ghash-x86.pl -2a0d23a644083e46745c7cb1ca79de393af9336a2e8eab7c85ffeb3b7b1a286f crypto/modes/asm/ghash-x86_64.pl -b407d9fc6ea65fe1a05edc2d139298d78391f3c165314fa6d56dd375b8e453cd crypto/modes/asm/ghashp8-ppc.pl -d8436f6dc43a18d49b1a16999ecb513ccf4483f418f75edc01ce68e777c614a9 crypto/modes/asm/ghashv8-armx.pl +72744131007d2389c09665a59a862f5f6bb61b64bd3456e9b400985cb56586b8 crypto/modes/asm/ghash-x86_64.pl +a4e9f2e496bd9362b17a1b5989aa4682647cefcff6117f0607122a9e11a9dfd9 crypto/modes/asm/ghashp8-ppc.pl +69a13f423ca74c22543900c14aef4a848e3bc75504b65d2f51c6903aebcc17a7 crypto/modes/asm/ghashv8-armx.pl 65112dfe63cd59487e7bdb1706b44acfcf48ecede12cc3ae51daa5b661f41f06 crypto/modes/cbc128.c 1611e73dc1e01b5c2201f51756a7405b7673aa0bb872e2957d1ec80c3530486f crypto/modes/ccm128.c d8c2f256532a4b94db6d03aea5cb609cccc938069f644b2fc77c5015648d148d crypto/modes/cfb128.c @@ -257,7 +257,7 @@ c698d5166d091d6bb6e9df3c211fe1cc916fd43a26ec844f28f547cd708f9c55 crypto/param_b 4fda13f6af05d80b0ab89ec4f5813c274a21a9b4565be958a02d006236cef05c crypto/params_dup.c b6cbfc8791b31587f32a3f9e4c117549793528ebddc34a361bad1ad8cf8d4c42 crypto/params_from_text.c 97cb7414dc2f165d5849ee3b46cdfff0afb067729435d9c01a747e0ca41e230c crypto/ppccap.c -826a78afb376cbf1e87f12a2a67eef2ee47059a0fd3f9cba7ce7f035e34f8052 crypto/ppccpuid.pl +3ca43596a7528dec8ff9d1a3cd0d68b62640f84b1d6a8b5e4842cfd0be1133ad crypto/ppccpuid.pl b4d34272a0bd1fbe6562022bf7ea6259b6a5a021a48222d415be47ef5ef2a905 crypto/property/defn_cache.c c3709986fd2ab18f3c6136d8dd7705a4538986aa789ceafe770c3a376db3c569 crypto/property/property.c 66da4f28d408133fb544b14aeb9ad4913e7c5c67e2826e53f0dc5bf4d8fada26 crypto/property/property_local.h @@ -288,50 +288,50 @@ f01af62704dbf9457e2669c3e7c1d4d740f0388faa49df93611b987a8aa2bf11 crypto/rsa/rsa 3aba73dacebb046faf8d09dc279149b52c629004b524ec33e6d81c8ad0bc31a8 crypto/rsa/rsa_sp800_56b_gen.c 1c1c2aeeb18bf1d69e8f134315b7e50d8f43d30eb1aa5bf42983eec9136a2fdc crypto/rsa/rsa_x931.c 0acbebed48f6242d595c21e3c1ad69da0daa960d62062e8970209deda144f337 crypto/s390xcap.c -370d98549d4d98e04b60677b319b85904259359bd9401dd5385aa728278e6626 crypto/s390xcpuid.pl +22205848cfb55116ebf999dced8331b575886a609ce29e6886e6267b2310c337 crypto/s390xcpuid.pl 5fa59240ca885cbc0c1cd026934b226d44fc9c3fdf0c2e7e3a7bd7f4963ca2e5 crypto/self_test_core.c -58a1a8aeb45421954fa0e4bc87157addb96d086ac4e6aade47da96523cecaa74 crypto/sha/asm/keccak1600-armv4.pl -d6df6cfdd4e2fee52dc16fd31c91768c45c48c22700c486406d70ecb37e8a8bb crypto/sha/asm/keccak1600-armv8.pl -81bfb4484d68a3a3e1d704855f76356090867fe10a75db7707b6f7364e8ee8da crypto/sha/asm/keccak1600-avx2.pl -b7bb35d51d439abbf3810454ccb9bfb5a51e2111eaf389fb95796ad6220a61a0 crypto/sha/asm/keccak1600-avx512.pl -37365dcc576f99006132271968bab990e2bebdab7f4168c726bd449a2fa51c6a crypto/sha/asm/keccak1600-avx512vl.pl -2767ae2f379a7a3d0c6dd1471d4d90dd896545b456cb6efd6c230df29e511d70 crypto/sha/asm/keccak1600-c64x.pl +05c533fde7fdba0c76103e97d881b7224c8427451b453e2f6413552996063e31 crypto/sha/asm/keccak1600-armv4.pl +ca3b2b654f9a8c4bc2fa2538c1f19d17acd4a6b9e0df6a4b81df04efa697e67e crypto/sha/asm/keccak1600-armv8.pl +12b7acce2fba0bc0e1ca07842ec84be6a022f141c86e077abb42c864af1d8d9c crypto/sha/asm/keccak1600-avx2.pl +faf0cccb685d5abc807e08db194f847c67b940da2fc3c235c210dc31d73a5334 crypto/sha/asm/keccak1600-avx512.pl +be1e7dd9998e3f31cfa6e1b17bc198aeec584a8b76820e38f71d51b05f8a9f2a crypto/sha/asm/keccak1600-avx512vl.pl +33bdcc6f7668460c3bdf779633e43bfad62b937042a73acb007b462fc5b0a034 crypto/sha/asm/keccak1600-c64x.pl 09fc831dd39bd90a701e9b16d9e9987cc215252a22e1e0355f5da6c495fca35a crypto/sha/asm/keccak1600-mmx.pl -485dcc50a51705b86c6dc47e6f58d092fec05dfbfcdf4f2785e4235c67cfe742 crypto/sha/asm/keccak1600-ppc64.pl -49535b60a1a981059a2a9636fdeeab22942d2a15e775b1ec9b5af8937a46aa76 crypto/sha/asm/keccak1600-s390x.pl -093751655b460d33b2fa6aa4d63a86e902f7f20b2d2a02ed948b78e5698c0dd5 crypto/sha/asm/keccak1600-x86_64.pl -e0a4a1df82716053a3f01ec0b096c735a0e3c4f6c9d9ec6b2006b37aaac64448 crypto/sha/asm/keccak1600p8-ppc.pl +ce4a58129e5ee3ac4c9dfec5ecc010440570ebf7bf869e3e9977f2121a64b27a crypto/sha/asm/keccak1600-ppc64.pl +a859fc8cb073b2d0012a93f3155a75fb6eb677441462b0de4f8cf8df1445e970 crypto/sha/asm/keccak1600-s390x.pl +618dcd4891b4064d3b8aa6dcd74bea7ef55f4962a64957b05a05448f6e3e0f17 crypto/sha/asm/keccak1600-x86_64.pl +831b8b02ab25d78ba6300ce960d96c13439bfba5844e13061e19c4e25cbacc3d crypto/sha/asm/keccak1600p8-ppc.pl 75d832db9bf0e98e7a5c522169060a6dd276c5118cfb297fc3f1111f55cd4007 crypto/sha/asm/sha1-586.pl -8d937771993f04407f5fdcca8ca8565f9f8a4d9c9a8f7bfd4e9f9121dd0450bb crypto/sha/asm/sha1-alpha.pl -ab7ecd62896324393b1fd9020515b9c0d2b9cc34d559f2efafa35affc9a1485d crypto/sha/asm/sha1-armv4-large.pl -0acc4e40f793d4d2b960af2baaecc91176ba6742ddd62dca0c33ddc838c58772 crypto/sha/asm/sha1-armv8.pl -c36f51761e7f59bdd0f61230297fb802542ac5d2d1c6d2b1096ed937131bd583 crypto/sha/asm/sha1-c64xplus.pl -4ab7c9153b085274a579b388ddff97a4ac7e11585e01811ca95b93a3ec786605 crypto/sha/asm/sha1-ia64.pl -7a392c5ef7dc19c39d67c7080e0c5214e7a80572c85c022be7e7d4378a5f740d crypto/sha/asm/sha1-mb-x86_64.pl -c0fea5a0d32001263c8bcf7fc0757aa68c6a7377f20fef8d28708e1b81de5dec crypto/sha/asm/sha1-mips.pl -f11b75a54c5f42aa3a052de8091bfba47d7cac01920b2fe0ddcb637d4c9d0eb9 crypto/sha/asm/sha1-parisc.pl -d46ef3fc166271a83144d90985034e2c514bd1020b84ec0fe5427ad593bfeb74 crypto/sha/asm/sha1-ppc.pl -a48c7d9403fe99fbd4daec60e96eb22058da766ab9e606d084a63613962851a2 crypto/sha/asm/sha1-s390x.pl -0e2951e0574c64ee055ffddf16ceefdec00823107d60362976605f139ad8ae68 crypto/sha/asm/sha1-sparcv9.pl -5da48400d4fae85e205e95a2fa368e7bf525e51e274b1dd680dfb48645426c85 crypto/sha/asm/sha1-sparcv9a.pl -04b73c902d36c28b5a7eab47cb85f743eb9c648ed5936f64f655524a1010a1b5 crypto/sha/asm/sha1-thumb.pl -f36d7ec7464c932230585a754b91f13cea4cde5a381fc9f798d959256d07910e crypto/sha/asm/sha1-x86_64.pl +c96e87d4f5311cd73bbdf499acc03418588be12426d878e157dd67e0099e0219 crypto/sha/asm/sha1-alpha.pl +4ba6d1c7f12fe76bf39babea966f0a4b7f8769e0c0510cbfc2c46a65dd62d45c crypto/sha/asm/sha1-armv4-large.pl +efc69cb0d867b7fac6b3fa8985c343d1f984d552bc8e75bbbbace0adf9ee5f15 crypto/sha/asm/sha1-armv8.pl +11d332b4e058e9fa418d6633316d2e9f9bf520a08b2d933e877bdf38b2edefcf crypto/sha/asm/sha1-c64xplus.pl +32ff0e701a7b8f25bcfe8477b20795de54f536527bd87d3ce694fd9aaae356d4 crypto/sha/asm/sha1-ia64.pl +471c27efca685b2a82ad7fefe329ca54172df9f49b9785da6d706b913b75e693 crypto/sha/asm/sha1-mb-x86_64.pl +0f5c63cf09e950d1b488935ab3b5562e3e9d5cd1a563fb88a41e3dae90a35e6d crypto/sha/asm/sha1-mips.pl +b5ffd7b6dbb04c05de7efa2945adb67ea845e7e61a3bf163a532f7b6acdf4267 crypto/sha/asm/sha1-parisc.pl +482cd23ca6ec38d6f62b90c68f9f20643579c50f2c0fbb0dab1c10a0e35efe77 crypto/sha/asm/sha1-ppc.pl +28cf69efd53d7a5a8c32e0f8db32c193f41b91faf44f5f59944334bc3f5aa337 crypto/sha/asm/sha1-s390x.pl +7fd355b412ddfa1c510e0ba3284f75b1c0d621b6db2ecb1d2a935d5cdb706628 crypto/sha/asm/sha1-sparcv9.pl +24554e68b0e7b7db7b635ff149549015f623ca0bcd9ae90439586a2076f6ae80 crypto/sha/asm/sha1-sparcv9a.pl +74d197cdd72400cabbff7e173f72c8976723081508b095dc995e8cd1abf3daa6 crypto/sha/asm/sha1-thumb.pl +a59a86293e28f5600609dc8af2b39c5285580ae8636520990b000eeeb67bb889 crypto/sha/asm/sha1-x86_64.pl c099059ef107f548ea2c2bab64a4eb8c277070ce6d74c4d32bb9808dc19c5fa3 crypto/sha/asm/sha256-586.pl -3a8cf38dd398a7ab1d9c6701fa61c428b07c4431a0041ed3a2ddf937897825c1 crypto/sha/asm/sha256-armv4.pl -c394bb5b0ff05595a9e6848b6602a0f29f73a79fc006593740f3ca645ad9d316 crypto/sha/asm/sha256-c64xplus.pl -f33af8e2e2f57b7b63b8c8b35722d7d11ca6ef1f73fb6c4ccebdd3e86912f4b1 crypto/sha/asm/sha256-mb-x86_64.pl +b9cee5c5a283f61f601d2dba68a7a76e7aba10bfafffc1a5c4987f9c0aa6f87d crypto/sha/asm/sha256-armv4.pl +93ddc97651ee3e779144a3c6b3e46a1bc4aa81e75cd7b9df068a2aef8743d25f crypto/sha/asm/sha256-c64xplus.pl +8be5c5d69733ecb16774aa8410b4bcb3623a9f060d2be103d8aa67bf6e4c5843 crypto/sha/asm/sha256-mb-x86_64.pl dd82e1311703abb019975fc7b61fb87d67e1ed916dddd065aced051e851114b9 crypto/sha/asm/sha512-586.pl -1f9ba79b1d591b7aa37b62382422cb025f5b45784d26cc5790c05cf4eb52b792 crypto/sha/asm/sha512-armv4.pl -8136196fce18b736f671a4b4945cd4aa4ab25a28c90c6fc9ab31ff771e8e0d9f crypto/sha/asm/sha512-armv8.pl -5b6796a9978b69fd78ee2ff1adc5cf35d44cad8194a38d1c2aba2023012cf252 crypto/sha/asm/sha512-c64xplus.pl -e8df660671ba61aa2e8f51358baf5d8ca913093e2ee1a40c9cb46d9c2c0851f6 crypto/sha/asm/sha512-ia64.pl -525f253ef8051bfb0e344ac2e40688ce359a42707fe360d23a03f522cc88c81a crypto/sha/asm/sha512-mips.pl -3c3e03529d8514467f8d77c01978348636bb339315feb8041fbde7640565001e crypto/sha/asm/sha512-parisc.pl -952ef1b10e8bbe3f638cc798b91ab9c5b47b66ed8fe94647b1beec9874f2e71e crypto/sha/asm/sha512-ppc.pl -193a0ea240264b29dd68a425f604a6da4b18e28838dcf909dd7e711af880f782 crypto/sha/asm/sha512-s390x.pl -dcb466a1e5938fb64ecb38b0533602192d61334da864ee8dfdcfa12d3cdfa273 crypto/sha/asm/sha512-sparcv9.pl -bb6503967a58b767a3e73441cfabc77f15c8ac747f377e276d4aa63d05f2c3c4 crypto/sha/asm/sha512-x86_64.pl -68d2f3b2dccb978ee42640f4fb4d2eae6b74d071017a3eedd9e7cb77762817dc crypto/sha/asm/sha512p8-ppc.pl +8d84164f3cfd53290c0c14bb5655510b7a9238857866328c0604d64b4e76fe21 crypto/sha/asm/sha512-armv4.pl +dadacb6d66b160913bffb4e1a6c3e5f7be6509b26e2c099701d8d3fdb92c1be0 crypto/sha/asm/sha512-armv8.pl +6f548a088feae3b6faa179653ba449df9d3f5cda1e0561e5b5f120b32274d1eb crypto/sha/asm/sha512-c64xplus.pl +9fa54fbc34fd881f4b344374b9b4f8fb15b641424be7af9a31c71af89ae5d577 crypto/sha/asm/sha512-ia64.pl +fb06844e7c3b014a58dccc8ec6020c71843cfdc5be08288bc7d204f0a840c474 crypto/sha/asm/sha512-mips.pl +11548f06d213947104a80898e000218ec0d6ff3f6913f6582de498476482ce9f crypto/sha/asm/sha512-parisc.pl +7c0c490ce6bb11a228853aecad5e164ce84e5bdabb8a6658ae7184782076c7d3 crypto/sha/asm/sha512-ppc.pl +38e0455fd6a2b93a7a5385379ca92bc6526585ca1eb4af365fac4c78f7285c72 crypto/sha/asm/sha512-s390x.pl +0611845c52091b0208dd41f22ddef9dd1e68d3d92fa4c4360738b840a6314de6 crypto/sha/asm/sha512-sparcv9.pl +f64d16c1e5c3fa4a7969de494a8372127502171a517c14be7a1e3a43a7308699 crypto/sha/asm/sha512-x86_64.pl +8725cabb8d695c576619f19283b034074a3fa0f1c0be952a9dbe9793be15b907 crypto/sha/asm/sha512p8-ppc.pl 57f6cf54b1b5d2cac7a8f622b7b6bd1878f360fff3fa0f02352061c24162ebbb crypto/sha/keccak1600.c 306cacd3f86e5cacaca74c58ef862516515e5c0cafaff48636d537fd84f1c2fb crypto/sha/sha1dgst.c 4d8cf04f5806611e7586aab47fb28165ec1afb00168e2c9876bb36cb5c29bf8b crypto/sha/sha256.c @@ -345,13 +345,13 @@ c50c584c55e56347bb43aca4b796b5344d70daece3061f586b79c871c21f5d1a crypto/sparse_ 7b4efa594d8d1f3ecbf4605cf54f72fb296a3b1d951bdc69e415aaa08f34e5c8 crypto/threads_lib.c a41ae93a755e2ec89b3cb5b4932e2b508fdda92ace2e025a2650a6da0e9e972c crypto/threads_none.c 3729e2bd36f945808b578e0d89fac0fcb3114e4fc9381614bcbd8a9869991716 crypto/threads_pthread.c -88423960f0414f6fd41fba4f4c67f9f7260c2741e4788adcd52493e895ec8027 crypto/threads_win.c -af0af59fe2cb8668a96751f343232d7faa3e7a937beb2bda09ed74fe60b9cb5f crypto/x86_64cpuid.pl +f82715745b668297d71b66d05e6bfc3c817bf80bd967c0f33ca7ffbb6e347645 crypto/threads_win.c +fd6c27cf7c6b5449b17f2b725f4203c4c10207f1973db09fd41571efe5de08fd crypto/x86_64cpuid.pl bbec287bb9bf35379885f8f8998b7fd9e8fc22efee9e1b299109af0f33a7ee16 crypto/x86cpuid.pl acbb841170d4d3eb91d969be1c0e4973b1babfd5fcd76440b0628f509f82fd76 e_os.h 249a0e58e9692920eddc1ada2ac772a0cfd749cfbf618f2f5da08280df545d8f include/crypto/aes_platform.h 8c6f308c1ca774e6127e325c3b80511dbcdc99631f032694d8db53a5c02364ee include/crypto/asn1_dsa.h -2e8c284672c4e8e395b3da56a3abf3e65bb4346313fb6f7358e925d077a2e1e2 include/crypto/bn.h +3bded0eaa7ccdebd0b4217b7fdb82676d5c0762a88aca462dbceaef851fafa99 include/crypto/bn.h 1c46818354d42bd1b1c4e5fdae9e019814936e775fd8c918ca49959c2a6416df include/crypto/bn_conf.h.in 7a43a4898fcc8446065e6c99249bcc14e475716e8c1d40d50408c0ab179520e6 include/crypto/bn_dh.h e69b2b20fb415e24b970941c84a62b752b5d0175bc68126e467f7cc970495504 include/crypto/cryptlib.h @@ -518,7 +518,7 @@ ab298c5f89f3165fa11093fad8063b7bcbff0924b43fb3107148ae66d54adcb5 providers/impl 8ed4a100e4756c31c56147b4b0fab76a4c6e5292aa2f079045f37b5502fd41b9 providers/implementations/ciphers/cipher_aes_gcm_hw_aesni.inc 4c6f3a2818754a5aa7b6db36dae53e248504f9e82cc5af2ed68c723903d4f9d5 providers/implementations/ciphers/cipher_aes_hw.c 89de794c090192459d99d95bc4a422e7782e62192cd0fdb3bdef4128cfedee68 providers/implementations/ciphers/cipher_aes_hw_aesni.inc -fac3a1878dc9c0c363d0ecdd9f74926157df54ca4f40adf8c479927395082008 providers/implementations/ciphers/cipher_aes_ocb.c +0d77239f0cc1a9e1ecdeb45b6fae12cac2637771d29842199be08699e59f87fc providers/implementations/ciphers/cipher_aes_ocb.c 88138a1aff9705e608c0557653be92eb4de65b152555a2b79ec8b2a8fae73e8f providers/implementations/ciphers/cipher_aes_ocb.h 855869ab5a8d7a61a11674cfe5d503dfa67f59e7e393730835d1d8cf0ab85c70 providers/implementations/ciphers/cipher_aes_ocb_hw.c 6a8782c728575d69c86b735c9f47acda5c0daa04e17f1e0faef2c963f23fab20 providers/implementations/ciphers/cipher_aes_wrp.c @@ -557,7 +557,7 @@ b9a61ce951c1904d8315b1bb26c0ab0aaadb47e71d4ead5df0a891608c728c4b providers/impl c95ce5498e724b9b3d58e3c2f4723e7e3e4beb07f9bea9422e43182cbadb43af providers/implementations/include/prov/macsignature.h 29d1a112b799e1f45fdf8bcee8361c2ed67428c250c1cdf408a9fbb7ebf4cce1 providers/implementations/include/prov/names.h 2187713b446d8b6d24ee986748b941ac3e24292c71e07ff9fb53a33021decdda providers/implementations/include/prov/seeding.h -d376c58489ae36fbece94bb88939845ced04a2a0bdd55d6a3562e45a56577ae1 providers/implementations/kdfs/hkdf.c +6091dd22e716fbe6c7c94524cdee6ad4432a572f2d3c4d360dcafafa3902d692 providers/implementations/kdfs/hkdf.c a62e3af09f5af84dcf36f951ba4ac90ca1694adaf3747126186020b155f94186 providers/implementations/kdfs/kbkdf.c e0644e727aacfea4da3cf2c4d2602d7ef0626ebb760b6467432ffd54d5fbb24d providers/implementations/kdfs/pbkdf2.c c0778565abff112c0c5257329a7750ec4605e62f26cc36851fa1fbee6e03c70c providers/implementations/kdfs/pbkdf2.h @@ -566,14 +566,14 @@ abe2b0f3711eaa34846e155cffc9242e4051c45de896f747afd5ac9d87f637dc providers/impl 8571556d77d10e8edc98212473a38f09632e3f19e9995dde89ee6c95f2e84ccf providers/implementations/kdfs/sskdf.c 589f6133799da80760e8bc3ab0191a341ab6d4d2706e92e6eb4a24b0250fefa6 providers/implementations/kdfs/tls1_prf.c 4d4a6d9a562d2dcfec941d3f113a544663b5ac2fbe4accd89ec70c1cc11751d0 providers/implementations/kdfs/x942kdf.c -6b6c776b12664164f3cb54c21df61e1c4477c7855d89431a16fb338cdae58d43 providers/implementations/kem/rsa_kem.c +58acb0ff36bf7e463ba714b347b714eccab9fda77c4ca6bacc3a55e6d2ce5ad9 providers/implementations/kem/rsa_kem.c 11a0d0fb88ed88e965f10b3a0ef6c880f60341df995128f57ad943053aaf15b2 providers/implementations/keymgmt/dh_kmgmt.c -a329f57cb041cd03907e9d996fbc2f378ee116c7f8d7fbf1ea08b7a5df7e0304 providers/implementations/keymgmt/dsa_kmgmt.c +9316fc619e8d8a1d841aa0936fc62c28eb2b4c60cc6c9b2d64b72f8641f28abb providers/implementations/keymgmt/dsa_kmgmt.c 9bc88451d3ae110c7a108ee73d3b3b6bda801ec3494d2dfb9c9970b85c2d34fe providers/implementations/keymgmt/ec_kmgmt.c 258ae17bb2dd87ed1511a8eb3fe99eed9b77f5c2f757215ff6b3d0e8791fc251 providers/implementations/keymgmt/ec_kmgmt_imexport.inc -011c36aad6834729043f23eacab417732541ee23916d9afa5bb9164862be00bb providers/implementations/keymgmt/ecx_kmgmt.c +d0c67b7fbddd51dcfebd96bf99794ca3bc437d50974ebcd56968fb8dd3627b0f providers/implementations/keymgmt/ecx_kmgmt.c 053a2be39a87f50b877ebdbbf799cf5faf8b2de33b04311d819d212ee1ea329b providers/implementations/keymgmt/kdf_legacy_kmgmt.c -1646b477fa231dd0f6c22444c99098f9b447cab0d39ff69b811262469d4dbe09 providers/implementations/keymgmt/mac_legacy_kmgmt.c +37e2f9f904eeabf94b1e4152b67ac236f872aa78dd7e47bf0de1b8f50ac19b6c providers/implementations/keymgmt/mac_legacy_kmgmt.c 19f22fc70a6321441e56d5bd4aab3d01d52d17069d4e4b5cefce0f411ecece75 providers/implementations/keymgmt/rsa_kmgmt.c 5eb96ea2df635cf79c5aeccae270fbe896b5e6384a5b3e4b187ce8c10fe8dfc7 providers/implementations/macs/cmac_prov.c e69aa06f8f3c6f5a26702b9f44a844b8589b99dc0ee590953a29e8b9ef10acbe providers/implementations/macs/gmac_prov.c @@ -588,7 +588,7 @@ f9457255fc57ef5739aa2584e535195e38cc947e31fd044d28d64c28c8a946ce providers/impl 04339b66c10017229ef368cb48077f58a252ebfda9ab12b9f919e4149b1036ed providers/implementations/rands/test_rng.c cafb9e6f54ad15889fcebddac6df61336bff7d78936f7de3bb5aab8aee5728d2 providers/implementations/signature/dsa_sig.c a30dc6308de0ca33406e7ce909f3bcf7580fb84d863b0976b275839f866258df providers/implementations/signature/ecdsa_sig.c -02e833a767afbe98247d6f09dfb1eb5a5cf7304a93f2c5427a9f6af9c8a3b549 providers/implementations/signature/eddsa_sig.c +09647b736980ac3c762f1e7c10cbfee78e2c6ab327ac62e5039968cea034ff3b providers/implementations/signature/eddsa_sig.c 3bb0f342b4cc1b4594ed0986adc47791c0a7b5c1ae7b1888c1fb5edb268a78d9 providers/implementations/signature/mac_legacy_sig.c 166d7e3a049b28ae2c6f94415070720d176a82e46af1613511c4b073ea705476 providers/implementations/signature/rsa_sig.c a14e901b02fe095713624db4080b3aa3ca685d43f9ebec03041f992240973346 ssl/record/tls_pad.c diff --git a/deps/openssl/openssl/providers/fips.checksum b/deps/openssl/openssl/providers/fips.checksum index cbd9c095117..0904f6a1029 100644 --- a/deps/openssl/openssl/providers/fips.checksum +++ b/deps/openssl/openssl/providers/fips.checksum @@ -1 +1 @@ -101807560af8f62c064ad796dfa1e4c269d45aaf5303b47ad0b25fdd6cc92466 providers/fips-sources.checksums +01b31117f96429fe4c8efbf7f4f10ef32efa2b11c69851fd227e4194db116b6f providers/fips-sources.checksums diff --git a/deps/openssl/openssl/providers/implementations/ciphers/cipher_aes_ocb.c b/deps/openssl/openssl/providers/implementations/ciphers/cipher_aes_ocb.c index eab315453ef..891e73f6726 100644 --- a/deps/openssl/openssl/providers/implementations/ciphers/cipher_aes_ocb.c +++ b/deps/openssl/openssl/providers/implementations/ciphers/cipher_aes_ocb.c @@ -369,12 +369,20 @@ static int aes_ocb_set_ctx_params(void *vctx, const OSSL_PARAM params[]) } if (p->data == NULL) { /* Tag len must be 0 to 16 */ - if (p->data_size > OCB_MAX_TAG_LEN) + if (p->data_size > OCB_MAX_TAG_LEN) { + ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_TAG_LENGTH); return 0; + } ctx->taglen = p->data_size; } else { - if (p->data_size != ctx->taglen || ctx->base.enc) + if (ctx->base.enc) { + ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT); + return 0; + } + if (p->data_size != ctx->taglen) { + ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_TAG_LENGTH); return 0; + } memcpy(ctx->tag, p->data, p->data_size); } } diff --git a/deps/openssl/openssl/providers/implementations/encode_decode/encode_key2text.c b/deps/openssl/openssl/providers/implementations/encode_decode/encode_key2text.c index 3e75a9afb37..637fcf6a121 100644 --- a/deps/openssl/openssl/providers/implementations/encode_decode/encode_key2text.c +++ b/deps/openssl/openssl/providers/implementations/encode_decode/encode_key2text.c @@ -112,7 +112,8 @@ static int print_labeled_bignum(BIO *out, const char *label, const BIGNUM *bn) use_sep = 0; /* The first byte on the next line doesnt have a : */ } if (BIO_printf(out, "%s%c%c", use_sep ? ":" : "", - tolower(p[0]), tolower(p[1])) <= 0) + tolower((unsigned char)p[0]), + tolower((unsigned char)p[1])) <= 0) goto err; ++bytes; p += 2; diff --git a/deps/openssl/openssl/providers/implementations/kdfs/hkdf.c b/deps/openssl/openssl/providers/implementations/kdfs/hkdf.c index 3db8b43891a..69ef565d04f 100644 --- a/deps/openssl/openssl/providers/implementations/kdfs/hkdf.c +++ b/deps/openssl/openssl/providers/implementations/kdfs/hkdf.c @@ -669,7 +669,7 @@ static int prov_tls13_hkdf_generate_secret(OSSL_LIB_CTX *libctx, EVP_MD_CTX_free(mctx); /* Generate the pre-extract secret */ - if (!prov_tls13_hkdf_expand(md, prevsecret, mdlen, + if (!prov_tls13_hkdf_expand(md, prevsecret, prevsecretlen, prefix, prefixlen, label, labellen, hash, mdlen, preextractsec, mdlen)) return 0; diff --git a/deps/openssl/openssl/providers/implementations/kdfs/scrypt.c b/deps/openssl/openssl/providers/implementations/kdfs/scrypt.c index a7072f785f0..6fa4192600f 100644 --- a/deps/openssl/openssl/providers/implementations/kdfs/scrypt.c +++ b/deps/openssl/openssl/providers/implementations/kdfs/scrypt.c @@ -1,5 +1,5 @@ /* - * Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2017-2025 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 @@ -88,7 +88,9 @@ static void kdf_scrypt_reset(void *vctx) KDF_SCRYPT *ctx = (KDF_SCRYPT *)vctx; OPENSSL_free(ctx->salt); + ctx->salt = NULL; OPENSSL_clear_free(ctx->pass, ctx->pass_len); + ctx->pass = NULL; kdf_scrypt_init(ctx); } @@ -128,7 +130,6 @@ static int set_digest(KDF_SCRYPT *ctx) EVP_MD_free(ctx->sha256); ctx->sha256 = EVP_MD_fetch(ctx->libctx, "sha256", ctx->propq); if (ctx->sha256 == NULL) { - OPENSSL_free(ctx); ERR_raise(ERR_LIB_PROV, PROV_R_UNABLE_TO_LOAD_SHA256); return 0; } diff --git a/deps/openssl/openssl/providers/implementations/kem/rsa_kem.c b/deps/openssl/openssl/providers/implementations/kem/rsa_kem.c index 882cf161258..94c5bceea59 100644 --- a/deps/openssl/openssl/providers/implementations/kem/rsa_kem.c +++ b/deps/openssl/openssl/providers/implementations/kem/rsa_kem.c @@ -264,6 +264,17 @@ static int rsasve_generate(PROV_RSA_CTX *prsactx, *secretlen = nlen; return 1; } + + /* + * If outlen is specified, then it must report the length + * of the out buffer on input so that we can confirm + * its size is sufficent for encapsulation + */ + if (outlen != NULL && *outlen < nlen) { + ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_OUTPUT_LENGTH); + return 0; + } + /* * Step (2): Generate a random byte string z of nlen bytes where * 1 < z < n - 1 @@ -285,15 +296,33 @@ static int rsasve_generate(PROV_RSA_CTX *prsactx, return ret; } -/* - * NIST.SP.800-56Br2 +/** + * rsasve_recover - Recovers a secret value from ciphertext using an RSA + * private key. Once, recovered, the secret value is considered to be a + * shared secret. Algorithm is preformed as per + * NIST SP 800-56B Rev 2 * 7.2.1.3 RSASVE Recovery Operation (RSASVE.RECOVER). + * + * This function performs RSA decryption using the private key from the + * provided RSA context (`prsactx`). It takes the input ciphertext, decrypts + * it, and writes the decrypted message to the output buffer. + * + * @prsactx: The RSA context containing the private key. + * @out: The output buffer to store the decrypted message. + * @outlen: On input, the size of the output buffer. On successful + * completion, the actual length of the decrypted message. + * @in: The input buffer containing the ciphertext to be decrypted. + * @inlen: The length of the input ciphertext in bytes. + * + * Returns 1 on success, or 0 on error. In case of error, appropriate + * error messages are raised using the ERR_raise function. */ static int rsasve_recover(PROV_RSA_CTX *prsactx, unsigned char *out, size_t *outlen, const unsigned char *in, size_t inlen) { size_t nlen; + int ret; /* Step (1): get the byte length of n */ nlen = RSA_size(prsactx->rsa); @@ -307,13 +336,30 @@ static int rsasve_recover(PROV_RSA_CTX *prsactx, return 1; } - /* Step (2): check the input ciphertext 'inlen' matches the nlen */ + /* + * Step (2): check the input ciphertext 'inlen' matches the nlen + * and that outlen is at least nlen bytes + */ if (inlen != nlen) { ERR_raise(ERR_LIB_PROV, PROV_R_BAD_LENGTH); return 0; } + + /* + * If outlen is specified, then it must report the length + * of the out buffer, so that we can confirm that it is of + * sufficient size to hold the output of decapsulation + */ + if (outlen != NULL && *outlen < nlen) { + ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_OUTPUT_LENGTH); + return 0; + } + /* Step (3): out = RSADP((n,d), in) */ - return (RSA_private_decrypt(inlen, in, out, prsactx->rsa, RSA_NO_PADDING) > 0); + ret = RSA_private_decrypt(inlen, in, out, prsactx->rsa, RSA_NO_PADDING); + if (ret > 0 && outlen != NULL) + *outlen = ret; + return ret > 0; } static int rsakem_generate(void *vprsactx, unsigned char *out, size_t *outlen, diff --git a/deps/openssl/openssl/providers/implementations/keymgmt/dsa_kmgmt.c b/deps/openssl/openssl/providers/implementations/keymgmt/dsa_kmgmt.c index 2f5742cfcc0..e3c3fd6916e 100644 --- a/deps/openssl/openssl/providers/implementations/keymgmt/dsa_kmgmt.c +++ b/deps/openssl/openssl/providers/implementations/keymgmt/dsa_kmgmt.c @@ -426,7 +426,7 @@ static void *dsa_gen_init(void *provctx, int selection, gctx->hindex = 0; } if (!dsa_gen_set_params(gctx, params)) { - OPENSSL_free(gctx); + dsa_gen_cleanup(gctx); gctx = NULL; } return gctx; diff --git a/deps/openssl/openssl/providers/implementations/keymgmt/ecx_kmgmt.c b/deps/openssl/openssl/providers/implementations/keymgmt/ecx_kmgmt.c index 987d38456fb..94e62f755c2 100644 --- a/deps/openssl/openssl/providers/implementations/keymgmt/ecx_kmgmt.c +++ b/deps/openssl/openssl/providers/implementations/keymgmt/ecx_kmgmt.c @@ -487,7 +487,7 @@ static void *ecx_gen_init(void *provctx, int selection, gctx->selection = selection; } if (!ecx_gen_set_params(gctx, params)) { - OPENSSL_free(gctx); + ecx_gen_cleanup(gctx); gctx = NULL; } return gctx; diff --git a/deps/openssl/openssl/providers/implementations/keymgmt/mac_legacy_kmgmt.c b/deps/openssl/openssl/providers/implementations/keymgmt/mac_legacy_kmgmt.c index 1fae4407fca..b02a0a91c6f 100644 --- a/deps/openssl/openssl/providers/implementations/keymgmt/mac_legacy_kmgmt.c +++ b/deps/openssl/openssl/providers/implementations/keymgmt/mac_legacy_kmgmt.c @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2020-2025 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 @@ -399,7 +399,7 @@ static void *mac_gen_init(void *provctx, int selection, struct mac_gen_ctx *gctx = mac_gen_init_common(provctx, selection); if (gctx != NULL && !mac_gen_set_params(gctx, params)) { - OPENSSL_free(gctx); + mac_gen_cleanup(gctx); gctx = NULL; } return gctx; @@ -411,7 +411,7 @@ static void *cmac_gen_init(void *provctx, int selection, struct mac_gen_ctx *gctx = mac_gen_init_common(provctx, selection); if (gctx != NULL && !cmac_gen_set_params(gctx, params)) { - OPENSSL_free(gctx); + mac_gen_cleanup(gctx); gctx = NULL; } return gctx; diff --git a/deps/openssl/openssl/providers/implementations/signature/eddsa_sig.c b/deps/openssl/openssl/providers/implementations/signature/eddsa_sig.c index c78f1fbb5fa..9ec910af252 100644 --- a/deps/openssl/openssl/providers/implementations/signature/eddsa_sig.c +++ b/deps/openssl/openssl/providers/implementations/signature/eddsa_sig.c @@ -1,5 +1,5 @@ /* - * Copyright 2020-2022 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2020-2025 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 @@ -133,6 +133,7 @@ static int eddsa_digest_signverify_init(void *vpeddsactx, const char *mdname, /* Should never happen */ ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR); ossl_ecx_key_free(edkey); + WPACKET_cleanup(&pkt); return 0; } if (ret && WPACKET_finish(&pkt)) { diff --git a/deps/openssl/openssl/providers/implementations/storemgmt/file_store.c b/deps/openssl/openssl/providers/implementations/storemgmt/file_store.c index bb8b2ab8625..3049a9c8113 100644 --- a/deps/openssl/openssl/providers/implementations/storemgmt/file_store.c +++ b/deps/openssl/openssl/providers/implementations/storemgmt/file_store.c @@ -238,7 +238,7 @@ static void *file_open(void *provctx, const char *uri) #ifdef _WIN32 /* Windows file: URIs with a drive letter start with a / */ if (p[0] == '/' && p[2] == ':' && p[3] == '/') { - char c = tolower(p[1]); + char c = tolower((unsigned char)p[1]); if (c >= 'a' && c <= 'z') { p++; diff --git a/deps/openssl/openssl/ssl/build.info b/deps/openssl/openssl/ssl/build.info index d99835c9a0d..0851357f81e 100644 --- a/deps/openssl/openssl/ssl/build.info +++ b/deps/openssl/openssl/ssl/build.info @@ -37,11 +37,8 @@ IF[{- !$disabled{'deprecated-3.0'} -}] SHARED_SOURCE[../libssl]=s3_cbc.c SOURCE[../libssl]=ssl_rsa_legacy.c ENDIF -DEFINE[../libssl]=$AESDEF -IF[{- !$disabled{quic} -}] - SOURCE[../libssl]=ssl_quic.c statem/statem_quic.c -ENDIF +DEFINE[../libssl]=$AESDEF SOURCE[../providers/libcommon.a]=record/tls_pad.c SOURCE[../providers/libdefault.a ../providers/libfips.a]=s3_cbc.c diff --git a/deps/openssl/openssl/ssl/s3_msg.c b/deps/openssl/openssl/ssl/s3_msg.c index dd2fe040e04..c0f0dbc17dc 100644 --- a/deps/openssl/openssl/ssl/s3_msg.c +++ b/deps/openssl/openssl/ssl/s3_msg.c @@ -81,16 +81,6 @@ int ssl3_dispatch_alert(SSL *s) s->s3.alert_dispatch = 0; alertlen = 2; -#ifndef OPENSSL_NO_QUIC - if (SSL_IS_QUIC(s)) { - if (!s->quic_method->send_alert(s, s->quic_write_level, - s->s3.send_alert[1])) { - ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR); - return 0; - } - i = 1; - } else -#endif i = do_ssl3_write(s, SSL3_RT_ALERT, &s->s3.send_alert[0], &alertlen, 1, 0, &written); if (i <= 0) { diff --git a/deps/openssl/openssl/ssl/ssl_ciph.c b/deps/openssl/openssl/ssl/ssl_ciph.c index 76a1a8c967e..9e32417e75d 100644 --- a/deps/openssl/openssl/ssl/ssl_ciph.c +++ b/deps/openssl/openssl/ssl/ssl_ciph.c @@ -2240,37 +2240,3 @@ const char *OSSL_default_ciphersuites(void) "TLS_CHACHA20_POLY1305_SHA256:" "TLS_AES_128_GCM_SHA256"; } - -#ifndef OPENSSL_NO_QUIC -int SSL_CIPHER_get_prf_nid(const SSL_CIPHER *c) -{ - switch (c->algorithm2 & (0xFF << TLS1_PRF_DGST_SHIFT)) { - default: - break; - case TLS1_PRF_SHA1_MD5: /* TLS1_PRF */ - return NID_md5_sha1; - case TLS1_PRF_SHA256: - return NID_sha256; - case TLS1_PRF_SHA384: - return NID_sha384; - case TLS1_PRF_GOST94: - return NID_id_GostR3411_94_prf; - case TLS1_PRF_GOST12_256: - return NID_id_GostR3411_2012_256; - case TLS1_PRF_GOST12_512: - return NID_id_GostR3411_2012_512; - } - /* TLSv1.3 ciphers don't specify separate PRF */ - switch (c->algorithm2 & SSL_HANDSHAKE_MAC_MASK) { - default: - break; - case SSL_HANDSHAKE_MAC_MD5_SHA1: /* SSL_HANDSHAKE_MAC_DEFAULT */ - return NID_md5_sha1; - case SSL_HANDSHAKE_MAC_SHA256: - return NID_sha256; - case SSL_HANDSHAKE_MAC_SHA384: - return NID_sha384; - } - return NID_undef; -} -#endif diff --git a/deps/openssl/openssl/ssl/ssl_err.c b/deps/openssl/openssl/ssl/ssl_err.c index fe0d9c280f7..75be692e000 100644 --- a/deps/openssl/openssl/ssl/ssl_err.c +++ b/deps/openssl/openssl/ssl/ssl_err.c @@ -241,8 +241,6 @@ static const ERR_STRING_DATA SSL_str_reasons[] = { {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_MISSING_PARAMETERS), "missing parameters"}, {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_MISSING_PSK_KEX_MODES_EXTENSION), "missing psk kex modes extension"}, - {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_MISSING_QUIC_TRANSPORT_PARAMETERS_EXTENSION), - "missing quic transport parameters extension"}, {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_MISSING_RSA_CERTIFICATE), "missing rsa certificate"}, {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_MISSING_RSA_ENCRYPTING_CERT), @@ -550,8 +548,6 @@ static const ERR_STRING_DATA SSL_str_reasons[] = { {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_WRONG_CIPHER_RETURNED), "wrong cipher returned"}, {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_WRONG_CURVE), "wrong curve"}, - {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_WRONG_ENCRYPTION_LEVEL_RECEIVED), - "wrong encryption level received"}, {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_WRONG_SIGNATURE_LENGTH), "wrong signature length"}, {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_WRONG_SIGNATURE_SIZE), diff --git a/deps/openssl/openssl/ssl/ssl_lib.c b/deps/openssl/openssl/ssl/ssl_lib.c index 2619636df88..e628140dfae 100644 --- a/deps/openssl/openssl/ssl/ssl_lib.c +++ b/deps/openssl/openssl/ssl/ssl_lib.c @@ -581,56 +581,7 @@ static void clear_ciphers(SSL *s) ssl_clear_hash_ctx(&s->write_hash); } -#ifndef OPENSSL_NO_QUIC int SSL_clear(SSL *s) -{ - if (!SSL_clear_not_quic(s)) - return 0; - return SSL_clear_quic(s); -} - -int SSL_clear_quic(SSL *s) -{ - OPENSSL_free(s->ext.peer_quic_transport_params_draft); - s->ext.peer_quic_transport_params_draft = NULL; - s->ext.peer_quic_transport_params_draft_len = 0; - OPENSSL_free(s->ext.peer_quic_transport_params); - s->ext.peer_quic_transport_params = NULL; - s->ext.peer_quic_transport_params_len = 0; - s->quic_read_level = ssl_encryption_initial; - s->quic_write_level = ssl_encryption_initial; - s->quic_latest_level_received = ssl_encryption_initial; - while (s->quic_input_data_head != NULL) { - QUIC_DATA *qd; - - qd = s->quic_input_data_head; - s->quic_input_data_head = qd->next; - OPENSSL_free(qd); - } - s->quic_input_data_tail = NULL; - BUF_MEM_free(s->quic_buf); - s->quic_buf = NULL; - s->quic_next_record_start = 0; - memset(s->client_hand_traffic_secret, 0, EVP_MAX_MD_SIZE); - memset(s->server_hand_traffic_secret, 0, EVP_MAX_MD_SIZE); - memset(s->client_early_traffic_secret, 0, EVP_MAX_MD_SIZE); - /* - * CONFIG - DON'T CLEAR - * s->ext.quic_transport_params - * s->ext.quic_transport_params_len - * s->quic_transport_version - * s->quic_method = NULL; - */ - return 1; -} -#endif - -/* Keep this conditional very local */ -#ifndef OPENSSL_NO_QUIC -int SSL_clear_not_quic(SSL *s) -#else -int SSL_clear(SSL *s) -#endif { if (s->method == NULL) { ERR_raise(ERR_LIB_SSL, SSL_R_NO_METHOD_SPECIFIED); @@ -905,10 +856,6 @@ SSL *SSL_new(SSL_CTX *ctx) s->job = NULL; -#ifndef OPENSSL_NO_QUIC - s->quic_method = ctx->quic_method; -#endif - #ifndef OPENSSL_NO_CT if (!SSL_set_ct_validation_callback(s, ctx->ct_validation_callback, ctx->ct_validation_callback_arg)) @@ -1306,20 +1253,6 @@ void SSL_free(SSL *s) OPENSSL_free(s->pha_context); EVP_MD_CTX_free(s->pha_dgst); -#ifndef OPENSSL_NO_QUIC - OPENSSL_free(s->ext.quic_transport_params); - OPENSSL_free(s->ext.peer_quic_transport_params_draft); - OPENSSL_free(s->ext.peer_quic_transport_params); - BUF_MEM_free(s->quic_buf); - while (s->quic_input_data_head != NULL) { - QUIC_DATA *qd; - - qd = s->quic_input_data_head; - s->quic_input_data_head = qd->next; - OPENSSL_free(qd); - } -#endif - sk_X509_NAME_pop_free(s->ca_names, X509_NAME_free); sk_X509_NAME_pop_free(s->client_ca_names, X509_NAME_free); @@ -1919,12 +1852,6 @@ static int ssl_io_intern(void *vargs) int ssl_read_internal(SSL *s, void *buf, size_t num, size_t *readbytes) { -#ifndef OPENSSL_NO_QUIC - if (SSL_IS_QUIC(s)) { - ERR_raise(ERR_LIB_SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); - return -1; - } -#endif if (s->handshake_func == NULL) { ERR_raise(ERR_LIB_SSL, SSL_R_UNINITIALIZED); return -1; @@ -2056,12 +1983,6 @@ int SSL_get_early_data_status(const SSL *s) static int ssl_peek_internal(SSL *s, void *buf, size_t num, size_t *readbytes) { -#ifndef OPENSSL_NO_QUIC - if (SSL_IS_QUIC(s)) { - ERR_raise(ERR_LIB_SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); - return -1; - } -#endif if (s->handshake_func == NULL) { ERR_raise(ERR_LIB_SSL, SSL_R_UNINITIALIZED); return -1; @@ -2122,12 +2043,6 @@ int SSL_peek_ex(SSL *s, void *buf, size_t num, size_t *readbytes) int ssl_write_internal(SSL *s, const void *buf, size_t num, size_t *written) { -#ifndef OPENSSL_NO_QUIC - if (SSL_IS_QUIC(s)) { - ERR_raise(ERR_LIB_SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); - return -1; - } -#endif if (s->handshake_func == NULL) { ERR_raise(ERR_LIB_SSL, SSL_R_UNINITIALIZED); return -1; @@ -3960,11 +3875,6 @@ int SSL_get_error(const SSL *s, int i) } if (SSL_want_read(s)) { -#ifndef OPENSSL_NO_QUIC - if (SSL_IS_QUIC(s)) { - return SSL_ERROR_WANT_READ; - } -#endif bio = SSL_get_rbio(s); if (BIO_should_read(bio)) return SSL_ERROR_WANT_READ; @@ -4064,21 +3974,6 @@ int SSL_do_handshake(SSL *s) ret = s->handshake_func(s); } } -#ifndef OPENSSL_NO_QUIC - if (SSL_IS_QUIC(s) && ret == 1) { - if (s->server) { - if (s->early_data_state == SSL_EARLY_DATA_ACCEPTING) { - s->early_data_state = SSL_EARLY_DATA_FINISHED_READING; - s->rwstate = SSL_READING; - ret = 0; - } - } else if (s->early_data_state == SSL_EARLY_DATA_CONNECTING) { - s->early_data_state = SSL_EARLY_DATA_WRITE_RETRY; - s->rwstate = SSL_READING; - ret = 0; - } - } -#endif return ret; } diff --git a/deps/openssl/openssl/ssl/ssl_local.h b/deps/openssl/openssl/ssl/ssl_local.h index 51c4a77a9ed..5fb1feb8016 100644 --- a/deps/openssl/openssl/ssl/ssl_local.h +++ b/deps/openssl/openssl/ssl/ssl_local.h @@ -337,13 +337,6 @@ /* Flag used on OpenSSL ciphersuite ids to indicate they are for SSLv3+ */ # define SSL3_CK_CIPHERSUITE_FLAG 0x03000000 -/* Check if an SSL structure is using QUIC (which uses TLSv1.3) */ -# ifndef OPENSSL_NO_QUIC -# define SSL_IS_QUIC(s) (s->quic_method != NULL) -# else -# define SSL_IS_QUIC(s) 0 -# endif - /* Check if an SSL structure is using DTLS */ # define SSL_IS_DTLS(s) (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_DTLS) @@ -773,8 +766,6 @@ typedef enum tlsext_index_en { TLSEXT_IDX_cryptopro_bug, TLSEXT_IDX_early_data, TLSEXT_IDX_certificate_authorities, - TLSEXT_IDX_quic_transport_parameters_draft, - TLSEXT_IDX_quic_transport_parameters, TLSEXT_IDX_padding, TLSEXT_IDX_psk, /* Dummy index - must always be the last entry */ @@ -1214,25 +1205,10 @@ struct ssl_ctx_st { uint32_t disabled_mac_mask; uint32_t disabled_mkey_mask; uint32_t disabled_auth_mask; - -#ifndef OPENSSL_NO_QUIC - const SSL_QUIC_METHOD *quic_method; -#endif }; typedef struct cert_pkey_st CERT_PKEY; -#ifndef OPENSSL_NO_QUIC -struct quic_data_st { - struct quic_data_st *next; - OSSL_ENCRYPTION_LEVEL level; - size_t start; /* offset into quic_buf->data */ - size_t length; -}; -typedef struct quic_data_st QUIC_DATA; -int quic_set_encryption_secrets(SSL *ssl, OSSL_ENCRYPTION_LEVEL level); -#endif - struct ssl_st { /* * protocol version (one of SSL2_VERSION, SSL3_VERSION, TLS1_VERSION, @@ -1492,11 +1468,6 @@ struct ssl_st { unsigned char handshake_traffic_hash[EVP_MAX_MD_SIZE]; unsigned char client_app_traffic_secret[EVP_MAX_MD_SIZE]; unsigned char server_app_traffic_secret[EVP_MAX_MD_SIZE]; -# ifndef OPENSSL_NO_QUIC - unsigned char client_hand_traffic_secret[EVP_MAX_MD_SIZE]; - unsigned char server_hand_traffic_secret[EVP_MAX_MD_SIZE]; - unsigned char client_early_traffic_secret[EVP_MAX_MD_SIZE]; -# endif unsigned char exporter_master_secret[EVP_MAX_MD_SIZE]; unsigned char early_exporter_master_secret[EVP_MAX_MD_SIZE]; EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */ @@ -1709,35 +1680,8 @@ struct ssl_st { * selected. */ int tick_identity; - -#ifndef OPENSSL_NO_QUIC - uint8_t *quic_transport_params; - size_t quic_transport_params_len; - uint8_t *peer_quic_transport_params_draft; - size_t peer_quic_transport_params_draft_len; - uint8_t *peer_quic_transport_params; - size_t peer_quic_transport_params_len; -#endif } ext; -#ifndef OPENSSL_NO_QUIC - OSSL_ENCRYPTION_LEVEL quic_read_level; - OSSL_ENCRYPTION_LEVEL quic_write_level; - OSSL_ENCRYPTION_LEVEL quic_latest_level_received; - BUF_MEM *quic_buf; /* buffer incoming handshake messages */ - /* - * defaults to 0, but can be set to: - * - TLSEXT_TYPE_quic_transport_parameters_draft - * - TLSEXT_TYPE_quic_transport_parameters - * Client: if 0, send both - * Server: if 0, use same version as client sent - */ - int quic_transport_version; - QUIC_DATA *quic_input_data_head; - QUIC_DATA *quic_input_data_tail; - size_t quic_next_record_start; - const SSL_QUIC_METHOD *quic_method; -#endif /* * Parsed form of the ClientHello, kept around across client_hello_cb * calls. @@ -2867,11 +2811,6 @@ void custom_exts_free(custom_ext_methods *exts); void ssl_comp_free_compression_methods_int(void); -#ifndef OPENSSL_NO_QUIC -__owur int SSL_clear_not_quic(SSL *s); -__owur int SSL_clear_quic(SSL *s); -#endif - /* ssl_mcnf.c */ void ssl_ctx_system_config(SSL_CTX *ctx); diff --git a/deps/openssl/openssl/ssl/ssl_quic.c b/deps/openssl/openssl/ssl/ssl_quic.c deleted file mode 100644 index 987c1e740ca..00000000000 --- a/deps/openssl/openssl/ssl/ssl_quic.c +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright 2019-2021 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 - * https://www.openssl.org/source/license.html - */ - -#include "ssl_local.h" -#include "internal/cryptlib.h" -#include "internal/refcount.h" - -int SSL_set_quic_transport_params(SSL *ssl, const uint8_t *params, - size_t params_len) -{ - uint8_t *tmp; - - if (params == NULL || params_len == 0) { - tmp = NULL; - params_len = 0; - } else { - tmp = OPENSSL_memdup(params, params_len); - if (tmp == NULL) - return 0; - } - - OPENSSL_free(ssl->ext.quic_transport_params); - ssl->ext.quic_transport_params = tmp; - ssl->ext.quic_transport_params_len = params_len; - return 1; -} - -void SSL_get_peer_quic_transport_params(const SSL *ssl, - const uint8_t **out_params, - size_t *out_params_len) -{ - if (ssl->ext.peer_quic_transport_params_len) { - *out_params = ssl->ext.peer_quic_transport_params; - *out_params_len = ssl->ext.peer_quic_transport_params_len; - } else { - *out_params = ssl->ext.peer_quic_transport_params_draft; - *out_params_len = ssl->ext.peer_quic_transport_params_draft_len; - } -} - -/* Returns the negotiated version, or -1 on error */ -int SSL_get_peer_quic_transport_version(const SSL *ssl) -{ - if (ssl->ext.peer_quic_transport_params_len != 0 - && ssl->ext.peer_quic_transport_params_draft_len != 0) - return -1; - if (ssl->ext.peer_quic_transport_params_len != 0) - return TLSEXT_TYPE_quic_transport_parameters; - if (ssl->ext.peer_quic_transport_params_draft_len != 0) - return TLSEXT_TYPE_quic_transport_parameters_draft; - - return -1; -} - -void SSL_set_quic_use_legacy_codepoint(SSL *ssl, int use_legacy) -{ - if (use_legacy) - ssl->quic_transport_version = TLSEXT_TYPE_quic_transport_parameters_draft; - else - ssl->quic_transport_version = TLSEXT_TYPE_quic_transport_parameters; -} - -void SSL_set_quic_transport_version(SSL *ssl, int version) -{ - ssl->quic_transport_version = version; -} - -int SSL_get_quic_transport_version(const SSL *ssl) -{ - return ssl->quic_transport_version; -} - -size_t SSL_quic_max_handshake_flight_len(const SSL *ssl, OSSL_ENCRYPTION_LEVEL level) -{ - /* - * Limits flights to 16K by default when there are no large - * (certificate-carrying) messages. - */ - static const size_t DEFAULT_FLIGHT_LIMIT = 16384; - - switch (level) { - case ssl_encryption_initial: - return DEFAULT_FLIGHT_LIMIT; - case ssl_encryption_early_data: - /* QUIC does not send EndOfEarlyData. */ - return 0; - case ssl_encryption_handshake: - if (ssl->server) { - /* - * Servers may receive Certificate message if configured to request - * client certificates. - */ - if ((ssl->verify_mode & SSL_VERIFY_PEER) - && ssl->max_cert_list > DEFAULT_FLIGHT_LIMIT) - return ssl->max_cert_list; - } else { - /* - * Clients may receive both Certificate message and a CertificateRequest - * message. - */ - if (2*ssl->max_cert_list > DEFAULT_FLIGHT_LIMIT) - return 2 * ssl->max_cert_list; - } - return DEFAULT_FLIGHT_LIMIT; - case ssl_encryption_application: - return DEFAULT_FLIGHT_LIMIT; - } - - return 0; -} - -OSSL_ENCRYPTION_LEVEL SSL_quic_read_level(const SSL *ssl) -{ - return ssl->quic_read_level; -} - -OSSL_ENCRYPTION_LEVEL SSL_quic_write_level(const SSL *ssl) -{ - return ssl->quic_write_level; -} - -int SSL_provide_quic_data(SSL *ssl, OSSL_ENCRYPTION_LEVEL level, - const uint8_t *data, size_t len) -{ - size_t l, offset; - - if (!SSL_IS_QUIC(ssl)) { - ERR_raise(ERR_LIB_SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); - return 0; - } - - /* Level can be different than the current read, but not less */ - if (level < ssl->quic_read_level - || (ssl->quic_input_data_tail != NULL && level < ssl->quic_input_data_tail->level) - || level < ssl->quic_latest_level_received) { - ERR_raise(ERR_LIB_SSL, SSL_R_WRONG_ENCRYPTION_LEVEL_RECEIVED); - return 0; - } - - if (len == 0) - return 1; - - if (ssl->quic_buf == NULL) { - BUF_MEM *buf; - if ((buf = BUF_MEM_new()) == NULL) { - ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR); - return 0; - } - if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { - ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR); - BUF_MEM_free(buf); - return 0; - } - ssl->quic_buf = buf; - /* We preallocated storage, but there's still no *data*. */ - ssl->quic_buf->length = 0; - buf = NULL; - } - - /* A TLS message must not cross an encryption level boundary */ - if (ssl->quic_buf->length != ssl->quic_next_record_start - && level != ssl->quic_latest_level_received) { - ERR_raise(ERR_LIB_SSL, SSL_R_WRONG_ENCRYPTION_LEVEL_RECEIVED); - return 0; - } - ssl->quic_latest_level_received = level; - - offset = ssl->quic_buf->length; - if (!BUF_MEM_grow(ssl->quic_buf, offset + len)) { - ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR); - return 0; - } - memcpy(ssl->quic_buf->data + offset, data, len); - - /* Split on handshake message boundaries */ - while (ssl->quic_buf->length > ssl->quic_next_record_start - + SSL3_HM_HEADER_LENGTH) { - QUIC_DATA *qd; - const uint8_t *p; - - /* TLS Handshake message header has 1-byte type and 3-byte length */ - p = (const uint8_t *)ssl->quic_buf->data - + ssl->quic_next_record_start + 1; - n2l3(p, l); - l += SSL3_HM_HEADER_LENGTH; - /* Don't allocate a QUIC_DATA if we don't have a full record */ - if (l > ssl->quic_buf->length - ssl->quic_next_record_start) - break; - - qd = OPENSSL_zalloc(sizeof(*qd)); - if (qd == NULL) { - ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR); - return 0; - } - - qd->next = NULL; - qd->length = l; - qd->start = ssl->quic_next_record_start; - qd->level = level; - - if (ssl->quic_input_data_tail != NULL) - ssl->quic_input_data_tail->next = qd; - else - ssl->quic_input_data_head = qd; - ssl->quic_input_data_tail = qd; - ssl->quic_next_record_start += l; - } - - return 1; -} - -int SSL_CTX_set_quic_method(SSL_CTX *ctx, const SSL_QUIC_METHOD *quic_method) -{ - if (ctx->method->version != TLS_ANY_VERSION) - return 0; - ctx->quic_method = quic_method; - ctx->options &= ~SSL_OP_ENABLE_MIDDLEBOX_COMPAT; - return 1; -} - -int SSL_set_quic_method(SSL *ssl, const SSL_QUIC_METHOD *quic_method) -{ - if (ssl->method->version != TLS_ANY_VERSION) - return 0; - ssl->quic_method = quic_method; - ssl->options &= ~SSL_OP_ENABLE_MIDDLEBOX_COMPAT; - return 1; -} - -int quic_set_encryption_secrets(SSL *ssl, OSSL_ENCRYPTION_LEVEL level) -{ - uint8_t *c2s_secret = NULL; - uint8_t *s2c_secret = NULL; - size_t len; - const EVP_MD *md; - - if (!SSL_IS_QUIC(ssl)) - return 1; - - /* secrets from the POV of the client */ - switch (level) { - case ssl_encryption_early_data: - c2s_secret = ssl->client_early_traffic_secret; - break; - case ssl_encryption_handshake: - c2s_secret = ssl->client_hand_traffic_secret; - s2c_secret = ssl->server_hand_traffic_secret; - break; - case ssl_encryption_application: - c2s_secret = ssl->client_app_traffic_secret; - s2c_secret = ssl->server_app_traffic_secret; - break; - default: - return 1; - } - - if (level == ssl_encryption_early_data) { - const SSL_CIPHER *c = SSL_SESSION_get0_cipher(ssl->session); - if (ssl->early_data_state == SSL_EARLY_DATA_CONNECTING - && ssl->max_early_data > 0 - && ssl->session->ext.max_early_data == 0) { - if (!ossl_assert(ssl->psksession != NULL - && ssl->max_early_data == - ssl->psksession->ext.max_early_data)) { - SSLfatal(ssl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - return 0; - } - c = SSL_SESSION_get0_cipher(ssl->psksession); - } - - if (c == NULL) { - SSLfatal(ssl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - return 0; - } - - md = ssl_md(ssl->ctx, c->algorithm2); - } else { - md = ssl_handshake_md(ssl); - if (md == NULL) { - /* May not have selected cipher, yet */ - const SSL_CIPHER *c = NULL; - - /* - * It probably doesn't make sense to use an (external) PSK session, - * but in theory some kinds of external session caches could be - * implemented using it, so allow psksession to be used as well as - * the regular session. - */ - if (ssl->session != NULL) - c = SSL_SESSION_get0_cipher(ssl->session); - else if (ssl->psksession != NULL) - c = SSL_SESSION_get0_cipher(ssl->psksession); - - if (c != NULL) - md = SSL_CIPHER_get_handshake_digest(c); - } - } - - if ((len = EVP_MD_size(md)) <= 0) { - SSLfatal(ssl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - return 0; - } - - if (ssl->server) { - if (!ssl->quic_method->set_encryption_secrets(ssl, level, c2s_secret, - s2c_secret, len)) { - SSLfatal(ssl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - return 0; - } - } else { - if (!ssl->quic_method->set_encryption_secrets(ssl, level, s2c_secret, - c2s_secret, len)) { - SSLfatal(ssl, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - return 0; - } - } - - return 1; -} - -int SSL_process_quic_post_handshake(SSL *ssl) -{ - int ret; - - if (SSL_in_init(ssl) || !SSL_IS_QUIC(ssl)) { - ERR_raise(ERR_LIB_SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); - return 0; - } - - /* if there is no data, return success as BoringSSL */ - while (ssl->quic_input_data_head != NULL) { - /* - * This is always safe (we are sure to be at a record boundary) because - * SSL_read()/SSL_write() are never used for QUIC connections -- the - * application data is handled at the QUIC layer instead. - */ - ossl_statem_set_in_init(ssl, 1); - ret = ssl->handshake_func(ssl); - ossl_statem_set_in_init(ssl, 0); - - if (ret <= 0) - return 0; - } - return 1; -} - -int SSL_is_quic(SSL* ssl) -{ - return SSL_IS_QUIC(ssl); -} - -void SSL_set_quic_early_data_enabled(SSL *ssl, int enabled) -{ - if (!SSL_is_quic(ssl) || !SSL_in_before(ssl)) - return; - - if (!enabled) { - ssl->early_data_state = SSL_EARLY_DATA_NONE; - return; - } - - if (ssl->server) { - ssl->early_data_state = SSL_EARLY_DATA_ACCEPTING; - return; - } - - if ((ssl->session == NULL || ssl->session->ext.max_early_data == 0) - && ssl->psk_use_session_cb == NULL) - return; - - ssl->early_data_state = SSL_EARLY_DATA_CONNECTING; -} diff --git a/deps/openssl/openssl/ssl/statem/extensions.c b/deps/openssl/openssl/ssl/statem/extensions.c index ed78744119e..f8157389b7f 100644 --- a/deps/openssl/openssl/ssl/statem/extensions.c +++ b/deps/openssl/openssl/ssl/statem/extensions.c @@ -59,11 +59,6 @@ static int final_early_data(SSL *s, unsigned int context, int sent); static int final_maxfragmentlen(SSL *s, unsigned int context, int sent); static int init_post_handshake_auth(SSL *s, unsigned int context); static int final_psk(SSL *s, unsigned int context, int sent); -#ifndef OPENSSL_NO_QUIC -static int init_quic_transport_params(SSL *s, unsigned int context); -static int final_quic_transport_params_draft(SSL *s, unsigned int context, int sent); -static int final_quic_transport_params(SSL *s, unsigned int context, int sent); -#endif /* Structure to define a built-in extension */ typedef struct extensions_definition_st { @@ -375,29 +370,6 @@ static const EXTENSION_DEFINITION ext_defs[] = { tls_construct_certificate_authorities, tls_construct_certificate_authorities, NULL, }, -#ifndef OPENSSL_NO_QUIC - { - TLSEXT_TYPE_quic_transport_parameters_draft, - SSL_EXT_CLIENT_HELLO | SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS - | SSL_EXT_TLS_IMPLEMENTATION_ONLY | SSL_EXT_TLS1_3_ONLY, - init_quic_transport_params, - tls_parse_ctos_quic_transport_params_draft, tls_parse_stoc_quic_transport_params_draft, - tls_construct_stoc_quic_transport_params_draft, tls_construct_ctos_quic_transport_params_draft, - final_quic_transport_params_draft, - }, - { - TLSEXT_TYPE_quic_transport_parameters, - SSL_EXT_CLIENT_HELLO | SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS - | SSL_EXT_TLS_IMPLEMENTATION_ONLY | SSL_EXT_TLS1_3_ONLY, - init_quic_transport_params, - tls_parse_ctos_quic_transport_params, tls_parse_stoc_quic_transport_params, - tls_construct_stoc_quic_transport_params, tls_construct_ctos_quic_transport_params, - final_quic_transport_params, - }, -#else - INVALID_EXTENSION, - INVALID_EXTENSION, -#endif { /* Must be immediately before pre_shared_key */ TLSEXT_TYPE_padding, @@ -1750,44 +1722,3 @@ static int final_psk(SSL *s, unsigned int context, int sent) return 1; } - -#ifndef OPENSSL_NO_QUIC -static int init_quic_transport_params(SSL *s, unsigned int context) -{ - return 1; -} - -static int final_quic_transport_params_draft(SSL *s, unsigned int context, - int sent) -{ - return 1; -} - -static int final_quic_transport_params(SSL *s, unsigned int context, int sent) -{ - /* called after final_quic_transport_params_draft */ - if (SSL_IS_QUIC(s)) { - if (s->ext.peer_quic_transport_params_len == 0 - && s->ext.peer_quic_transport_params_draft_len == 0) { - SSLfatal(s, SSL_AD_MISSING_EXTENSION, - SSL_R_MISSING_QUIC_TRANSPORT_PARAMETERS_EXTENSION); - return 0; - } - /* if we got both, discard the one we can't use */ - if (s->ext.peer_quic_transport_params_len != 0 - && s->ext.peer_quic_transport_params_draft_len != 0) { - if (s->quic_transport_version == TLSEXT_TYPE_quic_transport_parameters_draft) { - OPENSSL_free(s->ext.peer_quic_transport_params); - s->ext.peer_quic_transport_params = NULL; - s->ext.peer_quic_transport_params_len = 0; - } else { - OPENSSL_free(s->ext.peer_quic_transport_params_draft); - s->ext.peer_quic_transport_params_draft = NULL; - s->ext.peer_quic_transport_params_draft_len = 0; - } - } - } - - return 1; -} -#endif diff --git a/deps/openssl/openssl/ssl/statem/extensions_clnt.c b/deps/openssl/openssl/ssl/statem/extensions_clnt.c index 3b0781fc71c..ced88f77ba3 100644 --- a/deps/openssl/openssl/ssl/statem/extensions_clnt.c +++ b/deps/openssl/openssl/ssl/statem/extensions_clnt.c @@ -1196,47 +1196,7 @@ EXT_RETURN tls_construct_ctos_post_handshake_auth(SSL *s, WPACKET *pkt, #endif } -#ifndef OPENSSL_NO_QUIC -EXT_RETURN tls_construct_ctos_quic_transport_params_draft(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx) -{ - if (s->quic_transport_version == TLSEXT_TYPE_quic_transport_parameters - || s->ext.quic_transport_params == NULL - || s->ext.quic_transport_params_len == 0) { - return EXT_RETURN_NOT_SENT; - } - - if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_quic_transport_parameters_draft) - || !WPACKET_sub_memcpy_u16(pkt, s->ext.quic_transport_params, - s->ext.quic_transport_params_len)) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - return EXT_RETURN_FAIL; - } - - return EXT_RETURN_SENT; -} -EXT_RETURN tls_construct_ctos_quic_transport_params(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx) -{ - if (s->quic_transport_version == TLSEXT_TYPE_quic_transport_parameters_draft - || s->ext.quic_transport_params == NULL - || s->ext.quic_transport_params_len == 0) { - return EXT_RETURN_NOT_SENT; - } - - if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_quic_transport_parameters) - || !WPACKET_sub_memcpy_u16(pkt, s->ext.quic_transport_params, - s->ext.quic_transport_params_len)) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - return EXT_RETURN_FAIL; - } - - return EXT_RETURN_SENT; -} -#endif /* * Parse the server's renegotiation binding and abort if it's not right */ @@ -1964,17 +1924,6 @@ int tls_parse_stoc_early_data(SSL *s, PACKET *pkt, unsigned int context, return 0; } -#ifndef OPENSSL_NO_QUIC - /* - * QUIC server must send 0xFFFFFFFF or it's a PROTOCOL_VIOLATION - * per RFC9001 S4.6.1 - */ - if (SSL_IS_QUIC(s) && max_early_data != 0xFFFFFFFF) { - SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_R_INVALID_MAX_EARLY_DATA); - return 0; - } -#endif - s->session->ext.max_early_data = max_early_data; return 1; @@ -2057,37 +2006,3 @@ int tls_parse_stoc_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x, return 1; } -#ifndef OPENSSL_NO_QUIC -int tls_parse_stoc_quic_transport_params_draft(SSL *s, PACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx) -{ - OPENSSL_free(s->ext.peer_quic_transport_params_draft); - s->ext.peer_quic_transport_params_draft = NULL; - s->ext.peer_quic_transport_params_draft_len = 0; - - if (!PACKET_memdup(pkt, - &s->ext.peer_quic_transport_params_draft, - &s->ext.peer_quic_transport_params_draft_len)) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - return 0; - } - return 1; -} - -int tls_parse_stoc_quic_transport_params(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx) -{ - OPENSSL_free(s->ext.peer_quic_transport_params); - s->ext.peer_quic_transport_params = NULL; - s->ext.peer_quic_transport_params_len = 0; - - if (!PACKET_memdup(pkt, - &s->ext.peer_quic_transport_params, - &s->ext.peer_quic_transport_params_len)) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - return 0; - } - return 1; -} -#endif diff --git a/deps/openssl/openssl/ssl/statem/extensions_srvr.c b/deps/openssl/openssl/ssl/statem/extensions_srvr.c index 546d11dd1f7..72c00574be6 100644 --- a/deps/openssl/openssl/ssl/statem/extensions_srvr.c +++ b/deps/openssl/openssl/ssl/statem/extensions_srvr.c @@ -1083,7 +1083,7 @@ int tls_parse_ctos_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x, if (sesstmp == NULL) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - return 0; + goto err; } SSL_SESSION_free(sess); sess = sesstmp; @@ -1237,40 +1237,6 @@ int tls_parse_ctos_post_handshake_auth(SSL *s, PACKET *pkt, return 1; } -#ifndef OPENSSL_NO_QUIC -int tls_parse_ctos_quic_transport_params_draft(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx) -{ - OPENSSL_free(s->ext.peer_quic_transport_params_draft); - s->ext.peer_quic_transport_params_draft = NULL; - s->ext.peer_quic_transport_params_draft_len = 0; - - if (!PACKET_memdup(pkt, - &s->ext.peer_quic_transport_params_draft, - &s->ext.peer_quic_transport_params_draft_len)) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - return 0; - } - return 1; -} - -int tls_parse_ctos_quic_transport_params(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx) -{ - OPENSSL_free(s->ext.peer_quic_transport_params); - s->ext.peer_quic_transport_params = NULL; - s->ext.peer_quic_transport_params_len = 0; - - if (!PACKET_memdup(pkt, - &s->ext.peer_quic_transport_params, - &s->ext.peer_quic_transport_params_len)) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - return 0; - } - return 1; -} -#endif - /* * Add the server's renegotiation binding */ @@ -1911,20 +1877,12 @@ EXT_RETURN tls_construct_stoc_early_data(SSL *s, WPACKET *pkt, size_t chainidx) { if (context == SSL_EXT_TLS1_3_NEW_SESSION_TICKET) { - uint32_t max_early_data = s->max_early_data; - - if (max_early_data == 0) + if (s->max_early_data == 0) return EXT_RETURN_NOT_SENT; -#ifndef OPENSSL_NO_QUIC - /* QUIC server must always send 0xFFFFFFFF, per RFC9001 S4.6.1 */ - if (SSL_IS_QUIC(s)) - max_early_data = 0xFFFFFFFF; -#endif - if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_early_data) || !WPACKET_start_sub_packet_u16(pkt) - || !WPACKET_put_bytes_u32(pkt, max_early_data) + || !WPACKET_put_bytes_u32(pkt, s->max_early_data) || !WPACKET_close(pkt)) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); return EXT_RETURN_FAIL; @@ -1962,48 +1920,3 @@ EXT_RETURN tls_construct_stoc_psk(SSL *s, WPACKET *pkt, unsigned int context, return EXT_RETURN_SENT; } - -#ifndef OPENSSL_NO_QUIC -EXT_RETURN tls_construct_stoc_quic_transport_params_draft(SSL *s, WPACKET *pkt, - unsigned int context, - X509 *x, - size_t chainidx) -{ - if (s->quic_transport_version == TLSEXT_TYPE_quic_transport_parameters - || s->ext.peer_quic_transport_params_draft_len == 0 - || s->ext.quic_transport_params == NULL - || s->ext.quic_transport_params_len == 0) { - return EXT_RETURN_NOT_SENT; - } - - if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_quic_transport_parameters_draft) - || !WPACKET_sub_memcpy_u16(pkt, s->ext.quic_transport_params, - s->ext.quic_transport_params_len)) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - return EXT_RETURN_FAIL; - } - - return EXT_RETURN_SENT; -} - -EXT_RETURN tls_construct_stoc_quic_transport_params(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx) -{ - if (s->quic_transport_version == TLSEXT_TYPE_quic_transport_parameters_draft - || s->ext.peer_quic_transport_params_len == 0 - || s->ext.quic_transport_params == NULL - || s->ext.quic_transport_params_len == 0) { - return EXT_RETURN_NOT_SENT; - } - - if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_quic_transport_parameters) - || !WPACKET_sub_memcpy_u16(pkt, s->ext.quic_transport_params, - s->ext.quic_transport_params_len)) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - return EXT_RETURN_FAIL; - } - - return EXT_RETURN_SENT; -} -#endif diff --git a/deps/openssl/openssl/ssl/statem/statem.c b/deps/openssl/openssl/ssl/statem/statem.c index d80d4da2038..553546d93a4 100644 --- a/deps/openssl/openssl/ssl/statem/statem.c +++ b/deps/openssl/openssl/ssl/statem/statem.c @@ -334,13 +334,8 @@ static int state_machine(SSL *s, int server) * If we are stateless then we already called SSL_clear() - don't do * it again and clear the STATELESS flag itself. */ -#ifndef OPENSSL_NO_QUIC - if ((s->s3.flags & TLS1_FLAGS_STATELESS) == 0 && !SSL_clear_not_quic(s)) - return -1; -#else if ((s->s3.flags & TLS1_FLAGS_STATELESS) == 0 && !SSL_clear(s)) return -1; -#endif } #ifndef OPENSSL_NO_SCTP if (SSL_IS_DTLS(s) && BIO_dgram_is_sctp(SSL_get_wbio(s))) { @@ -588,11 +583,6 @@ static SUB_STATE_RETURN read_state_machine(SSL *s) * In DTLS we get the whole message in one go - header and body */ ret = dtls_get_message(s, &mt); -#ifndef OPENSSL_NO_QUIC - } else if (SSL_IS_QUIC(s)) { - /* QUIC behaves like DTLS -- all in one go. */ - ret = quic_get_message(s, &mt); -#endif } else { ret = tls_get_message_header(s, &mt); } @@ -622,8 +612,8 @@ static SUB_STATE_RETURN read_state_machine(SSL *s) return SUB_STATE_ERROR; } - /* dtls_get_message/quic_get_message already did this */ - if (!SSL_IS_DTLS(s) && !SSL_IS_QUIC(s) + /* dtls_get_message already did this */ + if (!SSL_IS_DTLS(s) && s->s3.tmp.message_size > 0 && !grow_init_buf(s, s->s3.tmp.message_size + SSL3_HM_HEADER_LENGTH)) { @@ -641,10 +631,6 @@ static SUB_STATE_RETURN read_state_machine(SSL *s) * opportunity to do any further processing. */ ret = dtls_get_message_body(s, &len); -#ifndef OPENSSL_NO_QUIC - } else if (SSL_IS_QUIC(s)) { - ret = quic_get_message_body(s, &len); -#endif } else { ret = tls_get_message_body(s, &len); } @@ -935,14 +921,6 @@ static SUB_STATE_RETURN write_state_machine(SSL *s) int statem_flush(SSL *s) { s->rwstate = SSL_WRITING; -#ifndef OPENSSL_NO_QUIC - if (SSL_IS_QUIC(s)) { - if (!s->quic_method->flush_flight(s)) { - ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR); - return 0; - } - } else -#endif if (BIO_flush(s->wbio) <= 0) { return 0; } diff --git a/deps/openssl/openssl/ssl/statem/statem_clnt.c b/deps/openssl/openssl/ssl/statem/statem_clnt.c index 9d925091b6c..3cd1ee2d3df 100644 --- a/deps/openssl/openssl/ssl/statem/statem_clnt.c +++ b/deps/openssl/openssl/ssl/statem/statem_clnt.c @@ -904,14 +904,6 @@ int ossl_statem_client_construct_message(SSL *s, WPACKET *pkt, break; case TLS_ST_CW_END_OF_EARLY_DATA: -#ifndef OPENSSL_NO_QUIC - /* QUIC does not send EndOfEarlyData, RFC9001 S8.3 */ - if (SSL_IS_QUIC(s)) { - *confunc = NULL; - *mt = SSL3_MT_DUMMY; - break; - } -#endif *confunc = tls_construct_end_of_early_data; *mt = SSL3_MT_END_OF_EARLY_DATA; break; diff --git a/deps/openssl/openssl/ssl/statem/statem_lib.c b/deps/openssl/openssl/ssl/statem/statem_lib.c index 121929b06f4..6f0eaa5d6c0 100644 --- a/deps/openssl/openssl/ssl/statem/statem_lib.c +++ b/deps/openssl/openssl/ssl/statem/statem_lib.c @@ -45,29 +45,8 @@ int ssl3_do_write(SSL *s, int type) int ret; size_t written = 0; -#ifndef OPENSSL_NO_QUIC - if (SSL_IS_QUIC(s)) { - if (type == SSL3_RT_HANDSHAKE) { - ret = s->quic_method->add_handshake_data(s, s->quic_write_level, - (const uint8_t*)&s->init_buf->data[s->init_off], - s->init_num); - if (!ret) { - ret = -1; - /* QUIC can't sent anything out sice the above failed */ - ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR); - } else { - written = s->init_num; - } - } else { - /* QUIC doesn't use ChangeCipherSpec */ - ret = -1; - ERR_raise(ERR_LIB_SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); - } - } else -#endif - ret = ssl3_write_bytes(s, type, &s->init_buf->data[s->init_off], - s->init_num, &written); - + ret = ssl3_write_bytes(s, type, &s->init_buf->data[s->init_off], + s->init_num, &written); if (ret <= 0) return -1; if (type == SSL3_RT_HANDSHAKE) @@ -666,13 +645,6 @@ int tls_construct_finished(SSL *s, WPACKET *pkt) int tls_construct_key_update(SSL *s, WPACKET *pkt) { -#ifndef OPENSSL_NO_QUIC - if (SSL_is_quic(s)) { - /* TLS KeyUpdate is not used for QUIC, so this is an error. */ - SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - return 0; - } -#endif if (!WPACKET_put_bytes_u8(pkt, s->key_update)) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); return 0; @@ -695,13 +667,6 @@ MSG_PROCESS_RETURN tls_process_key_update(SSL *s, PACKET *pkt) return MSG_PROCESS_ERROR; } -#ifndef OPENSSL_NO_QUIC - if (SSL_is_quic(s)) { - SSLfatal(s, SSL_AD_UNEXPECTED_MESSAGE, SSL_R_UNEXPECTED_MESSAGE); - return MSG_PROCESS_ERROR; - } -#endif - if (!PACKET_get_1(pkt, &updatetype) || PACKET_remaining(pkt) != 0) { SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_R_BAD_KEY_UPDATE); diff --git a/deps/openssl/openssl/ssl/statem/statem_local.h b/deps/openssl/openssl/ssl/statem/statem_local.h index 4203c084e87..ad4d93b1e27 100644 --- a/deps/openssl/openssl/ssl/statem/statem_local.h +++ b/deps/openssl/openssl/ssl/statem/statem_local.h @@ -104,10 +104,6 @@ __owur int tls_get_message_header(SSL *s, int *mt); __owur int tls_get_message_body(SSL *s, size_t *len); __owur int dtls_get_message(SSL *s, int *mt); __owur int dtls_get_message_body(SSL *s, size_t *len); -#ifndef OPENSSL_NO_QUIC -__owur int quic_get_message(SSL *s, int *mt); -__owur int quic_get_message_body(SSL *s, size_t *len); -#endif /* Message construction and processing functions */ __owur int tls_process_initial_server_flight(SSL *s); @@ -255,14 +251,6 @@ int tls_parse_ctos_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x, size_t chainidx); int tls_parse_ctos_post_handshake_auth(SSL *, PACKET *pkt, unsigned int context, X509 *x, size_t chainidx); -#ifndef OPENSSL_NO_QUIC -int tls_parse_ctos_quic_transport_params_draft(SSL *s, PACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); - -int tls_parse_ctos_quic_transport_params(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -#endif EXT_RETURN tls_construct_stoc_renegotiate(SSL *s, WPACKET *pkt, unsigned int context, X509 *x, @@ -323,16 +311,6 @@ EXT_RETURN tls_construct_stoc_cryptopro_bug(SSL *s, WPACKET *pkt, size_t chainidx); EXT_RETURN tls_construct_stoc_psk(SSL *s, WPACKET *pkt, unsigned int context, X509 *x, size_t chainidx); -#ifndef OPENSSL_NO_QUIC -EXT_RETURN tls_construct_stoc_quic_transport_params_draft(SSL *s, WPACKET *pkt, - unsigned int context, - X509 *x, - size_t chainidx); - -EXT_RETURN tls_construct_stoc_quic_transport_params(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -#endif /* Client Extension processing */ EXT_RETURN tls_construct_ctos_renegotiate(SSL *s, WPACKET *pkt, unsigned int context, @@ -402,15 +380,6 @@ EXT_RETURN tls_construct_ctos_psk(SSL *s, WPACKET *pkt, unsigned int context, X509 *x, size_t chainidx); EXT_RETURN tls_construct_ctos_post_handshake_auth(SSL *s, WPACKET *pkt, unsigned int context, X509 *x, size_t chainidx); -#ifndef OPENSSL_NO_QUIC -EXT_RETURN tls_construct_ctos_quic_transport_params_draft(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); - -EXT_RETURN tls_construct_ctos_quic_transport_params(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -#endif int tls_parse_stoc_renegotiate(SSL *s, PACKET *pkt, unsigned int context, X509 *x, size_t chainidx); @@ -454,14 +423,6 @@ int tls_parse_stoc_cookie(SSL *s, PACKET *pkt, unsigned int context, X509 *x, size_t chainidx); int tls_parse_stoc_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x, size_t chainidx); -#ifndef OPENSSL_NO_QUIC -int tls_parse_stoc_quic_transport_params_draft(SSL *s, PACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); - -int tls_parse_stoc_quic_transport_params(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -#endif int tls_handle_alpn(SSL *s); diff --git a/deps/openssl/openssl/ssl/statem/statem_quic.c b/deps/openssl/openssl/ssl/statem/statem_quic.c deleted file mode 100644 index 7bd329c2421..00000000000 --- a/deps/openssl/openssl/ssl/statem/statem_quic.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2019-2021 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 - * https://www.openssl.org/source/license.html - */ - -#include "../ssl_local.h" -#include "statem_local.h" -#include "internal/cryptlib.h" - -int quic_get_message(SSL *s, int *mt) -{ - size_t l; - QUIC_DATA *qd = s->quic_input_data_head; - uint8_t *p; - - if (qd == NULL) { - s->rwstate = SSL_READING; - *mt = 0; - return 0; - } - - if (!ossl_assert(qd->length >= SSL3_HM_HEADER_LENGTH)) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_R_BAD_LENGTH); - *mt = 0; - return 0; - } - - /* This is where we check for the proper level, not when data is given */ - if (qd->level != s->quic_read_level) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_R_WRONG_ENCRYPTION_LEVEL_RECEIVED); - *mt = 0; - return 0; - } - - if (!BUF_MEM_grow_clean(s->init_buf, (int)qd->length)) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_BUF_LIB); - *mt = 0; - return 0; - } - - /* Copy buffered data */ - memcpy(s->init_buf->data, s->quic_buf->data + qd->start, qd->length); - s->init_buf->length = qd->length; - s->quic_input_data_head = qd->next; - if (s->quic_input_data_head == NULL) - s->quic_input_data_tail = NULL; - OPENSSL_free(qd); - - s->s3.tmp.message_type = *mt = *(s->init_buf->data); - p = (uint8_t*)s->init_buf->data + 1; - n2l3(p, l); - s->init_num = s->s3.tmp.message_size = l; - s->init_msg = s->init_buf->data + SSL3_HM_HEADER_LENGTH; - - return 1; -} - -int quic_get_message_body(SSL *s, size_t *len) -{ - /* No CCS in QUIC/TLSv1.3? */ - if (s->s3.tmp.message_type == SSL3_MT_CHANGE_CIPHER_SPEC) { - SSLfatal(s, SSL_AD_UNEXPECTED_MESSAGE, SSL_R_CCS_RECEIVED_EARLY); - *len = 0; - return 0; - } - /* No KeyUpdate in QUIC */ - if (s->s3.tmp.message_type == SSL3_MT_KEY_UPDATE) { - SSLfatal(s, SSL_AD_UNEXPECTED_MESSAGE, SSL_R_UNEXPECTED_MESSAGE); - *len = 0; - return 0; - } - - /* - * If receiving Finished, record MAC of prior handshake messages for - * Finished verification. - */ - if (s->s3.tmp.message_type == SSL3_MT_FINISHED && !ssl3_take_mac(s)) { - /* SSLfatal() already called */ - *len = 0; - return 0; - } - - /* - * We defer feeding in the HRR until later. We'll do it as part of - * processing the message - * The TLsv1.3 handshake transcript stops at the ClientFinished - * message. - */ -#define SERVER_HELLO_RANDOM_OFFSET (SSL3_HM_HEADER_LENGTH + 2) - /* KeyUpdate and NewSessionTicket do not need to be added */ - if (s->s3.tmp.message_type != SSL3_MT_NEWSESSION_TICKET - && s->s3.tmp.message_type != SSL3_MT_KEY_UPDATE) { - if (s->s3.tmp.message_type != SSL3_MT_SERVER_HELLO - || s->init_num < SERVER_HELLO_RANDOM_OFFSET + SSL3_RANDOM_SIZE - || memcmp(hrrrandom, - s->init_buf->data + SERVER_HELLO_RANDOM_OFFSET, - SSL3_RANDOM_SIZE) != 0) { - if (!ssl3_finish_mac(s, (unsigned char *)s->init_buf->data, - s->init_num + SSL3_HM_HEADER_LENGTH)) { - /* SSLfatal() already called */ - *len = 0; - return 0; - } - } - } - if (s->msg_callback) - s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, s->init_buf->data, - (size_t)s->init_num + SSL3_HM_HEADER_LENGTH, s, - s->msg_callback_arg); - - *len = s->init_num; - return 1; -} diff --git a/deps/openssl/openssl/ssl/statem/statem_srvr.c b/deps/openssl/openssl/ssl/statem/statem_srvr.c index 92e4f793ab2..7d7c198bd63 100644 --- a/deps/openssl/openssl/ssl/statem/statem_srvr.c +++ b/deps/openssl/openssl/ssl/statem/statem_srvr.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * Copyright 2005 Nokia. All rights reserved. * @@ -74,8 +74,7 @@ static int ossl_statem_server13_read_transition(SSL *s, int mt) return 1; } break; - } else if (s->ext.early_data == SSL_EARLY_DATA_ACCEPTED - && !SSL_IS_QUIC(s)) { + } else if (s->ext.early_data == SSL_EARLY_DATA_ACCEPTED) { if (mt == SSL3_MT_END_OF_EARLY_DATA) { st->hand_state = TLS_ST_SR_END_OF_EARLY_DATA; return 1; @@ -964,16 +963,6 @@ WORK_STATE ossl_statem_server_post_work(SSL *s, WORK_STATE wst) SSL3_CC_APPLICATION | SSL3_CHANGE_CIPHER_SERVER_WRITE)) /* SSLfatal() already called */ return WORK_ERROR; - -#ifndef OPENSSL_NO_QUIC - if (SSL_IS_QUIC(s) && s->ext.early_data == SSL_EARLY_DATA_ACCEPTED) { - s->early_data_state = SSL_EARLY_DATA_FINISHED_READING; - if (!s->method->ssl3_enc->change_cipher_state( - s, SSL3_CC_HANDSHAKE | SSL3_CHANGE_CIPHER_SERVER_READ)) - /* SSLfatal() already called */ - return WORK_ERROR; - } -#endif } break; @@ -1566,15 +1555,6 @@ MSG_PROCESS_RETURN tls_process_client_hello(SSL *s, PACKET *pkt) goto err; } } -#ifndef OPENSSL_NO_QUIC - if (SSL_IS_QUIC(s)) { - /* Any other QUIC checks on ClientHello here */ - if (clienthello->session_id_len > 0) { - SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_R_LENGTH_MISMATCH); - goto err; - } - } -#endif } if (!PACKET_copy_all(&compression, clienthello->compressions, @@ -3005,7 +2985,7 @@ static int tls_process_cke_dhe(SSL *s, PACKET *pkt) } if (!EVP_PKEY_set1_encoded_public_key(ckey, data, i)) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); + SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_R_BAD_KEY_SHARE); goto err; } @@ -3059,7 +3039,7 @@ static int tls_process_cke_ecdhe(SSL *s, PACKET *pkt) } if (EVP_PKEY_set1_encoded_public_key(ckey, data, i) <= 0) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_EC_LIB); + SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_R_BAD_KEY_SHARE); goto err; } } diff --git a/deps/openssl/openssl/ssl/tls13_enc.c b/deps/openssl/openssl/ssl/tls13_enc.c index 33cf79199fe..ddcff5eb891 100644 --- a/deps/openssl/openssl/ssl/tls13_enc.c +++ b/deps/openssl/openssl/ssl/tls13_enc.c @@ -400,231 +400,27 @@ static int derive_secret_key_and_iv(SSL *s, int sending, const EVP_MD *md, return 1; } +int tls13_change_cipher_state(SSL *s, int which) +{ #ifdef CHARSET_EBCDIC -static const unsigned char client_early_traffic[] = {0x63, 0x20, 0x65, 0x20, /*traffic*/0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x00}; -static const unsigned char client_handshake_traffic[] = {0x63, 0x20, 0x68, 0x73, 0x20, /*traffic*/0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x00}; -static const unsigned char client_application_traffic[] = {0x63, 0x20, 0x61, 0x70, 0x20, /*traffic*/0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x00}; -static const unsigned char server_handshake_traffic[] = {0x73, 0x20, 0x68, 0x73, 0x20, /*traffic*/0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x00}; -static const unsigned char server_application_traffic[] = {0x73, 0x20, 0x61, 0x70, 0x20, /*traffic*/0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x00}; -static const unsigned char exporter_master_secret[] = {0x65, 0x78, 0x70, 0x20, /* master*/ 0x6D, 0x61, 0x73, 0x74, 0x65, 0x72, 0x00}; -static const unsigned char resumption_master_secret[] = {0x72, 0x65, 0x73, 0x20, /* master*/ 0x6D, 0x61, 0x73, 0x74, 0x65, 0x72, 0x00}; -static const unsigned char early_exporter_master_secret[] = {0x65, 0x20, 0x65, 0x78, 0x70, 0x20, /* master*/ 0x6D, 0x61, 0x73, 0x74, 0x65, 0x72, 0x00}; + static const unsigned char client_early_traffic[] = {0x63, 0x20, 0x65, 0x20, /*traffic*/0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x00}; + static const unsigned char client_handshake_traffic[] = {0x63, 0x20, 0x68, 0x73, 0x20, /*traffic*/0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x00}; + static const unsigned char client_application_traffic[] = {0x63, 0x20, 0x61, 0x70, 0x20, /*traffic*/0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x00}; + static const unsigned char server_handshake_traffic[] = {0x73, 0x20, 0x68, 0x73, 0x20, /*traffic*/0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x00}; + static const unsigned char server_application_traffic[] = {0x73, 0x20, 0x61, 0x70, 0x20, /*traffic*/0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x00}; + static const unsigned char exporter_master_secret[] = {0x65, 0x78, 0x70, 0x20, /* master*/ 0x6D, 0x61, 0x73, 0x74, 0x65, 0x72, 0x00}; + static const unsigned char resumption_master_secret[] = {0x72, 0x65, 0x73, 0x20, /* master*/ 0x6D, 0x61, 0x73, 0x74, 0x65, 0x72, 0x00}; + static const unsigned char early_exporter_master_secret[] = {0x65, 0x20, 0x65, 0x78, 0x70, 0x20, /* master*/ 0x6D, 0x61, 0x73, 0x74, 0x65, 0x72, 0x00}; #else -static const unsigned char client_early_traffic[] = "c e traffic"; -static const unsigned char client_handshake_traffic[] = "c hs traffic"; -static const unsigned char client_application_traffic[] = "c ap traffic"; -static const unsigned char server_handshake_traffic[] = "s hs traffic"; -static const unsigned char server_application_traffic[] = "s ap traffic"; -static const unsigned char exporter_master_secret[] = "exp master"; -static const unsigned char resumption_master_secret[] = "res master"; -static const unsigned char early_exporter_master_secret[] = "e exp master"; + static const unsigned char client_early_traffic[] = "c e traffic"; + static const unsigned char client_handshake_traffic[] = "c hs traffic"; + static const unsigned char client_application_traffic[] = "c ap traffic"; + static const unsigned char server_handshake_traffic[] = "s hs traffic"; + static const unsigned char server_application_traffic[] = "s ap traffic"; + static const unsigned char exporter_master_secret[] = "exp master"; + static const unsigned char resumption_master_secret[] = "res master"; + static const unsigned char early_exporter_master_secret[] = "e exp master"; #endif - -#ifndef OPENSSL_NO_QUIC -static int quic_change_cipher_state(SSL *s, int which) -{ - unsigned char hash[EVP_MAX_MD_SIZE]; - size_t hashlen = 0; - int hashleni; - int ret = 0; - const EVP_MD *md = NULL; - OSSL_ENCRYPTION_LEVEL level; - int is_handshake = ((which & SSL3_CC_HANDSHAKE) == SSL3_CC_HANDSHAKE); - int is_client_read = ((which & SSL3_CHANGE_CIPHER_CLIENT_READ) == SSL3_CHANGE_CIPHER_CLIENT_READ); - int is_server_write = ((which & SSL3_CHANGE_CIPHER_SERVER_WRITE) == SSL3_CHANGE_CIPHER_SERVER_WRITE); - int is_early = (which & SSL3_CC_EARLY); - - if (is_early) { - EVP_MD_CTX *mdctx = NULL; - long handlen; - void *hdata; - unsigned int hashlenui; - const SSL_CIPHER *sslcipher = SSL_SESSION_get0_cipher(s->session); - - handlen = BIO_get_mem_data(s->s3.handshake_buffer, &hdata); - if (handlen <= 0) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_R_BAD_HANDSHAKE_LENGTH); - goto err; - } - - if (s->early_data_state == SSL_EARLY_DATA_CONNECTING - && s->max_early_data > 0 - && s->session->ext.max_early_data == 0) { - /* - * If we are attempting to send early data, and we've decided to - * actually do it but max_early_data in s->session is 0 then we - * must be using an external PSK. - */ - if (!ossl_assert(s->psksession != NULL - && s->max_early_data == - s->psksession->ext.max_early_data)) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - goto err; - } - sslcipher = SSL_SESSION_get0_cipher(s->psksession); - } - if (sslcipher == NULL) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_R_BAD_PSK); - goto err; - } - - /* - * We need to calculate the handshake digest using the digest from - * the session. We haven't yet selected our ciphersuite so we can't - * use ssl_handshake_md(). - */ - mdctx = EVP_MD_CTX_new(); - if (mdctx == NULL) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_MALLOC_FAILURE); - goto err; - } - md = ssl_md(s->ctx, sslcipher->algorithm2); - if (md == NULL || !EVP_DigestInit_ex(mdctx, md, NULL) - || !EVP_DigestUpdate(mdctx, hdata, handlen) - || !EVP_DigestFinal_ex(mdctx, hash, &hashlenui)) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); - EVP_MD_CTX_free(mdctx); - goto err; - } - hashlen = hashlenui; - EVP_MD_CTX_free(mdctx); - } else { - md = ssl_handshake_md(s); - if (!ssl3_digest_cached_records(s, 1) - || !ssl_handshake_hash(s, hash, sizeof(hash), &hashlen)) { - /* SSLfatal() already called */; - goto err; - } - - /* Ensure cast to size_t is safe */ - hashleni = EVP_MD_size(md); - if (!ossl_assert(hashleni >= 0)) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_EVP_LIB); - goto err; - } - hashlen = (size_t)hashleni; - } - - if (is_client_read || is_server_write) { - if (is_handshake) { - /* - * This looks a bit weird, since the condition is basically "the - * server is writing" but we set both the server *and* client - * handshake traffic keys here. That's because there's only a fixed - * number of change-cipher-state events in the TLS 1.3 handshake, - * and in particular there's not an event in between when the server - * writes encrypted handshake messages and when the client writes - * encrypted handshake messages, so we generate both here. - */ - level = ssl_encryption_handshake; - - if (!tls13_hkdf_expand(s, md, s->handshake_secret, - client_handshake_traffic, - sizeof(client_handshake_traffic)-1, hash, - hashlen, s->client_hand_traffic_secret, - hashlen, 1) - || !ssl_log_secret(s, CLIENT_HANDSHAKE_LABEL, - s->client_hand_traffic_secret, hashlen) - || !tls13_derive_finishedkey(s, md, - s->client_hand_traffic_secret, - s->client_finished_secret, hashlen) - || !tls13_hkdf_expand(s, md, s->handshake_secret, - server_handshake_traffic, - sizeof(server_handshake_traffic)-1, hash, - hashlen, s->server_hand_traffic_secret, - hashlen, 1) - || !ssl_log_secret(s, SERVER_HANDSHAKE_LABEL, - s->server_hand_traffic_secret, hashlen) - || !tls13_derive_finishedkey(s, md, - s->server_hand_traffic_secret, - s->server_finished_secret, - hashlen)) { - /* SSLfatal() already called */ - goto err; - } - } else { - /* - * As above, we generate both sets of application traffic keys at - * the same time. - */ - level = ssl_encryption_application; - - if (!tls13_hkdf_expand(s, md, s->master_secret, - client_application_traffic, - sizeof(client_application_traffic)-1, hash, - hashlen, s->client_app_traffic_secret, - hashlen, 1) - || !ssl_log_secret(s, CLIENT_APPLICATION_LABEL, - s->client_app_traffic_secret, hashlen) - || !tls13_hkdf_expand(s, md, s->master_secret, - server_application_traffic, - sizeof(server_application_traffic)-1, - hash, hashlen, - s->server_app_traffic_secret, hashlen, 1) - || !ssl_log_secret(s, SERVER_APPLICATION_LABEL, - s->server_app_traffic_secret, hashlen)) { - /* SSLfatal() already called */ - goto err; - } - } - if (!quic_set_encryption_secrets(s, level)) { - /* SSLfatal() already called */ - goto err; - } - if (s->server) - s->quic_write_level = level; - else - s->quic_read_level = level; - } else { - /* is_client_write || is_server_read */ - - if (is_early) { - level = ssl_encryption_early_data; - - if (!tls13_hkdf_expand(s, md, s->early_secret, client_early_traffic, - sizeof(client_early_traffic)-1, hash, - hashlen, s->client_early_traffic_secret, - hashlen, 1) - || !ssl_log_secret(s, CLIENT_EARLY_LABEL, - s->client_early_traffic_secret, hashlen) - || !quic_set_encryption_secrets(s, level)) { - /* SSLfatal() already called */ - goto err; - } - } else if (is_handshake) { - level = ssl_encryption_handshake; - } else { - level = ssl_encryption_application; - /* - * We also create the resumption master secret, but this time use the - * hash for the whole handshake including the Client Finished - */ - if (!tls13_hkdf_expand(s, md, s->master_secret, - resumption_master_secret, - sizeof(resumption_master_secret)-1, hash, - hashlen, s->resumption_master_secret, - hashlen, 1)) { - /* SSLfatal() already called */ - goto err; - } - } - - if (level != ssl_encryption_early_data) { - if (s->server) - s->quic_read_level = level; - else - s->quic_write_level = level; - } - } - - ret = 1; - err: - return ret; -} -#endif /* OPENSSL_NO_QUIC */ - -int tls13_change_cipher_state(SSL *s, int which) -{ unsigned char *iv; unsigned char key[EVP_MAX_KEY_LENGTH]; unsigned char secret[EVP_MAX_MD_SIZE]; @@ -645,11 +441,6 @@ int tls13_change_cipher_state(SSL *s, int which) BIO *bio; #endif -#ifndef OPENSSL_NO_QUIC - if (SSL_IS_QUIC(s)) - return quic_change_cipher_state(s, which); -#endif - if (which & SSL3_CC_READ) { if (s->enc_read_ctx != NULL) { EVP_CIPHER_CTX_reset(s->enc_read_ctx); @@ -941,7 +732,6 @@ int tls13_change_cipher_state(SSL *s, int which) skip_ktls: # endif #endif - ret = 1; err: if ((which & SSL3_CC_EARLY) != 0) { diff --git a/deps/openssl/openssl/test/acvp_test.c b/deps/openssl/openssl/test/acvp_test.c index fee880d441b..eccf9d90a02 100644 --- a/deps/openssl/openssl/test/acvp_test.c +++ b/deps/openssl/openssl/test/acvp_test.c @@ -1251,7 +1251,7 @@ static int rsa_decryption_primitive_test(int id) BN_CTX *bn_ctx = NULL; const struct rsa_decrypt_prim_st *tst = &rsa_decrypt_prim_data[id]; - if (!TEST_ptr(pkey = EVP_PKEY_Q_keygen(libctx, NULL, "RSA", 2048)) + if (!TEST_ptr(pkey = EVP_PKEY_Q_keygen(libctx, NULL, "RSA", (size_t)2048)) || !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_RSA_N, &n, &n_len)) || !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_RSA_E, &e, &e_len)) || !TEST_ptr(ctx = EVP_PKEY_CTX_new_from_pkey(libctx, pkey, "")) diff --git a/deps/openssl/openssl/test/bio_pw_callback_test.c b/deps/openssl/openssl/test/bio_pw_callback_test.c new file mode 100644 index 00000000000..e11368454a8 --- /dev/null +++ b/deps/openssl/openssl/test/bio_pw_callback_test.c @@ -0,0 +1,402 @@ +/* + * Copyright 2024 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 + * https://www.openssl.org/source/license.html + */ + +#include "testutil.h" + +#include +#include + +/* dummy data that needs to be passed to the callback */ +typedef struct CallbackData { + char magic; + int result; +} CALLBACK_DATA; + +/* constants */ +static const char weak_password[] = "weak_password"; +static const char a0a_password[] = "aaaaaaaa\0aaaaaaaa"; +static const char a0b_password[] = "aaaaaaaa\0bbbbbbbb"; +static const char cb_magic = 'p'; + +/* shared working data for all tests */ +static char *key_file = NULL; +static EVP_PKEY *original_pkey = NULL; + +/* the test performed by the callback */ +typedef enum CallbackTest { + CB_TEST_NEGATIVE = 0, + CB_TEST_ZERO_LENGTH, + CB_TEST_WEAK, + CB_TEST_16ZERO, + CB_TEST_A0A, + CB_TEST_A0B, + CB_TEST_MATCH_SIZE, + CB_TEST_EXCEED_SIZE +} CALLBACK_TEST; +static CALLBACK_TEST callback_test = CB_TEST_NEGATIVE; + +typedef enum KeyEncoding { + KE_PEM = 0, + KE_PKCS8 +} KEY_ENCODING; + +typedef enum ExpectedResult { + ER_FAILURE = 0, + ER_SUCCESS +} EXPECTED_RESULT; + +typedef enum OPTION_choice { + OPT_ERR = -1, + OPT_EOF = 0, + OPT_KEY_FILE, + OPT_TEST_ENUM +} OPTION_CHOICE; + +const OPTIONS *test_get_options(void) +{ + static const OPTIONS test_options[] = { + OPT_TEST_OPTIONS_DEFAULT_USAGE, + { "keyfile", OPT_KEY_FILE, '<', + "The PEM file with the encrypted key to load" }, + { NULL } + }; + return test_options; +} + +static int callback_copy_password(char *buf, int size) +{ + int ret = -1; + + switch (callback_test) { + case CB_TEST_NEGATIVE: + break; + case CB_TEST_ZERO_LENGTH: + ret = 0; + break; + case CB_TEST_WEAK: + ret = sizeof(weak_password) - 1; + memcpy(buf, weak_password, ret); + break; + case CB_TEST_16ZERO: + memset(buf, 0, 16); + ret = 16; + break; + case CB_TEST_A0A: + ret = sizeof(a0a_password) - 1; + memcpy(buf, a0a_password, ret); + break; + case CB_TEST_A0B: + ret = sizeof(a0b_password) - 1; + memcpy(buf, a0b_password, ret); + break; + case CB_TEST_MATCH_SIZE: + memset(buf, 'e', size); + ret = size; + break; + case CB_TEST_EXCEED_SIZE: + memset(buf, 'e', size); + ret = 1000000; + break; + } + return ret; +} + +static int read_callback(char *buf, int size, int rwflag, void *u) +{ + CALLBACK_DATA *cb_data = (CALLBACK_DATA *)u; + int ret = -1; + + /* basic verification of the received data */ + if (!TEST_ptr(cb_data)) + goto err; + if (!TEST_char_eq(cb_data->magic, cb_magic)) + goto err; + if (!TEST_ptr(buf)) + goto err; + if (!TEST_int_gt(size, 0)) + goto err; + if (!TEST_int_eq(rwflag, 0)) + goto err; + ret = callback_copy_password(buf, size); + cb_data->result = 1; +err: + return ret; +} + +static int write_callback(char *buf, int size, int rwflag, void *u) +{ + CALLBACK_DATA *cb_data = (CALLBACK_DATA *)u; + int ret = -1; + + /* basic verification of the received data */ + if (!TEST_ptr(cb_data)) + goto err; + if (!TEST_char_eq(cb_data->magic, cb_magic)) + goto err; + if (!TEST_ptr(buf)) + goto err; + if (!TEST_int_gt(size, 0)) + goto err; + if (!TEST_int_eq(rwflag, 1)) + goto err; + ret = callback_copy_password(buf, size); + cb_data->result = 1; +err: + return ret; +} + +static int re_encrypt_key(char **enc_data, int *enc_data_size, + KEY_ENCODING key_encoding) +{ + CALLBACK_DATA cb_data; + int w_ret = 0; + BUF_MEM *bptr = NULL; + BIO *bio = NULL; + int ret = 0; + + if (!TEST_ptr(enc_data)) + goto err; + if (!TEST_ptr(enc_data_size)) + goto err; + if (!TEST_ptr(bio = BIO_new(BIO_s_mem()))) + goto err; + cb_data.magic = cb_magic; + cb_data.result = 0; + switch (key_encoding) { + case KE_PEM: + w_ret = PEM_write_bio_PrivateKey(bio, original_pkey, EVP_aes_256_cbc(), + NULL, 0, write_callback, &cb_data); + break; + case KE_PKCS8: + w_ret = i2d_PKCS8PrivateKey_bio(bio, original_pkey, EVP_aes_256_cbc(), + NULL, 0, write_callback, &cb_data); + break; + } + if (!TEST_int_ne(w_ret, 0)) + goto err; + if (!TEST_char_eq(cb_data.magic, cb_magic)) + goto err; + if (!TEST_int_eq(cb_data.result, 1)) + goto err; + *enc_data_size = BIO_get_mem_data(bio, enc_data); + BIO_get_mem_ptr(bio, &bptr); + if (!BIO_set_close(bio, BIO_NOCLOSE)) + goto err; + bptr->data = NULL; + ret = 1; +err: + BUF_MEM_free(bptr); + BIO_free(bio); + return ret; +} + +static int decrypt_key(char *enc_data, int enc_data_size, + KEY_ENCODING key_encoding, + EXPECTED_RESULT expected_result) +{ + CALLBACK_DATA cb_data; + EVP_PKEY *r_ret = NULL; + BIO *bio = NULL; + EVP_PKEY *pkey = NULL; + int ret = 0; + + if (!TEST_ptr(bio = BIO_new_mem_buf(enc_data, enc_data_size))) + goto err; + cb_data.magic = cb_magic; + cb_data.result = 0; + switch (key_encoding) { + case KE_PEM: + r_ret = PEM_read_bio_PrivateKey(bio, &pkey, read_callback, &cb_data); + break; + case KE_PKCS8: + r_ret = d2i_PKCS8PrivateKey_bio(bio, &pkey, read_callback, &cb_data); + break; + } + if (expected_result == ER_SUCCESS) { + if (!TEST_ptr(r_ret)) + goto err; + } else { + if (!TEST_ptr_null(r_ret)) + goto err; + } + if (!TEST_char_eq(cb_data.magic, cb_magic)) + goto err; + if (!TEST_int_eq(cb_data.result, 1)) + goto err; + ret = 1; +err: + EVP_PKEY_free(pkey); + BIO_free(bio); + return ret; +} + +static int full_cycle_test(KEY_ENCODING key_encoding, CALLBACK_TEST write_test, + CALLBACK_TEST read_test, + EXPECTED_RESULT expected_read_result) +{ + char *enc_data = NULL; + int enc_data_size = 0; + int ret = 0; + + callback_test = write_test; + if (!re_encrypt_key(&enc_data, &enc_data_size, key_encoding)) + goto err; + callback_test = read_test; + if (!decrypt_key(enc_data, enc_data_size, key_encoding, + expected_read_result)) + goto err; + ret = 1; +err: + OPENSSL_free(enc_data); + return ret; +} + +static int test_pem_negative(void) +{ + return full_cycle_test(KE_PEM, CB_TEST_WEAK, CB_TEST_NEGATIVE, ER_FAILURE); +} + +static int test_pem_zero_length(void) +{ + return full_cycle_test(KE_PEM, CB_TEST_ZERO_LENGTH, CB_TEST_ZERO_LENGTH, + ER_SUCCESS); +} + +static int test_pem_weak(void) +{ + return full_cycle_test(KE_PEM, CB_TEST_WEAK, CB_TEST_WEAK, ER_SUCCESS); +} + +static int test_pem_16zero(void) +{ + return full_cycle_test(KE_PEM, CB_TEST_16ZERO, CB_TEST_16ZERO, ER_SUCCESS); +} + +static int test_pem_a0a(void) +{ + return full_cycle_test(KE_PEM, CB_TEST_A0A, CB_TEST_A0A, ER_SUCCESS); +} + +static int test_pem_a0a_a0b(void) +{ + return full_cycle_test(KE_PEM, CB_TEST_A0A, CB_TEST_A0B, ER_FAILURE); +} + +static int test_pem_match_size(void) +{ + return full_cycle_test(KE_PEM, CB_TEST_MATCH_SIZE, CB_TEST_MATCH_SIZE, + ER_SUCCESS); +} + +static int test_pem_exceed_size(void) +{ + return full_cycle_test(KE_PEM, CB_TEST_MATCH_SIZE, CB_TEST_EXCEED_SIZE, + ER_FAILURE); +} + +static int test_pkcs8_negative(void) +{ + return full_cycle_test(KE_PKCS8, CB_TEST_WEAK, CB_TEST_NEGATIVE, ER_FAILURE); +} + +static int test_pkcs8_zero_length(void) +{ + return full_cycle_test(KE_PKCS8, CB_TEST_ZERO_LENGTH, CB_TEST_ZERO_LENGTH, + ER_SUCCESS); +} + +static int test_pkcs8_weak(void) +{ + return full_cycle_test(KE_PKCS8, CB_TEST_WEAK, CB_TEST_WEAK, ER_SUCCESS); +} + +static int test_pkcs8_16zero(void) +{ + return full_cycle_test(KE_PKCS8, CB_TEST_16ZERO, CB_TEST_16ZERO, + ER_SUCCESS); +} + +static int test_pkcs8_a0a(void) +{ + return full_cycle_test(KE_PKCS8, CB_TEST_A0A, CB_TEST_A0A, ER_SUCCESS); +} + +static int test_pkcs8_a0a_a0b(void) +{ + return full_cycle_test(KE_PKCS8, CB_TEST_A0A, CB_TEST_A0B, ER_FAILURE); +} + +static int test_pkcs8_match_size(void) +{ + return full_cycle_test(KE_PKCS8, CB_TEST_MATCH_SIZE, CB_TEST_MATCH_SIZE, + ER_SUCCESS); +} + +static int test_pkcs8_exceed_size(void) +{ + return full_cycle_test(KE_PKCS8, CB_TEST_MATCH_SIZE, CB_TEST_EXCEED_SIZE, + ER_FAILURE); +} + +static int callback_original_pw(char *buf, int size, int rwflag, void *u) +{ + memcpy(buf, weak_password, sizeof(weak_password) - 1); + return sizeof(weak_password) - 1; +} + +int setup_tests(void) +{ + OPTION_CHOICE o; + BIO *bio = NULL; + + while ((o = opt_next()) != OPT_EOF) { + switch (o) { + case OPT_KEY_FILE: + key_file = opt_arg(); + break; + case OPT_TEST_CASES: + break; + default: + case OPT_ERR: + return 0; + } + } + + /* read the original key */ + if (!TEST_ptr(bio = BIO_new_file(key_file, "r"))) + return 0; + if (!TEST_ptr(PEM_read_bio_PrivateKey(bio, &original_pkey, + callback_original_pw, NULL))) + return 0; + BIO_free(bio); + + /* add all tests */ + ADD_TEST(test_pem_negative); + ADD_TEST(test_pem_zero_length); + ADD_TEST(test_pem_weak); + ADD_TEST(test_pem_16zero); + ADD_TEST(test_pem_a0a); + ADD_TEST(test_pem_a0a_a0b); + ADD_TEST(test_pem_match_size); + ADD_TEST(test_pem_exceed_size); + ADD_TEST(test_pkcs8_negative); + ADD_TEST(test_pkcs8_zero_length); + ADD_TEST(test_pkcs8_weak); + ADD_TEST(test_pkcs8_16zero); + ADD_TEST(test_pkcs8_a0a); + ADD_TEST(test_pkcs8_a0a_a0b); + ADD_TEST(test_pkcs8_match_size); + ADD_TEST(test_pkcs8_exceed_size); + return 1; +} + +void cleanup_tests(void) +{ + EVP_PKEY_free(original_pkey); +} diff --git a/deps/openssl/openssl/test/build.info b/deps/openssl/openssl/test/build.info index 76ff945ab8b..6089b8c97cf 100644 --- a/deps/openssl/openssl/test/build.info +++ b/deps/openssl/openssl/test/build.info @@ -61,7 +61,7 @@ IF[{- !$disabled{tests} -}] keymgmt_internal_test hexstr_test provider_status_test defltfips_test \ bio_readbuffer_test user_property_test pkcs7_test upcallstest \ provfetchtest prov_config_test rand_test fips_version_test \ - nodefltctxtest + nodefltctxtest bio_pw_callback_test IF[{- !$disabled{'deprecated-3.0'} -}] PROGRAMS{noinst}=enginetest @@ -943,6 +943,10 @@ ENDIF INCLUDE[ssl_ctx_test]=../include ../apps/include DEPEND[ssl_ctx_test]=../libcrypto ../libssl libtestutil.a + SOURCE[bio_pw_callback_test]=bio_pw_callback_test.c + INCLUDE[bio_pw_callback_test]=../include ../apps/include + DEPEND[bio_pw_callback_test]=../libcrypto libtestutil.a + {- use File::Spec::Functions; use File::Basename; diff --git a/deps/openssl/openssl/test/cmactest.c b/deps/openssl/openssl/test/cmactest.c index cb2b273b0f4..72f7a0d9366 100644 --- a/deps/openssl/openssl/test/cmactest.c +++ b/deps/openssl/openssl/test/cmactest.c @@ -196,13 +196,15 @@ static int test_cmac_copy(void) return ret; } +#define OSSL_HEX_CHARS_PER_BYTE 2 static char *pt(unsigned char *md, unsigned int len) { unsigned int i; - static char buf[80]; + static char buf[81]; - for (i = 0; i < len; i++) - sprintf(&(buf[i * 2]), "%02x", md[i]); + for (i = 0; i < len && (i + 1) * OSSL_HEX_CHARS_PER_BYTE < sizeof(buf); i++) + BIO_snprintf(buf + i * OSSL_HEX_CHARS_PER_BYTE, + OSSL_HEX_CHARS_PER_BYTE + 1, "%02x", md[i]); return buf; } diff --git a/deps/openssl/openssl/test/conf_include_test.c b/deps/openssl/openssl/test/conf_include_test.c index 2481a2380b7..f6835d59e79 100644 --- a/deps/openssl/openssl/test/conf_include_test.c +++ b/deps/openssl/openssl/test/conf_include_test.c @@ -158,7 +158,7 @@ static int test_check_overflow(void) char max[(sizeof(long) * 8) / 3 + 3]; char *p; - p = max + sprintf(max, "0%ld", LONG_MAX) - 1; + p = max + BIO_snprintf(max, sizeof(max), "0%ld", LONG_MAX) - 1; setenv("FNORD", max, 1); if (!TEST_true(NCONF_get_number(NULL, "missing", "FNORD", &val)) || !TEST_long_eq(val, LONG_MAX)) diff --git a/deps/openssl/openssl/test/drbgtest.c b/deps/openssl/openssl/test/drbgtest.c index b5122b60bdd..afbc5511252 100644 --- a/deps/openssl/openssl/test/drbgtest.c +++ b/deps/openssl/openssl/test/drbgtest.c @@ -423,7 +423,7 @@ static int test_rand_reseed_on_fork(EVP_RAND_CTX *primary, presult[0].pindex = presult[1].pindex = i; - sprintf(presult[0].name, "child %d", i); + BIO_snprintf(presult[0].name, sizeof(presult[0].name), "child %d", i); strcpy(presult[1].name, presult[0].name); /* collect the random output of the children */ diff --git a/deps/openssl/openssl/test/ec_internal_test.c b/deps/openssl/openssl/test/ec_internal_test.c index 8c2cd056316..02cfd4e9d88 100644 --- a/deps/openssl/openssl/test/ec_internal_test.c +++ b/deps/openssl/openssl/test/ec_internal_test.c @@ -155,6 +155,56 @@ static int field_tests_ecp_mont(void) } #ifndef OPENSSL_NO_EC2M +/* Test that decoding of invalid GF2m field parameters fails. */ +static int ec2m_field_sanity(void) +{ + int ret = 0; + BN_CTX *ctx = BN_CTX_new(); + BIGNUM *p, *a, *b; + EC_GROUP *group1 = NULL, *group2 = NULL, *group3 = NULL; + + TEST_info("Testing GF2m hardening\n"); + + BN_CTX_start(ctx); + p = BN_CTX_get(ctx); + a = BN_CTX_get(ctx); + if (!TEST_ptr(b = BN_CTX_get(ctx)) + || !TEST_true(BN_one(a)) + || !TEST_true(BN_one(b))) + goto out; + + /* Even pentanomial value should be rejected */ + if (!TEST_true(BN_set_word(p, 0xf2))) + goto out; + if (!TEST_ptr_null(group1 = EC_GROUP_new_curve_GF2m(p, a, b, ctx))) + TEST_error("Zero constant term accepted in GF2m polynomial"); + + /* Odd hexanomial should also be rejected */ + if (!TEST_true(BN_set_word(p, 0xf3))) + goto out; + if (!TEST_ptr_null(group2 = EC_GROUP_new_curve_GF2m(p, a, b, ctx))) + TEST_error("Hexanomial accepted as GF2m polynomial"); + + /* Excessive polynomial degree should also be rejected */ + if (!TEST_true(BN_set_word(p, 0x71)) + || !TEST_true(BN_set_bit(p, OPENSSL_ECC_MAX_FIELD_BITS + 1))) + goto out; + if (!TEST_ptr_null(group3 = EC_GROUP_new_curve_GF2m(p, a, b, ctx))) + TEST_error("GF2m polynomial degree > %d accepted", + OPENSSL_ECC_MAX_FIELD_BITS); + + ret = group1 == NULL && group2 == NULL && group3 == NULL; + + out: + EC_GROUP_free(group1); + EC_GROUP_free(group2); + EC_GROUP_free(group3); + BN_CTX_end(ctx); + BN_CTX_free(ctx); + + return ret; +} + /* test EC_GF2m_simple_method directly */ static int field_tests_ec2_simple(void) { @@ -443,6 +493,7 @@ int setup_tests(void) ADD_TEST(field_tests_ecp_simple); ADD_TEST(field_tests_ecp_mont); #ifndef OPENSSL_NO_EC2M + ADD_TEST(ec2m_field_sanity); ADD_TEST(field_tests_ec2_simple); #endif ADD_ALL_TESTS(field_tests_default, crv_len); diff --git a/deps/openssl/openssl/test/enginetest.c b/deps/openssl/openssl/test/enginetest.c index 8ba999b0176..79ffb230548 100644 --- a/deps/openssl/openssl/test/enginetest.c +++ b/deps/openssl/openssl/test/enginetest.c @@ -147,9 +147,9 @@ static int test_engines(void) TEST_info("About to beef up the engine-type list"); for (loop = 0; loop < NUMTOADD; loop++) { - sprintf(buf, "id%d", loop); + BIO_snprintf(buf, sizeof(buf), "id%d", loop); eid[loop] = OPENSSL_strdup(buf); - sprintf(buf, "Fake engine type %d", loop); + BIO_snprintf(buf, sizeof(buf), "Fake engine type %d", loop); ename[loop] = OPENSSL_strdup(buf); if (!TEST_ptr(block[loop] = ENGINE_new()) || !TEST_true(ENGINE_set_id(block[loop], eid[loop])) diff --git a/deps/openssl/openssl/test/evp_kdf_test.c b/deps/openssl/openssl/test/evp_kdf_test.c index 8f35900bdd8..0ee1aaea6f3 100644 --- a/deps/openssl/openssl/test/evp_kdf_test.c +++ b/deps/openssl/openssl/test/evp_kdf_test.c @@ -1,5 +1,5 @@ /* - * Copyright 2018-2024 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2018-2025 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2018-2020, Oracle and/or its affiliates. All rights reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use @@ -857,7 +857,7 @@ static int test_kdf_pbkdf2_invalid_digest(void) #ifndef OPENSSL_NO_SCRYPT static int test_kdf_scrypt(void) { - int ret; + int i, ret; EVP_KDF_CTX *kctx; OSSL_PARAM params[7], *p = params; unsigned char out[64]; @@ -883,15 +883,21 @@ static int test_kdf_scrypt(void) *p++ = OSSL_PARAM_construct_uint(OSSL_KDF_PARAM_SCRYPT_MAXMEM, &maxmem); *p = OSSL_PARAM_construct_end(); - ret = - TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_SCRYPT)) - && TEST_true(EVP_KDF_CTX_set_params(kctx, params)) - /* failure test *//* - && TEST_int_le(EVP_KDF_derive(kctx, out, sizeof(out), NULL), 0)*/ - && TEST_true(OSSL_PARAM_set_uint(p - 1, 10 * 1024 * 1024)) - && TEST_true(EVP_KDF_CTX_set_params(kctx, p - 1)) - && TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), NULL), 0) - && TEST_mem_eq(out, sizeof(out), expected, sizeof(expected)); + ret = TEST_ptr(kctx = get_kdfbyname(OSSL_KDF_NAME_SCRYPT)); + for (i = 0; ret && i < 2; ++i) { + ret = ret + && TEST_true(EVP_KDF_CTX_set_params(kctx, params)); + if (i == 0) + ret = ret + && TEST_int_le(EVP_KDF_derive(kctx, out, sizeof(out), NULL), 0) + && TEST_true(OSSL_PARAM_set_uint(p - 1, 10 * 1024 * 1024)) + && TEST_true(EVP_KDF_CTX_set_params(kctx, p - 1)); + ret = ret + && TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out), NULL), 0) + && TEST_mem_eq(out, sizeof(out), expected, sizeof(expected)); + if (i == 0) + EVP_KDF_CTX_reset(kctx); + } EVP_KDF_CTX_free(kctx); return ret; diff --git a/deps/openssl/openssl/test/evp_libctx_test.c b/deps/openssl/openssl/test/evp_libctx_test.c index 2448c35a149..fd114a118cb 100644 --- a/deps/openssl/openssl/test/evp_libctx_test.c +++ b/deps/openssl/openssl/test/evp_libctx_test.c @@ -501,7 +501,7 @@ static int rsa_keygen(int bits, EVP_PKEY **pub, EVP_PKEY **priv) size_t len = 0; OSSL_ENCODER_CTX *ectx = NULL; - if (!TEST_ptr(*priv = EVP_PKEY_Q_keygen(libctx, NULL, "RSA", bits)) + if (!TEST_ptr(*priv = EVP_PKEY_Q_keygen(libctx, NULL, "RSA", (size_t)bits)) || !TEST_ptr(ectx = OSSL_ENCODER_CTX_new_for_pkey(*priv, EVP_PKEY_PUBLIC_KEY, @@ -536,6 +536,8 @@ static int kem_rsa_gen_recover(void) && TEST_int_eq(EVP_PKEY_encapsulate_init(sctx, NULL), 1) && TEST_int_eq(EVP_PKEY_CTX_set_kem_op(sctx, "RSASVE"), 1) && TEST_ptr(dctx = EVP_PKEY_CTX_dup(sctx)) + /* Test that providing a NULL wrappedlen fails */ + && TEST_int_eq(EVP_PKEY_encapsulate(dctx, NULL, NULL, NULL, NULL), 0) && TEST_int_eq(EVP_PKEY_encapsulate(dctx, NULL, &ctlen, NULL, &secretlen), 1) && TEST_int_eq(ctlen, secretlen) @@ -545,11 +547,26 @@ static int kem_rsa_gen_recover(void) && TEST_ptr(rctx = EVP_PKEY_CTX_new_from_pkey(libctx, priv, NULL)) && TEST_int_eq(EVP_PKEY_decapsulate_init(rctx, NULL), 1) && TEST_int_eq(EVP_PKEY_CTX_set_kem_op(rctx, "RSASVE"), 1) + /* Test that providing a NULL unwrappedlen fails */ + && TEST_int_eq(EVP_PKEY_decapsulate(rctx, NULL, NULL, ct, ctlen), 0) && TEST_int_eq(EVP_PKEY_decapsulate(rctx, NULL, &unwraplen, ct, ctlen), 1) && TEST_int_eq(EVP_PKEY_decapsulate(rctx, unwrap, &unwraplen, ct, ctlen), 1) && TEST_mem_eq(unwrap, unwraplen, secret, secretlen); + + /* Test that providing a too short unwrapped/ctlen fails */ + if (fips_provider_version_match(libctx, ">=3.4.0")) { + ctlen = 1; + if (!TEST_int_eq(EVP_PKEY_encapsulate(dctx, ct, &ctlen, secret, + &secretlen), 0)) + ret = 0; + unwraplen = 1; + if (!TEST_int_eq(EVP_PKEY_decapsulate(rctx, unwrap, &unwraplen, ct, + ctlen), 0)) + ret = 0; + } + EVP_PKEY_free(pub); EVP_PKEY_free(priv); EVP_PKEY_CTX_free(rctx); @@ -596,59 +613,60 @@ static int kem_rsa_params(void) size_t ctlen = 0, secretlen = 0; ret = TEST_true(rsa_keygen(2048, &pub, &priv)) - && TEST_ptr(pubctx = EVP_PKEY_CTX_new_from_pkey(libctx, pub, NULL)) - && TEST_ptr(privctx = EVP_PKEY_CTX_new_from_pkey(libctx, priv, NULL)) - /* Test setting kem op before the init fails */ - && TEST_int_eq(EVP_PKEY_CTX_set_kem_op(pubctx, "RSASVE"), -2) - /* Test NULL ctx passed */ - && TEST_int_eq(EVP_PKEY_encapsulate_init(NULL, NULL), 0) - && TEST_int_eq(EVP_PKEY_encapsulate(NULL, NULL, NULL, NULL, NULL), 0) - && TEST_int_eq(EVP_PKEY_decapsulate_init(NULL, NULL), 0) - && TEST_int_eq(EVP_PKEY_decapsulate(NULL, NULL, NULL, NULL, 0), 0) - /* Test Invalid operation */ - && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, NULL, NULL, NULL), -1) - && TEST_int_eq(EVP_PKEY_decapsulate(privctx, NULL, NULL, NULL, 0), 0) - /* Wrong key component - no secret should be returned on failure */ - && TEST_int_eq(EVP_PKEY_decapsulate_init(pubctx, NULL), 1) - && TEST_int_eq(EVP_PKEY_CTX_set_kem_op(pubctx, "RSASVE"), 1) - && TEST_int_eq(EVP_PKEY_decapsulate(pubctx, secret, &secretlen, ct, - sizeof(ct)), 0) - && TEST_uchar_eq(secret[0], 0) - /* Test encapsulate fails if the mode is not set */ - && TEST_int_eq(EVP_PKEY_encapsulate_init(pubctx, NULL), 1) - && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, ct, &ctlen, secret, &secretlen), -2) - /* Test setting a bad kem ops fail */ - && TEST_int_eq(EVP_PKEY_CTX_set_kem_op(pubctx, "RSA"), 0) - && TEST_int_eq(EVP_PKEY_CTX_set_kem_op(pubctx, NULL), 0) - && TEST_int_eq(EVP_PKEY_CTX_set_kem_op(NULL, "RSASVE"), 0) - && TEST_int_eq(EVP_PKEY_CTX_set_kem_op(NULL, NULL), 0) - /* Test secretlen is optional */ - && TEST_int_eq(EVP_PKEY_CTX_set_kem_op(pubctx, "RSASVE"), 1) - && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, ct, &ctlen, secret, NULL), 1) - && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, &ctlen, NULL, NULL), 1) - /* Test outlen is optional */ - && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, NULL, NULL, &secretlen), 1) - && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, ct, NULL, secret, &secretlen), 1) - /* test that either len must be set if out is NULL */ - && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, NULL, NULL, NULL), 0) - && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, &ctlen, NULL, NULL), 1) - && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, NULL, NULL, &secretlen), 1) - && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, &ctlen, NULL, &secretlen), 1) - /* Secret buffer should be set if there is an output buffer */ - && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, ct, &ctlen, NULL, NULL), 0) - /* Test that lengths are optional if ct is not NULL */ - && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, ct, NULL, secret, NULL), 1) - /* Pass if secret or secret length are not NULL */ - && TEST_int_eq(EVP_PKEY_decapsulate_init(privctx, NULL), 1) - && TEST_int_eq(EVP_PKEY_CTX_set_kem_op(privctx, "RSASVE"), 1) - && TEST_int_eq(EVP_PKEY_decapsulate(privctx, secret, NULL, ct, sizeof(ct)), 1) - && TEST_int_eq(EVP_PKEY_decapsulate(privctx, NULL, &secretlen, ct, sizeof(ct)), 1) - && TEST_int_eq(secretlen, 256) - /* Fail if passed NULL arguments */ - && TEST_int_eq(EVP_PKEY_decapsulate(privctx, NULL, NULL, ct, sizeof(ct)), 0) - && TEST_int_eq(EVP_PKEY_decapsulate(privctx, secret, &secretlen, NULL, 0), 0) - && TEST_int_eq(EVP_PKEY_decapsulate(privctx, secret, &secretlen, NULL, sizeof(ct)), 0) - && TEST_int_eq(EVP_PKEY_decapsulate(privctx, secret, &secretlen, ct, 0), 0); + && TEST_ptr(pubctx = EVP_PKEY_CTX_new_from_pkey(libctx, pub, NULL)) + && TEST_ptr(privctx = EVP_PKEY_CTX_new_from_pkey(libctx, priv, NULL)) + /* Test setting kem op before the init fails */ + && TEST_int_eq(EVP_PKEY_CTX_set_kem_op(pubctx, "RSASVE"), -2) + /* Test NULL ctx passed */ + && TEST_int_eq(EVP_PKEY_encapsulate_init(NULL, NULL), 0) + && TEST_int_eq(EVP_PKEY_encapsulate(NULL, NULL, NULL, NULL, NULL), 0) + && TEST_int_eq(EVP_PKEY_decapsulate_init(NULL, NULL), 0) + && TEST_int_eq(EVP_PKEY_decapsulate(NULL, NULL, NULL, NULL, 0), 0) + /* Test Invalid operation */ + && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, NULL, NULL, NULL), -1) + && TEST_int_eq(EVP_PKEY_decapsulate(privctx, NULL, NULL, NULL, 0), 0) + /* Wrong key component - no secret should be returned on failure */ + && TEST_int_eq(EVP_PKEY_decapsulate_init(pubctx, NULL), 1) + && TEST_int_eq(EVP_PKEY_CTX_set_kem_op(pubctx, "RSASVE"), 1) + && TEST_int_eq(EVP_PKEY_decapsulate(pubctx, secret, &secretlen, ct, + sizeof(ct)), 0) + && TEST_uchar_eq(secret[0], 0) + /* Test encapsulate fails if the mode is not set */ + && TEST_int_eq(EVP_PKEY_encapsulate_init(pubctx, NULL), 1) + && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, ct, &ctlen, secret, &secretlen), -2) + /* Test setting a bad kem ops fail */ + && TEST_int_eq(EVP_PKEY_CTX_set_kem_op(pubctx, "RSA"), 0) + && TEST_int_eq(EVP_PKEY_CTX_set_kem_op(pubctx, NULL), 0) + && TEST_int_eq(EVP_PKEY_CTX_set_kem_op(NULL, "RSASVE"), 0) + && TEST_int_eq(EVP_PKEY_CTX_set_kem_op(NULL, NULL), 0) + /* Test secretlen is optional */ + && TEST_int_eq(EVP_PKEY_CTX_set_kem_op(pubctx, "RSASVE"), 1) + && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, &ctlen, NULL, NULL), 1) + && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, ct, &ctlen, secret, NULL), 1) + && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, &ctlen, NULL, NULL), 1) + /* Test outlen is optional */ + && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, NULL, NULL, &secretlen), 1) + && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, ct, NULL, secret, &secretlen), 1) + /* test that either len must be set if out is NULL */ + && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, NULL, NULL, NULL), 0) + && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, &ctlen, NULL, NULL), 1) + && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, NULL, NULL, &secretlen), 1) + && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, NULL, &ctlen, NULL, &secretlen), 1) + /* Secret buffer should be set if there is an output buffer */ + && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, ct, &ctlen, NULL, NULL), 0) + /* Test that lengths are optional if ct is not NULL */ + && TEST_int_eq(EVP_PKEY_encapsulate(pubctx, ct, NULL, secret, NULL), 1) + /* Pass if secret or secret length are not NULL */ + && TEST_int_eq(EVP_PKEY_decapsulate_init(privctx, NULL), 1) + && TEST_int_eq(EVP_PKEY_CTX_set_kem_op(privctx, "RSASVE"), 1) + && TEST_int_eq(EVP_PKEY_decapsulate(privctx, secret, NULL, ct, sizeof(ct)), 1) + && TEST_int_eq(EVP_PKEY_decapsulate(privctx, NULL, &secretlen, ct, sizeof(ct)), 1) + && TEST_int_eq(secretlen, 256) + /* Fail if passed NULL arguments */ + && TEST_int_eq(EVP_PKEY_decapsulate(privctx, NULL, NULL, ct, sizeof(ct)), 0) + && TEST_int_eq(EVP_PKEY_decapsulate(privctx, secret, &secretlen, NULL, 0), 0) + && TEST_int_eq(EVP_PKEY_decapsulate(privctx, secret, &secretlen, NULL, sizeof(ct)), 0) + && TEST_int_eq(EVP_PKEY_decapsulate(privctx, secret, &secretlen, ct, 0), 0); EVP_PKEY_free(pub); EVP_PKEY_free(priv); diff --git a/deps/openssl/openssl/test/ext_internal_test.c b/deps/openssl/openssl/test/ext_internal_test.c index 769b25391d5..dec6ee61efb 100644 --- a/deps/openssl/openssl/test/ext_internal_test.c +++ b/deps/openssl/openssl/test/ext_internal_test.c @@ -69,13 +69,6 @@ static EXT_LIST ext_list[] = { EXT_ENTRY(cryptopro_bug), EXT_ENTRY(early_data), EXT_ENTRY(certificate_authorities), -#ifndef OPENSSL_NO_QUIC - EXT_ENTRY(quic_transport_parameters_draft), - EXT_ENTRY(quic_transport_parameters), -#else - EXT_EXCEPTION(quic_transport_parameters_draft), - EXT_EXCEPTION(quic_transport_parameters), -#endif EXT_ENTRY(padding), EXT_ENTRY(psk), EXT_END(num_builtins) diff --git a/deps/openssl/openssl/test/hmactest.c b/deps/openssl/openssl/test/hmactest.c index 8f5bf32f870..0a29c58731f 100644 --- a/deps/openssl/openssl/test/hmactest.c +++ b/deps/openssl/openssl/test/hmactest.c @@ -275,19 +275,21 @@ static int test_hmac_copy_uninited(void) return res; } -# ifndef OPENSSL_NO_MD5 +#ifndef OPENSSL_NO_MD5 +# define OSSL_HEX_CHARS_PER_BYTE 2 static char *pt(unsigned char *md, unsigned int len) { unsigned int i; - static char buf[80]; + static char buf[201]; if (md == NULL) return NULL; - for (i = 0; i < len; i++) - sprintf(&(buf[i * 2]), "%02x", md[i]); + for (i = 0; i < len && (i + 1) * OSSL_HEX_CHARS_PER_BYTE < sizeof(buf); i++) + BIO_snprintf(buf + i * OSSL_HEX_CHARS_PER_BYTE, + OSSL_HEX_CHARS_PER_BYTE + 1, "%02x", md[i]); return buf; } -# endif +#endif int setup_tests(void) { diff --git a/deps/openssl/openssl/test/memleaktest.c b/deps/openssl/openssl/test/memleaktest.c index 97827b8e9cd..87616867739 100644 --- a/deps/openssl/openssl/test/memleaktest.c +++ b/deps/openssl/openssl/test/memleaktest.c @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2025 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 @@ -44,7 +44,7 @@ int main(int argc, char *argv[]) */ int exitcode = EXIT_FAILURE; #endif - char *lost; + char *volatile lost; lost = OPENSSL_malloc(3); if (!TEST_ptr(lost)) diff --git a/deps/openssl/openssl/test/nocache-and-default.cnf b/deps/openssl/openssl/test/nocache-and-default.cnf new file mode 100644 index 00000000000..cf5ca8d1141 --- /dev/null +++ b/deps/openssl/openssl/test/nocache-and-default.cnf @@ -0,0 +1,18 @@ +openssl_conf = openssl_init + +# Comment out the next line to ignore configuration errors +config_diagnostics = 1 + +[openssl_init] +providers = provider_sect + +[provider_sect] +test = test_sect +default = default_sect + +[test_sect] +module = ../test/p_test.so +activate = true + +[default_sect] +activate = true diff --git a/deps/openssl/openssl/test/p_test.c b/deps/openssl/openssl/test/p_test.c index 80f0784dd9d..46f990113fb 100644 --- a/deps/openssl/openssl/test/p_test.c +++ b/deps/openssl/openssl/test/p_test.c @@ -1,5 +1,5 @@ /* - * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2019-2025 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 @@ -16,6 +16,8 @@ #include #include +#include + /* * When built as an object file to link the application with, we get the * init function name through the macro PROVIDER_INIT_FUNCTION_NAME. If @@ -46,6 +48,7 @@ static OSSL_FUNC_core_get_params_fn *c_get_params = NULL; static OSSL_FUNC_core_new_error_fn *c_new_error; static OSSL_FUNC_core_set_error_debug_fn *c_set_error_debug; static OSSL_FUNC_core_vset_error_fn *c_vset_error; +static OSSL_FUNC_BIO_vsnprintf_fn *c_BIO_vsnprintf; /* Tell the core what params we provide and what type they are */ static const OSSL_PARAM p_param_types[] = { @@ -60,6 +63,17 @@ static OSSL_FUNC_provider_get_params_fn p_get_params; static OSSL_FUNC_provider_get_reason_strings_fn p_get_reason_strings; static OSSL_FUNC_provider_teardown_fn p_teardown; +static int local_snprintf(char *buf, size_t n, const char *format, ...) +{ + va_list args; + int ret; + + va_start(args, format); + ret = (*c_BIO_vsnprintf)(buf, n, format, args); + va_end(args); + return ret; +} + static void p_set_error(int lib, int reason, const char *file, int line, const char *func, const char *fmt, ...) { @@ -114,11 +128,11 @@ static int p_get_params(void *provctx, OSSL_PARAM params[]) const char *versionp = *(void **)counter_request[0].data; const char *namep = *(void **)counter_request[1].data; - sprintf(buf, "Hello OpenSSL %.20s, greetings from %s!", - versionp, namep); + local_snprintf(buf, sizeof(buf), "Hello OpenSSL %.20s, greetings from %s!", + versionp, namep); } } else { - sprintf(buf, "Howdy stranger..."); + local_snprintf(buf, sizeof(buf), "Howdy stranger..."); } p->return_size = buf_l = strlen(buf) + 1; @@ -216,12 +230,21 @@ static const OSSL_ITEM *p_get_reason_strings(void *_) return reason_strings; } +static const OSSL_ALGORITHM *p_query(OSSL_PROVIDER *prov, + int operation_id, + int *no_cache) +{ + *no_cache = 1; + return NULL; +} + static const OSSL_DISPATCH p_test_table[] = { { OSSL_FUNC_PROVIDER_GETTABLE_PARAMS, (void (*)(void))p_gettable_params }, { OSSL_FUNC_PROVIDER_GET_PARAMS, (void (*)(void))p_get_params }, { OSSL_FUNC_PROVIDER_GET_REASON_STRINGS, (void (*)(void))p_get_reason_strings}, { OSSL_FUNC_PROVIDER_TEARDOWN, (void (*)(void))p_teardown }, + { OSSL_FUNC_PROVIDER_QUERY_OPERATION, (void (*)(void))p_query }, { 0, NULL } }; @@ -250,6 +273,9 @@ int OSSL_provider_init(const OSSL_CORE_HANDLE *handle, case OSSL_FUNC_CORE_VSET_ERROR: c_vset_error = OSSL_FUNC_core_vset_error(in); break; + case OSSL_FUNC_BIO_VSNPRINTF: + c_BIO_vsnprintf = OSSL_FUNC_BIO_vsnprintf(in); + break; default: /* Just ignore anything we don't understand */ break; diff --git a/deps/openssl/openssl/test/pkcs12_format_test.c b/deps/openssl/openssl/test/pkcs12_format_test.c index c142093f72b..f7ecd7c1e63 100644 --- a/deps/openssl/openssl/test/pkcs12_format_test.c +++ b/deps/openssl/openssl/test/pkcs12_format_test.c @@ -358,7 +358,8 @@ static int test_single_key(PKCS12_ENC *enc) char fname[80]; PKCS12_BUILDER *pb; - sprintf(fname, "1key_ciph-%s_iter-%d.p12", OBJ_nid2sn(enc->nid), enc->iter); + BIO_snprintf(fname, sizeof(fname), "1key_ciph-%s_iter-%d.p12", + OBJ_nid2sn(enc->nid), enc->iter); pb = new_pkcs12_builder(fname); @@ -457,7 +458,8 @@ static int test_single_cert_mac(PKCS12_ENC *mac) char fname[80]; PKCS12_BUILDER *pb; - sprintf(fname, "1cert_mac-%s_iter-%d.p12", OBJ_nid2sn(mac->nid), mac->iter); + BIO_snprintf(fname, sizeof(fname), "1cert_mac-%s_iter-%d.p12", + OBJ_nid2sn(mac->nid), mac->iter); pb = new_pkcs12_builder(fname); @@ -617,7 +619,8 @@ static int test_single_secret(PKCS12_ENC *enc) char fname[80]; PKCS12_BUILDER *pb; - sprintf(fname, "1secret_ciph-%s_iter-%d.p12", OBJ_nid2sn(enc->nid), enc->iter); + BIO_snprintf(fname, sizeof(fname), "1secret_ciph-%s_iter-%d.p12", + OBJ_nid2sn(enc->nid), enc->iter); pb = new_pkcs12_builder(fname); custom_nid = get_custom_oid(); diff --git a/deps/openssl/openssl/test/property_test.c b/deps/openssl/openssl/test/property_test.c index 88c5342c538..1f1171ad90a 100644 --- a/deps/openssl/openssl/test/property_test.c +++ b/deps/openssl/openssl/test/property_test.c @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2019-2025 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use @@ -50,30 +50,37 @@ static void down_ref(void *p) static int test_property_string(void) { - OSSL_METHOD_STORE *store; + OSSL_LIB_CTX *ctx; + OSSL_METHOD_STORE *store = NULL; int res = 0; OSSL_PROPERTY_IDX i, j; - if (TEST_ptr(store = ossl_method_store_new(NULL)) - && TEST_int_eq(ossl_property_name(NULL, "fnord", 0), 0) - && TEST_int_ne(ossl_property_name(NULL, "fnord", 1), 0) - && TEST_int_ne(ossl_property_name(NULL, "name", 1), 0) + /*- + * Use our own library context because we depend on ordering from a + * pristine state. + */ + if (TEST_ptr(ctx = OSSL_LIB_CTX_new()) + && TEST_ptr(store = ossl_method_store_new(ctx)) + && TEST_int_eq(ossl_property_name(ctx, "fnord", 0), 0) + && TEST_int_ne(ossl_property_name(ctx, "fnord", 1), 0) + && TEST_int_ne(ossl_property_name(ctx, "name", 1), 0) /* Property value checks */ - && TEST_int_eq(ossl_property_value(NULL, "fnord", 0), 0) - && TEST_int_ne(i = ossl_property_value(NULL, "no", 0), 0) - && TEST_int_ne(j = ossl_property_value(NULL, "yes", 0), 0) + && TEST_int_eq(ossl_property_value(ctx, "fnord", 0), 0) + && TEST_int_ne(i = ossl_property_value(ctx, "no", 0), 0) + && TEST_int_ne(j = ossl_property_value(ctx, "yes", 0), 0) && TEST_int_ne(i, j) - && TEST_int_eq(ossl_property_value(NULL, "yes", 1), j) - && TEST_int_eq(ossl_property_value(NULL, "no", 1), i) - && TEST_int_ne(i = ossl_property_value(NULL, "illuminati", 1), 0) - && TEST_int_eq(j = ossl_property_value(NULL, "fnord", 1), i + 1) - && TEST_int_eq(ossl_property_value(NULL, "fnord", 1), j) + && TEST_int_eq(ossl_property_value(ctx, "yes", 1), j) + && TEST_int_eq(ossl_property_value(ctx, "no", 1), i) + && TEST_int_ne(i = ossl_property_value(ctx, "illuminati", 1), 0) + && TEST_int_eq(j = ossl_property_value(ctx, "fnord", 1), i + 1) + && TEST_int_eq(ossl_property_value(ctx, "fnord", 1), j) /* Check name and values are distinct */ - && TEST_int_eq(ossl_property_value(NULL, "cold", 0), 0) - && TEST_int_ne(ossl_property_name(NULL, "fnord", 0), - ossl_property_value(NULL, "fnord", 0))) + && TEST_int_eq(ossl_property_value(ctx, "cold", 0), 0) + && TEST_int_ne(ossl_property_name(ctx, "fnord", 0), + ossl_property_value(ctx, "fnord", 0))) res = 1; ossl_method_store_free(store); + OSSL_LIB_CTX_free(ctx); return res; } diff --git a/deps/openssl/openssl/test/recipes/03-test_fipsinstall.t b/deps/openssl/openssl/test/recipes/03-test_fipsinstall.t index 5f514e231b5..c243b5646d3 100644 --- a/deps/openssl/openssl/test/recipes/03-test_fipsinstall.t +++ b/deps/openssl/openssl/test/recipes/03-test_fipsinstall.t @@ -253,6 +253,10 @@ SKIP: { SKIP: { skip "Skipping Asymmetric RSA corruption test because of no rsa in this build", 1 if disabled("rsa"); + run(test(["fips_version_test", "-config", $provconf, "<3.5.0"]), + capture => 1, statusvar => \my $exit); + skip "FIPS provider version is too new for Asymmetric RSA corruption test", 1 + if !$exit; ok(!run(app(['openssl', 'fipsinstall', '-out', 'fips.cnf', '-module', $infile, '-corrupt_desc', 'RSA_Encrypt', '-corrupt_type', 'KAT_AsymmetricCipher'])), diff --git a/deps/openssl/openssl/test/recipes/04-test_encoder_decoder.t b/deps/openssl/openssl/test/recipes/04-test_encoder_decoder.t index 19541610a9a..d5d79f3a575 100644 --- a/deps/openssl/openssl/test/recipes/04-test_encoder_decoder.t +++ b/deps/openssl/openssl/test/recipes/04-test_encoder_decoder.t @@ -25,9 +25,26 @@ my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0); my $rsa_key = srctop_file("test", "certs", "ee-key.pem"); my $pss_key = srctop_file("test", "certs", "ca-pss-key.pem"); -plan tests => ($no_fips ? 0 : 1) + 2; # FIPS install test + test +plan tests => ($no_fips ? 0 : 3) + 2; # FIPS install test + test my $conf = srctop_file("test", "default.cnf"); + +# Check if the specified pattern occurs in the given file +# Returns 1 if the pattern is found and 0 if not +sub find_line_file { + my ($key, $file) = @_; + + open(my $in, $file) or return -1; + while (my $line = <$in>) { + if ($line =~ /$key/) { + close($in); + return 1; + } + } + close($in); + return 0; +} + ok(run(test(["endecode_test", "-rsa", $rsa_key, "-pss", $pss_key, "-config", $conf, @@ -47,5 +64,13 @@ unless ($no_fips) { "-pss", $pss_key, "-config", $conf, "-provider", "fips"]))); +SKIP: { + skip "EC disabled", 2 if disabled("ec"); + ok(run(app([ 'openssl', 'genpkey', '-algorithm', 'EC', + '-pkeyopt', 'group:P-256', '-text', + '-config', $conf, '-provider', 'fips', '-out', 'ec.txt' ])), + 'Print a FIPS provider EC private key'); + ok(find_line_file('NIST CURVE: P-256', 'ec.txt') == 1, + 'Printing an FIPS provider EC private key'); +} } - diff --git a/deps/openssl/openssl/test/recipes/20-test_nocache.t b/deps/openssl/openssl/test/recipes/20-test_nocache.t new file mode 100644 index 00000000000..f7a956ee05e --- /dev/null +++ b/deps/openssl/openssl/test/recipes/20-test_nocache.t @@ -0,0 +1,34 @@ +#! /usr/bin/env perl +# Copyright 2016-2025 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 +# https://www.openssl.org/source/license.html + +use strict; +use warnings; + +use OpenSSL::Test qw/:DEFAULT bldtop_file srctop_file bldtop_dir with/; +use OpenSSL::Test::Utils; + +setup("test_nocache"); + +plan tests => 4; + +ok(run(app(["openssl", "list", "-mac-algorithms"], + stdout => "listout.txt")), +"List mac algorithms - default configuration"); +open DATA, "listout.txt"; +my @match = grep /MAC/, ; +close DATA; +ok(scalar @match > 1 ? 1 : 0, "Several algorithms are listed - default configuration"); + +$ENV{OPENSSL_CONF} = bldtop_file("test", "nocache-and-default.cnf"); +ok(run(app(["openssl", "list", "-mac-algorithms"], + stdout => "listout.txt")), +"List mac algorithms"); +open DATA, "listout.txt"; +my @match = grep /MAC/, ; +close DATA; +ok(scalar @match > 1 ? 1 : 0, "Several algorithms are listed - nocache-and-default"); diff --git a/deps/openssl/openssl/test/recipes/25-test_verify.t b/deps/openssl/openssl/test/recipes/25-test_verify.t index 818c9ac50dd..7fa14d9daa8 100644 --- a/deps/openssl/openssl/test/recipes/25-test_verify.t +++ b/deps/openssl/openssl/test/recipes/25-test_verify.t @@ -61,7 +61,7 @@ ok(verify("ee-cert-ocsp-nocheck", "", ["root-cert"], ["ca-cert"]), ok(verify("ee-cert", "sslserver", [qw(sroot-cert)], [qw(ca-cert)]), "accept server purpose"); ok(!verify("ee-cert", "sslserver", [qw(croot-cert)], [qw(ca-cert)]), - "fail client purpose"); + "fail client purpose"); # beware, questionable non-standard EKU check on trust anchor ok(verify("ee-cert", "sslserver", [qw(root+serverAuth)], [qw(ca-cert)]), "accept server trust"); ok(verify("ee-cert", "sslserver", [qw(sroot+serverAuth)], [qw(ca-cert)]), @@ -81,7 +81,7 @@ ok(verify("ee-cert", "sslserver", [qw(root-clientAuth)], [qw(ca-cert)]), ok(verify("ee-cert", "sslserver", [qw(sroot-clientAuth)], [qw(ca-cert)]), "accept client mistrust with server purpose"); ok(!verify("ee-cert", "sslserver", [qw(croot-clientAuth)], [qw(ca-cert)]), - "fail client mistrust with client purpose"); + "fail client mistrust with client purpose"); # beware, questionable non-standard EKU check on trust anchor # Inapplicable trust ok(!verify("ee-cert", "sslserver", [qw(root+clientAuth)], [qw(ca-cert)]), "fail client trust"); @@ -150,7 +150,7 @@ ok(!verify("ee-cert", "sslserver", [qw(root-expired)], [qw(ca-cert)]), ok(verify("ee-cert", "sslserver", [qw(sca-cert)], [], "-partial_chain"), "accept partial chain with server purpose"); ok(!verify("ee-cert", "sslserver", [qw(cca-cert)], [], "-partial_chain"), - "fail partial chain with client purpose"); + "fail partial chain with client purpose"); # beware, questionable non-standard EKU check on trust anchor ok(verify("ee-cert", "sslserver", [qw(ca+serverAuth)], [], "-partial_chain"), "accept server trust partial chain"); ok(verify("ee-cert", "sslserver", [qw(cca+serverAuth)], [], "-partial_chain"), @@ -188,7 +188,7 @@ ok(verify("ee-cert", "sslserver", [qw(root-cert cca+serverAuth)], [qw(ca-cert)]) ok(verify("ee-cert", "sslserver", [qw(root-cert cca+anyEKU)], [qw(ca-cert)]), "accept wildcard trust and client purpose"); ok(!verify("ee-cert", "sslserver", [qw(root-cert cca-cert)], [qw(ca-cert)]), - "fail client purpose"); + "fail client purpose intermediate trusted"); # beware, questionable non-standard EKU check on trust anchor ok(!verify("ee-cert", "sslserver", [qw(root-cert ca-anyEKU)], [qw(ca-cert)]), "fail wildcard mistrust"); ok(!verify("ee-cert", "sslserver", [qw(root-cert ca-serverAuth)], [qw(ca-cert)]), diff --git a/deps/openssl/openssl/test/recipes/30-test_evp_data/evpkdf_tls13_kdf.txt b/deps/openssl/openssl/test/recipes/30-test_evp_data/evpkdf_tls13_kdf.txt index 9ad8b9fbd2d..c7e7b4b5bf9 100644 --- a/deps/openssl/openssl/test/recipes/30-test_evp_data/evpkdf_tls13_kdf.txt +++ b/deps/openssl/openssl/test/recipes/30-test_evp_data/evpkdf_tls13_kdf.txt @@ -4935,3 +4935,13 @@ Ctrl.mode = mode:EXTRACT_AND_EXPAND Ctrl.digest = digest:SHA256 Result = KDF_CTRL_ERROR +# Test that salt of arbitrary length works +FIPSversion = >=3.4.0 +KDF = TLS13-KDF +Ctrl.mode = mode:EXTRACT_ONLY +Ctrl.digest = digest:SHA2-256 +Ctrl.key = hexkey:f8af6aea2d397baf2948a25b2834200692cff17eee9165e4e27babee9edefd05 +Ctrl.salt = hexsalt:00010203040506070809000102030405060708090001020304050607080900010203040506070809 +Ctrl.prefix = hexprefix:746c73313320 +Ctrl.label = hexlabel:64657269766564 +Output = ef0aa4925ab6f4588759e15dfadcf7602ca7aa39ebb092bd7ab48f6a68c54449 diff --git a/deps/openssl/openssl/test/recipes/61-test_bio_pw_callback.t b/deps/openssl/openssl/test/recipes/61-test_bio_pw_callback.t new file mode 100644 index 00000000000..4cb1db1f589 --- /dev/null +++ b/deps/openssl/openssl/test/recipes/61-test_bio_pw_callback.t @@ -0,0 +1,20 @@ +#! /usr/bin/env perl +# Copyright 2024 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 +# https://www.openssl.org/source/license.html + +use strict; +use warnings; + +use OpenSSL::Test qw(:DEFAULT data_file); + +setup('test_bio_pw_callback'); + +plan tests => 1; + +my $private_key_path = data_file("private_key.pem"); +ok(run(test(["bio_pw_callback_test", "-keyfile", $private_key_path])), + "Running bio_pw_callback_test"); diff --git a/deps/openssl/openssl/test/recipes/61-test_bio_pw_callback_data/private_key.pem b/deps/openssl/openssl/test/recipes/61-test_bio_pw_callback_data/private_key.pem new file mode 100644 index 00000000000..f9c9ae5dbc4 --- /dev/null +++ b/deps/openssl/openssl/test/recipes/61-test_bio_pw_callback_data/private_key.pem @@ -0,0 +1,30 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQmftpln/ZNiEznncq ++u0FuwICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEBO5TGcD0mGTfRS8 +HgafEXYEggTQOasEXPm4ChGPzfXACYhaAtMFnfL9qpI1S30bHMUHsWuXLZDFPNty +7KNKWr35woaq3XFEeul7onszcBBRrRwPkTqOifuv/J01s7oS0uC6jwbvSkAFNjHe +jkgvMMQA3y7nwZ2wSwVjO2K91qasTjNivus3ZaCvGqGpgNckEXILPZJEdWteWP+1 +SN9zLxxeHwgt5SrMfylrTghLB8b119/uq4GnOYHZdhMbp4YmneuGqvlZ7nle7qLY +33tuM5deajk9hINLfbYWGwURaOZ+r++Rvrz4OxISfe70uXT+2fcSZPVkNT5a6B5T +9rCwdF69W/+3au50gfc2VEF/xZBajxLI0PBpMSpxNE3a5/3YLKXAs+z0YJdQKNhN +U+SpOUv8D2GraJVfP7MddO2JvETh8w7tGN/a8qSw07Z91SE3Vfuq0l5PheC/vXJq +/xxU3YSbZC7LCSZn1aXBlj9KbTh2o1ARzdJsVYo1xY2OIFtFpncOjQDuaAmsNcZE +CuB9FUcBwwO/bjooIkv4lJU+DWDxrCR7Si8PZ4hHgXCXXKiXA20SBccUYm0Z4HR3 +i2tm9UTwAuCy1BF7hRmPLIyvlgtlKh2V9Cre5j86GoKTmPh/q5DHdSmNAM8Aakct +GdQgscOXRmHq7/1nec28wEhlbqVyYJ45MZbWhBTrycMru/ch9+ZnsIgPXLfbBA+P +6GHK1DF+onKZtMkH0SNMU3X1arlJKRreVQsvkbgL7aw3mI0veYa4/tJUf7hbkPpA +LArQU5wQ+A9mzC+tYMfz3mrIE05FrpYkHRxiB/odeNvCTMR7DhGoghhnYUN/gSSN +qH5EBG2hQ/pJ5ZSawE+P9+vCLlvcc4n00zgi0s3rMN2AntPZoI3sWKZcbbgJoOIH +cbAmBAKCIiwmlPmI0hjEAIXRBixJzHVGNowuSc3jy5pIiSjmDESnARl+n5imqI3D +po9OuCHpo4nRLcAX0GrJqqKxUG+R1A8g/AooIGEPQgkXk/4v9gwd4aBvwT4YxR44 +onAXdyBMM0T8C+8dUmT6OPvU5w6JHFidJfhBgJhDIdj9JM+wWdr1CW94todjEyKY +Xe3NRG1bGbcN6HBVwbe4UZ39A9p4kKGyiXexlsD+DvFxwaGvSy2rp0lLabz19Kkr +fnLU1Ugb38AnEYTGYJMB9nO19lHW62Mk6+9ky42x8X9vBn81Nif/c0kmvEKsZEfw +UM7m0fIWTZOWSH01DGIXqCoCk7vJ1CSm0wUsAvyKFLm1qnM5eJJNMlBbayDDBsnU +Jj9hx7GWjujVKFwFngUOoFpmFWB72bqeBWenaQJhIVydQa1rolny0TECJIkFOsUK +Wa0y52V4h68Ig5G5p2WHG0RlEVtmcgzSoL1mLE5UdOYaH5oB7nTVM+Z0b8HJFrYc +7Xhym8uNq6UHc4Ae6TT8EA3lA3fDttedKzWxlBFXqX9behl2uBnPzCl3cS2G2Uek +xtexjecZINP8L5i6eIL7bPoVMF5CUsUhIWFA0gzIovRBRvVS91HnTrIDLvqF8YgQ +ToctUU/vS8r3x2/TIR60UBvW0vkoFa+lfzHtsxBnT1nMBZNeeHOCM8QtboyI9Ir9 +UkJbTO+QpJQ5A3ELharpcqr7iywDOnLSV9LZSUZr934zOrRl2oAXx/0= +-----END ENCRYPTED PRIVATE KEY----- diff --git a/deps/openssl/openssl/test/recipes/80-test_cmp_http.t b/deps/openssl/openssl/test/recipes/80-test_cmp_http.t index 0ca547354fc..c704cc758e9 100644 --- a/deps/openssl/openssl/test/recipes/80-test_cmp_http.t +++ b/deps/openssl/openssl/test/recipes/80-test_cmp_http.t @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2007-2022 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2007-2025 The OpenSSL Project Authors. All Rights Reserved. # Copyright Nokia 2007-2019 # Copyright Siemens AG 2015-2019 # @@ -270,7 +270,7 @@ sub start_mock_server { print "Current directory is ".getcwd()."\n"; print "Launching mock server: $cmd\n"; die "Invalid port: $server_port" unless $server_port =~ m/^\d+$/; - my $pid = open($server_fh, "$cmd|") or die "Trying to $cmd"; + my $pid = open($server_fh, "$cmd 2>".result_dir()."/error.txt |") or die "Trying to $cmd"; print "Pid is: $pid\n"; if ($server_port == 0) { # Find out the actual server port diff --git a/deps/openssl/openssl/test/recipes/80-test_cmp_http_data/test_connection.csv b/deps/openssl/openssl/test/recipes/80-test_cmp_http_data/test_connection.csv index 33a572a29da..cc012411ea5 100644 --- a/deps/openssl/openssl/test/recipes/80-test_cmp_http_data/test_connection.csv +++ b/deps/openssl/openssl/test/recipes/80-test_cmp_http_data/test_connection.csv @@ -2,8 +2,8 @@ expected,description, -section,val, -server,val, -proxy,val, -no_proxy,val, -tls ,Message transfer options:,,,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,,,,,, 1,default config, -section,,,,,,,,BLANK,,,,BLANK,,BLANK,,BLANK, -TBD,Domain name, -section,, -server,_SERVER_CN:_SERVER_PORT,,,,,,,,,,,,,, -TBD,IP address, -section,, -server,_SERVER_IP:_SERVER_PORT,,,,,,,,,,,,,, +1,disabled as not supported by some host IP configurations: server domain name, -section,, -server,localhost:_SERVER_PORT,,,,,,,,,,,,,, +1,disabled as not supported by some host IP configurations: server IPv6 address, -section,, -server,[::1]:_SERVER_PORT,,,,,,,,,,,,,, ,,,,,,,,,,,,,,,,,,, 0,wrong server, -section,, -server,xn--rksmrgs-5wao1o.example.com:_SERVER_PORT,,,,,BLANK,,,, -msg_timeout,1,BLANK,,BLANK, 0,wrong server port, -section,, -server,_SERVER_HOST:99,,,,,BLANK,,,, -msg_timeout,1,BLANK,,BLANK, diff --git a/deps/openssl/openssl/test/recipes/80-test_cms.t b/deps/openssl/openssl/test/recipes/80-test_cms.t index 31f9fbd1280..0e8b0259f1c 100644 --- a/deps/openssl/openssl/test/recipes/80-test_cms.t +++ b/deps/openssl/openssl/test/recipes/80-test_cms.t @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2015-2023 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2015-2025 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 @@ -25,6 +25,7 @@ use lib srctop_dir('Configurations'); use lib bldtop_dir('.'); my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0); +my $old_fips = 0; plan skip_all => "CMS is not supported by this OpenSSL build" if disabled("cms"); @@ -50,13 +51,17 @@ my ($no_des, $no_dh, $no_dsa, $no_ec, $no_ec2m, $no_rc2, $no_zlib) $no_rc2 = 1 if disabled("legacy"); -plan tests => 19; +plan tests => 20; ok(run(test(["pkcs7_test"])), "test pkcs7"); unless ($no_fips) { - @config = ( "-config", srctop_file("test", "fips-and-base.cnf") ); + my $provconf = srctop_file("test", "fips-and-base.cnf"); + @config = ( "-config", $provconf ); $provname = 'fips'; + + run(test(["fips_version_test", "-config", $provconf, "<3.4.0"]), + capture => 1, statusvar => $old_fips); } $ENV{OPENSSL_TEST_LIBCTX} = "1"; @@ -394,6 +399,13 @@ my @smime_cms_tests = ( "-out", "{output}.txt" ], \&final_compare ], + + [ "encrypted content test streaming PEM format -noout, 128 bit AES key", + [ "{cmd1}", @prov, "-EncryptedData_encrypt", "-in", $smcont, "-outform", "PEM", + "-aes128", "-secretkey", "000102030405060708090A0B0C0D0E0F", + "-stream", "-noout" ], + [ "{cmd2}", @prov, "-help" ] + ], ); my @smime_cms_cades_tests = ( @@ -604,6 +616,7 @@ my @smime_cms_param_tests = ( "-stream", "-out", "{output}.cms", "-recip", catfile($smdir, "smec1.pem"), "-aes128", "-keyopt", "ecdh_kdf_md:sha256" ], + sub { my %opts = @_; smimeType_matches("$opts{output}.cms", "enveloped-data"); }, [ "{cmd2}", @prov, "-decrypt", "-recip", catfile($smdir, "smec1.pem"), "-in", "{output}.cms", "-out", "{output}.txt" ], \&final_compare @@ -613,6 +626,7 @@ my @smime_cms_param_tests = ( [ "{cmd1}", @prov, "-encrypt", "-in", $smcont, "-stream", "-out", "{output}.cms", "-recip", catfile($smdir, "smec1.pem"), "-aes-128-gcm", "-keyopt", "ecdh_kdf_md:sha256" ], + sub { my %opts = @_; smimeType_matches("$opts{output}.cms", "authEnveloped-data"); }, [ "{cmd2}", "-decrypt", "-recip", catfile($smdir, "smec1.pem"), "-in", "{output}.cms", "-out", "{output}.txt" ], \&final_compare @@ -626,18 +640,23 @@ my @smime_cms_param_tests = ( [ "{cmd2}", @prov, "-decrypt", "-recip", catfile($smdir, "smec2.pem"), "-in", "{output}.cms", "-out", "{output}.txt" ], \&final_compare - ], - - [ "enveloped content test streaming S/MIME format, X9.42 DH", - [ "{cmd1}", @prov, "-encrypt", "-in", $smcont, - "-stream", "-out", "{output}.cms", - "-recip", catfile($smdir, "smdh.pem"), "-aes128" ], - [ "{cmd2}", @prov, "-decrypt", "-recip", catfile($smdir, "smdh.pem"), - "-in", "{output}.cms", "-out", "{output}.txt" ], - \&final_compare ] ); +if ($no_fips || $old_fips) { + # Only SHA1 supported in dh_cms_encrypt() + push(@smime_cms_param_tests, + [ "enveloped content test streaming S/MIME format, X9.42 DH", + [ "{cmd1}", @prov, "-encrypt", "-in", $smcont, + "-stream", "-out", "{output}.cms", + "-recip", catfile($smdir, "smdh.pem"), "-aes128" ], + [ "{cmd2}", @prov, "-decrypt", "-recip", catfile($smdir, "smdh.pem"), + "-in", "{output}.cms", "-out", "{output}.txt" ], + \&final_compare + ] + ); +} + my @contenttype_cms_test = ( [ "signed content test - check that content type is added to additional signerinfo, RSA keys", [ "{cmd1}", @prov, "-sign", "-binary", "-nodetach", "-stream", "-in", $smcont, @@ -765,6 +784,28 @@ sub contentType_matches { return scalar(@c); } +# Returns 1 if the smime-type matches the passed parameter, otherwise 0. +sub smimeType_matches { + my ($in, $expected_smime_type) = @_; + + # Read the text file + open(my $fh, '<', $in) or die("open failed for $in : $!"); + local $/; + my $content = <$fh>; + close($fh); + + # Extract the Content-Type line with the smime-type attribute + if ($content =~ /Content-Type:\s*application\/pkcs7-mime.*smime-type=([^\s;]+)/) { + my $smime_type = $1; + + # Compare the extracted smime-type with the expected value + return ($smime_type eq $expected_smime_type) ? 1 : 0; + } + + # If no smime-type is found, return 0 + return 0; +} + sub rsapssSaltlen { my ($in) = @_; my $exit = 0; @@ -986,6 +1027,22 @@ ok(!run(app(['openssl', 'cms', '-verify', ])), "issue#19643"); +# Check that kari encryption with originator does not segfault +with({ exit_checker => sub { return shift == 3; } }, + sub { + SKIP: { + skip "EC is not supported in this build", 1 if $no_ec; + + ok(run(app(['openssl', 'cms', '-encrypt', + '-in', srctop_file("test", "smcont.txt"), '-aes128', + '-recip', catfile($smdir, "smec1.pem"), + '-originator', catfile($smdir, "smec3.pem"), + '-inkey', catfile($smdir, "smec3.pem") + ])), + "Check failure for currently not supported kari encryption with static originator"); + } + }); + # Check that we get the expected failure return code with({ exit_checker => sub { return shift == 6; } }, sub { diff --git a/deps/openssl/openssl/test/sslapitest.c b/deps/openssl/openssl/test/sslapitest.c index b0544d4942f..368b15f22b7 100644 --- a/deps/openssl/openssl/test/sslapitest.c +++ b/deps/openssl/openssl/test/sslapitest.c @@ -1,5 +1,5 @@ /* - * Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2025 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 @@ -190,7 +190,7 @@ static int compare_hex_encoded_buffer(const char *hex_encoded, return 1; for (i = j = 0; i < raw_length && j + 1 < hex_length; i++, j += 2) { - sprintf(hexed, "%02x", raw[i]); + BIO_snprintf(hexed, sizeof(hexed), "%02x", raw[i]); if (!TEST_int_eq(hexed[0], hex_encoded[j]) || !TEST_int_eq(hexed[1], hex_encoded[j + 1])) return 1; @@ -10764,364 +10764,6 @@ static int test_multi_resume(int idx) SSL_SESSION_free(sess); return testresult; } -#ifndef OPENSSL_NO_QUIC -static int test_quic_set_encryption_secrets(SSL *ssl, - OSSL_ENCRYPTION_LEVEL level, - const uint8_t *read_secret, - const uint8_t *write_secret, - size_t secret_len) -{ - test_printf_stderr("quic_set_encryption_secrets() %s, lvl=%d, len=%zd\n", - ssl->server ? "server" : "client", level, secret_len); - return 1; -} - -static int test_quic_add_handshake_data(SSL *ssl, OSSL_ENCRYPTION_LEVEL level, - const uint8_t *data, size_t len) -{ - SSL *peer = (SSL*)SSL_get_app_data(ssl); - - TEST_info("quic_add_handshake_data() %s, lvl=%d, *data=0x%02X, len=%zd\n", - ssl->server ? "server" : "client", level, (int)*data, len); - if (!TEST_ptr(peer)) - return 0; - - /* We're called with what is locally written; this gives it to the peer */ - if (!TEST_true(SSL_provide_quic_data(peer, level, data, len))) { - ERR_print_errors_fp(stderr); - return 0; - } - - return 1; -} - -static int test_quic_flush_flight(SSL *ssl) -{ - test_printf_stderr("quic_flush_flight() %s\n", ssl->server ? "server" : "client"); - return 1; -} - -static int test_quic_send_alert(SSL *ssl, enum ssl_encryption_level_t level, uint8_t alert) -{ - test_printf_stderr("quic_send_alert() %s, lvl=%d, alert=%d\n", - ssl->server ? "server" : "client", level, alert); - return 1; -} - -static SSL_QUIC_METHOD quic_method = { - test_quic_set_encryption_secrets, - test_quic_add_handshake_data, - test_quic_flush_flight, - test_quic_send_alert, -}; - -static int test_quic_api_set_versions(SSL *ssl, int ver) -{ - SSL_set_quic_transport_version(ssl, ver); - return 1; -} - -static int test_quic_api_version(int clnt, int srvr) -{ - SSL_CTX *cctx = NULL, *sctx = NULL; - SSL *clientssl = NULL, *serverssl = NULL; - int testresult = 0; - - static const char *server_str = "SERVER"; - static const char *client_str = "CLIENT"; - const uint8_t *peer_str; - size_t peer_str_len; - - TEST_info("original clnt=0x%X, srvr=0x%X\n", clnt, srvr); - - if (!TEST_true(create_ssl_ctx_pair(libctx, - TLS_server_method(), - TLS_client_method(), - TLS1_3_VERSION, 0, - &sctx, &cctx, cert, privkey)) - || !TEST_true(SSL_CTX_set_quic_method(sctx, &quic_method)) - || !TEST_true(SSL_CTX_set_quic_method(cctx, &quic_method)) - || !TEST_true(create_ssl_objects(sctx, cctx, &serverssl, - &clientssl, NULL, NULL)) - || !TEST_true(SSL_set_quic_transport_params(serverssl, - (unsigned char*)server_str, - strlen(server_str)+1)) - || !TEST_true(SSL_set_quic_transport_params(clientssl, - (unsigned char*)client_str, - strlen(client_str)+1)) - || !TEST_true(SSL_set_app_data(serverssl, clientssl)) - || !TEST_true(SSL_set_app_data(clientssl, serverssl)) - || !TEST_true(test_quic_api_set_versions(clientssl, clnt)) - || !TEST_true(test_quic_api_set_versions(serverssl, srvr)) - || !TEST_true(create_bare_ssl_connection(serverssl, clientssl, - SSL_ERROR_NONE, 0)) - || !TEST_true(SSL_version(serverssl) == TLS1_3_VERSION) - || !TEST_true(SSL_version(clientssl) == TLS1_3_VERSION) - || !(TEST_int_eq(SSL_quic_read_level(clientssl), ssl_encryption_application)) - || !(TEST_int_eq(SSL_quic_read_level(serverssl), ssl_encryption_application)) - || !(TEST_int_eq(SSL_quic_write_level(clientssl), ssl_encryption_application)) - || !(TEST_int_eq(SSL_quic_write_level(serverssl), ssl_encryption_application))) - goto end; - - SSL_get_peer_quic_transport_params(serverssl, &peer_str, &peer_str_len); - if (!TEST_mem_eq(peer_str, peer_str_len, client_str, strlen(client_str)+1)) - goto end; - SSL_get_peer_quic_transport_params(clientssl, &peer_str, &peer_str_len); - if (!TEST_mem_eq(peer_str, peer_str_len, server_str, strlen(server_str)+1)) - goto end; - - /* Deal with two NewSessionTickets */ - if (!TEST_true(SSL_process_quic_post_handshake(clientssl))) - goto end; - - /* Dummy handshake call should succeed */ - if (!TEST_true(SSL_do_handshake(clientssl))) - goto end; - /* Test that we (correctly) fail to send KeyUpdate */ - if (!TEST_true(SSL_key_update(clientssl, SSL_KEY_UPDATE_NOT_REQUESTED)) - || !TEST_int_le(SSL_do_handshake(clientssl), 0)) - goto end; - if (!TEST_true(SSL_key_update(serverssl, SSL_KEY_UPDATE_NOT_REQUESTED)) - || !TEST_int_le(SSL_do_handshake(serverssl), 0)) - goto end; - - TEST_info("original clnt=0x%X, srvr=0x%X\n", clnt, srvr); - if (srvr == 0 && clnt == 0) - srvr = clnt = TLSEXT_TYPE_quic_transport_parameters; - else if (srvr == 0) - srvr = clnt; - else if (clnt == 0) - clnt = srvr; - TEST_info("expected clnt=0x%X, srvr=0x%X\n", clnt, srvr); - if (!TEST_int_eq(SSL_get_peer_quic_transport_version(serverssl), clnt)) - goto end; - if (!TEST_int_eq(SSL_get_peer_quic_transport_version(clientssl), srvr)) - goto end; - - testresult = 1; - - end: - SSL_free(serverssl); - SSL_free(clientssl); - SSL_CTX_free(sctx); - SSL_CTX_free(cctx); - - return testresult; -} - -static int test_quic_api(int tst) -{ - SSL_CTX *sctx = NULL; - SSL *serverssl = NULL; - int testresult = 0; - static int clnt_params[] = { 0, - TLSEXT_TYPE_quic_transport_parameters_draft, - TLSEXT_TYPE_quic_transport_parameters, - 0, - TLSEXT_TYPE_quic_transport_parameters_draft, - TLSEXT_TYPE_quic_transport_parameters, - 0, - TLSEXT_TYPE_quic_transport_parameters_draft, - TLSEXT_TYPE_quic_transport_parameters }; - static int srvr_params[] = { 0, - 0, - 0, - TLSEXT_TYPE_quic_transport_parameters_draft, - TLSEXT_TYPE_quic_transport_parameters_draft, - TLSEXT_TYPE_quic_transport_parameters_draft, - TLSEXT_TYPE_quic_transport_parameters, - TLSEXT_TYPE_quic_transport_parameters, - TLSEXT_TYPE_quic_transport_parameters }; - static int results[] = { 1, 1, 1, 1, 1, 0, 1, 0, 1 }; - - /* Failure cases: - * test 6/[5] clnt = parameters, srvr = draft - * test 8/[7] clnt = draft, srvr = parameters - */ - - /* Clean up logging space */ - memset(client_log_buffer, 0, sizeof(client_log_buffer)); - memset(server_log_buffer, 0, sizeof(server_log_buffer)); - client_log_buffer_index = 0; - server_log_buffer_index = 0; - error_writing_log = 0; - - if (!TEST_ptr(sctx = SSL_CTX_new_ex(libctx, NULL, TLS_server_method())) - || !TEST_true(SSL_CTX_set_quic_method(sctx, &quic_method)) - || !TEST_ptr(sctx->quic_method) - || !TEST_ptr(serverssl = SSL_new(sctx)) - || !TEST_true(SSL_IS_QUIC(serverssl)) - || !TEST_true(SSL_set_quic_method(serverssl, NULL)) - || !TEST_false(SSL_IS_QUIC(serverssl)) - || !TEST_true(SSL_set_quic_method(serverssl, &quic_method)) - || !TEST_true(SSL_IS_QUIC(serverssl))) - goto end; - - if (!TEST_int_eq(test_quic_api_version(clnt_params[tst], srvr_params[tst]), results[tst])) - goto end; - - testresult = 1; - -end: - SSL_CTX_free(sctx); - sctx = NULL; - SSL_free(serverssl); - serverssl = NULL; - return testresult; -} - -# ifndef OSSL_NO_USABLE_TLS1_3 -/* - * Helper method to setup objects for QUIC early data test. Caller - * frees objects on error. - */ -static int quic_setupearly_data_test(SSL_CTX **cctx, SSL_CTX **sctx, - SSL **clientssl, SSL **serverssl, - SSL_SESSION **sess, int idx) -{ - static const char *server_str = "SERVER"; - static const char *client_str = "CLIENT"; - - if (*sctx == NULL - && (!TEST_true(create_ssl_ctx_pair(libctx, TLS_server_method(), - TLS_client_method(), - TLS1_3_VERSION, 0, - sctx, cctx, cert, privkey)) - || !TEST_true(SSL_CTX_set_quic_method(*sctx, &quic_method)) - || !TEST_true(SSL_CTX_set_quic_method(*cctx, &quic_method)) - || !TEST_true(SSL_CTX_set_max_early_data(*sctx, 0xffffffffu)))) - return 0; - - if (idx == 1) { - /* When idx == 1 we repeat the tests with read_ahead set */ - SSL_CTX_set_read_ahead(*cctx, 1); - SSL_CTX_set_read_ahead(*sctx, 1); - } else if (idx == 2) { - /* When idx == 2 we are doing early_data with a PSK. Set up callbacks */ - SSL_CTX_set_psk_use_session_callback(*cctx, use_session_cb); - SSL_CTX_set_psk_find_session_callback(*sctx, find_session_cb); - use_session_cb_cnt = 0; - find_session_cb_cnt = 0; - srvid = pskid; - } - - if (!TEST_true(create_ssl_objects(*sctx, *cctx, serverssl, clientssl, - NULL, NULL)) - || !TEST_true(SSL_set_quic_transport_params(*serverssl, - (unsigned char*)server_str, - strlen(server_str)+1)) - || !TEST_true(SSL_set_quic_transport_params(*clientssl, - (unsigned char*)client_str, - strlen(client_str)+1)) - || !TEST_true(SSL_set_app_data(*serverssl, *clientssl)) - || !TEST_true(SSL_set_app_data(*clientssl, *serverssl))) - return 0; - - /* - * For one of the run throughs (doesn't matter which one), we'll try sending - * some SNI data in the initial ClientHello. This will be ignored (because - * there is no SNI cb set up by the server), so it should not impact - * early_data. - */ - if (idx == 1 - && !TEST_true(SSL_set_tlsext_host_name(*clientssl, "localhost"))) - return 0; - - if (idx == 2) { - clientpsk = create_a_psk(*clientssl, SHA256_DIGEST_LENGTH); - if (!TEST_ptr(clientpsk) - || !TEST_true(SSL_SESSION_set_max_early_data(clientpsk, - 0xffffffffu)) - || !TEST_true(SSL_SESSION_up_ref(clientpsk))) { - SSL_SESSION_free(clientpsk); - clientpsk = NULL; - return 0; - } - serverpsk = clientpsk; - - if (sess != NULL) { - if (!TEST_true(SSL_SESSION_up_ref(clientpsk))) { - SSL_SESSION_free(clientpsk); - SSL_SESSION_free(serverpsk); - clientpsk = serverpsk = NULL; - return 0; - } - *sess = clientpsk; - } - - SSL_set_quic_early_data_enabled(*serverssl, 1); - SSL_set_quic_early_data_enabled(*clientssl, 1); - - return 1; - } - - if (sess == NULL) - return 1; - - if (!TEST_true(create_bare_ssl_connection(*serverssl, *clientssl, - SSL_ERROR_NONE, 0))) - return 0; - - /* Deal with two NewSessionTickets */ - if (!TEST_true(SSL_process_quic_post_handshake(*clientssl))) - return 0; - - *sess = SSL_get1_session(*clientssl); - SSL_shutdown(*clientssl); - SSL_shutdown(*serverssl); - SSL_free(*serverssl); - SSL_free(*clientssl); - *serverssl = *clientssl = NULL; - - if (!TEST_true(create_ssl_objects(*sctx, *cctx, serverssl, - clientssl, NULL, NULL)) - || !TEST_true(SSL_set_session(*clientssl, *sess)) - || !TEST_true(SSL_set_quic_transport_params(*serverssl, - (unsigned char*)server_str, - strlen(server_str)+1)) - || !TEST_true(SSL_set_quic_transport_params(*clientssl, - (unsigned char*)client_str, - strlen(client_str)+1)) - || !TEST_true(SSL_set_app_data(*serverssl, *clientssl)) - || !TEST_true(SSL_set_app_data(*clientssl, *serverssl))) - return 0; - - SSL_set_quic_early_data_enabled(*serverssl, 1); - SSL_set_quic_early_data_enabled(*clientssl, 1); - - return 1; -} - -static int test_quic_early_data(int tst) -{ - SSL_CTX *cctx = NULL, *sctx = NULL; - SSL *clientssl = NULL, *serverssl = NULL; - int testresult = 0; - SSL_SESSION *sess = NULL; - - if (!TEST_true(quic_setupearly_data_test(&cctx, &sctx, &clientssl, - &serverssl, &sess, tst))) - goto end; - - if (!TEST_true(create_bare_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE, 0)) - || !TEST_true(SSL_get_early_data_status(serverssl))) - goto end; - - testresult = 1; - - end: - SSL_SESSION_free(sess); - SSL_SESSION_free(clientpsk); - SSL_SESSION_free(serverpsk); - clientpsk = serverpsk = NULL; - SSL_free(serverssl); - SSL_free(clientssl); - SSL_CTX_free(sctx); - SSL_CTX_free(cctx); - return testresult; -} -# endif /* OSSL_NO_USABLE_TLS1_3 */ -#endif /* OPENSSL_NO_QUIC */ static struct next_proto_st { int serverlen; @@ -11276,6 +10918,7 @@ static int npn_advert_cb(SSL *ssl, const unsigned char **out, return SSL_TLSEXT_ERR_OK; case 1: + *out = NULL; *outlen = 0; return SSL_TLSEXT_ERR_OK; @@ -11765,12 +11408,6 @@ int setup_tests(void) ADD_ALL_TESTS(test_npn, 5); #endif ADD_ALL_TESTS(test_alpn, 4); -#ifndef OPENSSL_NO_QUIC - ADD_ALL_TESTS(test_quic_api, 9); -# ifndef OSSL_NO_USABLE_TLS1_3 - ADD_ALL_TESTS(test_quic_early_data, 3); -# endif -#endif return 1; err: diff --git a/deps/openssl/openssl/test/testutil/tests.c b/deps/openssl/openssl/test/testutil/tests.c index ef7e224cd11..05526870acd 100644 --- a/deps/openssl/openssl/test/testutil/tests.c +++ b/deps/openssl/openssl/test/testutil/tests.c @@ -1,5 +1,5 @@ /* - * Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2017-2025 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 @@ -146,6 +146,7 @@ void test_perror(const char *s) void test_note(const char *fmt, ...) { + test_flush_stdout(); if (fmt != NULL) { va_list ap; diff --git a/deps/openssl/openssl/test/threadstest.c b/deps/openssl/openssl/test/threadstest.c index 289565c14b5..046a9eb8023 100644 --- a/deps/openssl/openssl/test/threadstest.c +++ b/deps/openssl/openssl/test/threadstest.c @@ -358,7 +358,7 @@ static void thread_general_worker(void) * Therefore we use an insecure bit length where we can (512). * In the FIPS module though we must use a longer length. */ - pkey = EVP_PKEY_Q_keygen(multi_libctx, NULL, "RSA", isfips ? 2048 : 512); + pkey = EVP_PKEY_Q_keygen(multi_libctx, NULL, "RSA", (size_t)(isfips ? 2048 : 512)); if (!TEST_ptr(pkey)) goto err; diff --git a/deps/openssl/openssl/test/tls13secretstest.c b/deps/openssl/openssl/test/tls13secretstest.c index 8323b237787..bf214d3d5ba 100644 --- a/deps/openssl/openssl/test/tls13secretstest.c +++ b/deps/openssl/openssl/test/tls13secretstest.c @@ -224,13 +224,6 @@ void ssl_evp_md_free(const EVP_MD *md) { } -#ifndef OPENSSL_NO_QUIC -int quic_set_encryption_secrets(SSL *ssl, OSSL_ENCRYPTION_LEVEL level) -{ - return 1; -} -#endif - /* End of mocked out code */ static int test_secret(SSL *s, unsigned char *prk, diff --git a/deps/openssl/openssl/util/check-format-commit.sh b/deps/openssl/openssl/util/check-format-commit.sh index 7e712dc48cf..206827dd866 100755 --- a/deps/openssl/openssl/util/check-format-commit.sh +++ b/deps/openssl/openssl/util/check-format-commit.sh @@ -6,24 +6,21 @@ # You can obtain a copy in the file LICENSE in the source distribution # or at https://www.openssl.org/source/license.html # -# This script is a wrapper around check-format.pl. It accepts a commit sha -# value as input, and uses it to identify the files and ranges that were -# changed in that commit, filtering check-format.pl output only to lines that -# fall into the commits change ranges. -# - - -# List of Regexes to use when running check-format.pl. -# Style checks don't apply to any of these -EXCLUDED_FILE_REGEX=("\.pod" \ - "\.pl" \ - "\.pm" \ - "\.t" \ - "\.yml" \ - "\.sh") - -# Exit code for the script -EXIT_CODE=0 +# This script is a wrapper around check-format.pl. +# It accepts the same commit revision range as 'git diff' as arguments, +# or just a single commit id, and uses it to identify the files and line ranges +# that were changed in that commit range, filtering check-format.pl output +# only to lines that fall into the change ranges of the changed files. +# examples: +# check-format-commit.sh # check unstaged changes +# check-format-commit.sh HEAD +# check-format-commit.sh @~3.. +# check-format-commit.sh f5981c9629667a5a5d6 +# check-format-commit.sh f5981c9629667a5a5d6..ee0bf38e8709bf71888 + +# Allowlist of files to scan +# Currently this is any .c or .h file (with an optional .in suffix) +FILE_NAME_END_ALLOWLIST=("\.[ch]\(.in\)\?") # Global vars @@ -45,94 +42,107 @@ cleanup() { trap cleanup EXIT -# Get the canonical sha256 sum for the commit we are checking +# Get the list of ids of the commits we are checking, +# or empty for unstaged changes. # This lets us pass in symbolic ref names like master/etc and -# resolve them to sha256 sums easily -COMMIT=$(git rev-parse $1) +# resolve them to commit ids easily +COMMIT_RANGE="$@" +[ -n $COMMIT_RANGE ] && COMMIT_LAST=$(git rev-parse $COMMIT_RANGE) -# Fail gracefully if git rev-parse doesn't produce a valid -# commit +# Fail gracefully if git rev-parse doesn't produce a valid commit if [ $? -ne 0 ] then - echo "$1 is not a valid revision" + echo "$1 is not a valid commit range or commit id" exit 1 fi -# Create a iteratable list of files to check for a -# given commit. It produces output of the format -# , -touch $TEMPDIR/ranges.txt -git show $COMMIT | awk -v mycmt=$COMMIT ' +# If the commit range is exactly one revision, +# git rev-parse will output just the commit id of that one alone. +# In that case, we must manipulate a little to get a desirable result, +# as 'git diff' has a slightly different interpretation of a single commit id: +# it takes that to mean all commits up to HEAD, plus any unstaged changes. +if [ $(echo -n "$COMMIT_LAST" | wc -w) -ne 1 ]; then + COMMIT_LAST=$(echo "$COMMIT_LAST" | head -1) +else + # $COMMIT_RANGE is just one commit, make it an actual range + COMMIT_RANGE=$COMMIT_RANGE^..$COMMIT_RANGE +fi + +# Create an iterable list of files to check formatting on, +# including the line ranges that are changed by the commits +# It produces output of this format: +# , +git diff -U0 $COMMIT_RANGE | awk ' BEGIN {myfile=""} - /+{3}/ { - gsub(/b\//,"",$2); - myfile=$2 - } - /@@/ { - gsub(/+/,"",$3); - printf mycmt " " myfile " " $3 "\n" - }' >> $TEMPDIR/ranges.txt || true - -# filter out anything that matches on a filter regex -for i in ${EXCLUDED_FILE_REGEX[@]} -do - touch $TEMPDIR/ranges.filter - grep -v "$i" $TEMPDIR/ranges.txt >> $TEMPDIR/ranges.filter || true - REMAINING_FILES=$(wc -l $TEMPDIR/ranges.filter | awk '{print $1}') - if [ $REMAINING_FILES -eq 0 ] - then - echo "This commit has no files that require checking" - exit 0 - fi - mv $TEMPDIR/ranges.filter $TEMPDIR/ranges.txt -done + /^\+\+\+/ { sub(/^b./,"",$2); file=$2 } + /^@@/ { sub(/^\+/,"",$3); range=$3; printf file " " range "\n" } + ' > $TEMPDIR/ranges.txt -# check out the files from the commit level. -# For each file name in ranges, we show that file at the commit -# level we are checking, and redirect it to the same path, relative -# to $TEMPDIR/check-format. This give us the full file to run -# check-format.pl on with line numbers matching the ranges in the -# $TEMPDIR/ranges.txt file -for j in $(grep $COMMIT $TEMPDIR/ranges.txt | awk '{print $2}') +# filter in anything that matches on a filter regex +for i in ${FILE_NAME_END_ALLOWLIST[@]} do - FDIR=$(dirname $j) - mkdir -p $TEMPDIR/check-format/$FDIR - git show $COMMIT:$j > $TEMPDIR/check-format/$j + # Note the space after the $i below. This is done because we want + # to match on file name suffixes, but the input file is of the form + # , + # So we can't just match on end of line. The additional space + # here lets us match on suffixes followed by the expected space + # in the input file + grep "$i " $TEMPDIR/ranges.txt >> $TEMPDIR/ranges.filter || true done -# Now for each file in $TEMPDIR/check-format run check-format.pl -# Note that we use the %P formatter in the find utilty. This strips -# off the $TEMPDIR/check-format path prefix, leaving $j with the -# path to the file relative to the root of the source dir, so that -# output from check-format.pl looks correct, relative to the root -# of the git tree. -for j in $(find $TEMPDIR/check-format -type f -printf "%P\n") +REMAINING_FILES=$(wc -l <$TEMPDIR/ranges.filter) +if [ $REMAINING_FILES -eq 0 ] +then + echo "The given commit range has no C source file changes that require checking" + exit 0 +fi + +# unless checking the format of unstaged changes, +# check out the files from the commit range. +if [ -n "$COMMIT_RANGE" ] +then + # For each file name in ranges, we show that file at the commit range + # we are checking, and redirect it to the same path, + # relative to $TEMPDIR/check-format. + # This give us the full file path to run check-format.pl on + # with line numbers matching the ranges in the $TEMPDIR/ranges.filter file + for j in $(awk '{print $1}' $TEMPDIR/ranges.filter | sort -u) + do + FDIR=$(dirname $j) + mkdir -p $TEMPDIR/check-format/$FDIR + git show $COMMIT_LAST:$j > $TEMPDIR/check-format/$j + done +fi + +# Now for each file in $TEMPDIR/ranges.filter, run check-format.pl +for j in $(awk '{print $1}' $TEMPDIR/ranges.filter | sort -u) do range_start=() range_end=() # Get the ranges for this file. Create 2 arrays. range_start contains # the start lines for valid ranges from the commit. the range_end array - # contains the corresponding end line (note, since diff output gives us + # contains the corresponding end line. Note, since diff output gives us # a line count for a change, the range_end[k] entry is actually # range_start[k]+line count - for k in $(grep $COMMIT $TEMPDIR/ranges.txt | grep $j | awk '{print $3}') + for k in $(grep ^$j $TEMPDIR/ranges.filter | awk '{print $2}') do - RANGE=$k - RSTART=$(echo $RANGE | awk -F',' '{print $1}') - RLEN=$(echo $RANGE | awk -F',' '{print $2}') + RSTART=$(echo $k | awk -F',' '{print $1}') + RLEN=$(echo $k | awk -F',' '{print $2}') + # when the hunk is just one line, its length is implied + if [ -z "$RLEN" ]; then RLEN=1; fi let REND=$RSTART+$RLEN range_start+=($RSTART) range_end+=($REND) done - # Go to our checked out tree - cd $TEMPDIR/check-format + # Go to our checked out tree, unless checking unstaged changes + [ -n "$COMMIT_RANGE" ] && cd $TEMPDIR/check-format # Actually run check-format.pl on the file, capturing the output - # in a temporary file. Note the format of check-patch.pl output is - # ::: - $TOPDIR/util/check-format.pl $j > $TEMPDIR/format-results.txt + # in a temporary file. Note the format of check-format.pl output is + # ::: + $TOPDIR/util/check-format.pl $j > $TEMPDIR/results.txt # Now we filter the check-format.pl output based on the changed lines # captured in the range_start/end arrays @@ -146,26 +156,15 @@ do # Check here if any line in that output falls between any of the # start/end ranges defined in the range_start/range_end array. # If it does fall in that range, print the entire line to stdout - # If anything is printed, have awk exit with a non-zero exit code awk -v rstart=$RSTART -v rend=$REND -F':' ' - BEGIN {rc=0} - /:/ { - if (($2 >= rstart) && ($2 <= rend)) { - print $0; - rc=1 - } - } - END {exit rc;} - ' $TEMPDIR/format-results.txt - - # If awk exited with a non-zero code, this script will also exit - # with a non-zero code - if [ $? -ne 0 ] - then - EXIT_CODE=1 - fi + /:/ { if (rstart <= $2 && $2 <= rend) print $0 } + ' $TEMPDIR/results.txt >>$TEMPDIR/results-filtered.txt done done +cat $TEMPDIR/results-filtered.txt -# Exit with the recorded exit code above -exit $EXIT_CODE +# If any findings were in range, exit with a different error code +if [ -s $TEMPDIR/results-filtered.txt ] +then + exit 2 +fi diff --git a/deps/openssl/openssl/util/check-format.pl b/deps/openssl/openssl/util/check-format.pl index ef2c1920e72..559b9023d08 100755 --- a/deps/openssl/openssl/util/check-format.pl +++ b/deps/openssl/openssl/util/check-format.pl @@ -791,7 +791,7 @@ sub check_nested_nonblock_indents { # treat remaining blinded comments and string literal contents as (single) space during matching below $intra_line =~ s/@+/ /g; # note that extra SPC has already been handled above $intra_line =~ s/\s+$//; # strip any (resulting) space at EOL - # replace ';;' or '; ;' by ';' in "for(;;)" and in "for (...)" unless "..." contains just SPC and ';' characters: + # replace ';;' or '; ;' by ';' in "for (;;)" and in "for (...)" unless "..." contains just SPC and ';' characters: $intra_line =~ s/((^|\W)for\s*\()([^;]*?)(\s*)(;\s?);(\s*)([^;]*)(\))/ "$1$3$4".("$3$4$5$6$7" eq ";" || $3 ne "" || $7 ne "" ? "" : $5).";$6$7$8"/eg; # strip trailing ';' or '; ' in "for (...)" except in "for (;;)" or "for (;; )": @@ -904,7 +904,7 @@ sub check_nested_nonblock_indents { # handle opening brace '{' after if/else/while/for/switch/do on line before if ($hanging_offset > 0 && m/^[\s@]*{/ && # leading opening '{' $line_before > 0 && - $contents_before_ =~ m/(^|^.*\W)(if|else|while|for|switch|do)(\W.*$|$)/) { + $contents_before_ =~ m/(^|^.*\W)(if|else|while|for|(OSSL_)?LIST_FOREACH(_\w+)?|switch|do)(\W.*$|$)/) { $keyword_opening_brace = $1; $hanging_offset -= INDENT_LEVEL; # cancel newly hanging_offset } @@ -966,7 +966,7 @@ sub check_nested_nonblock_indents { my $outermost_level = $block_indent - $preproc_offset == 0; - report("more than one stmt") if !m/(^|\W)for(\W.*|$)/ && # no 'for' - TODO improve matching + report("more than one stmt") if !m/(^|\W)(for|(OSSL_)?LIST_FOREACH(_\w+)?)(\W.*|$)/ && # no 'for' - TODO improve matching m/;.*;/; # two or more terminators ';', so more than one statement # check for code block containing a single line/statement @@ -1004,7 +1004,7 @@ sub check_nested_nonblock_indents { my $assignment_start = 0; my $tmp = $_; $tmp =~ s/[\!<>=]=/@@/g; # blind (in-)equality symbols like '<=' as '@@' to prevent matching them as '=' below - if (m/^((^|.*\W)(if|while|for|switch))(\W.*|$)$/) { # (last) if/for/while/switch + if (m/^((^|.*\W)(if|while|for|(OSSL_)?LIST_FOREACH(_\w+)?|switch))(\W.*|$)$/) { # (last) if/for/while/switch $paren_expr_start = 1; } elsif (m/^((^|.*\W)(return|enum))(\W.*|$)/ # (last) return/enum && !$in_expr && @nested_indents == 0 && parens_balance($1) == 0) { # not nested enum @@ -1135,7 +1135,7 @@ sub check_nested_nonblock_indents { $line_body_start = $contents =~ m/LONG BODY/ ? 0 : $line if $line_function_start != 0; } } else { - $line_opening_brace = $line if $keyword_opening_brace =~ m/if|do|while|for/; + $line_opening_brace = $line if $keyword_opening_brace =~ m/if|do|while|for|(OSSL_)?LIST_FOREACH(_\w+)?/; # using, not assigning, $keyword_opening_brace here because it could be on an earlier line $line_opening_brace = $line if $keyword_opening_brace eq "else" && $extended_1_stmt && # TODO prevent false positives for if/else where braces around single-statement branches @@ -1148,11 +1148,11 @@ sub check_nested_nonblock_indents { } } - # check for opening brace after if/while/for/switch/do not on same line + # check for opening brace after if/while/for/switch/do missing on same line # note that "missing '{' on same line after '} else'" is handled further below if (/^[\s@]*{/ && # leading '{' $line_before > 0 && !($contents_before_ =~ m/^\s*#/) && # not preprocessor directive '#if - (my ($head, $mid, $tail) = ($contents_before_ =~ m/(^|^.*\W)(if|while|for|switch|do)(\W.*$|$)/))) { + (my ($head, $mid, $tail) = ($contents_before_ =~ m/(^|^.*\W)(if|while|for|(OSSL_)?LIST_FOREACH(_\w+)?|switch|do)(\W.*$|$)/))) { my $brace_after = $tail =~ /^[\s@]*{/; # any whitespace or comments then '{' report("'{' not on same line as preceding '$mid'") if !$brace_after; } diff --git a/deps/openssl/openssl/util/libssl.num b/deps/openssl/openssl/util/libssl.num index 4a9d5b20074..f055c967bf1 100644 --- a/deps/openssl/openssl/util/libssl.num +++ b/deps/openssl/openssl/util/libssl.num @@ -520,19 +520,3 @@ SSL_load_client_CA_file_ex 520 3_0_0 EXIST::FUNCTION: SSL_set0_tmp_dh_pkey 521 3_0_0 EXIST::FUNCTION: SSL_CTX_set0_tmp_dh_pkey 522 3_0_0 EXIST::FUNCTION: SSL_group_to_name 523 3_0_0 EXIST::FUNCTION: -SSL_quic_read_level 20000 3_0_0 EXIST::FUNCTION:QUIC -SSL_set_quic_transport_params 20001 3_0_0 EXIST::FUNCTION:QUIC -SSL_CIPHER_get_prf_nid 20002 3_0_0 EXIST::FUNCTION:QUIC -SSL_is_quic 20003 3_0_0 EXIST::FUNCTION:QUIC -SSL_get_peer_quic_transport_params 20004 3_0_0 EXIST::FUNCTION:QUIC -SSL_quic_write_level 20005 3_0_0 EXIST::FUNCTION:QUIC -SSL_CTX_set_quic_method 20006 3_0_0 EXIST::FUNCTION:QUIC -SSL_set_quic_method 20007 3_0_0 EXIST::FUNCTION:QUIC -SSL_quic_max_handshake_flight_len 20008 3_0_0 EXIST::FUNCTION:QUIC -SSL_process_quic_post_handshake 20009 3_0_0 EXIST::FUNCTION:QUIC -SSL_provide_quic_data 20010 3_0_0 EXIST::FUNCTION:QUIC -SSL_set_quic_use_legacy_codepoint 20011 3_0_0 EXIST::FUNCTION:QUIC -SSL_set_quic_transport_version 20012 3_0_0 EXIST::FUNCTION:QUIC -SSL_get_peer_quic_transport_version 20013 3_0_0 EXIST::FUNCTION:QUIC -SSL_get_quic_transport_version 20014 3_0_0 EXIST::FUNCTION:QUIC -SSL_set_quic_early_data_enabled 20015 3_0_0 EXIST::FUNCTION:QUIC diff --git a/deps/openssl/openssl/util/mkbuildinf.pl b/deps/openssl/openssl/util/mkbuildinf.pl index 1c273872be1..799ed3cdcd0 100755 --- a/deps/openssl/openssl/util/mkbuildinf.pl +++ b/deps/openssl/openssl/util/mkbuildinf.pl @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2014-2017 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2014-2025 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 @@ -9,17 +9,21 @@ use strict; use warnings; -my ($cflags, $platform) = @ARGV; +my $platform = pop @ARGV; +my $cflags = join(' ', @ARGV); +$cflags =~ s(\\)(\\\\)g; $cflags = "compiler: $cflags"; -my $date = gmtime($ENV{'SOURCE_DATE_EPOCH'} || time()) . " UTC"; +# Use the value of the envvar SOURCE_DATE_EPOCH, even if it's +# zero or the empty string. +my $date = gmtime($ENV{'SOURCE_DATE_EPOCH'} // time()) . " UTC"; print <<"END_OUTPUT"; /* * WARNING: do not edit! * Generated by util/mkbuildinf.pl * - * Copyright 2014-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2014-2025 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 diff --git a/deps/openssl/openssl/util/other.syms b/deps/openssl/openssl/util/other.syms index 839d0d2c08c..ea0a8caac43 100644 --- a/deps/openssl/openssl/util/other.syms +++ b/deps/openssl/openssl/util/other.syms @@ -143,8 +143,6 @@ custom_ext_free_cb datatype custom_ext_parse_cb datatype pem_password_cb datatype ssl_ct_validation_cb datatype -OSSL_ENCRYPTION_LEVEL datatype -SSL_QUIC_METHOD datatype # ASN1_BIT_STRING_digest define BIO_append_filename define diff --git a/deps/openssl/openssl/util/perl/OpenSSL/Template.pm b/deps/openssl/openssl/util/perl/OpenSSL/Template.pm index 7411dd8ae8d..ad93278ca76 100644 --- a/deps/openssl/openssl/util/perl/OpenSSL/Template.pm +++ b/deps/openssl/openssl/util/perl/OpenSSL/Template.pm @@ -42,6 +42,14 @@ use Text::Template 1.46; our @ISA = qw(Text::Template); # parent +sub tmpl_error { + my (%err_dict) = @_; + + $ERROR = $err_dict{"error"}; + + return undef; +} + sub new { my $class = shift; @@ -66,6 +74,7 @@ sub fill_in { output_on => sub { $self->output_on() }, output_off => sub { $self->output_off() }, %hash }, + BROKEN => \&tmpl_error, %opts); } diff --git a/deps/opentelemetry-cpp/MODULE.bazel b/deps/opentelemetry-cpp/MODULE.bazel index f0597b59e0a..d147305b137 100644 --- a/deps/opentelemetry-cpp/MODULE.bazel +++ b/deps/opentelemetry-cpp/MODULE.bazel @@ -3,23 +3,23 @@ module( name = "opentelemetry-cpp", - version = "1.22.0", + version = "1.23.0", compatibility_level = 0, repo_name = "io_opentelemetry_cpp", ) bazel_dep(name = "abseil-cpp", version = "20240116.1", repo_name = "com_google_absl") -bazel_dep(name = "bazel_skylib", version = "1.5.0") +bazel_dep(name = "bazel_skylib", version = "1.7.1") bazel_dep(name = "curl", version = "8.8.0") -bazel_dep(name = "grpc", version = "1.63.1.bcr.1", repo_name = "com_github_grpc_grpc") +bazel_dep(name = "grpc", version = "1.66.0.bcr.2", repo_name = "com_github_grpc_grpc") bazel_dep(name = "nlohmann_json", version = "3.12.0", repo_name = "github_nlohmann_json") bazel_dep(name = "opentelemetry-proto", version = "1.7.0", repo_name = "com_github_opentelemetry_proto") bazel_dep(name = "opentracing-cpp", version = "1.6.0", repo_name = "com_github_opentracing") -bazel_dep(name = "platforms", version = "0.0.8") +bazel_dep(name = "platforms", version = "0.0.11") bazel_dep(name = "prometheus-cpp", version = "1.3.0", repo_name = "com_github_jupp0r_prometheus_cpp") -bazel_dep(name = "protobuf", version = "26.0", repo_name = "com_google_protobuf") -bazel_dep(name = "rules_proto", version = "5.3.0-21.7") -bazel_dep(name = "zlib", version = "1.3.1.bcr.1") +bazel_dep(name = "protobuf", version = "29.0", repo_name = "com_google_protobuf") +bazel_dep(name = "rules_proto", version = "7.0.2") +bazel_dep(name = "zlib", version = "1.3.1.bcr.5") -bazel_dep(name = "google_benchmark", version = "1.8.3", dev_dependency = True, repo_name = "com_github_google_benchmark") +bazel_dep(name = "google_benchmark", version = "1.8.4", dev_dependency = True, repo_name = "com_github_google_benchmark") bazel_dep(name = "googletest", version = "1.14.0.bcr.1", dev_dependency = True, repo_name = "com_google_googletest") diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/common/string_util.h b/deps/opentelemetry-cpp/api/include/opentelemetry/common/string_util.h index 273a65272ba..5108f186e72 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/common/string_util.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/common/string_util.h @@ -3,6 +3,8 @@ #pragma once +#include + #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/logs/noop.h b/deps/opentelemetry-cpp/api/include/opentelemetry/logs/noop.h index 24312f061c5..5e7654ae750 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/logs/noop.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/logs/noop.h @@ -112,9 +112,28 @@ class NoopEventLogger final : public EventLogger class NoopEventLoggerProvider final : public EventLoggerProvider { public: +# if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable : 4996) +# elif defined(__GNUC__) && !defined(__clang__) && !defined(__apple_build_version__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +# elif defined(__clang__) || defined(__apple_build_version__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" +# endif + NoopEventLoggerProvider() : event_logger_{nostd::shared_ptr(new NoopEventLogger())} {} +# if defined(_MSC_VER) +# pragma warning(pop) +# elif defined(__GNUC__) && !defined(__clang__) && !defined(__apple_build_version__) +# pragma GCC diagnostic pop +# elif defined(__clang__) || defined(__apple_build_version__) +# pragma clang diagnostic pop +# endif + nostd::shared_ptr CreateEventLogger( nostd::shared_ptr /*delegate_logger*/, nostd::string_view /*event_domain*/) noexcept override diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/logs/provider.h b/deps/opentelemetry-cpp/api/include/opentelemetry/logs/provider.h index 0c1b4deea8a..58f668e0419 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/logs/provider.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/logs/provider.h @@ -84,8 +84,27 @@ class OPENTELEMETRY_EXPORT Provider OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr & GetEventProvider() noexcept { +# if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable : 4996) +# elif defined(__GNUC__) && !defined(__clang__) && !defined(__apple_build_version__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +# elif defined(__clang__) || defined(__apple_build_version__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" +# endif + static nostd::shared_ptr provider(new NoopEventLoggerProvider); return provider; + +# if defined(_MSC_VER) +# pragma warning(pop) +# elif defined(__GNUC__) && !defined(__clang__) && !defined(__apple_build_version__) +# pragma GCC diagnostic pop +# elif defined(__clang__) || defined(__apple_build_version__) +# pragma clang diagnostic pop +# endif } #endif diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/app_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/app_attributes.h index fdbad251b1f..b8477ee3bba 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/app_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/app_attributes.h @@ -19,6 +19,11 @@ namespace semconv namespace app { +/** + Unique identifier for a particular build or compilation of the application. + */ +static constexpr const char *kAppBuildId = "app.build_id"; + /** A unique identifier representing the installation of an application on a specific device

@@ -42,11 +47,29 @@ namespace app Settings.getString(Settings.Secure.ANDROID_ID) @endcode.

- More information about Android identifier best practices can be found here. + More information about Android identifier best practices can be found in the Android user data IDs + guide. */ static constexpr const char *kAppInstallationId = "app.installation.id"; +/** + A number of frame renders that experienced jank. +

+ Depending on platform limitations, the value provided MAY be approximation. + */ +static constexpr const char *kAppJankFrameCount = "app.jank.frame_count"; + +/** + The time period, in seconds, for which this jank is being reported. + */ +static constexpr const char *kAppJankPeriod = "app.jank.period"; + +/** + The minimum rendering threshold for this jank, in seconds. + */ +static constexpr const char *kAppJankThreshold = "app.jank.threshold"; + /** The x (horizontal) coordinate of a screen coordinate, in screen pixels. */ diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/aws_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/aws_attributes.h index 2abf1b762d4..d5922558029 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/aws_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/aws_attributes.h @@ -409,12 +409,12 @@ static constexpr const char *kAwsStepFunctionsStateMachineArn = namespace AwsEcsLaunchtypeValues { /** - none + Amazon EC2 */ static constexpr const char *kEc2 = "ec2"; /** - none + Amazon Fargate */ static constexpr const char *kFargate = "fargate"; diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/azure_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/azure_attributes.h index 0c62bad288f..1618050f9d9 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/azure_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/azure_attributes.h @@ -92,27 +92,27 @@ static constexpr const char *kDirect = "direct"; namespace AzureCosmosdbConsistencyLevelValues { /** - none + Strong */ static constexpr const char *kStrong = "Strong"; /** - none + Bounded Staleness */ static constexpr const char *kBoundedStaleness = "BoundedStaleness"; /** - none + Session */ static constexpr const char *kSession = "Session"; /** - none + Eventual */ static constexpr const char *kEventual = "Eventual"; /** - none + Consistent Prefix */ static constexpr const char *kConsistentPrefix = "ConsistentPrefix"; diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/azure_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/azure_metrics.h index fb60c3ce530..98f265f5e16 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/azure_metrics.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/azure_metrics.h @@ -21,14 +21,14 @@ namespace azure { /** - Number of active client instances + Number of active client instances.

updowncounter */ static constexpr const char *kMetricAzureCosmosdbClientActiveInstanceCount = "azure.cosmosdb.client.active_instance.count"; static constexpr const char *descrMetricAzureCosmosdbClientActiveInstanceCount = - "Number of active client instances"; + "Number of active client instances."; static constexpr const char *unitMetricAzureCosmosdbClientActiveInstanceCount = "{instance}"; static inline nostd::unique_ptr> @@ -67,13 +67,13 @@ CreateAsyncDoubleMetricAzureCosmosdbClientActiveInstanceCount(metrics::Meter *me /** Request units consumed by - the operation

histogram + the operation.

histogram */ static constexpr const char *kMetricAzureCosmosdbClientOperationRequestCharge = "azure.cosmosdb.client.operation.request_charge"; static constexpr const char *descrMetricAzureCosmosdbClientOperationRequestCharge = "[Request units](https://learn.microsoft.com/azure/cosmos-db/request-units) consumed by the " - "operation"; + "operation."; static constexpr const char *unitMetricAzureCosmosdbClientOperationRequestCharge = "{request_unit}"; static inline nostd::unique_ptr> diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cassandra_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cassandra_attributes.h index 88a71ba5ddb..c8db7380899 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cassandra_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cassandra_attributes.h @@ -55,57 +55,57 @@ static constexpr const char *kCassandraSpeculativeExecutionCount = namespace CassandraConsistencyLevelValues { /** - none + All */ static constexpr const char *kAll = "all"; /** - none + Each Quorum */ static constexpr const char *kEachQuorum = "each_quorum"; /** - none + Quorum */ static constexpr const char *kQuorum = "quorum"; /** - none + Local Quorum */ static constexpr const char *kLocalQuorum = "local_quorum"; /** - none + One */ static constexpr const char *kOne = "one"; /** - none + Two */ static constexpr const char *kTwo = "two"; /** - none + Three */ static constexpr const char *kThree = "three"; /** - none + Local One */ static constexpr const char *kLocalOne = "local_one"; /** - none + Any */ static constexpr const char *kAny = "any"; /** - none + Serial */ static constexpr const char *kSerial = "serial"; /** - none + Local Serial */ static constexpr const char *kLocalSerial = "local_serial"; diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/container_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/container_attributes.h index 92213a1e6b7..e0678618e28 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/container_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/container_attributes.h @@ -130,8 +130,28 @@ static constexpr const char *kContainerName = "container.name"; /** The container runtime managing this container. + + @deprecated + {"note": "Replaced by @code container.runtime.name @endcode.", "reason": "renamed", "renamed_to": + "container.runtime.name"} + */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kContainerRuntime = "container.runtime"; + +/** + A description about the runtime which could include, for example details about the CRI/API version + being used or other customisations. + */ +static constexpr const char *kContainerRuntimeDescription = "container.runtime.description"; + +/** + The container runtime managing this container. + */ +static constexpr const char *kContainerRuntimeName = "container.runtime.name"; + +/** + The version of the runtime of this process, as returned by the runtime without modification. */ -static constexpr const char *kContainerRuntime = "container.runtime"; +static constexpr const char *kContainerRuntimeVersion = "container.runtime.version"; namespace ContainerCpuStateValues { diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/container_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/container_metrics.h index 69853e77718..1b867442243 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/container_metrics.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/container_metrics.h @@ -21,14 +21,14 @@ namespace container { /** - Total CPU time consumed + Total CPU time consumed.

Total CPU time consumed by the specific container on all available CPU cores

counter */ static constexpr const char *kMetricContainerCpuTime = "container.cpu.time"; -static constexpr const char *descrMetricContainerCpuTime = "Total CPU time consumed"; +static constexpr const char *descrMetricContainerCpuTime = "Total CPU time consumed."; static constexpr const char *unitMetricContainerCpuTime = "s"; static inline nostd::unique_ptr> CreateSyncInt64MetricContainerCpuTime( @@ -60,7 +60,7 @@ CreateAsyncDoubleMetricContainerCpuTime(metrics::Meter *meter) } /** - Container's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs + Container's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs.

CPU usage of the specific container on all available CPU cores, averaged over the sample window

@@ -68,7 +68,7 @@ CreateAsyncDoubleMetricContainerCpuTime(metrics::Meter *meter) */ static constexpr const char *kMetricContainerCpuUsage = "container.cpu.usage"; static constexpr const char *descrMetricContainerCpuUsage = - "Container's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs"; + "Container's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs."; static constexpr const char *unitMetricContainerCpuUsage = "{cpu}"; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 @@ -141,6 +141,154 @@ CreateAsyncDoubleMetricContainerDiskIo(metrics::Meter *meter) unitMetricContainerDiskIo); } +/** + Container filesystem available bytes. +

+ In K8s, this metric is derived from the + FsStats.AvailableBytes + field of the ContainerStats.Rootfs + of the Kubelet's stats API. +

+ updowncounter + */ +static constexpr const char *kMetricContainerFilesystemAvailable = "container.filesystem.available"; +static constexpr const char *descrMetricContainerFilesystemAvailable = + "Container filesystem available bytes."; +static constexpr const char *unitMetricContainerFilesystemAvailable = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricContainerFilesystemAvailable(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricContainerFilesystemAvailable, + descrMetricContainerFilesystemAvailable, + unitMetricContainerFilesystemAvailable); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricContainerFilesystemAvailable(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricContainerFilesystemAvailable, + descrMetricContainerFilesystemAvailable, + unitMetricContainerFilesystemAvailable); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricContainerFilesystemAvailable(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricContainerFilesystemAvailable, + descrMetricContainerFilesystemAvailable, + unitMetricContainerFilesystemAvailable); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricContainerFilesystemAvailable(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricContainerFilesystemAvailable, + descrMetricContainerFilesystemAvailable, + unitMetricContainerFilesystemAvailable); +} + +/** + Container filesystem capacity. +

+ In K8s, this metric is derived from the + FsStats.CapacityBytes + field of the ContainerStats.Rootfs + of the Kubelet's stats API. +

+ updowncounter + */ +static constexpr const char *kMetricContainerFilesystemCapacity = "container.filesystem.capacity"; +static constexpr const char *descrMetricContainerFilesystemCapacity = + "Container filesystem capacity."; +static constexpr const char *unitMetricContainerFilesystemCapacity = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricContainerFilesystemCapacity(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricContainerFilesystemCapacity, + descrMetricContainerFilesystemCapacity, + unitMetricContainerFilesystemCapacity); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricContainerFilesystemCapacity(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricContainerFilesystemCapacity, + descrMetricContainerFilesystemCapacity, + unitMetricContainerFilesystemCapacity); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricContainerFilesystemCapacity(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricContainerFilesystemCapacity, + descrMetricContainerFilesystemCapacity, + unitMetricContainerFilesystemCapacity); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricContainerFilesystemCapacity(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricContainerFilesystemCapacity, + descrMetricContainerFilesystemCapacity, + unitMetricContainerFilesystemCapacity); +} + +/** + Container filesystem usage. +

+ This may not equal capacity - available. +

+ In K8s, this metric is derived from the + FsStats.UsedBytes + field of the ContainerStats.Rootfs + of the Kubelet's stats API. +

+ updowncounter + */ +static constexpr const char *kMetricContainerFilesystemUsage = "container.filesystem.usage"; +static constexpr const char *descrMetricContainerFilesystemUsage = "Container filesystem usage."; +static constexpr const char *unitMetricContainerFilesystemUsage = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricContainerFilesystemUsage(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricContainerFilesystemUsage, + descrMetricContainerFilesystemUsage, + unitMetricContainerFilesystemUsage); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricContainerFilesystemUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricContainerFilesystemUsage, + descrMetricContainerFilesystemUsage, + unitMetricContainerFilesystemUsage); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricContainerFilesystemUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricContainerFilesystemUsage, + descrMetricContainerFilesystemUsage, + unitMetricContainerFilesystemUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricContainerFilesystemUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricContainerFilesystemUsage, + descrMetricContainerFilesystemUsage, + unitMetricContainerFilesystemUsage); +} + /** Memory usage of the container.

@@ -220,15 +368,16 @@ CreateAsyncDoubleMetricContainerNetworkIo(metrics::Meter *meter) } /** - The time the container has been running + The time the container has been running.

Instrumentations SHOULD use a gauge with type @code double @endcode and measure uptime in seconds as a floating point number with the highest precision available. The actual accuracy would depend on the instrumentation and operating system.

gauge */ -static constexpr const char *kMetricContainerUptime = "container.uptime"; -static constexpr const char *descrMetricContainerUptime = "The time the container has been running"; -static constexpr const char *unitMetricContainerUptime = "s"; +static constexpr const char *kMetricContainerUptime = "container.uptime"; +static constexpr const char *descrMetricContainerUptime = + "The time the container has been running."; +static constexpr const char *unitMetricContainerUptime = "s"; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cpu_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cpu_attributes.h index c3c3ef58a56..f3b24e6950d 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cpu_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/cpu_attributes.h @@ -32,42 +32,42 @@ static constexpr const char *kCpuMode = "cpu.mode"; namespace CpuModeValues { /** - none + User */ static constexpr const char *kUser = "user"; /** - none + System */ static constexpr const char *kSystem = "system"; /** - none + Nice */ static constexpr const char *kNice = "nice"; /** - none + Idle */ static constexpr const char *kIdle = "idle"; /** - none + IO Wait */ static constexpr const char *kIowait = "iowait"; /** - none + Interrupt */ static constexpr const char *kInterrupt = "interrupt"; /** - none + Steal */ static constexpr const char *kSteal = "steal"; /** - none + Kernel */ static constexpr const char *kKernel = "kernel"; diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/db_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/db_attributes.h index c0c44276bc9..31b8f2b74e3 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/db_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/db_attributes.h @@ -517,87 +517,45 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kDbUser = "db.user"; namespace DbCassandraConsistencyLevelValues { -/** - none - */ + static constexpr const char *kAll = "all"; -/** - none - */ static constexpr const char *kEachQuorum = "each_quorum"; -/** - none - */ static constexpr const char *kQuorum = "quorum"; -/** - none - */ static constexpr const char *kLocalQuorum = "local_quorum"; -/** - none - */ static constexpr const char *kOne = "one"; -/** - none - */ static constexpr const char *kTwo = "two"; -/** - none - */ static constexpr const char *kThree = "three"; -/** - none - */ static constexpr const char *kLocalOne = "local_one"; -/** - none - */ static constexpr const char *kAny = "any"; -/** - none - */ static constexpr const char *kSerial = "serial"; -/** - none - */ static constexpr const char *kLocalSerial = "local_serial"; } // namespace DbCassandraConsistencyLevelValues namespace DbClientConnectionStateValues { -/** - none - */ + static constexpr const char *kIdle = "idle"; -/** - none - */ static constexpr const char *kUsed = "used"; } // namespace DbClientConnectionStateValues namespace DbClientConnectionsStateValues { -/** - none - */ + static constexpr const char *kIdle = "idle"; -/** - none - */ static constexpr const char *kUsed = "used"; } // namespace DbClientConnectionsStateValues @@ -618,108 +576,50 @@ static constexpr const char *kDirect = "direct"; namespace DbCosmosdbConsistencyLevelValues { -/** - none - */ + static constexpr const char *kStrong = "Strong"; -/** - none - */ static constexpr const char *kBoundedStaleness = "BoundedStaleness"; -/** - none - */ static constexpr const char *kSession = "Session"; -/** - none - */ static constexpr const char *kEventual = "Eventual"; -/** - none - */ static constexpr const char *kConsistentPrefix = "ConsistentPrefix"; } // namespace DbCosmosdbConsistencyLevelValues namespace DbCosmosdbOperationTypeValues { -/** - none - */ + static constexpr const char *kBatch = "batch"; -/** - none - */ static constexpr const char *kCreate = "create"; -/** - none - */ static constexpr const char *kDelete = "delete"; -/** - none - */ static constexpr const char *kExecute = "execute"; -/** - none - */ static constexpr const char *kExecuteJavascript = "execute_javascript"; -/** - none - */ static constexpr const char *kInvalid = "invalid"; -/** - none - */ static constexpr const char *kHead = "head"; -/** - none - */ static constexpr const char *kHeadFeed = "head_feed"; -/** - none - */ static constexpr const char *kPatch = "patch"; -/** - none - */ static constexpr const char *kQuery = "query"; -/** - none - */ static constexpr const char *kQueryPlan = "query_plan"; -/** - none - */ static constexpr const char *kRead = "read"; -/** - none - */ static constexpr const char *kReadFeed = "read_feed"; -/** - none - */ static constexpr const char *kReplace = "replace"; -/** - none - */ static constexpr const char *kUpsert = "upsert"; } // namespace DbCosmosdbOperationTypeValues @@ -738,8 +638,12 @@ static constexpr const char *kAdabas = "adabas"; /** Deprecated, use @code intersystems_cache @endcode instead. + + @deprecated + {"note": "Replaced by @code intersystems_cache @endcode.", "reason": "renamed", "renamed_to": + "intersystems_cache"} */ -static constexpr const char *kCache = "cache"; +OPENTELEMETRY_DEPRECATED static constexpr const char *kCache = "cache"; /** InterSystems Caché @@ -758,8 +662,11 @@ static constexpr const char *kClickhouse = "clickhouse"; /** Deprecated, use @code other_sql @endcode instead. + + @deprecated + {"note": "Replaced by @code other_sql @endcode.", "reason": "renamed", "renamed_to": "other_sql"} */ -static constexpr const char *kCloudscape = "cloudscape"; +OPENTELEMETRY_DEPRECATED static constexpr const char *kCloudscape = "cloudscape"; /** CockroachDB @@ -768,8 +675,11 @@ static constexpr const char *kCockroachdb = "cockroachdb"; /** Deprecated, no replacement at this time. + + @deprecated + {"note": "Obsoleted.", "reason": "obsoleted"} */ -static constexpr const char *kColdfusion = "coldfusion"; +OPENTELEMETRY_DEPRECATED static constexpr const char *kColdfusion = "coldfusion"; /** Microsoft Azure Cosmos DB @@ -823,8 +733,11 @@ static constexpr const char *kFirebird = "firebird"; /** Deprecated, use @code other_sql @endcode instead. + + @deprecated + {"note": "Replaced by @code other_sql @endcode.", "reason": "renamed", "renamed_to": "other_sql"} */ -static constexpr const char *kFirstsql = "firstsql"; +OPENTELEMETRY_DEPRECATED static constexpr const char *kFirstsql = "firstsql"; /** Apache Geode @@ -908,8 +821,11 @@ static constexpr const char *kMssql = "mssql"; /** Deprecated, Microsoft SQL Server Compact is discontinued. + + @deprecated + {"note": "Replaced by @code other_sql @endcode.", "reason": "renamed", "renamed_to": "other_sql"} */ -static constexpr const char *kMssqlcompact = "mssqlcompact"; +OPENTELEMETRY_DEPRECATED static constexpr const char *kMssqlcompact = "mssqlcompact"; /** MySQL diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/db_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/db_metrics.h index 8b74c62bcf2..935bad9d698 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/db_metrics.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/db_metrics.h @@ -22,11 +22,11 @@ namespace db /** The number of connections that are currently in state described by the @code state @endcode - attribute

updowncounter + attribute.

updowncounter */ static constexpr const char *kMetricDbClientConnectionCount = "db.client.connection.count"; static constexpr const char *descrMetricDbClientConnectionCount = - "The number of connections that are currently in state described by the `state` attribute"; + "The number of connections that are currently in state described by the `state` attribute."; static constexpr const char *unitMetricDbClientConnectionCount = "{connection}"; static inline nostd::unique_ptr> @@ -62,14 +62,14 @@ CreateAsyncDoubleMetricDbClientConnectionCount(metrics::Meter *meter) } /** - The time it took to create a new connection + The time it took to create a new connection.

histogram */ static constexpr const char *kMetricDbClientConnectionCreateTime = "db.client.connection.create_time"; static constexpr const char *descrMetricDbClientConnectionCreateTime = - "The time it took to create a new connection"; + "The time it took to create a new connection."; static constexpr const char *unitMetricDbClientConnectionCreateTime = "s"; static inline nostd::unique_ptr> @@ -89,13 +89,13 @@ CreateSyncDoubleMetricDbClientConnectionCreateTime(metrics::Meter *meter) } /** - The maximum number of idle open connections allowed + The maximum number of idle open connections allowed.

updowncounter */ static constexpr const char *kMetricDbClientConnectionIdleMax = "db.client.connection.idle.max"; static constexpr const char *descrMetricDbClientConnectionIdleMax = - "The maximum number of idle open connections allowed"; + "The maximum number of idle open connections allowed."; static constexpr const char *unitMetricDbClientConnectionIdleMax = "{connection}"; static inline nostd::unique_ptr> @@ -131,13 +131,13 @@ CreateAsyncDoubleMetricDbClientConnectionIdleMax(metrics::Meter *meter) } /** - The minimum number of idle open connections allowed + The minimum number of idle open connections allowed.

updowncounter */ static constexpr const char *kMetricDbClientConnectionIdleMin = "db.client.connection.idle.min"; static constexpr const char *descrMetricDbClientConnectionIdleMin = - "The minimum number of idle open connections allowed"; + "The minimum number of idle open connections allowed."; static constexpr const char *unitMetricDbClientConnectionIdleMin = "{connection}"; static inline nostd::unique_ptr> @@ -173,13 +173,13 @@ CreateAsyncDoubleMetricDbClientConnectionIdleMin(metrics::Meter *meter) } /** - The maximum number of open connections allowed + The maximum number of open connections allowed.

updowncounter */ static constexpr const char *kMetricDbClientConnectionMax = "db.client.connection.max"; static constexpr const char *descrMetricDbClientConnectionMax = - "The maximum number of open connections allowed"; + "The maximum number of open connections allowed."; static constexpr const char *unitMetricDbClientConnectionMax = "{connection}"; static inline nostd::unique_ptr> @@ -215,14 +215,14 @@ CreateAsyncDoubleMetricDbClientConnectionMax(metrics::Meter *meter) } /** - The number of current pending requests for an open connection + The number of current pending requests for an open connection.

updowncounter */ static constexpr const char *kMetricDbClientConnectionPendingRequests = "db.client.connection.pending_requests"; static constexpr const char *descrMetricDbClientConnectionPendingRequests = - "The number of current pending requests for an open connection"; + "The number of current pending requests for an open connection."; static constexpr const char *unitMetricDbClientConnectionPendingRequests = "{request}"; static inline nostd::unique_ptr> @@ -258,14 +258,14 @@ CreateAsyncDoubleMetricDbClientConnectionPendingRequests(metrics::Meter *meter) } /** - The number of connection timeouts that have occurred trying to obtain a connection from the pool + The number of connection timeouts that have occurred trying to obtain a connection from the pool.

counter */ static constexpr const char *kMetricDbClientConnectionTimeouts = "db.client.connection.timeouts"; static constexpr const char *descrMetricDbClientConnectionTimeouts = "The number of connection timeouts that have occurred trying to obtain a connection from the " - "pool"; + "pool."; static constexpr const char *unitMetricDbClientConnectionTimeouts = "{timeout}"; static inline nostd::unique_ptr> @@ -301,13 +301,13 @@ CreateAsyncDoubleMetricDbClientConnectionTimeouts(metrics::Meter *meter) } /** - The time between borrowing a connection and returning it to the pool + The time between borrowing a connection and returning it to the pool.

histogram */ static constexpr const char *kMetricDbClientConnectionUseTime = "db.client.connection.use_time"; static constexpr const char *descrMetricDbClientConnectionUseTime = - "The time between borrowing a connection and returning it to the pool"; + "The time between borrowing a connection and returning it to the pool."; static constexpr const char *unitMetricDbClientConnectionUseTime = "s"; static inline nostd::unique_ptr> @@ -327,13 +327,13 @@ CreateSyncDoubleMetricDbClientConnectionUseTime(metrics::Meter *meter) } /** - The time it took to obtain an open connection from the pool + The time it took to obtain an open connection from the pool.

histogram */ static constexpr const char *kMetricDbClientConnectionWaitTime = "db.client.connection.wait_time"; static constexpr const char *descrMetricDbClientConnectionWaitTime = - "The time it took to obtain an open connection from the pool"; + "The time it took to obtain an open connection from the pool."; static constexpr const char *unitMetricDbClientConnectionWaitTime = "s"; static inline nostd::unique_ptr> diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/deployment_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/deployment_attributes.h index 33209ebbf0c..80f240663cc 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/deployment_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/deployment_attributes.h @@ -20,7 +20,7 @@ namespace deployment { /** - 'Deprecated, use @code deployment.environment.name @endcode instead.' + Deprecated, use @code deployment.environment.name @endcode instead. @deprecated {"note": "Replaced by @code deployment.environment.name @endcode.", "reason": "renamed", diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/device_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/device_attributes.h index f69856ee4fb..e801686f410 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/device_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/device_attributes.h @@ -25,8 +25,9 @@ namespace device Its value SHOULD be identical for all apps on a device and it SHOULD NOT change if an app is uninstalled and re-installed. However, it might be resettable by the user for all apps on a device. Hardware IDs (e.g. vendor-specific serial number, IMEI or MAC address) MAY be used as - values.

More information about Android identifier best practices can be found here.

+ values.

More information about Android identifier best practices can be found in the Android user data IDs + guide.

[!WARNING]

This attribute may contain sensitive (PII) information. Caution should be taken when storing diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/disk_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/disk_attributes.h index c2504d75ff5..3e3e209b8f4 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/disk_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/disk_attributes.h @@ -26,14 +26,9 @@ static constexpr const char *kDiskIoDirection = "disk.io.direction"; namespace DiskIoDirectionValues { -/** - none - */ + static constexpr const char *kRead = "read"; -/** - none - */ static constexpr const char *kWrite = "write"; } // namespace DiskIoDirectionValues diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/enduser_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/enduser_attributes.h index 9120aa2c05a..d117dd268e1 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/enduser_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/enduser_attributes.h @@ -40,7 +40,8 @@ static constexpr const char *kEnduserPseudoId = "enduser.pseudo.id"; Deprecated, use @code user.roles @endcode instead. @deprecated - {"note": "Use @code user.roles @endcode attribute instead.", "reason": "uncategorized"} + {"note": "Replaced by @code user.roles @endcode.", "reason": "renamed", "renamed_to": + "user.roles"} */ OPENTELEMETRY_DEPRECATED static constexpr const char *kEnduserRole = "enduser.role"; diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/faas_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/faas_metrics.h index 99888cde9de..868eac024e0 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/faas_metrics.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/faas_metrics.h @@ -21,12 +21,12 @@ namespace faas { /** - Number of invocation cold starts + Number of invocation cold starts.

counter */ static constexpr const char *kMetricFaasColdstarts = "faas.coldstarts"; -static constexpr const char *descrMetricFaasColdstarts = "Number of invocation cold starts"; +static constexpr const char *descrMetricFaasColdstarts = "Number of invocation cold starts."; static constexpr const char *unitMetricFaasColdstarts = "{coldstart}"; static inline nostd::unique_ptr> CreateSyncInt64MetricFaasColdstarts( @@ -58,12 +58,12 @@ CreateAsyncDoubleMetricFaasColdstarts(metrics::Meter *meter) } /** - Distribution of CPU usage per invocation + Distribution of CPU usage per invocation.

histogram */ static constexpr const char *kMetricFaasCpuUsage = "faas.cpu_usage"; -static constexpr const char *descrMetricFaasCpuUsage = "Distribution of CPU usage per invocation"; +static constexpr const char *descrMetricFaasCpuUsage = "Distribution of CPU usage per invocation."; static constexpr const char *unitMetricFaasCpuUsage = "s"; static inline nostd::unique_ptr> CreateSyncInt64MetricFaasCpuUsage( @@ -81,12 +81,12 @@ static inline nostd::unique_ptr> CreateSyncDoubleMetr } /** - Number of invocation errors + Number of invocation errors.

counter */ static constexpr const char *kMetricFaasErrors = "faas.errors"; -static constexpr const char *descrMetricFaasErrors = "Number of invocation errors"; +static constexpr const char *descrMetricFaasErrors = "Number of invocation errors."; static constexpr const char *unitMetricFaasErrors = "{error}"; static inline nostd::unique_ptr> CreateSyncInt64MetricFaasErrors( @@ -116,13 +116,13 @@ static inline nostd::shared_ptr CreateAsyncDouble } /** - Measures the duration of the function's initialization, such as a cold start + Measures the duration of the function's initialization, such as a cold start.

histogram */ static constexpr const char *kMetricFaasInitDuration = "faas.init_duration"; static constexpr const char *descrMetricFaasInitDuration = - "Measures the duration of the function's initialization, such as a cold start"; + "Measures the duration of the function's initialization, such as a cold start."; static constexpr const char *unitMetricFaasInitDuration = "s"; static inline nostd::unique_ptr> CreateSyncInt64MetricFaasInitDuration( @@ -140,12 +140,12 @@ static inline nostd::unique_ptr> CreateSyncDoubleMetr } /** - Number of successful invocations + Number of successful invocations.

counter */ static constexpr const char *kMetricFaasInvocations = "faas.invocations"; -static constexpr const char *descrMetricFaasInvocations = "Number of successful invocations"; +static constexpr const char *descrMetricFaasInvocations = "Number of successful invocations."; static constexpr const char *unitMetricFaasInvocations = "{invocation}"; static inline nostd::unique_ptr> CreateSyncInt64MetricFaasInvocations( @@ -177,13 +177,13 @@ CreateAsyncDoubleMetricFaasInvocations(metrics::Meter *meter) } /** - Measures the duration of the function's logic execution + Measures the duration of the function's logic execution.

histogram */ static constexpr const char *kMetricFaasInvokeDuration = "faas.invoke_duration"; static constexpr const char *descrMetricFaasInvokeDuration = - "Measures the duration of the function's logic execution"; + "Measures the duration of the function's logic execution."; static constexpr const char *unitMetricFaasInvokeDuration = "s"; static inline nostd::unique_ptr> @@ -201,13 +201,13 @@ CreateSyncDoubleMetricFaasInvokeDuration(metrics::Meter *meter) } /** - Distribution of max memory usage per invocation + Distribution of max memory usage per invocation.

histogram */ static constexpr const char *kMetricFaasMemUsage = "faas.mem_usage"; static constexpr const char *descrMetricFaasMemUsage = - "Distribution of max memory usage per invocation"; + "Distribution of max memory usage per invocation."; static constexpr const char *unitMetricFaasMemUsage = "By"; static inline nostd::unique_ptr> CreateSyncInt64MetricFaasMemUsage( @@ -225,12 +225,12 @@ static inline nostd::unique_ptr> CreateSyncDoubleMetr } /** - Distribution of net I/O usage per invocation + Distribution of net I/O usage per invocation.

histogram */ static constexpr const char *kMetricFaasNetIo = "faas.net_io"; -static constexpr const char *descrMetricFaasNetIo = "Distribution of net I/O usage per invocation"; +static constexpr const char *descrMetricFaasNetIo = "Distribution of net I/O usage per invocation."; static constexpr const char *unitMetricFaasNetIo = "By"; static inline nostd::unique_ptr> CreateSyncInt64MetricFaasNetIo( @@ -246,12 +246,12 @@ static inline nostd::unique_ptr> CreateSyncDoubleMetr } /** - Number of invocation timeouts + Number of invocation timeouts.

counter */ static constexpr const char *kMetricFaasTimeouts = "faas.timeouts"; -static constexpr const char *descrMetricFaasTimeouts = "Number of invocation timeouts"; +static constexpr const char *descrMetricFaasTimeouts = "Number of invocation timeouts."; static constexpr const char *unitMetricFaasTimeouts = "{timeout}"; static inline nostd::unique_ptr> CreateSyncInt64MetricFaasTimeouts( diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h index 95f11c7fc4c..50bfff5317f 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h @@ -61,6 +61,23 @@ static constexpr const char *kGenAiConversationId = "gen_ai.conversation.id"; */ static constexpr const char *kGenAiDataSourceId = "gen_ai.data_source.id"; +/** + The chat history provided to the model as an input. +

+ Instrumentations MUST follow Input messages JSON + schema. When the attribute is recorded on events, it MUST be recorded in structured form. When + recorded on spans, it MAY be recorded as a JSON string if structured format is not supported and + SHOULD be recorded in structured form otherwise.

Messages MUST be provided in the order they + were sent to the model. Instrumentations MAY provide a way for users to filter or truncate input + messages.

+ [!Warning] + This attribute is likely to contain sensitive information including user/PII data.
+

+ See Recording content on + attributes section for more details. + */ +static constexpr const char *kGenAiInputMessages = "gen_ai.input.messages"; + /** Deprecated, use @code gen_ai.output.type @endcode. @@ -82,20 +99,33 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kGenAiOpenaiRequestSeed = "gen_ai.openai.request.seed"; /** - The service tier requested. May be a specific tier, default, or auto. + Deprecated, use @code openai.request.service_tier @endcode. + + @deprecated + {"note": "Replaced by @code openai.request.service_tier @endcode.", "reason": "renamed", + "renamed_to": "openai.request.service_tier"} */ -static constexpr const char *kGenAiOpenaiRequestServiceTier = "gen_ai.openai.request.service_tier"; +OPENTELEMETRY_DEPRECATED static constexpr const char *kGenAiOpenaiRequestServiceTier = + "gen_ai.openai.request.service_tier"; /** - The service tier used for the response. + Deprecated, use @code openai.response.service_tier @endcode. + + @deprecated + {"note": "Replaced by @code openai.response.service_tier @endcode.", "reason": "renamed", + "renamed_to": "openai.response.service_tier"} */ -static constexpr const char *kGenAiOpenaiResponseServiceTier = +OPENTELEMETRY_DEPRECATED static constexpr const char *kGenAiOpenaiResponseServiceTier = "gen_ai.openai.response.service_tier"; /** - A fingerprint to track any eventual change in the Generative AI environment. + Deprecated, use @code openai.response.system_fingerprint @endcode. + + @deprecated + {"note": "Replaced by @code openai.response.system_fingerprint @endcode.", "reason": "renamed", + "renamed_to": "openai.response.system_fingerprint"} */ -static constexpr const char *kGenAiOpenaiResponseSystemFingerprint = +OPENTELEMETRY_DEPRECATED static constexpr const char *kGenAiOpenaiResponseSystemFingerprint = "gen_ai.openai.response.system_fingerprint"; /** @@ -108,6 +138,29 @@ static constexpr const char *kGenAiOpenaiResponseSystemFingerprint = */ static constexpr const char *kGenAiOperationName = "gen_ai.operation.name"; +/** + Messages returned by the model where each message represents a specific model response (choice, + candidate).

Instrumentations MUST follow Output messages JSON schema

Each message + represents a single output choice/candidate generated by the model. Each message corresponds to + exactly one generation (choice/candidate) and vice versa - one choice cannot be split across + multiple messages or one message cannot contain parts from multiple choices. +

+ When the attribute is recorded on events, it MUST be recorded in structured + form. When recorded on spans, it MAY be recorded as a JSON string if structured + format is not supported and SHOULD be recorded in structured form otherwise. +

+ Instrumentations MAY provide a way for users to filter or truncate + output messages. +

+ [!Warning] + This attribute is likely to contain sensitive information including user/PII data.
+

+ See Recording content on + attributes section for more details. + */ +static constexpr const char *kGenAiOutputMessages = "gen_ai.output.messages"; + /** Represents the content type requested by the client.

@@ -127,6 +180,28 @@ static constexpr const char *kGenAiOutputType = "gen_ai.output.type"; */ OPENTELEMETRY_DEPRECATED static constexpr const char *kGenAiPrompt = "gen_ai.prompt"; +/** + The Generative AI provider as identified by the client or server instrumentation. +

+ The attribute SHOULD be set based on the instrumentation's best + knowledge and may differ from the actual model provider. +

+ Multiple providers, including Azure OpenAI, Gemini, and AI hosting platforms + are accessible using the OpenAI REST API and corresponding client libraries, + but may proxy or host models from different providers. +

+ The @code gen_ai.request.model @endcode, @code gen_ai.response.model @endcode, and @code + server.address @endcode attributes may help identify the actual system in use.

The @code + gen_ai.provider.name @endcode attribute acts as a discriminator that identifies the GenAI + telemetry format flavor specific to that provider within GenAI semantic conventions. It SHOULD be + set consistently with provider-specific attributes and signals. For example, GenAI spans, metrics, + and events related to AWS Bedrock should have the @code gen_ai.provider.name @endcode set to @code + aws.bedrock @endcode and include applicable @code aws.bedrock.* @endcode attributes and are not + expected to include + @code openai.* @endcode attributes. + */ +static constexpr const char *kGenAiProviderName = "gen_ai.provider.name"; + /** The target number of candidate completions to return. */ @@ -201,20 +276,37 @@ static constexpr const char *kGenAiResponseId = "gen_ai.response.id"; static constexpr const char *kGenAiResponseModel = "gen_ai.response.model"; /** - The Generative AI product as identified by the client or server instrumentation. + Deprecated, use @code gen_ai.provider.name @endcode instead. + + @deprecated + {"note": "Replaced by @code gen_ai.provider.name @endcode.", "reason": "renamed", "renamed_to": + "gen_ai.provider.name"} + */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kGenAiSystem = "gen_ai.system"; + +/** + The system message or instructions provided to the GenAI model separately from the chat history. +

+ This attribute SHOULD be used when the corresponding provider or API + allows to provide system instructions or messages separately from the + chat history.

- The @code gen_ai.system @endcode describes a family of GenAI models with specific model identified - by @code gen_ai.request.model @endcode and @code gen_ai.response.model @endcode attributes. + Instructions that are part of the chat history SHOULD be recorded in + @code gen_ai.input.messages @endcode attribute instead.

- The actual GenAI product may differ from the one identified by the client. - Multiple systems, including Azure OpenAI and Gemini, are accessible by OpenAI client - libraries. In such cases, the @code gen_ai.system @endcode is set to @code openai @endcode based - on the instrumentation's best knowledge, instead of the actual system. The @code server.address - @endcode attribute may help identify the actual system in use for @code openai @endcode.

For - custom model, a custom friendly name SHOULD be used. If none of these options apply, the @code - gen_ai.system @endcode SHOULD be set to @code _OTHER @endcode. + Instrumentations MUST follow System + instructions JSON schema.

When recorded on spans, it MAY be recorded as a JSON string if + structured format is not supported and SHOULD be recorded in structured form otherwise.

+ Instrumentations MAY provide a way for users to filter or truncate + system instructions. +

+ [!Warning] + This attribute may contain sensitive information.
+

+ See Recording content on + attributes section for more details. */ -static constexpr const char *kGenAiSystem = "gen_ai.system"; +static constexpr const char *kGenAiSystemInstructions = "gen_ai.system_instructions"; /** The type of token being counted. @@ -381,6 +473,85 @@ static constexpr const char *kSpeech = "speech"; } // namespace GenAiOutputTypeValues +namespace GenAiProviderNameValues +{ +/** + OpenAI + */ +static constexpr const char *kOpenai = "openai"; + +/** + Any Google generative AI endpoint + */ +static constexpr const char *kGcpGenAi = "gcp.gen_ai"; + +/** + Vertex AI + */ +static constexpr const char *kGcpVertexAi = "gcp.vertex_ai"; + +/** + Gemini + */ +static constexpr const char *kGcpGemini = "gcp.gemini"; + +/** + Anthropic + */ +static constexpr const char *kAnthropic = "anthropic"; + +/** + Cohere + */ +static constexpr const char *kCohere = "cohere"; + +/** + Azure AI Inference + */ +static constexpr const char *kAzureAiInference = "azure.ai.inference"; + +/** + Azure OpenAI + */ +static constexpr const char *kAzureAiOpenai = "azure.ai.openai"; + +/** + IBM Watsonx AI + */ +static constexpr const char *kIbmWatsonxAi = "ibm.watsonx.ai"; + +/** + AWS Bedrock + */ +static constexpr const char *kAwsBedrock = "aws.bedrock"; + +/** + Perplexity + */ +static constexpr const char *kPerplexity = "perplexity"; + +/** + xAI + */ +static constexpr const char *kXAi = "x_ai"; + +/** + DeepSeek + */ +static constexpr const char *kDeepseek = "deepseek"; + +/** + Groq + */ +static constexpr const char *kGroq = "groq"; + +/** + Mistral AI + */ +static constexpr const char *kMistralAi = "mistral_ai"; + +} // namespace GenAiProviderNameValues + namespace GenAiSystemValues { /** @@ -405,13 +576,21 @@ static constexpr const char *kGcpGemini = "gcp.gemini"; /** Vertex AI + + @deprecated + {"note": "Replaced by @code gcp.vertex_ai @endcode.", "reason": "renamed", "renamed_to": + "gcp.vertex_ai"} */ -static constexpr const char *kVertexAi = "vertex_ai"; +OPENTELEMETRY_DEPRECATED static constexpr const char *kVertexAi = "vertex_ai"; /** Gemini + + @deprecated + {"note": "Replaced by @code gcp.gemini @endcode.", "reason": "renamed", "renamed_to": + "gcp.gemini"} */ -static constexpr const char *kGemini = "gemini"; +OPENTELEMETRY_DEPRECATED static constexpr const char *kGemini = "gemini"; /** Anthropic @@ -426,22 +605,22 @@ static constexpr const char *kCohere = "cohere"; /** Azure AI Inference */ -static constexpr const char *kAzureAiInference = "azure.ai.inference"; +static constexpr const char *kAzAiInference = "az.ai.inference"; /** Azure OpenAI */ -static constexpr const char *kAzureAiOpenai = "azure.ai.openai"; +static constexpr const char *kAzAiOpenai = "az.ai.openai"; /** Azure AI Inference */ -static constexpr const char *kAzAiInference = "az.ai.inference"; +static constexpr const char *kAzureAiInference = "azure.ai.inference"; /** Azure OpenAI */ -static constexpr const char *kAzAiOpenai = "azure.ai.openai"; +static constexpr const char *kAzureAiOpenai = "azure.ai.openai"; /** IBM Watsonx AI @@ -460,8 +639,11 @@ static constexpr const char *kPerplexity = "perplexity"; /** xAI + + @deprecated + {"note": "Replaced by @code x_ai @endcode.", "reason": "renamed", "renamed_to": "x_ai"} */ -static constexpr const char *kXai = "xai"; +OPENTELEMETRY_DEPRECATED static constexpr const char *kXai = "xai"; /** DeepSeek @@ -489,8 +671,11 @@ static constexpr const char *kInput = "input"; /** Output tokens (completion, response, etc.) + + @deprecated + {"note": "Replaced by @code output @endcode.", "reason": "renamed", "renamed_to": "output"} */ -static constexpr const char *kCompletion = "output"; +OPENTELEMETRY_DEPRECATED static constexpr const char *kCompletion = "output"; /** Output tokens (completion, response, etc.) diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/gen_ai_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/gen_ai_metrics.h index 2cd11bd546f..a5798f9dbcf 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/gen_ai_metrics.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/gen_ai_metrics.h @@ -21,13 +21,13 @@ namespace gen_ai { /** - GenAI operation duration + GenAI operation duration.

histogram */ static constexpr const char *kMetricGenAiClientOperationDuration = "gen_ai.client.operation.duration"; -static constexpr const char *descrMetricGenAiClientOperationDuration = "GenAI operation duration"; +static constexpr const char *descrMetricGenAiClientOperationDuration = "GenAI operation duration."; static constexpr const char *unitMetricGenAiClientOperationDuration = "s"; static inline nostd::unique_ptr> @@ -47,13 +47,13 @@ CreateSyncDoubleMetricGenAiClientOperationDuration(metrics::Meter *meter) } /** - Measures number of input and output tokens used + Number of input and output tokens used.

histogram */ static constexpr const char *kMetricGenAiClientTokenUsage = "gen_ai.client.token.usage"; static constexpr const char *descrMetricGenAiClientTokenUsage = - "Measures number of input and output tokens used"; + "Number of input and output tokens used."; static constexpr const char *unitMetricGenAiClientTokenUsage = "{token}"; static inline nostd::unique_ptr> @@ -73,13 +73,13 @@ CreateSyncDoubleMetricGenAiClientTokenUsage(metrics::Meter *meter) } /** - Generative AI server request duration such as time-to-last byte or last output token + Generative AI server request duration such as time-to-last byte or last output token.

histogram */ static constexpr const char *kMetricGenAiServerRequestDuration = "gen_ai.server.request.duration"; static constexpr const char *descrMetricGenAiServerRequestDuration = - "Generative AI server request duration such as time-to-last byte or last output token"; + "Generative AI server request duration such as time-to-last byte or last output token."; static constexpr const char *unitMetricGenAiServerRequestDuration = "s"; static inline nostd::unique_ptr> @@ -99,14 +99,14 @@ CreateSyncDoubleMetricGenAiServerRequestDuration(metrics::Meter *meter) } /** - Time per output token generated after the first token for successful responses + Time per output token generated after the first token for successful responses.

histogram */ static constexpr const char *kMetricGenAiServerTimePerOutputToken = "gen_ai.server.time_per_output_token"; static constexpr const char *descrMetricGenAiServerTimePerOutputToken = - "Time per output token generated after the first token for successful responses"; + "Time per output token generated after the first token for successful responses."; static constexpr const char *unitMetricGenAiServerTimePerOutputToken = "s"; static inline nostd::unique_ptr> @@ -126,14 +126,14 @@ CreateSyncDoubleMetricGenAiServerTimePerOutputToken(metrics::Meter *meter) } /** - Time to generate first token for successful responses + Time to generate first token for successful responses.

histogram */ static constexpr const char *kMetricGenAiServerTimeToFirstToken = "gen_ai.server.time_to_first_token"; static constexpr const char *descrMetricGenAiServerTimeToFirstToken = - "Time to generate first token for successful responses"; + "Time to generate first token for successful responses."; static constexpr const char *unitMetricGenAiServerTimeToFirstToken = "s"; static inline nostd::unique_ptr> diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/hw_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/hw_attributes.h index 04c8a7638b2..2ffcfd16f0d 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/hw_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/hw_attributes.h @@ -19,27 +19,134 @@ namespace semconv namespace hw { +/** + Design capacity in Watts-hours or Amper-hours + */ +static constexpr const char *kHwBatteryCapacity = "hw.battery.capacity"; + +/** + Battery chemistry, + e.g. Lithium-Ion, Nickel-Cadmium, etc. + */ +static constexpr const char *kHwBatteryChemistry = "hw.battery.chemistry"; + +/** + The current state of the battery + */ +static constexpr const char *kHwBatteryState = "hw.battery.state"; + +/** + BIOS version of the hardware component + */ +static constexpr const char *kHwBiosVersion = "hw.bios_version"; + +/** + Driver version for the hardware component + */ +static constexpr const char *kHwDriverVersion = "hw.driver_version"; + +/** + Type of the enclosure (useful for modular systems) + */ +static constexpr const char *kHwEnclosureType = "hw.enclosure.type"; + +/** + Firmware version of the hardware component + */ +static constexpr const char *kHwFirmwareVersion = "hw.firmware_version"; + +/** + Type of task the GPU is performing + */ +static constexpr const char *kHwGpuTask = "hw.gpu.task"; + /** An identifier for the hardware component, unique within the monitored host */ static constexpr const char *kHwId = "hw.id"; +/** + Type of limit for hardware components + */ +static constexpr const char *kHwLimitType = "hw.limit_type"; + +/** + RAID Level of the logical disk + */ +static constexpr const char *kHwLogicalDiskRaidLevel = "hw.logical_disk.raid_level"; + +/** + State of the logical disk space usage + */ +static constexpr const char *kHwLogicalDiskState = "hw.logical_disk.state"; + +/** + Type of the memory module + */ +static constexpr const char *kHwMemoryType = "hw.memory.type"; + +/** + Descriptive model name of the hardware component + */ +static constexpr const char *kHwModel = "hw.model"; + /** An easily-recognizable name for the hardware component */ static constexpr const char *kHwName = "hw.name"; +/** + Logical addresses of the adapter (e.g. IP address, or WWPN) + */ +static constexpr const char *kHwNetworkLogicalAddresses = "hw.network.logical_addresses"; + +/** + Physical address of the adapter (e.g. MAC address, or WWNN) + */ +static constexpr const char *kHwNetworkPhysicalAddress = "hw.network.physical_address"; + /** Unique identifier of the parent component (typically the @code hw.id @endcode attribute of the enclosure, or disk controller) */ static constexpr const char *kHwParent = "hw.parent"; +/** + S.M.A.R.T. (Self-Monitoring, Analysis, and + Reporting Technology) attribute of the physical disk + */ +static constexpr const char *kHwPhysicalDiskSmartAttribute = "hw.physical_disk.smart_attribute"; + +/** + State of the physical disk endurance utilization + */ +static constexpr const char *kHwPhysicalDiskState = "hw.physical_disk.state"; + +/** + Type of the physical disk + */ +static constexpr const char *kHwPhysicalDiskType = "hw.physical_disk.type"; + +/** + Location of the sensor + */ +static constexpr const char *kHwSensorLocation = "hw.sensor_location"; + +/** + Serial number of the hardware component + */ +static constexpr const char *kHwSerialNumber = "hw.serial_number"; + /** The current state of the component */ static constexpr const char *kHwState = "hw.state"; +/** + Type of tape drive operation + */ +static constexpr const char *kHwTapeDriveOperationType = "hw.tape_drive.operation_type"; + /** Type of the component

@@ -50,25 +157,164 @@ static constexpr const char *kHwState = "hw.state"; */ static constexpr const char *kHwType = "hw.type"; -namespace HwStateValues +/** + Vendor name of the hardware component + */ +static constexpr const char *kHwVendor = "hw.vendor"; + +namespace HwBatteryStateValues { /** - Ok + Charging */ -static constexpr const char *kOk = "ok"; +static constexpr const char *kCharging = "charging"; + +/** + Discharging + */ +static constexpr const char *kDischarging = "discharging"; + +} // namespace HwBatteryStateValues + +namespace HwGpuTaskValues +{ +/** + Decoder + */ +static constexpr const char *kDecoder = "decoder"; + +/** + Encoder + */ +static constexpr const char *kEncoder = "encoder"; + +/** + General + */ +static constexpr const char *kGeneral = "general"; + +} // namespace HwGpuTaskValues + +namespace HwLimitTypeValues +{ +/** + Critical + */ +static constexpr const char *kCritical = "critical"; /** Degraded */ static constexpr const char *kDegraded = "degraded"; +/** + High Critical + */ +static constexpr const char *kHighCritical = "high.critical"; + +/** + High Degraded + */ +static constexpr const char *kHighDegraded = "high.degraded"; + +/** + Low Critical + */ +static constexpr const char *kLowCritical = "low.critical"; + +/** + Low Degraded + */ +static constexpr const char *kLowDegraded = "low.degraded"; + +/** + Maximum + */ +static constexpr const char *kMax = "max"; + +/** + Throttled + */ +static constexpr const char *kThrottled = "throttled"; + +/** + Turbo + */ +static constexpr const char *kTurbo = "turbo"; + +} // namespace HwLimitTypeValues + +namespace HwLogicalDiskStateValues +{ +/** + Used + */ +static constexpr const char *kUsed = "used"; + +/** + Free + */ +static constexpr const char *kFree = "free"; + +} // namespace HwLogicalDiskStateValues + +namespace HwPhysicalDiskStateValues +{ +/** + Remaining + */ +static constexpr const char *kRemaining = "remaining"; + +} // namespace HwPhysicalDiskStateValues + +namespace HwStateValues +{ +/** + Degraded + */ +static constexpr const char *kDegraded = "degraded"; + /** Failed */ static constexpr const char *kFailed = "failed"; +/** + Needs Cleaning + */ +static constexpr const char *kNeedsCleaning = "needs_cleaning"; + +/** + OK + */ +static constexpr const char *kOk = "ok"; + +/** + Predicted Failure + */ +static constexpr const char *kPredictedFailure = "predicted_failure"; + } // namespace HwStateValues +namespace HwTapeDriveOperationTypeValues +{ +/** + Mount + */ +static constexpr const char *kMount = "mount"; + +/** + Unmount + */ +static constexpr const char *kUnmount = "unmount"; + +/** + Clean + */ +static constexpr const char *kClean = "clean"; + +} // namespace HwTapeDriveOperationTypeValues + namespace HwTypeValues { /** diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/hw_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/hw_metrics.h index e73e9edeb89..fe391112659 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/hw_metrics.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/hw_metrics.h @@ -21,12 +21,212 @@ namespace hw { /** - Energy consumed by the component + Remaining fraction of battery charge. +

+ gauge + */ +static constexpr const char *kMetricHwBatteryCharge = "hw.battery.charge"; +static constexpr const char *descrMetricHwBatteryCharge = "Remaining fraction of battery charge."; +static constexpr const char *unitMetricHwBatteryCharge = "1"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwBatteryCharge( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwBatteryCharge, descrMetricHwBatteryCharge, + unitMetricHwBatteryCharge); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwBatteryCharge( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwBatteryCharge, descrMetricHwBatteryCharge, + unitMetricHwBatteryCharge); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwBatteryCharge(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricHwBatteryCharge, descrMetricHwBatteryCharge, + unitMetricHwBatteryCharge); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwBatteryCharge(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricHwBatteryCharge, descrMetricHwBatteryCharge, + unitMetricHwBatteryCharge); +} + +/** + Lower limit of battery charge fraction to ensure proper operation. +

+ gauge + */ +static constexpr const char *kMetricHwBatteryChargeLimit = "hw.battery.charge.limit"; +static constexpr const char *descrMetricHwBatteryChargeLimit = + "Lower limit of battery charge fraction to ensure proper operation."; +static constexpr const char *unitMetricHwBatteryChargeLimit = "1"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwBatteryChargeLimit( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwBatteryChargeLimit, descrMetricHwBatteryChargeLimit, + unitMetricHwBatteryChargeLimit); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwBatteryChargeLimit( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwBatteryChargeLimit, descrMetricHwBatteryChargeLimit, + unitMetricHwBatteryChargeLimit); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwBatteryChargeLimit(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge( + kMetricHwBatteryChargeLimit, descrMetricHwBatteryChargeLimit, unitMetricHwBatteryChargeLimit); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwBatteryChargeLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge( + kMetricHwBatteryChargeLimit, descrMetricHwBatteryChargeLimit, unitMetricHwBatteryChargeLimit); +} + +/** + Time left before battery is completely charged or discharged. +

+ gauge + */ +static constexpr const char *kMetricHwBatteryTimeLeft = "hw.battery.time_left"; +static constexpr const char *descrMetricHwBatteryTimeLeft = + "Time left before battery is completely charged or discharged."; +static constexpr const char *unitMetricHwBatteryTimeLeft = "s"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwBatteryTimeLeft( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwBatteryTimeLeft, descrMetricHwBatteryTimeLeft, + unitMetricHwBatteryTimeLeft); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwBatteryTimeLeft( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwBatteryTimeLeft, descrMetricHwBatteryTimeLeft, + unitMetricHwBatteryTimeLeft); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwBatteryTimeLeft(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricHwBatteryTimeLeft, descrMetricHwBatteryTimeLeft, + unitMetricHwBatteryTimeLeft); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwBatteryTimeLeft(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricHwBatteryTimeLeft, descrMetricHwBatteryTimeLeft, + unitMetricHwBatteryTimeLeft); +} + +/** + CPU current frequency. +

+ gauge + */ +static constexpr const char *kMetricHwCpuSpeed = "hw.cpu.speed"; +static constexpr const char *descrMetricHwCpuSpeed = "CPU current frequency."; +static constexpr const char *unitMetricHwCpuSpeed = "Hz"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwCpuSpeed( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwCpuSpeed, descrMetricHwCpuSpeed, unitMetricHwCpuSpeed); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwCpuSpeed( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwCpuSpeed, descrMetricHwCpuSpeed, unitMetricHwCpuSpeed); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr CreateAsyncInt64MetricHwCpuSpeed( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricHwCpuSpeed, descrMetricHwCpuSpeed, + unitMetricHwCpuSpeed); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricHwCpuSpeed( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricHwCpuSpeed, descrMetricHwCpuSpeed, + unitMetricHwCpuSpeed); +} + +/** + CPU maximum frequency. +

+ gauge + */ +static constexpr const char *kMetricHwCpuSpeedLimit = "hw.cpu.speed.limit"; +static constexpr const char *descrMetricHwCpuSpeedLimit = "CPU maximum frequency."; +static constexpr const char *unitMetricHwCpuSpeedLimit = "Hz"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwCpuSpeedLimit( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwCpuSpeedLimit, descrMetricHwCpuSpeedLimit, + unitMetricHwCpuSpeedLimit); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwCpuSpeedLimit( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwCpuSpeedLimit, descrMetricHwCpuSpeedLimit, + unitMetricHwCpuSpeedLimit); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwCpuSpeedLimit(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricHwCpuSpeedLimit, descrMetricHwCpuSpeedLimit, + unitMetricHwCpuSpeedLimit); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwCpuSpeedLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricHwCpuSpeedLimit, descrMetricHwCpuSpeedLimit, + unitMetricHwCpuSpeedLimit); +} + +/** + Energy consumed by the component.

counter */ static constexpr const char *kMetricHwEnergy = "hw.energy"; -static constexpr const char *descrMetricHwEnergy = "Energy consumed by the component"; +static constexpr const char *descrMetricHwEnergy = "Energy consumed by the component."; static constexpr const char *unitMetricHwEnergy = "J"; static inline nostd::unique_ptr> CreateSyncInt64MetricHwEnergy( @@ -56,12 +256,12 @@ static inline nostd::shared_ptr CreateAsyncDouble } /** - Number of errors encountered by the component + Number of errors encountered by the component.

counter */ static constexpr const char *kMetricHwErrors = "hw.errors"; -static constexpr const char *descrMetricHwErrors = "Number of errors encountered by the component"; +static constexpr const char *descrMetricHwErrors = "Number of errors encountered by the component."; static constexpr const char *unitMetricHwErrors = "{error}"; static inline nostd::unique_ptr> CreateSyncInt64MetricHwErrors( @@ -91,237 +291,1148 @@ static inline nostd::shared_ptr CreateAsyncDouble } /** - Ambient (external) temperature of the physical host + Fan speed in revolutions per minute.

gauge */ -static constexpr const char *kMetricHwHostAmbientTemperature = "hw.host.ambient_temperature"; -static constexpr const char *descrMetricHwHostAmbientTemperature = - "Ambient (external) temperature of the physical host"; -static constexpr const char *unitMetricHwHostAmbientTemperature = "Cel"; +static constexpr const char *kMetricHwFanSpeed = "hw.fan.speed"; +static constexpr const char *descrMetricHwFanSpeed = "Fan speed in revolutions per minute."; +static constexpr const char *unitMetricHwFanSpeed = "rpm"; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 -static inline nostd::unique_ptr> -CreateSyncInt64MetricHwHostAmbientTemperature(metrics::Meter *meter) +static inline nostd::unique_ptr> CreateSyncInt64MetricHwFanSpeed( + metrics::Meter *meter) { - return meter->CreateInt64Gauge(kMetricHwHostAmbientTemperature, - descrMetricHwHostAmbientTemperature, - unitMetricHwHostAmbientTemperature); + return meter->CreateInt64Gauge(kMetricHwFanSpeed, descrMetricHwFanSpeed, unitMetricHwFanSpeed); } -static inline nostd::unique_ptr> -CreateSyncDoubleMetricHwHostAmbientTemperature(metrics::Meter *meter) +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwFanSpeed( + metrics::Meter *meter) { - return meter->CreateDoubleGauge(kMetricHwHostAmbientTemperature, - descrMetricHwHostAmbientTemperature, - unitMetricHwHostAmbientTemperature); + return meter->CreateDoubleGauge(kMetricHwFanSpeed, descrMetricHwFanSpeed, unitMetricHwFanSpeed); } #endif /* OPENTELEMETRY_ABI_VERSION_NO */ -static inline nostd::shared_ptr -CreateAsyncInt64MetricHwHostAmbientTemperature(metrics::Meter *meter) +static inline nostd::shared_ptr CreateAsyncInt64MetricHwFanSpeed( + metrics::Meter *meter) { - return meter->CreateInt64ObservableGauge(kMetricHwHostAmbientTemperature, - descrMetricHwHostAmbientTemperature, - unitMetricHwHostAmbientTemperature); + return meter->CreateInt64ObservableGauge(kMetricHwFanSpeed, descrMetricHwFanSpeed, + unitMetricHwFanSpeed); } -static inline nostd::shared_ptr -CreateAsyncDoubleMetricHwHostAmbientTemperature(metrics::Meter *meter) +static inline nostd::shared_ptr CreateAsyncDoubleMetricHwFanSpeed( + metrics::Meter *meter) { - return meter->CreateDoubleObservableGauge(kMetricHwHostAmbientTemperature, - descrMetricHwHostAmbientTemperature, - unitMetricHwHostAmbientTemperature); + return meter->CreateDoubleObservableGauge(kMetricHwFanSpeed, descrMetricHwFanSpeed, + unitMetricHwFanSpeed); } /** - Total energy consumed by the entire physical host, in joules + Speed limit in rpm.

- The overall energy usage of a host MUST be reported using the specific @code hw.host.energy - @endcode and @code hw.host.power @endcode metrics only, instead of the generic - @code hw.energy @endcode and @code hw.power @endcode described in the previous section, to prevent - summing up overlapping values.

counter + gauge */ -static constexpr const char *kMetricHwHostEnergy = "hw.host.energy"; -static constexpr const char *descrMetricHwHostEnergy = - "Total energy consumed by the entire physical host, in joules"; -static constexpr const char *unitMetricHwHostEnergy = "J"; +static constexpr const char *kMetricHwFanSpeedLimit = "hw.fan.speed.limit"; +static constexpr const char *descrMetricHwFanSpeedLimit = "Speed limit in rpm."; +static constexpr const char *unitMetricHwFanSpeedLimit = "rpm"; -static inline nostd::unique_ptr> CreateSyncInt64MetricHwHostEnergy( +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwFanSpeedLimit( metrics::Meter *meter) { - return meter->CreateUInt64Counter(kMetricHwHostEnergy, descrMetricHwHostEnergy, - unitMetricHwHostEnergy); + return meter->CreateInt64Gauge(kMetricHwFanSpeedLimit, descrMetricHwFanSpeedLimit, + unitMetricHwFanSpeedLimit); } -static inline nostd::unique_ptr> CreateSyncDoubleMetricHwHostEnergy( +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwFanSpeedLimit( metrics::Meter *meter) { - return meter->CreateDoubleCounter(kMetricHwHostEnergy, descrMetricHwHostEnergy, - unitMetricHwHostEnergy); + return meter->CreateDoubleGauge(kMetricHwFanSpeedLimit, descrMetricHwFanSpeedLimit, + unitMetricHwFanSpeedLimit); } +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ -static inline nostd::shared_ptr CreateAsyncInt64MetricHwHostEnergy( - metrics::Meter *meter) +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwFanSpeedLimit(metrics::Meter *meter) { - return meter->CreateInt64ObservableCounter(kMetricHwHostEnergy, descrMetricHwHostEnergy, - unitMetricHwHostEnergy); + return meter->CreateInt64ObservableGauge(kMetricHwFanSpeedLimit, descrMetricHwFanSpeedLimit, + unitMetricHwFanSpeedLimit); } -static inline nostd::shared_ptr CreateAsyncDoubleMetricHwHostEnergy( - metrics::Meter *meter) +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwFanSpeedLimit(metrics::Meter *meter) { - return meter->CreateDoubleObservableCounter(kMetricHwHostEnergy, descrMetricHwHostEnergy, - unitMetricHwHostEnergy); + return meter->CreateDoubleObservableGauge(kMetricHwFanSpeedLimit, descrMetricHwFanSpeedLimit, + unitMetricHwFanSpeedLimit); } /** - By how many degrees Celsius the temperature of the physical host can be increased, before reaching - a warning threshold on one of the internal sensors

gauge + Fan speed expressed as a fraction of its maximum speed. +

+ gauge */ -static constexpr const char *kMetricHwHostHeatingMargin = "hw.host.heating_margin"; -static constexpr const char *descrMetricHwHostHeatingMargin = - "By how many degrees Celsius the temperature of the physical host can be increased, before reaching a warning threshold on one of the internal sensors - "; - static constexpr const char *unitMetricHwHostHeatingMargin = "Cel"; +static constexpr const char *kMetricHwFanSpeedRatio = "hw.fan.speed_ratio"; +static constexpr const char *descrMetricHwFanSpeedRatio = + "Fan speed expressed as a fraction of its maximum speed."; +static constexpr const char *unitMetricHwFanSpeedRatio = "1"; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 -static inline nostd::unique_ptr> CreateSyncInt64MetricHwHostHeatingMargin( +static inline nostd::unique_ptr> CreateSyncInt64MetricHwFanSpeedRatio( metrics::Meter *meter) { - return meter->CreateInt64Gauge(kMetricHwHostHeatingMargin, descrMetricHwHostHeatingMargin, - unitMetricHwHostHeatingMargin); + return meter->CreateInt64Gauge(kMetricHwFanSpeedRatio, descrMetricHwFanSpeedRatio, + unitMetricHwFanSpeedRatio); } -static inline nostd::unique_ptr> CreateSyncDoubleMetricHwHostHeatingMargin( +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwFanSpeedRatio( metrics::Meter *meter) { - return meter->CreateDoubleGauge(kMetricHwHostHeatingMargin, descrMetricHwHostHeatingMargin, - unitMetricHwHostHeatingMargin); + return meter->CreateDoubleGauge(kMetricHwFanSpeedRatio, descrMetricHwFanSpeedRatio, + unitMetricHwFanSpeedRatio); } #endif /* OPENTELEMETRY_ABI_VERSION_NO */ static inline nostd::shared_ptr -CreateAsyncInt64MetricHwHostHeatingMargin(metrics::Meter *meter) +CreateAsyncInt64MetricHwFanSpeedRatio(metrics::Meter *meter) { - return meter->CreateInt64ObservableGauge( - kMetricHwHostHeatingMargin, descrMetricHwHostHeatingMargin, unitMetricHwHostHeatingMargin); + return meter->CreateInt64ObservableGauge(kMetricHwFanSpeedRatio, descrMetricHwFanSpeedRatio, + unitMetricHwFanSpeedRatio); } static inline nostd::shared_ptr -CreateAsyncDoubleMetricHwHostHeatingMargin(metrics::Meter *meter) +CreateAsyncDoubleMetricHwFanSpeedRatio(metrics::Meter *meter) { - return meter->CreateDoubleObservableGauge( - kMetricHwHostHeatingMargin, descrMetricHwHostHeatingMargin, unitMetricHwHostHeatingMargin); + return meter->CreateDoubleObservableGauge(kMetricHwFanSpeedRatio, descrMetricHwFanSpeedRatio, + unitMetricHwFanSpeedRatio); } /** - Instantaneous power consumed by the entire physical host in Watts (@code hw.host.energy @endcode - is preferred)

The overall energy usage of a host MUST be reported using the specific @code - hw.host.energy @endcode and @code hw.host.power @endcode metrics only, instead of - the generic @code hw.energy @endcode and @code hw.power @endcode described in the previous - section, to prevent summing up overlapping values.

gauge + Received and transmitted bytes by the GPU. +

+ counter */ -static constexpr const char *kMetricHwHostPower = "hw.host.power"; -static constexpr const char *descrMetricHwHostPower = - "Instantaneous power consumed by the entire physical host in Watts (`hw.host.energy` is preferred) - "; - static constexpr const char *unitMetricHwHostPower = "W"; - -#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +static constexpr const char *kMetricHwGpuIo = "hw.gpu.io"; +static constexpr const char *descrMetricHwGpuIo = "Received and transmitted bytes by the GPU."; +static constexpr const char *unitMetricHwGpuIo = "By"; -static inline nostd::unique_ptr> CreateSyncInt64MetricHwHostPower( +static inline nostd::unique_ptr> CreateSyncInt64MetricHwGpuIo( metrics::Meter *meter) { - return meter->CreateInt64Gauge(kMetricHwHostPower, descrMetricHwHostPower, unitMetricHwHostPower); + return meter->CreateUInt64Counter(kMetricHwGpuIo, descrMetricHwGpuIo, unitMetricHwGpuIo); } -static inline nostd::unique_ptr> CreateSyncDoubleMetricHwHostPower( +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwGpuIo( metrics::Meter *meter) { - return meter->CreateDoubleGauge(kMetricHwHostPower, descrMetricHwHostPower, - unitMetricHwHostPower); + return meter->CreateDoubleCounter(kMetricHwGpuIo, descrMetricHwGpuIo, unitMetricHwGpuIo); } -#endif /* OPENTELEMETRY_ABI_VERSION_NO */ -static inline nostd::shared_ptr CreateAsyncInt64MetricHwHostPower( +static inline nostd::shared_ptr CreateAsyncInt64MetricHwGpuIo( metrics::Meter *meter) { - return meter->CreateInt64ObservableGauge(kMetricHwHostPower, descrMetricHwHostPower, - unitMetricHwHostPower); + return meter->CreateInt64ObservableCounter(kMetricHwGpuIo, descrMetricHwGpuIo, unitMetricHwGpuIo); } -static inline nostd::shared_ptr CreateAsyncDoubleMetricHwHostPower( +static inline nostd::shared_ptr CreateAsyncDoubleMetricHwGpuIo( metrics::Meter *meter) { - return meter->CreateDoubleObservableGauge(kMetricHwHostPower, descrMetricHwHostPower, - unitMetricHwHostPower); + return meter->CreateDoubleObservableCounter(kMetricHwGpuIo, descrMetricHwGpuIo, + unitMetricHwGpuIo); } /** - Instantaneous power consumed by the component + Size of the GPU memory.

- It is recommended to report @code hw.energy @endcode instead of @code hw.power @endcode when - possible.

gauge + updowncounter */ -static constexpr const char *kMetricHwPower = "hw.power"; -static constexpr const char *descrMetricHwPower = "Instantaneous power consumed by the component"; -static constexpr const char *unitMetricHwPower = "W"; +static constexpr const char *kMetricHwGpuMemoryLimit = "hw.gpu.memory.limit"; +static constexpr const char *descrMetricHwGpuMemoryLimit = "Size of the GPU memory."; +static constexpr const char *unitMetricHwGpuMemoryLimit = "By"; -#if OPENTELEMETRY_ABI_VERSION_NO >= 2 - -static inline nostd::unique_ptr> CreateSyncInt64MetricHwPower( - metrics::Meter *meter) +static inline nostd::unique_ptr> +CreateSyncInt64MetricHwGpuMemoryLimit(metrics::Meter *meter) { - return meter->CreateInt64Gauge(kMetricHwPower, descrMetricHwPower, unitMetricHwPower); + return meter->CreateInt64UpDownCounter(kMetricHwGpuMemoryLimit, descrMetricHwGpuMemoryLimit, + unitMetricHwGpuMemoryLimit); } -static inline nostd::unique_ptr> CreateSyncDoubleMetricHwPower( - metrics::Meter *meter) +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHwGpuMemoryLimit(metrics::Meter *meter) { - return meter->CreateDoubleGauge(kMetricHwPower, descrMetricHwPower, unitMetricHwPower); + return meter->CreateDoubleUpDownCounter(kMetricHwGpuMemoryLimit, descrMetricHwGpuMemoryLimit, + unitMetricHwGpuMemoryLimit); } -#endif /* OPENTELEMETRY_ABI_VERSION_NO */ -static inline nostd::shared_ptr CreateAsyncInt64MetricHwPower( - metrics::Meter *meter) +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwGpuMemoryLimit(metrics::Meter *meter) { - return meter->CreateInt64ObservableGauge(kMetricHwPower, descrMetricHwPower, unitMetricHwPower); + return meter->CreateInt64ObservableUpDownCounter( + kMetricHwGpuMemoryLimit, descrMetricHwGpuMemoryLimit, unitMetricHwGpuMemoryLimit); } -static inline nostd::shared_ptr CreateAsyncDoubleMetricHwPower( - metrics::Meter *meter) +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwGpuMemoryLimit(metrics::Meter *meter) { - return meter->CreateDoubleObservableGauge(kMetricHwPower, descrMetricHwPower, unitMetricHwPower); + return meter->CreateDoubleObservableUpDownCounter( + kMetricHwGpuMemoryLimit, descrMetricHwGpuMemoryLimit, unitMetricHwGpuMemoryLimit); } /** - Operational status: @code 1 @endcode (true) or @code 0 @endcode (false) for each of the possible - states

- @code hw.status @endcode is currently specified as an UpDownCounter but would ideally be - represented using a StateSet - as defined in OpenMetrics. This semantic convention will be updated once StateSet is - specified in OpenTelemetry. This planned change is not expected to have any consequence on the way - users query their timeseries backend to retrieve the values of @code hw.status @endcode over time. + GPU memory used.

updowncounter */ -static constexpr const char *kMetricHwStatus = "hw.status"; -static constexpr const char *descrMetricHwStatus = - "Operational status: `1` (true) or `0` (false) for each of the possible states"; -static constexpr const char *unitMetricHwStatus = "1"; +static constexpr const char *kMetricHwGpuMemoryUsage = "hw.gpu.memory.usage"; +static constexpr const char *descrMetricHwGpuMemoryUsage = "GPU memory used."; +static constexpr const char *unitMetricHwGpuMemoryUsage = "By"; -static inline nostd::unique_ptr> CreateSyncInt64MetricHwStatus( - metrics::Meter *meter) +static inline nostd::unique_ptr> +CreateSyncInt64MetricHwGpuMemoryUsage(metrics::Meter *meter) { - return meter->CreateInt64UpDownCounter(kMetricHwStatus, descrMetricHwStatus, unitMetricHwStatus); + return meter->CreateInt64UpDownCounter(kMetricHwGpuMemoryUsage, descrMetricHwGpuMemoryUsage, + unitMetricHwGpuMemoryUsage); } -static inline nostd::unique_ptr> CreateSyncDoubleMetricHwStatus( - metrics::Meter *meter) +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHwGpuMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricHwGpuMemoryUsage, descrMetricHwGpuMemoryUsage, + unitMetricHwGpuMemoryUsage); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwGpuMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricHwGpuMemoryUsage, descrMetricHwGpuMemoryUsage, unitMetricHwGpuMemoryUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwGpuMemoryUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricHwGpuMemoryUsage, descrMetricHwGpuMemoryUsage, unitMetricHwGpuMemoryUsage); +} + +/** + Fraction of GPU memory used. +

+ gauge + */ +static constexpr const char *kMetricHwGpuMemoryUtilization = "hw.gpu.memory.utilization"; +static constexpr const char *descrMetricHwGpuMemoryUtilization = "Fraction of GPU memory used."; +static constexpr const char *unitMetricHwGpuMemoryUtilization = "1"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHwGpuMemoryUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwGpuMemoryUtilization, descrMetricHwGpuMemoryUtilization, + unitMetricHwGpuMemoryUtilization); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHwGpuMemoryUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwGpuMemoryUtilization, descrMetricHwGpuMemoryUtilization, + unitMetricHwGpuMemoryUtilization); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwGpuMemoryUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricHwGpuMemoryUtilization, + descrMetricHwGpuMemoryUtilization, + unitMetricHwGpuMemoryUtilization); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwGpuMemoryUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricHwGpuMemoryUtilization, + descrMetricHwGpuMemoryUtilization, + unitMetricHwGpuMemoryUtilization); +} + +/** + Fraction of time spent in a specific task. +

+ gauge + */ +static constexpr const char *kMetricHwGpuUtilization = "hw.gpu.utilization"; +static constexpr const char *descrMetricHwGpuUtilization = + "Fraction of time spent in a specific task."; +static constexpr const char *unitMetricHwGpuUtilization = "1"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwGpuUtilization( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwGpuUtilization, descrMetricHwGpuUtilization, + unitMetricHwGpuUtilization); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwGpuUtilization( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwGpuUtilization, descrMetricHwGpuUtilization, + unitMetricHwGpuUtilization); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwGpuUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricHwGpuUtilization, descrMetricHwGpuUtilization, + unitMetricHwGpuUtilization); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwGpuUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricHwGpuUtilization, descrMetricHwGpuUtilization, + unitMetricHwGpuUtilization); +} + +/** + Ambient (external) temperature of the physical host. +

+ gauge + */ +static constexpr const char *kMetricHwHostAmbientTemperature = "hw.host.ambient_temperature"; +static constexpr const char *descrMetricHwHostAmbientTemperature = + "Ambient (external) temperature of the physical host."; +static constexpr const char *unitMetricHwHostAmbientTemperature = "Cel"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHwHostAmbientTemperature(metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwHostAmbientTemperature, + descrMetricHwHostAmbientTemperature, + unitMetricHwHostAmbientTemperature); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHwHostAmbientTemperature(metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwHostAmbientTemperature, + descrMetricHwHostAmbientTemperature, + unitMetricHwHostAmbientTemperature); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwHostAmbientTemperature(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricHwHostAmbientTemperature, + descrMetricHwHostAmbientTemperature, + unitMetricHwHostAmbientTemperature); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwHostAmbientTemperature(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricHwHostAmbientTemperature, + descrMetricHwHostAmbientTemperature, + unitMetricHwHostAmbientTemperature); +} + +/** + Total energy consumed by the entire physical host, in joules. +

+ The overall energy usage of a host MUST be reported using the specific @code hw.host.energy + @endcode and @code hw.host.power @endcode metrics only, instead of the generic + @code hw.energy @endcode and @code hw.power @endcode described in the previous section, to prevent + summing up overlapping values.

counter + */ +static constexpr const char *kMetricHwHostEnergy = "hw.host.energy"; +static constexpr const char *descrMetricHwHostEnergy = + "Total energy consumed by the entire physical host, in joules."; +static constexpr const char *unitMetricHwHostEnergy = "J"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwHostEnergy( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricHwHostEnergy, descrMetricHwHostEnergy, + unitMetricHwHostEnergy); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwHostEnergy( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricHwHostEnergy, descrMetricHwHostEnergy, + unitMetricHwHostEnergy); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricHwHostEnergy( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricHwHostEnergy, descrMetricHwHostEnergy, + unitMetricHwHostEnergy); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricHwHostEnergy( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricHwHostEnergy, descrMetricHwHostEnergy, + unitMetricHwHostEnergy); +} + +/** + By how many degrees Celsius the temperature of the physical host can be increased, before reaching + a warning threshold on one of the internal sensors.

gauge + */ +static constexpr const char *kMetricHwHostHeatingMargin = "hw.host.heating_margin"; +static constexpr const char *descrMetricHwHostHeatingMargin = + "By how many degrees Celsius the temperature of the physical host can be increased, before reaching a warning threshold on one of the internal sensors. + "; + static constexpr const char *unitMetricHwHostHeatingMargin = "Cel"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwHostHeatingMargin( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwHostHeatingMargin, descrMetricHwHostHeatingMargin, + unitMetricHwHostHeatingMargin); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwHostHeatingMargin( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwHostHeatingMargin, descrMetricHwHostHeatingMargin, + unitMetricHwHostHeatingMargin); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwHostHeatingMargin(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge( + kMetricHwHostHeatingMargin, descrMetricHwHostHeatingMargin, unitMetricHwHostHeatingMargin); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwHostHeatingMargin(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge( + kMetricHwHostHeatingMargin, descrMetricHwHostHeatingMargin, unitMetricHwHostHeatingMargin); +} + +/** + Instantaneous power consumed by the entire physical host in Watts (@code hw.host.energy @endcode + is preferred).

The overall energy usage of a host MUST be reported using the specific @code + hw.host.energy @endcode and @code hw.host.power @endcode metrics only, instead of + the generic @code hw.energy @endcode and @code hw.power @endcode described in the previous + section, to prevent summing up overlapping values.

gauge + */ +static constexpr const char *kMetricHwHostPower = "hw.host.power"; +static constexpr const char *descrMetricHwHostPower = + "Instantaneous power consumed by the entire physical host in Watts (`hw.host.energy` is preferred). + "; + static constexpr const char *unitMetricHwHostPower = "W"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwHostPower( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwHostPower, descrMetricHwHostPower, unitMetricHwHostPower); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwHostPower( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwHostPower, descrMetricHwHostPower, + unitMetricHwHostPower); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr CreateAsyncInt64MetricHwHostPower( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricHwHostPower, descrMetricHwHostPower, + unitMetricHwHostPower); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricHwHostPower( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricHwHostPower, descrMetricHwHostPower, + unitMetricHwHostPower); +} + +/** + Size of the logical disk. +

+ updowncounter + */ +static constexpr const char *kMetricHwLogicalDiskLimit = "hw.logical_disk.limit"; +static constexpr const char *descrMetricHwLogicalDiskLimit = "Size of the logical disk."; +static constexpr const char *unitMetricHwLogicalDiskLimit = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHwLogicalDiskLimit(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricHwLogicalDiskLimit, descrMetricHwLogicalDiskLimit, + unitMetricHwLogicalDiskLimit); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHwLogicalDiskLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricHwLogicalDiskLimit, descrMetricHwLogicalDiskLimit, + unitMetricHwLogicalDiskLimit); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwLogicalDiskLimit(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricHwLogicalDiskLimit, descrMetricHwLogicalDiskLimit, unitMetricHwLogicalDiskLimit); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwLogicalDiskLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricHwLogicalDiskLimit, descrMetricHwLogicalDiskLimit, unitMetricHwLogicalDiskLimit); +} + +/** + Logical disk space usage. +

+ updowncounter + */ +static constexpr const char *kMetricHwLogicalDiskUsage = "hw.logical_disk.usage"; +static constexpr const char *descrMetricHwLogicalDiskUsage = "Logical disk space usage."; +static constexpr const char *unitMetricHwLogicalDiskUsage = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHwLogicalDiskUsage(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricHwLogicalDiskUsage, descrMetricHwLogicalDiskUsage, + unitMetricHwLogicalDiskUsage); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHwLogicalDiskUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricHwLogicalDiskUsage, descrMetricHwLogicalDiskUsage, + unitMetricHwLogicalDiskUsage); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwLogicalDiskUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricHwLogicalDiskUsage, descrMetricHwLogicalDiskUsage, unitMetricHwLogicalDiskUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwLogicalDiskUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricHwLogicalDiskUsage, descrMetricHwLogicalDiskUsage, unitMetricHwLogicalDiskUsage); +} + +/** + Logical disk space utilization as a fraction. +

+ gauge + */ +static constexpr const char *kMetricHwLogicalDiskUtilization = "hw.logical_disk.utilization"; +static constexpr const char *descrMetricHwLogicalDiskUtilization = + "Logical disk space utilization as a fraction."; +static constexpr const char *unitMetricHwLogicalDiskUtilization = "1"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHwLogicalDiskUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwLogicalDiskUtilization, + descrMetricHwLogicalDiskUtilization, + unitMetricHwLogicalDiskUtilization); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHwLogicalDiskUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwLogicalDiskUtilization, + descrMetricHwLogicalDiskUtilization, + unitMetricHwLogicalDiskUtilization); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwLogicalDiskUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricHwLogicalDiskUtilization, + descrMetricHwLogicalDiskUtilization, + unitMetricHwLogicalDiskUtilization); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwLogicalDiskUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricHwLogicalDiskUtilization, + descrMetricHwLogicalDiskUtilization, + unitMetricHwLogicalDiskUtilization); +} + +/** + Size of the memory module. +

+ updowncounter + */ +static constexpr const char *kMetricHwMemorySize = "hw.memory.size"; +static constexpr const char *descrMetricHwMemorySize = "Size of the memory module."; +static constexpr const char *unitMetricHwMemorySize = "By"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwMemorySize( + metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricHwMemorySize, descrMetricHwMemorySize, + unitMetricHwMemorySize); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwMemorySize( + metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricHwMemorySize, descrMetricHwMemorySize, + unitMetricHwMemorySize); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricHwMemorySize( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricHwMemorySize, descrMetricHwMemorySize, + unitMetricHwMemorySize); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricHwMemorySize( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricHwMemorySize, descrMetricHwMemorySize, + unitMetricHwMemorySize); +} + +/** + Link speed. +

+ updowncounter + */ +static constexpr const char *kMetricHwNetworkBandwidthLimit = "hw.network.bandwidth.limit"; +static constexpr const char *descrMetricHwNetworkBandwidthLimit = "Link speed."; +static constexpr const char *unitMetricHwNetworkBandwidthLimit = "By/s"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHwNetworkBandwidthLimit(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricHwNetworkBandwidthLimit, + descrMetricHwNetworkBandwidthLimit, + unitMetricHwNetworkBandwidthLimit); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHwNetworkBandwidthLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricHwNetworkBandwidthLimit, + descrMetricHwNetworkBandwidthLimit, + unitMetricHwNetworkBandwidthLimit); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwNetworkBandwidthLimit(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricHwNetworkBandwidthLimit, + descrMetricHwNetworkBandwidthLimit, + unitMetricHwNetworkBandwidthLimit); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwNetworkBandwidthLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricHwNetworkBandwidthLimit, + descrMetricHwNetworkBandwidthLimit, + unitMetricHwNetworkBandwidthLimit); +} + +/** + Utilization of the network bandwidth as a fraction. +

+ gauge + */ +static constexpr const char *kMetricHwNetworkBandwidthUtilization = + "hw.network.bandwidth.utilization"; +static constexpr const char *descrMetricHwNetworkBandwidthUtilization = + "Utilization of the network bandwidth as a fraction."; +static constexpr const char *unitMetricHwNetworkBandwidthUtilization = "1"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHwNetworkBandwidthUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwNetworkBandwidthUtilization, + descrMetricHwNetworkBandwidthUtilization, + unitMetricHwNetworkBandwidthUtilization); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHwNetworkBandwidthUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwNetworkBandwidthUtilization, + descrMetricHwNetworkBandwidthUtilization, + unitMetricHwNetworkBandwidthUtilization); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwNetworkBandwidthUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricHwNetworkBandwidthUtilization, + descrMetricHwNetworkBandwidthUtilization, + unitMetricHwNetworkBandwidthUtilization); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwNetworkBandwidthUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricHwNetworkBandwidthUtilization, + descrMetricHwNetworkBandwidthUtilization, + unitMetricHwNetworkBandwidthUtilization); +} + +/** + Received and transmitted network traffic in bytes. +

+ counter + */ +static constexpr const char *kMetricHwNetworkIo = "hw.network.io"; +static constexpr const char *descrMetricHwNetworkIo = + "Received and transmitted network traffic in bytes."; +static constexpr const char *unitMetricHwNetworkIo = "By"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwNetworkIo( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricHwNetworkIo, descrMetricHwNetworkIo, + unitMetricHwNetworkIo); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwNetworkIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricHwNetworkIo, descrMetricHwNetworkIo, + unitMetricHwNetworkIo); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricHwNetworkIo( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricHwNetworkIo, descrMetricHwNetworkIo, + unitMetricHwNetworkIo); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricHwNetworkIo( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricHwNetworkIo, descrMetricHwNetworkIo, + unitMetricHwNetworkIo); +} + +/** + Received and transmitted network traffic in packets (or frames). +

+ counter + */ +static constexpr const char *kMetricHwNetworkPackets = "hw.network.packets"; +static constexpr const char *descrMetricHwNetworkPackets = + "Received and transmitted network traffic in packets (or frames)."; +static constexpr const char *unitMetricHwNetworkPackets = "{packet}"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwNetworkPackets( + metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricHwNetworkPackets, descrMetricHwNetworkPackets, + unitMetricHwNetworkPackets); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwNetworkPackets( + metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricHwNetworkPackets, descrMetricHwNetworkPackets, + unitMetricHwNetworkPackets); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwNetworkPackets(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricHwNetworkPackets, descrMetricHwNetworkPackets, + unitMetricHwNetworkPackets); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwNetworkPackets(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricHwNetworkPackets, descrMetricHwNetworkPackets, + unitMetricHwNetworkPackets); +} + +/** + Link status: @code 1 @endcode (up) or @code 0 @endcode (down). +

+ updowncounter + */ +static constexpr const char *kMetricHwNetworkUp = "hw.network.up"; +static constexpr const char *descrMetricHwNetworkUp = "Link status: `1` (up) or `0` (down)."; +static constexpr const char *unitMetricHwNetworkUp = "1"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwNetworkUp( + metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricHwNetworkUp, descrMetricHwNetworkUp, + unitMetricHwNetworkUp); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwNetworkUp( + metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricHwNetworkUp, descrMetricHwNetworkUp, + unitMetricHwNetworkUp); +} + +static inline nostd::shared_ptr CreateAsyncInt64MetricHwNetworkUp( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricHwNetworkUp, descrMetricHwNetworkUp, + unitMetricHwNetworkUp); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricHwNetworkUp( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricHwNetworkUp, descrMetricHwNetworkUp, + unitMetricHwNetworkUp); +} + +/** + Endurance remaining for this SSD disk. +

+ gauge + */ +static constexpr const char *kMetricHwPhysicalDiskEnduranceUtilization = + "hw.physical_disk.endurance_utilization"; +static constexpr const char *descrMetricHwPhysicalDiskEnduranceUtilization = + "Endurance remaining for this SSD disk."; +static constexpr const char *unitMetricHwPhysicalDiskEnduranceUtilization = "1"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHwPhysicalDiskEnduranceUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwPhysicalDiskEnduranceUtilization, + descrMetricHwPhysicalDiskEnduranceUtilization, + unitMetricHwPhysicalDiskEnduranceUtilization); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHwPhysicalDiskEnduranceUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwPhysicalDiskEnduranceUtilization, + descrMetricHwPhysicalDiskEnduranceUtilization, + unitMetricHwPhysicalDiskEnduranceUtilization); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwPhysicalDiskEnduranceUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricHwPhysicalDiskEnduranceUtilization, + descrMetricHwPhysicalDiskEnduranceUtilization, + unitMetricHwPhysicalDiskEnduranceUtilization); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwPhysicalDiskEnduranceUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricHwPhysicalDiskEnduranceUtilization, + descrMetricHwPhysicalDiskEnduranceUtilization, + unitMetricHwPhysicalDiskEnduranceUtilization); +} + +/** + Size of the disk. +

+ updowncounter + */ +static constexpr const char *kMetricHwPhysicalDiskSize = "hw.physical_disk.size"; +static constexpr const char *descrMetricHwPhysicalDiskSize = "Size of the disk."; +static constexpr const char *unitMetricHwPhysicalDiskSize = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHwPhysicalDiskSize(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricHwPhysicalDiskSize, descrMetricHwPhysicalDiskSize, + unitMetricHwPhysicalDiskSize); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHwPhysicalDiskSize(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricHwPhysicalDiskSize, descrMetricHwPhysicalDiskSize, + unitMetricHwPhysicalDiskSize); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwPhysicalDiskSize(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricHwPhysicalDiskSize, descrMetricHwPhysicalDiskSize, unitMetricHwPhysicalDiskSize); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwPhysicalDiskSize(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricHwPhysicalDiskSize, descrMetricHwPhysicalDiskSize, unitMetricHwPhysicalDiskSize); +} + +/** + Value of the corresponding S.M.A.R.T. + (Self-Monitoring, Analysis, and Reporting Technology) attribute.

gauge + */ +static constexpr const char *kMetricHwPhysicalDiskSmart = "hw.physical_disk.smart"; +static constexpr const char *descrMetricHwPhysicalDiskSmart = + "Value of the corresponding [S.M.A.R.T.](https://wikipedia.org/wiki/S.M.A.R.T.) " + "(Self-Monitoring, Analysis, and Reporting Technology) attribute."; +static constexpr const char *unitMetricHwPhysicalDiskSmart = "1"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwPhysicalDiskSmart( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwPhysicalDiskSmart, descrMetricHwPhysicalDiskSmart, + unitMetricHwPhysicalDiskSmart); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwPhysicalDiskSmart( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwPhysicalDiskSmart, descrMetricHwPhysicalDiskSmart, + unitMetricHwPhysicalDiskSmart); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwPhysicalDiskSmart(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge( + kMetricHwPhysicalDiskSmart, descrMetricHwPhysicalDiskSmart, unitMetricHwPhysicalDiskSmart); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwPhysicalDiskSmart(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge( + kMetricHwPhysicalDiskSmart, descrMetricHwPhysicalDiskSmart, unitMetricHwPhysicalDiskSmart); +} + +/** + Instantaneous power consumed by the component. +

+ It is recommended to report @code hw.energy @endcode instead of @code hw.power @endcode when + possible.

gauge + */ +static constexpr const char *kMetricHwPower = "hw.power"; +static constexpr const char *descrMetricHwPower = "Instantaneous power consumed by the component."; +static constexpr const char *unitMetricHwPower = "W"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwPower( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwPower, descrMetricHwPower, unitMetricHwPower); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwPower( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwPower, descrMetricHwPower, unitMetricHwPower); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr CreateAsyncInt64MetricHwPower( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricHwPower, descrMetricHwPower, unitMetricHwPower); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricHwPower( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricHwPower, descrMetricHwPower, unitMetricHwPower); +} + +/** + Maximum power output of the power supply. +

+ updowncounter + */ +static constexpr const char *kMetricHwPowerSupplyLimit = "hw.power_supply.limit"; +static constexpr const char *descrMetricHwPowerSupplyLimit = + "Maximum power output of the power supply."; +static constexpr const char *unitMetricHwPowerSupplyLimit = "W"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHwPowerSupplyLimit(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricHwPowerSupplyLimit, descrMetricHwPowerSupplyLimit, + unitMetricHwPowerSupplyLimit); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHwPowerSupplyLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricHwPowerSupplyLimit, descrMetricHwPowerSupplyLimit, + unitMetricHwPowerSupplyLimit); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwPowerSupplyLimit(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricHwPowerSupplyLimit, descrMetricHwPowerSupplyLimit, unitMetricHwPowerSupplyLimit); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwPowerSupplyLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricHwPowerSupplyLimit, descrMetricHwPowerSupplyLimit, unitMetricHwPowerSupplyLimit); +} + +/** + Current power output of the power supply. +

+ updowncounter + */ +static constexpr const char *kMetricHwPowerSupplyUsage = "hw.power_supply.usage"; +static constexpr const char *descrMetricHwPowerSupplyUsage = + "Current power output of the power supply."; +static constexpr const char *unitMetricHwPowerSupplyUsage = "W"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHwPowerSupplyUsage(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricHwPowerSupplyUsage, descrMetricHwPowerSupplyUsage, + unitMetricHwPowerSupplyUsage); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHwPowerSupplyUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricHwPowerSupplyUsage, descrMetricHwPowerSupplyUsage, + unitMetricHwPowerSupplyUsage); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwPowerSupplyUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricHwPowerSupplyUsage, descrMetricHwPowerSupplyUsage, unitMetricHwPowerSupplyUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwPowerSupplyUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricHwPowerSupplyUsage, descrMetricHwPowerSupplyUsage, unitMetricHwPowerSupplyUsage); +} + +/** + Utilization of the power supply as a fraction of its maximum output. +

+ gauge + */ +static constexpr const char *kMetricHwPowerSupplyUtilization = "hw.power_supply.utilization"; +static constexpr const char *descrMetricHwPowerSupplyUtilization = + "Utilization of the power supply as a fraction of its maximum output."; +static constexpr const char *unitMetricHwPowerSupplyUtilization = "1"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHwPowerSupplyUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwPowerSupplyUtilization, + descrMetricHwPowerSupplyUtilization, + unitMetricHwPowerSupplyUtilization); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHwPowerSupplyUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwPowerSupplyUtilization, + descrMetricHwPowerSupplyUtilization, + unitMetricHwPowerSupplyUtilization); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwPowerSupplyUtilization(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricHwPowerSupplyUtilization, + descrMetricHwPowerSupplyUtilization, + unitMetricHwPowerSupplyUtilization); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwPowerSupplyUtilization(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricHwPowerSupplyUtilization, + descrMetricHwPowerSupplyUtilization, + unitMetricHwPowerSupplyUtilization); +} + +/** + Operational status: @code 1 @endcode (true) or @code 0 @endcode (false) for each of the possible + states.

+ @code hw.status @endcode is currently specified as an UpDownCounter but would ideally be + represented using a StateSet + as defined in OpenMetrics. This semantic convention will be updated once StateSet is + specified in OpenTelemetry. This planned change is not expected to have any consequence on the way + users query their timeseries backend to retrieve the values of @code hw.status @endcode over time. +

+ updowncounter + */ +static constexpr const char *kMetricHwStatus = "hw.status"; +static constexpr const char *descrMetricHwStatus = + "Operational status: `1` (true) or `0` (false) for each of the possible states."; +static constexpr const char *unitMetricHwStatus = "1"; + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwStatus( + metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricHwStatus, descrMetricHwStatus, unitMetricHwStatus); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwStatus( + metrics::Meter *meter) { return meter->CreateDoubleUpDownCounter(kMetricHwStatus, descrMetricHwStatus, unitMetricHwStatus); } @@ -340,6 +1451,245 @@ static inline nostd::shared_ptr CreateAsyncDouble unitMetricHwStatus); } +/** + Operations performed by the tape drive. +

+ counter + */ +static constexpr const char *kMetricHwTapeDriveOperations = "hw.tape_drive.operations"; +static constexpr const char *descrMetricHwTapeDriveOperations = + "Operations performed by the tape drive."; +static constexpr const char *unitMetricHwTapeDriveOperations = "{operation}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricHwTapeDriveOperations(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricHwTapeDriveOperations, descrMetricHwTapeDriveOperations, + unitMetricHwTapeDriveOperations); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricHwTapeDriveOperations(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricHwTapeDriveOperations, descrMetricHwTapeDriveOperations, + unitMetricHwTapeDriveOperations); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwTapeDriveOperations(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricHwTapeDriveOperations, + descrMetricHwTapeDriveOperations, + unitMetricHwTapeDriveOperations); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwTapeDriveOperations(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricHwTapeDriveOperations, + descrMetricHwTapeDriveOperations, + unitMetricHwTapeDriveOperations); +} + +/** + Temperature in degrees Celsius. +

+ gauge + */ +static constexpr const char *kMetricHwTemperature = "hw.temperature"; +static constexpr const char *descrMetricHwTemperature = "Temperature in degrees Celsius."; +static constexpr const char *unitMetricHwTemperature = "Cel"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwTemperature( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwTemperature, descrMetricHwTemperature, + unitMetricHwTemperature); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwTemperature( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwTemperature, descrMetricHwTemperature, + unitMetricHwTemperature); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr CreateAsyncInt64MetricHwTemperature( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricHwTemperature, descrMetricHwTemperature, + unitMetricHwTemperature); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricHwTemperature( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricHwTemperature, descrMetricHwTemperature, + unitMetricHwTemperature); +} + +/** + Temperature limit in degrees Celsius. +

+ gauge + */ +static constexpr const char *kMetricHwTemperatureLimit = "hw.temperature.limit"; +static constexpr const char *descrMetricHwTemperatureLimit = + "Temperature limit in degrees Celsius."; +static constexpr const char *unitMetricHwTemperatureLimit = "Cel"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwTemperatureLimit( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwTemperatureLimit, descrMetricHwTemperatureLimit, + unitMetricHwTemperatureLimit); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwTemperatureLimit( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwTemperatureLimit, descrMetricHwTemperatureLimit, + unitMetricHwTemperatureLimit); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwTemperatureLimit(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricHwTemperatureLimit, descrMetricHwTemperatureLimit, + unitMetricHwTemperatureLimit); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwTemperatureLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge( + kMetricHwTemperatureLimit, descrMetricHwTemperatureLimit, unitMetricHwTemperatureLimit); +} + +/** + Voltage measured by the sensor. +

+ gauge + */ +static constexpr const char *kMetricHwVoltage = "hw.voltage"; +static constexpr const char *descrMetricHwVoltage = "Voltage measured by the sensor."; +static constexpr const char *unitMetricHwVoltage = "V"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwVoltage( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwVoltage, descrMetricHwVoltage, unitMetricHwVoltage); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwVoltage( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwVoltage, descrMetricHwVoltage, unitMetricHwVoltage); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr CreateAsyncInt64MetricHwVoltage( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricHwVoltage, descrMetricHwVoltage, + unitMetricHwVoltage); +} + +static inline nostd::shared_ptr CreateAsyncDoubleMetricHwVoltage( + metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricHwVoltage, descrMetricHwVoltage, + unitMetricHwVoltage); +} + +/** + Voltage limit in Volts. +

+ gauge + */ +static constexpr const char *kMetricHwVoltageLimit = "hw.voltage.limit"; +static constexpr const char *descrMetricHwVoltageLimit = "Voltage limit in Volts."; +static constexpr const char *unitMetricHwVoltageLimit = "V"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwVoltageLimit( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwVoltageLimit, descrMetricHwVoltageLimit, + unitMetricHwVoltageLimit); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwVoltageLimit( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwVoltageLimit, descrMetricHwVoltageLimit, + unitMetricHwVoltageLimit); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr CreateAsyncInt64MetricHwVoltageLimit( + metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricHwVoltageLimit, descrMetricHwVoltageLimit, + unitMetricHwVoltageLimit); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwVoltageLimit(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricHwVoltageLimit, descrMetricHwVoltageLimit, + unitMetricHwVoltageLimit); +} + +/** + Nominal (expected) voltage. +

+ gauge + */ +static constexpr const char *kMetricHwVoltageNominal = "hw.voltage.nominal"; +static constexpr const char *descrMetricHwVoltageNominal = "Nominal (expected) voltage."; +static constexpr const char *unitMetricHwVoltageNominal = "V"; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + +static inline nostd::unique_ptr> CreateSyncInt64MetricHwVoltageNominal( + metrics::Meter *meter) +{ + return meter->CreateInt64Gauge(kMetricHwVoltageNominal, descrMetricHwVoltageNominal, + unitMetricHwVoltageNominal); +} + +static inline nostd::unique_ptr> CreateSyncDoubleMetricHwVoltageNominal( + metrics::Meter *meter) +{ + return meter->CreateDoubleGauge(kMetricHwVoltageNominal, descrMetricHwVoltageNominal, + unitMetricHwVoltageNominal); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + +static inline nostd::shared_ptr +CreateAsyncInt64MetricHwVoltageNominal(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableGauge(kMetricHwVoltageNominal, descrMetricHwVoltageNominal, + unitMetricHwVoltageNominal); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricHwVoltageNominal(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableGauge(kMetricHwVoltageNominal, descrMetricHwVoltageNominal, + unitMetricHwVoltageNominal); +} + } // namespace hw } // namespace semconv OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/k8s_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/k8s_attributes.h index 29f08e7793f..80ef2a964ba 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/k8s_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/k8s_attributes.h @@ -595,19 +595,11 @@ static constexpr const char *kTerminating = "terminating"; namespace K8sNodeConditionStatusValues { -/** - none - */ + static constexpr const char *kConditionTrue = "true"; -/** - none - */ static constexpr const char *kConditionFalse = "false"; -/** - none - */ static constexpr const char *kConditionUnknown = "unknown"; } // namespace K8sNodeConditionStatusValues diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/k8s_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/k8s_metrics.h index d37bd12741d..678b24ff85d 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/k8s_metrics.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/k8s_metrics.h @@ -21,7 +21,7 @@ namespace k8s { /** - Maximum CPU resource limit set for the container + Maximum CPU resource limit set for the container.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core @@ -29,7 +29,7 @@ namespace k8s */ static constexpr const char *kMetricK8sContainerCpuLimit = "k8s.container.cpu.limit"; static constexpr const char *descrMetricK8sContainerCpuLimit = - "Maximum CPU resource limit set for the container"; + "Maximum CPU resource limit set for the container."; static constexpr const char *unitMetricK8sContainerCpuLimit = "{cpu}"; static inline nostd::unique_ptr> @@ -61,7 +61,7 @@ CreateAsyncDoubleMetricK8sContainerCpuLimit(metrics::Meter *meter) } /** - CPU resource requested for the container + CPU resource requested for the container.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core @@ -69,7 +69,7 @@ CreateAsyncDoubleMetricK8sContainerCpuLimit(metrics::Meter *meter) */ static constexpr const char *kMetricK8sContainerCpuRequest = "k8s.container.cpu.request"; static constexpr const char *descrMetricK8sContainerCpuRequest = - "CPU resource requested for the container"; + "CPU resource requested for the container."; static constexpr const char *unitMetricK8sContainerCpuRequest = "{cpu}"; static inline nostd::unique_ptr> @@ -105,7 +105,7 @@ CreateAsyncDoubleMetricK8sContainerCpuRequest(metrics::Meter *meter) } /** - Maximum ephemeral storage resource limit set for the container + Maximum ephemeral storage resource limit set for the container.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core @@ -114,7 +114,7 @@ CreateAsyncDoubleMetricK8sContainerCpuRequest(metrics::Meter *meter) static constexpr const char *kMetricK8sContainerEphemeralStorageLimit = "k8s.container.ephemeral_storage.limit"; static constexpr const char *descrMetricK8sContainerEphemeralStorageLimit = - "Maximum ephemeral storage resource limit set for the container"; + "Maximum ephemeral storage resource limit set for the container."; static constexpr const char *unitMetricK8sContainerEphemeralStorageLimit = "By"; static inline nostd::unique_ptr> @@ -150,7 +150,7 @@ CreateAsyncDoubleMetricK8sContainerEphemeralStorageLimit(metrics::Meter *meter) } /** - Ephemeral storage resource requested for the container + Ephemeral storage resource requested for the container.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core @@ -159,7 +159,7 @@ CreateAsyncDoubleMetricK8sContainerEphemeralStorageLimit(metrics::Meter *meter) static constexpr const char *kMetricK8sContainerEphemeralStorageRequest = "k8s.container.ephemeral_storage.request"; static constexpr const char *descrMetricK8sContainerEphemeralStorageRequest = - "Ephemeral storage resource requested for the container"; + "Ephemeral storage resource requested for the container."; static constexpr const char *unitMetricK8sContainerEphemeralStorageRequest = "By"; static inline nostd::unique_ptr> @@ -195,7 +195,7 @@ CreateAsyncDoubleMetricK8sContainerEphemeralStorageRequest(metrics::Meter *meter } /** - Maximum memory resource limit set for the container + Maximum memory resource limit set for the container.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core @@ -203,7 +203,7 @@ CreateAsyncDoubleMetricK8sContainerEphemeralStorageRequest(metrics::Meter *meter */ static constexpr const char *kMetricK8sContainerMemoryLimit = "k8s.container.memory.limit"; static constexpr const char *descrMetricK8sContainerMemoryLimit = - "Maximum memory resource limit set for the container"; + "Maximum memory resource limit set for the container."; static constexpr const char *unitMetricK8sContainerMemoryLimit = "By"; static inline nostd::unique_ptr> @@ -239,7 +239,7 @@ CreateAsyncDoubleMetricK8sContainerMemoryLimit(metrics::Meter *meter) } /** - Memory resource requested for the container + Memory resource requested for the container.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core @@ -247,7 +247,7 @@ CreateAsyncDoubleMetricK8sContainerMemoryLimit(metrics::Meter *meter) */ static constexpr const char *kMetricK8sContainerMemoryRequest = "k8s.container.memory.request"; static constexpr const char *descrMetricK8sContainerMemoryRequest = - "Memory resource requested for the container"; + "Memory resource requested for the container."; static constexpr const char *unitMetricK8sContainerMemoryRequest = "By"; static inline nostd::unique_ptr> @@ -284,14 +284,14 @@ CreateAsyncDoubleMetricK8sContainerMemoryRequest(metrics::Meter *meter) /** Indicates whether the container is currently marked as ready to accept traffic, based on its - readiness probe (1 = ready, 0 = not ready)

This metric SHOULD reflect the value of the @code + readiness probe (1 = ready, 0 = not ready).

This metric SHOULD reflect the value of the @code ready @endcode field in the K8s ContainerStatus.

updowncounter */ static constexpr const char *kMetricK8sContainerReady = "k8s.container.ready"; static constexpr const char *descrMetricK8sContainerReady = - "Indicates whether the container is currently marked as ready to accept traffic, based on its readiness probe (1 = ready, 0 = not ready) + "Indicates whether the container is currently marked as ready to accept traffic, based on its readiness probe (1 = ready, 0 = not ready). "; static constexpr const char *unitMetricK8sContainerReady = "{container}"; @@ -324,7 +324,7 @@ CreateAsyncDoubleMetricK8sContainerReady(metrics::Meter *meter) } /** - Describes how many times the container has restarted (since the last counter reset) + Describes how many times the container has restarted (since the last counter reset).

This value is pulled directly from the K8s API and the value can go indefinitely high and be reset to 0 at any time depending on how your kubelet is configured to prune dead containers. It is best @@ -335,7 +335,7 @@ CreateAsyncDoubleMetricK8sContainerReady(metrics::Meter *meter) */ static constexpr const char *kMetricK8sContainerRestartCount = "k8s.container.restart.count"; static constexpr const char *descrMetricK8sContainerRestartCount = - "Describes how many times the container has restarted (since the last counter reset)"; + "Describes how many times the container has restarted (since the last counter reset)."; static constexpr const char *unitMetricK8sContainerRestartCount = "{restart}"; static inline nostd::unique_ptr> @@ -371,7 +371,7 @@ CreateAsyncDoubleMetricK8sContainerRestartCount(metrics::Meter *meter) } /** - Describes the number of K8s containers that are currently in a state for a given reason + Describes the number of K8s containers that are currently in a state for a given reason.

All possible container state reasons will be reported at each time interval to avoid missing metrics. Only the value corresponding to the current state reason will be non-zero.

@@ -379,7 +379,7 @@ CreateAsyncDoubleMetricK8sContainerRestartCount(metrics::Meter *meter) */ static constexpr const char *kMetricK8sContainerStatusReason = "k8s.container.status.reason"; static constexpr const char *descrMetricK8sContainerStatusReason = - "Describes the number of K8s containers that are currently in a state for a given reason"; + "Describes the number of K8s containers that are currently in a state for a given reason."; static constexpr const char *unitMetricK8sContainerStatusReason = "{container}"; static inline nostd::unique_ptr> @@ -415,7 +415,7 @@ CreateAsyncDoubleMetricK8sContainerStatusReason(metrics::Meter *meter) } /** - Describes the number of K8s containers that are currently in a given state + Describes the number of K8s containers that are currently in a given state.

All possible container states will be reported at each time interval to avoid missing metrics. Only the value corresponding to the current state will be non-zero. @@ -424,7 +424,7 @@ CreateAsyncDoubleMetricK8sContainerStatusReason(metrics::Meter *meter) */ static constexpr const char *kMetricK8sContainerStatusState = "k8s.container.status.state"; static constexpr const char *descrMetricK8sContainerStatusState = - "Describes the number of K8s containers that are currently in a given state"; + "Describes the number of K8s containers that are currently in a given state."; static constexpr const char *unitMetricK8sContainerStatusState = "{container}"; static inline nostd::unique_ptr> @@ -460,7 +460,7 @@ CreateAsyncDoubleMetricK8sContainerStatusState(metrics::Meter *meter) } /** - Maximum storage resource limit set for the container + Maximum storage resource limit set for the container.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core @@ -468,7 +468,7 @@ CreateAsyncDoubleMetricK8sContainerStatusState(metrics::Meter *meter) */ static constexpr const char *kMetricK8sContainerStorageLimit = "k8s.container.storage.limit"; static constexpr const char *descrMetricK8sContainerStorageLimit = - "Maximum storage resource limit set for the container"; + "Maximum storage resource limit set for the container."; static constexpr const char *unitMetricK8sContainerStorageLimit = "By"; static inline nostd::unique_ptr> @@ -504,7 +504,7 @@ CreateAsyncDoubleMetricK8sContainerStorageLimit(metrics::Meter *meter) } /** - Storage resource requested for the container + Storage resource requested for the container.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core @@ -512,7 +512,7 @@ CreateAsyncDoubleMetricK8sContainerStorageLimit(metrics::Meter *meter) */ static constexpr const char *kMetricK8sContainerStorageRequest = "k8s.container.storage.request"; static constexpr const char *descrMetricK8sContainerStorageRequest = - "Storage resource requested for the container"; + "Storage resource requested for the container."; static constexpr const char *unitMetricK8sContainerStorageRequest = "By"; static inline nostd::unique_ptr> @@ -548,7 +548,7 @@ CreateAsyncDoubleMetricK8sContainerStorageRequest(metrics::Meter *meter) } /** - The number of actively running jobs for a cronjob + The number of actively running jobs for a cronjob.

This metric aligns with the @code active @endcode field of the > @@ -589,7 +589,7 @@ CreateAsyncDoubleMetricK8sCronjobActiveJobs(metrics::Meter *meter) } /** - Number of nodes that are running at least 1 daemon pod and are supposed to run the daemon pod + Number of nodes that are running at least 1 daemon pod and are supposed to run the daemon pod.

This metric aligns with the @code currentNumberScheduled @endcode field of the > @@ -636,7 +637,7 @@ CreateAsyncDoubleMetricK8sDaemonsetCurrentScheduledNodes(metrics::Meter *meter) /** Number of nodes that should be running the daemon pod (including nodes currently running the - daemon pod)

This metric aligns with the @code desiredNumberScheduled @endcode field of the This metric aligns with the @code desiredNumberScheduled @endcode field of the K8s DaemonSetStatus.

updowncounter */ @@ -644,7 +645,7 @@ static constexpr const char *kMetricK8sDaemonsetDesiredScheduledNodes = "k8s.daemonset.desired_scheduled_nodes"; static constexpr const char *descrMetricK8sDaemonsetDesiredScheduledNodes = "Number of nodes that should be running the daemon pod (including nodes currently running the " - "daemon pod)"; + "daemon pod)."; static constexpr const char *unitMetricK8sDaemonsetDesiredScheduledNodes = "{node}"; static inline nostd::unique_ptr> @@ -680,7 +681,7 @@ CreateAsyncDoubleMetricK8sDaemonsetDesiredScheduledNodes(metrics::Meter *meter) } /** - Number of nodes that are running the daemon pod, but are not supposed to run the daemon pod + Number of nodes that are running the daemon pod, but are not supposed to run the daemon pod.

This metric aligns with the @code numberMisscheduled @endcode field of the > @@ -727,14 +728,14 @@ CreateAsyncDoubleMetricK8sDaemonsetMisscheduledNodes(metrics::Meter *meter) /** Number of nodes that should be running the daemon pod and have one or more of the daemon pod - running and ready

This metric aligns with the @code numberReady @endcode field of the This metric aligns with the @code numberReady @endcode field of the K8s DaemonSetStatus.

updowncounter */ static constexpr const char *kMetricK8sDaemonsetReadyNodes = "k8s.daemonset.ready_nodes"; static constexpr const char *descrMetricK8sDaemonsetReadyNodes = "Number of nodes that should be running the daemon pod and have one or more of the daemon pod " - "running and ready"; + "running and ready."; static constexpr const char *unitMetricK8sDaemonsetReadyNodes = "{node}"; static inline nostd::unique_ptr> @@ -771,14 +772,14 @@ CreateAsyncDoubleMetricK8sDaemonsetReadyNodes(metrics::Meter *meter) /** Total number of available replica pods (ready for at least minReadySeconds) targeted by this - deployment

This metric aligns with the @code availableReplicas @endcode field of the This metric aligns with the @code availableReplicas @endcode field of the K8s DeploymentStatus.

updowncounter */ static constexpr const char *kMetricK8sDeploymentAvailablePods = "k8s.deployment.available_pods"; static constexpr const char *descrMetricK8sDeploymentAvailablePods = "Total number of available replica pods (ready for at least minReadySeconds) targeted by this " - "deployment"; + "deployment."; static constexpr const char *unitMetricK8sDeploymentAvailablePods = "{pod}"; static inline nostd::unique_ptr> @@ -814,7 +815,7 @@ CreateAsyncDoubleMetricK8sDeploymentAvailablePods(metrics::Meter *meter) } /** - Number of desired replica pods in this deployment + Number of desired replica pods in this deployment.

This metric aligns with the @code replicas @endcode field of the > @@ -860,14 +861,14 @@ CreateAsyncDoubleMetricK8sDeploymentDesiredPods(metrics::Meter *meter) /** Current number of replica pods managed by this horizontal pod autoscaler, as last seen by the - autoscaler

This metric aligns with the @code currentReplicas @endcode field of the This metric aligns with the @code currentReplicas @endcode field of the K8s HorizontalPodAutoscalerStatus

updowncounter */ static constexpr const char *kMetricK8sHpaCurrentPods = "k8s.hpa.current_pods"; static constexpr const char *descrMetricK8sHpaCurrentPods = "Current number of replica pods managed by this horizontal pod autoscaler, as last seen by the " - "autoscaler"; + "autoscaler."; static constexpr const char *unitMetricK8sHpaCurrentPods = "{pod}"; static inline nostd::unique_ptr> @@ -900,14 +901,14 @@ CreateAsyncDoubleMetricK8sHpaCurrentPods(metrics::Meter *meter) /** Desired number of replica pods managed by this horizontal pod autoscaler, as last calculated by - the autoscaler

This metric aligns with the @code desiredReplicas @endcode field of the This metric aligns with the @code desiredReplicas @endcode field of the K8s HorizontalPodAutoscalerStatus

updowncounter */ static constexpr const char *kMetricK8sHpaDesiredPods = "k8s.hpa.desired_pods"; static constexpr const char *descrMetricK8sHpaDesiredPods = "Desired number of replica pods managed by this horizontal pod autoscaler, as last calculated " - "by the autoscaler"; + "by the autoscaler."; static constexpr const char *unitMetricK8sHpaDesiredPods = "{pod}"; static inline nostd::unique_ptr> @@ -939,7 +940,7 @@ CreateAsyncDoubleMetricK8sHpaDesiredPods(metrics::Meter *meter) } /** - The upper limit for the number of replica pods to which the autoscaler can scale up + The upper limit for the number of replica pods to which the autoscaler can scale up.

This metric aligns with the @code maxReplicas @endcode field of the > CreateSyncInt64MetricK8sHpaMaxPods( @@ -1135,7 +1136,7 @@ CreateAsyncDoubleMetricK8sHpaMetricTargetCpuValue(metrics::Meter *meter) } /** - The lower limit for the number of replica pods to which the autoscaler can scale down + The lower limit for the number of replica pods to which the autoscaler can scale down.

This metric aligns with the @code minReplicas @endcode field of the > CreateSyncInt64MetricK8sHpaMinPods( @@ -1176,7 +1177,7 @@ static inline nostd::shared_ptr CreateAsyncDouble } /** - The number of pending and actively running pods for a job + The number of pending and actively running pods for a job.

This metric aligns with the @code active @endcode field of the CreateAsyncDouble */ static constexpr const char *kMetricK8sJobActivePods = "k8s.job.active_pods"; static constexpr const char *descrMetricK8sJobActivePods = - "The number of pending and actively running pods for a job"; + "The number of pending and actively running pods for a job."; static constexpr const char *unitMetricK8sJobActivePods = "{pod}"; static inline nostd::unique_ptr> @@ -1217,7 +1218,7 @@ CreateAsyncDoubleMetricK8sJobActivePods(metrics::Meter *meter) } /** - The desired number of successfully finished pods the job should be run with + The desired number of successfully finished pods the job should be run with.

This metric aligns with the @code completions @endcode field of the > @@ -1262,7 +1263,7 @@ CreateAsyncDoubleMetricK8sJobDesiredSuccessfulPods(metrics::Meter *meter) } /** - The number of pods which reached phase Failed for a job + The number of pods which reached phase Failed for a job.

This metric aligns with the @code failed @endcode field of the > @@ -1303,7 +1304,7 @@ CreateAsyncDoubleMetricK8sJobFailedPods(metrics::Meter *meter) } /** - The max desired number of pods the job should run at any given time + The max desired number of pods the job should run at any given time.

This metric aligns with the @code parallelism @endcode field of the > @@ -1348,7 +1349,7 @@ CreateAsyncDoubleMetricK8sJobMaxParallelPods(metrics::Meter *meter) } /** - The number of pods which reached phase Succeeded for a job + The number of pods which reached phase Succeeded for a job.

This metric aligns with the @code succeeded @endcode field of the > @@ -1427,13 +1428,13 @@ CreateAsyncDoubleMetricK8sNamespacePhase(metrics::Meter *meter) } /** - Amount of cpu allocatable on the node + Amount of cpu allocatable on the node.

updowncounter */ static constexpr const char *kMetricK8sNodeAllocatableCpu = "k8s.node.allocatable.cpu"; static constexpr const char *descrMetricK8sNodeAllocatableCpu = - "Amount of cpu allocatable on the node"; + "Amount of cpu allocatable on the node."; static constexpr const char *unitMetricK8sNodeAllocatableCpu = "{cpu}"; static inline nostd::unique_ptr> @@ -1469,14 +1470,14 @@ CreateAsyncDoubleMetricK8sNodeAllocatableCpu(metrics::Meter *meter) } /** - Amount of ephemeral-storage allocatable on the node + Amount of ephemeral-storage allocatable on the node.

updowncounter */ static constexpr const char *kMetricK8sNodeAllocatableEphemeralStorage = "k8s.node.allocatable.ephemeral_storage"; static constexpr const char *descrMetricK8sNodeAllocatableEphemeralStorage = - "Amount of ephemeral-storage allocatable on the node"; + "Amount of ephemeral-storage allocatable on the node."; static constexpr const char *unitMetricK8sNodeAllocatableEphemeralStorage = "By"; static inline nostd::unique_ptr> @@ -1512,13 +1513,13 @@ CreateAsyncDoubleMetricK8sNodeAllocatableEphemeralStorage(metrics::Meter *meter) } /** - Amount of memory allocatable on the node + Amount of memory allocatable on the node.

updowncounter */ static constexpr const char *kMetricK8sNodeAllocatableMemory = "k8s.node.allocatable.memory"; static constexpr const char *descrMetricK8sNodeAllocatableMemory = - "Amount of memory allocatable on the node"; + "Amount of memory allocatable on the node."; static constexpr const char *unitMetricK8sNodeAllocatableMemory = "By"; static inline nostd::unique_ptr> @@ -1554,13 +1555,13 @@ CreateAsyncDoubleMetricK8sNodeAllocatableMemory(metrics::Meter *meter) } /** - Amount of pods allocatable on the node + Amount of pods allocatable on the node.

updowncounter */ static constexpr const char *kMetricK8sNodeAllocatablePods = "k8s.node.allocatable.pods"; static constexpr const char *descrMetricK8sNodeAllocatablePods = - "Amount of pods allocatable on the node"; + "Amount of pods allocatable on the node."; static constexpr const char *unitMetricK8sNodeAllocatablePods = "{pod}"; static inline nostd::unique_ptr> @@ -1640,14 +1641,14 @@ CreateAsyncDoubleMetricK8sNodeConditionStatus(metrics::Meter *meter) } /** - Total CPU time consumed + Total CPU time consumed.

Total CPU time consumed by the specific Node on all available CPU cores

counter */ static constexpr const char *kMetricK8sNodeCpuTime = "k8s.node.cpu.time"; -static constexpr const char *descrMetricK8sNodeCpuTime = "Total CPU time consumed"; +static constexpr const char *descrMetricK8sNodeCpuTime = "Total CPU time consumed."; static constexpr const char *unitMetricK8sNodeCpuTime = "s"; static inline nostd::unique_ptr> CreateSyncInt64MetricK8sNodeCpuTime( @@ -1679,7 +1680,7 @@ CreateAsyncDoubleMetricK8sNodeCpuTime(metrics::Meter *meter) } /** - Node's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs + Node's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs.

CPU usage of the specific Node on all available CPU cores, averaged over the sample window

@@ -1687,7 +1688,7 @@ CreateAsyncDoubleMetricK8sNodeCpuTime(metrics::Meter *meter) */ static constexpr const char *kMetricK8sNodeCpuUsage = "k8s.node.cpu.usage"; static constexpr const char *descrMetricK8sNodeCpuUsage = - "Node's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs"; + "Node's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs."; static constexpr const char *unitMetricK8sNodeCpuUsage = "{cpu}"; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 @@ -1722,14 +1723,161 @@ CreateAsyncDoubleMetricK8sNodeCpuUsage(metrics::Meter *meter) } /** - Memory usage of the Node + Node filesystem available bytes. +

+ This metric is derived from the + FsStats.AvailableBytes + field of the NodeStats.Fs + of the Kubelet's stats API. +

+ updowncounter + */ +static constexpr const char *kMetricK8sNodeFilesystemAvailable = "k8s.node.filesystem.available"; +static constexpr const char *descrMetricK8sNodeFilesystemAvailable = + "Node filesystem available bytes."; +static constexpr const char *unitMetricK8sNodeFilesystemAvailable = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricK8sNodeFilesystemAvailable(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricK8sNodeFilesystemAvailable, + descrMetricK8sNodeFilesystemAvailable, + unitMetricK8sNodeFilesystemAvailable); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricK8sNodeFilesystemAvailable(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricK8sNodeFilesystemAvailable, + descrMetricK8sNodeFilesystemAvailable, + unitMetricK8sNodeFilesystemAvailable); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sNodeFilesystemAvailable(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricK8sNodeFilesystemAvailable, + descrMetricK8sNodeFilesystemAvailable, + unitMetricK8sNodeFilesystemAvailable); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sNodeFilesystemAvailable(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricK8sNodeFilesystemAvailable, + descrMetricK8sNodeFilesystemAvailable, + unitMetricK8sNodeFilesystemAvailable); +} + +/** + Node filesystem capacity. +

+ This metric is derived from the + FsStats.CapacityBytes + field of the NodeStats.Fs + of the Kubelet's stats API. +

+ updowncounter + */ +static constexpr const char *kMetricK8sNodeFilesystemCapacity = "k8s.node.filesystem.capacity"; +static constexpr const char *descrMetricK8sNodeFilesystemCapacity = "Node filesystem capacity."; +static constexpr const char *unitMetricK8sNodeFilesystemCapacity = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricK8sNodeFilesystemCapacity(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricK8sNodeFilesystemCapacity, + descrMetricK8sNodeFilesystemCapacity, + unitMetricK8sNodeFilesystemCapacity); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricK8sNodeFilesystemCapacity(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricK8sNodeFilesystemCapacity, + descrMetricK8sNodeFilesystemCapacity, + unitMetricK8sNodeFilesystemCapacity); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sNodeFilesystemCapacity(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricK8sNodeFilesystemCapacity, + descrMetricK8sNodeFilesystemCapacity, + unitMetricK8sNodeFilesystemCapacity); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sNodeFilesystemCapacity(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricK8sNodeFilesystemCapacity, + descrMetricK8sNodeFilesystemCapacity, + unitMetricK8sNodeFilesystemCapacity); +} + +/** + Node filesystem usage. +

+ This may not equal capacity - available. +

+ This metric is derived from the + FsStats.UsedBytes + field of the NodeStats.Fs + of the Kubelet's stats API. +

+ updowncounter + */ +static constexpr const char *kMetricK8sNodeFilesystemUsage = "k8s.node.filesystem.usage"; +static constexpr const char *descrMetricK8sNodeFilesystemUsage = "Node filesystem usage."; +static constexpr const char *unitMetricK8sNodeFilesystemUsage = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricK8sNodeFilesystemUsage(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricK8sNodeFilesystemUsage, + descrMetricK8sNodeFilesystemUsage, + unitMetricK8sNodeFilesystemUsage); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricK8sNodeFilesystemUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricK8sNodeFilesystemUsage, + descrMetricK8sNodeFilesystemUsage, + unitMetricK8sNodeFilesystemUsage); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sNodeFilesystemUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricK8sNodeFilesystemUsage, + descrMetricK8sNodeFilesystemUsage, + unitMetricK8sNodeFilesystemUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sNodeFilesystemUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricK8sNodeFilesystemUsage, + descrMetricK8sNodeFilesystemUsage, + unitMetricK8sNodeFilesystemUsage); +} + +/** + Memory usage of the Node.

Total memory usage of the Node

gauge */ static constexpr const char *kMetricK8sNodeMemoryUsage = "k8s.node.memory.usage"; -static constexpr const char *descrMetricK8sNodeMemoryUsage = "Memory usage of the Node"; +static constexpr const char *descrMetricK8sNodeMemoryUsage = "Memory usage of the Node."; static constexpr const char *unitMetricK8sNodeMemoryUsage = "By"; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 @@ -1764,12 +1912,12 @@ CreateAsyncDoubleMetricK8sNodeMemoryUsage(metrics::Meter *meter) } /** - Node network errors + Node network errors.

counter */ static constexpr const char *kMetricK8sNodeNetworkErrors = "k8s.node.network.errors"; -static constexpr const char *descrMetricK8sNodeNetworkErrors = "Node network errors"; +static constexpr const char *descrMetricK8sNodeNetworkErrors = "Node network errors."; static constexpr const char *unitMetricK8sNodeNetworkErrors = "{error}"; static inline nostd::unique_ptr> @@ -1801,12 +1949,12 @@ CreateAsyncDoubleMetricK8sNodeNetworkErrors(metrics::Meter *meter) } /** - Network bytes for the Node + Network bytes for the Node.

counter */ static constexpr const char *kMetricK8sNodeNetworkIo = "k8s.node.network.io"; -static constexpr const char *descrMetricK8sNodeNetworkIo = "Network bytes for the Node"; +static constexpr const char *descrMetricK8sNodeNetworkIo = "Network bytes for the Node."; static constexpr const char *unitMetricK8sNodeNetworkIo = "By"; static inline nostd::unique_ptr> CreateSyncInt64MetricK8sNodeNetworkIo( @@ -1838,14 +1986,14 @@ CreateAsyncDoubleMetricK8sNodeNetworkIo(metrics::Meter *meter) } /** - The time the Node has been running + The time the Node has been running.

Instrumentations SHOULD use a gauge with type @code double @endcode and measure uptime in seconds as a floating point number with the highest precision available. The actual accuracy would depend on the instrumentation and operating system.

gauge */ static constexpr const char *kMetricK8sNodeUptime = "k8s.node.uptime"; -static constexpr const char *descrMetricK8sNodeUptime = "The time the Node has been running"; +static constexpr const char *descrMetricK8sNodeUptime = "The time the Node has been running."; static constexpr const char *unitMetricK8sNodeUptime = "s"; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 @@ -1880,14 +2028,14 @@ static inline nostd::shared_ptr CreateAsyncDouble } /** - Total CPU time consumed + Total CPU time consumed.

Total CPU time consumed by the specific Pod on all available CPU cores

counter */ static constexpr const char *kMetricK8sPodCpuTime = "k8s.pod.cpu.time"; -static constexpr const char *descrMetricK8sPodCpuTime = "Total CPU time consumed"; +static constexpr const char *descrMetricK8sPodCpuTime = "Total CPU time consumed."; static constexpr const char *unitMetricK8sPodCpuTime = "s"; static inline nostd::unique_ptr> CreateSyncInt64MetricK8sPodCpuTime( @@ -1919,7 +2067,7 @@ static inline nostd::shared_ptr CreateAsyncDouble } /** - Pod's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs + Pod's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs.

CPU usage of the specific Pod on all available CPU cores, averaged over the sample window

@@ -1927,7 +2075,7 @@ static inline nostd::shared_ptr CreateAsyncDouble */ static constexpr const char *kMetricK8sPodCpuUsage = "k8s.pod.cpu.usage"; static constexpr const char *descrMetricK8sPodCpuUsage = - "Pod's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs"; + "Pod's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs."; static constexpr const char *unitMetricK8sPodCpuUsage = "{cpu}"; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 @@ -1962,14 +2110,161 @@ CreateAsyncDoubleMetricK8sPodCpuUsage(metrics::Meter *meter) } /** - Memory usage of the Pod + Pod filesystem available bytes. +

+ This metric is derived from the + FsStats.AvailableBytes + field of the PodStats.EphemeralStorage + of the Kubelet's stats API. +

+ updowncounter + */ +static constexpr const char *kMetricK8sPodFilesystemAvailable = "k8s.pod.filesystem.available"; +static constexpr const char *descrMetricK8sPodFilesystemAvailable = + "Pod filesystem available bytes."; +static constexpr const char *unitMetricK8sPodFilesystemAvailable = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricK8sPodFilesystemAvailable(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricK8sPodFilesystemAvailable, + descrMetricK8sPodFilesystemAvailable, + unitMetricK8sPodFilesystemAvailable); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricK8sPodFilesystemAvailable(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricK8sPodFilesystemAvailable, + descrMetricK8sPodFilesystemAvailable, + unitMetricK8sPodFilesystemAvailable); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sPodFilesystemAvailable(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricK8sPodFilesystemAvailable, + descrMetricK8sPodFilesystemAvailable, + unitMetricK8sPodFilesystemAvailable); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sPodFilesystemAvailable(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricK8sPodFilesystemAvailable, + descrMetricK8sPodFilesystemAvailable, + unitMetricK8sPodFilesystemAvailable); +} + +/** + Pod filesystem capacity. +

+ This metric is derived from the + FsStats.CapacityBytes + field of the PodStats.EphemeralStorage + of the Kubelet's stats API. +

+ updowncounter + */ +static constexpr const char *kMetricK8sPodFilesystemCapacity = "k8s.pod.filesystem.capacity"; +static constexpr const char *descrMetricK8sPodFilesystemCapacity = "Pod filesystem capacity."; +static constexpr const char *unitMetricK8sPodFilesystemCapacity = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricK8sPodFilesystemCapacity(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricK8sPodFilesystemCapacity, + descrMetricK8sPodFilesystemCapacity, + unitMetricK8sPodFilesystemCapacity); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricK8sPodFilesystemCapacity(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricK8sPodFilesystemCapacity, + descrMetricK8sPodFilesystemCapacity, + unitMetricK8sPodFilesystemCapacity); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sPodFilesystemCapacity(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricK8sPodFilesystemCapacity, + descrMetricK8sPodFilesystemCapacity, + unitMetricK8sPodFilesystemCapacity); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sPodFilesystemCapacity(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricK8sPodFilesystemCapacity, + descrMetricK8sPodFilesystemCapacity, + unitMetricK8sPodFilesystemCapacity); +} + +/** + Pod filesystem usage. +

+ This may not equal capacity - available. +

+ This metric is derived from the + FsStats.UsedBytes + field of the PodStats.EphemeralStorage + of the Kubelet's stats API. +

+ updowncounter + */ +static constexpr const char *kMetricK8sPodFilesystemUsage = "k8s.pod.filesystem.usage"; +static constexpr const char *descrMetricK8sPodFilesystemUsage = "Pod filesystem usage."; +static constexpr const char *unitMetricK8sPodFilesystemUsage = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricK8sPodFilesystemUsage(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricK8sPodFilesystemUsage, + descrMetricK8sPodFilesystemUsage, + unitMetricK8sPodFilesystemUsage); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricK8sPodFilesystemUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricK8sPodFilesystemUsage, + descrMetricK8sPodFilesystemUsage, + unitMetricK8sPodFilesystemUsage); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sPodFilesystemUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricK8sPodFilesystemUsage, + descrMetricK8sPodFilesystemUsage, + unitMetricK8sPodFilesystemUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sPodFilesystemUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricK8sPodFilesystemUsage, + descrMetricK8sPodFilesystemUsage, + unitMetricK8sPodFilesystemUsage); +} + +/** + Memory usage of the Pod.

Total memory usage of the Pod

gauge */ static constexpr const char *kMetricK8sPodMemoryUsage = "k8s.pod.memory.usage"; -static constexpr const char *descrMetricK8sPodMemoryUsage = "Memory usage of the Pod"; +static constexpr const char *descrMetricK8sPodMemoryUsage = "Memory usage of the Pod."; static constexpr const char *unitMetricK8sPodMemoryUsage = "By"; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 @@ -2004,12 +2299,12 @@ CreateAsyncDoubleMetricK8sPodMemoryUsage(metrics::Meter *meter) } /** - Pod network errors + Pod network errors.

counter */ static constexpr const char *kMetricK8sPodNetworkErrors = "k8s.pod.network.errors"; -static constexpr const char *descrMetricK8sPodNetworkErrors = "Pod network errors"; +static constexpr const char *descrMetricK8sPodNetworkErrors = "Pod network errors."; static constexpr const char *unitMetricK8sPodNetworkErrors = "{error}"; static inline nostd::unique_ptr> @@ -2041,12 +2336,12 @@ CreateAsyncDoubleMetricK8sPodNetworkErrors(metrics::Meter *meter) } /** - Network bytes for the Pod + Network bytes for the Pod.

counter */ static constexpr const char *kMetricK8sPodNetworkIo = "k8s.pod.network.io"; -static constexpr const char *descrMetricK8sPodNetworkIo = "Network bytes for the Pod"; +static constexpr const char *descrMetricK8sPodNetworkIo = "Network bytes for the Pod."; static constexpr const char *unitMetricK8sPodNetworkIo = "By"; static inline nostd::unique_ptr> CreateSyncInt64MetricK8sPodNetworkIo( @@ -2078,14 +2373,14 @@ CreateAsyncDoubleMetricK8sPodNetworkIo(metrics::Meter *meter) } /** - The time the Pod has been running + The time the Pod has been running.

Instrumentations SHOULD use a gauge with type @code double @endcode and measure uptime in seconds as a floating point number with the highest precision available. The actual accuracy would depend on the instrumentation and operating system.

gauge */ static constexpr const char *kMetricK8sPodUptime = "k8s.pod.uptime"; -static constexpr const char *descrMetricK8sPodUptime = "The time the Pod has been running"; +static constexpr const char *descrMetricK8sPodUptime = "The time the Pod has been running."; static constexpr const char *unitMetricK8sPodUptime = "s"; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 @@ -2119,16 +2414,291 @@ static inline nostd::shared_ptr CreateAsyncDouble unitMetricK8sPodUptime); } +/** + Pod volume storage space available. +

+ This metric is derived from the + VolumeStats.AvailableBytes + field of the PodStats of + the Kubelet's stats API.

updowncounter + */ +static constexpr const char *kMetricK8sPodVolumeAvailable = "k8s.pod.volume.available"; +static constexpr const char *descrMetricK8sPodVolumeAvailable = + "Pod volume storage space available."; +static constexpr const char *unitMetricK8sPodVolumeAvailable = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricK8sPodVolumeAvailable(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricK8sPodVolumeAvailable, + descrMetricK8sPodVolumeAvailable, + unitMetricK8sPodVolumeAvailable); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricK8sPodVolumeAvailable(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricK8sPodVolumeAvailable, + descrMetricK8sPodVolumeAvailable, + unitMetricK8sPodVolumeAvailable); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sPodVolumeAvailable(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricK8sPodVolumeAvailable, + descrMetricK8sPodVolumeAvailable, + unitMetricK8sPodVolumeAvailable); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sPodVolumeAvailable(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricK8sPodVolumeAvailable, + descrMetricK8sPodVolumeAvailable, + unitMetricK8sPodVolumeAvailable); +} + +/** + Pod volume total capacity. +

+ This metric is derived from the + VolumeStats.CapacityBytes + field of the PodStats of + the Kubelet's stats API.

updowncounter + */ +static constexpr const char *kMetricK8sPodVolumeCapacity = "k8s.pod.volume.capacity"; +static constexpr const char *descrMetricK8sPodVolumeCapacity = "Pod volume total capacity."; +static constexpr const char *unitMetricK8sPodVolumeCapacity = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricK8sPodVolumeCapacity(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter( + kMetricK8sPodVolumeCapacity, descrMetricK8sPodVolumeCapacity, unitMetricK8sPodVolumeCapacity); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricK8sPodVolumeCapacity(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter( + kMetricK8sPodVolumeCapacity, descrMetricK8sPodVolumeCapacity, unitMetricK8sPodVolumeCapacity); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sPodVolumeCapacity(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricK8sPodVolumeCapacity, descrMetricK8sPodVolumeCapacity, unitMetricK8sPodVolumeCapacity); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sPodVolumeCapacity(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricK8sPodVolumeCapacity, descrMetricK8sPodVolumeCapacity, unitMetricK8sPodVolumeCapacity); +} + +/** + The total inodes in the filesystem of the Pod's volume. +

+ This metric is derived from the + VolumeStats.Inodes + field of the PodStats of + the Kubelet's stats API.

updowncounter + */ +static constexpr const char *kMetricK8sPodVolumeInodeCount = "k8s.pod.volume.inode.count"; +static constexpr const char *descrMetricK8sPodVolumeInodeCount = + "The total inodes in the filesystem of the Pod's volume."; +static constexpr const char *unitMetricK8sPodVolumeInodeCount = "{inode}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricK8sPodVolumeInodeCount(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricK8sPodVolumeInodeCount, + descrMetricK8sPodVolumeInodeCount, + unitMetricK8sPodVolumeInodeCount); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricK8sPodVolumeInodeCount(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricK8sPodVolumeInodeCount, + descrMetricK8sPodVolumeInodeCount, + unitMetricK8sPodVolumeInodeCount); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sPodVolumeInodeCount(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricK8sPodVolumeInodeCount, + descrMetricK8sPodVolumeInodeCount, + unitMetricK8sPodVolumeInodeCount); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sPodVolumeInodeCount(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricK8sPodVolumeInodeCount, + descrMetricK8sPodVolumeInodeCount, + unitMetricK8sPodVolumeInodeCount); +} + +/** + The free inodes in the filesystem of the Pod's volume. +

+ This metric is derived from the + VolumeStats.InodesFree + field of the PodStats of + the Kubelet's stats API.

updowncounter + */ +static constexpr const char *kMetricK8sPodVolumeInodeFree = "k8s.pod.volume.inode.free"; +static constexpr const char *descrMetricK8sPodVolumeInodeFree = + "The free inodes in the filesystem of the Pod's volume."; +static constexpr const char *unitMetricK8sPodVolumeInodeFree = "{inode}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricK8sPodVolumeInodeFree(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricK8sPodVolumeInodeFree, + descrMetricK8sPodVolumeInodeFree, + unitMetricK8sPodVolumeInodeFree); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricK8sPodVolumeInodeFree(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricK8sPodVolumeInodeFree, + descrMetricK8sPodVolumeInodeFree, + unitMetricK8sPodVolumeInodeFree); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sPodVolumeInodeFree(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricK8sPodVolumeInodeFree, + descrMetricK8sPodVolumeInodeFree, + unitMetricK8sPodVolumeInodeFree); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sPodVolumeInodeFree(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricK8sPodVolumeInodeFree, + descrMetricK8sPodVolumeInodeFree, + unitMetricK8sPodVolumeInodeFree); +} + +/** + The inodes used by the filesystem of the Pod's volume. +

+ This metric is derived from the + VolumeStats.InodesUsed + field of the PodStats of + the Kubelet's stats API.

This may not be equal to @code inodes - free @endcode because + filesystem may share inodes with other filesystems.

updowncounter + */ +static constexpr const char *kMetricK8sPodVolumeInodeUsed = "k8s.pod.volume.inode.used"; +static constexpr const char *descrMetricK8sPodVolumeInodeUsed = + "The inodes used by the filesystem of the Pod's volume."; +static constexpr const char *unitMetricK8sPodVolumeInodeUsed = "{inode}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricK8sPodVolumeInodeUsed(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricK8sPodVolumeInodeUsed, + descrMetricK8sPodVolumeInodeUsed, + unitMetricK8sPodVolumeInodeUsed); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricK8sPodVolumeInodeUsed(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricK8sPodVolumeInodeUsed, + descrMetricK8sPodVolumeInodeUsed, + unitMetricK8sPodVolumeInodeUsed); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sPodVolumeInodeUsed(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter(kMetricK8sPodVolumeInodeUsed, + descrMetricK8sPodVolumeInodeUsed, + unitMetricK8sPodVolumeInodeUsed); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sPodVolumeInodeUsed(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter(kMetricK8sPodVolumeInodeUsed, + descrMetricK8sPodVolumeInodeUsed, + unitMetricK8sPodVolumeInodeUsed); +} + +/** + Pod volume usage. +

+ This may not equal capacity - available. +

+ This metric is derived from the + VolumeStats.UsedBytes + field of the PodStats of + the Kubelet's stats API.

updowncounter + */ +static constexpr const char *kMetricK8sPodVolumeUsage = "k8s.pod.volume.usage"; +static constexpr const char *descrMetricK8sPodVolumeUsage = "Pod volume usage."; +static constexpr const char *unitMetricK8sPodVolumeUsage = "By"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricK8sPodVolumeUsage(metrics::Meter *meter) +{ + return meter->CreateInt64UpDownCounter(kMetricK8sPodVolumeUsage, descrMetricK8sPodVolumeUsage, + unitMetricK8sPodVolumeUsage); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricK8sPodVolumeUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleUpDownCounter(kMetricK8sPodVolumeUsage, descrMetricK8sPodVolumeUsage, + unitMetricK8sPodVolumeUsage); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricK8sPodVolumeUsage(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableUpDownCounter( + kMetricK8sPodVolumeUsage, descrMetricK8sPodVolumeUsage, unitMetricK8sPodVolumeUsage); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricK8sPodVolumeUsage(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableUpDownCounter( + kMetricK8sPodVolumeUsage, descrMetricK8sPodVolumeUsage, unitMetricK8sPodVolumeUsage); +} + /** Total number of available replica pods (ready for at least minReadySeconds) targeted by this - replicaset

This metric aligns with the @code availableReplicas @endcode field of the This metric aligns with the @code availableReplicas @endcode field of the K8s ReplicaSetStatus.

updowncounter */ static constexpr const char *kMetricK8sReplicasetAvailablePods = "k8s.replicaset.available_pods"; static constexpr const char *descrMetricK8sReplicasetAvailablePods = "Total number of available replica pods (ready for at least minReadySeconds) targeted by this " - "replicaset"; + "replicaset."; static constexpr const char *unitMetricK8sReplicasetAvailablePods = "{pod}"; static inline nostd::unique_ptr> @@ -2164,7 +2734,7 @@ CreateAsyncDoubleMetricK8sReplicasetAvailablePods(metrics::Meter *meter) } /** - Number of desired replica pods in this replicaset + Number of desired replica pods in this replicaset.

This metric aligns with the @code replicas @endcode field of the > @@ -2305,7 +2875,7 @@ CreateAsyncDoubleMetricK8sReplicationControllerDesiredPods(metrics::Meter *meter /** Total number of available replica pods (ready for at least minReadySeconds) targeted by this - replication controller

This metric aligns with the @code availableReplicas @endcode field of + replication controller.

This metric aligns with the @code availableReplicas @endcode field of the K8s ReplicationControllerStatus

updowncounter @@ -2314,7 +2884,7 @@ static constexpr const char *kMetricK8sReplicationcontrollerAvailablePods = "k8s.replicationcontroller.available_pods"; static constexpr const char *descrMetricK8sReplicationcontrollerAvailablePods = "Total number of available replica pods (ready for at least minReadySeconds) targeted by this " - "replication controller"; + "replication controller."; static constexpr const char *unitMetricK8sReplicationcontrollerAvailablePods = "{pod}"; static inline nostd::unique_ptr> @@ -2351,7 +2921,7 @@ CreateAsyncDoubleMetricK8sReplicationcontrollerAvailablePods(metrics::Meter *met } /** - Number of desired replica pods in this replication controller + Number of desired replica pods in this replication controller.

This metric aligns with the @code replicas @endcode field of the > @@ -3380,7 +3950,7 @@ CreateAsyncDoubleMetricK8sResourcequotaStorageRequestUsed(metrics::Meter *meter) /** The number of replica pods created by the statefulset controller from the statefulset version - indicated by currentRevision

This metric aligns with the @code currentReplicas @endcode field + indicated by currentRevision.

This metric aligns with the @code currentReplicas @endcode field of the K8s StatefulSetStatus.

updowncounter @@ -3388,7 +3958,7 @@ CreateAsyncDoubleMetricK8sResourcequotaStorageRequestUsed(metrics::Meter *meter) static constexpr const char *kMetricK8sStatefulsetCurrentPods = "k8s.statefulset.current_pods"; static constexpr const char *descrMetricK8sStatefulsetCurrentPods = "The number of replica pods created by the statefulset controller from the statefulset version " - "indicated by currentRevision"; + "indicated by currentRevision."; static constexpr const char *unitMetricK8sStatefulsetCurrentPods = "{pod}"; static inline nostd::unique_ptr> @@ -3424,7 +3994,7 @@ CreateAsyncDoubleMetricK8sStatefulsetCurrentPods(metrics::Meter *meter) } /** - Number of desired replica pods in this statefulset + Number of desired replica pods in this statefulset.

This metric aligns with the @code replicas @endcode field of the > @@ -3469,7 +4039,7 @@ CreateAsyncDoubleMetricK8sStatefulsetDesiredPods(metrics::Meter *meter) } /** - The number of replica pods created for this statefulset with a Ready Condition + The number of replica pods created for this statefulset with a Ready Condition.

This metric aligns with the @code readyReplicas @endcode field of the > @@ -3515,7 +4085,7 @@ CreateAsyncDoubleMetricK8sStatefulsetReadyPods(metrics::Meter *meter) /** Number of replica pods created by the statefulset controller from the statefulset version - indicated by updateRevision

This metric aligns with the @code updatedReplicas @endcode field + indicated by updateRevision.

This metric aligns with the @code updatedReplicas @endcode field of the K8s StatefulSetStatus.

updowncounter @@ -3523,7 +4093,7 @@ CreateAsyncDoubleMetricK8sStatefulsetReadyPods(metrics::Meter *meter) static constexpr const char *kMetricK8sStatefulsetUpdatedPods = "k8s.statefulset.updated_pods"; static constexpr const char *descrMetricK8sStatefulsetUpdatedPods = "Number of replica pods created by the statefulset controller from the statefulset version " - "indicated by updateRevision"; + "indicated by updateRevision."; static constexpr const char *unitMetricK8sStatefulsetUpdatedPods = "{pod}"; static inline nostd::unique_ptr> diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/linux_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/linux_attributes.h index c3f90337a4e..18e77516bc6 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/linux_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/linux_attributes.h @@ -26,14 +26,9 @@ static constexpr const char *kLinuxMemorySlabState = "linux.memory.slab.state"; namespace LinuxMemorySlabStateValues { -/** - none - */ + static constexpr const char *kReclaimable = "reclaimable"; -/** - none - */ static constexpr const char *kUnreclaimable = "unreclaimable"; } // namespace LinuxMemorySlabStateValues diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/message_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/message_attributes.h index 05941248c97..0643e94ed5c 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/message_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/message_attributes.h @@ -59,14 +59,9 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kMessageUncompressedSize = namespace MessageTypeValues { -/** - none - */ + static constexpr const char *kSent = "SENT"; -/** - none - */ static constexpr const char *kReceived = "RECEIVED"; } // namespace MessageTypeValues diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/messaging_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/messaging_attributes.h index f036c3654ab..4a3e48eac16 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/messaging_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/messaging_attributes.h @@ -386,13 +386,19 @@ static constexpr const char *kSettle = "settle"; /** Deprecated. Use @code process @endcode instead. + + @deprecated + {"note": "Replaced by @code process @endcode.", "reason": "renamed", "renamed_to": "process"} */ -static constexpr const char *kDeliver = "deliver"; +OPENTELEMETRY_DEPRECATED static constexpr const char *kDeliver = "deliver"; /** Deprecated. Use @code send @endcode instead. + + @deprecated + {"note": "Replaced by @code send @endcode.", "reason": "renamed", "renamed_to": "send"} */ -static constexpr const char *kPublish = "publish"; +OPENTELEMETRY_DEPRECATED static constexpr const char *kPublish = "publish"; } // namespace MessagingOperationTypeValues @@ -465,6 +471,11 @@ namespace MessagingSystemValues */ static constexpr const char *kActivemq = "activemq"; +/** + Amazon Simple Notification Service (SNS) + */ +static constexpr const char *kAwsSns = "aws.sns"; + /** Amazon Simple Queue Service (SQS) */ diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/net_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/net_attributes.h index 951217616ad..266982691fd 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/net_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/net_attributes.h @@ -176,14 +176,9 @@ static constexpr const char *kUnix = "unix"; namespace NetTransportValues { -/** - none - */ + static constexpr const char *kIpTcp = "ip_tcp"; -/** - none - */ static constexpr const char *kIpUdp = "ip_udp"; /** diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/network_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/network_attributes.h index 7b8404b2c9c..34c6a880e13 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/network_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/network_attributes.h @@ -122,59 +122,27 @@ static constexpr const char *kNetworkType = "network.type"; namespace NetworkConnectionStateValues { -/** - none - */ + static constexpr const char *kClosed = "closed"; -/** - none - */ static constexpr const char *kCloseWait = "close_wait"; -/** - none - */ static constexpr const char *kClosing = "closing"; -/** - none - */ static constexpr const char *kEstablished = "established"; -/** - none - */ static constexpr const char *kFinWait1 = "fin_wait_1"; -/** - none - */ static constexpr const char *kFinWait2 = "fin_wait_2"; -/** - none - */ static constexpr const char *kLastAck = "last_ack"; -/** - none - */ static constexpr const char *kListen = "listen"; -/** - none - */ static constexpr const char *kSynReceived = "syn_received"; -/** - none - */ static constexpr const char *kSynSent = "syn_sent"; -/** - none - */ static constexpr const char *kTimeWait = "time_wait"; } // namespace NetworkConnectionStateValues @@ -290,43 +258,24 @@ static constexpr const char *kLteCa = "lte_ca"; namespace NetworkConnectionTypeValues { -/** - none - */ + static constexpr const char *kWifi = "wifi"; -/** - none - */ static constexpr const char *kWired = "wired"; -/** - none - */ static constexpr const char *kCell = "cell"; -/** - none - */ static constexpr const char *kUnavailable = "unavailable"; -/** - none - */ static constexpr const char *kUnknown = "unknown"; } // namespace NetworkConnectionTypeValues namespace NetworkIoDirectionValues { -/** - none - */ + static constexpr const char *kTransmit = "transmit"; -/** - none - */ static constexpr const char *kReceive = "receive"; } // namespace NetworkIoDirectionValues diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/openai_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/openai_attributes.h new file mode 100644 index 00000000000..83cbd44e8c7 --- /dev/null +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/openai_attributes.h @@ -0,0 +1,54 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * DO NOT EDIT, this is an Auto-generated file from: + * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 + */ + +#pragma once + +#include "opentelemetry/common/macros.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace semconv +{ +namespace openai +{ + +/** + The service tier requested. May be a specific tier, default, or auto. + */ +static constexpr const char *kOpenaiRequestServiceTier = "openai.request.service_tier"; + +/** + The service tier used for the response. + */ +static constexpr const char *kOpenaiResponseServiceTier = "openai.response.service_tier"; + +/** + A fingerprint to track any eventual change in the Generative AI environment. + */ +static constexpr const char *kOpenaiResponseSystemFingerprint = + "openai.response.system_fingerprint"; + +namespace OpenaiRequestServiceTierValues +{ +/** + The system will utilize scale tier credits until they are exhausted. + */ +static constexpr const char *kAuto = "auto"; + +/** + The system will utilize the default scale tier. + */ +static constexpr const char *kDefault = "default"; + +} // namespace OpenaiRequestServiceTierValues + +} // namespace openai +} // namespace semconv +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/os_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/os_attributes.h index 1c12402c613..90ca8e5aa17 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/os_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/os_attributes.h @@ -100,8 +100,11 @@ static constexpr const char *kSolaris = "solaris"; /** Deprecated. Use @code zos @endcode instead. + + @deprecated + {"note": "Replaced by @code zos @endcode.", "reason": "renamed", "renamed_to": "zos"} */ -static constexpr const char *kZOs = "z_os"; +OPENTELEMETRY_DEPRECATED static constexpr const char *kZOs = "z_os"; /** IBM z/OS diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/otel_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/otel_attributes.h index ddf04b9406f..20f7bd7786c 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/otel_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/otel_attributes.h @@ -69,6 +69,11 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kOtelLibraryVersion = "ote */ static constexpr const char *kOtelScopeName = "otel.scope.name"; +/** + The schema URL of the instrumentation scope. + */ +static constexpr const char *kOtelScopeSchemaUrl = "otel.scope.schema_url"; + /** The version of the instrumentation scope - (@code InstrumentationScope.Version @endcode in OTLP). */ diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/otel_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/otel_metrics.h index 2f4d9cd2fc2..607939122da 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/otel_metrics.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/otel_metrics.h @@ -21,7 +21,7 @@ namespace otel { /** - The number of log records for which the export has finished, either successful or failed + The number of log records for which the export has finished, either successful or failed.

For successful exports, @code error.type @endcode MUST NOT be set. For failed exports, @code error.type @endcode MUST contain the failure cause. For exporters with partial success semantics @@ -31,7 +31,7 @@ namespace otel */ static constexpr const char *kMetricOtelSdkExporterLogExported = "otel.sdk.exporter.log.exported"; static constexpr const char *descrMetricOtelSdkExporterLogExported = - "The number of log records for which the export has finished, either successful or failed"; + "The number of log records for which the export has finished, either successful or failed."; static constexpr const char *unitMetricOtelSdkExporterLogExported = "{log_record}"; static inline nostd::unique_ptr> @@ -68,14 +68,14 @@ CreateAsyncDoubleMetricOtelSdkExporterLogExported(metrics::Meter *meter) /** The number of log records which were passed to the exporter, but that have not been exported yet - (neither successful, nor failed)

For successful exports, @code error.type @endcode MUST NOT be - set. For failed exports, @code error.type @endcode MUST contain the failure cause.

+ (neither successful, nor failed).

For successful exports, @code error.type @endcode MUST NOT + be set. For failed exports, @code error.type @endcode MUST contain the failure cause.

updowncounter */ static constexpr const char *kMetricOtelSdkExporterLogInflight = "otel.sdk.exporter.log.inflight"; static constexpr const char *descrMetricOtelSdkExporterLogInflight = "The number of log records which were passed to the exporter, but that have not been exported " - "yet (neither successful, nor failed)"; + "yet (neither successful, nor failed)."; static constexpr const char *unitMetricOtelSdkExporterLogInflight = "{log_record}"; static inline nostd::unique_ptr> @@ -111,7 +111,7 @@ CreateAsyncDoubleMetricOtelSdkExporterLogInflight(metrics::Meter *meter) } /** - The number of metric data points for which the export has finished, either successful or failed + The number of metric data points for which the export has finished, either successful or failed.

For successful exports, @code error.type @endcode MUST NOT be set. For failed exports, @code error.type @endcode MUST contain the failure cause. For exporters with partial success semantics @@ -123,7 +123,7 @@ static constexpr const char *kMetricOtelSdkExporterMetricDataPointExported = "otel.sdk.exporter.metric_data_point.exported"; static constexpr const char *descrMetricOtelSdkExporterMetricDataPointExported = "The number of metric data points for which the export has finished, either successful or " - "failed"; + "failed."; static constexpr const char *unitMetricOtelSdkExporterMetricDataPointExported = "{data_point}"; static inline nostd::unique_ptr> @@ -160,7 +160,7 @@ CreateAsyncDoubleMetricOtelSdkExporterMetricDataPointExported(metrics::Meter *me /** The number of metric data points which were passed to the exporter, but that have not been - exported yet (neither successful, nor failed)

For successful exports, @code error.type + exported yet (neither successful, nor failed).

For successful exports, @code error.type @endcode MUST NOT be set. For failed exports, @code error.type @endcode MUST contain the failure cause.

updowncounter */ @@ -168,7 +168,7 @@ static constexpr const char *kMetricOtelSdkExporterMetricDataPointInflight = "otel.sdk.exporter.metric_data_point.inflight"; static constexpr const char *descrMetricOtelSdkExporterMetricDataPointInflight = "The number of metric data points which were passed to the exporter, but that have not been " - "exported yet (neither successful, nor failed)"; + "exported yet (neither successful, nor failed)."; static constexpr const char *unitMetricOtelSdkExporterMetricDataPointInflight = "{data_point}"; static inline nostd::unique_ptr> @@ -239,7 +239,7 @@ CreateSyncDoubleMetricOtelSdkExporterOperationDuration(metrics::Meter *meter) } /** - The number of spans for which the export has finished, either successful or failed + The number of spans for which the export has finished, either successful or failed.

For successful exports, @code error.type @endcode MUST NOT be set. For failed exports, @code error.type @endcode MUST contain the failure cause. For exporters with partial success semantics @@ -249,7 +249,7 @@ CreateSyncDoubleMetricOtelSdkExporterOperationDuration(metrics::Meter *meter) */ static constexpr const char *kMetricOtelSdkExporterSpanExported = "otel.sdk.exporter.span.exported"; static constexpr const char *descrMetricOtelSdkExporterSpanExported = - "The number of spans for which the export has finished, either successful or failed"; + "The number of spans for which the export has finished, either successful or failed."; static constexpr const char *unitMetricOtelSdkExporterSpanExported = "{span}"; static inline nostd::unique_ptr> @@ -332,14 +332,14 @@ CreateAsyncDoubleMetricOtelSdkExporterSpanExportedCount(metrics::Meter *meter) /** The number of spans which were passed to the exporter, but that have not been exported yet - (neither successful, nor failed)

For successful exports, @code error.type @endcode MUST NOT be - set. For failed exports, @code error.type @endcode MUST contain the failure cause.

+ (neither successful, nor failed).

For successful exports, @code error.type @endcode MUST NOT + be set. For failed exports, @code error.type @endcode MUST contain the failure cause.

updowncounter */ static constexpr const char *kMetricOtelSdkExporterSpanInflight = "otel.sdk.exporter.span.inflight"; static constexpr const char *descrMetricOtelSdkExporterSpanInflight = "The number of spans which were passed to the exporter, but that have not been exported yet " - "(neither successful, nor failed)"; + "(neither successful, nor failed)."; static constexpr const char *unitMetricOtelSdkExporterSpanInflight = "{span}"; static inline nostd::unique_ptr> @@ -421,13 +421,13 @@ CreateAsyncDoubleMetricOtelSdkExporterSpanInflightCount(metrics::Meter *meter) } /** - The number of logs submitted to enabled SDK Loggers + The number of logs submitted to enabled SDK Loggers.

counter */ static constexpr const char *kMetricOtelSdkLogCreated = "otel.sdk.log.created"; static constexpr const char *descrMetricOtelSdkLogCreated = - "The number of logs submitted to enabled SDK Loggers"; + "The number of logs submitted to enabled SDK Loggers."; static constexpr const char *unitMetricOtelSdkLogCreated = "{log_record}"; static inline nostd::unique_ptr> CreateSyncInt64MetricOtelSdkLogCreated( @@ -489,7 +489,7 @@ CreateSyncDoubleMetricOtelSdkMetricReaderCollectionDuration(metrics::Meter *mete } /** - The number of log records for which the processing has finished, either successful or failed + The number of log records for which the processing has finished, either successful or failed.

For successful processing, @code error.type @endcode MUST NOT be set. For failed processing, @code error.type @endcode MUST contain the failure cause. For the SDK Simple and Batching Log Record @@ -499,7 +499,7 @@ CreateSyncDoubleMetricOtelSdkMetricReaderCollectionDuration(metrics::Meter *mete static constexpr const char *kMetricOtelSdkProcessorLogProcessed = "otel.sdk.processor.log.processed"; static constexpr const char *descrMetricOtelSdkProcessorLogProcessed = - "The number of log records for which the processing has finished, either successful or failed"; + "The number of log records for which the processing has finished, either successful or failed."; static constexpr const char *unitMetricOtelSdkProcessorLogProcessed = "{log_record}"; static inline nostd::unique_ptr> @@ -536,14 +536,14 @@ CreateAsyncDoubleMetricOtelSdkProcessorLogProcessed(metrics::Meter *meter) /** The maximum number of log records the queue of a given instance of an SDK Log Record processor can - hold

Only applies to Log Record processors which use a queue, e.g. the SDK Batching Log Record - Processor.

updowncounter + hold.

Only applies to Log Record processors which use a queue, e.g. the SDK Batching Log + Record Processor.

updowncounter */ static constexpr const char *kMetricOtelSdkProcessorLogQueueCapacity = "otel.sdk.processor.log.queue.capacity"; static constexpr const char *descrMetricOtelSdkProcessorLogQueueCapacity = "The maximum number of log records the queue of a given instance of an SDK Log Record " - "processor can hold"; + "processor can hold."; static constexpr const char *unitMetricOtelSdkProcessorLogQueueCapacity = "{log_record}"; static inline nostd::unique_ptr> @@ -579,7 +579,7 @@ CreateAsyncDoubleMetricOtelSdkProcessorLogQueueCapacity(metrics::Meter *meter) } /** - The number of log records in the queue of a given instance of an SDK log processor + The number of log records in the queue of a given instance of an SDK log processor.

Only applies to log record processors which use a queue, e.g. the SDK Batching Log Record Processor.

updowncounter @@ -587,7 +587,7 @@ CreateAsyncDoubleMetricOtelSdkProcessorLogQueueCapacity(metrics::Meter *meter) static constexpr const char *kMetricOtelSdkProcessorLogQueueSize = "otel.sdk.processor.log.queue.size"; static constexpr const char *descrMetricOtelSdkProcessorLogQueueSize = - "The number of log records in the queue of a given instance of an SDK log processor"; + "The number of log records in the queue of a given instance of an SDK log processor."; static constexpr const char *unitMetricOtelSdkProcessorLogQueueSize = "{log_record}"; static inline nostd::unique_ptr> @@ -623,7 +623,7 @@ CreateAsyncDoubleMetricOtelSdkProcessorLogQueueSize(metrics::Meter *meter) } /** - The number of spans for which the processing has finished, either successful or failed + The number of spans for which the processing has finished, either successful or failed.

For successful processing, @code error.type @endcode MUST NOT be set. For failed processing, @code error.type @endcode MUST contain the failure cause. For the SDK Simple and Batching Span Processor @@ -633,7 +633,7 @@ CreateAsyncDoubleMetricOtelSdkProcessorLogQueueSize(metrics::Meter *meter) static constexpr const char *kMetricOtelSdkProcessorSpanProcessed = "otel.sdk.processor.span.processed"; static constexpr const char *descrMetricOtelSdkProcessorSpanProcessed = - "The number of spans for which the processing has finished, either successful or failed"; + "The number of spans for which the processing has finished, either successful or failed."; static constexpr const char *unitMetricOtelSdkProcessorSpanProcessed = "{span}"; static inline nostd::unique_ptr> @@ -716,7 +716,7 @@ CreateAsyncDoubleMetricOtelSdkProcessorSpanProcessedCount(metrics::Meter *meter) } /** - The maximum number of spans the queue of a given instance of an SDK span processor can hold + The maximum number of spans the queue of a given instance of an SDK span processor can hold.

Only applies to span processors which use a queue, e.g. the SDK Batching Span Processor.

@@ -725,7 +725,7 @@ CreateAsyncDoubleMetricOtelSdkProcessorSpanProcessedCount(metrics::Meter *meter) static constexpr const char *kMetricOtelSdkProcessorSpanQueueCapacity = "otel.sdk.processor.span.queue.capacity"; static constexpr const char *descrMetricOtelSdkProcessorSpanQueueCapacity = - "The maximum number of spans the queue of a given instance of an SDK span processor can hold"; + "The maximum number of spans the queue of a given instance of an SDK span processor can hold."; static constexpr const char *unitMetricOtelSdkProcessorSpanQueueCapacity = "{span}"; static inline nostd::unique_ptr> @@ -761,7 +761,7 @@ CreateAsyncDoubleMetricOtelSdkProcessorSpanQueueCapacity(metrics::Meter *meter) } /** - The number of spans in the queue of a given instance of an SDK span processor + The number of spans in the queue of a given instance of an SDK span processor.

Only applies to span processors which use a queue, e.g. the SDK Batching Span Processor.

@@ -770,7 +770,7 @@ CreateAsyncDoubleMetricOtelSdkProcessorSpanQueueCapacity(metrics::Meter *meter) static constexpr const char *kMetricOtelSdkProcessorSpanQueueSize = "otel.sdk.processor.span.queue.size"; static constexpr const char *descrMetricOtelSdkProcessorSpanQueueSize = - "The number of spans in the queue of a given instance of an SDK span processor"; + "The number of spans in the queue of a given instance of an SDK span processor."; static constexpr const char *unitMetricOtelSdkProcessorSpanQueueSize = "{span}"; static inline nostd::unique_ptr> @@ -895,12 +895,12 @@ CreateAsyncDoubleMetricOtelSdkSpanEndedCount(metrics::Meter *meter) /** The number of created spans with @code recording=true @endcode for which the end operation has not - been called yet

updowncounter + been called yet.

updowncounter */ static constexpr const char *kMetricOtelSdkSpanLive = "otel.sdk.span.live"; static constexpr const char *descrMetricOtelSdkSpanLive = "The number of created spans with `recording=true` for which the end operation has not been " - "called yet"; + "called yet."; static constexpr const char *unitMetricOtelSdkSpanLive = "{span}"; static inline nostd::unique_ptr> @@ -973,14 +973,14 @@ CreateAsyncDoubleMetricOtelSdkSpanLiveCount(metrics::Meter *meter) } /** - The number of created spans + The number of created spans.

Implementations MUST record this metric for all spans, even for non-recording ones.

counter */ static constexpr const char *kMetricOtelSdkSpanStarted = "otel.sdk.span.started"; -static constexpr const char *descrMetricOtelSdkSpanStarted = "The number of created spans"; +static constexpr const char *descrMetricOtelSdkSpanStarted = "The number of created spans."; static constexpr const char *unitMetricOtelSdkSpanStarted = "{span}"; static inline nostd::unique_ptr> CreateSyncInt64MetricOtelSdkSpanStarted( diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/other_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/other_attributes.h index ab0939606f4..c8feb59b622 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/other_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/other_attributes.h @@ -30,14 +30,9 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kState = "state"; namespace StateValues { -/** - none - */ + static constexpr const char *kIdle = "idle"; -/** - none - */ static constexpr const char *kUsed = "used"; } // namespace StateValues diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/process_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/process_attributes.h index e6f32fbc084..b6a8bd1d024 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/process_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/process_attributes.h @@ -247,47 +247,29 @@ static constexpr const char *kProcessWorkingDirectory = "process.working_directo namespace ProcessContextSwitchTypeValues { -/** - none - */ + static constexpr const char *kVoluntary = "voluntary"; -/** - none - */ static constexpr const char *kInvoluntary = "involuntary"; } // namespace ProcessContextSwitchTypeValues namespace ProcessCpuStateValues { -/** - none - */ + static constexpr const char *kSystem = "system"; -/** - none - */ static constexpr const char *kUser = "user"; -/** - none - */ static constexpr const char *kWait = "wait"; } // namespace ProcessCpuStateValues namespace ProcessPagingFaultTypeValues { -/** - none - */ + static constexpr const char *kMajor = "major"; -/** - none - */ static constexpr const char *kMinor = "minor"; } // namespace ProcessPagingFaultTypeValues diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/rpc_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/rpc_attributes.h index daf36ce67bb..8a85fe46970 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/rpc_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/rpc_attributes.h @@ -149,84 +149,37 @@ static constexpr const char *kRpcSystem = "rpc.system"; namespace RpcConnectRpcErrorCodeValues { -/** - none - */ + static constexpr const char *kCancelled = "cancelled"; -/** - none - */ static constexpr const char *kUnknown = "unknown"; -/** - none - */ static constexpr const char *kInvalidArgument = "invalid_argument"; -/** - none - */ static constexpr const char *kDeadlineExceeded = "deadline_exceeded"; -/** - none - */ static constexpr const char *kNotFound = "not_found"; -/** - none - */ static constexpr const char *kAlreadyExists = "already_exists"; -/** - none - */ static constexpr const char *kPermissionDenied = "permission_denied"; -/** - none - */ static constexpr const char *kResourceExhausted = "resource_exhausted"; -/** - none - */ static constexpr const char *kFailedPrecondition = "failed_precondition"; -/** - none - */ static constexpr const char *kAborted = "aborted"; -/** - none - */ static constexpr const char *kOutOfRange = "out_of_range"; -/** - none - */ static constexpr const char *kUnimplemented = "unimplemented"; -/** - none - */ static constexpr const char *kInternal = "internal"; -/** - none - */ static constexpr const char *kUnavailable = "unavailable"; -/** - none - */ static constexpr const char *kDataLoss = "data_loss"; -/** - none - */ static constexpr const char *kUnauthenticated = "unauthenticated"; } // namespace RpcConnectRpcErrorCodeValues @@ -322,14 +275,9 @@ static constexpr int kUnauthenticated = 16; namespace RpcMessageTypeValues { -/** - none - */ + static constexpr const char *kSent = "SENT"; -/** - none - */ static constexpr const char *kReceived = "RECEIVED"; } // namespace RpcMessageTypeValues diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/system_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/system_attributes.h index 917d507b364..70001903511 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/system_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/system_attributes.h @@ -105,92 +105,47 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kSystemProcessesStatus = namespace SystemCpuStateValues { -/** - none - */ + static constexpr const char *kUser = "user"; -/** - none - */ static constexpr const char *kSystem = "system"; -/** - none - */ static constexpr const char *kNice = "nice"; -/** - none - */ static constexpr const char *kIdle = "idle"; -/** - none - */ static constexpr const char *kIowait = "iowait"; -/** - none - */ static constexpr const char *kInterrupt = "interrupt"; -/** - none - */ static constexpr const char *kSteal = "steal"; } // namespace SystemCpuStateValues namespace SystemFilesystemStateValues { -/** - none - */ + static constexpr const char *kUsed = "used"; -/** - none - */ static constexpr const char *kFree = "free"; -/** - none - */ static constexpr const char *kReserved = "reserved"; } // namespace SystemFilesystemStateValues namespace SystemFilesystemTypeValues { -/** - none - */ + static constexpr const char *kFat32 = "fat32"; -/** - none - */ static constexpr const char *kExfat = "exfat"; -/** - none - */ static constexpr const char *kNtfs = "ntfs"; -/** - none - */ static constexpr const char *kRefs = "refs"; -/** - none - */ static constexpr const char *kHfsplus = "hfsplus"; -/** - none - */ static constexpr const char *kExt4 = "ext4"; } // namespace SystemFilesystemTypeValues @@ -198,182 +153,103 @@ static constexpr const char *kExt4 = "ext4"; namespace SystemMemoryStateValues { /** - none + Actual used virtual memory in bytes. */ static constexpr const char *kUsed = "used"; -/** - none - */ static constexpr const char *kFree = "free"; /** - none + @deprecated + {"note": "Removed, report shared memory usage with @code metric.system.memory.shared @endcode + metric", "reason": "uncategorized"} */ -static constexpr const char *kShared = "shared"; +OPENTELEMETRY_DEPRECATED static constexpr const char *kShared = "shared"; -/** - none - */ static constexpr const char *kBuffers = "buffers"; -/** - none - */ static constexpr const char *kCached = "cached"; } // namespace SystemMemoryStateValues namespace SystemNetworkStateValues { -/** - none - */ + static constexpr const char *kClose = "close"; -/** - none - */ static constexpr const char *kCloseWait = "close_wait"; -/** - none - */ static constexpr const char *kClosing = "closing"; -/** - none - */ static constexpr const char *kDelete = "delete"; -/** - none - */ static constexpr const char *kEstablished = "established"; -/** - none - */ static constexpr const char *kFinWait1 = "fin_wait_1"; -/** - none - */ static constexpr const char *kFinWait2 = "fin_wait_2"; -/** - none - */ static constexpr const char *kLastAck = "last_ack"; -/** - none - */ static constexpr const char *kListen = "listen"; -/** - none - */ static constexpr const char *kSynRecv = "syn_recv"; -/** - none - */ static constexpr const char *kSynSent = "syn_sent"; -/** - none - */ static constexpr const char *kTimeWait = "time_wait"; } // namespace SystemNetworkStateValues namespace SystemPagingDirectionValues { -/** - none - */ + static constexpr const char *kIn = "in"; -/** - none - */ static constexpr const char *kOut = "out"; } // namespace SystemPagingDirectionValues namespace SystemPagingStateValues { -/** - none - */ + static constexpr const char *kUsed = "used"; -/** - none - */ static constexpr const char *kFree = "free"; } // namespace SystemPagingStateValues namespace SystemPagingTypeValues { -/** - none - */ + static constexpr const char *kMajor = "major"; -/** - none - */ static constexpr const char *kMinor = "minor"; } // namespace SystemPagingTypeValues namespace SystemProcessStatusValues { -/** - none - */ + static constexpr const char *kRunning = "running"; -/** - none - */ static constexpr const char *kSleeping = "sleeping"; -/** - none - */ static constexpr const char *kStopped = "stopped"; -/** - none - */ static constexpr const char *kDefunct = "defunct"; } // namespace SystemProcessStatusValues namespace SystemProcessesStatusValues { -/** - none - */ + static constexpr const char *kRunning = "running"; -/** - none - */ static constexpr const char *kSleeping = "sleeping"; -/** - none - */ static constexpr const char *kStopped = "stopped"; -/** - none - */ static constexpr const char *kDefunct = "defunct"; } // namespace SystemProcessesStatusValues diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/system_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/system_metrics.h index f905b73b6ff..d0767b51a60 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/system_metrics.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/system_metrics.h @@ -63,13 +63,13 @@ CreateAsyncDoubleMetricSystemCpuFrequency(metrics::Meter *meter) /** Reports the number of logical (virtual) processor cores created by the operating system to manage - multitasking

Calculated by multiplying the number of sockets by the number of cores per + multitasking.

Calculated by multiplying the number of sockets by the number of cores per socket, and then by the number of threads per core

updowncounter */ static constexpr const char *kMetricSystemCpuLogicalCount = "system.cpu.logical.count"; static constexpr const char *descrMetricSystemCpuLogicalCount = "Reports the number of logical (virtual) processor cores created by the operating system to " - "manage multitasking"; + "manage multitasking."; static constexpr const char *unitMetricSystemCpuLogicalCount = "{cpu}"; static inline nostd::unique_ptr> @@ -105,7 +105,7 @@ CreateAsyncDoubleMetricSystemCpuLogicalCount(metrics::Meter *meter) } /** - Reports the number of actual physical processor cores on the hardware + Reports the number of actual physical processor cores on the hardware.

Calculated by multiplying the number of sockets by the number of cores per socket

@@ -113,7 +113,7 @@ CreateAsyncDoubleMetricSystemCpuLogicalCount(metrics::Meter *meter) */ static constexpr const char *kMetricSystemCpuPhysicalCount = "system.cpu.physical.count"; static constexpr const char *descrMetricSystemCpuPhysicalCount = - "Reports the number of actual physical processor cores on the hardware"; + "Reports the number of actual physical processor cores on the hardware."; static constexpr const char *unitMetricSystemCpuPhysicalCount = "{cpu}"; static inline nostd::unique_ptr> @@ -149,13 +149,13 @@ CreateAsyncDoubleMetricSystemCpuPhysicalCount(metrics::Meter *meter) } /** - Seconds each logical CPU spent on each mode + Seconds each logical CPU spent on each mode.

counter */ static constexpr const char *kMetricSystemCpuTime = "system.cpu.time"; static constexpr const char *descrMetricSystemCpuTime = - "Seconds each logical CPU spent on each mode"; + "Seconds each logical CPU spent on each mode."; static constexpr const char *unitMetricSystemCpuTime = "s"; static inline nostd::unique_ptr> CreateSyncInt64MetricSystemCpuTime( @@ -228,10 +228,12 @@ CreateAsyncDoubleMetricSystemCpuUtilization(metrics::Meter *meter) } /** + TODO. +

counter */ static constexpr const char *kMetricSystemDiskIo = "system.disk.io"; -static constexpr const char *descrMetricSystemDiskIo = ""; +static constexpr const char *descrMetricSystemDiskIo = "TODO."; static constexpr const char *unitMetricSystemDiskIo = "By"; static inline nostd::unique_ptr> CreateSyncInt64MetricSystemDiskIo( @@ -263,7 +265,7 @@ static inline nostd::shared_ptr CreateAsyncDouble } /** - Time disk spent activated + Time disk spent activated.

The real elapsed time ("wall clock") used in the I/O path (time from operations running in parallel are not counted). Measured as:

  • Linux: Field 13 from CreateAsyncDouble counter */ static constexpr const char *kMetricSystemDiskIoTime = "system.disk.io_time"; -static constexpr const char *descrMetricSystemDiskIoTime = "Time disk spent activated"; +static constexpr const char *descrMetricSystemDiskIoTime = "Time disk spent activated."; static constexpr const char *unitMetricSystemDiskIoTime = "s"; static inline nostd::unique_ptr> CreateSyncInt64MetricSystemDiskIoTime( @@ -309,12 +311,12 @@ CreateAsyncDoubleMetricSystemDiskIoTime(metrics::Meter *meter) } /** - The total storage capacity of the disk + The total storage capacity of the disk.

    updowncounter */ static constexpr const char *kMetricSystemDiskLimit = "system.disk.limit"; -static constexpr const char *descrMetricSystemDiskLimit = "The total storage capacity of the disk"; +static constexpr const char *descrMetricSystemDiskLimit = "The total storage capacity of the disk."; static constexpr const char *unitMetricSystemDiskLimit = "By"; static inline nostd::unique_ptr> @@ -346,10 +348,12 @@ CreateAsyncDoubleMetricSystemDiskLimit(metrics::Meter *meter) } /** + TODO. +

    counter */ static constexpr const char *kMetricSystemDiskMerged = "system.disk.merged"; -static constexpr const char *descrMetricSystemDiskMerged = ""; +static constexpr const char *descrMetricSystemDiskMerged = "TODO."; static constexpr const char *unitMetricSystemDiskMerged = "{operation}"; static inline nostd::unique_ptr> CreateSyncInt64MetricSystemDiskMerged( @@ -381,7 +385,7 @@ CreateAsyncDoubleMetricSystemDiskMerged(metrics::Meter *meter) } /** - Sum of the time each operation took to complete + Sum of the time each operation took to complete.

    Because it is the sum of time each request took, parallel-issued requests each contribute to make the count grow. Measured as:

    • Linux: Fields 7 & 11 from > @@ -430,10 +434,12 @@ CreateAsyncDoubleMetricSystemDiskOperationTime(metrics::Meter *meter) } /** + TODO. +

      counter */ static constexpr const char *kMetricSystemDiskOperations = "system.disk.operations"; -static constexpr const char *descrMetricSystemDiskOperations = ""; +static constexpr const char *descrMetricSystemDiskOperations = "TODO."; static constexpr const char *unitMetricSystemDiskOperations = "{operation}"; static inline nostd::unique_ptr> @@ -465,13 +471,13 @@ CreateAsyncDoubleMetricSystemDiskOperations(metrics::Meter *meter) } /** - The total storage capacity of the filesystem + The total storage capacity of the filesystem.

      updowncounter */ static constexpr const char *kMetricSystemFilesystemLimit = "system.filesystem.limit"; static constexpr const char *descrMetricSystemFilesystemLimit = - "The total storage capacity of the filesystem"; + "The total storage capacity of the filesystem."; static constexpr const char *unitMetricSystemFilesystemLimit = "By"; static inline nostd::unique_ptr> @@ -551,10 +557,12 @@ CreateAsyncDoubleMetricSystemFilesystemUsage(metrics::Meter *meter) } /** + TODO. +

      gauge */ static constexpr const char *kMetricSystemFilesystemUtilization = "system.filesystem.utilization"; -static constexpr const char *descrMetricSystemFilesystemUtilization = ""; +static constexpr const char *descrMetricSystemFilesystemUtilization = "TODO."; static constexpr const char *unitMetricSystemFilesystemUtilization = "1"; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 @@ -594,7 +602,7 @@ CreateAsyncDoubleMetricSystemFilesystemUtilization(metrics::Meter *meter) /** An estimate of how much memory is available for starting new applications, without causing - swapping

      This is an alternative to @code system.memory.usage @endcode metric with @code + swapping.

      This is an alternative to @code system.memory.usage @endcode metric with @code state=free @endcode. Linux starting from 3.14 exports "available" memory. It takes "free" memory as a baseline, and then factors in kernel-specific values. This is supposed to be more accurate than just "free" memory. For reference, see the calculations > @@ -688,15 +696,14 @@ CreateAsyncDoubleMetricSystemLinuxMemorySlabUsage(metrics::Meter *meter) } /** - Total memory available in the system. -

      - Its value SHOULD equal the sum of @code system.memory.state @endcode over all states. + Total virtual memory available in the system.

      updowncounter */ -static constexpr const char *kMetricSystemMemoryLimit = "system.memory.limit"; -static constexpr const char *descrMetricSystemMemoryLimit = "Total memory available in the system."; -static constexpr const char *unitMetricSystemMemoryLimit = "By"; +static constexpr const char *kMetricSystemMemoryLimit = "system.memory.limit"; +static constexpr const char *descrMetricSystemMemoryLimit = + "Total virtual memory available in the system."; +static constexpr const char *unitMetricSystemMemoryLimit = "By"; static inline nostd::unique_ptr> CreateSyncInt64MetricSystemMemoryLimit(metrics::Meter *meter) @@ -770,9 +777,6 @@ CreateAsyncDoubleMetricSystemMemoryShared(metrics::Meter *meter) /** Reports memory in use by state.

      - The sum over all @code system.memory.state @endcode values SHOULD equal the total memory - available on the system, that is @code system.memory.limit @endcode. -

      updowncounter */ static constexpr const char *kMetricSystemMemoryUsage = "system.memory.usage"; @@ -808,10 +812,12 @@ CreateAsyncDoubleMetricSystemMemoryUsage(metrics::Meter *meter) } /** + TODO. +

      gauge */ static constexpr const char *kMetricSystemMemoryUtilization = "system.memory.utilization"; -static constexpr const char *descrMetricSystemMemoryUtilization = ""; +static constexpr const char *descrMetricSystemMemoryUtilization = "TODO."; static constexpr const char *unitMetricSystemMemoryUtilization = "1"; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 @@ -849,11 +855,13 @@ CreateAsyncDoubleMetricSystemMemoryUtilization(metrics::Meter *meter) } /** + TODO. +

      updowncounter */ static constexpr const char *kMetricSystemNetworkConnectionCount = "system.network.connection.count"; -static constexpr const char *descrMetricSystemNetworkConnectionCount = ""; +static constexpr const char *descrMetricSystemNetworkConnectionCount = "TODO."; static constexpr const char *unitMetricSystemNetworkConnectionCount = "{connection}"; static inline nostd::unique_ptr> @@ -889,7 +897,7 @@ CreateAsyncDoubleMetricSystemNetworkConnectionCount(metrics::Meter *meter) } /** - Deprecated, use @code system.network.connection.count @endcode instead + Deprecated, use @code system.network.connection.count @endcode instead. @deprecated {"note": "Replaced by @code system.network.connection.count @endcode.", "reason": "renamed", @@ -898,7 +906,7 @@ CreateAsyncDoubleMetricSystemNetworkConnectionCount(metrics::Meter *meter) OPENTELEMETRY_DEPRECATED static constexpr const char *kMetricSystemNetworkConnections = "system.network.connections"; OPENTELEMETRY_DEPRECATED static constexpr const char *descrMetricSystemNetworkConnections = - "Deprecated, use `system.network.connection.count` instead"; + "Deprecated, use `system.network.connection.count` instead."; OPENTELEMETRY_DEPRECATED static constexpr const char *unitMetricSystemNetworkConnections = "{connection}"; @@ -935,60 +943,11 @@ CreateAsyncDoubleMetricSystemNetworkConnections(metrics::Meter *meter) } /** - Count of packets that are dropped or discarded even though there was no error + Count of network errors detected.

      Measured as:

      -

      - counter - */ -static constexpr const char *kMetricSystemNetworkDropped = "system.network.dropped"; -static constexpr const char *descrMetricSystemNetworkDropped = - "Count of packets that are dropped or discarded even though there was no error"; -static constexpr const char *unitMetricSystemNetworkDropped = "{packet}"; - -static inline nostd::unique_ptr> -CreateSyncInt64MetricSystemNetworkDropped(metrics::Meter *meter) -{ - return meter->CreateUInt64Counter(kMetricSystemNetworkDropped, descrMetricSystemNetworkDropped, - unitMetricSystemNetworkDropped); -} - -static inline nostd::unique_ptr> -CreateSyncDoubleMetricSystemNetworkDropped(metrics::Meter *meter) -{ - return meter->CreateDoubleCounter(kMetricSystemNetworkDropped, descrMetricSystemNetworkDropped, - unitMetricSystemNetworkDropped); -} - -static inline nostd::shared_ptr -CreateAsyncInt64MetricSystemNetworkDropped(metrics::Meter *meter) -{ - return meter->CreateInt64ObservableCounter( - kMetricSystemNetworkDropped, descrMetricSystemNetworkDropped, unitMetricSystemNetworkDropped); -} - -static inline nostd::shared_ptr -CreateAsyncDoubleMetricSystemNetworkDropped(metrics::Meter *meter) -{ - return meter->CreateDoubleObservableCounter( - kMetricSystemNetworkDropped, descrMetricSystemNetworkDropped, unitMetricSystemNetworkDropped); -} - -/** - Count of network errors detected -

      - Measured as: -

        -
      • Linux: the @code errs @endcode column in @code /proc/dev/net @endcode (Linux: the @code errs @endcode column in @code /proc/net/dev @endcode (source).
      • Windows: @code @@ -1000,7 +959,7 @@ CreateAsyncDoubleMetricSystemNetworkDropped(metrics::Meter *meter) counter */ static constexpr const char *kMetricSystemNetworkErrors = "system.network.errors"; -static constexpr const char *descrMetricSystemNetworkErrors = "Count of network errors detected"; +static constexpr const char *descrMetricSystemNetworkErrors = "Count of network errors detected."; static constexpr const char *unitMetricSystemNetworkErrors = "{error}"; static inline nostd::unique_ptr> @@ -1032,10 +991,12 @@ CreateAsyncDoubleMetricSystemNetworkErrors(metrics::Meter *meter) } /** + TODO. +

        counter */ static constexpr const char *kMetricSystemNetworkIo = "system.network.io"; -static constexpr const char *descrMetricSystemNetworkIo = ""; +static constexpr const char *descrMetricSystemNetworkIo = "TODO."; static constexpr const char *unitMetricSystemNetworkIo = "By"; static inline nostd::unique_ptr> CreateSyncInt64MetricSystemNetworkIo( @@ -1067,45 +1028,106 @@ CreateAsyncDoubleMetricSystemNetworkIo(metrics::Meter *meter) } /** + TODO. +

        counter */ -static constexpr const char *kMetricSystemNetworkPackets = "system.network.packets"; -static constexpr const char *descrMetricSystemNetworkPackets = ""; -static constexpr const char *unitMetricSystemNetworkPackets = "{packet}"; +static constexpr const char *kMetricSystemNetworkPacketCount = "system.network.packet.count"; +static constexpr const char *descrMetricSystemNetworkPacketCount = "TODO."; +static constexpr const char *unitMetricSystemNetworkPacketCount = "{packet}"; static inline nostd::unique_ptr> -CreateSyncInt64MetricSystemNetworkPackets(metrics::Meter *meter) +CreateSyncInt64MetricSystemNetworkPacketCount(metrics::Meter *meter) { - return meter->CreateUInt64Counter(kMetricSystemNetworkPackets, descrMetricSystemNetworkPackets, - unitMetricSystemNetworkPackets); + return meter->CreateUInt64Counter(kMetricSystemNetworkPacketCount, + descrMetricSystemNetworkPacketCount, + unitMetricSystemNetworkPacketCount); } static inline nostd::unique_ptr> -CreateSyncDoubleMetricSystemNetworkPackets(metrics::Meter *meter) +CreateSyncDoubleMetricSystemNetworkPacketCount(metrics::Meter *meter) { - return meter->CreateDoubleCounter(kMetricSystemNetworkPackets, descrMetricSystemNetworkPackets, - unitMetricSystemNetworkPackets); + return meter->CreateDoubleCounter(kMetricSystemNetworkPacketCount, + descrMetricSystemNetworkPacketCount, + unitMetricSystemNetworkPacketCount); } static inline nostd::shared_ptr -CreateAsyncInt64MetricSystemNetworkPackets(metrics::Meter *meter) +CreateAsyncInt64MetricSystemNetworkPacketCount(metrics::Meter *meter) { - return meter->CreateInt64ObservableCounter( - kMetricSystemNetworkPackets, descrMetricSystemNetworkPackets, unitMetricSystemNetworkPackets); + return meter->CreateInt64ObservableCounter(kMetricSystemNetworkPacketCount, + descrMetricSystemNetworkPacketCount, + unitMetricSystemNetworkPacketCount); } static inline nostd::shared_ptr -CreateAsyncDoubleMetricSystemNetworkPackets(metrics::Meter *meter) +CreateAsyncDoubleMetricSystemNetworkPacketCount(metrics::Meter *meter) { - return meter->CreateDoubleObservableCounter( - kMetricSystemNetworkPackets, descrMetricSystemNetworkPackets, unitMetricSystemNetworkPackets); + return meter->CreateDoubleObservableCounter(kMetricSystemNetworkPacketCount, + descrMetricSystemNetworkPacketCount, + unitMetricSystemNetworkPacketCount); } /** + Count of packets that are dropped or discarded even though there was no error. +

        + Measured as: +

        +

        + counter + */ +static constexpr const char *kMetricSystemNetworkPacketDropped = "system.network.packet.dropped"; +static constexpr const char *descrMetricSystemNetworkPacketDropped = + "Count of packets that are dropped or discarded even though there was no error."; +static constexpr const char *unitMetricSystemNetworkPacketDropped = "{packet}"; + +static inline nostd::unique_ptr> +CreateSyncInt64MetricSystemNetworkPacketDropped(metrics::Meter *meter) +{ + return meter->CreateUInt64Counter(kMetricSystemNetworkPacketDropped, + descrMetricSystemNetworkPacketDropped, + unitMetricSystemNetworkPacketDropped); +} + +static inline nostd::unique_ptr> +CreateSyncDoubleMetricSystemNetworkPacketDropped(metrics::Meter *meter) +{ + return meter->CreateDoubleCounter(kMetricSystemNetworkPacketDropped, + descrMetricSystemNetworkPacketDropped, + unitMetricSystemNetworkPacketDropped); +} + +static inline nostd::shared_ptr +CreateAsyncInt64MetricSystemNetworkPacketDropped(metrics::Meter *meter) +{ + return meter->CreateInt64ObservableCounter(kMetricSystemNetworkPacketDropped, + descrMetricSystemNetworkPacketDropped, + unitMetricSystemNetworkPacketDropped); +} + +static inline nostd::shared_ptr +CreateAsyncDoubleMetricSystemNetworkPacketDropped(metrics::Meter *meter) +{ + return meter->CreateDoubleObservableCounter(kMetricSystemNetworkPacketDropped, + descrMetricSystemNetworkPacketDropped, + unitMetricSystemNetworkPacketDropped); +} + +/** + TODO. +

        counter */ static constexpr const char *kMetricSystemPagingFaults = "system.paging.faults"; -static constexpr const char *descrMetricSystemPagingFaults = ""; +static constexpr const char *descrMetricSystemPagingFaults = "TODO."; static constexpr const char *unitMetricSystemPagingFaults = "{fault}"; static inline nostd::unique_ptr> CreateSyncInt64MetricSystemPagingFaults( @@ -1137,10 +1159,12 @@ CreateAsyncDoubleMetricSystemPagingFaults(metrics::Meter *meter) } /** + TODO. +

        counter */ static constexpr const char *kMetricSystemPagingOperations = "system.paging.operations"; -static constexpr const char *descrMetricSystemPagingOperations = ""; +static constexpr const char *descrMetricSystemPagingOperations = "TODO."; static constexpr const char *unitMetricSystemPagingOperations = "{operation}"; static inline nostd::unique_ptr> @@ -1176,12 +1200,12 @@ CreateAsyncDoubleMetricSystemPagingOperations(metrics::Meter *meter) } /** - Unix swap or windows pagefile usage + Unix swap or windows pagefile usage.

        updowncounter */ static constexpr const char *kMetricSystemPagingUsage = "system.paging.usage"; -static constexpr const char *descrMetricSystemPagingUsage = "Unix swap or windows pagefile usage"; +static constexpr const char *descrMetricSystemPagingUsage = "Unix swap or windows pagefile usage."; static constexpr const char *unitMetricSystemPagingUsage = "By"; static inline nostd::unique_ptr> @@ -1213,10 +1237,12 @@ CreateAsyncDoubleMetricSystemPagingUsage(metrics::Meter *meter) } /** + TODO. +

        gauge */ static constexpr const char *kMetricSystemPagingUtilization = "system.paging.utilization"; -static constexpr const char *descrMetricSystemPagingUtilization = ""; +static constexpr const char *descrMetricSystemPagingUtilization = "TODO."; static constexpr const char *unitMetricSystemPagingUtilization = "1"; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 @@ -1254,13 +1280,13 @@ CreateAsyncDoubleMetricSystemPagingUtilization(metrics::Meter *meter) } /** - Total number of processes in each state + Total number of processes in each state.

        updowncounter */ static constexpr const char *kMetricSystemProcessCount = "system.process.count"; static constexpr const char *descrMetricSystemProcessCount = - "Total number of processes in each state"; + "Total number of processes in each state."; static constexpr const char *unitMetricSystemProcessCount = "{process}"; static inline nostd::unique_ptr> @@ -1292,13 +1318,13 @@ CreateAsyncDoubleMetricSystemProcessCount(metrics::Meter *meter) } /** - Total number of processes created over uptime of the host + Total number of processes created over uptime of the host.

        counter */ static constexpr const char *kMetricSystemProcessCreated = "system.process.created"; static constexpr const char *descrMetricSystemProcessCreated = - "Total number of processes created over uptime of the host"; + "Total number of processes created over uptime of the host."; static constexpr const char *unitMetricSystemProcessCreated = "{process}"; static inline nostd::unique_ptr> @@ -1330,14 +1356,14 @@ CreateAsyncDoubleMetricSystemProcessCreated(metrics::Meter *meter) } /** - The time the system has been running + The time the system has been running.

        Instrumentations SHOULD use a gauge with type @code double @endcode and measure uptime in seconds as a floating point number with the highest precision available. The actual accuracy would depend on the instrumentation and operating system.

        gauge */ static constexpr const char *kMetricSystemUptime = "system.uptime"; -static constexpr const char *descrMetricSystemUptime = "The time the system has been running"; +static constexpr const char *descrMetricSystemUptime = "The time the system has been running."; static constexpr const char *unitMetricSystemUptime = "s"; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/telemetry_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/telemetry_attributes.h index 7a34acefe23..05ef72558a1 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/telemetry_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/telemetry_attributes.h @@ -58,64 +58,29 @@ static constexpr const char *kTelemetrySdkVersion = "telemetry.sdk.version"; namespace TelemetrySdkLanguageValues { -/** - none - */ + static constexpr const char *kCpp = "cpp"; -/** - none - */ static constexpr const char *kDotnet = "dotnet"; -/** - none - */ static constexpr const char *kErlang = "erlang"; -/** - none - */ static constexpr const char *kGo = "go"; -/** - none - */ static constexpr const char *kJava = "java"; -/** - none - */ static constexpr const char *kNodejs = "nodejs"; -/** - none - */ static constexpr const char *kPhp = "php"; -/** - none - */ static constexpr const char *kPython = "python"; -/** - none - */ static constexpr const char *kRuby = "ruby"; -/** - none - */ static constexpr const char *kRust = "rust"; -/** - none - */ static constexpr const char *kSwift = "swift"; -/** - none - */ static constexpr const char *kWebjs = "webjs"; } // namespace TelemetrySdkLanguageValues diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/tls_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/tls_attributes.h index 0deee289d07..7f2db4afeac 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/tls_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/tls_attributes.h @@ -205,14 +205,9 @@ static constexpr const char *kTlsServerSubject = "tls.server.subject"; namespace TlsProtocolNameValues { -/** - none - */ + static constexpr const char *kSsl = "ssl"; -/** - none - */ static constexpr const char *kTls = "tls"; } // namespace TlsProtocolNameValues diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/vcs_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/vcs_attributes.h index 5a0f31952fe..16227fe4b4d 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/vcs_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/vcs_attributes.h @@ -254,8 +254,11 @@ static constexpr const char *kGitlab = "gitlab"; /** Deprecated, use @code gitea @endcode instead. + + @deprecated + {"note": "Replaced by @code gitea @endcode.", "reason": "renamed", "renamed_to": "gitea"} */ -static constexpr const char *kGittea = "gittea"; +OPENTELEMETRY_DEPRECATED static constexpr const char *kGittea = "gittea"; /** Gitea diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/vcs_metrics.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/vcs_metrics.h index c38dce26ae0..07722c7d59a 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/vcs_metrics.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/incubating/vcs_metrics.h @@ -22,12 +22,12 @@ namespace vcs /** The number of changes (pull requests/merge requests/changelists) in a repository, categorized by - their state (e.g. open or merged)

        updowncounter + their state (e.g. open or merged).

        updowncounter */ static constexpr const char *kMetricVcsChangeCount = "vcs.change.count"; static constexpr const char *descrMetricVcsChangeCount = "The number of changes (pull requests/merge requests/changelists) in a repository, categorized " - "by their state (e.g. open or merged)"; + "by their state (e.g. open or merged)."; static constexpr const char *unitMetricVcsChangeCount = "{change}"; static inline nostd::unique_ptr> @@ -185,13 +185,13 @@ CreateAsyncDoubleMetricVcsChangeTimeToMerge(metrics::Meter *meter) } /** - The number of unique contributors to a repository + The number of unique contributors to a repository.

        gauge */ static constexpr const char *kMetricVcsContributorCount = "vcs.contributor.count"; static constexpr const char *descrMetricVcsContributorCount = - "The number of unique contributors to a repository"; + "The number of unique contributors to a repository."; static constexpr const char *unitMetricVcsContributorCount = "{contributor}"; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 @@ -310,7 +310,7 @@ CreateAsyncDoubleMetricVcsRefLinesDelta(metrics::Meter *meter) /** The number of revisions (commits) a ref (branch) is ahead/behind the branch from the @code - vcs.ref.base.name @endcode attribute

        This metric should be reported for each @code + vcs.ref.base.name @endcode attribute.

        This metric should be reported for each @code vcs.revision_delta.direction @endcode value. For example if branch @code a @endcode is 3 commits behind and 2 commits ahead of @code trunk @endcode, instrumentation SHOULD report two measurements: 3 and 2 (both positive numbers) and @code vcs.ref.base.name @endcode is set to @code @@ -319,7 +319,7 @@ CreateAsyncDoubleMetricVcsRefLinesDelta(metrics::Meter *meter) static constexpr const char *kMetricVcsRefRevisionsDelta = "vcs.ref.revisions_delta"; static constexpr const char *descrMetricVcsRefRevisionsDelta = "The number of revisions (commits) a ref (branch) is ahead/behind the branch from the " - "`vcs.ref.base.name` attribute"; + "`vcs.ref.base.name` attribute."; static constexpr const char *unitMetricVcsRefRevisionsDelta = "{revision}"; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 @@ -355,12 +355,12 @@ CreateAsyncDoubleMetricVcsRefRevisionsDelta(metrics::Meter *meter) /** Time a ref (branch) created from the default branch (trunk) has existed. The @code ref.type - @endcode attribute will always be @code branch @endcode

        gauge + @endcode attribute will always be @code branch @endcode.

        gauge */ static constexpr const char *kMetricVcsRefTime = "vcs.ref.time"; static constexpr const char *descrMetricVcsRefTime = "Time a ref (branch) created from the default branch (trunk) has existed. The `ref.type` " - "attribute will always be `branch`"; + "attribute will always be `branch`."; static constexpr const char *unitMetricVcsRefTime = "s"; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/schema_url.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/schema_url.h index 7b46b52e93f..6d5fc0e48dd 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/schema_url.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/schema_url.h @@ -19,6 +19,6 @@ namespace semconv /** * The URL of the OpenTelemetry schema for these keys and values. */ -static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.36.0"; +static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.37.0"; } // namespace semconv OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/telemetry_attributes.h b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/telemetry_attributes.h index 1722398ddb3..946f80de071 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/telemetry_attributes.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/semconv/telemetry_attributes.h @@ -44,64 +44,29 @@ static constexpr const char *kTelemetrySdkVersion = "telemetry.sdk.version"; namespace TelemetrySdkLanguageValues { -/** - none - */ + static constexpr const char *kCpp = "cpp"; -/** - none - */ static constexpr const char *kDotnet = "dotnet"; -/** - none - */ static constexpr const char *kErlang = "erlang"; -/** - none - */ static constexpr const char *kGo = "go"; -/** - none - */ static constexpr const char *kJava = "java"; -/** - none - */ static constexpr const char *kNodejs = "nodejs"; -/** - none - */ static constexpr const char *kPhp = "php"; -/** - none - */ static constexpr const char *kPython = "python"; -/** - none - */ static constexpr const char *kRuby = "ruby"; -/** - none - */ static constexpr const char *kRust = "rust"; -/** - none - */ static constexpr const char *kSwift = "swift"; -/** - none - */ static constexpr const char *kWebjs = "webjs"; } // namespace TelemetrySdkLanguageValues diff --git a/deps/opentelemetry-cpp/api/include/opentelemetry/version.h b/deps/opentelemetry-cpp/api/include/opentelemetry/version.h index ab69ca02f27..e8747af9a18 100644 --- a/deps/opentelemetry-cpp/api/include/opentelemetry/version.h +++ b/deps/opentelemetry-cpp/api/include/opentelemetry/version.h @@ -10,9 +10,9 @@ # define OPENTELEMETRY_ABI_VERSION_NO 1 #endif -#define OPENTELEMETRY_VERSION "1.22.0" +#define OPENTELEMETRY_VERSION "1.23.0" #define OPENTELEMETRY_VERSION_MAJOR 1 -#define OPENTELEMETRY_VERSION_MINOR 22 +#define OPENTELEMETRY_VERSION_MINOR 23 #define OPENTELEMETRY_VERSION_PATCH 0 #define OPENTELEMETRY_ABI_VERSION OPENTELEMETRY_STRINGIFY(OPENTELEMETRY_ABI_VERSION_NO) diff --git a/deps/opentelemetry-cpp/api/test/core/version_test.cc b/deps/opentelemetry-cpp/api/test/core/version_test.cc index 1ceb68602b7..9d9e06eb9b7 100644 --- a/deps/opentelemetry-cpp/api/test/core/version_test.cc +++ b/deps/opentelemetry-cpp/api/test/core/version_test.cc @@ -3,6 +3,7 @@ #include #include +#include #include #include "opentelemetry/version.h" @@ -14,5 +15,7 @@ TEST(VersionTest, Consistency) OPENTELEMETRY_VERSION_MINOR, OPENTELEMETRY_VERSION_PATCH); std::string actual = OPENTELEMETRY_VERSION; - EXPECT_EQ(actual, expected); + /* OPENTELEMETRY_VERSION may contain a -dev suffix */ + std::string prefix = actual.substr(0, strlen(expected)); + EXPECT_EQ(prefix, expected); } diff --git a/deps/opentelemetry-cpp/exporters/ostream/include/opentelemetry/exporters/ostream/console_log_record_builder.h b/deps/opentelemetry-cpp/exporters/ostream/include/opentelemetry/exporters/ostream/console_log_record_builder.h new file mode 100644 index 00000000000..16822d92bb7 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/ostream/include/opentelemetry/exporters/ostream/console_log_record_builder.h @@ -0,0 +1,33 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/console_log_record_exporter_builder.h" +#include "opentelemetry/sdk/configuration/console_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace logs +{ + +class OPENTELEMETRY_EXPORT ConsoleLogRecordBuilder + : public opentelemetry::sdk::configuration::ConsoleLogRecordExporterBuilder +{ +public: + static void Register(opentelemetry::sdk::configuration::Registry *registry); + + std::unique_ptr Build( + const opentelemetry::sdk::configuration::ConsoleLogRecordExporterConfiguration *model) + const override; +}; + +} // namespace logs +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/ostream/include/opentelemetry/exporters/ostream/console_push_metric_builder.h b/deps/opentelemetry-cpp/exporters/ostream/include/opentelemetry/exporters/ostream/console_push_metric_builder.h new file mode 100644 index 00000000000..3b1bd7f224e --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/ostream/include/opentelemetry/exporters/ostream/console_push_metric_builder.h @@ -0,0 +1,33 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/console_push_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/console_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace metrics +{ + +class OPENTELEMETRY_EXPORT ConsolePushMetricBuilder + : public opentelemetry::sdk::configuration::ConsolePushMetricExporterBuilder +{ +public: + static void Register(opentelemetry::sdk::configuration::Registry *registry); + + std::unique_ptr Build( + const opentelemetry::sdk::configuration::ConsolePushMetricExporterConfiguration *model) + const override; +}; + +} // namespace metrics +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/ostream/include/opentelemetry/exporters/ostream/console_span_builder.h b/deps/opentelemetry-cpp/exporters/ostream/include/opentelemetry/exporters/ostream/console_span_builder.h new file mode 100644 index 00000000000..03a7b615c20 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/ostream/include/opentelemetry/exporters/ostream/console_span_builder.h @@ -0,0 +1,33 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/console_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/console_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace trace +{ + +class OPENTELEMETRY_EXPORT ConsoleSpanBuilder + : public opentelemetry::sdk::configuration::ConsoleSpanExporterBuilder +{ +public: + static void Register(opentelemetry::sdk::configuration::Registry *registry); + + std::unique_ptr Build( + const opentelemetry::sdk::configuration::ConsoleSpanExporterConfiguration *model) + const override; +}; + +} // namespace trace +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/ostream/src/console_log_record_builder.cc b/deps/opentelemetry-cpp/exporters/ostream/src/console_log_record_builder.cc new file mode 100644 index 00000000000..a3849a41c32 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/ostream/src/console_log_record_builder.cc @@ -0,0 +1,36 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include + +#include "opentelemetry/exporters/ostream/console_log_record_builder.h" +#include "opentelemetry/exporters/ostream/log_record_exporter_factory.h" +#include "opentelemetry/sdk/configuration/console_log_record_exporter_builder.h" +#include "opentelemetry/sdk/configuration/console_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace logs +{ + +void ConsoleLogRecordBuilder::Register(opentelemetry::sdk::configuration::Registry *registry) +{ + auto builder = std::make_unique(); + registry->SetConsoleLogRecordBuilder(std::move(builder)); +} + +std::unique_ptr ConsoleLogRecordBuilder::Build( + const opentelemetry::sdk::configuration::ConsoleLogRecordExporterConfiguration * /* model */) + const +{ + return OStreamLogRecordExporterFactory::Create(); +} + +} // namespace logs +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/ostream/src/console_push_metric_builder.cc b/deps/opentelemetry-cpp/exporters/ostream/src/console_push_metric_builder.cc new file mode 100644 index 00000000000..ca875617551 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/ostream/src/console_push_metric_builder.cc @@ -0,0 +1,36 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include + +#include "opentelemetry/exporters/ostream/console_push_metric_builder.h" +#include "opentelemetry/exporters/ostream/metric_exporter_factory.h" +#include "opentelemetry/sdk/configuration/console_push_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/console_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace metrics +{ + +void ConsolePushMetricBuilder::Register(opentelemetry::sdk::configuration::Registry *registry) +{ + auto builder = std::make_unique(); + registry->SetConsolePushMetricExporterBuilder(std::move(builder)); +} + +std::unique_ptr ConsolePushMetricBuilder::Build( + const opentelemetry::sdk::configuration::ConsolePushMetricExporterConfiguration * /* model */) + const +{ + return OStreamMetricExporterFactory::Create(); +} + +} // namespace metrics +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/ostream/src/console_span_builder.cc b/deps/opentelemetry-cpp/exporters/ostream/src/console_span_builder.cc new file mode 100644 index 00000000000..e55190bda92 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/ostream/src/console_span_builder.cc @@ -0,0 +1,35 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include + +#include "opentelemetry/exporters/ostream/console_span_builder.h" +#include "opentelemetry/exporters/ostream/span_exporter_factory.h" +#include "opentelemetry/sdk/configuration/console_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/console_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace trace +{ + +void ConsoleSpanBuilder::Register(opentelemetry::sdk::configuration::Registry *registry) +{ + auto builder = std::make_unique(); + registry->SetConsoleSpanBuilder(std::move(builder)); +} + +std::unique_ptr ConsoleSpanBuilder::Build( + const opentelemetry::sdk::configuration::ConsoleSpanExporterConfiguration * /* model */) const +{ + return OStreamSpanExporterFactory::Create(); +} + +} // namespace trace +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/ostream/test/ostream_log_test.cc b/deps/opentelemetry-cpp/exporters/ostream/test/ostream_log_test.cc index 6c7028ed165..8b8063f6d44 100644 --- a/deps/opentelemetry-cpp/exporters/ostream/test/ostream_log_test.cc +++ b/deps/opentelemetry-cpp/exporters/ostream/test/ostream_log_test.cc @@ -125,7 +125,7 @@ TEST(OstreamLogExporter, DefaultLogRecordToCout) " severity_text : INVALID\n", " body : \n", " resource : \n", - std::string{" telemetry.sdk.version: "} + OPENTELEMETRY_VERSION + "\n", + std::string{" telemetry.sdk.version: "} + OPENTELEMETRY_SDK_VERSION + "\n", " telemetry.sdk.name: opentelemetry\n", " telemetry.sdk.language: cpp\n", " attributes : \n", @@ -199,7 +199,7 @@ TEST(OStreamLogRecordExporter, SimpleLogToCout) " severity_text : TRACE\n" " body : Message\n", " resource : \n", - std::string{" telemetry.sdk.version: "} + OPENTELEMETRY_VERSION + "\n", + std::string{" telemetry.sdk.version: "} + OPENTELEMETRY_SDK_VERSION + "\n", " telemetry.sdk.name: opentelemetry\n", " telemetry.sdk.language: cpp\n", " attributes : \n", @@ -270,7 +270,7 @@ TEST(OStreamLogRecordExporter, LogWithStringAttributesToCerr) " severity_text : INVALID\n", " body : \n", " resource : \n", - std::string{" telemetry.sdk.version: "} + OPENTELEMETRY_VERSION + "\n", + std::string{" telemetry.sdk.version: "} + OPENTELEMETRY_SDK_VERSION + "\n", " telemetry.sdk.name: opentelemetry\n", " telemetry.sdk.language: cpp\n", " service.name: unknown_service\n", @@ -352,7 +352,7 @@ TEST(OStreamLogRecordExporter, LogWithVariantTypesToClog) " body : \n", " resource : \n", " service.name: unknown_service\n", - std::string{" telemetry.sdk.version: "} + OPENTELEMETRY_VERSION + "\n", + std::string{" telemetry.sdk.version: "} + OPENTELEMETRY_SDK_VERSION + "\n", " telemetry.sdk.name: opentelemetry\n", " telemetry.sdk.language: cpp\n", " res1: [1,2,3]\n", @@ -425,7 +425,7 @@ TEST(OStreamLogRecordExporter, IntegrationTest) " severity_text : DEBUG\n", " body : Hello\n", " resource : \n", - std::string{" telemetry.sdk.version: "} + OPENTELEMETRY_VERSION + "\n", + std::string{" telemetry.sdk.version: "} + OPENTELEMETRY_SDK_VERSION + "\n", " service.name: unknown_service\n", " telemetry.sdk.name: opentelemetry\n", " telemetry.sdk.language: cpp\n", @@ -496,7 +496,7 @@ TEST(OStreamLogRecordExporter, IntegrationTestWithEventId) " severity_text : DEBUG\n", " body : Hello {key1} {key2}\n", " resource : \n", - std::string{" telemetry.sdk.version: "} + OPENTELEMETRY_VERSION + "\n", + std::string{" telemetry.sdk.version: "} + OPENTELEMETRY_SDK_VERSION + "\n", " service.name: unknown_service\n", " telemetry.sdk.name: opentelemetry\n", " telemetry.sdk.language: cpp\n", diff --git a/deps/opentelemetry-cpp/exporters/otlp/CMakeLists.txt b/deps/opentelemetry-cpp/exporters/otlp/CMakeLists.txt index def5a025515..9ad6d7922d7 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/CMakeLists.txt +++ b/deps/opentelemetry-cpp/exporters/otlp/CMakeLists.txt @@ -32,7 +32,6 @@ target_link_libraries(opentelemetry_otlp_recordable PUBLIC opentelemetry_metrics) if(WITH_OTLP_GRPC) - find_package(gRPC REQUIRED) if(NOT DEFINED grpc_lib_type) message( FATAL_ERROR "cmake/opentelemetry-proto.cmake should be included first") diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_builder_utils.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_builder_utils.h new file mode 100644 index 00000000000..029e73b78e8 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_builder_utils.h @@ -0,0 +1,38 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/exporters/otlp/otlp_environment.h" // For OtlpHeaders +#include "opentelemetry/exporters/otlp/otlp_http.h" +#include "opentelemetry/exporters/otlp/otlp_preferred_temporality.h" +#include "opentelemetry/sdk/configuration/headers_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_http_encoding.h" +#include "opentelemetry/sdk/configuration/temporality_preference.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +class OtlpBuilderUtils +{ +public: + static HttpRequestContentType ConvertOtlpHttpEncoding( + opentelemetry::sdk::configuration::OtlpHttpEncoding model); + + static OtlpHeaders ConvertHeadersConfigurationModel( + const opentelemetry::sdk::configuration::HeadersConfiguration *model, + const std::string &headers_list); + + static PreferredAggregationTemporality ConvertTemporalityPreference( + opentelemetry::sdk::configuration::TemporalityPreference model); +}; + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_exporter_options.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_exporter_options.h index 1dd2ebfd7f4..b4c4f36c015 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_exporter_options.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_exporter_options.h @@ -22,6 +22,11 @@ namespace otlp struct OPENTELEMETRY_EXPORT OtlpFileExporterOptions : public OtlpFileClientOptions { OtlpFileExporterOptions(); + OtlpFileExporterOptions(const OtlpFileExporterOptions &) = default; + OtlpFileExporterOptions(OtlpFileExporterOptions &&) = default; + OtlpFileExporterOptions &operator=(const OtlpFileExporterOptions &) = default; + OtlpFileExporterOptions &operator=(OtlpFileExporterOptions &&) = default; + ~OtlpFileExporterOptions() override; }; } // namespace otlp diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_log_record_builder.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_log_record_builder.h new file mode 100644 index 00000000000..3ace85c1f93 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_log_record_builder.h @@ -0,0 +1,33 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/otlp_file_log_record_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_file_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +class OPENTELEMETRY_EXPORT OtlpFileLogRecordBuilder + : public opentelemetry::sdk::configuration::OtlpFileLogRecordExporterBuilder +{ +public: + static void Register(opentelemetry::sdk::configuration::Registry *registry); + + std::unique_ptr Build( + const opentelemetry::sdk::configuration::OtlpFileLogRecordExporterConfiguration *model) + const override; +}; + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_log_record_exporter_options.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_log_record_exporter_options.h index caeb3daaf4e..cca6fc8e10b 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_log_record_exporter_options.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_log_record_exporter_options.h @@ -22,6 +22,11 @@ namespace otlp struct OPENTELEMETRY_EXPORT OtlpFileLogRecordExporterOptions : public OtlpFileClientOptions { OtlpFileLogRecordExporterOptions(); + OtlpFileLogRecordExporterOptions(const OtlpFileLogRecordExporterOptions &) = default; + OtlpFileLogRecordExporterOptions(OtlpFileLogRecordExporterOptions &&) = default; + OtlpFileLogRecordExporterOptions &operator=(const OtlpFileLogRecordExporterOptions &) = default; + OtlpFileLogRecordExporterOptions &operator=(OtlpFileLogRecordExporterOptions &&) = default; + ~OtlpFileLogRecordExporterOptions() override; }; } // namespace otlp diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_metric_exporter_options.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_metric_exporter_options.h index 3e946e482bb..d89dcbd3cf6 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_metric_exporter_options.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_metric_exporter_options.h @@ -23,6 +23,11 @@ namespace otlp struct OPENTELEMETRY_EXPORT OtlpFileMetricExporterOptions : public OtlpFileClientOptions { OtlpFileMetricExporterOptions(); + OtlpFileMetricExporterOptions(const OtlpFileMetricExporterOptions &) = default; + OtlpFileMetricExporterOptions(OtlpFileMetricExporterOptions &&) = default; + OtlpFileMetricExporterOptions &operator=(const OtlpFileMetricExporterOptions &) = default; + OtlpFileMetricExporterOptions &operator=(OtlpFileMetricExporterOptions &&) = default; + ~OtlpFileMetricExporterOptions() override; PreferredAggregationTemporality aggregation_temporality; }; diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_push_metric_builder.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_push_metric_builder.h new file mode 100644 index 00000000000..6fb830d75b5 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_push_metric_builder.h @@ -0,0 +1,33 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/otlp_file_push_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_file_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +class OPENTELEMETRY_EXPORT OtlpFilePushMetricBuilder + : public opentelemetry::sdk::configuration::OtlpFilePushMetricExporterBuilder +{ +public: + static void Register(opentelemetry::sdk::configuration::Registry *registry); + + std::unique_ptr Build( + const opentelemetry::sdk::configuration::OtlpFilePushMetricExporterConfiguration *model) + const override; +}; + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_span_builder.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_span_builder.h new file mode 100644 index 00000000000..b96c9411a4a --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_span_builder.h @@ -0,0 +1,33 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/otlp_file_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_file_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +class OPENTELEMETRY_EXPORT OtlpFileSpanBuilder + : public opentelemetry::sdk::configuration::OtlpFileSpanExporterBuilder +{ +public: + static void Register(opentelemetry::sdk::configuration::Registry *registry); + + std::unique_ptr Build( + const opentelemetry::sdk::configuration::OtlpFileSpanExporterConfiguration *model) + const override; +}; + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client.h index 159ac0227d5..2a60a28a21c 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client.h @@ -106,8 +106,11 @@ class OtlpGrpcClient { public: OtlpGrpcClient(const OtlpGrpcClientOptions &options); - ~OtlpGrpcClient(); + OtlpGrpcClient(const OtlpGrpcClient &) = delete; + OtlpGrpcClient(OtlpGrpcClient &&) = delete; + OtlpGrpcClient &operator=(const OtlpGrpcClient &) = delete; + OtlpGrpcClient &operator=(OtlpGrpcClient &&) = delete; static std::string GetGrpcTarget(const std::string &endpoint); diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client_options.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client_options.h index 0ffe5ba72e3..f377ef7d098 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client_options.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client_options.h @@ -23,11 +23,18 @@ namespace otlp struct OtlpGrpcClientOptions { + virtual ~OtlpGrpcClientOptions() = default; + OtlpGrpcClientOptions() = default; + OtlpGrpcClientOptions(const OtlpGrpcClientOptions &) = default; + OtlpGrpcClientOptions(OtlpGrpcClientOptions &&) = default; + OtlpGrpcClientOptions &operator=(const OtlpGrpcClientOptions &) = default; + OtlpGrpcClientOptions &operator=(OtlpGrpcClientOptions &&) = default; + /** The endpoint to export to. */ std::string endpoint; /** Use SSL. */ - bool use_ssl_credentials; + bool use_ssl_credentials{}; /** CA CERT, path to a file. */ std::string ssl_credentials_cacert_path; @@ -64,14 +71,14 @@ struct OtlpGrpcClientOptions std::string user_agent; /** max number of threads that can be allocated from this */ - std::size_t max_threads; + std::size_t max_threads{}; /** Compression type. */ std::string compression; #ifdef ENABLE_ASYNC_EXPORT // Concurrent requests - std::size_t max_concurrent_requests; + std::size_t max_concurrent_requests{}; #endif /** The maximum number of call attempts, including the original attempt. */ diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h index 1022b0dc8fc..f698b8fb5d7 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h @@ -58,6 +58,10 @@ class OtlpGrpcExporter final : public opentelemetry::sdk::trace::SpanExporter explicit OtlpGrpcExporter(const OtlpGrpcExporterOptions &options); ~OtlpGrpcExporter() override; + OtlpGrpcExporter(const OtlpGrpcExporter &) = delete; + OtlpGrpcExporter(OtlpGrpcExporter &&) = delete; + OtlpGrpcExporter &operator=(const OtlpGrpcExporter &) = delete; + OtlpGrpcExporter &operator=(OtlpGrpcExporter &&) = delete; /** * Create a span recordable. diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h index b2556f1f767..4fceaa91518 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h @@ -23,8 +23,15 @@ namespace otlp */ struct OPENTELEMETRY_EXPORT OtlpGrpcExporterOptions : public OtlpGrpcClientOptions { + /** Lookup environment variables. */ OtlpGrpcExporterOptions(); - ~OtlpGrpcExporterOptions(); + /** No defaults. */ + OtlpGrpcExporterOptions(void *); + OtlpGrpcExporterOptions(const OtlpGrpcExporterOptions &) = default; + OtlpGrpcExporterOptions(OtlpGrpcExporterOptions &&) = default; + OtlpGrpcExporterOptions &operator=(const OtlpGrpcExporterOptions &) = default; + OtlpGrpcExporterOptions &operator=(OtlpGrpcExporterOptions &&) = default; + ~OtlpGrpcExporterOptions() override; }; } // namespace otlp diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_builder.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_builder.h new file mode 100644 index 00000000000..642f7cf3175 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_builder.h @@ -0,0 +1,33 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/otlp_grpc_log_record_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +class OPENTELEMETRY_EXPORT OtlpGrpcLogRecordBuilder + : public opentelemetry::sdk::configuration::OtlpGrpcLogRecordExporterBuilder +{ +public: + static void Register(opentelemetry::sdk::configuration::Registry *registry); + + std::unique_ptr Build( + const opentelemetry::sdk::configuration::OtlpGrpcLogRecordExporterConfiguration *model) + const override; +}; + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h index da278ccd282..888c368b282 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h @@ -57,6 +57,10 @@ class OtlpGrpcLogRecordExporter : public opentelemetry::sdk::logs::LogRecordExpo OtlpGrpcLogRecordExporter(const OtlpGrpcLogRecordExporterOptions &options); ~OtlpGrpcLogRecordExporter() override; + OtlpGrpcLogRecordExporter(const OtlpGrpcLogRecordExporter &) = delete; + OtlpGrpcLogRecordExporter(OtlpGrpcLogRecordExporter &&) = delete; + OtlpGrpcLogRecordExporter &operator=(const OtlpGrpcLogRecordExporter &) = delete; + OtlpGrpcLogRecordExporter &operator=(OtlpGrpcLogRecordExporter &&) = delete; /** * Creates a recordable that stores the data in protobuf. diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h index 8438bb080d2..8e6f53644d4 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h @@ -23,8 +23,15 @@ namespace otlp */ struct OPENTELEMETRY_EXPORT OtlpGrpcLogRecordExporterOptions : public OtlpGrpcClientOptions { + /** Lookup environment variables. */ OtlpGrpcLogRecordExporterOptions(); - ~OtlpGrpcLogRecordExporterOptions(); + /** No defaults. */ + OtlpGrpcLogRecordExporterOptions(void *); + OtlpGrpcLogRecordExporterOptions(const OtlpGrpcLogRecordExporterOptions &) = default; + OtlpGrpcLogRecordExporterOptions(OtlpGrpcLogRecordExporterOptions &&) = default; + OtlpGrpcLogRecordExporterOptions &operator=(const OtlpGrpcLogRecordExporterOptions &) = default; + OtlpGrpcLogRecordExporterOptions &operator=(OtlpGrpcLogRecordExporterOptions &&) = default; + ~OtlpGrpcLogRecordExporterOptions() override; }; } // namespace otlp diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h index d3d857b3f08..4272bf2126a 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h @@ -55,6 +55,10 @@ class OtlpGrpcMetricExporter : public opentelemetry::sdk::metrics::PushMetricExp explicit OtlpGrpcMetricExporter(const OtlpGrpcMetricExporterOptions &options); ~OtlpGrpcMetricExporter() override; + OtlpGrpcMetricExporter(const OtlpGrpcMetricExporter &) = delete; + OtlpGrpcMetricExporter(OtlpGrpcMetricExporter &&) = delete; + OtlpGrpcMetricExporter &operator=(const OtlpGrpcMetricExporter &) = delete; + OtlpGrpcMetricExporter &operator=(OtlpGrpcMetricExporter &&) = delete; /** * Get the AggregationTemporality for exporter diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h index 22be5809722..ab6c8795f7d 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h @@ -24,8 +24,15 @@ namespace otlp */ struct OPENTELEMETRY_EXPORT OtlpGrpcMetricExporterOptions : public OtlpGrpcClientOptions { + /** Lookup environment variables. */ OtlpGrpcMetricExporterOptions(); - ~OtlpGrpcMetricExporterOptions(); + /** No defaults. */ + OtlpGrpcMetricExporterOptions(void *); + OtlpGrpcMetricExporterOptions(const OtlpGrpcMetricExporterOptions &) = default; + OtlpGrpcMetricExporterOptions(OtlpGrpcMetricExporterOptions &&) = default; + OtlpGrpcMetricExporterOptions &operator=(const OtlpGrpcMetricExporterOptions &) = default; + OtlpGrpcMetricExporterOptions &operator=(OtlpGrpcMetricExporterOptions &&) = default; + ~OtlpGrpcMetricExporterOptions() override; /** Preferred Aggregation Temporality. */ PreferredAggregationTemporality aggregation_temporality; diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_push_metric_builder.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_push_metric_builder.h new file mode 100644 index 00000000000..8ab6c3022c8 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_push_metric_builder.h @@ -0,0 +1,33 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/otlp_grpc_push_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +class OPENTELEMETRY_EXPORT OtlpGrpcPushMetricBuilder + : public opentelemetry::sdk::configuration::OtlpGrpcPushMetricExporterBuilder +{ +public: + static void Register(opentelemetry::sdk::configuration::Registry *registry); + + std::unique_ptr Build( + const opentelemetry::sdk::configuration::OtlpGrpcPushMetricExporterConfiguration *model) + const override; +}; + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_span_builder.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_span_builder.h new file mode 100644 index 00000000000..86c588c4d5f --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_span_builder.h @@ -0,0 +1,33 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/otlp_grpc_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +class OPENTELEMETRY_EXPORT OtlpGrpcSpanBuilder + : public opentelemetry::sdk::configuration::OtlpGrpcSpanExporterBuilder +{ +public: + static void Register(opentelemetry::sdk::configuration::Registry *registry); + + std::unique_ptr Build( + const opentelemetry::sdk::configuration::OtlpGrpcSpanExporterConfiguration *model) + const override; +}; + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h index 5cb5fdfbc6c..dff27d92f2b 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h @@ -159,6 +159,10 @@ class OtlpHttpClient explicit OtlpHttpClient(OtlpHttpClientOptions &&options); ~OtlpHttpClient(); + OtlpHttpClient(const OtlpHttpClient &) = delete; + OtlpHttpClient &operator=(const OtlpHttpClient &) = delete; + OtlpHttpClient(OtlpHttpClient &&) = delete; + OtlpHttpClient &operator=(OtlpHttpClient &&) = delete; /** * Sync export @@ -230,28 +234,13 @@ class OtlpHttpClient std::shared_ptr session; std::shared_ptr event_handle; - inline HttpSessionData() = default; + HttpSessionData() = default; - inline explicit HttpSessionData( + explicit HttpSessionData( std::shared_ptr &&input_session, std::shared_ptr &&input_handle) - { - session.swap(input_session); - event_handle.swap(input_handle); - } - - inline HttpSessionData(HttpSessionData &&other) - { - session.swap(other.session); - event_handle.swap(other.event_handle); - } - - inline HttpSessionData &operator=(HttpSessionData &&other) noexcept - { - session.swap(other.session); - event_handle.swap(other.event_handle); - return *this; - } + : session(std::move(input_session)), event_handle(std::move(input_handle)) + {} }; /** diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_options.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_options.h index 52f2208575b..93e15ed887b 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_options.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_options.h @@ -32,7 +32,14 @@ namespace otlp */ struct OPENTELEMETRY_EXPORT OtlpHttpExporterOptions { + /** Lookup environment variables. */ OtlpHttpExporterOptions(); + /** No defaults. */ + OtlpHttpExporterOptions(void *); + OtlpHttpExporterOptions(const OtlpHttpExporterOptions &) = default; + OtlpHttpExporterOptions(OtlpHttpExporterOptions &&) = default; + OtlpHttpExporterOptions &operator=(const OtlpHttpExporterOptions &) = default; + OtlpHttpExporterOptions &operator=(OtlpHttpExporterOptions &&) = default; ~OtlpHttpExporterOptions(); /** The endpoint to export to. */ diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_runtime_options.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_runtime_options.h index 02ec76acf97..b5e11b377eb 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_runtime_options.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_runtime_options.h @@ -19,8 +19,7 @@ namespace otlp */ struct OPENTELEMETRY_EXPORT OtlpHttpExporterRuntimeOptions { - OtlpHttpExporterRuntimeOptions() = default; - ~OtlpHttpExporterRuntimeOptions() = default; + OtlpHttpExporterRuntimeOptions() = default; std::shared_ptr thread_instrumentation = std::shared_ptr(nullptr); diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_builder.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_builder.h new file mode 100644 index 00000000000..48c916d2689 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_builder.h @@ -0,0 +1,33 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/otlp_http_log_record_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_http_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +class OPENTELEMETRY_EXPORT OtlpHttpLogRecordBuilder + : public opentelemetry::sdk::configuration::OtlpHttpLogRecordExporterBuilder +{ +public: + static void Register(opentelemetry::sdk::configuration::Registry *registry); + + std::unique_ptr Build( + const opentelemetry::sdk::configuration::OtlpHttpLogRecordExporterConfiguration *model) + const override; +}; + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h index 78160deeb06..60785ed9f86 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h @@ -32,7 +32,14 @@ namespace otlp */ struct OPENTELEMETRY_EXPORT OtlpHttpLogRecordExporterOptions { + /** Lookup environment variables. */ OtlpHttpLogRecordExporterOptions(); + /** No defaults. */ + OtlpHttpLogRecordExporterOptions(void *); + OtlpHttpLogRecordExporterOptions(const OtlpHttpLogRecordExporterOptions &) = default; + OtlpHttpLogRecordExporterOptions(OtlpHttpLogRecordExporterOptions &&) = default; + OtlpHttpLogRecordExporterOptions &operator=(const OtlpHttpLogRecordExporterOptions &) = default; + OtlpHttpLogRecordExporterOptions &operator=(OtlpHttpLogRecordExporterOptions &&) = default; ~OtlpHttpLogRecordExporterOptions(); /** The endpoint to export to. */ diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_runtime_options.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_runtime_options.h index b5ef2ed967d..09213731af7 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_runtime_options.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_runtime_options.h @@ -19,8 +19,7 @@ namespace otlp */ struct OPENTELEMETRY_EXPORT OtlpHttpLogRecordExporterRuntimeOptions { - OtlpHttpLogRecordExporterRuntimeOptions() = default; - ~OtlpHttpLogRecordExporterRuntimeOptions() = default; + OtlpHttpLogRecordExporterRuntimeOptions() = default; std::shared_ptr thread_instrumentation = std::shared_ptr(nullptr); diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter.h index 8733a740a95..72774f36060 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter.h @@ -72,7 +72,7 @@ class OtlpHttpMetricExporter final : public opentelemetry::sdk::metrics::PushMet OtlpHttpMetricExporterRuntimeOptions runtime_options_; // Aggregation Temporality Selector - const sdk::metrics::AggregationTemporalitySelector aggregation_temporality_selector_; + sdk::metrics::AggregationTemporalitySelector aggregation_temporality_selector_; // Object that stores the HTTP sessions that have been created std::unique_ptr http_client_; diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h index 255491a39f4..76f2e9a5136 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h @@ -33,7 +33,14 @@ namespace otlp */ struct OPENTELEMETRY_EXPORT OtlpHttpMetricExporterOptions { + /** Lookup environment variables. */ OtlpHttpMetricExporterOptions(); + /** No defaults. */ + OtlpHttpMetricExporterOptions(void *); + OtlpHttpMetricExporterOptions(const OtlpHttpMetricExporterOptions &) = default; + OtlpHttpMetricExporterOptions(OtlpHttpMetricExporterOptions &&) = default; + OtlpHttpMetricExporterOptions &operator=(const OtlpHttpMetricExporterOptions &) = default; + OtlpHttpMetricExporterOptions &operator=(OtlpHttpMetricExporterOptions &&) = default; ~OtlpHttpMetricExporterOptions(); /** The endpoint to export to. */ diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_runtime_options.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_runtime_options.h index c0e91a342c4..a26d54b9ff1 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_runtime_options.h +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_runtime_options.h @@ -19,8 +19,7 @@ namespace otlp */ struct OPENTELEMETRY_EXPORT OtlpHttpMetricExporterRuntimeOptions { - OtlpHttpMetricExporterRuntimeOptions() = default; - ~OtlpHttpMetricExporterRuntimeOptions() = default; + OtlpHttpMetricExporterRuntimeOptions() = default; std::shared_ptr thread_instrumentation = std::shared_ptr(nullptr); diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_push_metric_builder.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_push_metric_builder.h new file mode 100644 index 00000000000..795dcb2a166 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_push_metric_builder.h @@ -0,0 +1,33 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/otlp_http_push_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_http_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +class OPENTELEMETRY_EXPORT OtlpHttpPushMetricBuilder + : public opentelemetry::sdk::configuration::OtlpHttpPushMetricExporterBuilder +{ +public: + static void Register(opentelemetry::sdk::configuration::Registry *registry); + + std::unique_ptr Build( + const opentelemetry::sdk::configuration::OtlpHttpPushMetricExporterConfiguration *model) + const override; +}; + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_span_builder.h b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_span_builder.h new file mode 100644 index 00000000000..b1e9342d95c --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_span_builder.h @@ -0,0 +1,33 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/otlp_http_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_http_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +class OPENTELEMETRY_EXPORT OtlpHttpSpanBuilder + : public opentelemetry::sdk::configuration::OtlpHttpSpanExporterBuilder +{ +public: + static void Register(opentelemetry::sdk::configuration::Registry *registry); + + std::unique_ptr Build( + const opentelemetry::sdk::configuration::OtlpHttpSpanExporterConfiguration *model) + const override; +}; + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_builder_utils.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_builder_utils.cc new file mode 100644 index 00000000000..cac5efcbad5 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_builder_utils.cc @@ -0,0 +1,120 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include +#include + +#include "opentelemetry/common/kv_properties.h" +#include "opentelemetry/exporters/otlp/otlp_builder_utils.h" +#include "opentelemetry/exporters/otlp/otlp_environment.h" +#include "opentelemetry/exporters/otlp/otlp_http.h" +#include "opentelemetry/exporters/otlp/otlp_preferred_temporality.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/configuration/headers_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_http_encoding.h" +#include "opentelemetry/sdk/configuration/temporality_preference.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +HttpRequestContentType OtlpBuilderUtils::ConvertOtlpHttpEncoding( + opentelemetry::sdk::configuration::OtlpHttpEncoding model) +{ + auto result = exporter::otlp::HttpRequestContentType::kBinary; + + switch (model) + { + case opentelemetry::sdk::configuration::OtlpHttpEncoding::protobuf: + result = exporter::otlp::HttpRequestContentType::kBinary; + break; + case opentelemetry::sdk::configuration::OtlpHttpEncoding::json: + result = exporter::otlp::HttpRequestContentType::kJson; + break; + } + + return result; +} + +OtlpHeaders OtlpBuilderUtils::ConvertHeadersConfigurationModel( + const opentelemetry::sdk::configuration::HeadersConfiguration *model, + const std::string &headers_list) +{ + OtlpHeaders headers; + + // First, scan headers_list, which has low priority. + if (headers_list.size() > 0) + { + opentelemetry::common::KeyValueStringTokenizer tokenizer{headers_list}; + + opentelemetry::nostd::string_view header_key; + opentelemetry::nostd::string_view header_value; + bool header_valid = true; + + while (tokenizer.next(header_valid, header_key, header_value)) + { + if (header_valid) + { + std::string key(header_key); + std::string value(header_value); + + if (headers.find(key) == headers.end()) + { + headers.emplace(std::make_pair(std::move(key), std::move(value))); + } + else + { + OTEL_INTERNAL_LOG_WARN("Found duplicate key in headers_list"); + } + } + else + { + OTEL_INTERNAL_LOG_WARN("Found invalid key/value pair in headers_list"); + } + } + } + + // Second, scan headers, which has high priority. + for (const auto &kv : model->kv_map) + { + const auto &search = headers.find(kv.first); + if (search != headers.end()) + { + headers.erase(search); + } + + headers.emplace(std::make_pair(kv.first, kv.second)); + } + + return headers; +} + +PreferredAggregationTemporality OtlpBuilderUtils::ConvertTemporalityPreference( + opentelemetry::sdk::configuration::TemporalityPreference model) +{ + auto result = exporter::otlp::PreferredAggregationTemporality::kCumulative; + + switch (model) + { + case opentelemetry::sdk::configuration::TemporalityPreference::cumulative: + result = exporter::otlp::PreferredAggregationTemporality::kCumulative; + break; + case opentelemetry::sdk::configuration::TemporalityPreference::delta: + result = exporter::otlp::PreferredAggregationTemporality::kDelta; + break; + case opentelemetry::sdk::configuration::TemporalityPreference::low_memory: + result = exporter::otlp::PreferredAggregationTemporality::kLowMemory; + break; + } + + return result; +} + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_exporter_options.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_exporter_options.cc index ddc371fdda2..b5e9fa725f4 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_exporter_options.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_exporter_options.cc @@ -27,6 +27,8 @@ OtlpFileExporterOptions::OtlpFileExporterOptions() backend_options = fs_options; } +OtlpFileExporterOptions::~OtlpFileExporterOptions() {} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_log_record_builder.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_log_record_builder.cc new file mode 100644 index 00000000000..c09c7f2f307 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_log_record_builder.cc @@ -0,0 +1,41 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include + +#include "opentelemetry/exporters/otlp/otlp_file_log_record_builder.h" +#include "opentelemetry/exporters/otlp/otlp_file_log_record_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_file_log_record_exporter_options.h" +#include "opentelemetry/sdk/configuration/otlp_file_log_record_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_file_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +void OtlpFileLogRecordBuilder::Register(opentelemetry::sdk::configuration::Registry *registry) +{ + auto builder = std::make_unique(); + registry->SetOtlpFileLogRecordBuilder(std::move(builder)); +} + +std::unique_ptr OtlpFileLogRecordBuilder::Build( + const opentelemetry::sdk::configuration::OtlpFileLogRecordExporterConfiguration * /* model */) + const +{ + OtlpFileLogRecordExporterOptions options; + + // FIXME: unclear how to map model->output_stream to a OtlpFileClientBackendOptions + + return OtlpFileLogRecordExporterFactory::Create(options); +} + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_log_record_exporter_options.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_log_record_exporter_options.cc index abc628dc025..be794b28726 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_log_record_exporter_options.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_log_record_exporter_options.cc @@ -27,6 +27,8 @@ OtlpFileLogRecordExporterOptions::OtlpFileLogRecordExporterOptions() backend_options = fs_options; } +OtlpFileLogRecordExporterOptions::~OtlpFileLogRecordExporterOptions() {} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_metric_exporter_options.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_metric_exporter_options.cc index 22d2cc7c499..e1b1f5ca7a5 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_metric_exporter_options.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_metric_exporter_options.cc @@ -28,6 +28,8 @@ OtlpFileMetricExporterOptions::OtlpFileMetricExporterOptions() backend_options = fs_options; } +OtlpFileMetricExporterOptions::~OtlpFileMetricExporterOptions() {} + } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_push_metric_builder.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_push_metric_builder.cc new file mode 100644 index 00000000000..cdf3a6fe39f --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_push_metric_builder.cc @@ -0,0 +1,44 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include + +#include "opentelemetry/exporters/otlp/otlp_builder_utils.h" +#include "opentelemetry/exporters/otlp/otlp_file_metric_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_file_metric_exporter_options.h" +#include "opentelemetry/exporters/otlp/otlp_file_push_metric_builder.h" +#include "opentelemetry/sdk/configuration/otlp_file_push_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_file_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +void OtlpFilePushMetricBuilder::Register(opentelemetry::sdk::configuration::Registry *registry) +{ + auto builder = std::make_unique(); + registry->SetOtlpFilePushMetricExporterBuilder(std::move(builder)); +} + +std::unique_ptr OtlpFilePushMetricBuilder::Build( + const opentelemetry::sdk::configuration::OtlpFilePushMetricExporterConfiguration *model) const +{ + OtlpFileMetricExporterOptions options; + + // FIXME: unclear how to map model->output_stream to a OtlpFileClientBackendOptions + + options.aggregation_temporality = + OtlpBuilderUtils::ConvertTemporalityPreference(model->temporality_preference); + + return OtlpFileMetricExporterFactory::Create(options); +} + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_span_builder.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_span_builder.cc new file mode 100644 index 00000000000..8fbbc335b32 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_file_span_builder.cc @@ -0,0 +1,40 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include + +#include "opentelemetry/exporters/otlp/otlp_file_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_file_exporter_options.h" +#include "opentelemetry/exporters/otlp/otlp_file_span_builder.h" +#include "opentelemetry/sdk/configuration/otlp_file_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_file_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +void OtlpFileSpanBuilder::Register(opentelemetry::sdk::configuration::Registry *registry) +{ + auto builder = std::make_unique(); + registry->SetOtlpFileSpanBuilder(std::move(builder)); +} + +std::unique_ptr OtlpFileSpanBuilder::Build( + const opentelemetry::sdk::configuration::OtlpFileSpanExporterConfiguration * /* model */) const +{ + OtlpFileExporterOptions options; + + // FIXME: unclear how to map model->output_stream to a OtlpFileClientBackendOptions + + return OtlpFileExporterFactory::Create(options); +} + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_client.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_client.cc index 2bc66aa7391..a51740404f9 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_client.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_client.cc @@ -238,7 +238,7 @@ static sdk::common::ExportResult InternalDelegateAsyncExport( stub->experimental_async() # endif ->Export(call_data->grpc_context.get(), call_data->request, call_data->response, - [call_data, async_data, export_data_name](::grpc::Status grpc_status) { + [call_data, async_data, export_data_name](const ::grpc::Status &grpc_status) { { std::lock_guard lock{async_data->running_calls_lock}; async_data->running_calls.erase( diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_exporter_options.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_exporter_options.cc index 1f921abdbc7..482a5193ec5 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_exporter_options.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_exporter_options.cc @@ -45,6 +45,16 @@ OtlpGrpcExporterOptions::OtlpGrpcExporterOptions() retry_policy_backoff_multiplier = GetOtlpDefaultTracesRetryBackoffMultiplier(); } +OtlpGrpcExporterOptions::OtlpGrpcExporterOptions(void *) +{ + use_ssl_credentials = true; + max_threads = 0; + +#ifdef ENABLE_ASYNC_EXPORT + max_concurrent_requests = 64; +#endif +} + OtlpGrpcExporterOptions::~OtlpGrpcExporterOptions() {} } // namespace otlp diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_log_record_builder.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_log_record_builder.cc new file mode 100644 index 00000000000..e65b5848387 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_log_record_builder.cc @@ -0,0 +1,56 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include +#include +#include + +#include "opentelemetry/exporters/otlp/otlp_builder_utils.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_log_record_builder.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_log_record_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +void OtlpGrpcLogRecordBuilder::Register(opentelemetry::sdk::configuration::Registry *registry) +{ + auto builder = std::make_unique(); + registry->SetOtlpGrpcLogRecordBuilder(std::move(builder)); +} + +std::unique_ptr OtlpGrpcLogRecordBuilder::Build( + const opentelemetry::sdk::configuration::OtlpGrpcLogRecordExporterConfiguration *model) const +{ + OtlpGrpcLogRecordExporterOptions options(nullptr); + + options.endpoint = model->endpoint; + options.use_ssl_credentials = !model->insecure; + + options.ssl_credentials_cacert_path = model->certificate_file; +#ifdef ENABLE_OTLP_GRPC_SSL_MTLS_PREVIEW + options.ssl_client_key_path = model->client_key_file; + options.ssl_client_cert_path = model->client_certificate_file; +#endif + + options.timeout = std::chrono::duration_cast( + std::chrono::seconds{model->timeout}); + options.metadata = + OtlpBuilderUtils::ConvertHeadersConfigurationModel(model->headers.get(), model->headers_list); + options.compression = model->compression; + + return OtlpGrpcLogRecordExporterFactory::Create(options); +} + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_log_record_exporter_options.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_log_record_exporter_options.cc index 6bdf8fb98f0..55c108c03d6 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_log_record_exporter_options.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_log_record_exporter_options.cc @@ -45,6 +45,16 @@ OtlpGrpcLogRecordExporterOptions::OtlpGrpcLogRecordExporterOptions() retry_policy_backoff_multiplier = GetOtlpDefaultLogsRetryBackoffMultiplier(); } +OtlpGrpcLogRecordExporterOptions::OtlpGrpcLogRecordExporterOptions(void *) +{ + use_ssl_credentials = true; + max_threads = 0; + +#ifdef ENABLE_ASYNC_EXPORT + max_concurrent_requests = 64; +#endif +} + OtlpGrpcLogRecordExporterOptions::~OtlpGrpcLogRecordExporterOptions() {} } // namespace otlp diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_metric_exporter_options.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_metric_exporter_options.cc index a75b95b11f1..540357ff9c3 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_metric_exporter_options.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_metric_exporter_options.cc @@ -47,6 +47,17 @@ OtlpGrpcMetricExporterOptions::OtlpGrpcMetricExporterOptions() retry_policy_backoff_multiplier = GetOtlpDefaultMetricsRetryBackoffMultiplier(); } +OtlpGrpcMetricExporterOptions::OtlpGrpcMetricExporterOptions(void *) + : aggregation_temporality(PreferredAggregationTemporality::kCumulative) +{ + use_ssl_credentials = true; + max_threads = 0; + +#ifdef ENABLE_ASYNC_EXPORT + max_concurrent_requests = 64; +#endif +} + OtlpGrpcMetricExporterOptions::~OtlpGrpcMetricExporterOptions() {} } // namespace otlp diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_push_metric_builder.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_push_metric_builder.cc new file mode 100644 index 00000000000..6f0acd3e783 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_push_metric_builder.cc @@ -0,0 +1,59 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include +#include +#include + +#include "opentelemetry/exporters/otlp/otlp_builder_utils.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_push_metric_builder.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_push_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +void OtlpGrpcPushMetricBuilder::Register(opentelemetry::sdk::configuration::Registry *registry) +{ + auto builder = std::make_unique(); + registry->SetOtlpGrpcPushMetricExporterBuilder(std::move(builder)); +} + +std::unique_ptr OtlpGrpcPushMetricBuilder::Build( + const opentelemetry::sdk::configuration::OtlpGrpcPushMetricExporterConfiguration *model) const +{ + OtlpGrpcMetricExporterOptions options(nullptr); + + options.endpoint = model->endpoint; + options.use_ssl_credentials = !model->insecure; + + options.ssl_credentials_cacert_path = model->certificate_file; +#ifdef ENABLE_OTLP_GRPC_SSL_MTLS_PREVIEW + options.ssl_client_key_path = model->client_key_file; + options.ssl_client_cert_path = model->client_certificate_file; +#endif + + options.timeout = std::chrono::duration_cast( + std::chrono::seconds{model->timeout}); + options.metadata = + OtlpBuilderUtils::ConvertHeadersConfigurationModel(model->headers.get(), model->headers_list); + options.compression = model->compression; + + options.aggregation_temporality = + OtlpBuilderUtils::ConvertTemporalityPreference(model->temporality_preference); + + return OtlpGrpcMetricExporterFactory::Create(options); +} + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_span_builder.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_span_builder.cc new file mode 100644 index 00000000000..42aeeb56f50 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_span_builder.cc @@ -0,0 +1,56 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include +#include +#include + +#include "opentelemetry/exporters/otlp/otlp_builder_utils.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_span_builder.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +void OtlpGrpcSpanBuilder::Register(opentelemetry::sdk::configuration::Registry *registry) +{ + auto builder = std::make_unique(); + registry->SetOtlpGrpcSpanBuilder(std::move(builder)); +} + +std::unique_ptr OtlpGrpcSpanBuilder::Build( + const opentelemetry::sdk::configuration::OtlpGrpcSpanExporterConfiguration *model) const +{ + OtlpGrpcExporterOptions options(nullptr); + + options.endpoint = model->endpoint; + options.use_ssl_credentials = !model->insecure; + + options.ssl_credentials_cacert_path = model->certificate_file; +#ifdef ENABLE_OTLP_GRPC_SSL_MTLS_PREVIEW + options.ssl_client_key_path = model->client_key_file; + options.ssl_client_cert_path = model->client_certificate_file; +#endif + + options.timeout = std::chrono::duration_cast( + std::chrono::seconds{model->timeout}); + options.metadata = + OtlpBuilderUtils::ConvertHeadersConfigurationModel(model->headers.get(), model->headers_list); + options.compression = model->compression; + + return OtlpGrpcExporterFactory::Create(options); +} + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_exporter_options.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_exporter_options.cc index 7a75018e137..f50e3e1bfd5 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_exporter_options.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_exporter_options.cc @@ -43,6 +43,19 @@ OtlpHttpExporterOptions::OtlpHttpExporterOptions() retry_policy_backoff_multiplier(GetOtlpDefaultTracesRetryBackoffMultiplier()) {} +OtlpHttpExporterOptions::OtlpHttpExporterOptions(void *) + : url(), + content_type(HttpRequestContentType::kBinary), + json_bytes_mapping(JsonBytesMappingKind::kHexId), + use_json_name(false), + console_debug(false), +#ifdef ENABLE_ASYNC_EXPORT + max_concurrent_requests{64}, + max_requests_per_connection{8}, +#endif + ssl_insecure_skip_verify(false) +{} + OtlpHttpExporterOptions::~OtlpHttpExporterOptions() {} } // namespace otlp diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_log_record_builder.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_log_record_builder.cc new file mode 100644 index 00000000000..ad72b918689 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_log_record_builder.cc @@ -0,0 +1,57 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include +#include +#include + +#include "opentelemetry/exporters/otlp/otlp_builder_utils.h" +#include "opentelemetry/exporters/otlp/otlp_http.h" +#include "opentelemetry/exporters/otlp/otlp_http_log_record_builder.h" +#include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h" +#include "opentelemetry/sdk/configuration/otlp_http_log_record_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_http_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +void OtlpHttpLogRecordBuilder::Register(opentelemetry::sdk::configuration::Registry *registry) +{ + auto builder = std::make_unique(); + registry->SetOtlpHttpLogRecordBuilder(std::move(builder)); +} + +std::unique_ptr OtlpHttpLogRecordBuilder::Build( + const opentelemetry::sdk::configuration::OtlpHttpLogRecordExporterConfiguration *model) const +{ + OtlpHttpLogRecordExporterOptions options(nullptr); + + options.url = model->endpoint; + options.content_type = OtlpBuilderUtils::ConvertOtlpHttpEncoding(model->encoding); + options.json_bytes_mapping = JsonBytesMappingKind::kHexId; + options.use_json_name = false; + options.console_debug = false; + options.timeout = std::chrono::duration_cast( + std::chrono::seconds{model->timeout}); + options.http_headers = + OtlpBuilderUtils::ConvertHeadersConfigurationModel(model->headers.get(), model->headers_list); + options.ssl_insecure_skip_verify = false; + options.ssl_ca_cert_path = model->certificate_file; + options.ssl_client_key_path = model->client_key_file; + options.ssl_client_cert_path = model->client_certificate_file; + options.compression = model->compression; + + return OtlpHttpLogRecordExporterFactory::Create(options); +} + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_log_record_exporter_options.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_log_record_exporter_options.cc index 212bc3f6cd7..32c42940da1 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_log_record_exporter_options.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_log_record_exporter_options.cc @@ -43,6 +43,19 @@ OtlpHttpLogRecordExporterOptions::OtlpHttpLogRecordExporterOptions() retry_policy_backoff_multiplier(GetOtlpDefaultLogsRetryBackoffMultiplier()) {} +OtlpHttpLogRecordExporterOptions::OtlpHttpLogRecordExporterOptions(void *) + : url(), + content_type(exporter::otlp::HttpRequestContentType::kBinary), + json_bytes_mapping(JsonBytesMappingKind::kHexId), + use_json_name(false), + console_debug(false), +#ifdef ENABLE_ASYNC_EXPORT + max_concurrent_requests{64}, + max_requests_per_connection{8}, +#endif + ssl_insecure_skip_verify(false) +{} + OtlpHttpLogRecordExporterOptions::~OtlpHttpLogRecordExporterOptions() {} } // namespace otlp diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_metric_exporter_options.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_metric_exporter_options.cc index 0ccdc0ab942..f78ed4f0873 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_metric_exporter_options.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_metric_exporter_options.cc @@ -45,6 +45,20 @@ OtlpHttpMetricExporterOptions::OtlpHttpMetricExporterOptions() retry_policy_backoff_multiplier(GetOtlpDefaultMetricsRetryBackoffMultiplier()) {} +OtlpHttpMetricExporterOptions::OtlpHttpMetricExporterOptions(void *) + : url(), + content_type(exporter::otlp::HttpRequestContentType::kBinary), + json_bytes_mapping(JsonBytesMappingKind::kHexId), + use_json_name(false), + console_debug(false), + aggregation_temporality(PreferredAggregationTemporality::kCumulative), +#ifdef ENABLE_ASYNC_EXPORT + max_concurrent_requests{64}, + max_requests_per_connection{8}, +#endif + ssl_insecure_skip_verify(false) +{} + OtlpHttpMetricExporterOptions::~OtlpHttpMetricExporterOptions() {} } // namespace otlp diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_push_metric_builder.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_push_metric_builder.cc new file mode 100644 index 00000000000..afc59adabe6 --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_push_metric_builder.cc @@ -0,0 +1,59 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include +#include +#include + +#include "opentelemetry/exporters/otlp/otlp_builder_utils.h" +#include "opentelemetry/exporters/otlp/otlp_http.h" +#include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h" +#include "opentelemetry/exporters/otlp/otlp_http_push_metric_builder.h" +#include "opentelemetry/sdk/configuration/otlp_http_push_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_http_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +void OtlpHttpPushMetricBuilder::Register(opentelemetry::sdk::configuration::Registry *registry) +{ + auto builder = std::make_unique(); + registry->SetOtlpHttpPushMetricExporterBuilder(std::move(builder)); +} + +std::unique_ptr OtlpHttpPushMetricBuilder::Build( + const opentelemetry::sdk::configuration::OtlpHttpPushMetricExporterConfiguration *model) const +{ + OtlpHttpMetricExporterOptions options(nullptr); + + options.url = model->endpoint; + options.content_type = OtlpBuilderUtils::ConvertOtlpHttpEncoding(model->encoding); + options.json_bytes_mapping = JsonBytesMappingKind::kHexId; + options.use_json_name = false; + options.console_debug = false; + options.timeout = std::chrono::duration_cast( + std::chrono::seconds{model->timeout}); + options.http_headers = + OtlpBuilderUtils::ConvertHeadersConfigurationModel(model->headers.get(), model->headers_list); + options.aggregation_temporality = + OtlpBuilderUtils::ConvertTemporalityPreference(model->temporality_preference); + options.ssl_insecure_skip_verify = false; + options.ssl_ca_cert_path = model->certificate_file; + options.ssl_client_key_path = model->client_key_file; + options.ssl_client_cert_path = model->client_certificate_file; + options.compression = model->compression; + + return OtlpHttpMetricExporterFactory::Create(options); +} + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_span_builder.cc b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_span_builder.cc new file mode 100644 index 00000000000..98b79c6a58d --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/otlp/src/otlp_http_span_builder.cc @@ -0,0 +1,57 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include +#include +#include + +#include "opentelemetry/exporters/otlp/otlp_builder_utils.h" +#include "opentelemetry/exporters/otlp/otlp_http.h" +#include "opentelemetry/exporters/otlp/otlp_http_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_http_exporter_options.h" +#include "opentelemetry/exporters/otlp/otlp_http_span_builder.h" +#include "opentelemetry/sdk/configuration/otlp_http_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_http_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +void OtlpHttpSpanBuilder::Register(opentelemetry::sdk::configuration::Registry *registry) +{ + auto builder = std::make_unique(); + registry->SetOtlpHttpSpanBuilder(std::move(builder)); +} + +std::unique_ptr OtlpHttpSpanBuilder::Build( + const opentelemetry::sdk::configuration::OtlpHttpSpanExporterConfiguration *model) const +{ + OtlpHttpExporterOptions options(nullptr); + + options.url = model->endpoint; + options.content_type = OtlpBuilderUtils::ConvertOtlpHttpEncoding(model->encoding); + options.json_bytes_mapping = JsonBytesMappingKind::kHexId; + options.use_json_name = false; + options.console_debug = false; + options.timeout = std::chrono::duration_cast( + std::chrono::seconds{model->timeout}); + options.http_headers = + OtlpBuilderUtils::ConvertHeadersConfigurationModel(model->headers.get(), model->headers_list); + options.ssl_insecure_skip_verify = false; + options.ssl_ca_cert_path = model->certificate_file; + options.ssl_client_key_path = model->client_key_file; + options.ssl_client_cert_path = model->client_certificate_file; + options.compression = model->compression; + + return OtlpHttpExporterFactory::Create(options); +} + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/otlp/test/otlp_file_metric_exporter_test.cc b/deps/opentelemetry-cpp/exporters/otlp/test/otlp_file_metric_exporter_test.cc index 965da942ae0..fb388f316ed 100644 --- a/deps/opentelemetry-cpp/exporters/otlp/test/otlp_file_metric_exporter_test.cc +++ b/deps/opentelemetry-cpp/exporters/otlp/test/otlp_file_metric_exporter_test.cc @@ -95,8 +95,9 @@ class OtlpFileMetricExporterTestPeer : public ::testing::Test opentelemetry::sdk::resource::ResourceAttributes{}, "resource_url"); data.resource_ = &resource; - auto scope = opentelemetry::sdk::instrumentationscope::InstrumentationScope::Create( - "library_name", "1.5.0", "scope_url", {{"scope_key", "scope_value"}}); + auto instrumentation_scope = + opentelemetry::sdk::instrumentationscope::InstrumentationScope::Create( + "library_name", "1.5.0", "scope_url", {{"scope_key", "scope_value"}}); opentelemetry::sdk::metrics::MetricData metric_data{ opentelemetry::sdk::metrics::InstrumentDescriptor{ @@ -110,7 +111,8 @@ class OtlpFileMetricExporterTestPeer : public ::testing::Test {opentelemetry::sdk::metrics::PointAttributes{{"a2", "b2"}}, sum_point_data2}}}; data.scope_metric_data_ = std::vector{ - {scope.get(), std::vector{metric_data}}}; + {instrumentation_scope.get(), + std::vector{metric_data}}}; auto result = exporter->Export(data); EXPECT_EQ(result, opentelemetry::sdk::common::ExportResult::kSuccess); @@ -180,10 +182,12 @@ class OtlpFileMetricExporterTestPeer : public ::testing::Test auto resource = opentelemetry::sdk::resource::Resource::Create( opentelemetry::sdk::resource::ResourceAttributes{}); data.resource_ = &resource; - auto scope = opentelemetry::sdk::instrumentationscope::InstrumentationScope::Create( - "library_name", "1.5.0"); + auto instrumentation_scope = + opentelemetry::sdk::instrumentationscope::InstrumentationScope::Create("library_name", + "1.5.0"); data.scope_metric_data_ = std::vector{ - {scope.get(), std::vector{metric_data}}}; + {instrumentation_scope.get(), + std::vector{metric_data}}}; auto result = exporter->Export(data); EXPECT_EQ(result, opentelemetry::sdk::common::ExportResult::kSuccess); @@ -250,10 +254,12 @@ class OtlpFileMetricExporterTestPeer : public ::testing::Test auto resource = opentelemetry::sdk::resource::Resource::Create( opentelemetry::sdk::resource::ResourceAttributes{}); data.resource_ = &resource; - auto scope = opentelemetry::sdk::instrumentationscope::InstrumentationScope::Create( - "library_name", "1.5.0"); + auto instrumentation_scope = + opentelemetry::sdk::instrumentationscope::InstrumentationScope::Create("library_name", + "1.5.0"); data.scope_metric_data_ = std::vector{ - {scope.get(), std::vector{metric_data}}}; + {instrumentation_scope.get(), + std::vector{metric_data}}}; auto result = exporter->Export(data); EXPECT_EQ(result, opentelemetry::sdk::common::ExportResult::kSuccess); diff --git a/deps/opentelemetry-cpp/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_options.h b/deps/opentelemetry-cpp/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_options.h index da9d124029e..9d41d268e81 100644 --- a/deps/opentelemetry-cpp/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_options.h +++ b/deps/opentelemetry-cpp/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_options.h @@ -18,8 +18,12 @@ namespace metrics */ struct PrometheusExporterOptions { + // Lookup environment variables PrometheusExporterOptions(); + // No defaults + PrometheusExporterOptions(void *); + // The endpoint the Prometheus backend can collect metrics from std::string url; diff --git a/deps/opentelemetry-cpp/exporters/prometheus/include/opentelemetry/exporters/prometheus/prometheus_pull_builder.h b/deps/opentelemetry-cpp/exporters/prometheus/include/opentelemetry/exporters/prometheus/prometheus_pull_builder.h new file mode 100644 index 00000000000..621643b08fc --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/prometheus/include/opentelemetry/exporters/prometheus/prometheus_pull_builder.h @@ -0,0 +1,33 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/metrics/metric_reader.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace metrics +{ + +class OPENTELEMETRY_EXPORT PrometheusPullBuilder + : public opentelemetry::sdk::configuration::PrometheusPullMetricExporterBuilder +{ +public: + static void Register(opentelemetry::sdk::configuration::Registry *registry); + + std::unique_ptr Build( + const opentelemetry::sdk::configuration::PrometheusPullMetricExporterConfiguration *model) + const override; +}; + +} // namespace metrics +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/prometheus/src/exporter_options.cc b/deps/opentelemetry-cpp/exporters/prometheus/src/exporter_options.cc index 2ac24b635da..122baf5198f 100644 --- a/deps/opentelemetry-cpp/exporters/prometheus/src/exporter_options.cc +++ b/deps/opentelemetry-cpp/exporters/prometheus/src/exporter_options.cc @@ -77,6 +77,8 @@ PrometheusExporterOptions::PrometheusExporterOptions() without_type_suffix(GetPrometheusWithoutTypeSuffix()) {} +PrometheusExporterOptions::PrometheusExporterOptions(void *) : url("") {} + } // namespace metrics } // namespace exporter OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/prometheus/src/prometheus_pull_builder.cc b/deps/opentelemetry-cpp/exporters/prometheus/src/prometheus_pull_builder.cc new file mode 100644 index 00000000000..18cf814051e --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/prometheus/src/prometheus_pull_builder.cc @@ -0,0 +1,49 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include +#include + +#include "opentelemetry/exporters/prometheus/exporter_factory.h" +#include "opentelemetry/exporters/prometheus/exporter_options.h" +#include "opentelemetry/exporters/prometheus/prometheus_pull_builder.h" +#include "opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/metrics/metric_reader.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace metrics +{ + +void PrometheusPullBuilder::Register(opentelemetry::sdk::configuration::Registry *registry) +{ + auto builder = std::make_unique(); + registry->SetPrometheusPullMetricExporterBuilder(std::move(builder)); +} + +std::unique_ptr PrometheusPullBuilder::Build( + const opentelemetry::sdk::configuration::PrometheusPullMetricExporterConfiguration *model) const +{ + opentelemetry::exporter::metrics::PrometheusExporterOptions options(nullptr); + + std::string url(model->host); + url.append(":"); + url.append(std::to_string(model->port)); + + options.url = url; + options.populate_target_info = true; + options.without_otel_scope = model->without_scope_info; + options.without_units = model->without_units; + options.without_type_suffix = model->without_type_suffix; + + return PrometheusExporterFactory::Create(options); +} + +} // namespace metrics +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/prometheus/test/exporter_utils_test.cc b/deps/opentelemetry-cpp/exporters/prometheus/test/exporter_utils_test.cc index c8a6254f3b8..4ad329f0ec0 100644 --- a/deps/opentelemetry-cpp/exporters/prometheus/test/exporter_utils_test.cc +++ b/deps/opentelemetry-cpp/exporters/prometheus/test/exporter_utils_test.cc @@ -102,18 +102,21 @@ void assert_basic(prometheus_client::MetricFamily &metric, switch (type) { case prometheus_client::MetricType::Counter: { - ASSERT_DOUBLE_EQ(metric_data.counter.value, vals[0]); + ASSERT_DOUBLE_EQ(static_cast(metric_data.counter.value), + static_cast(vals[0])); break; } case prometheus_client::MetricType::Histogram: { - ASSERT_DOUBLE_EQ(metric_data.histogram.sample_count, vals[0]); - ASSERT_DOUBLE_EQ(metric_data.histogram.sample_sum, vals[1]); + ASSERT_DOUBLE_EQ(static_cast(metric_data.histogram.sample_count), + static_cast(vals[0])); + ASSERT_DOUBLE_EQ(static_cast(metric_data.histogram.sample_sum), + static_cast(vals[1])); auto buckets = metric_data.histogram.bucket; ASSERT_EQ(buckets.size(), vals[2]); break; } case prometheus_client::MetricType::Gauge: { - ASSERT_DOUBLE_EQ(metric_data.gauge.value, vals[0]); + ASSERT_DOUBLE_EQ(static_cast(metric_data.gauge.value), static_cast(vals[0])); break; } break; diff --git a/deps/opentelemetry-cpp/exporters/zipkin/CMakeLists.txt b/deps/opentelemetry-cpp/exporters/zipkin/CMakeLists.txt index 548a9fd44d2..9fc92ba7a52 100644 --- a/deps/opentelemetry-cpp/exporters/zipkin/CMakeLists.txt +++ b/deps/opentelemetry-cpp/exporters/zipkin/CMakeLists.txt @@ -59,7 +59,7 @@ if(BUILD_TESTING) ${GMOCK_LIB} opentelemetry_exporter_zipkin_trace opentelemetry_resources - ${CURL_LIBRARIES}) + CURL::libcurl) gtest_add_tests( TARGET zipkin_exporter_test diff --git a/deps/opentelemetry-cpp/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_builder.h b/deps/opentelemetry-cpp/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_builder.h new file mode 100644 index 00000000000..c5d28d09cea --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_builder.h @@ -0,0 +1,33 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/configuration/zipkin_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/zipkin_span_exporter_configuration.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace zipkin +{ + +class OPENTELEMETRY_EXPORT ZipkinBuilder + : public opentelemetry::sdk::configuration::ZipkinSpanExporterBuilder +{ +public: + static void Register(opentelemetry::sdk::configuration::Registry *registry); + + std::unique_ptr Build( + const opentelemetry::sdk::configuration::ZipkinSpanExporterConfiguration *model) + const override; +}; + +} // namespace zipkin +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter_options.h b/deps/opentelemetry-cpp/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter_options.h index f5ee941d225..45cfef45dca 100644 --- a/deps/opentelemetry-cpp/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter_options.h +++ b/deps/opentelemetry-cpp/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter_options.h @@ -13,6 +13,7 @@ namespace exporter namespace zipkin { +// The endpoint to export to. By default the OpenTelemetry Collector's default endpoint. inline const std::string GetDefaultZipkinEndpoint() { const char *otel_exporter_zipkin_endpoint_env = "OTEL_EXPORTER_ZIPKIN_ENDPOINT"; @@ -36,8 +37,13 @@ enum class TransportFormat */ struct ZipkinExporterOptions { - // The endpoint to export to. By default the OpenTelemetry Collector's default endpoint. - std::string endpoint = GetDefaultZipkinEndpoint(); + // Lookup environment variables + ZipkinExporterOptions() : endpoint(GetDefaultZipkinEndpoint()) {} + + // No defaults + ZipkinExporterOptions(void *) : endpoint("") {} + + std::string endpoint; TransportFormat format = TransportFormat::kJson; std::string service_name = "default-service"; std::string ipv4; diff --git a/deps/opentelemetry-cpp/exporters/zipkin/src/zipkin_builder.cc b/deps/opentelemetry-cpp/exporters/zipkin/src/zipkin_builder.cc new file mode 100644 index 00000000000..a7bdc770d4c --- /dev/null +++ b/deps/opentelemetry-cpp/exporters/zipkin/src/zipkin_builder.cc @@ -0,0 +1,41 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include +#include + +#include "opentelemetry/exporters/zipkin/zipkin_builder.h" +#include "opentelemetry/exporters/zipkin/zipkin_exporter_factory.h" +#include "opentelemetry/exporters/zipkin/zipkin_exporter_options.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/configuration/zipkin_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/zipkin_span_exporter_configuration.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace zipkin +{ + +void ZipkinBuilder::Register(opentelemetry::sdk::configuration::Registry *registry) +{ + auto builder = std::make_unique(); + registry->SetZipkinSpanBuilder(std::move(builder)); +} + +std::unique_ptr ZipkinBuilder::Build( + const opentelemetry::sdk::configuration::ZipkinSpanExporterConfiguration *model) const +{ + ZipkinExporterOptions options(nullptr); + + options.endpoint = model->endpoint; + + return ZipkinExporterFactory::Create(options); +} + +} // namespace zipkin +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h b/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h index 77bd6bf89c4..1dc4e6a9050 100644 --- a/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h +++ b/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h @@ -323,6 +323,8 @@ class HttpClient : public opentelemetry::ext::http::client::HttpClient void SetMaxSessionsPerConnection(std::size_t max_requests_per_connection) noexcept override; + bool InternalCancelAllSessions() noexcept; + inline uint64_t GetMaxSessionsPerConnection() const noexcept { return max_sessions_per_connection_; diff --git a/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h b/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h index d180134cae6..76879fc1df9 100644 --- a/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h +++ b/deps/opentelemetry-cpp/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h @@ -338,6 +338,7 @@ class HttpOperation std::promise result_promise; std::future result_future; }; + friend class HttpOperationAccessor; std::unique_ptr async_data_; }; } // namespace curl diff --git a/deps/opentelemetry-cpp/ext/src/dll/input.src b/deps/opentelemetry-cpp/ext/src/dll/input.src index 661e01c1a73..9d6a529c5c8 100644 --- a/deps/opentelemetry-cpp/ext/src/dll/input.src +++ b/deps/opentelemetry-cpp/ext/src/dll/input.src @@ -16,6 +16,7 @@ ForceFlush@LoggerProvider@logs@sdk@v1@opentelemetry OStreamLogRecordExporter@logs@exporter@v1@opentelemetry Create@OStreamMetricExporterFactory@metrics@exporter@v1@opentelemetry Create@PeriodicExportingMetricReaderFactory@metrics@sdk@v1@opentelemetry +PeriodicExportingMetricReaderOptions@metrics@sdk@v1@opentelemetry Create@MeterProviderFactory@metrics@sdk@v1@opentelemetry Create@MeterContextFactory@metrics@sdk@v1@opentelemetry Create@ViewFactory@metrics@sdk@v1@opentelemetry diff --git a/deps/opentelemetry-cpp/ext/src/http/client/curl/CMakeLists.txt b/deps/opentelemetry-cpp/ext/src/http/client/curl/CMakeLists.txt index 0c1d8c61950..d238a1c4dd0 100644 --- a/deps/opentelemetry-cpp/ext/src/http/client/curl/CMakeLists.txt +++ b/deps/opentelemetry-cpp/ext/src/http/client/curl/CMakeLists.txt @@ -11,40 +11,10 @@ set_target_version(opentelemetry_http_client_curl) target_link_libraries(opentelemetry_http_client_curl PUBLIC opentelemetry_common) -unset(CURL_IMPORTED_TARGET_NAME) - -foreach(FIND_CURL_IMPORTED_TARGET CURL::libcurl CURL::libcurl_shared - CURL::libcurl_static) - if(TARGET ${FIND_CURL_IMPORTED_TARGET}) - set(CURL_IMPORTED_TARGET_NAME ${FIND_CURL_IMPORTED_TARGET}) - break() - endif() -endforeach() - -if(TARGET ${CURL_IMPORTED_TARGET_NAME}) - target_link_libraries( - opentelemetry_http_client_curl - PUBLIC opentelemetry_ext - PRIVATE ${CURL_IMPORTED_TARGET_NAME}) - - # Some versions of libcurl do not export the link directories, which may cause - # link errors - project_build_tools_get_imported_location(CURL_LIB_FILE_PATH - ${CURL_IMPORTED_TARGET_NAME}) - get_filename_component(CURL_LIB_DIR_PATH "${CURL_LIB_FILE_PATH}" DIRECTORY) - - if(CURL_LIB_DIR_PATH) - target_link_directories(opentelemetry_http_client_curl PUBLIC - "$") - endif() -else() - target_include_directories(opentelemetry_http_client_curl - INTERFACE "${CURL_INCLUDE_DIRS}") - target_link_libraries( - opentelemetry_http_client_curl - PUBLIC opentelemetry_ext - PRIVATE ${CURL_LIBRARIES}) -endif() +target_link_libraries( + opentelemetry_http_client_curl + PUBLIC opentelemetry_ext + PRIVATE CURL::libcurl) if(WITH_CURL_LOGGING) target_compile_definitions(opentelemetry_http_client_curl @@ -52,19 +22,10 @@ if(WITH_CURL_LOGGING) endif() if(WITH_OTLP_HTTP_COMPRESSION) - if(TARGET ZLIB::ZLIB) - target_link_libraries( - opentelemetry_http_client_curl - PUBLIC opentelemetry_ext - PRIVATE ZLIB::ZLIB) - else() - target_include_directories(opentelemetry_http_client_curl - INTERFACE "${ZLIB_INCLUDE_DIRS}") - target_link_libraries( - opentelemetry_http_client_curl - PUBLIC opentelemetry_ext - PRIVATE ${ZLIB_LIBRARIES}) - endif() + target_link_libraries( + opentelemetry_http_client_curl + PUBLIC opentelemetry_ext + PRIVATE ZLIB::ZLIB) endif() otel_add_component(COMPONENT ext_http_curl TARGETS diff --git a/deps/opentelemetry-cpp/ext/src/http/client/curl/http_client_curl.cc b/deps/opentelemetry-cpp/ext/src/http/client/curl/http_client_curl.cc index 71f5454d33a..77105398d37 100644 --- a/deps/opentelemetry-cpp/ext/src/http/client/curl/http_client_curl.cc +++ b/deps/opentelemetry-cpp/ext/src/http/client/curl/http_client_curl.cc @@ -101,13 +101,13 @@ int deflateInPlace(z_stream *strm, unsigned char *buf, uint32_t len, uint32_t *m have = 0; while (ret == Z_OK) { - strm->avail_out = - strm->avail_in ? strm->next_in - strm->next_out : (buf + *max_len) - strm->next_out; + strm->avail_out = static_cast( + strm->avail_in ? strm->next_in - strm->next_out : (buf + *max_len) - strm->next_out); ret = deflate(strm, Z_FINISH); } if (ret != Z_BUF_ERROR || strm->avail_in == 0) { - *max_len = strm->next_out - buf; + *max_len = static_cast(strm->next_out - buf); return ret == Z_STREAM_END ? Z_OK : ret; } } @@ -130,10 +130,10 @@ int deflateInPlace(z_stream *strm, unsigned char *buf, uint32_t len, uint32_t *m std::memcpy(buf, temp.data(), have); strm->next_out = buf + have; } - strm->avail_out = (buf + *max_len) - strm->next_out; + strm->avail_out = static_cast((buf + *max_len) - strm->next_out); ret = deflate(strm, Z_FINISH); strm->zfree(strm->opaque, hold); - *max_len = strm->next_out - buf; + *max_len = static_cast(strm->next_out - buf); return ret == Z_OK ? Z_BUF_ERROR : (ret == Z_STREAM_END ? Z_OK : ret); } #endif // ENABLE_OTLP_COMPRESSION_PREVIEW @@ -302,7 +302,7 @@ HttpClient::~HttpClient() } // Force to abort all sessions - CancelAllSessions(); + InternalCancelAllSessions(); if (!background_thread) { @@ -342,27 +342,7 @@ std::shared_ptr HttpClient::CreateSes bool HttpClient::CancelAllSessions() noexcept { - // CancelSession may change sessions_, we can not change a container while iterating it. - while (true) - { - std::unordered_map> sessions; - { - // We can only cleanup session and curl handles in the IO thread. - std::lock_guard lock_guard{sessions_m_}; - sessions = sessions_; - } - - if (sessions.empty()) - { - break; - } - - for (auto &session : sessions) - { - session.second->CancelSession(); - } - } - return true; + return InternalCancelAllSessions(); } bool HttpClient::FinishAllSessions() noexcept @@ -435,6 +415,31 @@ void HttpClient::CleanupSession(uint64_t session_id) } } +bool HttpClient::InternalCancelAllSessions() noexcept +{ + // CancelSession may change sessions_, we can not change a container while iterating it. + while (true) + { + std::unordered_map> sessions; + { + // We can only cleanup session and curl handles in the IO thread. + std::lock_guard lock_guard{sessions_m_}; + sessions = sessions_; + } + + if (sessions.empty()) + { + break; + } + + for (auto &session : sessions) + { + session.second->CancelSession(); + } + } + return true; +} + bool HttpClient::MaybeSpawnBackgroundThread() { std::lock_guard lock_guard{background_thread_m_}; diff --git a/deps/opentelemetry-cpp/ext/src/http/client/curl/http_operation_curl.cc b/deps/opentelemetry-cpp/ext/src/http/client/curl/http_operation_curl.cc index 042ae4fe631..3fd27c96342 100644 --- a/deps/opentelemetry-cpp/ext/src/http/client/curl/http_operation_curl.cc +++ b/deps/opentelemetry-cpp/ext/src/http/client/curl/http_operation_curl.cc @@ -47,6 +47,28 @@ namespace client namespace curl { +class HttpOperationAccessor +{ +public: + OPENTELEMETRY_SANITIZER_NO_THREAD static std::thread::id GetThreadId( + const HttpOperation::AsyncData &async_data) + { +#if !(defined(OPENTELEMETRY_HAVE_THREAD_SANITIZER) && OPENTELEMETRY_HAVE_THREAD_SANITIZER) + std::atomic_thread_fence(std::memory_order_acquire); +#endif + return async_data.callback_thread; + } + + OPENTELEMETRY_SANITIZER_NO_THREAD static void SetThreadId(HttpOperation::AsyncData &async_data, + std::thread::id thread_id) + { + async_data.callback_thread = thread_id; +#if !(defined(OPENTELEMETRY_HAVE_THREAD_SANITIZER) && OPENTELEMETRY_HAVE_THREAD_SANITIZER) + std::atomic_thread_fence(std::memory_order_release); +#endif + } +}; + size_t HttpOperation::WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp) { HttpOperation *self = reinterpret_cast(userp); @@ -335,7 +357,7 @@ HttpOperation::~HttpOperation() case opentelemetry::ext::http::client::SessionState::Sending: { if (async_data_ && async_data_->result_future.valid()) { - if (async_data_->callback_thread != std::this_thread::get_id()) + if (HttpOperationAccessor::GetThreadId(*async_data_) != std::this_thread::get_id()) { async_data_->result_future.wait(); last_curl_result_ = async_data_->result_future.get(); @@ -360,7 +382,7 @@ void HttpOperation::Finish() if (async_data_ && async_data_->result_future.valid()) { // We should not wait in callback from Cleanup() - if (async_data_->callback_thread != std::this_thread::get_id()) + if (HttpOperationAccessor::GetThreadId(*async_data_) != std::this_thread::get_id()) { async_data_->result_future.wait(); last_curl_result_ = async_data_->result_future.get(); @@ -412,9 +434,9 @@ void HttpOperation::Cleanup() callback.swap(async_data_->callback); if (callback) { - async_data_->callback_thread = std::this_thread::get_id(); + HttpOperationAccessor::SetThreadId(*async_data_, std::this_thread::get_id()); callback(*this); - async_data_->callback_thread = std::thread::id(); + HttpOperationAccessor::SetThreadId(*async_data_, std::thread::id()); } // Set value to promise to continue Finish() diff --git a/deps/opentelemetry-cpp/ext/test/http/CMakeLists.txt b/deps/opentelemetry-cpp/ext/test/http/CMakeLists.txt index f4d3774735e..b7707bd8c20 100644 --- a/deps/opentelemetry-cpp/ext/test/http/CMakeLists.txt +++ b/deps/opentelemetry-cpp/ext/test/http/CMakeLists.txt @@ -4,28 +4,10 @@ if(WITH_HTTP_CLIENT_CURL) set(FILENAME curl_http_test) add_executable(${FILENAME} ${FILENAME}.cc) - target_link_libraries(${FILENAME} ${GMOCK_LIB} ${GTEST_BOTH_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT}) - - unset(CURL_IMPORTED_TARGET_NAME) - - foreach(FIND_CURL_IMPORTED_TARGET CURL::libcurl CURL::libcurl_shared - CURL::libcurl_static) - if(TARGET ${FIND_CURL_IMPORTED_TARGET}) - set(CURL_IMPORTED_TARGET_NAME ${FIND_CURL_IMPORTED_TARGET}) - break() - endif() - endforeach() - - if(TARGET ${CURL_IMPORTED_TARGET_NAME}) - target_link_libraries(${FILENAME} opentelemetry_http_client_curl - opentelemetry_common ${CURL_IMPORTED_TARGET_NAME}) - else() - target_include_directories(${FILENAME} PRIVATE ${CURL_INCLUDE_DIRS}) - target_link_libraries(${FILENAME} ${CURL_LIBRARIES} - opentelemetry_http_client_curl opentelemetry_common) - endif() - + target_link_libraries( + ${FILENAME} + PRIVATE ${GMOCK_LIB} ${GTEST_BOTH_LIBRARIES} opentelemetry_http_client_curl + opentelemetry_common CURL::libcurl) gtest_add_tests( TARGET ${FILENAME} TEST_PREFIX ext.http.curl. diff --git a/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/CMakeLists.txt b/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/CMakeLists.txt index 53e7a27ccf8..095da7ad80e 100644 --- a/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/CMakeLists.txt +++ b/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/CMakeLists.txt @@ -6,4 +6,4 @@ target_link_libraries( w3c_tracecontext_http_test_server PRIVATE ${CMAKE_THREAD_LIBS_INIT} opentelemetry_trace opentelemetry_http_client_curl opentelemetry_exporter_ostream_span - ${CURL_LIBRARIES} nlohmann_json::nlohmann_json) + CURL::libcurl nlohmann_json::nlohmann_json) diff --git a/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/main.cc b/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/main.cc index cb07ca84600..1ee3a2d5116 100644 --- a/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/main.cc +++ b/deps/opentelemetry-cpp/ext/test/w3c_tracecontext_http_test_server/main.cc @@ -119,7 +119,7 @@ struct Uri size_t port_end = uri.substr(host_end + 1, std::string::npos).find('/'); host = uri.substr(0, host_end + 7); - port = std::stoi(uri.substr(7 + host_end + 1, port_end)); + port = static_cast(std::stoi(uri.substr(7 + host_end + 1, port_end))); path = uri.substr(host_end + port_end + 2, std::string::npos); } }; @@ -185,7 +185,7 @@ int main(int argc, char *argv[]) // The port the validation service listens to can be specified via the command line. if (argc > 1) { - port = atoi(argv[1]); + port = static_cast(atoi(argv[1])); } else { diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/common/circular_buffer.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/common/circular_buffer.h index a35498ecea0..943b250b1cf 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/common/circular_buffer.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/common/circular_buffer.h @@ -181,7 +181,7 @@ class CircularBuffer { return {}; } - auto data = data_.get(); + AtomicUniquePtr *data = data_.get(); if (tail_index < head_index) { return CircularBufferRange>{nostd::span>{ diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/common/custom_hash_equality.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/common/custom_hash_equality.h new file mode 100644 index 00000000000..d1b5555b3a4 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/common/custom_hash_equality.h @@ -0,0 +1,157 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include +#include +#include + +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace common +{ +/** + * + * FNV Hashing Utilities + * + * Implements FNV-1a hashing algorithm for 32-bit and 64-bit types. + * + * - FNV (Fowler–Noll–Vo) is a simple, fast, and widely used non-cryptographic hash. + * - FNV-1a is the recommended variant because it mixes input bits better. + * - We parameterize by type size (4 = 32-bit, 8 = 64-bit). + */ + +// Forward declaration for FNV prime constants +template +struct FnvPrime; + +// Specialization for 32-bit +template +struct FnvPrime +{ + static constexpr Ty value = static_cast(0x01000193U); +}; + +// Specialization for 64-bit +template +struct FnvPrime +{ + static constexpr Ty value = static_cast(0x100000001b3ULL); +}; + +// Forward declaration for FNV offset basis constants +template +struct FnvOffset; + +// Specialization for 32-bit +template +struct FnvOffset +{ + // 32-bit offset basis + static constexpr Ty value = static_cast(0x811C9DC5U); + + static constexpr Ty Fix(Ty hval) noexcept { return hval; } +}; + +// Specialization for 64-bit +template +struct FnvOffset +{ + // 64-bit offset basis + static constexpr Ty value = static_cast(0xCBF29CE484222325ULL); + + // Fix function: mix upper and lower bits for better distribution + static constexpr Ty Fix(Ty hval) noexcept { return hval ^ (hval >> 32); } +}; + +/** + * FNV-1a hash function + * + * @tparam Ty Hash integer type (std::size_t, uint32_t, uint64_t, etc.) + * @param buf Pointer to the input buffer + * @param len Length of the buffer + * @param hval Starting hash value (defaults to offset basis) + * @return Computed hash + */ +template +inline Ty Fnv1a(const void *buf, size_t len, Ty hval = FnvOffset::value) noexcept +{ + const unsigned char *bp = reinterpret_cast(buf); + const unsigned char *be = bp + len; + Ty prime = FnvPrime::value; + + while (bp < be) + { + hval ^= static_cast(*bp++); + hval *= prime; + } + return FnvOffset::Fix(hval); +} + +/** + * Hash and equality for nostd::string_view, enabling safe use in unordered_map + * without requiring null termination. + */ + +struct StringViewHash +{ +#if defined(OPENTELEMETRY_STL_VERSION) +# if OPENTELEMETRY_STL_VERSION >= 2020 + using is_transparent = void; +# endif +#endif + + std::size_t operator()(const std::string &s) const noexcept + { + return Fnv1a(s.data(), s.size()); + } + + std::size_t operator()(opentelemetry::nostd::string_view sv) const noexcept + { + return Fnv1a(sv.data(), sv.size()); + } +}; + +struct StringViewEqual +{ +#if defined(OPENTELEMETRY_STL_VERSION) +# if OPENTELEMETRY_STL_VERSION >= 2020 + using is_transparent = void; +# endif +#endif + + template + bool operator()(const Lhs &lhs, const Rhs &rhs) const noexcept + { + opentelemetry::nostd::string_view lsv(lhs); + opentelemetry::nostd::string_view rsv(rhs); + + return lsv.size() == rsv.size() && std::memcmp(lsv.data(), rsv.data(), lsv.size()) == 0; + } +}; + +/** + * Cross-platform heterogeneous lookup wrapper. + * Falls back to std::string construction on libc++ (macOS) and pre-c++20, + * but uses direct lookup on libstdc++ (Linux). + */ + +template +inline auto find_heterogeneous(MapType &&map, opentelemetry::nostd::string_view key) +{ +#if defined(_LIBCPP_VERSION) || \ + (!defined(OPENTELEMETRY_STL_VERSION) || OPENTELEMETRY_STL_VERSION < 2020) + return map.find(std::string(key)); +#else + // libstdc++ + C++20: heterogeneous lookup works + return map.find(key); +#endif +} +} // namespace common +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/configured_sdk.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/configured_sdk.h new file mode 100644 index 00000000000..c2205a8be31 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/configured_sdk.h @@ -0,0 +1,60 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/context/propagation/text_map_propagator.h" +#include "opentelemetry/sdk/configuration/configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/logs/logger_provider.h" +#include "opentelemetry/sdk/metrics/meter_provider.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +/** + * This class represents a fully configured SDK. + * A SDK contains various objects, like propagators and providers for each + * signals, that collectively describe the opentelemetry configuration. + */ +class ConfiguredSdk +{ +public: + static std::unique_ptr Create( + std::shared_ptr registry, + const std::unique_ptr &model); + + ConfiguredSdk() : resource(opentelemetry::sdk::resource::Resource::GetEmpty()) {} + + /** + * Install the SDK, so that an instrumented application can make calls + * to it. + * This methods sets the global provider singletons to point to the SDK. + */ + void Install(); + + /** + * Uninstall the SDK, so that an instrumented application no longer makes + * calls to it. + * This method clears the global provider singletons. + */ + void UnInstall(); + + opentelemetry::sdk::resource::Resource resource; + std::shared_ptr tracer_provider; + std::shared_ptr propagator; + std::shared_ptr meter_provider; + std::shared_ptr logger_provider; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/console_log_record_exporter_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/console_log_record_exporter_builder.h new file mode 100644 index 00000000000..29d99bec5c4 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/console_log_record_exporter_builder.h @@ -0,0 +1,36 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/console_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class ConsoleLogRecordExporterBuilder +{ +public: + ConsoleLogRecordExporterBuilder() = default; + ConsoleLogRecordExporterBuilder(ConsoleLogRecordExporterBuilder &&) = default; + ConsoleLogRecordExporterBuilder(const ConsoleLogRecordExporterBuilder &) = default; + ConsoleLogRecordExporterBuilder &operator=(ConsoleLogRecordExporterBuilder &&) = default; + ConsoleLogRecordExporterBuilder &operator=(const ConsoleLogRecordExporterBuilder &other) = + default; + virtual ~ConsoleLogRecordExporterBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::ConsoleLogRecordExporterConfiguration *model) + const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/console_push_metric_exporter_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/console_push_metric_exporter_builder.h new file mode 100644 index 00000000000..0fe0725aa72 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/console_push_metric_exporter_builder.h @@ -0,0 +1,36 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/console_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class ConsolePushMetricExporterBuilder +{ +public: + ConsolePushMetricExporterBuilder() = default; + ConsolePushMetricExporterBuilder(ConsolePushMetricExporterBuilder &&) = default; + ConsolePushMetricExporterBuilder(const ConsolePushMetricExporterBuilder &) = default; + ConsolePushMetricExporterBuilder &operator=(ConsolePushMetricExporterBuilder &&) = default; + ConsolePushMetricExporterBuilder &operator=(const ConsolePushMetricExporterBuilder &other) = + default; + virtual ~ConsolePushMetricExporterBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::ConsolePushMetricExporterConfiguration *model) + const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/console_span_exporter_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/console_span_exporter_builder.h new file mode 100644 index 00000000000..0db9ba9e5b9 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/console_span_exporter_builder.h @@ -0,0 +1,34 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/console_span_exporter_configuration.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class ConsoleSpanExporterBuilder +{ +public: + ConsoleSpanExporterBuilder() = default; + ConsoleSpanExporterBuilder(ConsoleSpanExporterBuilder &&) = default; + ConsoleSpanExporterBuilder(const ConsoleSpanExporterBuilder &) = default; + ConsoleSpanExporterBuilder &operator=(ConsoleSpanExporterBuilder &&) = default; + ConsoleSpanExporterBuilder &operator=(const ConsoleSpanExporterBuilder &other) = default; + virtual ~ConsoleSpanExporterBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::ConsoleSpanExporterConfiguration *model) const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_log_record_exporter_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_log_record_exporter_builder.h new file mode 100644 index 00000000000..e9a7c102cb8 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_log_record_exporter_builder.h @@ -0,0 +1,36 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/extension_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class ExtensionLogRecordExporterBuilder +{ +public: + ExtensionLogRecordExporterBuilder() = default; + ExtensionLogRecordExporterBuilder(ExtensionLogRecordExporterBuilder &&) = default; + ExtensionLogRecordExporterBuilder(const ExtensionLogRecordExporterBuilder &) = default; + ExtensionLogRecordExporterBuilder &operator=(ExtensionLogRecordExporterBuilder &&) = default; + ExtensionLogRecordExporterBuilder &operator=(const ExtensionLogRecordExporterBuilder &other) = + default; + virtual ~ExtensionLogRecordExporterBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::ExtensionLogRecordExporterConfiguration *model) + const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_log_record_processor_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_log_record_processor_builder.h new file mode 100644 index 00000000000..51d21fd0107 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_log_record_processor_builder.h @@ -0,0 +1,36 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/extension_log_record_processor_configuration.h" +#include "opentelemetry/sdk/logs/processor.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class ExtensionLogRecordProcessorBuilder +{ +public: + ExtensionLogRecordProcessorBuilder() = default; + ExtensionLogRecordProcessorBuilder(ExtensionLogRecordProcessorBuilder &&) = default; + ExtensionLogRecordProcessorBuilder(const ExtensionLogRecordProcessorBuilder &) = default; + ExtensionLogRecordProcessorBuilder &operator=(ExtensionLogRecordProcessorBuilder &&) = default; + ExtensionLogRecordProcessorBuilder &operator=(const ExtensionLogRecordProcessorBuilder &other) = + default; + virtual ~ExtensionLogRecordProcessorBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::ExtensionLogRecordProcessorConfiguration *model) + const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_metric_producer_configuration.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_metric_producer_configuration.h new file mode 100644 index 00000000000..f715e12f065 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_metric_producer_configuration.h @@ -0,0 +1,34 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include +#include + +#include "opentelemetry/sdk/configuration/document_node.h" +#include "opentelemetry/sdk/configuration/metric_producer_configuration.h" +#include "opentelemetry/sdk/configuration/metric_producer_configuration_visitor.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class ExtensionMetricProducerConfiguration : public MetricProducerConfiguration +{ +public: + void Accept(MetricProducerConfigurationVisitor *visitor) const override + { + visitor->VisitExtension(this); + } + + std::string name; + std::unique_ptr node; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_pull_metric_exporter_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_pull_metric_exporter_builder.h new file mode 100644 index 00000000000..fc621c2b780 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_pull_metric_exporter_builder.h @@ -0,0 +1,36 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/extension_pull_metric_exporter_configuration.h" +#include "opentelemetry/sdk/metrics/metric_reader.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class ExtensionPullMetricExporterBuilder +{ +public: + ExtensionPullMetricExporterBuilder() = default; + ExtensionPullMetricExporterBuilder(ExtensionPullMetricExporterBuilder &&) = default; + ExtensionPullMetricExporterBuilder(const ExtensionPullMetricExporterBuilder &) = default; + ExtensionPullMetricExporterBuilder &operator=(ExtensionPullMetricExporterBuilder &&) = default; + ExtensionPullMetricExporterBuilder &operator=(const ExtensionPullMetricExporterBuilder &other) = + default; + virtual ~ExtensionPullMetricExporterBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::ExtensionPullMetricExporterConfiguration *model) + const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_push_metric_exporter_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_push_metric_exporter_builder.h new file mode 100644 index 00000000000..b3eacfc770c --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_push_metric_exporter_builder.h @@ -0,0 +1,36 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/extension_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class ExtensionPushMetricExporterBuilder +{ +public: + ExtensionPushMetricExporterBuilder() = default; + ExtensionPushMetricExporterBuilder(ExtensionPushMetricExporterBuilder &&) = default; + ExtensionPushMetricExporterBuilder(const ExtensionPushMetricExporterBuilder &) = default; + ExtensionPushMetricExporterBuilder &operator=(ExtensionPushMetricExporterBuilder &&) = default; + ExtensionPushMetricExporterBuilder &operator=(const ExtensionPushMetricExporterBuilder &other) = + default; + virtual ~ExtensionPushMetricExporterBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::ExtensionPushMetricExporterConfiguration *model) + const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_sampler_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_sampler_builder.h new file mode 100644 index 00000000000..3ac5d7263b2 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_sampler_builder.h @@ -0,0 +1,34 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/extension_sampler_configuration.h" +#include "opentelemetry/sdk/trace/sampler.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class ExtensionSamplerBuilder +{ +public: + ExtensionSamplerBuilder() = default; + ExtensionSamplerBuilder(ExtensionSamplerBuilder &&) = default; + ExtensionSamplerBuilder(const ExtensionSamplerBuilder &) = default; + ExtensionSamplerBuilder &operator=(ExtensionSamplerBuilder &&) = default; + ExtensionSamplerBuilder &operator=(const ExtensionSamplerBuilder &other) = default; + virtual ~ExtensionSamplerBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::ExtensionSamplerConfiguration *model) const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_span_exporter_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_span_exporter_builder.h new file mode 100644 index 00000000000..50a5ac12d7a --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_span_exporter_builder.h @@ -0,0 +1,34 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/extension_span_exporter_configuration.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class ExtensionSpanExporterBuilder +{ +public: + ExtensionSpanExporterBuilder() = default; + ExtensionSpanExporterBuilder(ExtensionSpanExporterBuilder &&) = default; + ExtensionSpanExporterBuilder(const ExtensionSpanExporterBuilder &) = default; + ExtensionSpanExporterBuilder &operator=(ExtensionSpanExporterBuilder &&) = default; + ExtensionSpanExporterBuilder &operator=(const ExtensionSpanExporterBuilder &other) = default; + virtual ~ExtensionSpanExporterBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::ExtensionSpanExporterConfiguration *model) const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_span_processor_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_span_processor_builder.h new file mode 100644 index 00000000000..86732e78171 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/extension_span_processor_builder.h @@ -0,0 +1,35 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/extension_span_processor_configuration.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class ExtensionSpanProcessorBuilder +{ +public: + ExtensionSpanProcessorBuilder() = default; + ExtensionSpanProcessorBuilder(ExtensionSpanProcessorBuilder &&) = default; + ExtensionSpanProcessorBuilder(const ExtensionSpanProcessorBuilder &) = default; + ExtensionSpanProcessorBuilder &operator=(ExtensionSpanProcessorBuilder &&) = default; + ExtensionSpanProcessorBuilder &operator=(const ExtensionSpanProcessorBuilder &other) = default; + virtual ~ExtensionSpanProcessorBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::ExtensionSpanProcessorConfiguration *model) + const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/metric_producer_configuration_visitor.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/metric_producer_configuration_visitor.h new file mode 100644 index 00000000000..73340f31664 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/metric_producer_configuration_visitor.h @@ -0,0 +1,34 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class OpenCensusMetricProducerConfiguration; +class ExtensionMetricProducerConfiguration; + +class MetricProducerConfigurationVisitor +{ +public: + MetricProducerConfigurationVisitor() = default; + MetricProducerConfigurationVisitor(MetricProducerConfigurationVisitor &&) = default; + MetricProducerConfigurationVisitor(const MetricProducerConfigurationVisitor &) = default; + MetricProducerConfigurationVisitor &operator=(MetricProducerConfigurationVisitor &&) = default; + MetricProducerConfigurationVisitor &operator=(const MetricProducerConfigurationVisitor &other) = + default; + virtual ~MetricProducerConfigurationVisitor() = default; + + virtual void VisitOpenCensus(const OpenCensusMetricProducerConfiguration *model) = 0; + virtual void VisitExtension(const ExtensionMetricProducerConfiguration *model) = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/open_census_metric_producer_configuration.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/open_census_metric_producer_configuration.h new file mode 100644 index 00000000000..b8b7eb6b663 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/open_census_metric_producer_configuration.h @@ -0,0 +1,31 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/metric_producer_configuration.h" +#include "opentelemetry/sdk/configuration/metric_producer_configuration_visitor.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +// YAML-SCHEMA: schema/meter_provider.json +// YAML-NODE: OpenCensusMetricProducer +class OpenCensusMetricProducerConfiguration : public MetricProducerConfiguration +{ +public: + void Accept(MetricProducerConfigurationVisitor *visitor) const override + { + visitor->VisitOpenCensus(this); + } +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_file_log_record_exporter_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_file_log_record_exporter_builder.h new file mode 100644 index 00000000000..c7be2657ccf --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_file_log_record_exporter_builder.h @@ -0,0 +1,36 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/otlp_file_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class OtlpFileLogRecordExporterBuilder +{ +public: + OtlpFileLogRecordExporterBuilder() = default; + OtlpFileLogRecordExporterBuilder(OtlpFileLogRecordExporterBuilder &&) = default; + OtlpFileLogRecordExporterBuilder(const OtlpFileLogRecordExporterBuilder &) = default; + OtlpFileLogRecordExporterBuilder &operator=(OtlpFileLogRecordExporterBuilder &&) = default; + OtlpFileLogRecordExporterBuilder &operator=(const OtlpFileLogRecordExporterBuilder &other) = + default; + virtual ~OtlpFileLogRecordExporterBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::OtlpFileLogRecordExporterConfiguration *model) + const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_file_push_metric_exporter_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_file_push_metric_exporter_builder.h new file mode 100644 index 00000000000..79d60f1ca48 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_file_push_metric_exporter_builder.h @@ -0,0 +1,37 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/otlp_file_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class OtlpFilePushMetricExporterBuilder +{ +public: + OtlpFilePushMetricExporterBuilder() = default; + OtlpFilePushMetricExporterBuilder(OtlpFilePushMetricExporterBuilder &&) = default; + OtlpFilePushMetricExporterBuilder(const OtlpFilePushMetricExporterBuilder &) = default; + OtlpFilePushMetricExporterBuilder &operator=(OtlpFilePushMetricExporterBuilder &&) = default; + OtlpFilePushMetricExporterBuilder &operator=(const OtlpFilePushMetricExporterBuilder &other) = + default; + virtual ~OtlpFilePushMetricExporterBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::OtlpFilePushMetricExporterConfiguration *model) + const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_file_span_exporter_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_file_span_exporter_builder.h new file mode 100644 index 00000000000..c2bec566dfe --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_file_span_exporter_builder.h @@ -0,0 +1,34 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/otlp_file_span_exporter_configuration.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class OtlpFileSpanExporterBuilder +{ +public: + OtlpFileSpanExporterBuilder() = default; + OtlpFileSpanExporterBuilder(OtlpFileSpanExporterBuilder &&) = default; + OtlpFileSpanExporterBuilder(const OtlpFileSpanExporterBuilder &) = default; + OtlpFileSpanExporterBuilder &operator=(OtlpFileSpanExporterBuilder &&) = default; + OtlpFileSpanExporterBuilder &operator=(const OtlpFileSpanExporterBuilder &other) = default; + virtual ~OtlpFileSpanExporterBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::OtlpFileSpanExporterConfiguration *model) const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_log_record_exporter_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_log_record_exporter_builder.h new file mode 100644 index 00000000000..e560e6bc7da --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_log_record_exporter_builder.h @@ -0,0 +1,36 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/otlp_grpc_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class OtlpGrpcLogRecordExporterBuilder +{ +public: + OtlpGrpcLogRecordExporterBuilder() = default; + OtlpGrpcLogRecordExporterBuilder(OtlpGrpcLogRecordExporterBuilder &&) = default; + OtlpGrpcLogRecordExporterBuilder(const OtlpGrpcLogRecordExporterBuilder &) = default; + OtlpGrpcLogRecordExporterBuilder &operator=(OtlpGrpcLogRecordExporterBuilder &&) = default; + OtlpGrpcLogRecordExporterBuilder &operator=(const OtlpGrpcLogRecordExporterBuilder &other) = + default; + virtual ~OtlpGrpcLogRecordExporterBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::OtlpGrpcLogRecordExporterConfiguration *model) + const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_push_metric_exporter_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_push_metric_exporter_builder.h new file mode 100644 index 00000000000..61adf7c0892 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_push_metric_exporter_builder.h @@ -0,0 +1,37 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/otlp_grpc_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class OtlpGrpcPushMetricExporterBuilder +{ +public: + OtlpGrpcPushMetricExporterBuilder() = default; + OtlpGrpcPushMetricExporterBuilder(OtlpGrpcPushMetricExporterBuilder &&) = default; + OtlpGrpcPushMetricExporterBuilder(const OtlpGrpcPushMetricExporterBuilder &) = default; + OtlpGrpcPushMetricExporterBuilder &operator=(OtlpGrpcPushMetricExporterBuilder &&) = default; + OtlpGrpcPushMetricExporterBuilder &operator=(const OtlpGrpcPushMetricExporterBuilder &other) = + default; + virtual ~OtlpGrpcPushMetricExporterBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::OtlpGrpcPushMetricExporterConfiguration *model) + const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_span_exporter_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_span_exporter_builder.h new file mode 100644 index 00000000000..79550ee830f --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_span_exporter_builder.h @@ -0,0 +1,34 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/otlp_grpc_span_exporter_configuration.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class OtlpGrpcSpanExporterBuilder +{ +public: + OtlpGrpcSpanExporterBuilder() = default; + OtlpGrpcSpanExporterBuilder(OtlpGrpcSpanExporterBuilder &&) = default; + OtlpGrpcSpanExporterBuilder(const OtlpGrpcSpanExporterBuilder &) = default; + OtlpGrpcSpanExporterBuilder &operator=(OtlpGrpcSpanExporterBuilder &&) = default; + OtlpGrpcSpanExporterBuilder &operator=(const OtlpGrpcSpanExporterBuilder &other) = default; + virtual ~OtlpGrpcSpanExporterBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::OtlpGrpcSpanExporterConfiguration *model) const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_http_log_record_exporter_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_http_log_record_exporter_builder.h new file mode 100644 index 00000000000..a8d1313da42 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_http_log_record_exporter_builder.h @@ -0,0 +1,36 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/otlp_http_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class OtlpHttpLogRecordExporterBuilder +{ +public: + OtlpHttpLogRecordExporterBuilder() = default; + OtlpHttpLogRecordExporterBuilder(OtlpHttpLogRecordExporterBuilder &&) = default; + OtlpHttpLogRecordExporterBuilder(const OtlpHttpLogRecordExporterBuilder &) = default; + OtlpHttpLogRecordExporterBuilder &operator=(OtlpHttpLogRecordExporterBuilder &&) = default; + OtlpHttpLogRecordExporterBuilder &operator=(const OtlpHttpLogRecordExporterBuilder &other) = + default; + virtual ~OtlpHttpLogRecordExporterBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::OtlpHttpLogRecordExporterConfiguration *model) + const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_http_push_metric_exporter_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_http_push_metric_exporter_builder.h new file mode 100644 index 00000000000..c407eca52c1 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_http_push_metric_exporter_builder.h @@ -0,0 +1,37 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/otlp_http_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class OtlpHttpPushMetricExporterBuilder +{ +public: + OtlpHttpPushMetricExporterBuilder() = default; + OtlpHttpPushMetricExporterBuilder(OtlpHttpPushMetricExporterBuilder &&) = default; + OtlpHttpPushMetricExporterBuilder(const OtlpHttpPushMetricExporterBuilder &) = default; + OtlpHttpPushMetricExporterBuilder &operator=(OtlpHttpPushMetricExporterBuilder &&) = default; + OtlpHttpPushMetricExporterBuilder &operator=(const OtlpHttpPushMetricExporterBuilder &other) = + default; + virtual ~OtlpHttpPushMetricExporterBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::OtlpHttpPushMetricExporterConfiguration *model) + const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_http_span_exporter_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_http_span_exporter_builder.h new file mode 100644 index 00000000000..8dda6f2b9e7 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/otlp_http_span_exporter_builder.h @@ -0,0 +1,34 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/otlp_http_span_exporter_configuration.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class OtlpHttpSpanExporterBuilder +{ +public: + OtlpHttpSpanExporterBuilder() = default; + OtlpHttpSpanExporterBuilder(OtlpHttpSpanExporterBuilder &&) = default; + OtlpHttpSpanExporterBuilder(const OtlpHttpSpanExporterBuilder &) = default; + OtlpHttpSpanExporterBuilder &operator=(OtlpHttpSpanExporterBuilder &&) = default; + OtlpHttpSpanExporterBuilder &operator=(const OtlpHttpSpanExporterBuilder &other) = default; + virtual ~OtlpHttpSpanExporterBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::OtlpHttpSpanExporterConfiguration *model) const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_builder.h new file mode 100644 index 00000000000..4a4496dc490 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_builder.h @@ -0,0 +1,36 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_configuration.h" +#include "opentelemetry/sdk/metrics/metric_reader.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class PrometheusPullMetricExporterBuilder +{ +public: + PrometheusPullMetricExporterBuilder() = default; + PrometheusPullMetricExporterBuilder(PrometheusPullMetricExporterBuilder &&) = default; + PrometheusPullMetricExporterBuilder(const PrometheusPullMetricExporterBuilder &) = default; + PrometheusPullMetricExporterBuilder &operator=(PrometheusPullMetricExporterBuilder &&) = default; + PrometheusPullMetricExporterBuilder &operator=(const PrometheusPullMetricExporterBuilder &other) = + default; + virtual ~PrometheusPullMetricExporterBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::PrometheusPullMetricExporterConfiguration *model) + const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/propagator_configuration.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/propagator_configuration.h index cd1f7693d07..b2f6e476aed 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/propagator_configuration.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/propagator_configuration.h @@ -20,6 +20,7 @@ class PropagatorConfiguration { public: std::vector composite; + std::string composite_list; }; } // namespace configuration diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/registry.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/registry.h new file mode 100644 index 00000000000..81d38d2ef65 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/registry.h @@ -0,0 +1,283 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include +#include + +#include "opentelemetry/sdk/configuration/console_log_record_exporter_builder.h" +#include "opentelemetry/sdk/configuration/console_push_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/console_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/extension_log_record_exporter_builder.h" +#include "opentelemetry/sdk/configuration/extension_log_record_processor_builder.h" +#include "opentelemetry/sdk/configuration/extension_pull_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/extension_push_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/extension_sampler_builder.h" +#include "opentelemetry/sdk/configuration/extension_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/extension_span_processor_builder.h" +#include "opentelemetry/sdk/configuration/otlp_file_log_record_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_file_push_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_file_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_log_record_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_push_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_http_log_record_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_http_push_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_http_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/text_map_propagator_builder.h" +#include "opentelemetry/sdk/configuration/zipkin_span_exporter_builder.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class Registry +{ +public: + Registry(); + Registry(Registry &&) = delete; + Registry(const Registry &) = delete; + Registry &operator=(Registry &&) = delete; + Registry &operator=(const Registry &other) = delete; + + ~Registry() = default; + + /* Core optional components. */ + + const OtlpHttpSpanExporterBuilder *GetOtlpHttpSpanBuilder() const + { + return otlp_http_span_builder_.get(); + } + + void SetOtlpHttpSpanBuilder(std::unique_ptr &&builder) + { + otlp_http_span_builder_ = std::move(builder); + } + + const OtlpGrpcSpanExporterBuilder *GetOtlpGrpcSpanBuilder() const + { + return otlp_grpc_span_builder_.get(); + } + + void SetOtlpGrpcSpanBuilder(std::unique_ptr &&builder) + { + otlp_grpc_span_builder_ = std::move(builder); + } + + const OtlpFileSpanExporterBuilder *GetOtlpFileSpanBuilder() const + { + return otlp_file_span_builder_.get(); + } + + void SetOtlpFileSpanBuilder(std::unique_ptr &&builder) + { + otlp_file_span_builder_ = std::move(builder); + } + + const ConsoleSpanExporterBuilder *GetConsoleSpanBuilder() const + { + return console_span_builder_.get(); + } + + void SetConsoleSpanBuilder(std::unique_ptr &&builder) + { + console_span_builder_ = std::move(builder); + } + + const ZipkinSpanExporterBuilder *GetZipkinSpanBuilder() const + { + return zipkin_span_builder_.get(); + } + + void SetZipkinSpanBuilder(std::unique_ptr &&builder) + { + zipkin_span_builder_ = std::move(builder); + } + + const OtlpHttpPushMetricExporterBuilder *GetOtlpHttpPushMetricExporterBuilder() const + { + return otlp_http_push_metric_builder_.get(); + } + + void SetOtlpHttpPushMetricExporterBuilder( + std::unique_ptr &&builder) + { + otlp_http_push_metric_builder_ = std::move(builder); + } + + const OtlpGrpcPushMetricExporterBuilder *GetOtlpGrpcPushMetricExporterBuilder() const + { + return otlp_grpc_push_metric_builder_.get(); + } + + void SetOtlpGrpcPushMetricExporterBuilder( + std::unique_ptr &&builder) + { + otlp_grpc_push_metric_builder_ = std::move(builder); + } + + const OtlpFilePushMetricExporterBuilder *GetOtlpFilePushMetricExporterBuilder() const + { + return otlp_file_push_metric_builder_.get(); + } + + void SetOtlpFilePushMetricExporterBuilder( + std::unique_ptr &&builder) + { + otlp_file_push_metric_builder_ = std::move(builder); + } + + const ConsolePushMetricExporterBuilder *GetConsolePushMetricExporterBuilder() const + { + return console_metric_builder_.get(); + } + + void SetConsolePushMetricExporterBuilder( + std::unique_ptr &&builder) + { + console_metric_builder_ = std::move(builder); + } + + const PrometheusPullMetricExporterBuilder *GetPrometheusPullMetricExporterBuilder() const + { + return prometheus_metric_builder_.get(); + } + + void SetPrometheusPullMetricExporterBuilder( + std::unique_ptr &&builder) + { + prometheus_metric_builder_ = std::move(builder); + } + + const OtlpHttpLogRecordExporterBuilder *GetOtlpHttpLogRecordBuilder() const + { + return otlp_http_log_record_builder_.get(); + } + + void SetOtlpHttpLogRecordBuilder(std::unique_ptr &&builder) + { + otlp_http_log_record_builder_ = std::move(builder); + } + + const OtlpGrpcLogRecordExporterBuilder *GetOtlpGrpcLogRecordBuilder() const + { + return otlp_grpc_log_record_builder_.get(); + } + + void SetOtlpGrpcLogRecordBuilder(std::unique_ptr &&builder) + { + otlp_grpc_log_record_builder_ = std::move(builder); + } + + const OtlpFileLogRecordExporterBuilder *GetOtlpFileLogRecordBuilder() const + { + return otlp_file_log_record_builder_.get(); + } + + void SetOtlpFileLogRecordBuilder(std::unique_ptr &&builder) + { + otlp_file_log_record_builder_ = std::move(builder); + } + + const ConsoleLogRecordExporterBuilder *GetConsoleLogRecordBuilder() const + { + return console_log_record_builder_.get(); + } + + void SetConsoleLogRecordBuilder(std::unique_ptr &&builder) + { + console_log_record_builder_ = std::move(builder); + } + + /* Extension points */ + + const TextMapPropagatorBuilder *GetTextMapPropagatorBuilder(const std::string &name) const; + + void SetTextMapPropagatorBuilder(const std::string &name, + std::unique_ptr &&builder); + + const ExtensionSamplerBuilder *GetExtensionSamplerBuilder(const std::string &name) const; + + void SetExtensionSamplerBuilder(const std::string &name, + std::unique_ptr &&builder); + + const ExtensionSpanExporterBuilder *GetExtensionSpanExporterBuilder( + const std::string &name) const; + + void SetExtensionSpanExporterBuilder(const std::string &name, + std::unique_ptr &&builder); + + const ExtensionSpanProcessorBuilder *GetExtensionSpanProcessorBuilder( + const std::string &name) const; + + void SetExtensionSpanProcessorBuilder(const std::string &name, + std::unique_ptr &&builder); + + const ExtensionPushMetricExporterBuilder *GetExtensionPushMetricExporterBuilder( + const std::string &name) const; + + void SetExtensionPushMetricExporterBuilder( + const std::string &name, + std::unique_ptr &&builder); + + const ExtensionPullMetricExporterBuilder *GetExtensionPullMetricExporterBuilder( + const std::string &name) const; + + void SetExtensionPullMetricExporterBuilder( + const std::string &name, + std::unique_ptr &&builder); + + const ExtensionLogRecordExporterBuilder *GetExtensionLogRecordExporterBuilder( + const std::string &name) const; + + void SetExtensionLogRecordExporterBuilder( + const std::string &name, + std::unique_ptr &&builder); + + const ExtensionLogRecordProcessorBuilder *GetExtensionLogRecordProcessorBuilder( + const std::string &name) const; + + void SetExtensionLogRecordProcessorBuilder( + const std::string &name, + std::unique_ptr &&builder); + +private: + std::unique_ptr otlp_http_span_builder_; + std::unique_ptr otlp_grpc_span_builder_; + std::unique_ptr otlp_file_span_builder_; + std::unique_ptr console_span_builder_; + std::unique_ptr zipkin_span_builder_; + + std::unique_ptr otlp_http_push_metric_builder_; + std::unique_ptr otlp_grpc_push_metric_builder_; + std::unique_ptr otlp_file_push_metric_builder_; + std::unique_ptr console_metric_builder_; + std::unique_ptr prometheus_metric_builder_; + + std::unique_ptr otlp_http_log_record_builder_; + std::unique_ptr otlp_grpc_log_record_builder_; + std::unique_ptr otlp_file_log_record_builder_; + std::unique_ptr console_log_record_builder_; + + std::map> propagator_builders_; + std::map> sampler_builders_; + std::map> span_exporter_builders_; + std::map> span_processor_builders_; + std::map> + push_metric_exporter_builders_; + std::map> + pull_metric_exporter_builders_; + std::map> + log_record_exporter_builders_; + std::map> + log_record_processor_builders_; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/sdk_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/sdk_builder.h new file mode 100644 index 00000000000..9f31ba68e01 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/sdk_builder.h @@ -0,0 +1,271 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/always_off_sampler_configuration.h" +#include "opentelemetry/sdk/configuration/base2_exponential_bucket_histogram_aggregation_configuration.h" +#include "opentelemetry/sdk/configuration/batch_log_record_processor_configuration.h" +#include "opentelemetry/sdk/configuration/batch_span_processor_configuration.h" +#include "opentelemetry/sdk/configuration/boolean_array_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/boolean_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/configuration.h" +#include "opentelemetry/sdk/configuration/configured_sdk.h" +#include "opentelemetry/sdk/configuration/console_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/console_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/double_array_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/double_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/explicit_bucket_histogram_aggregation_configuration.h" +#include "opentelemetry/sdk/configuration/extension_pull_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/extension_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/extension_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/extension_span_processor_configuration.h" +#include "opentelemetry/sdk/configuration/integer_array_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/integer_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/metric_reader_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_file_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_file_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_file_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_http_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_http_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_http_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/periodic_metric_reader_configuration.h" +#include "opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/pull_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/pull_metric_reader_configuration.h" +#include "opentelemetry/sdk/configuration/push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/configuration/simple_span_processor_configuration.h" +#include "opentelemetry/sdk/configuration/span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/string_array_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/string_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/zipkin_span_exporter_configuration.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/sdk/logs/logger_provider.h" +#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader.h" +#include "opentelemetry/sdk/metrics/meter_provider.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/sampler.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" +#include "opentelemetry/trace/tracer_provider.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class SdkBuilder +{ +public: + SdkBuilder(std::shared_ptr registry) : registry_(std::move(registry)) {} + SdkBuilder(SdkBuilder &&) = default; + SdkBuilder(const SdkBuilder &) = default; + SdkBuilder &operator=(SdkBuilder &&) = default; + SdkBuilder &operator=(const SdkBuilder &other) = default; + ~SdkBuilder() = default; + + std::unique_ptr CreateAlwaysOffSampler( + const opentelemetry::sdk::configuration::AlwaysOffSamplerConfiguration *model) const; + + std::unique_ptr CreateAlwaysOnSampler( + const opentelemetry::sdk::configuration::AlwaysOnSamplerConfiguration *model) const; + + std::unique_ptr CreateJaegerRemoteSampler( + const opentelemetry::sdk::configuration::JaegerRemoteSamplerConfiguration *model) const; + + std::unique_ptr CreateParentBasedSampler( + const opentelemetry::sdk::configuration::ParentBasedSamplerConfiguration *model) const; + + std::unique_ptr CreateTraceIdRatioBasedSampler( + const opentelemetry::sdk::configuration::TraceIdRatioBasedSamplerConfiguration *model) const; + + std::unique_ptr CreateExtensionSampler( + const opentelemetry::sdk::configuration::ExtensionSamplerConfiguration *model) const; + + std::unique_ptr CreateSampler( + const std::unique_ptr &model) const; + + std::unique_ptr CreateOtlpHttpSpanExporter( + const opentelemetry::sdk::configuration::OtlpHttpSpanExporterConfiguration *model) const; + + std::unique_ptr CreateOtlpGrpcSpanExporter( + const opentelemetry::sdk::configuration::OtlpGrpcSpanExporterConfiguration *model) const; + + std::unique_ptr CreateOtlpFileSpanExporter( + const opentelemetry::sdk::configuration::OtlpFileSpanExporterConfiguration *model) const; + + std::unique_ptr CreateConsoleSpanExporter( + const opentelemetry::sdk::configuration::ConsoleSpanExporterConfiguration *model) const; + + std::unique_ptr CreateZipkinSpanExporter( + const opentelemetry::sdk::configuration::ZipkinSpanExporterConfiguration *model) const; + + std::unique_ptr CreateExtensionSpanExporter( + const opentelemetry::sdk::configuration::ExtensionSpanExporterConfiguration *model) const; + + std::unique_ptr CreateSpanExporter( + const std::unique_ptr &model) + const; + + std::unique_ptr CreateBatchSpanProcessor( + const opentelemetry::sdk::configuration::BatchSpanProcessorConfiguration *model) const; + + std::unique_ptr CreateSimpleSpanProcessor( + const opentelemetry::sdk::configuration::SimpleSpanProcessorConfiguration *model) const; + + std::unique_ptr CreateExtensionSpanProcessor( + const opentelemetry::sdk::configuration::ExtensionSpanProcessorConfiguration *model) const; + + std::unique_ptr CreateSpanProcessor( + const std::unique_ptr &model) + const; + + std::unique_ptr CreateTracerProvider( + const std::unique_ptr &model, + const opentelemetry::sdk::resource::Resource &resource) const; + + std::unique_ptr CreateTextMapPropagator( + const std::string &name) const; + + std::unique_ptr CreatePropagator( + const std::unique_ptr &model) + const; + + std::unique_ptr CreateOtlpHttpPushMetricExporter( + const opentelemetry::sdk::configuration::OtlpHttpPushMetricExporterConfiguration *model) + const; + + std::unique_ptr CreateOtlpGrpcPushMetricExporter( + const opentelemetry::sdk::configuration::OtlpGrpcPushMetricExporterConfiguration *model) + const; + + std::unique_ptr CreateOtlpFilePushMetricExporter( + const opentelemetry::sdk::configuration::OtlpFilePushMetricExporterConfiguration *model) + const; + + std::unique_ptr CreateConsolePushMetricExporter( + const opentelemetry::sdk::configuration::ConsolePushMetricExporterConfiguration *model) const; + + std::unique_ptr + CreateExtensionPushMetricExporter( + const opentelemetry::sdk::configuration::ExtensionPushMetricExporterConfiguration *model) + const; + + std::unique_ptr CreatePrometheusPullMetricExporter( + const opentelemetry::sdk::configuration::PrometheusPullMetricExporterConfiguration *model) + const; + + std::unique_ptr CreateExtensionPullMetricExporter( + const opentelemetry::sdk::configuration::ExtensionPullMetricExporterConfiguration *model) + const; + + std::unique_ptr CreatePushMetricExporter( + const std::unique_ptr + &model) const; + + std::unique_ptr CreatePullMetricExporter( + const std::unique_ptr + &model) const; + + std::unique_ptr CreatePeriodicMetricReader( + const opentelemetry::sdk::configuration::PeriodicMetricReaderConfiguration *model) const; + + std::unique_ptr CreatePullMetricReader( + const opentelemetry::sdk::configuration::PullMetricReaderConfiguration *model) const; + + std::unique_ptr CreateMetricReader( + const std::unique_ptr &model) + const; + + std::unique_ptr + CreateBase2ExponentialBucketHistogramAggregation( + const opentelemetry::sdk::configuration:: + Base2ExponentialBucketHistogramAggregationConfiguration *model) const; + + std::unique_ptr + CreateExplicitBucketHistogramAggregation( + const opentelemetry::sdk::configuration::ExplicitBucketHistogramAggregationConfiguration + *model) const; + + std::unique_ptr CreateAggregationConfig( + const std::unique_ptr &model, + opentelemetry::sdk::metrics::AggregationType &aggregation_type) const; + + std::unique_ptr CreateAttributesProcessor( + const std::unique_ptr &model) + const; + + void AddView( + opentelemetry::sdk::metrics::ViewRegistry *view_registry, + const std::unique_ptr &model) const; + + std::unique_ptr CreateMeterProvider( + const std::unique_ptr &model, + const opentelemetry::sdk::resource::Resource &resource) const; + + std::unique_ptr CreateOtlpHttpLogRecordExporter( + const opentelemetry::sdk::configuration::OtlpHttpLogRecordExporterConfiguration *model) const; + + std::unique_ptr CreateOtlpGrpcLogRecordExporter( + const opentelemetry::sdk::configuration::OtlpGrpcLogRecordExporterConfiguration *model) const; + + std::unique_ptr CreateOtlpFileLogRecordExporter( + const opentelemetry::sdk::configuration::OtlpFileLogRecordExporterConfiguration *model) const; + + std::unique_ptr CreateConsoleLogRecordExporter( + const opentelemetry::sdk::configuration::ConsoleLogRecordExporterConfiguration *model) const; + + std::unique_ptr CreateExtensionLogRecordExporter( + const opentelemetry::sdk::configuration::ExtensionLogRecordExporterConfiguration *model) + const; + + std::unique_ptr CreateLogRecordExporter( + const std::unique_ptr + &model) const; + + std::unique_ptr CreateBatchLogRecordProcessor( + const opentelemetry::sdk::configuration::BatchLogRecordProcessorConfiguration *model) const; + + std::unique_ptr CreateSimpleLogRecordProcessor( + const opentelemetry::sdk::configuration::SimpleLogRecordProcessorConfiguration *model) const; + + std::unique_ptr CreateExtensionLogRecordProcessor( + const opentelemetry::sdk::configuration::ExtensionLogRecordProcessorConfiguration *model) + const; + + std::unique_ptr CreateLogRecordProcessor( + const std::unique_ptr + &model) const; + + std::unique_ptr CreateLoggerProvider( + const std::unique_ptr &model, + const opentelemetry::sdk::resource::Resource &resource) const; + + void SetResourceAttribute( + opentelemetry::sdk::resource::ResourceAttributes &resource_attributes, + const std::string &name, + const opentelemetry::sdk::configuration::AttributeValueConfiguration *model) const; + + void SetResource(opentelemetry::sdk::resource::Resource &resource, + const std::unique_ptr + &opt_model) const; + + std::unique_ptr CreateConfiguredSdk( + const std::unique_ptr &model) const; + +private: + std::shared_ptr registry_; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/text_map_propagator_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/text_map_propagator_builder.h new file mode 100644 index 00000000000..76ec51ed4d3 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/text_map_propagator_builder.h @@ -0,0 +1,32 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/context/propagation/text_map_propagator.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class TextMapPropagatorBuilder +{ +public: + TextMapPropagatorBuilder() = default; + TextMapPropagatorBuilder(TextMapPropagatorBuilder &&) = default; + TextMapPropagatorBuilder(const TextMapPropagatorBuilder &) = default; + TextMapPropagatorBuilder &operator=(TextMapPropagatorBuilder &&) = default; + TextMapPropagatorBuilder &operator=(const TextMapPropagatorBuilder &other) = default; + virtual ~TextMapPropagatorBuilder() = default; + + virtual std::unique_ptr Build() const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/unsupported_exception.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/unsupported_exception.h new file mode 100644 index 00000000000..95da867b997 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/unsupported_exception.h @@ -0,0 +1,30 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include +#include + +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class UnsupportedException : public std::runtime_error +{ +public: + UnsupportedException(const std::string &msg) : std::runtime_error(msg) {} + UnsupportedException(UnsupportedException &&) = default; + UnsupportedException(const UnsupportedException &) = default; + UnsupportedException &operator=(UnsupportedException &&) = default; + UnsupportedException &operator=(const UnsupportedException &other) = default; + ~UnsupportedException() override = default; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/view_selector_configuration.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/view_selector_configuration.h index 7c47bdd1d38..248ff775787 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/view_selector_configuration.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/view_selector_configuration.h @@ -4,7 +4,6 @@ #pragma once #include -#include #include #include "opentelemetry/sdk/configuration/instrument_type.h" diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/zipkin_span_exporter_builder.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/zipkin_span_exporter_builder.h new file mode 100644 index 00000000000..2b140e4c485 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/configuration/zipkin_span_exporter_builder.h @@ -0,0 +1,34 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/zipkin_span_exporter_configuration.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class ZipkinSpanExporterBuilder +{ +public: + ZipkinSpanExporterBuilder() = default; + ZipkinSpanExporterBuilder(ZipkinSpanExporterBuilder &&) = default; + ZipkinSpanExporterBuilder(const ZipkinSpanExporterBuilder &) = default; + ZipkinSpanExporterBuilder &operator=(ZipkinSpanExporterBuilder &&) = default; + ZipkinSpanExporterBuilder &operator=(const ZipkinSpanExporterBuilder &other) = default; + virtual ~ZipkinSpanExporterBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::ZipkinSpanExporterConfiguration *model) const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor.h index 9f36b18fcae..49398a14547 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor.h @@ -93,10 +93,11 @@ class BatchLogRecordProcessor : public LogRecordProcessor /** * Shuts down the processor and does any cleanup required. Completely drains the buffer/queue of - * all its logs and passes them to the exporter. Any subsequent calls to - * ForceFlush or Shutdown will return immediately without doing anything. + * all its logs and passes them to the exporter. * - * NOTE: Timeout functionality not supported yet. + * @param timeout minimum amount of microseconds to wait for shutdown before giving up and + * returning failure. + * @return true if the shutdown succeeded, false otherwise */ bool Shutdown( std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override; @@ -107,6 +108,13 @@ class BatchLogRecordProcessor : public LogRecordProcessor ~BatchLogRecordProcessor() override; protected: + /** + * Shuts down the processor and does any cleanup required. Completely drains the buffer/queue of + * all its logs and passes them to the exporter. + */ + bool InternalShutdown( + std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept; + /** * The background routine performed by the worker thread. */ diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor_options.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor_options.h index b130f947af1..84e03bcf37f 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor_options.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor_options.h @@ -16,7 +16,7 @@ namespace logs { /** - * Struct to hold batch SpanProcessor options. + * Struct to hold batch LogRecordProcessor options. */ struct BatchLogRecordProcessorOptions { diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor.h index 46432ef22eb..4db2b3497a2 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor.h @@ -49,13 +49,32 @@ class MultiLogRecordProcessor : public LogRecordProcessor /** * Shuts down the processor and does any cleanup required. * ShutDown should only be called once for each processor. - * @param timeout minimum amount of microseconds to wait for - * shutdown before giving up and returning failure. + * @param timeout minimum amount of microseconds to wait for shutdown before giving up and + * returning failure. * @return true if the shutdown succeeded, false otherwise */ bool Shutdown( std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override; +protected: + /** + * Exports all log records that have not yet been exported to the configured Exporter. + * @param timeout that the forceflush is required to finish within. + * @return a result code indicating whether it succeeded, failed or timed out + */ + bool InternalForceFlush( + std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept; + + /** + * Shuts down the processor and does any cleanup required. + * ShutDown should only be called once for each processor. + * @param timeout minimum amount of microseconds to wait for shutdown before giving up and + * returning failure. + * @return true if the shutdown succeeded, false otherwise + */ + bool InternalShutdown( + std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept; + private: std::vector> processors_; }; diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/aggregation/aggregation_config.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/aggregation/aggregation_config.h index 0cae37f39e5..2effa4933cc 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/aggregation/aggregation_config.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/aggregation/aggregation_config.h @@ -5,6 +5,7 @@ #include +#include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -15,6 +16,21 @@ namespace metrics class AggregationConfig { public: + AggregationConfig(size_t cardinality_limit = kAggregationCardinalityLimit) + : cardinality_limit_(cardinality_limit) + {} + + static const AggregationConfig *GetOrDefault(const AggregationConfig *config) + { + if (config) + { + return config; + } + static const AggregationConfig default_config{}; + return &default_config; + } + + size_t cardinality_limit_; virtual ~AggregationConfig() = default; }; diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir_utils.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir_utils.h index dfd10995a47..6ca88411af8 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir_utils.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir_utils.h @@ -5,6 +5,8 @@ #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW +# include + # include "opentelemetry/common/macros.h" # include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" # include "opentelemetry/sdk/metrics/exemplar/aligned_histogram_bucket_exemplar_reservoir.h" @@ -27,6 +29,23 @@ static inline MapAndResetCellType GetMapAndResetCellMethod( return &ReservoirCell::GetAndResetDouble; } +static inline size_t GetSimpleFixedReservoirDefaultSize(const AggregationType agg_type, + const AggregationConfig *const agg_config) + +{ + constexpr size_t kMaxBase2ExponentialHistogramReservoirSize = 20; + + if (agg_type == AggregationType::kBase2ExponentialHistogram) + { + const auto *histogram_agg_config = + static_cast(agg_config); + return (std::min)(kMaxBase2ExponentialHistogramReservoirSize, + histogram_agg_config->max_buckets_); + } + + return SimpleFixedSizeExemplarReservoir::kDefaultSimpleReservoirSize; +} + static inline nostd::shared_ptr GetExemplarReservoir( const AggregationType agg_type, const AggregationConfig *agg_config, @@ -52,7 +71,7 @@ static inline nostd::shared_ptr GetExemplarReservoir( } return nostd::shared_ptr(new SimpleFixedSizeExemplarReservoir( - SimpleFixedSizeExemplarReservoir::kDefaultSimpleReservoirSize, + GetSimpleFixedReservoirDefaultSize(agg_type, agg_config), SimpleFixedSizeExemplarReservoir::GetSimpleFixedSizeCellSelector(), GetMapAndResetCellMethod(instrument_descriptor))); } diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_options.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_options.h index 80514f96d89..d4bda975ab0 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_options.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_options.h @@ -3,10 +3,10 @@ #pragma once -#include "opentelemetry/version.h" - #include +#include "opentelemetry/version.h" + OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { @@ -20,14 +20,15 @@ constexpr std::chrono::milliseconds kExportTimeOutMillis = std::chrono::millise * Struct to hold PeriodicExortingMetricReader options. */ -struct PeriodicExportingMetricReaderOptions +struct OPENTELEMETRY_EXPORT PeriodicExportingMetricReaderOptions { /* The time interval between two consecutive exports. */ - std::chrono::milliseconds export_interval_millis = - std::chrono::milliseconds(kExportIntervalMillis); + std::chrono::milliseconds export_interval_millis; /* how long the export can run before it is cancelled. */ - std::chrono::milliseconds export_timeout_millis = std::chrono::milliseconds(kExportTimeOutMillis); + std::chrono::milliseconds export_timeout_millis; + + PeriodicExportingMetricReaderOptions(); }; } // namespace metrics diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/state/async_metric_storage.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/state/async_metric_storage.h index 93ffccc48c1..968de7aa82d 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/state/async_metric_storage.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/state/async_metric_storage.h @@ -9,6 +9,7 @@ #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/common/attributemap_hash.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" #include "opentelemetry/sdk/metrics/aggregation/default_aggregation.h" #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW @@ -42,8 +43,11 @@ class AsyncMetricStorage : public MetricStorage, public AsyncWritableMetricStora const AggregationConfig *aggregation_config) : instrument_descriptor_(instrument_descriptor), aggregation_type_{aggregation_type}, - cumulative_hash_map_(new AttributesHashMap()), - delta_hash_map_(new AttributesHashMap()), + aggregation_config_{AggregationConfig::GetOrDefault(aggregation_config)}, + cumulative_hash_map_( + std::make_unique(aggregation_config_->cardinality_limit_)), + delta_hash_map_( + std::make_unique(aggregation_config_->cardinality_limit_)), #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW exemplar_filter_type_(exempler_filter_type), exemplar_reservoir_(exemplar_reservoir), @@ -124,7 +128,8 @@ class AsyncMetricStorage : public MetricStorage, public AsyncWritableMetricStora { std::lock_guard guard(hashmap_lock_); delta_metrics = std::move(delta_hash_map_); - delta_hash_map_.reset(new AttributesHashMap); + delta_hash_map_ = + std::make_unique(aggregation_config_->cardinality_limit_); } auto status = @@ -136,6 +141,7 @@ class AsyncMetricStorage : public MetricStorage, public AsyncWritableMetricStora private: InstrumentDescriptor instrument_descriptor_; AggregationType aggregation_type_; + const AggregationConfig *aggregation_config_; std::unique_ptr cumulative_hash_map_; std::unique_ptr delta_hash_map_; opentelemetry::common::SpinLockMutex hashmap_lock_; diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/state/attributes_hashmap.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/state/attributes_hashmap.h index f1ab55ed616..2dd82a99918 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/state/attributes_hashmap.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/state/attributes_hashmap.h @@ -49,7 +49,13 @@ class AttributesHashMapWithCustomHash public: AttributesHashMapWithCustomHash(size_t attributes_limit = kAggregationCardinalityLimit) : attributes_limit_(attributes_limit) - {} + { + if (attributes_limit_ > kAggregationCardinalityLimit) + { + hash_map_.reserve(attributes_limit_); + } + } + Aggregation *Get(const MetricAttributes &attributes) const { auto it = hash_map_.find(attributes); @@ -89,7 +95,7 @@ class AttributesHashMapWithCustomHash return it->second.get(); } - if (IsOverflowAttributes()) + if (IsOverflowAttributes(attr)) { return GetOrSetOveflowAttributes(aggregation_callback); } @@ -108,7 +114,7 @@ class AttributesHashMapWithCustomHash return it->second.get(); } - if (IsOverflowAttributes()) + if (IsOverflowAttributes(attributes)) { return GetOrSetOveflowAttributes(aggregation_callback); } @@ -127,7 +133,7 @@ class AttributesHashMapWithCustomHash return it->second.get(); } - if (IsOverflowAttributes()) + if (IsOverflowAttributes(attributes)) { return GetOrSetOveflowAttributes(aggregation_callback); } @@ -152,7 +158,7 @@ class AttributesHashMapWithCustomHash { it->second = std::move(aggr); } - else if (IsOverflowAttributes()) + else if (IsOverflowAttributes(attributes)) { hash_map_[kOverflowAttributes] = std::move(aggr); } @@ -169,7 +175,7 @@ class AttributesHashMapWithCustomHash { it->second = std::move(aggr); } - else if (IsOverflowAttributes()) + else if (IsOverflowAttributes(attributes)) { hash_map_[kOverflowAttributes] = std::move(aggr); } @@ -228,7 +234,27 @@ class AttributesHashMapWithCustomHash return result.first->second.get(); } - bool IsOverflowAttributes() const { return (hash_map_.size() + 1 >= attributes_limit_); } + bool IsOverflowAttributes(const MetricAttributes &attributes) const + { + // If the incoming attributes are exactly the overflow sentinel, route + // directly to the overflow entry. + if (attributes == kOverflowAttributes) + { + return true; + } + // Determine if overflow entry already exists. + bool has_overflow = (hash_map_.find(kOverflowAttributes) != hash_map_.end()); + // If overflow already present, total size already includes it; trigger overflow + // when current size (including overflow) is >= limit. + if (has_overflow) + { + return hash_map_.size() >= attributes_limit_; + } + // If overflow not present yet, simulate adding a new distinct key. If that + // would exceed the limit, we redirect to overflow instead of creating a + // new real attribute entry. + return (hash_map_.size() + 1) >= attributes_limit_; + } }; using AttributesHashMap = AttributesHashMapWithCustomHash<>; diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/state/sync_metric_storage.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/state/sync_metric_storage.h index ded2be1820e..f517375fd8d 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/state/sync_metric_storage.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/state/sync_metric_storage.h @@ -18,6 +18,7 @@ #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/common/attributemap_hash.h" #include "opentelemetry/sdk/metrics/aggregation/aggregation.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" #include "opentelemetry/sdk/metrics/aggregation/default_aggregation.h" #include "opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h" #include "opentelemetry/sdk/metrics/data/metric_data.h" @@ -63,10 +64,11 @@ class SyncMetricStorage : public MetricStorage, public SyncWritableMetricStorage ExemplarFilterType exempler_filter_type, nostd::shared_ptr &&exemplar_reservoir, #endif - const AggregationConfig *aggregation_config, - size_t attributes_limit = kAggregationCardinalityLimit) + const AggregationConfig *aggregation_config) : instrument_descriptor_(instrument_descriptor), - attributes_hashmap_(new AttributesHashMap(attributes_limit)), + aggregation_config_(AggregationConfig::GetOrDefault(aggregation_config)), + attributes_hashmap_( + std::make_unique(aggregation_config_->cardinality_limit_)), attributes_processor_(std::move(attributes_processor)), #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW exemplar_filter_type_(exempler_filter_type), @@ -173,6 +175,7 @@ class SyncMetricStorage : public MetricStorage, public SyncWritableMetricStorage private: InstrumentDescriptor instrument_descriptor_; // hashmap to maintain the metrics for delta collection (i.e, collection since last Collect call) + const AggregationConfig *aggregation_config_; std::unique_ptr attributes_hashmap_; std::function()> create_default_aggregation_; std::shared_ptr attributes_processor_; diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/view/attributes_processor.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/view/attributes_processor.h index 7ab8cafb139..b00687a5c13 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/view/attributes_processor.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/view/attributes_processor.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include #include @@ -10,6 +11,7 @@ #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/common/custom_hash_equality.h" #include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" #include "opentelemetry/version.h" @@ -18,8 +20,15 @@ namespace sdk { namespace metrics { + using MetricAttributes = opentelemetry::sdk::metrics::FilteredOrderedAttributeMap; +typedef std::unordered_map + FilterAttributeMap; + /** * The AttributesProcessor is responsible for customizing which * attribute(s) are to be reported as metrics dimension(s). @@ -65,12 +74,11 @@ class DefaultAttributesProcessor : public AttributesProcessor class FilteringAttributesProcessor : public AttributesProcessor { public: - FilteringAttributesProcessor(std::unordered_map &&allowed_attribute_keys = {}) + FilteringAttributesProcessor(FilterAttributeMap &&allowed_attribute_keys = {}) : allowed_attribute_keys_(std::move(allowed_attribute_keys)) {} - FilteringAttributesProcessor( - const std::unordered_map &allowed_attribute_keys = {}) + FilteringAttributesProcessor(const FilterAttributeMap &allowed_attribute_keys = {}) : allowed_attribute_keys_(allowed_attribute_keys) {} @@ -80,7 +88,8 @@ class FilteringAttributesProcessor : public AttributesProcessor MetricAttributes result; attributes.ForEachKeyValue( [&](nostd::string_view key, opentelemetry::common::AttributeValue value) noexcept { - if (allowed_attribute_keys_.find(key.data()) != allowed_attribute_keys_.end()) + if (opentelemetry::sdk::common::find_heterogeneous(allowed_attribute_keys_, key) != + allowed_attribute_keys_.end()) { result.SetAttribute(key, value); return true; @@ -94,11 +103,56 @@ class FilteringAttributesProcessor : public AttributesProcessor bool isPresent(nostd::string_view key) const noexcept override { - return (allowed_attribute_keys_.find(key.data()) != allowed_attribute_keys_.end()); + return (opentelemetry::sdk::common::find_heterogeneous(allowed_attribute_keys_, key) != + allowed_attribute_keys_.end()); + } + +private: + FilterAttributeMap allowed_attribute_keys_; +}; + +/** + * FilteringExcludeAttributeProcessor filters by exclude attribute list and drops names if they are + * present in the exclude list + */ + +class FilteringExcludeAttributesProcessor : public AttributesProcessor +{ +public: + FilteringExcludeAttributesProcessor(FilterAttributeMap &&exclude_list = {}) + : exclude_list_(std::move(exclude_list)) + {} + + FilteringExcludeAttributesProcessor(const FilterAttributeMap &exclude_list = {}) + : exclude_list_(exclude_list) + {} + + MetricAttributes process( + const opentelemetry::common::KeyValueIterable &attributes) const noexcept override + { + MetricAttributes result; + attributes.ForEachKeyValue([&](nostd::string_view key, + opentelemetry::common::AttributeValue value) noexcept { + if (opentelemetry::sdk::common::find_heterogeneous(exclude_list_, key) == exclude_list_.end()) + { + result.SetAttribute(key, value); + return true; + } + return true; + }); + + result.UpdateHash(); + return result; + } + + bool isPresent(nostd::string_view key) const noexcept override + { + return (opentelemetry::sdk::common::find_heterogeneous(exclude_list_, key) == + exclude_list_.end()); } private: - std::unordered_map allowed_attribute_keys_; + FilterAttributeMap exclude_list_; }; } // namespace metrics diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/view/view.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/view/view.h index e1c6237b368..49c52ff5d34 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/view/view.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/view/view.h @@ -26,7 +26,6 @@ class View public: View(const std::string &name, const std::string &description = "", - const std::string &unit = "", AggregationType aggregation_type = AggregationType::kDefault, std::shared_ptr aggregation_config = nullptr, std::unique_ptr attributes_processor = @@ -34,7 +33,6 @@ class View new opentelemetry::sdk::metrics::DefaultAttributesProcessor())) : name_(name), description_(description), - unit_(unit), aggregation_type_{aggregation_type}, aggregation_config_{aggregation_config}, attributes_processor_{std::move(attributes_processor)} @@ -62,7 +60,6 @@ class View private: std::string name_; std::string description_; - std::string unit_; AggregationType aggregation_type_; std::shared_ptr aggregation_config_; std::shared_ptr attributes_processor_; diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/view/view_factory.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/view/view_factory.h index 2fa1733f92b..df3c9665710 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/view/view_factory.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/metrics/view/view_factory.h @@ -30,22 +30,15 @@ class OPENTELEMETRY_EXPORT ViewFactory static std::unique_ptr Create(const std::string &name, const std::string &description, - const std::string &unit); - - static std::unique_ptr Create(const std::string &name, - const std::string &description, - const std::string &unit, AggregationType aggregation_type); static std::unique_ptr Create(const std::string &name, const std::string &description, - const std::string &unit, AggregationType aggregation_type, std::shared_ptr aggregation_config); static std::unique_ptr Create(const std::string &name, const std::string &description, - const std::string &unit, AggregationType aggregation_type, std::shared_ptr aggregation_config, std::unique_ptr attributes_processor); diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/resource/resource.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/resource/resource.h index 5260b7c3f56..b89e84649e6 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/resource/resource.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/resource/resource.h @@ -19,7 +19,14 @@ using ResourceAttributes = opentelemetry::sdk::common::AttributeMap; class Resource { public: - Resource(const Resource &) = default; + Resource() noexcept; + + Resource(const ResourceAttributes &attributes) noexcept; + + Resource(const ResourceAttributes &attributes, const std::string &schema_url) noexcept; + + Resource(const Resource &) = default; + Resource &operator=(const Resource &) = default; const ResourceAttributes &GetAttributes() const noexcept; const std::string &GetSchemaURL() const noexcept; @@ -61,21 +68,9 @@ class Resource static Resource &GetDefault(); -protected: - /** - * The constructor is protected and only for use internally by the class and - * inside ResourceDetector class. - * Users should use the Create factory method to obtain a Resource - * instance. - */ - Resource(const ResourceAttributes &attributes = ResourceAttributes(), - const std::string &schema_url = std::string{}) noexcept; - private: ResourceAttributes attributes_; std::string schema_url_; - - friend class ResourceDetector; }; } // namespace resource diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h index 3a78d6f33cf..333c01df8ab 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h @@ -91,10 +91,11 @@ class BatchSpanProcessor : public SpanProcessor /** * Shuts down the processor and does any cleanup required. Completely drains the buffer/queue of - * all its ended spans and passes them to the exporter. Any subsequent calls to OnStart, OnEnd, - * ForceFlush or Shutdown will return immediately without doing anything. + * all its ended spans and passes them to the exporter. * - * NOTE: Timeout functionality not supported yet. + * @param timeout minimum amount of microseconds to wait for shutdown before giving up and + * returning failure. + * @return true if the shutdown succeeded, false otherwise */ bool Shutdown( std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override; @@ -108,6 +109,17 @@ class BatchSpanProcessor : public SpanProcessor ~BatchSpanProcessor() override; protected: + /** + * Shuts down the processor and does any cleanup required. Completely drains the buffer/queue of + * all its ended spans and passes them to the exporter. + * + * @param timeout minimum amount of microseconds to wait for shutdown before giving up and + * returning failure. + * @return true if the shutdown succeeded, false otherwise + */ + bool InternalShutdown( + std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept; + /** * The background routine performed by the worker thread. */ diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/multi_span_processor.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/multi_span_processor.h index 094c5b3e24c..4f732df5a4c 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/multi_span_processor.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/multi_span_processor.h @@ -123,6 +123,19 @@ class MultiSpanProcessor : public SpanProcessor bool Shutdown( std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override + { + return InternalShutdown(timeout); + } + + ~MultiSpanProcessor() override + { + InternalShutdown(); + Cleanup(); + } + +protected: + bool InternalShutdown( + std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept { bool result = true; ProcessorNode *node = head_; @@ -135,12 +148,6 @@ class MultiSpanProcessor : public SpanProcessor return result; } - ~MultiSpanProcessor() override - { - Shutdown(); - Cleanup(); - } - private: struct ProcessorNode { diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/samplers/parent.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/samplers/parent.h index e44e9fa320b..5917273df62 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/samplers/parent.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/samplers/parent.h @@ -9,6 +9,8 @@ #include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/trace/sampler.h" +#include "opentelemetry/sdk/trace/samplers/always_off.h" +#include "opentelemetry/sdk/trace/samplers/always_on.h" #include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_metadata.h" #include "opentelemetry/trace/trace_id.h" @@ -21,16 +23,36 @@ namespace trace { /** - * The ParentBased sampler is a composite sampler. ParentBased(delegateSampler) either respects - * the parent span's sampling decision or delegates to delegateSampler for root spans. + * The ParentBased sampler is a composite sampler that delegates sampling decisions based on the + * parent span's context. + * + * The decision is delegated to one of five configurable samplers: + * - No parent exists (root span): delegates to `root sampler`. + * - A remote parent exists and was sampled: delegates to `remote_parent_sampled_sampler` (default + * to AlwaysOnSampler). + * - A remote parent exists and was not sampled: delegates to `remote_parent_nonsampled_sampler` + * (default to AlwaysOffSampler). + * - A local parent exists and was sampled: delegates to `local_parent_sampled_sampler` (default to + * AlwaysOnSampler). + * - A local parent exists and was not sampled: delegates to `local_parent_nonsampled_sampler` + * (default to AlwaysOffSampler). */ class ParentBasedSampler : public Sampler { public: - explicit ParentBasedSampler(const std::shared_ptr &delegate_sampler) noexcept; - /** The decision either respects the parent span's sampling decision or delegates to - * delegateSampler for root spans - * @return Returns DROP always + explicit ParentBasedSampler(const std::shared_ptr &root_sampler, + const std::shared_ptr &remote_parent_sampled_sampler = + std::make_shared(), + const std::shared_ptr &remote_parent_nonsampled_sampler = + std::make_shared(), + const std::shared_ptr &local_parent_sampled_sampler = + std::make_shared(), + const std::shared_ptr &local_parent_nonsampled_sampler = + std::make_shared()) noexcept; + + /** Implements the decision logic by checking the parent context and delegating to the appropriate + * configured sampler + * @return The SamplingResult from the delegated sampler */ SamplingResult ShouldSample( const opentelemetry::trace::SpanContext &parent_context, @@ -46,9 +68,14 @@ class ParentBasedSampler : public Sampler nostd::string_view GetDescription() const noexcept override; private: - const std::shared_ptr delegate_sampler_; + const std::shared_ptr root_sampler_; + const std::shared_ptr remote_parent_sampled_sampler_; + const std::shared_ptr remote_parent_nonsampled_sampler_; + const std::shared_ptr local_parent_sampled_sampler_; + const std::shared_ptr local_parent_nonsampled_sampler_; const std::string description_; }; + } // namespace trace } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h index d5cf598311d..d07e4c1c0cb 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h @@ -23,7 +23,17 @@ class ParentBasedSamplerFactory /** * Create a ParentBasedSampler. */ - static std::unique_ptr Create(const std::shared_ptr &delegate_sampler); + static std::unique_ptr Create(const std::shared_ptr &root_sampler); + + /** + * Create a ParentBasedSampler. + */ + static std::unique_ptr Create( + const std::shared_ptr &root_sampler, + const std::shared_ptr &remote_parent_sampled_sampler, + const std::shared_ptr &remote_parent_nonsampled_sampler, + const std::shared_ptr &local_parent_sampled_sampler, + const std::shared_ptr &local_parent_nonsampled_sampler); }; } // namespace trace diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/simple_processor.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/simple_processor.h index ce6d378b794..6a562a8f0ab 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/simple_processor.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/trace/simple_processor.h @@ -76,6 +76,15 @@ class SimpleSpanProcessor : public SpanProcessor bool Shutdown( std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override + { + return InternalShutdown(timeout); + } + + ~SimpleSpanProcessor() override { InternalShutdown(); } + +protected: + bool InternalShutdown( + std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept { // We only call shutdown ONCE. if (exporter_ != nullptr && !shutdown_latch_.test_and_set(std::memory_order_acquire)) @@ -85,8 +94,6 @@ class SimpleSpanProcessor : public SpanProcessor return true; } - ~SimpleSpanProcessor() override { Shutdown(); } - private: std::unique_ptr exporter_; opentelemetry::common::SpinLockMutex lock_; diff --git a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/version/version.h b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/version/version.h index 1b31852ca26..a5045807a55 100644 --- a/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/version/version.h +++ b/deps/opentelemetry-cpp/sdk/include/opentelemetry/sdk/version/version.h @@ -3,7 +3,7 @@ #pragma once -#define OPENTELEMETRY_SDK_VERSION "1.22.0" +#define OPENTELEMETRY_SDK_VERSION "1.23.0" #include "opentelemetry/version.h" diff --git a/deps/opentelemetry-cpp/sdk/src/configuration/configuration_parser.cc b/deps/opentelemetry-cpp/sdk/src/configuration/configuration_parser.cc index 000b9356626..7b0abcbca72 100644 --- a/deps/opentelemetry-cpp/sdk/src/configuration/configuration_parser.cc +++ b/deps/opentelemetry-cpp/sdk/src/configuration/configuration_parser.cc @@ -37,6 +37,7 @@ #include "opentelemetry/sdk/configuration/explicit_bucket_histogram_aggregation_configuration.h" #include "opentelemetry/sdk/configuration/extension_log_record_exporter_configuration.h" #include "opentelemetry/sdk/configuration/extension_log_record_processor_configuration.h" +#include "opentelemetry/sdk/configuration/extension_metric_producer_configuration.h" #include "opentelemetry/sdk/configuration/extension_pull_metric_exporter_configuration.h" #include "opentelemetry/sdk/configuration/extension_push_metric_exporter_configuration.h" #include "opentelemetry/sdk/configuration/extension_sampler_configuration.h" @@ -55,7 +56,9 @@ #include "opentelemetry/sdk/configuration/log_record_processor_configuration.h" #include "opentelemetry/sdk/configuration/logger_provider_configuration.h" #include "opentelemetry/sdk/configuration/meter_provider_configuration.h" +#include "opentelemetry/sdk/configuration/metric_producer_configuration.h" #include "opentelemetry/sdk/configuration/metric_reader_configuration.h" +#include "opentelemetry/sdk/configuration/open_census_metric_producer_configuration.h" #include "opentelemetry/sdk/configuration/otlp_file_log_record_exporter_configuration.h" #include "opentelemetry/sdk/configuration/otlp_file_push_metric_exporter_configuration.h" #include "opentelemetry/sdk/configuration/otlp_file_span_exporter_configuration.h" @@ -691,7 +694,7 @@ static std::unique_ptr ParsePullMetricExporterC throw InvalidSchemaException(message); } - if (name == "prometheus") + if (name == "prometheus/development") { model = ParsePrometheusPullMetricExporterConfiguration(child); } @@ -703,6 +706,61 @@ static std::unique_ptr ParsePullMetricExporterC return model; } +static std::unique_ptr +ParseOpenCensusMetricProducerConfiguration(const std::unique_ptr & /* node */) +{ + auto model = std::make_unique(); + + return model; +} + +static std::unique_ptr +ParseExtensionMetricProducerConfiguration(const std::string &name, + std::unique_ptr node) +{ + auto model = std::make_unique(); + + model->name = name; + model->node = std::move(node); + + return model; +} + +static std::unique_ptr ParseMetricProducerConfiguration( + const std::unique_ptr &node) +{ + std::unique_ptr model; + + std::string name; + std::unique_ptr child; + size_t count = 0; + + for (auto it = node->begin_properties(); it != node->end_properties(); ++it) + { + name = it.Name(); + child = it.Value(); + count++; + } + + if (count != 1) + { + std::string message("Illegal metric producer, properties count: "); + message.append(std::to_string(count)); + throw InvalidSchemaException(message); + } + + if (name == "opencensus") + { + model = ParseOpenCensusMetricProducerConfiguration(child); + } + else + { + model = ParseExtensionMetricProducerConfiguration(name, std::move(child)); + } + + return model; +} + static std::unique_ptr ParsePeriodicMetricReaderConfiguration( const std::unique_ptr &node) { @@ -715,6 +773,16 @@ static std::unique_ptr ParsePeriodicMetricRea child = node->GetRequiredChildNode("exporter"); model->exporter = ParsePushMetricExporterConfiguration(child); + child = node->GetChildNode("producers"); + + if (child) + { + for (auto it = child->begin(); it != child->end(); ++it) + { + model->producers.push_back(ParseMetricProducerConfiguration(*it)); + } + } + return model; } @@ -727,6 +795,16 @@ static std::unique_ptr ParsePullMetricReaderConfi child = node->GetRequiredChildNode("exporter"); model->exporter = ParsePullMetricExporterConfiguration(child); + child = node->GetChildNode("producers"); + + if (child) + { + for (auto it = child->begin(); it != child->end(); ++it) + { + model->producers.push_back(ParseMetricProducerConfiguration(*it)); + } + } + return model; } @@ -1031,17 +1109,41 @@ static std::unique_ptr ParsePropagatorConfiguration( auto model = std::make_unique(); std::unique_ptr child; - child = node->GetRequiredChildNode("composite"); + child = node->GetChildNode("composite"); + std::string name; + int num_child = 0; - for (auto it = child->begin(); it != child->end(); ++it) + if (child) { - std::unique_ptr element(*it); - - std::string name = element->AsString(); - - model->composite.push_back(name); + for (auto it = child->begin(); it != child->end(); ++it) + { + // This is an entry in the composite array + std::unique_ptr element(*it); + num_child++; + int count = 0; + + // Find out its name, we expect an object with a unique property. + for (auto it2 = element->begin_properties(); it2 != element->end_properties(); ++it2) + { + name = it2.Name(); + count++; + } + + if (count != 1) + { + std::string message("Illegal composite child "); + message.append(std::to_string(num_child)); + message.append(", properties count: "); + message.append(std::to_string(count)); + throw InvalidSchemaException(message); + } + + model->composite.push_back(name); + } } + model->composite_list = node->GetString("composite_list", ""); + return model; } diff --git a/deps/opentelemetry-cpp/sdk/src/configuration/configured_sdk.cc b/deps/opentelemetry-cpp/sdk/src/configuration/configured_sdk.cc new file mode 100644 index 00000000000..3eb81c9e488 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/src/configuration/configured_sdk.cc @@ -0,0 +1,114 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include +#include +#include + +#include "opentelemetry/context/propagation/global_propagator.h" +#include "opentelemetry/context/propagation/text_map_propagator.h" +#include "opentelemetry/logs/logger_provider.h" +#include "opentelemetry/logs/provider.h" +#include "opentelemetry/metrics/meter_provider.h" +#include "opentelemetry/metrics/provider.h" +#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/configuration/configuration.h" +#include "opentelemetry/sdk/configuration/configured_sdk.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/configuration/sdk_builder.h" +#include "opentelemetry/sdk/logs/logger_provider.h" +#include "opentelemetry/sdk/metrics/meter_provider.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" +#include "opentelemetry/trace/provider.h" +#include "opentelemetry/trace/tracer_provider.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +std::unique_ptr ConfiguredSdk::Create( + std::shared_ptr registry, + const std::unique_ptr &model) +{ + std::unique_ptr sdk; + + if (model) + { + try + { + SdkBuilder builder(std::move(registry)); + sdk = builder.CreateConfiguredSdk(model); + } + catch (const std::exception &e) + { + OTEL_INTERNAL_LOG_ERROR("[Configured Sdk] builder failed with exception: " << e.what()); + } + catch (...) + { + OTEL_INTERNAL_LOG_ERROR("[Configured Sdk] builder failed with unknown exception."); + } + } + + return sdk; +} + +void ConfiguredSdk::Install() +{ + if (propagator) + { + opentelemetry::context::propagation::GlobalTextMapPropagator::SetGlobalPropagator(propagator); + } + + if (tracer_provider) + { + std::shared_ptr api_tracer_provider = tracer_provider; + opentelemetry::trace::Provider::SetTracerProvider(api_tracer_provider); + } + + if (meter_provider) + { + std::shared_ptr api_meter_provider = meter_provider; + opentelemetry::metrics::Provider::SetMeterProvider(api_meter_provider); + } + + if (logger_provider) + { + std::shared_ptr api_logger_provider = logger_provider; + opentelemetry::logs::Provider::SetLoggerProvider(api_logger_provider); + } +} + +void ConfiguredSdk::UnInstall() +{ + if (propagator) + { + std::shared_ptr none; + opentelemetry::context::propagation::GlobalTextMapPropagator::SetGlobalPropagator(none); + } + + if (tracer_provider) + { + std::shared_ptr none; + opentelemetry::trace::Provider::SetTracerProvider(none); + } + + if (meter_provider) + { + std::shared_ptr none; + opentelemetry::metrics::Provider::SetMeterProvider(none); + } + + if (logger_provider) + { + std::shared_ptr none; + opentelemetry::logs::Provider::SetLoggerProvider(none); + } +} + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/src/configuration/registry.cc b/deps/opentelemetry-cpp/sdk/src/configuration/registry.cc new file mode 100644 index 00000000000..804faf38fa6 --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/src/configuration/registry.cc @@ -0,0 +1,248 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include +#include +#include + +#include "opentelemetry/baggage/propagation/baggage_propagator.h" +#include "opentelemetry/context/propagation/text_map_propagator.h" +#include "opentelemetry/sdk/configuration/extension_log_record_exporter_builder.h" +#include "opentelemetry/sdk/configuration/extension_log_record_processor_builder.h" +#include "opentelemetry/sdk/configuration/extension_pull_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/extension_push_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/extension_sampler_builder.h" +#include "opentelemetry/sdk/configuration/extension_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/extension_span_processor_builder.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/configuration/text_map_propagator_builder.h" +#include "opentelemetry/trace/propagation/b3_propagator.h" +#include "opentelemetry/trace/propagation/http_trace_context.h" +#include "opentelemetry/trace/propagation/jaeger.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class TraceContextBuilder : public TextMapPropagatorBuilder +{ +public: + std::unique_ptr Build() const override + { + auto result = std::make_unique(); + return result; + } +}; + +class BaggageBuilder : public TextMapPropagatorBuilder +{ +public: + std::unique_ptr Build() const override + { + auto result = std::make_unique(); + return result; + } +}; + +class B3Builder : public TextMapPropagatorBuilder +{ +public: + std::unique_ptr Build() const override + { + auto result = std::make_unique(); + return result; + } +}; + +class B3MultiBuilder : public TextMapPropagatorBuilder +{ +public: + std::unique_ptr Build() const override + { + auto result = std::make_unique(); + return result; + } +}; + +class JaegerBuilder : public TextMapPropagatorBuilder +{ +public: + std::unique_ptr Build() const override + { + auto result = std::make_unique(); + return result; + } +}; + +Registry::Registry() +{ + SetTextMapPropagatorBuilder("tracecontext", std::make_unique()); + SetTextMapPropagatorBuilder("baggage", std::make_unique()); + SetTextMapPropagatorBuilder("b3", std::make_unique()); + SetTextMapPropagatorBuilder("b3multi", std::make_unique()); + SetTextMapPropagatorBuilder("jaeger", std::make_unique()); +} + +const TextMapPropagatorBuilder *Registry::GetTextMapPropagatorBuilder(const std::string &name) const +{ + TextMapPropagatorBuilder *builder = nullptr; + auto search = propagator_builders_.find(name); + if (search != propagator_builders_.end()) + { + builder = search->second.get(); + } + return builder; +} + +void Registry::SetTextMapPropagatorBuilder(const std::string &name, + std::unique_ptr &&builder) +{ + propagator_builders_.erase(name); + propagator_builders_.insert({name, std::move(builder)}); +} + +const ExtensionSamplerBuilder *Registry::GetExtensionSamplerBuilder(const std::string &name) const +{ + ExtensionSamplerBuilder *builder = nullptr; + auto search = sampler_builders_.find(name); + if (search != sampler_builders_.end()) + { + builder = search->second.get(); + } + return builder; +} + +void Registry::SetExtensionSamplerBuilder(const std::string &name, + std::unique_ptr &&builder) +{ + sampler_builders_.erase(name); + sampler_builders_.insert({name, std::move(builder)}); +} + +const ExtensionSpanExporterBuilder *Registry::GetExtensionSpanExporterBuilder( + const std::string &name) const +{ + ExtensionSpanExporterBuilder *builder = nullptr; + auto search = span_exporter_builders_.find(name); + if (search != span_exporter_builders_.end()) + { + builder = search->second.get(); + } + return builder; +} + +void Registry::SetExtensionSpanExporterBuilder( + const std::string &name, + std::unique_ptr &&builder) +{ + span_exporter_builders_.erase(name); + span_exporter_builders_.insert({name, std::move(builder)}); +} + +const ExtensionSpanProcessorBuilder *Registry::GetExtensionSpanProcessorBuilder( + const std::string &name) const +{ + ExtensionSpanProcessorBuilder *builder = nullptr; + auto search = span_processor_builders_.find(name); + if (search != span_processor_builders_.end()) + { + builder = search->second.get(); + } + return builder; +} + +void Registry::SetExtensionSpanProcessorBuilder( + const std::string &name, + std::unique_ptr &&builder) +{ + span_processor_builders_.erase(name); + span_processor_builders_.insert({name, std::move(builder)}); +} + +const ExtensionPushMetricExporterBuilder *Registry::GetExtensionPushMetricExporterBuilder( + const std::string &name) const +{ + ExtensionPushMetricExporterBuilder *builder = nullptr; + auto search = push_metric_exporter_builders_.find(name); + if (search != push_metric_exporter_builders_.end()) + { + builder = search->second.get(); + } + return builder; +} + +void Registry::SetExtensionPushMetricExporterBuilder( + const std::string &name, + std::unique_ptr &&builder) +{ + push_metric_exporter_builders_.erase(name); + push_metric_exporter_builders_.insert({name, std::move(builder)}); +} + +const ExtensionPullMetricExporterBuilder *Registry::GetExtensionPullMetricExporterBuilder( + const std::string &name) const +{ + ExtensionPullMetricExporterBuilder *builder = nullptr; + auto search = pull_metric_exporter_builders_.find(name); + if (search != pull_metric_exporter_builders_.end()) + { + builder = search->second.get(); + } + return builder; +} + +void Registry::SetExtensionPullMetricExporterBuilder( + const std::string &name, + std::unique_ptr &&builder) +{ + pull_metric_exporter_builders_.erase(name); + pull_metric_exporter_builders_.insert({name, std::move(builder)}); +} + +const ExtensionLogRecordExporterBuilder *Registry::GetExtensionLogRecordExporterBuilder( + const std::string &name) const +{ + ExtensionLogRecordExporterBuilder *builder = nullptr; + auto search = log_record_exporter_builders_.find(name); + if (search != log_record_exporter_builders_.end()) + { + builder = search->second.get(); + } + return builder; +} + +void Registry::SetExtensionLogRecordExporterBuilder( + const std::string &name, + std::unique_ptr &&builder) +{ + log_record_exporter_builders_.erase(name); + log_record_exporter_builders_.insert({name, std::move(builder)}); +} + +const ExtensionLogRecordProcessorBuilder *Registry::GetExtensionLogRecordProcessorBuilder( + const std::string &name) const +{ + ExtensionLogRecordProcessorBuilder *builder = nullptr; + auto search = log_record_processor_builders_.find(name); + if (search != log_record_processor_builders_.end()) + { + builder = search->second.get(); + } + return builder; +} + +void Registry::SetExtensionLogRecordProcessorBuilder( + const std::string &name, + std::unique_ptr &&builder) +{ + log_record_processor_builders_.erase(name); + log_record_processor_builders_.insert({name, std::move(builder)}); +} + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/src/configuration/sdk_builder.cc b/deps/opentelemetry-cpp/sdk/src/configuration/sdk_builder.cc new file mode 100644 index 00000000000..0da1af86dce --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/src/configuration/sdk_builder.cc @@ -0,0 +1,1838 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/kv_properties.h" +#include "opentelemetry/context/propagation/composite_propagator.h" +#include "opentelemetry/context/propagation/text_map_propagator.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/configuration/aggregation_configuration.h" +#include "opentelemetry/sdk/configuration/aggregation_configuration_visitor.h" +#include "opentelemetry/sdk/configuration/always_off_sampler_configuration.h" +#include "opentelemetry/sdk/configuration/always_on_sampler_configuration.h" +#include "opentelemetry/sdk/configuration/attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/attribute_value_configuration_visitor.h" +#include "opentelemetry/sdk/configuration/attributes_configuration.h" +#include "opentelemetry/sdk/configuration/base2_exponential_bucket_histogram_aggregation_configuration.h" +#include "opentelemetry/sdk/configuration/batch_log_record_processor_configuration.h" +#include "opentelemetry/sdk/configuration/batch_span_processor_configuration.h" +#include "opentelemetry/sdk/configuration/boolean_array_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/boolean_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/configuration.h" +#include "opentelemetry/sdk/configuration/configured_sdk.h" +#include "opentelemetry/sdk/configuration/console_log_record_exporter_builder.h" +#include "opentelemetry/sdk/configuration/console_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/console_push_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/console_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/console_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/console_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/double_array_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/double_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/explicit_bucket_histogram_aggregation_configuration.h" +#include "opentelemetry/sdk/configuration/extension_log_record_exporter_builder.h" +#include "opentelemetry/sdk/configuration/extension_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/extension_log_record_processor_builder.h" +#include "opentelemetry/sdk/configuration/extension_log_record_processor_configuration.h" +#include "opentelemetry/sdk/configuration/extension_pull_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/extension_pull_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/extension_push_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/extension_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/extension_sampler_builder.h" +#include "opentelemetry/sdk/configuration/extension_sampler_configuration.h" +#include "opentelemetry/sdk/configuration/extension_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/extension_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/extension_span_processor_builder.h" +#include "opentelemetry/sdk/configuration/extension_span_processor_configuration.h" +#include "opentelemetry/sdk/configuration/include_exclude_configuration.h" +#include "opentelemetry/sdk/configuration/instrument_type.h" +#include "opentelemetry/sdk/configuration/integer_array_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/integer_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/jaeger_remote_sampler_configuration.h" +#include "opentelemetry/sdk/configuration/log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/log_record_exporter_configuration_visitor.h" +#include "opentelemetry/sdk/configuration/log_record_processor_configuration.h" +#include "opentelemetry/sdk/configuration/log_record_processor_configuration_visitor.h" +#include "opentelemetry/sdk/configuration/logger_provider_configuration.h" +#include "opentelemetry/sdk/configuration/meter_provider_configuration.h" +#include "opentelemetry/sdk/configuration/metric_reader_configuration.h" +#include "opentelemetry/sdk/configuration/metric_reader_configuration_visitor.h" +#include "opentelemetry/sdk/configuration/otlp_file_log_record_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_file_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_file_push_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_file_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_file_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_file_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_log_record_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_push_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_http_log_record_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_http_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_http_push_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_http_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_http_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/otlp_http_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/parent_based_sampler_configuration.h" +#include "opentelemetry/sdk/configuration/periodic_metric_reader_configuration.h" +#include "opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_builder.h" +#include "opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/propagator_configuration.h" +#include "opentelemetry/sdk/configuration/pull_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/pull_metric_exporter_configuration_visitor.h" +#include "opentelemetry/sdk/configuration/pull_metric_reader_configuration.h" +#include "opentelemetry/sdk/configuration/push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/push_metric_exporter_configuration_visitor.h" +#include "opentelemetry/sdk/configuration/registry.h" +#include "opentelemetry/sdk/configuration/resource_configuration.h" +#include "opentelemetry/sdk/configuration/sampler_configuration.h" +#include "opentelemetry/sdk/configuration/sampler_configuration_visitor.h" +#include "opentelemetry/sdk/configuration/sdk_builder.h" +#include "opentelemetry/sdk/configuration/simple_log_record_processor_configuration.h" +#include "opentelemetry/sdk/configuration/simple_span_processor_configuration.h" +#include "opentelemetry/sdk/configuration/span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/span_exporter_configuration_visitor.h" +#include "opentelemetry/sdk/configuration/span_processor_configuration.h" +#include "opentelemetry/sdk/configuration/span_processor_configuration_visitor.h" +#include "opentelemetry/sdk/configuration/string_array_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/string_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/text_map_propagator_builder.h" +#include "opentelemetry/sdk/configuration/trace_id_ratio_based_sampler_configuration.h" +#include "opentelemetry/sdk/configuration/tracer_provider_configuration.h" +#include "opentelemetry/sdk/configuration/unsupported_exception.h" +#include "opentelemetry/sdk/configuration/view_configuration.h" +#include "opentelemetry/sdk/configuration/view_selector_configuration.h" +#include "opentelemetry/sdk/configuration/view_stream_configuration.h" +#include "opentelemetry/sdk/configuration/zipkin_span_exporter_builder.h" +#include "opentelemetry/sdk/configuration/zipkin_span_exporter_configuration.h" +#include "opentelemetry/sdk/logs/batch_log_record_processor_factory.h" +#include "opentelemetry/sdk/logs/batch_log_record_processor_options.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/sdk/logs/logger_provider.h" +#include "opentelemetry/sdk/logs/logger_provider_factory.h" +#include "opentelemetry/sdk/logs/processor.h" +#include "opentelemetry/sdk/logs/simple_log_record_processor_factory.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" +#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h" +#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_options.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/meter_context_factory.h" +#include "opentelemetry/sdk/metrics/meter_provider.h" +#include "opentelemetry/sdk/metrics/meter_provider_factory.h" +#include "opentelemetry/sdk/metrics/metric_reader.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" +#include "opentelemetry/sdk/metrics/view/instrument_selector.h" +#include "opentelemetry/sdk/metrics/view/meter_selector.h" +#include "opentelemetry/sdk/metrics/view/view.h" +#include "opentelemetry/sdk/metrics/view/view_registry.h" +#include "opentelemetry/sdk/metrics/view/view_registry_factory.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/batch_span_processor_factory.h" +#include "opentelemetry/sdk/trace/batch_span_processor_options.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/sampler.h" +#include "opentelemetry/sdk/trace/samplers/always_off_factory.h" +#include "opentelemetry/sdk/trace/samplers/always_on_factory.h" +#include "opentelemetry/sdk/trace/samplers/parent_factory.h" +#include "opentelemetry/sdk/trace/samplers/trace_id_ratio_factory.h" +#include "opentelemetry/sdk/trace/simple_processor_factory.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" +#include "opentelemetry/sdk/trace/tracer_provider_factory.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class ResourceAttributeValueSetter + : public opentelemetry::sdk::configuration::AttributeValueConfigurationVisitor +{ +public: + ResourceAttributeValueSetter( + opentelemetry::sdk::resource::ResourceAttributes &resource_attributes, + const std::string &name) + : resource_attributes_(resource_attributes), name_(name) + {} + ResourceAttributeValueSetter(ResourceAttributeValueSetter &&) = delete; + ResourceAttributeValueSetter(const ResourceAttributeValueSetter &) = delete; + ResourceAttributeValueSetter &operator=(ResourceAttributeValueSetter &&) = delete; + ResourceAttributeValueSetter &operator=(const ResourceAttributeValueSetter &other) = delete; + ~ResourceAttributeValueSetter() override = default; + + void VisitString( + const opentelemetry::sdk::configuration::StringAttributeValueConfiguration *model) override + { + opentelemetry::common::AttributeValue attribute_value(model->value); + resource_attributes_.SetAttribute(name_, attribute_value); + } + + void VisitInteger( + const opentelemetry::sdk::configuration::IntegerAttributeValueConfiguration *model) override + { + opentelemetry::common::AttributeValue attribute_value(model->value); + resource_attributes_.SetAttribute(name_, attribute_value); + } + + void VisitDouble( + const opentelemetry::sdk::configuration::DoubleAttributeValueConfiguration *model) override + { + opentelemetry::common::AttributeValue attribute_value(model->value); + resource_attributes_.SetAttribute(name_, attribute_value); + } + + void VisitBoolean( + const opentelemetry::sdk::configuration::BooleanAttributeValueConfiguration *model) override + { + opentelemetry::common::AttributeValue attribute_value(model->value); + resource_attributes_.SetAttribute(name_, attribute_value); + } + + void VisitStringArray( + const opentelemetry::sdk::configuration::StringArrayAttributeValueConfiguration *model) + override + { + size_t length = model->value.size(); + std::vector string_view_array(length); + + // We have: std::vector + // We need: nostd::span + + for (size_t i = 0; i < length; i++) + { + string_view_array[i] = model->value[i]; + } + + nostd::span span(string_view_array.data(), string_view_array.size()); + + opentelemetry::common::AttributeValue attribute_value(span); + resource_attributes_.SetAttribute(name_, attribute_value); + } + + void VisitIntegerArray( + const opentelemetry::sdk::configuration::IntegerArrayAttributeValueConfiguration *model) + override + { + size_t length = model->value.size(); + std::vector int_array(length); + + // We have: std::vector + // We need: nostd::span + + for (size_t i = 0; i < length; i++) + { + int_array[i] = model->value[i]; + } + + nostd::span span(int_array.data(), int_array.size()); + + opentelemetry::common::AttributeValue attribute_value(span); + resource_attributes_.SetAttribute(name_, attribute_value); + } + + void VisitDoubleArray( + const opentelemetry::sdk::configuration::DoubleArrayAttributeValueConfiguration *model) + override + { + // We have: std::vector + // We need: nostd::span + // so no data conversion needed + + nostd::span span(model->value.data(), model->value.size()); + + opentelemetry::common::AttributeValue attribute_value(span); + resource_attributes_.SetAttribute(name_, attribute_value); + } + + void VisitBooleanArray( + const opentelemetry::sdk::configuration::BooleanArrayAttributeValueConfiguration *model) + override + { + size_t length = model->value.size(); + + // Can not use std::vector, + // it has no data() to convert it to a span + std::unique_ptr bool_array(new bool[length]); + + // We have: std::vector + // We need: nostd::span + + for (size_t i = 0; i < length; i++) + { + bool_array[i] = model->value[i]; + } + + nostd::span span(&bool_array[0], length); + + opentelemetry::common::AttributeValue attribute_value(span); + resource_attributes_.SetAttribute(name_, attribute_value); + } + + opentelemetry::common::AttributeValue attribute_value; + +private: + opentelemetry::sdk::resource::ResourceAttributes &resource_attributes_; + std::string name_; +}; + +class SamplerBuilder : public opentelemetry::sdk::configuration::SamplerConfigurationVisitor +{ +public: + SamplerBuilder(const SdkBuilder *b) : sdk_builder_(b) {} + SamplerBuilder(SamplerBuilder &&) = delete; + SamplerBuilder(const SamplerBuilder &) = delete; + SamplerBuilder &operator=(SamplerBuilder &&) = delete; + SamplerBuilder &operator=(const SamplerBuilder &other) = delete; + ~SamplerBuilder() override = default; + + void VisitAlwaysOff( + const opentelemetry::sdk::configuration::AlwaysOffSamplerConfiguration *model) override + { + sampler = sdk_builder_->CreateAlwaysOffSampler(model); + } + + void VisitAlwaysOn( + const opentelemetry::sdk::configuration::AlwaysOnSamplerConfiguration *model) override + { + sampler = sdk_builder_->CreateAlwaysOnSampler(model); + } + + void VisitJaegerRemote( + const opentelemetry::sdk::configuration::JaegerRemoteSamplerConfiguration *model) override + { + sampler = sdk_builder_->CreateJaegerRemoteSampler(model); + } + + void VisitParentBased( + const opentelemetry::sdk::configuration::ParentBasedSamplerConfiguration *model) override + { + sampler = sdk_builder_->CreateParentBasedSampler(model); + } + + void VisitTraceIdRatioBased( + const opentelemetry::sdk::configuration::TraceIdRatioBasedSamplerConfiguration *model) + override + { + sampler = sdk_builder_->CreateTraceIdRatioBasedSampler(model); + } + + void VisitExtension( + const opentelemetry::sdk::configuration::ExtensionSamplerConfiguration *model) override + { + sampler = sdk_builder_->CreateExtensionSampler(model); + } + + std::unique_ptr sampler; + +private: + const SdkBuilder *sdk_builder_; +}; + +class SpanProcessorBuilder + : public opentelemetry::sdk::configuration::SpanProcessorConfigurationVisitor +{ +public: + SpanProcessorBuilder(const SdkBuilder *b) : sdk_builder_(b) {} + SpanProcessorBuilder(SpanProcessorBuilder &&) = delete; + SpanProcessorBuilder(const SpanProcessorBuilder &) = delete; + SpanProcessorBuilder &operator=(SpanProcessorBuilder &&) = delete; + SpanProcessorBuilder &operator=(const SpanProcessorBuilder &other) = delete; + ~SpanProcessorBuilder() override = default; + + void VisitBatch( + const opentelemetry::sdk::configuration::BatchSpanProcessorConfiguration *model) override + { + processor = sdk_builder_->CreateBatchSpanProcessor(model); + } + + void VisitSimple( + const opentelemetry::sdk::configuration::SimpleSpanProcessorConfiguration *model) override + { + processor = sdk_builder_->CreateSimpleSpanProcessor(model); + } + + void VisitExtension( + const opentelemetry::sdk::configuration::ExtensionSpanProcessorConfiguration *model) override + { + processor = sdk_builder_->CreateExtensionSpanProcessor(model); + } + + std::unique_ptr processor; + +private: + const SdkBuilder *sdk_builder_; +}; + +class SpanExporterBuilder + : public opentelemetry::sdk::configuration::SpanExporterConfigurationVisitor +{ +public: + SpanExporterBuilder(const SdkBuilder *b) : sdk_builder_(b) {} + SpanExporterBuilder(SpanExporterBuilder &&) = delete; + SpanExporterBuilder(const SpanExporterBuilder &) = delete; + SpanExporterBuilder &operator=(SpanExporterBuilder &&) = delete; + SpanExporterBuilder &operator=(const SpanExporterBuilder &other) = delete; + ~SpanExporterBuilder() override = default; + + void VisitOtlpHttp( + const opentelemetry::sdk::configuration::OtlpHttpSpanExporterConfiguration *model) override + { + exporter = sdk_builder_->CreateOtlpHttpSpanExporter(model); + } + + void VisitOtlpGrpc( + const opentelemetry::sdk::configuration::OtlpGrpcSpanExporterConfiguration *model) override + { + exporter = sdk_builder_->CreateOtlpGrpcSpanExporter(model); + } + + void VisitOtlpFile( + const opentelemetry::sdk::configuration::OtlpFileSpanExporterConfiguration *model) override + { + exporter = sdk_builder_->CreateOtlpFileSpanExporter(model); + } + + void VisitConsole( + const opentelemetry::sdk::configuration::ConsoleSpanExporterConfiguration *model) override + { + exporter = sdk_builder_->CreateConsoleSpanExporter(model); + } + + void VisitZipkin( + const opentelemetry::sdk::configuration::ZipkinSpanExporterConfiguration *model) override + { + exporter = sdk_builder_->CreateZipkinSpanExporter(model); + } + + void VisitExtension( + const opentelemetry::sdk::configuration::ExtensionSpanExporterConfiguration *model) override + { + exporter = sdk_builder_->CreateExtensionSpanExporter(model); + } + + std::unique_ptr exporter; + +private: + const SdkBuilder *sdk_builder_; +}; + +class MetricReaderBuilder + : public opentelemetry::sdk::configuration::MetricReaderConfigurationVisitor +{ +public: + MetricReaderBuilder(const SdkBuilder *b) : sdk_builder_(b) {} + MetricReaderBuilder(MetricReaderBuilder &&) = delete; + MetricReaderBuilder(const MetricReaderBuilder &) = delete; + MetricReaderBuilder &operator=(MetricReaderBuilder &&) = delete; + MetricReaderBuilder &operator=(const MetricReaderBuilder &other) = delete; + ~MetricReaderBuilder() override = default; + + void VisitPeriodic( + const opentelemetry::sdk::configuration::PeriodicMetricReaderConfiguration *model) override + { + metric_reader = sdk_builder_->CreatePeriodicMetricReader(model); + } + + void VisitPull( + const opentelemetry::sdk::configuration::PullMetricReaderConfiguration *model) override + { + metric_reader = sdk_builder_->CreatePullMetricReader(model); + } + + std::unique_ptr metric_reader; + +private: + const SdkBuilder *sdk_builder_; +}; + +class PushMetricExporterBuilder + : public opentelemetry::sdk::configuration::PushMetricExporterConfigurationVisitor +{ +public: + PushMetricExporterBuilder(const SdkBuilder *b) : sdk_builder_(b) {} + PushMetricExporterBuilder(PushMetricExporterBuilder &&) = delete; + PushMetricExporterBuilder(const PushMetricExporterBuilder &) = delete; + PushMetricExporterBuilder &operator=(PushMetricExporterBuilder &&) = delete; + PushMetricExporterBuilder &operator=(const PushMetricExporterBuilder &other) = delete; + ~PushMetricExporterBuilder() override = default; + + void VisitOtlpHttp( + const opentelemetry::sdk::configuration::OtlpHttpPushMetricExporterConfiguration *model) + override + { + exporter = sdk_builder_->CreateOtlpHttpPushMetricExporter(model); + } + + void VisitOtlpGrpc( + const opentelemetry::sdk::configuration::OtlpGrpcPushMetricExporterConfiguration *model) + override + { + exporter = sdk_builder_->CreateOtlpGrpcPushMetricExporter(model); + } + + void VisitOtlpFile( + const opentelemetry::sdk::configuration::OtlpFilePushMetricExporterConfiguration *model) + override + { + exporter = sdk_builder_->CreateOtlpFilePushMetricExporter(model); + } + + void VisitConsole(const opentelemetry::sdk::configuration::ConsolePushMetricExporterConfiguration + *model) override + { + exporter = sdk_builder_->CreateConsolePushMetricExporter(model); + } + + void VisitExtension( + const opentelemetry::sdk::configuration::ExtensionPushMetricExporterConfiguration *model) + override + { + exporter = sdk_builder_->CreateExtensionPushMetricExporter(model); + } + + std::unique_ptr exporter; + +private: + const SdkBuilder *sdk_builder_; +}; + +class PullMetricExporterBuilder + : public opentelemetry::sdk::configuration::PullMetricExporterConfigurationVisitor +{ +public: + PullMetricExporterBuilder(const SdkBuilder *b) : sdk_builder_(b) {} + PullMetricExporterBuilder(PullMetricExporterBuilder &&) = delete; + PullMetricExporterBuilder(const PullMetricExporterBuilder &) = delete; + PullMetricExporterBuilder &operator=(PullMetricExporterBuilder &&) = delete; + PullMetricExporterBuilder &operator=(const PullMetricExporterBuilder &other) = delete; + ~PullMetricExporterBuilder() override = default; + + void VisitPrometheus( + const opentelemetry::sdk::configuration::PrometheusPullMetricExporterConfiguration *model) + override + { + exporter = sdk_builder_->CreatePrometheusPullMetricExporter(model); + } + + void VisitExtension( + const opentelemetry::sdk::configuration::ExtensionPullMetricExporterConfiguration *model) + override + { + exporter = sdk_builder_->CreateExtensionPullMetricExporter(model); + } + + std::unique_ptr exporter; + +private: + const SdkBuilder *sdk_builder_; +}; + +class AggregationConfigBuilder + : public opentelemetry::sdk::configuration::AggregationConfigurationVisitor +{ +public: + AggregationConfigBuilder(const SdkBuilder *b) : sdk_builder_(b) {} + AggregationConfigBuilder(AggregationConfigBuilder &&) = delete; + AggregationConfigBuilder(const AggregationConfigBuilder &) = delete; + AggregationConfigBuilder &operator=(AggregationConfigBuilder &&) = delete; + AggregationConfigBuilder &operator=(const AggregationConfigBuilder &other) = delete; + ~AggregationConfigBuilder() override = default; + + void VisitBase2ExponentialBucketHistogram( + const opentelemetry::sdk::configuration:: + Base2ExponentialBucketHistogramAggregationConfiguration *model) override + { + aggregation_type = opentelemetry::sdk::metrics::AggregationType::kBase2ExponentialHistogram; + aggregation_config = sdk_builder_->CreateBase2ExponentialBucketHistogramAggregation(model); + } + + void VisitDefault(const opentelemetry::sdk::configuration::DefaultAggregationConfiguration + * /* model */) override + { + aggregation_type = opentelemetry::sdk::metrics::AggregationType::kDefault; + } + + void VisitDrop( + const opentelemetry::sdk::configuration::DropAggregationConfiguration * /* model */) override + { + aggregation_type = opentelemetry::sdk::metrics::AggregationType::kDrop; + } + + void VisitExplicitBucketHistogram( + const opentelemetry::sdk::configuration::ExplicitBucketHistogramAggregationConfiguration + *model) override + { + aggregation_type = opentelemetry::sdk::metrics::AggregationType::kHistogram; + aggregation_config = sdk_builder_->CreateExplicitBucketHistogramAggregation(model); + } + + void VisitLastValue(const opentelemetry::sdk::configuration::LastValueAggregationConfiguration + * /* model */) override + { + aggregation_type = opentelemetry::sdk::metrics::AggregationType::kLastValue; + } + + void VisitSum( + const opentelemetry::sdk::configuration::SumAggregationConfiguration * /* model */) override + { + aggregation_type = opentelemetry::sdk::metrics::AggregationType::kSum; + } + + opentelemetry::sdk::metrics::AggregationType aggregation_type; + std::unique_ptr aggregation_config; + +private: + const SdkBuilder *sdk_builder_; +}; + +class LogRecordProcessorBuilder + : public opentelemetry::sdk::configuration::LogRecordProcessorConfigurationVisitor +{ +public: + LogRecordProcessorBuilder(const SdkBuilder *b) : sdk_builder_(b) {} + LogRecordProcessorBuilder(LogRecordProcessorBuilder &&) = delete; + LogRecordProcessorBuilder(const LogRecordProcessorBuilder &) = delete; + LogRecordProcessorBuilder &operator=(LogRecordProcessorBuilder &&) = delete; + LogRecordProcessorBuilder &operator=(const LogRecordProcessorBuilder &other) = delete; + ~LogRecordProcessorBuilder() override = default; + + void VisitBatch( + const opentelemetry::sdk::configuration::BatchLogRecordProcessorConfiguration *model) override + { + processor = sdk_builder_->CreateBatchLogRecordProcessor(model); + } + + void VisitSimple(const opentelemetry::sdk::configuration::SimpleLogRecordProcessorConfiguration + *model) override + { + processor = sdk_builder_->CreateSimpleLogRecordProcessor(model); + } + + void VisitExtension( + const opentelemetry::sdk::configuration::ExtensionLogRecordProcessorConfiguration *model) + override + { + processor = sdk_builder_->CreateExtensionLogRecordProcessor(model); + } + + std::unique_ptr processor; + +private: + const SdkBuilder *sdk_builder_; +}; + +class LogRecordExporterBuilder + : public opentelemetry::sdk::configuration::LogRecordExporterConfigurationVisitor +{ +public: + LogRecordExporterBuilder(const SdkBuilder *b) : sdk_builder_(b) {} + LogRecordExporterBuilder(LogRecordExporterBuilder &&) = delete; + LogRecordExporterBuilder(const LogRecordExporterBuilder &) = delete; + LogRecordExporterBuilder &operator=(LogRecordExporterBuilder &&) = delete; + LogRecordExporterBuilder &operator=(const LogRecordExporterBuilder &other) = delete; + ~LogRecordExporterBuilder() override = default; + + void VisitOtlpHttp(const opentelemetry::sdk::configuration::OtlpHttpLogRecordExporterConfiguration + *model) override + { + exporter = sdk_builder_->CreateOtlpHttpLogRecordExporter(model); + } + + void VisitOtlpGrpc(const opentelemetry::sdk::configuration::OtlpGrpcLogRecordExporterConfiguration + *model) override + { + exporter = sdk_builder_->CreateOtlpGrpcLogRecordExporter(model); + } + + void VisitOtlpFile(const opentelemetry::sdk::configuration::OtlpFileLogRecordExporterConfiguration + *model) override + { + exporter = sdk_builder_->CreateOtlpFileLogRecordExporter(model); + } + + void VisitConsole(const opentelemetry::sdk::configuration::ConsoleLogRecordExporterConfiguration + *model) override + { + exporter = sdk_builder_->CreateConsoleLogRecordExporter(model); + } + + void VisitExtension( + const opentelemetry::sdk::configuration::ExtensionLogRecordExporterConfiguration *model) + override + { + exporter = sdk_builder_->CreateExtensionLogRecordExporter(model); + } + + std::unique_ptr exporter; + +private: + const SdkBuilder *sdk_builder_; +}; + +std::unique_ptr SdkBuilder::CreateAlwaysOffSampler( + const opentelemetry::sdk::configuration::AlwaysOffSamplerConfiguration * /* model */) const +{ + std::unique_ptr sdk; + + sdk = opentelemetry::sdk::trace::AlwaysOffSamplerFactory::Create(); + + return sdk; +} + +std::unique_ptr SdkBuilder::CreateAlwaysOnSampler( + const opentelemetry::sdk::configuration::AlwaysOnSamplerConfiguration * /* model */) const +{ + std::unique_ptr sdk; + + sdk = opentelemetry::sdk::trace::AlwaysOnSamplerFactory::Create(); + + return sdk; +} + +std::unique_ptr SdkBuilder::CreateJaegerRemoteSampler( + const opentelemetry::sdk::configuration::JaegerRemoteSamplerConfiguration * /* model */) const +{ + std::unique_ptr sdk; + + static const std::string die("JaegerRemoteSampler not supported"); + throw UnsupportedException(die); + + return sdk; +} + +std::unique_ptr SdkBuilder::CreateParentBasedSampler( + const opentelemetry::sdk::configuration::ParentBasedSamplerConfiguration *model) const +{ + std::unique_ptr sdk; + std::unique_ptr remote_parent_sampled_sdk; + std::unique_ptr remote_parent_not_sampled_sdk; + std::unique_ptr local_parent_sampled_sdk; + std::unique_ptr local_parent_not_sampled_sdk; + + auto root_sdk = SdkBuilder::CreateSampler(model->root); + + if (model->remote_parent_sampled != nullptr) + { + remote_parent_sampled_sdk = SdkBuilder::CreateSampler(model->remote_parent_sampled); + } + else + { + remote_parent_sampled_sdk = opentelemetry::sdk::trace::AlwaysOnSamplerFactory::Create(); + } + + if (model->remote_parent_not_sampled != nullptr) + { + remote_parent_not_sampled_sdk = SdkBuilder::CreateSampler(model->remote_parent_not_sampled); + } + else + { + remote_parent_not_sampled_sdk = opentelemetry::sdk::trace::AlwaysOffSamplerFactory::Create(); + } + + if (model->local_parent_sampled != nullptr) + { + local_parent_sampled_sdk = SdkBuilder::CreateSampler(model->local_parent_sampled); + } + else + { + local_parent_sampled_sdk = opentelemetry::sdk::trace::AlwaysOnSamplerFactory::Create(); + } + + if (model->local_parent_not_sampled != nullptr) + { + local_parent_not_sampled_sdk = SdkBuilder::CreateSampler(model->local_parent_not_sampled); + } + else + { + local_parent_not_sampled_sdk = opentelemetry::sdk::trace::AlwaysOffSamplerFactory::Create(); + } + + std::shared_ptr shared_root = std::move(root_sdk); + std::shared_ptr shared_remote_parent_sampled = + std::move(remote_parent_sampled_sdk); + std::shared_ptr shared_remote_parent_not_sampled = + std::move(remote_parent_not_sampled_sdk); + std::shared_ptr shared_local_parent_sampled = + std::move(local_parent_sampled_sdk); + std::shared_ptr shared_local_parent_not_sampled = + std::move(local_parent_not_sampled_sdk); + + sdk = opentelemetry::sdk::trace::ParentBasedSamplerFactory::Create( + shared_root, shared_remote_parent_sampled, shared_remote_parent_not_sampled, + shared_local_parent_sampled, shared_local_parent_not_sampled); + + return sdk; +} + +std::unique_ptr SdkBuilder::CreateTraceIdRatioBasedSampler( + const opentelemetry::sdk::configuration::TraceIdRatioBasedSamplerConfiguration *model) const +{ + std::unique_ptr sdk; + + sdk = opentelemetry::sdk::trace::TraceIdRatioBasedSamplerFactory::Create(model->ratio); + + return sdk; +} + +std::unique_ptr SdkBuilder::CreateExtensionSampler( + const opentelemetry::sdk::configuration::ExtensionSamplerConfiguration *model) const +{ + std::unique_ptr sdk; + std::string name = model->name; + + const ExtensionSamplerBuilder *builder = registry_->GetExtensionSamplerBuilder(name); + + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateExtensionSampler() using registered builder " << name); + sdk = builder->Build(model); + return sdk; + } + + std::string die("CreateExtensionSampler() no builder for "); + die.append(name); + throw UnsupportedException(die); +} + +std::unique_ptr SdkBuilder::CreateSampler( + const std::unique_ptr &model) const +{ + std::unique_ptr sdk; + + SamplerBuilder builder(this); + model->Accept(&builder); + sdk = std::move(builder.sampler); + + return sdk; +} + +std::unique_ptr SdkBuilder::CreateOtlpHttpSpanExporter( + const opentelemetry::sdk::configuration::OtlpHttpSpanExporterConfiguration *model) const +{ + std::unique_ptr sdk; + const OtlpHttpSpanExporterBuilder *builder; + + builder = registry_->GetOtlpHttpSpanBuilder(); + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateOtlpHttpSpanExporter() using registered http builder"); + sdk = builder->Build(model); + return sdk; + } + + static const std::string die("No http builder for OtlpHttpSpanExporter"); + throw UnsupportedException(die); +} + +std::unique_ptr SdkBuilder::CreateOtlpGrpcSpanExporter( + const opentelemetry::sdk::configuration::OtlpGrpcSpanExporterConfiguration *model) const +{ + std::unique_ptr sdk; + const OtlpGrpcSpanExporterBuilder *builder; + + builder = registry_->GetOtlpGrpcSpanBuilder(); + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateOtlpGrpcSpanExporter() using registered grpc builder"); + sdk = builder->Build(model); + return sdk; + } + + static const std::string die("No builder for OtlpGrpcSpanExporter"); + throw UnsupportedException(die); +} + +std::unique_ptr SdkBuilder::CreateOtlpFileSpanExporter( + const opentelemetry::sdk::configuration::OtlpFileSpanExporterConfiguration *model) const +{ + std::unique_ptr sdk; + const OtlpFileSpanExporterBuilder *builder; + + builder = registry_->GetOtlpFileSpanBuilder(); + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateOtlpFileSpanExporter() using registered file builder"); + sdk = builder->Build(model); + return sdk; + } + + static const std::string die("No builder for OtlpFileSpanExporter"); + throw UnsupportedException(die); +} + +std::unique_ptr SdkBuilder::CreateConsoleSpanExporter( + const opentelemetry::sdk::configuration::ConsoleSpanExporterConfiguration *model) const +{ + std::unique_ptr sdk; + const ConsoleSpanExporterBuilder *builder = registry_->GetConsoleSpanBuilder(); + + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateConsoleSpanExporter() using registered builder"); + sdk = builder->Build(model); + return sdk; + } + + static const std::string die("No builder for ConsoleSpanExporter"); + throw UnsupportedException(die); +} + +std::unique_ptr SdkBuilder::CreateZipkinSpanExporter( + const opentelemetry::sdk::configuration::ZipkinSpanExporterConfiguration *model) const +{ + std::unique_ptr sdk; + const ZipkinSpanExporterBuilder *builder = registry_->GetZipkinSpanBuilder(); + + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateZipkinSpanExporter() using registered builder"); + sdk = builder->Build(model); + return sdk; + } + + static const std::string die("No builder for ZipkinSpanExporter"); + throw UnsupportedException(die); +} + +std::unique_ptr SdkBuilder::CreateExtensionSpanExporter( + const opentelemetry::sdk::configuration::ExtensionSpanExporterConfiguration *model) const +{ + std::unique_ptr sdk; + std::string name = model->name; + + const ExtensionSpanExporterBuilder *builder = registry_->GetExtensionSpanExporterBuilder(name); + + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateExtensionSpanExporter() using registered builder " << name); + sdk = builder->Build(model); + return sdk; + } + + std::string die("CreateExtensionSpanExporter() no builder for "); + die.append(name); + throw UnsupportedException(die); +} + +std::unique_ptr SdkBuilder::CreateSpanExporter( + const std::unique_ptr &model) + const +{ + std::unique_ptr sdk; + + SpanExporterBuilder builder(this); + model->Accept(&builder); + sdk = std::move(builder.exporter); + + return sdk; +} + +std::unique_ptr SdkBuilder::CreateBatchSpanProcessor( + const opentelemetry::sdk::configuration::BatchSpanProcessorConfiguration *model) const +{ + std::unique_ptr sdk; + opentelemetry::sdk::trace::BatchSpanProcessorOptions options; + + options.schedule_delay_millis = std::chrono::milliseconds(model->schedule_delay); + +#ifdef LATER + options.xxx = model->export_timeout; +#endif + + options.max_queue_size = model->max_queue_size; + options.max_export_batch_size = model->max_export_batch_size; + + auto exporter_sdk = CreateSpanExporter(model->exporter); + + sdk = opentelemetry::sdk::trace::BatchSpanProcessorFactory::Create(std::move(exporter_sdk), + options); + return sdk; +} + +std::unique_ptr SdkBuilder::CreateSimpleSpanProcessor( + const opentelemetry::sdk::configuration::SimpleSpanProcessorConfiguration *model) const +{ + std::unique_ptr sdk; + + auto exporter_sdk = CreateSpanExporter(model->exporter); + + sdk = opentelemetry::sdk::trace::SimpleSpanProcessorFactory::Create(std::move(exporter_sdk)); + + return sdk; +} + +std::unique_ptr SdkBuilder::CreateExtensionSpanProcessor( + const opentelemetry::sdk::configuration::ExtensionSpanProcessorConfiguration *model) const +{ + std::unique_ptr sdk; + std::string name = model->name; + + const ExtensionSpanProcessorBuilder *builder = registry_->GetExtensionSpanProcessorBuilder(name); + + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateExtensionSpanProcessor() using registered builder " << name); + sdk = builder->Build(model); + return sdk; + } + + std::string die("CreateExtensionSpanProcessor() no builder for "); + die.append(name); + throw UnsupportedException(die); +} + +std::unique_ptr SdkBuilder::CreateSpanProcessor( + const std::unique_ptr &model) + const +{ + std::unique_ptr sdk; + + SpanProcessorBuilder builder(this); + model->Accept(&builder); + sdk = std::move(builder.processor); + + return sdk; +} + +std::unique_ptr SdkBuilder::CreateTracerProvider( + const std::unique_ptr &model, + const opentelemetry::sdk::resource::Resource &resource) const +{ + std::unique_ptr sdk; + + // FIXME-CONFIG: https://github.com/open-telemetry/opentelemetry-configuration/issues/70 + // FIXME-CONFIG: Add support for IdGenerator + + std::unique_ptr sampler; + + if (model->sampler) + { + sampler = CreateSampler(model->sampler); + } + + std::vector> sdk_processors; + + for (const auto &processor_model : model->processors) + { + sdk_processors.push_back(CreateSpanProcessor(processor_model)); + } + + // FIXME-SDK: https://github.com/open-telemetry/opentelemetry-cpp/issues/3303 + // FIXME-SDK: use limits, id_generator, ... + sdk = opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(sdk_processors), + resource, std::move(sampler)); + + return sdk; +} + +std::unique_ptr +SdkBuilder::CreateTextMapPropagator(const std::string &name) const +{ + std::unique_ptr sdk; + + const TextMapPropagatorBuilder *builder = registry_->GetTextMapPropagatorBuilder(name); + + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateTextMapPropagator() using registered builder " << name); + sdk = builder->Build(); + return sdk; + } + + std::string die("CreateTextMapPropagator() no builder for "); + die.append(name); + throw UnsupportedException(die); +} + +static bool IsDuplicate(const std::vector &propagator_seen, const std::string &name) +{ + bool duplicate = false; + for (const auto &seen : propagator_seen) + { + if (name == seen) + { + duplicate = true; + } + } + + return duplicate; +} + +std::unique_ptr +SdkBuilder::CreatePropagator( + const std::unique_ptr &model) const +{ + std::unique_ptr sdk; + std::vector> propagators; + std::unique_ptr propagator; + std::vector propagator_seen; + bool duplicate = false; + + /* + * Note that the spec only requires to check duplicates between + * composite and composite_list. + * Here we check for duplicates globally, for ease of use. + */ + + for (const auto &name : model->composite) + { + duplicate = IsDuplicate(propagator_seen, name); + + if (!duplicate) + { + propagator = CreateTextMapPropagator(name); + propagators.push_back(std::move(propagator)); + propagator_seen.push_back(name); + } + } + + if (model->composite_list.size() > 0) + { + std::string str_list = model->composite_list; + size_t start_pos = 0; + size_t end_pos = 0; + char separator = ','; + std::string name; + + while ((end_pos = str_list.find(separator, start_pos)) != std::string::npos) + { + name = str_list.substr(start_pos, end_pos - start_pos); + + duplicate = IsDuplicate(propagator_seen, name); + + if (!duplicate) + { + propagator = CreateTextMapPropagator(name); + propagators.push_back(std::move(propagator)); + propagator_seen.push_back(name); + } + start_pos = end_pos + 1; + } + + name = str_list.substr(start_pos); + + duplicate = IsDuplicate(propagator_seen, name); + + if (!duplicate) + { + propagator = CreateTextMapPropagator(name); + propagators.push_back(std::move(propagator)); + } + } + + if (propagators.size() > 0) + { + sdk = std::make_unique( + std::move(propagators)); + } + + return sdk; +} + +static opentelemetry::sdk::metrics::InstrumentType ConvertInstrumentType( + enum opentelemetry::sdk::configuration::InstrumentType config) +{ + opentelemetry::sdk::metrics::InstrumentType sdk; + + switch (config) + { + case opentelemetry::sdk::configuration::InstrumentType::none: + case opentelemetry::sdk::configuration::InstrumentType::counter: + sdk = opentelemetry::sdk::metrics::InstrumentType::kCounter; + break; + case opentelemetry::sdk::configuration::InstrumentType::histogram: + sdk = opentelemetry::sdk::metrics::InstrumentType::kHistogram; + break; + case opentelemetry::sdk::configuration::InstrumentType::observable_counter: + sdk = opentelemetry::sdk::metrics::InstrumentType::kObservableCounter; + break; + case opentelemetry::sdk::configuration::InstrumentType::observable_gauge: + sdk = opentelemetry::sdk::metrics::InstrumentType::kObservableGauge; + break; + case opentelemetry::sdk::configuration::InstrumentType::observable_up_down_counter: + sdk = opentelemetry::sdk::metrics::InstrumentType::kObservableUpDownCounter; + break; + case opentelemetry::sdk::configuration::InstrumentType::up_down_counter: + sdk = opentelemetry::sdk::metrics::InstrumentType::kUpDownCounter; + break; + } + + return sdk; +} + +std::unique_ptr +SdkBuilder::CreateOtlpHttpPushMetricExporter( + const opentelemetry::sdk::configuration::OtlpHttpPushMetricExporterConfiguration *model) const +{ + std::unique_ptr sdk; + const OtlpHttpPushMetricExporterBuilder *builder; + + builder = registry_->GetOtlpHttpPushMetricExporterBuilder(); + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateOtlpHttpPushMetricExporter() using registered http builder"); + sdk = builder->Build(model); + return sdk; + } + + static const std::string die("No http builder for OtlpPushMetricExporter"); + throw UnsupportedException(die); +} + +std::unique_ptr +SdkBuilder::CreateOtlpGrpcPushMetricExporter( + const opentelemetry::sdk::configuration::OtlpGrpcPushMetricExporterConfiguration *model) const +{ + std::unique_ptr sdk; + const OtlpGrpcPushMetricExporterBuilder *builder; + + builder = registry_->GetOtlpGrpcPushMetricExporterBuilder(); + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateOtlpGrpcPushMetricExporter() using registered grpc builder"); + sdk = builder->Build(model); + return sdk; + } + + static const std::string die("No grpc builder for OtlpPushMetricExporter"); + throw UnsupportedException(die); +} + +std::unique_ptr +SdkBuilder::CreateOtlpFilePushMetricExporter( + const opentelemetry::sdk::configuration::OtlpFilePushMetricExporterConfiguration *model) const +{ + std::unique_ptr sdk; + const OtlpFilePushMetricExporterBuilder *builder; + + builder = registry_->GetOtlpFilePushMetricExporterBuilder(); + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateOtlpFilePushMetricExporter() using registered file builder"); + sdk = builder->Build(model); + return sdk; + } + + static const std::string die("No file builder for OtlpPushMetricExporter"); + throw UnsupportedException(die); +} + +std::unique_ptr +SdkBuilder::CreateConsolePushMetricExporter( + const opentelemetry::sdk::configuration::ConsolePushMetricExporterConfiguration *model) const +{ + std::unique_ptr sdk; + + const ConsolePushMetricExporterBuilder *builder = + registry_->GetConsolePushMetricExporterBuilder(); + + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateConsolePushMetricExporter() using registered builder"); + sdk = builder->Build(model); + return sdk; + } + + static const std::string die("No builder for ConsolePushMetricExporter"); + throw UnsupportedException(die); +} + +std::unique_ptr +SdkBuilder::CreateExtensionPushMetricExporter( + const opentelemetry::sdk::configuration::ExtensionPushMetricExporterConfiguration *model) const +{ + std::unique_ptr sdk; + std::string name = model->name; + + const ExtensionPushMetricExporterBuilder *builder = + registry_->GetExtensionPushMetricExporterBuilder(name); + + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateExtensionPushMetricExporter() using registered builder " + << name); + sdk = builder->Build(model); + return sdk; + } + + std::string die("No builder for ExtensionPushMetricExporter "); + die.append(name); + throw UnsupportedException(die); +} + +std::unique_ptr +SdkBuilder::CreatePrometheusPullMetricExporter( + const opentelemetry::sdk::configuration::PrometheusPullMetricExporterConfiguration *model) const +{ + std::unique_ptr sdk; + + const PrometheusPullMetricExporterBuilder *builder = + registry_->GetPrometheusPullMetricExporterBuilder(); + + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreatePrometheusPullMetricExporter() using registered builder"); + sdk = builder->Build(model); + return sdk; + } + + static const std::string die("No builder for PrometheusMetricExporter"); + throw UnsupportedException(die); +} + +std::unique_ptr +SdkBuilder::CreateExtensionPullMetricExporter( + const opentelemetry::sdk::configuration::ExtensionPullMetricExporterConfiguration *model) const +{ + std::unique_ptr sdk; + std::string name = model->name; + + const ExtensionPullMetricExporterBuilder *builder = + registry_->GetExtensionPullMetricExporterBuilder(name); + + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateExtensionPullMetricExporter() using registered builder " + << name); + sdk = builder->Build(model); + return sdk; + } + + std::string die("No builder for ExtensionPullMetricExporter "); + die.append(name); + throw UnsupportedException(die); +} + +std::unique_ptr +SdkBuilder::CreatePushMetricExporter( + const std::unique_ptr + &model) const +{ + std::unique_ptr sdk; + + PushMetricExporterBuilder builder(this); + model->Accept(&builder); + sdk = std::move(builder.exporter); + + return sdk; +} + +std::unique_ptr SdkBuilder::CreatePullMetricExporter( + const std::unique_ptr + &model) const +{ + std::unique_ptr sdk; + + PullMetricExporterBuilder builder(this); + model->Accept(&builder); + sdk = std::move(builder.exporter); + + return sdk; +} + +std::unique_ptr SdkBuilder::CreatePeriodicMetricReader( + const opentelemetry::sdk::configuration::PeriodicMetricReaderConfiguration *model) const +{ + std::unique_ptr sdk; + + opentelemetry::sdk::metrics::PeriodicExportingMetricReaderOptions options; + + options.export_interval_millis = std::chrono::milliseconds(model->interval); + options.export_timeout_millis = std::chrono::milliseconds(model->timeout); + + auto exporter_sdk = CreatePushMetricExporter(model->exporter); + + if (model->producers.size() > 0) + { + OTEL_INTERNAL_LOG_WARN("metric producer not supported, ignoring"); + } + + sdk = opentelemetry::sdk::metrics::PeriodicExportingMetricReaderFactory::Create( + std::move(exporter_sdk), options); + + return sdk; +} + +std::unique_ptr SdkBuilder::CreatePullMetricReader( + const opentelemetry::sdk::configuration::PullMetricReaderConfiguration *model) const +{ + std::unique_ptr sdk; + + sdk = CreatePullMetricExporter(model->exporter); + + if (model->producers.size() > 0) + { + OTEL_INTERNAL_LOG_WARN("metric producer not supported, ignoring"); + } + + return sdk; +} + +std::unique_ptr SdkBuilder::CreateMetricReader( + const std::unique_ptr &model) + const +{ + std::unique_ptr sdk; + + MetricReaderBuilder builder(this); + model->Accept(&builder); + sdk = std::move(builder.metric_reader); + + return sdk; +} + +std::unique_ptr +SdkBuilder::CreateBase2ExponentialBucketHistogramAggregation( + const opentelemetry::sdk::configuration::Base2ExponentialBucketHistogramAggregationConfiguration + *model) const +{ + auto sdk = + std::make_unique(); + + sdk->max_buckets_ = model->max_size; + sdk->max_scale_ = static_cast(model->max_scale); + sdk->record_min_max_ = model->record_min_max; + + return sdk; +} + +std::unique_ptr +SdkBuilder::CreateExplicitBucketHistogramAggregation( + const opentelemetry::sdk::configuration::ExplicitBucketHistogramAggregationConfiguration *model) + const +{ + auto sdk = std::make_unique(); + + sdk->boundaries_ = model->boundaries; + sdk->record_min_max_ = model->record_min_max; + + return sdk; +} + +std::unique_ptr SdkBuilder::CreateAggregationConfig( + const std::unique_ptr &model, + opentelemetry::sdk::metrics::AggregationType &aggregation_type) const +{ + std::unique_ptr sdk; + + AggregationConfigBuilder builder(this); + model->Accept(&builder); + aggregation_type = builder.aggregation_type; + sdk = std::move(builder.aggregation_config); + + return sdk; +} + +std::unique_ptr +SdkBuilder::CreateAttributesProcessor( + const std::unique_ptr + & /* model */) const +{ + std::unique_ptr sdk; + + // FIXME-SDK: https://github.com/open-telemetry/opentelemetry-cpp/issues/3546 + // FIXME-SDK: Need a subclass of AttributesProcessor for IncludeExclude + OTEL_INTERNAL_LOG_WARN("IncludeExclude attribute processor not supported, ignoring"); + + return sdk; +} + +void SdkBuilder::AddView( + opentelemetry::sdk::metrics::ViewRegistry *view_registry, + const std::unique_ptr &model) const +{ + auto *selector = model->selector.get(); + + if (selector->instrument_type == opentelemetry::sdk::configuration::InstrumentType::none) + { + std::string die("Runtime does not support instrument_type: null"); + throw UnsupportedException(die); + } + + auto sdk_instrument_type = ConvertInstrumentType(selector->instrument_type); + + auto sdk_instrument_selector = std::make_unique( + sdk_instrument_type, selector->instrument_name, selector->unit); + + auto sdk_meter_selector = std::make_unique( + selector->meter_name, selector->meter_version, selector->meter_schema_url); + + auto *stream = model->stream.get(); + + opentelemetry::sdk::metrics::AggregationType sdk_aggregation_type = + opentelemetry::sdk::metrics::AggregationType::kDefault; + + std::shared_ptr sdk_aggregation_config; + + sdk_aggregation_config = CreateAggregationConfig(stream->aggregation, sdk_aggregation_type); + + std::unique_ptr sdk_attribute_processor; + + if (stream->attribute_keys != nullptr) + { + sdk_attribute_processor = CreateAttributesProcessor(stream->attribute_keys); + } + + auto sdk_view = std::make_unique( + stream->name, stream->description, sdk_aggregation_type, sdk_aggregation_config, + std::move(sdk_attribute_processor)); + + view_registry->AddView(std::move(sdk_instrument_selector), std::move(sdk_meter_selector), + std::move(sdk_view)); +} + +std::unique_ptr SdkBuilder::CreateMeterProvider( + const std::unique_ptr &model, + const opentelemetry::sdk::resource::Resource &resource) const +{ + std::unique_ptr sdk; + + auto view_registry = opentelemetry::sdk::metrics::ViewRegistryFactory::Create(); + + for (const auto &view_configuration : model->views) + { + AddView(view_registry.get(), view_configuration); + } + + auto meter_context = + opentelemetry::sdk::metrics::MeterContextFactory::Create(std::move(view_registry), resource); + + for (const auto &reader_configuration : model->readers) + { + std::shared_ptr metric_reader; + metric_reader = CreateMetricReader(reader_configuration); + meter_context->AddMetricReader(metric_reader); + } + + sdk = opentelemetry::sdk::metrics::MeterProviderFactory::Create(std::move(meter_context)); + + return sdk; +} + +std::unique_ptr +SdkBuilder::CreateOtlpHttpLogRecordExporter( + const opentelemetry::sdk::configuration::OtlpHttpLogRecordExporterConfiguration *model) const +{ + std::unique_ptr sdk; + const OtlpHttpLogRecordExporterBuilder *builder; + + builder = registry_->GetOtlpHttpLogRecordBuilder(); + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateOtlpHttpLogRecordExporter() using registered http builder"); + sdk = builder->Build(model); + return sdk; + } + + static const std::string die("No http builder for OtlpLogRecordExporter"); + throw UnsupportedException(die); +} + +std::unique_ptr +SdkBuilder::CreateOtlpGrpcLogRecordExporter( + const opentelemetry::sdk::configuration::OtlpGrpcLogRecordExporterConfiguration *model) const +{ + std::unique_ptr sdk; + const OtlpGrpcLogRecordExporterBuilder *builder; + + builder = registry_->GetOtlpGrpcLogRecordBuilder(); + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateOtlpGrpcLogRecordExporter() using registered grpc builder"); + sdk = builder->Build(model); + return sdk; + } + + static const std::string die("No grpc builder for OtlpLogRecordExporter"); + throw UnsupportedException(die); +} + +std::unique_ptr +SdkBuilder::CreateOtlpFileLogRecordExporter( + const opentelemetry::sdk::configuration::OtlpFileLogRecordExporterConfiguration *model) const +{ + std::unique_ptr sdk; + const OtlpFileLogRecordExporterBuilder *builder; + + builder = registry_->GetOtlpFileLogRecordBuilder(); + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateOtlpFileLogRecordExporter() using registered file builder"); + sdk = builder->Build(model); + return sdk; + } + + static const std::string die("No file builder for OtlpLogRecordExporter"); + throw UnsupportedException(die); +} + +std::unique_ptr +SdkBuilder::CreateConsoleLogRecordExporter( + const opentelemetry::sdk::configuration::ConsoleLogRecordExporterConfiguration *model) const +{ + std::unique_ptr sdk; + const ConsoleLogRecordExporterBuilder *builder = registry_->GetConsoleLogRecordBuilder(); + + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateConsoleLogRecordExporter() using registered builder"); + sdk = builder->Build(model); + return sdk; + } + + static const std::string die("No builder for ConsoleLogRecordExporter"); + throw UnsupportedException(die); +} + +std::unique_ptr +SdkBuilder::CreateExtensionLogRecordExporter( + const opentelemetry::sdk::configuration::ExtensionLogRecordExporterConfiguration *model) const +{ + std::unique_ptr sdk; + std::string name = model->name; + + const ExtensionLogRecordExporterBuilder *builder = + registry_->GetExtensionLogRecordExporterBuilder(name); + + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateExtensionLogRecordExporter() using registered builder " << name); + sdk = builder->Build(model); + return sdk; + } + + std::string die("CreateExtensionLogRecordExporter() no builder for "); + die.append(name); + throw UnsupportedException(die); +} + +std::unique_ptr SdkBuilder::CreateLogRecordExporter( + const std::unique_ptr &model) + const +{ + std::unique_ptr sdk; + + LogRecordExporterBuilder builder(this); + model->Accept(&builder); + sdk = std::move(builder.exporter); + + return sdk; +} + +std::unique_ptr +SdkBuilder::CreateBatchLogRecordProcessor( + const opentelemetry::sdk::configuration::BatchLogRecordProcessorConfiguration *model) const +{ + std::unique_ptr sdk; + opentelemetry::sdk::logs::BatchLogRecordProcessorOptions options; + + options.schedule_delay_millis = std::chrono::milliseconds(model->schedule_delay); + options.max_queue_size = model->max_queue_size; + options.max_export_batch_size = model->max_export_batch_size; + + auto exporter_sdk = CreateLogRecordExporter(model->exporter); + + sdk = opentelemetry::sdk::logs::BatchLogRecordProcessorFactory::Create(std::move(exporter_sdk), + options); + + return sdk; +} + +std::unique_ptr +SdkBuilder::CreateSimpleLogRecordProcessor( + const opentelemetry::sdk::configuration::SimpleLogRecordProcessorConfiguration *model) const +{ + std::unique_ptr sdk; + + auto exporter_sdk = CreateLogRecordExporter(model->exporter); + + sdk = opentelemetry::sdk::logs::SimpleLogRecordProcessorFactory::Create(std::move(exporter_sdk)); + + return sdk; +} + +std::unique_ptr +SdkBuilder::CreateExtensionLogRecordProcessor( + const opentelemetry::sdk::configuration::ExtensionLogRecordProcessorConfiguration *model) const +{ + std::unique_ptr sdk; + std::string name = model->name; + + const ExtensionLogRecordProcessorBuilder *builder = + registry_->GetExtensionLogRecordProcessorBuilder(name); + + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateExtensionLogRecordProcessor() using registered builder " + << name); + sdk = builder->Build(model); + return sdk; + } + + std::string die("CreateExtensionLogRecordProcessor() no builder for "); + die.append(name); + throw UnsupportedException(die); +} + +std::unique_ptr SdkBuilder::CreateLogRecordProcessor( + const std::unique_ptr + &model) const +{ + std::unique_ptr sdk; + + LogRecordProcessorBuilder builder(this); + model->Accept(&builder); + sdk = std::move(builder.processor); + + return sdk; +} + +std::unique_ptr SdkBuilder::CreateLoggerProvider( + const std::unique_ptr &model, + const opentelemetry::sdk::resource::Resource &resource) const +{ + std::unique_ptr sdk; + + std::vector> sdk_processors; + + for (const auto &processor_model : model->processors) + { + sdk_processors.push_back(CreateLogRecordProcessor(processor_model)); + } + + // FIXME-SDK: https://github.com/open-telemetry/opentelemetry-cpp/issues/3303 + // FIXME-SDK: use limits + sdk = + opentelemetry::sdk::logs::LoggerProviderFactory::Create(std::move(sdk_processors), resource); + + return sdk; +} + +void SdkBuilder::SetResourceAttribute( + opentelemetry::sdk::resource::ResourceAttributes &resource_attributes, + const std::string &name, + const opentelemetry::sdk::configuration::AttributeValueConfiguration *model) const +{ + ResourceAttributeValueSetter setter(resource_attributes, name); + // Invokes resource_attributes.SetAttribute(name, ) + model->Accept(&setter); +} + +void SdkBuilder::SetResource( + opentelemetry::sdk::resource::Resource &resource, + const std::unique_ptr &opt_model) + const +{ + if (opt_model) + { + opentelemetry::sdk::resource::ResourceAttributes sdk_attributes; + + // First, scan attributes_list, which has low priority. + if (opt_model->attributes_list.size() != 0) + { + opentelemetry::common::KeyValueStringTokenizer tokenizer{opt_model->attributes_list}; + + opentelemetry::nostd::string_view attribute_key; + opentelemetry::nostd::string_view attribute_value; + bool attribute_valid = true; + + while (tokenizer.next(attribute_valid, attribute_key, attribute_value)) + { + if (attribute_valid) + { + opentelemetry::common::AttributeValue wrapped_attribute_value(attribute_value); + sdk_attributes.SetAttribute(attribute_key, wrapped_attribute_value); + } + else + { + OTEL_INTERNAL_LOG_WARN("Found invalid key/value pair in attributes_list"); + } + } + } + + // Second, scan attributes, which has high priority. + if (opt_model->attributes) + { + for (const auto &kv : opt_model->attributes->kv_map) + { + SetResourceAttribute(sdk_attributes, kv.first, kv.second.get()); + } + } + + if (opt_model->detectors != nullptr) + { + // FIXME-SDK: https://github.com/open-telemetry/opentelemetry-cpp/issues/3548 + // FIXME-SDK: Implement resource detectors + OTEL_INTERNAL_LOG_WARN("resource detectors not supported, ignoring"); + } + + auto sdk_resource = + opentelemetry::sdk::resource::Resource::Create(sdk_attributes, opt_model->schema_url); + resource = resource.Merge(sdk_resource); + } + else + { + resource = opentelemetry::sdk::resource::Resource::GetDefault(); + } +} + +std::unique_ptr SdkBuilder::CreateConfiguredSdk( + const std::unique_ptr &model) const +{ + auto sdk = std::make_unique(); + + if (!model->disabled) + { + SetResource(sdk->resource, model->resource); + + if (model->attribute_limits) + { + // FIXME-SDK: https://github.com/open-telemetry/opentelemetry-cpp/issues/3303 + // FIXME-SDK: Implement attribute limits + OTEL_INTERNAL_LOG_WARN("attribute_limits not supported, ignoring"); + } + + if (model->tracer_provider) + { + sdk->tracer_provider = CreateTracerProvider(model->tracer_provider, sdk->resource); + } + + if (model->propagator) + { + sdk->propagator = CreatePropagator(model->propagator); + } + + if (model->meter_provider) + { + sdk->meter_provider = CreateMeterProvider(model->meter_provider, sdk->resource); + } + + if (model->logger_provider) + { + sdk->logger_provider = CreateLoggerProvider(model->logger_provider, sdk->resource); + } + } + + return sdk; +} + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/src/logs/batch_log_record_processor.cc b/deps/opentelemetry-cpp/sdk/src/logs/batch_log_record_processor.cc index 14c88eeed9f..a656ef1f640 100644 --- a/deps/opentelemetry-cpp/sdk/src/logs/batch_log_record_processor.cc +++ b/deps/opentelemetry-cpp/sdk/src/logs/batch_log_record_processor.cc @@ -368,6 +368,19 @@ void BatchLogRecordProcessor::GetWaitAdjustedTime( } bool BatchLogRecordProcessor::Shutdown(std::chrono::microseconds timeout) noexcept +{ + return InternalShutdown(timeout); +} + +BatchLogRecordProcessor::~BatchLogRecordProcessor() +{ + if (synchronization_data_->is_shutdown.load() == false) + { + InternalShutdown(); + } +} + +bool BatchLogRecordProcessor::InternalShutdown(std::chrono::microseconds timeout) noexcept { auto start_time = std::chrono::system_clock::now(); @@ -391,14 +404,6 @@ bool BatchLogRecordProcessor::Shutdown(std::chrono::microseconds timeout) noexce return true; } -BatchLogRecordProcessor::~BatchLogRecordProcessor() -{ - if (synchronization_data_->is_shutdown.load() == false) - { - Shutdown(); - } -} - } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/src/logs/multi_log_record_processor.cc b/deps/opentelemetry-cpp/sdk/src/logs/multi_log_record_processor.cc index 8fdbf083289..d7dc1127d37 100644 --- a/deps/opentelemetry-cpp/sdk/src/logs/multi_log_record_processor.cc +++ b/deps/opentelemetry-cpp/sdk/src/logs/multi_log_record_processor.cc @@ -30,8 +30,8 @@ MultiLogRecordProcessor::MultiLogRecordProcessor( MultiLogRecordProcessor::~MultiLogRecordProcessor() { - ForceFlush(); - Shutdown(); + InternalForceFlush(); + InternalShutdown(); } void MultiLogRecordProcessor::AddProcessor(std::unique_ptr &&processor) @@ -74,6 +74,16 @@ void MultiLogRecordProcessor::OnEmit(std::unique_ptr &&record) noexc } bool MultiLogRecordProcessor::ForceFlush(std::chrono::microseconds timeout) noexcept +{ + return InternalForceFlush(timeout); +} + +bool MultiLogRecordProcessor::Shutdown(std::chrono::microseconds timeout) noexcept +{ + return InternalShutdown(timeout); +} + +bool MultiLogRecordProcessor::InternalForceFlush(std::chrono::microseconds timeout) noexcept { bool result = true; auto start_time = std::chrono::system_clock::now(); @@ -108,7 +118,7 @@ bool MultiLogRecordProcessor::ForceFlush(std::chrono::microseconds timeout) noex return result; } -bool MultiLogRecordProcessor::Shutdown(std::chrono::microseconds timeout) noexcept +bool MultiLogRecordProcessor::InternalShutdown(std::chrono::microseconds timeout) noexcept { bool result = true; auto start_time = std::chrono::system_clock::now(); diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/CMakeLists.txt b/deps/opentelemetry-cpp/sdk/src/metrics/CMakeLists.txt index b56fd553e92..73abddc16a7 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/CMakeLists.txt +++ b/deps/opentelemetry-cpp/sdk/src/metrics/CMakeLists.txt @@ -15,6 +15,7 @@ add_library( instrument_metadata_validator.cc export/periodic_exporting_metric_reader.cc export/periodic_exporting_metric_reader_factory.cc + export/periodic_exporting_metric_reader_options.cc state/filtered_ordered_attribute_map.cc state/metric_collector.cc state/observable_registry.cc diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/export/periodic_exporting_metric_reader_options.cc b/deps/opentelemetry-cpp/sdk/src/metrics/export/periodic_exporting_metric_reader_options.cc new file mode 100644 index 00000000000..94dbed48f8c --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/src/metrics/export/periodic_exporting_metric_reader_options.cc @@ -0,0 +1,35 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include + +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/common/env_variables.h" +#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_options.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace metrics +{ + +std::chrono::milliseconds GetEnvDuration(nostd::string_view env_var_name, + std::chrono::milliseconds default_value) +{ + std::chrono::system_clock::duration duration; + if (common::GetDurationEnvironmentVariable(env_var_name.data(), duration)) + { + return std::chrono::duration_cast(duration); + } + return default_value; +} + +PeriodicExportingMetricReaderOptions::PeriodicExportingMetricReaderOptions() + : export_interval_millis(GetEnvDuration("OTEL_METRIC_EXPORT_INTERVAL", kExportIntervalMillis)), + export_timeout_millis(GetEnvDuration("OTEL_METRIC_EXPORT_TIMEOUT", kExportTimeOutMillis)) +{} + +} // namespace metrics +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/state/sync_metric_storage.cc b/deps/opentelemetry-cpp/sdk/src/metrics/state/sync_metric_storage.cc index ad6ea278213..3844d2b05d8 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/state/sync_metric_storage.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/state/sync_metric_storage.cc @@ -9,6 +9,7 @@ #include "opentelemetry/common/timestamp.h" #include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" #include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" #include "opentelemetry/sdk/metrics/state/metric_collector.h" @@ -35,7 +36,7 @@ bool SyncMetricStorage::Collect(CollectorHandle *collector, { std::lock_guard guard(attribute_hashmap_lock_); delta_metrics = std::move(attributes_hashmap_); - attributes_hashmap_.reset(new AttributesHashMap); + attributes_hashmap_.reset(new AttributesHashMap(aggregation_config_->cardinality_limit_)); } return temporal_metric_storage_.buildMetrics(collector, collectors, sdk_start_ts, collection_ts, diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/state/temporal_metric_storage.cc b/deps/opentelemetry-cpp/sdk/src/metrics/state/temporal_metric_storage.cc index fb839ffd7ce..9e991f73f94 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/state/temporal_metric_storage.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/state/temporal_metric_storage.cc @@ -97,7 +97,9 @@ bool TemporalMetricStorage::buildMetrics(CollectorHandle *collector, } auto unreported_list = std::move(present->second); // Iterate over the unreporter metrics for `collector` and store result in `merged_metrics` - std::unique_ptr merged_metrics(new AttributesHashMap); + std::unique_ptr merged_metrics( + new AttributesHashMap(aggregation_config_ ? aggregation_config_->cardinality_limit_ + : kAggregationCardinalityLimit)); for (auto &agg_hashmap : unreported_list) { agg_hashmap->GetAllEnteries( diff --git a/deps/opentelemetry-cpp/sdk/src/metrics/view/view_factory.cc b/deps/opentelemetry-cpp/sdk/src/metrics/view/view_factory.cc index 319c10b956b..13d4678ece1 100644 --- a/deps/opentelemetry-cpp/sdk/src/metrics/view/view_factory.cc +++ b/deps/opentelemetry-cpp/sdk/src/metrics/view/view_factory.cc @@ -25,46 +25,36 @@ std::unique_ptr ViewFactory::Create(const std::string &name) std::unique_ptr ViewFactory::Create(const std::string &name, const std::string &description) { - return Create(name, description, "", AggregationType::kDefault); + return Create(name, description, AggregationType::kDefault); } std::unique_ptr ViewFactory::Create(const std::string &name, const std::string &description, - const std::string &unit) -{ - return Create(name, description, unit, AggregationType::kDefault); -} - -std::unique_ptr ViewFactory::Create(const std::string &name, - const std::string &description, - const std::string &unit, AggregationType aggregation_type) { std::shared_ptr aggregation_config(nullptr); - return Create(name, description, unit, aggregation_type, aggregation_config); + return Create(name, description, aggregation_type, aggregation_config); } std::unique_ptr ViewFactory::Create(const std::string &name, const std::string &description, - const std::string &unit, AggregationType aggregation_type, std::shared_ptr aggregation_config) { auto attributes_processor = std::unique_ptr(new DefaultAttributesProcessor()); - return Create(name, description, unit, aggregation_type, std::move(aggregation_config), + return Create(name, description, aggregation_type, std::move(aggregation_config), std::move(attributes_processor)); } std::unique_ptr ViewFactory::Create(const std::string &name, const std::string &description, - const std::string &unit, AggregationType aggregation_type, std::shared_ptr aggregation_config, std::unique_ptr attributes_processor) { - std::unique_ptr view(new View(name, description, unit, aggregation_type, + std::unique_ptr view(new View(name, description, aggregation_type, std::move(aggregation_config), std::move(attributes_processor))); return view; diff --git a/deps/opentelemetry-cpp/sdk/src/resource/resource.cc b/deps/opentelemetry-cpp/sdk/src/resource/resource.cc index 5ae5446e805..95b41498f8d 100644 --- a/deps/opentelemetry-cpp/sdk/src/resource/resource.cc +++ b/deps/opentelemetry-cpp/sdk/src/resource/resource.cc @@ -20,6 +20,12 @@ namespace sdk namespace resource { +Resource::Resource() noexcept : attributes_(), schema_url_() {} + +Resource::Resource(const ResourceAttributes &attributes) noexcept + : attributes_(attributes), schema_url_() +{} + Resource::Resource(const ResourceAttributes &attributes, const std::string &schema_url) noexcept : attributes_(attributes), schema_url_(schema_url) {} diff --git a/deps/opentelemetry-cpp/sdk/src/resource/resource_detector.cc b/deps/opentelemetry-cpp/sdk/src/resource/resource_detector.cc index 3158f2a43d9..f51d9a2a70a 100644 --- a/deps/opentelemetry-cpp/sdk/src/resource/resource_detector.cc +++ b/deps/opentelemetry-cpp/sdk/src/resource/resource_detector.cc @@ -19,8 +19,8 @@ namespace sdk namespace resource { -const char *OTEL_RESOURCE_ATTRIBUTES = "OTEL_RESOURCE_ATTRIBUTES"; -const char *OTEL_SERVICE_NAME = "OTEL_SERVICE_NAME"; +constexpr const char *kOtelResourceAttributes = "OTEL_RESOURCE_ATTRIBUTES"; +constexpr const char *kOtelServiceName = "OTEL_SERVICE_NAME"; Resource ResourceDetector::Create(const ResourceAttributes &attributes, const std::string &schema_url) @@ -33,9 +33,9 @@ Resource OTELResourceDetector::Detect() noexcept std::string attributes_str, service_name; bool attributes_exists = opentelemetry::sdk::common::GetStringEnvironmentVariable( - OTEL_RESOURCE_ATTRIBUTES, attributes_str); + kOtelResourceAttributes, attributes_str); bool service_name_exists = - opentelemetry::sdk::common::GetStringEnvironmentVariable(OTEL_SERVICE_NAME, service_name); + opentelemetry::sdk::common::GetStringEnvironmentVariable(kOtelServiceName, service_name); if (!attributes_exists && !service_name_exists) { diff --git a/deps/opentelemetry-cpp/sdk/src/trace/batch_span_processor.cc b/deps/opentelemetry-cpp/sdk/src/trace/batch_span_processor.cc index 5ec2376656f..ad93eae7aec 100644 --- a/deps/opentelemetry-cpp/sdk/src/trace/batch_span_processor.cc +++ b/deps/opentelemetry-cpp/sdk/src/trace/batch_span_processor.cc @@ -358,6 +358,19 @@ void BatchSpanProcessor::GetWaitAdjustedTime( } bool BatchSpanProcessor::Shutdown(std::chrono::microseconds timeout) noexcept +{ + return InternalShutdown(timeout); +} + +BatchSpanProcessor::~BatchSpanProcessor() +{ + if (synchronization_data_->is_shutdown.load() == false) + { + InternalShutdown(); + } +} + +bool BatchSpanProcessor::InternalShutdown(std::chrono::microseconds timeout) noexcept { auto start_time = std::chrono::system_clock::now(); std::lock_guard shutdown_guard{synchronization_data_->shutdown_m}; @@ -380,14 +393,6 @@ bool BatchSpanProcessor::Shutdown(std::chrono::microseconds timeout) noexcept return true; } -BatchSpanProcessor::~BatchSpanProcessor() -{ - if (synchronization_data_->is_shutdown.load() == false) - { - Shutdown(); - } -} - } // namespace trace } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/src/trace/samplers/parent.cc b/deps/opentelemetry-cpp/sdk/src/trace/samplers/parent.cc index 1e7dd9ba3df..e77db2e4aec 100644 --- a/deps/opentelemetry-cpp/sdk/src/trace/samplers/parent.cc +++ b/deps/opentelemetry-cpp/sdk/src/trace/samplers/parent.cc @@ -1,7 +1,6 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -21,9 +20,18 @@ namespace sdk { namespace trace { -ParentBasedSampler::ParentBasedSampler(const std::shared_ptr &delegate_sampler) noexcept - : delegate_sampler_(delegate_sampler), - description_("ParentBased{" + std::string{delegate_sampler->GetDescription()} + "}") +ParentBasedSampler::ParentBasedSampler( + const std::shared_ptr &root_sampler, + const std::shared_ptr &remote_parent_sampled_sampler, + const std::shared_ptr &remote_parent_nonsampled_sampler, + const std::shared_ptr &local_parent_sampled_sampler, + const std::shared_ptr &local_parent_nonsampled_sampler) noexcept + : root_sampler_(root_sampler), + remote_parent_sampled_sampler_(remote_parent_sampled_sampler), + remote_parent_nonsampled_sampler_(remote_parent_nonsampled_sampler), + local_parent_sampled_sampler_(local_parent_sampled_sampler), + local_parent_nonsampled_sampler_(local_parent_nonsampled_sampler), + description_("ParentBased{" + std::string{root_sampler->GetDescription()} + "}") {} SamplingResult ParentBasedSampler::ShouldSample( @@ -36,24 +44,38 @@ SamplingResult ParentBasedSampler::ShouldSample( { if (!parent_context.IsValid()) { - // If no parent (root span) exists returns the result of the delegateSampler - return delegate_sampler_->ShouldSample(parent_context, trace_id, name, span_kind, attributes, - links); + // If no parent (root span) exists returns the result of the root_sampler + return root_sampler_->ShouldSample(parent_context, trace_id, name, span_kind, attributes, + links); } // If parent exists: if (parent_context.IsSampled()) { - return {Decision::RECORD_AND_SAMPLE, nullptr, parent_context.trace_state()}; + if (parent_context.IsRemote()) + { + return remote_parent_sampled_sampler_->ShouldSample(parent_context, trace_id, name, span_kind, + attributes, links); + } + return local_parent_sampled_sampler_->ShouldSample(parent_context, trace_id, name, span_kind, + attributes, links); } - return {Decision::DROP, nullptr, parent_context.trace_state()}; + // Parent is not sampled + if (parent_context.IsRemote()) + { + return remote_parent_nonsampled_sampler_->ShouldSample(parent_context, trace_id, name, + span_kind, attributes, links); + } + return local_parent_nonsampled_sampler_->ShouldSample(parent_context, trace_id, name, span_kind, + attributes, links); } nostd::string_view ParentBasedSampler::GetDescription() const noexcept { return description_; } + } // namespace trace } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/src/trace/samplers/parent_factory.cc b/deps/opentelemetry-cpp/sdk/src/trace/samplers/parent_factory.cc index 25a2e94f653..a927ee7b2ea 100644 --- a/deps/opentelemetry-cpp/sdk/src/trace/samplers/parent_factory.cc +++ b/deps/opentelemetry-cpp/sdk/src/trace/samplers/parent_factory.cc @@ -4,6 +4,8 @@ #include #include "opentelemetry/sdk/trace/sampler.h" +#include "opentelemetry/sdk/trace/samplers/always_off.h" +#include "opentelemetry/sdk/trace/samplers/always_on.h" #include "opentelemetry/sdk/trace/samplers/parent.h" #include "opentelemetry/sdk/trace/samplers/parent_factory.h" #include "opentelemetry/version.h" @@ -15,9 +17,24 @@ namespace trace { std::unique_ptr ParentBasedSamplerFactory::Create( - const std::shared_ptr &delegate_sampler) + const std::shared_ptr &root_sampler) { - std::unique_ptr sampler(new ParentBasedSampler(delegate_sampler)); + std::unique_ptr sampler = ParentBasedSamplerFactory::Create( + root_sampler, std::make_shared(), std::make_shared(), + std::make_shared(), std::make_shared()); + return sampler; +} + +std::unique_ptr ParentBasedSamplerFactory::Create( + const std::shared_ptr &root_sampler, + const std::shared_ptr &remote_parent_sampled_sampler, + const std::shared_ptr &remote_parent_nonsampled_sampler, + const std::shared_ptr &local_parent_sampled_sampler, + const std::shared_ptr &local_parent_nonsampled_sampler) +{ + std::unique_ptr sampler(new ParentBasedSampler( + root_sampler, remote_parent_sampled_sampler, remote_parent_nonsampled_sampler, + local_parent_sampled_sampler, local_parent_nonsampled_sampler)); return sampler; } diff --git a/deps/opentelemetry-cpp/sdk/src/trace/samplers/trace_id_ratio.cc b/deps/opentelemetry-cpp/sdk/src/trace/samplers/trace_id_ratio.cc index fcb074ffc61..6d7009fedff 100644 --- a/deps/opentelemetry-cpp/sdk/src/trace/samplers/trace_id_ratio.cc +++ b/deps/opentelemetry-cpp/sdk/src/trace/samplers/trace_id_ratio.cc @@ -4,11 +4,11 @@ #include #include -#include #include #include #include +#include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/trace_id_ratio.h" @@ -56,8 +56,13 @@ uint64_t CalculateThresholdFromBuffer(const trace_api::TraceId &trace_id) noexce // We only use the first 8 bytes of TraceId. static_assert(trace_api::TraceId::kSize >= 8, "TraceID must be at least 8 bytes long."); - uint64_t res = 0; - std::memcpy(&res, &trace_id, 8); + // Always interpret as big-endian + const uint8_t *data = trace_id.Id().data(); + uint64_t res = 0; + for (int i = 0; i < 8; ++i) + { + res = (res << 8) | data[i]; + } double ratio = static_cast(res) / static_cast(UINT64_MAX); diff --git a/deps/opentelemetry-cpp/sdk/src/version/version.cc b/deps/opentelemetry-cpp/sdk/src/version/version.cc index 451f7d38eda..fb343dc0f52 100644 --- a/deps/opentelemetry-cpp/sdk/src/version/version.cc +++ b/deps/opentelemetry-cpp/sdk/src/version/version.cc @@ -12,13 +12,13 @@ namespace sdk namespace version { const int major_version = 1; -const int minor_version = 22; +const int minor_version = 23; const int patch_version = 0; -const char *pre_release = "NONE"; -const char *build_metadata = "NONE"; -const char *short_version = "1.22.0"; -const char *full_version = "1.22.0-NONE-NONE"; -const char *build_date = "Fri Jul 11 08:13:24 PM UTC 2025"; +const char *pre_release = ""; +const char *build_metadata = "none"; +const char *short_version = "1.23.0"; +const char *full_version = "1.23.0"; +const char *build_date = "Thu Sep 25 07:47:31 PM UTC 2025"; } // namespace version } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/deps/opentelemetry-cpp/sdk/test/configuration/yaml_metrics_test.cc b/deps/opentelemetry-cpp/sdk/test/configuration/yaml_metrics_test.cc index 8f963f293e0..4b202c2cf1c 100644 --- a/deps/opentelemetry-cpp/sdk/test/configuration/yaml_metrics_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/configuration/yaml_metrics_test.cc @@ -144,7 +144,7 @@ file_format: xx.yy readers: - pull: exporter: - prometheus: + prometheus/development: )"; auto config = DoParse(yaml); @@ -519,7 +519,7 @@ file_format: xx.yy readers: - pull: exporter: - prometheus: + prometheus/development: )"; auto config = DoParse(yaml); @@ -550,7 +550,7 @@ file_format: xx.yy readers: - pull: exporter: - prometheus: + prometheus/development: host: "prometheus" port: 1234 without_units: true diff --git a/deps/opentelemetry-cpp/sdk/test/configuration/yaml_propagator_test.cc b/deps/opentelemetry-cpp/sdk/test/configuration/yaml_propagator_test.cc new file mode 100644 index 00000000000..cba8bde4dad --- /dev/null +++ b/deps/opentelemetry-cpp/sdk/test/configuration/yaml_propagator_test.cc @@ -0,0 +1,172 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include +#include +#include +#include + +#include "opentelemetry/sdk/configuration/configuration.h" +#include "opentelemetry/sdk/configuration/propagator_configuration.h" +#include "opentelemetry/sdk/configuration/yaml_configuration_parser.h" + +static std::unique_ptr DoParse( + const std::string &yaml) +{ + static const std::string source("test"); + return opentelemetry::sdk::configuration::YamlConfigurationParser::ParseString(source, yaml); +} + +TEST(YamlPropagator, empty_propagator) +{ + std::string yaml = R"( +file_format: xx.yy +propagator: +)"; + + auto config = DoParse(yaml); + ASSERT_NE(config, nullptr); + ASSERT_NE(config->propagator, nullptr); + ASSERT_EQ(config->propagator->composite.size(), 0); + ASSERT_EQ(config->propagator->composite_list, ""); +} + +TEST(YamlPropagator, empty_composite) +{ + std::string yaml = R"( +file_format: xx.yy +propagator: + composite: +)"; + + auto config = DoParse(yaml); + ASSERT_NE(config, nullptr); + ASSERT_NE(config->propagator, nullptr); + ASSERT_EQ(config->propagator->composite.size(), 0); + ASSERT_EQ(config->propagator->composite_list, ""); +} + +TEST(YamlPropagator, old_propagator_1) +{ + // This is the old format, must fail + std::string yaml = R"( +file_format: xx.yy +propagator: + composite: + - foo + - bar +)"; + + auto config = DoParse(yaml); + ASSERT_EQ(config, nullptr); +} + +TEST(YamlPropagator, old_propagator_2) +{ + // This is the old format, must fail + std::string yaml = R"( +file_format: xx.yy +propagator: + composite: [foo, bar] +)"; + + auto config = DoParse(yaml); + ASSERT_EQ(config, nullptr); +} + +TEST(YamlPropagator, propagator_array_ok) +{ + std::string yaml = R"( +file_format: xx.yy +propagator: + composite: + - foo: + - bar: + - baz: +)"; + + auto config = DoParse(yaml); + ASSERT_NE(config, nullptr); + ASSERT_NE(config->propagator, nullptr); + ASSERT_EQ(config->propagator->composite.size(), 3); + ASSERT_EQ(config->propagator->composite[0], "foo"); + ASSERT_EQ(config->propagator->composite[1], "bar"); + ASSERT_EQ(config->propagator->composite[2], "baz"); + ASSERT_EQ(config->propagator->composite_list, ""); +} + +TEST(YamlPropagator, propagator_array_broken) +{ + std::string yaml = R"( +file_format: xx.yy +propagator: + composite: + - foo: + - bar: + baz: +)"; + + auto config = DoParse(yaml); + ASSERT_EQ(config, nullptr); +} + +TEST(YamlPropagator, propagator_composite_list) +{ + std::string yaml = R"( +file_format: xx.yy +propagator: + composite_list: "foo,bar,baz" +)"; + + auto config = DoParse(yaml); + ASSERT_NE(config, nullptr); + ASSERT_NE(config->propagator, nullptr); + ASSERT_EQ(config->propagator->composite.size(), 0); + ASSERT_EQ(config->propagator->composite_list, "foo,bar,baz"); +} + +TEST(YamlPropagator, propagator_both) +{ + std::string yaml = R"( +file_format: xx.yy +propagator: + composite: + - aaa: + - bbb: + - ccc: + composite_list: "ddd,eee,fff" +)"; + + auto config = DoParse(yaml); + ASSERT_NE(config, nullptr); + ASSERT_NE(config->propagator, nullptr); + ASSERT_EQ(config->propagator->composite.size(), 3); + ASSERT_EQ(config->propagator->composite[0], "aaa"); + ASSERT_EQ(config->propagator->composite[1], "bbb"); + ASSERT_EQ(config->propagator->composite[2], "ccc"); + ASSERT_EQ(config->propagator->composite_list, "ddd,eee,fff"); +} + +TEST(YamlPropagator, propagator_duplicates) +{ + std::string yaml = R"( +file_format: xx.yy +propagator: + composite: + - aaa: + - bbb: + - bbb: + - ccc: + composite_list: "aaa,eee,eee,fff,ccc" +)"; + + auto config = DoParse(yaml); + ASSERT_NE(config, nullptr); + ASSERT_NE(config->propagator, nullptr); + ASSERT_EQ(config->propagator->composite.size(), 4); + ASSERT_EQ(config->propagator->composite[0], "aaa"); + ASSERT_EQ(config->propagator->composite[1], "bbb"); + ASSERT_EQ(config->propagator->composite[2], "bbb"); + ASSERT_EQ(config->propagator->composite[3], "ccc"); + ASSERT_EQ(config->propagator->composite_list, "aaa,eee,eee,fff,ccc"); +} diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/async_metric_storage_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/async_metric_storage_test.cc index f6213793841..380ddd05643 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/async_metric_storage_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/async_metric_storage_test.cc @@ -25,11 +25,13 @@ #include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" #include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" #include "opentelemetry/sdk/metrics/state/metric_collector.h" -#include "opentelemetry/sdk/metrics/view/attributes_processor.h" #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW +# include "opentelemetry/sdk/metrics/data/exemplar_data.h" # include "opentelemetry/sdk/metrics/exemplar/filter_type.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir.h" +#else +# include "opentelemetry/sdk/metrics/view/attributes_processor.h" #endif using namespace opentelemetry::sdk::metrics; @@ -192,8 +194,10 @@ TEST_P(WritableMetricStorageTestUpDownFixture, TestAggregation) } return true; }); - // subsequent recording after collection shouldn't fail - // monotonic increasing values; + // Note: When the cardinality limit is set to n, the attributes hashmap emits n-1 distinct + // attribute sets, plus an overflow bucket for additional attributes. The test logic below is made + // generic to succeed for either n or n-1 total cardinality. If this behavior is unexpected, + // please investigate and file an issue. int64_t get_count2 = -50; int64_t put_count2 = -70; diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/attributes_hashmap_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/attributes_hashmap_test.cc index c51f4fe8003..944bbef3b69 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/attributes_hashmap_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/attributes_hashmap_test.cc @@ -158,3 +158,67 @@ TEST(AttributesHashMap, HashConsistencyAcrossStringTypes) EXPECT_EQ(hash_c_str, hash_std_str_view); #endif } + +TEST(AttributesHashMap, OverflowCardinalityLimitBehavior) +{ + // Configure a very small limit to exercise overflow logic easily. + const size_t limit = 4; // real attributes limit + AttributesHashMapWithCustomHash<> map(limit); + + // We expect to be able to insert exactly 'limit' distinct real attribute sets. + // After that, further distinct attributes should route to the overflow bucket, + // which should appear only once regardless of how many additional unique sets arrive. + + // Insert distinct attributes up to the limit. + for (size_t i = 0; i < limit; ++i) + { + MetricAttributes attr = {{"k", std::to_string(i)}}; + map.GetOrSetDefault(attr, []() { return std::unique_ptr(new DropAggregation()); }) + ->Aggregate(static_cast(1)); + } + + // Size should be exactly 'limit' (no overflow yet) + EXPECT_EQ(map.Size(), limit); + + // Insert one more distinct attribute; this should not increase the real attributes count + MetricAttributes overflow_trigger = {{"k", "overflow"}}; + map.GetOrSetDefault(overflow_trigger, + []() { return std::unique_ptr(new DropAggregation()); }) + ->Aggregate(static_cast(1)); + + EXPECT_EQ(map.Size(), limit); + + // Insert several more unique attributes - size must remain constant (limit) + for (size_t i = 0; i < limit - 1; ++i) + { + MetricAttributes extra_attr = {{"k", std::string("extra") + std::to_string(i)}}; + map.GetOrSetDefault(extra_attr, + []() { return std::unique_ptr(new DropAggregation()); }) + ->Aggregate(static_cast(1)); + } + EXPECT_EQ(map.Size(), limit); + + // Ensure overflow key was actually created and accessible via Get + EXPECT_NE(map.Get(kOverflowAttributes), nullptr); + + // Ensure original real attributes still present + for (size_t i = 0; i < limit - 1; ++i) + { + MetricAttributes attr = {{"k", std::to_string(i)}}; + EXPECT_NE(map.Get(attr), nullptr); + } + + // Copy the hash map to a new map in non-determistic order and verify all entries are present + AttributesHashMapWithCustomHash<> map_copy(limit); + map.GetAllEnteries([&map_copy](const MetricAttributes &attributes, Aggregation &) { + map_copy.Set(attributes, std::unique_ptr(new DropAggregation())); + return true; + }); + EXPECT_EQ(map_copy.Size(), map.Size()); + EXPECT_NE(map_copy.Get(kOverflowAttributes), nullptr); + for (size_t i = 0; i < limit - 1; ++i) + { + MetricAttributes attr = {{"k", std::to_string(i)}}; + EXPECT_NE(map_copy.Get(attr), nullptr); + } +} diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/attributes_processor_benchmark.cc b/deps/opentelemetry-cpp/sdk/test/metrics/attributes_processor_benchmark.cc index 02923c56424..c64aa6a77c4 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/attributes_processor_benchmark.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/attributes_processor_benchmark.cc @@ -4,7 +4,6 @@ #include #include #include -#include #include #include "opentelemetry/common/key_value_iterable_view.h" diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/attributes_processor_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/attributes_processor_test.cc index 25652ed3e15..3e13f0e1011 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/attributes_processor_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/attributes_processor_test.cc @@ -8,7 +8,7 @@ #include #include "opentelemetry/common/key_value_iterable_view.h" -#include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/common/custom_hash_equality.h" #include "opentelemetry/sdk/metrics/view/attributes_processor.h" using namespace opentelemetry::sdk::metrics; @@ -17,8 +17,8 @@ using namespace opentelemetry::sdk::common; TEST(AttributesProcessor, FilteringAttributesProcessor) { - const int kNumFilterAttributes = 3; - std::unordered_map filter = { + const int kNumFilterAttributes = 3; + opentelemetry::sdk::metrics::FilterAttributeMap filter = { {"attr2", true}, {"attr4", true}, {"attr6", true}}; const int kNumAttributes = 6; std::string keys[kNumAttributes] = {"attr1", "attr2", "attr3", "attr4", "attr5", "attr6"}; @@ -38,9 +38,9 @@ TEST(AttributesProcessor, FilteringAttributesProcessor) TEST(AttributesProcessor, FilteringAllAttributesProcessor) { - const int kNumFilterAttributes = 0; - std::unordered_map filter = {}; - const int kNumAttributes = 6; + const int kNumFilterAttributes = 0; + opentelemetry::sdk::metrics::FilterAttributeMap filter = {}; + const int kNumAttributes = 6; std::string keys[kNumAttributes] = {"attr1", "attr2", "attr3", "attr4", "attr5", "attr6"}; int values[kNumAttributes] = {10, 20, 30, 40, 50, 60}; std::map attributes = {{keys[0], values[0]}, {keys[1], values[1]}, @@ -51,3 +51,40 @@ TEST(AttributesProcessor, FilteringAllAttributesProcessor) auto filtered_attributes = attributes_processor.process(iterable); EXPECT_EQ(filter.size(), kNumFilterAttributes); } + +TEST(AttributesProcessor, FilteringExcludeAttributesProcessor) +{ + opentelemetry::sdk::metrics::FilterAttributeMap filter = { + {"attr2", true}, {"attr4", true}, {"attr6", true}}; + const int kNumAttributes = 7; + std::string keys[kNumAttributes] = {"attr1", "attr2", "attr3", "attr4", + "attr5", "attr6", "attr7"}; + int values[kNumAttributes] = {10, 20, 30, 40, 50, 60, 70}; + std::map attributes = { + {keys[0], values[0]}, {keys[1], values[1]}, {keys[2], values[2]}, {keys[3], values[3]}, + {keys[4], values[4]}, {keys[5], values[5]}, {keys[6], values[6]}}; + FilteringExcludeAttributesProcessor attributes_processor(filter); + opentelemetry::common::KeyValueIterableView> iterable(attributes); + auto filtered_attributes = attributes_processor.process(iterable); + for (auto &e : filtered_attributes) + { + EXPECT_TRUE(filter.find(e.first) == filter.end()); + } + int expected_filtered_attributes_size = 4; + EXPECT_EQ(filtered_attributes.size(), expected_filtered_attributes_size); +} + +TEST(AttributesProcessor, FilteringExcludeAllAttributesProcessor) +{ + opentelemetry::sdk::metrics::FilterAttributeMap filter = {}; + const int kNumAttributes = 6; + std::string keys[kNumAttributes] = {"attr1", "attr2", "attr3", "attr4", "attr5", "attr6"}; + int values[kNumAttributes] = {10, 20, 30, 40, 50, 60}; + std::map attributes = {{keys[0], values[0]}, {keys[1], values[1]}, + {keys[2], values[2]}, {keys[3], values[3]}, + {keys[4], values[4]}, {keys[5], values[5]}}; + FilteringExcludeAttributesProcessor attributes_processor(filter); + opentelemetry::common::KeyValueIterableView> iterable(attributes); + auto filtered_attributes = attributes_processor.process(iterable); + EXPECT_EQ(filtered_attributes.size(), kNumAttributes); +} diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/cardinality_limit_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/cardinality_limit_test.cc index 45e15200c35..61a47c5983d 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/cardinality_limit_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/cardinality_limit_test.cc @@ -20,6 +20,7 @@ #include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/metrics/aggregation/aggregation.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" #include "opentelemetry/sdk/metrics/aggregation/sum_aggregation.h" #include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/data/point_data.h" @@ -110,6 +111,7 @@ TEST_P(WritableMetricStorageCardinalityLimitTestFixture, LongCounterSumAggregati const size_t attributes_limit = 10; InstrumentDescriptor instr_desc = {"name", "desc", "1unit", InstrumentType::kCounter, InstrumentValueType::kLong}; + AggregationConfig aggConfig(attributes_limit); std::shared_ptr default_attributes_processor{ new DefaultAttributesProcessor{}}; SyncMetricStorage storage(instr_desc, AggregationType::kSum, default_attributes_processor, @@ -117,7 +119,7 @@ TEST_P(WritableMetricStorageCardinalityLimitTestFixture, LongCounterSumAggregati ExemplarFilterType::kAlwaysOff, ExemplarReservoir::GetNoExemplarReservoir(), #endif - nullptr, attributes_limit); + &aggConfig); int64_t record_value = 100; // add 9 unique metric points, and 6 more above limit. diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/histogram_aggregation_benchmark.cc b/deps/opentelemetry-cpp/sdk/test/metrics/histogram_aggregation_benchmark.cc index 45fcb5b1a45..e4b90eebc41 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/histogram_aggregation_benchmark.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/histogram_aggregation_benchmark.cc @@ -116,8 +116,7 @@ void RunBase2ExponentialHistogramAggregation(benchmark::State &state, int scale) config.max_scale_ = scale; std::unique_ptr histogram_view{ - new View("base2_expohisto", "description", instrument_unit, - AggregationType::kBase2ExponentialHistogram, + new View("base2_expohisto", "description", AggregationType::kBase2ExponentialHistogram, std::make_shared(config))}; std::unique_ptr views{new ViewRegistry()}; diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/histogram_aggregation_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/histogram_aggregation_test.cc index 25640209d16..9de7af7d8e6 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/histogram_aggregation_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/histogram_aggregation_test.cc @@ -87,8 +87,7 @@ TEST(CounterToHistogram, Double) std::shared_ptr reader{new MockMetricReader(std::move(exporter))}; mp.AddMetricReader(reader); - std::unique_ptr view{ - new View("view1", "view1_description", "unit", AggregationType::kHistogram)}; + std::unique_ptr view{new View("view1", "view1_description", AggregationType::kHistogram)}; std::unique_ptr instrument_selector{ new InstrumentSelector(InstrumentType::kCounter, "counter1", "unit")}; std::unique_ptr meter_selector{new MeterSelector("meter1", "version1", "schema1")}; diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/histogram_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/histogram_test.cc index a75b4f3f139..ad819d9e998 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/histogram_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/histogram_test.cc @@ -103,7 +103,7 @@ TEST(Histogram, DoubleCustomBuckets) std::shared_ptr config(new HistogramAggregationConfig()); config->boundaries_ = {10, 20, 30, 40}; std::unique_ptr view{ - new View("view1", "view1_description", instrument_unit, AggregationType::kHistogram, config)}; + new View("view1", "view1_description", AggregationType::kHistogram, config)}; std::unique_ptr instrument_selector{ new InstrumentSelector(InstrumentType::kHistogram, instrument_name, instrument_unit)}; std::unique_ptr meter_selector{new MeterSelector("meter1", "version1", "schema1")}; @@ -163,7 +163,7 @@ TEST(Histogram, DoubleEmptyBuckets) std::shared_ptr config(new HistogramAggregationConfig()); config->boundaries_ = {}; std::unique_ptr view{ - new View("view1", "view1_description", instrument_unit, AggregationType::kHistogram, config)}; + new View("view1", "view1_description", AggregationType::kHistogram, config)}; std::unique_ptr instrument_selector{ new InstrumentSelector(InstrumentType::kHistogram, instrument_name, instrument_unit)}; std::unique_ptr meter_selector{new MeterSelector("meter1", "version1", "schema1")}; @@ -278,7 +278,7 @@ TEST(Histogram, UInt64CustomBuckets) std::shared_ptr config(new HistogramAggregationConfig()); config->boundaries_ = {10, 20, 30, 40}; std::unique_ptr view{ - new View("view1", "view1_description", "ms", AggregationType::kHistogram, config)}; + new View("view1", "view1_description", AggregationType::kHistogram, config)}; std::unique_ptr instrument_selector{ new InstrumentSelector(InstrumentType::kHistogram, instrument_name, instrument_unit)}; std::unique_ptr meter_selector{new MeterSelector("meter1", "version1", "schema1")}; @@ -338,7 +338,7 @@ TEST(Histogram, UInt64EmptyBuckets) std::shared_ptr config(new HistogramAggregationConfig()); config->boundaries_ = {}; std::unique_ptr view{ - new View("view1", "view1_description", "ms", AggregationType::kHistogram, config)}; + new View("view1", "view1_description", AggregationType::kHistogram, config)}; std::unique_ptr instrument_selector{ new InstrumentSelector(InstrumentType::kHistogram, instrument_name, instrument_unit)}; std::unique_ptr meter_selector{new MeterSelector("meter1", "version1", "schema1")}; diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/meter_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/meter_test.cc index a4212996a36..5fe99b41a83 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/meter_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/meter_test.cc @@ -881,7 +881,7 @@ TEST(MeterTest, RecordAfterProviderDestructionWithCustomProcessor_NoResetInMain) // Register a View with custom processor std::unique_ptr view( - new View("my_counter", "", "", AggregationType::kSum, nullptr, std::move(processor))); + new View("my_counter", "", AggregationType::kSum, nullptr, std::move(processor))); std::unique_ptr instr_selector( new InstrumentSelector(InstrumentType::kCounter, "my_counter", "")); std::unique_ptr meter_selector(new MeterSelector("test_meter", "", "")); diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/periodic_exporting_metric_reader_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/periodic_exporting_metric_reader_test.cc index 158ba49c145..2b817276e8d 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/periodic_exporting_metric_reader_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/periodic_exporting_metric_reader_test.cc @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -18,6 +19,12 @@ #include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#if defined(_MSC_VER) +# include "opentelemetry/sdk/common/env_variables.h" +using opentelemetry::sdk::common::setenv; +using opentelemetry::sdk::common::unsetenv; +#endif + using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; using namespace opentelemetry::sdk::metrics; @@ -76,7 +83,7 @@ class MockMetricProducer : public MetricProducer size_t data_sent_size_{0}; }; -TEST(PeriodicExporingMetricReader, BasicTests) +TEST(PeriodicExportingMetricReader, BasicTests) { std::unique_ptr exporter( new MockPushMetricExporter(std::chrono::milliseconds{0})); @@ -95,7 +102,7 @@ TEST(PeriodicExporingMetricReader, BasicTests) static_cast(&producer)->GetDataCount()); } -TEST(PeriodicExporingMetricReader, Timeout) +TEST(PeriodicExportingMetricReader, Timeout) { std::unique_ptr exporter( new MockPushMetricExporter(std::chrono::milliseconds{2000})); @@ -109,3 +116,32 @@ TEST(PeriodicExporingMetricReader, Timeout) std::this_thread::sleep_for(std::chrono::milliseconds(1000)); reader->Shutdown(); } + +TEST(PeriodicExportingMetricReaderOptions, UsesEnvVars) +{ + const char *env_interval = "OTEL_METRIC_EXPORT_INTERVAL"; + const char *env_timeout = "OTEL_METRIC_EXPORT_TIMEOUT"; + + setenv(env_interval, "1500ms", 1); + setenv(env_timeout, "1000ms", 1); + + PeriodicExportingMetricReaderOptions options; + EXPECT_EQ(options.export_interval_millis, std::chrono::milliseconds(1500)); + EXPECT_EQ(options.export_timeout_millis, std::chrono::milliseconds(1000)); + + unsetenv(env_interval); + unsetenv(env_timeout); +} + +TEST(PeriodicExportingMetricReaderOptions, UsesDefault) +{ + const char *env_interval = "OTEL_METRIC_EXPORT_INTERVAL"; + const char *env_timeout = "OTEL_METRIC_EXPORT_TIMEOUT"; + + unsetenv(env_interval); + unsetenv(env_timeout); + + PeriodicExportingMetricReaderOptions options; + EXPECT_EQ(options.export_interval_millis, std::chrono::milliseconds(60000)); + EXPECT_EQ(options.export_timeout_millis, std::chrono::milliseconds(30000)); +} diff --git a/deps/opentelemetry-cpp/sdk/test/metrics/sum_aggregation_test.cc b/deps/opentelemetry-cpp/sdk/test/metrics/sum_aggregation_test.cc index 732f29e1f47..02421a9e260 100644 --- a/deps/opentelemetry-cpp/sdk/test/metrics/sum_aggregation_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/metrics/sum_aggregation_test.cc @@ -2,7 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include #include +#include #include #include #include @@ -26,6 +28,7 @@ #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" #include "opentelemetry/sdk/metrics/view/attributes_processor.h" #include "opentelemetry/sdk/metrics/view/instrument_selector.h" #include "opentelemetry/sdk/metrics/view/meter_selector.h" @@ -42,15 +45,14 @@ TEST(HistogramToSum, Double) MeterProvider mp; auto m = mp.GetMeter("meter1", "version1", "schema1"); std::string instrument_unit = "ms"; - std::string instrument_name = "historgram1"; + std::string instrument_name = "histogram1"; std::string instrument_desc = "histogram metrics"; std::unique_ptr exporter(new MockMetricExporter()); std::shared_ptr reader{new MockMetricReader(std::move(exporter))}; mp.AddMetricReader(reader); - std::unique_ptr view{ - new View("view1", "view1_description", instrument_unit, AggregationType::kSum)}; + std::unique_ptr view{new View("view1", "view1_description", AggregationType::kSum)}; std::unique_ptr instrument_selector{ new InstrumentSelector(InstrumentType::kHistogram, instrument_name, instrument_unit)}; std::unique_ptr meter_selector{new MeterSelector("meter1", "version1", "schema1")}; @@ -95,10 +97,10 @@ TEST(HistogramToSumFilterAttributes, Double) MeterProvider mp; auto m = mp.GetMeter("meter1", "version1", "schema1"); std::string instrument_unit = "ms"; - std::string instrument_name = "historgram1"; + std::string instrument_name = "histogram1"; std::string instrument_desc = "histogram metrics"; - std::unordered_map allowedattr; + opentelemetry::sdk::metrics::FilterAttributeMap allowedattr; allowedattr["attr1"] = true; std::unique_ptr attrproc{ new opentelemetry::sdk::metrics::FilteringAttributesProcessor(allowedattr)}; @@ -109,9 +111,8 @@ TEST(HistogramToSumFilterAttributes, Double) std::shared_ptr reader{new MockMetricReader(std::move(exporter))}; mp.AddMetricReader(reader); - std::unique_ptr view{new View("view1", "view1_description", instrument_unit, - AggregationType::kSum, dummy_aggregation_config, - std::move(attrproc))}; + std::unique_ptr view{new View("view1", "view1_description", AggregationType::kSum, + dummy_aggregation_config, std::move(attrproc))}; std::unique_ptr instrument_selector{ new InstrumentSelector(InstrumentType::kHistogram, instrument_name, instrument_unit)}; std::unique_ptr meter_selector{new MeterSelector("meter1", "version1", "schema1")}; @@ -144,6 +145,85 @@ TEST(HistogramToSumFilterAttributes, Double) }); } +TEST(HistogramToSumFilterAttributesWithCardinalityLimit, Double) +{ + MeterProvider mp; + auto m = mp.GetMeter("meter1", "version1", "schema1"); + std::string instrument_unit = "ms"; + std::string instrument_name = "histogram1"; + std::string instrument_desc = "histogram metrics"; + size_t cardinality_limit = 10000; + + opentelemetry::sdk::metrics::FilterAttributeMap allowedattr; + allowedattr["attr1"] = true; + std::unique_ptr attrproc{ + new opentelemetry::sdk::metrics::FilteringAttributesProcessor(allowedattr)}; + + std::shared_ptr dummy_aggregation_config{ + new opentelemetry::sdk::metrics::AggregationConfig(cardinality_limit)}; + std::unique_ptr exporter(new MockMetricExporter()); + std::shared_ptr reader{new MockMetricReader(std::move(exporter))}; + mp.AddMetricReader(reader); + + std::unique_ptr view{new View("view1", "view1_description", AggregationType::kSum, + dummy_aggregation_config, std::move(attrproc))}; + std::unique_ptr instrument_selector{ + new InstrumentSelector(InstrumentType::kHistogram, instrument_name, instrument_unit)}; + std::unique_ptr meter_selector{new MeterSelector("meter1", "version1", "schema1")}; + mp.AddView(std::move(instrument_selector), std::move(meter_selector), std::move(view)); + + auto h = m->CreateDoubleHistogram(instrument_name, instrument_desc, instrument_unit); + size_t total_metrics_times = 5; + + size_t agg_repeat_count = 5; + for (size_t repeat = 0; repeat < agg_repeat_count; repeat++) + { + + for (size_t times = 0; times < total_metrics_times; times++) + { + for (size_t i = 0; i < 2 * cardinality_limit; i++) + { + std::unordered_map attr = {{"attr1", std::to_string(i)}, + {"attr2", "val2"}}; + h->Record(1, attr, opentelemetry::context::Context{}); + } + } + + reader->Collect([&](ResourceMetrics &rm) { + for (const ScopeMetrics &smd : rm.scope_metric_data_) + { + for (const MetricData &md : smd.metric_data_) + { + // Something weird about attributes hashmap. If cardinality is setup to n, it emits n-1 + // including overflow. Just making the logic generic here to succeed for n or n-1 total + // cardinality. + EXPECT_GE(cardinality_limit, md.point_data_attr_.size()); + EXPECT_LT(cardinality_limit / 2, md.point_data_attr_.size()); + for (size_t i = 0; i < md.point_data_attr_.size(); i++) + { + EXPECT_EQ(1, md.point_data_attr_[i].attributes.size()); + if (md.point_data_attr_[i].attributes.end() != + md.point_data_attr_[i].attributes.find("attr1")) + { + EXPECT_EQ(total_metrics_times * (repeat + 1), + opentelemetry::nostd::get(opentelemetry::nostd::get( + md.point_data_attr_[i].point_data) + .value_)); + } + else + { + EXPECT_NE(md.point_data_attr_[i].attributes.end(), + md.point_data_attr_[i].attributes.find( + sdk::metrics::kAttributesLimitOverflowKey)); + } + } + } + } + return true; + }); + } +} + TEST(CounterToSum, Double) { MeterProvider mp; @@ -153,7 +233,7 @@ TEST(CounterToSum, Double) std::shared_ptr reader{new MockMetricReader(std::move(exporter))}; mp.AddMetricReader(reader); - std::unique_ptr view{new View("view1", "view1_description", "ms", AggregationType::kSum)}; + std::unique_ptr view{new View("view1", "view1_description", AggregationType::kSum)}; std::unique_ptr instrument_selector{ new InstrumentSelector(InstrumentType::kCounter, "counter1", "ms")}; std::unique_ptr meter_selector{new MeterSelector("meter1", "version1", "schema1")}; @@ -201,7 +281,7 @@ TEST(CounterToSumFilterAttributes, Double) std::string instrument_name = "counter1"; std::string instrument_desc = "counter metrics"; - std::unordered_map allowedattr; + opentelemetry::sdk::metrics::FilterAttributeMap allowedattr; allowedattr["attr1"] = true; std::unique_ptr attrproc{ new opentelemetry::sdk::metrics::FilteringAttributesProcessor(allowedattr)}; @@ -212,9 +292,8 @@ TEST(CounterToSumFilterAttributes, Double) std::shared_ptr reader{new MockMetricReader(std::move(exporter))}; mp.AddMetricReader(reader); - std::unique_ptr view{new View("view1", "view1_description", instrument_unit, - AggregationType::kSum, dummy_aggregation_config, - std::move(attrproc))}; + std::unique_ptr view{new View("view1", "view1_description", AggregationType::kSum, + dummy_aggregation_config, std::move(attrproc))}; std::unique_ptr instrument_selector{ new InstrumentSelector(InstrumentType::kCounter, instrument_name, instrument_unit)}; std::unique_ptr meter_selector{new MeterSelector("meter1", "version1", "schema1")}; @@ -247,6 +326,87 @@ TEST(CounterToSumFilterAttributes, Double) }); } +TEST(CounterToSumFilterAttributesWithCardinalityLimit, Double) +{ + MeterProvider mp; + auto m = mp.GetMeter("meter1", "version1", "schema1"); + std::string instrument_unit = "ms"; + std::string instrument_name = "counter1"; + std::string instrument_desc = "counter metrics"; + size_t cardinality_limit = 10000; + + opentelemetry::sdk::metrics::FilterAttributeMap allowedattr; + allowedattr["attr1"] = true; + std::unique_ptr attrproc{ + new opentelemetry::sdk::metrics::FilteringAttributesProcessor(allowedattr)}; + + std::shared_ptr dummy_aggregation_config{ + new opentelemetry::sdk::metrics::AggregationConfig(cardinality_limit)}; + std::unique_ptr exporter(new MockMetricExporter()); + std::shared_ptr reader{new MockMetricReader(std::move(exporter))}; + mp.AddMetricReader(reader); + + std::unique_ptr view{new View("view1", "view1_description", AggregationType::kSum, + dummy_aggregation_config, std::move(attrproc))}; + std::unique_ptr instrument_selector{ + new InstrumentSelector(InstrumentType::kCounter, instrument_name, instrument_unit)}; + std::unique_ptr meter_selector{new MeterSelector("meter1", "version1", "schema1")}; + mp.AddView(std::move(instrument_selector), std::move(meter_selector), std::move(view)); + + auto c = m->CreateDoubleCounter(instrument_name, instrument_desc, instrument_unit); + + size_t agg_repeat_count = 5; + for (size_t repeat = 0; repeat < agg_repeat_count; repeat++) + { + size_t total_metrics_times = 5; + + for (size_t times = 0; times < total_metrics_times; times++) + { + for (size_t i = 0; i < 2 * cardinality_limit; i++) + { + std::unordered_map attr = {{"attr1", std::to_string(i)}, + {"attr2", "val2"}}; + c->Add(1, attr, opentelemetry::context::Context{}); + } + } + + reader->Collect([&](ResourceMetrics &rm) { + for (const ScopeMetrics &smd : rm.scope_metric_data_) + { + for (const MetricData &md : smd.metric_data_) + { + // When the number of unique attribute sets exceeds the cardinality limit, the + // implementation emits up to (cardinality_limit - 1) unique sets and one overflow set, + // resulting in a total of cardinality_limit sets. This test checks that the number of + // emitted attribute sets is within the expected range, accounting for the overflow + // behavior. + EXPECT_GE(cardinality_limit, md.point_data_attr_.size()); + EXPECT_LT(cardinality_limit / 2, md.point_data_attr_.size()); + for (size_t i = 0; i < md.point_data_attr_.size(); i++) + { + EXPECT_EQ(1, md.point_data_attr_[i].attributes.size()); + if (md.point_data_attr_[i].attributes.find("attr1") != + md.point_data_attr_[i].attributes.end()) + { + EXPECT_EQ(total_metrics_times * (repeat + 1), + opentelemetry::nostd::get(opentelemetry::nostd::get( + md.point_data_attr_[i].point_data) + .value_)); + } + else + { + EXPECT_NE(md.point_data_attr_[i].attributes.end(), + md.point_data_attr_[i].attributes.find( + sdk::metrics::kAttributesLimitOverflowKey)); + } + } + } + } + return true; + }); + } +} + class UpDownCounterToSumFixture : public ::testing::TestWithParam {}; @@ -265,8 +425,7 @@ TEST_P(UpDownCounterToSumFixture, Double) if (is_matching_view) { - std::unique_ptr view{ - new View("view1", "view1_description", instrument_unit, AggregationType::kSum)}; + std::unique_ptr view{new View("view1", "view1_description", AggregationType::kSum)}; std::unique_ptr instrument_selector{ new InstrumentSelector(InstrumentType::kUpDownCounter, instrument_name, instrument_unit)}; std::unique_ptr meter_selector{ diff --git a/deps/opentelemetry-cpp/sdk/test/trace/parent_sampler_test.cc b/deps/opentelemetry-cpp/sdk/test/trace/parent_sampler_test.cc index e5ac16ff140..db179c96952 100644 --- a/deps/opentelemetry-cpp/sdk/test/trace/parent_sampler_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/trace/parent_sampler_test.cc @@ -51,10 +51,14 @@ TEST(ParentBasedSampler, ShouldSample) opentelemetry::common::KeyValueIterableView view{m1}; trace_api::SpanContextKeyValueIterableView links{l1}; auto trace_state = trace_api::TraceState::FromHeader("congo=t61rcWkgMzE"); - trace_api::SpanContext parent_context_sampled(trace_id, span_id, trace_api::TraceFlags{1}, false, - trace_state); - trace_api::SpanContext parent_context_nonsampled(trace_id, span_id, trace_api::TraceFlags{0}, - false, trace_state); + trace_api::SpanContext parent_context_sampled_local(trace_id, span_id, trace_api::TraceFlags{1}, + false, trace_state); + trace_api::SpanContext parent_context_nonsampled_local( + trace_id, span_id, trace_api::TraceFlags{0}, false, trace_state); + trace_api::SpanContext parent_context_sampled_remote(trace_id, span_id, trace_api::TraceFlags{1}, + true, trace_state); + trace_api::SpanContext parent_context_nonsampled_remote( + trace_id, span_id, trace_api::TraceFlags{0}, true, trace_state); // Case 1: Parent doesn't exist. Return result of delegateSampler() auto sampling_result = sampler_off.ShouldSample(trace_api::SpanContext::GetInvalid(), trace_id, @@ -67,17 +71,29 @@ TEST(ParentBasedSampler, ShouldSample) ASSERT_EQ("", sampling_result.trace_state->ToHeader()); ASSERT_EQ("", sampling_result2.trace_state->ToHeader()); - // Case 2: Parent exists and SampledFlag is true + // Case 2: Parent exists and SampledFlag is true and RemoteFlag is false auto sampling_result3 = - sampler_off.ShouldSample(parent_context_sampled, trace_id, "", span_kind, view, links); + sampler_off.ShouldSample(parent_context_sampled_local, trace_id, "", span_kind, view, links); ASSERT_EQ(Decision::RECORD_AND_SAMPLE, sampling_result3.decision); ASSERT_EQ("congo=t61rcWkgMzE", sampling_result3.trace_state->ToHeader()); - // Case 3: Parent exists and SampledFlag is false - auto sampling_result4 = - sampler_on.ShouldSample(parent_context_nonsampled, trace_id, "", span_kind, view, links); + // Case 3: Parent exists and SampledFlag is false and RemoteFlag is false + auto sampling_result4 = sampler_on.ShouldSample(parent_context_nonsampled_local, trace_id, "", + span_kind, view, links); ASSERT_EQ(Decision::DROP, sampling_result4.decision); ASSERT_EQ("congo=t61rcWkgMzE", sampling_result4.trace_state->ToHeader()); + + // Case 4: Parent exists, SampledFlag is true and RemoteFlag is true + auto sampling_result5 = + sampler_off.ShouldSample(parent_context_sampled_remote, trace_id, "", span_kind, view, links); + ASSERT_EQ(Decision::RECORD_AND_SAMPLE, sampling_result5.decision); + ASSERT_EQ("congo=t61rcWkgMzE", sampling_result5.trace_state->ToHeader()); + + // Case 5: Parent exists, SampledFlag is false and RemoteFlag is true + auto sampling_result6 = sampler_on.ShouldSample(parent_context_nonsampled_remote, trace_id, "", + span_kind, view, links); + ASSERT_EQ(Decision::DROP, sampling_result6.decision); + ASSERT_EQ("congo=t61rcWkgMzE", sampling_result6.trace_state->ToHeader()); } TEST(ParentBasedSampler, GetDescription) diff --git a/deps/opentelemetry-cpp/sdk/test/trace/trace_id_ratio_sampler_test.cc b/deps/opentelemetry-cpp/sdk/test/trace/trace_id_ratio_sampler_test.cc index 86aaeb40677..fd509281ebd 100644 --- a/deps/opentelemetry-cpp/sdk/test/trace/trace_id_ratio_sampler_test.cc +++ b/deps/opentelemetry-cpp/sdk/test/trace/trace_id_ratio_sampler_test.cc @@ -99,7 +99,7 @@ TEST(TraceIdRatioBasedSampler, ShouldSampleWithoutContext) ASSERT_EQ(Decision::RECORD_AND_SAMPLE, sampling_result.decision); ASSERT_EQ(nullptr, sampling_result.attributes); - constexpr uint8_t buf[] = {0, 0, 0, 0, 0, 0, 0, 0x80, 0, 0, 0, 0, 0, 0, 0, 0}; + constexpr uint8_t buf[] = {0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; trace_api::TraceId valid_trace_id(buf); sampling_result = s1.ShouldSample(trace_api::SpanContext::GetInvalid(), valid_trace_id, "", diff --git a/deps/protobuf/protobuf.gyp b/deps/protobuf/protobuf.gyp index 510fc1f8115..0d8ebc4c61d 100644 --- a/deps/protobuf/protobuf.gyp +++ b/deps/protobuf/protobuf.gyp @@ -60,11 +60,19 @@ 'src/google/protobuf/generated_message_util.cc', 'src/google/protobuf/implicit_weak_message.cc', 'src/google/protobuf/inlined_string_field.cc', + 'src/google/protobuf/json/json.cc', + 'src/google/protobuf/json/internal/lexer.cc', + 'src/google/protobuf/json/internal/message_path.cc', + 'src/google/protobuf/json/internal/parser.cc', + 'src/google/protobuf/json/internal/unparser.cc', + 'src/google/protobuf/json/internal/untyped_message.cc', + 'src/google/protobuf/json/internal/writer.cc', + 'src/google/protobuf/json/internal/zero_copy_buffered_stream.cc', 'src/google/protobuf/map.cc', 'src/google/protobuf/map_field.cc', 'src/google/protobuf/message.cc', 'src/google/protobuf/message_lite.cc', - 'src/google/protobuf/micro_string.cc', + 'src/google/protobuf/micro_string.cc', 'src/google/protobuf/parse_context.cc', 'src/google/protobuf/port.cc', 'src/google/protobuf/raw_ptr.cc', diff --git a/deps/v8/apply-patches.sh b/deps/v8/apply-patches.sh new file mode 100755 index 00000000000..737b94378f7 --- /dev/null +++ b/deps/v8/apply-patches.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -Eeuo pipefail + +PATCHES_DIR="$(dirname "$0")/patches" + +shopt -s nullglob +for patch in "$PATCHES_DIR"/*.patch; do + [ -f "$patch" ] || continue + name="$(basename "$patch")" + echo "Processing ${name}..." + # If the reverse applies cleanly, the patch is already applied. + if git apply --reverse --check "$patch" >/dev/null 2>&1; then + echo " ${name}: already applied, skipping." + continue + fi + # Otherwise, apply if it would apply cleanly. + if git apply --check "$patch" >/dev/null 2>&1; then + echo " ${name}: applying..." + git apply --index --3way "$patch" + echo " ${name}: applied." + else + echo " ${name}: ERROR: patch does not apply cleanly:" + # Show why it fails, then exit non-zero to stop the build. + git apply --check "$patch" || true + exit 1 + fi +done diff --git a/deps/v8/patches/000-allocation-tracker-fix.patch b/deps/v8/patches/000-allocation-tracker-fix.patch new file mode 100644 index 00000000000..d50cfa24eb6 --- /dev/null +++ b/deps/v8/patches/000-allocation-tracker-fix.patch @@ -0,0 +1,16 @@ +diff --git a/deps/v8/src/profiler/allocation-tracker.cc b/deps/v8/src/profiler/allocation-tracker.cc +index eac8c082aee..be9a6fa8132 100644 +--- a/deps/v8/src/profiler/allocation-tracker.cc ++++ b/deps/v8/src/profiler/allocation-tracker.cc +@@ -189,7 +189,10 @@ AllocationTracker::~AllocationTracker() { + + + void AllocationTracker::PrepareForSerialization() { +- for (UnresolvedLocation* location : unresolved_locations_) { ++ for (std::vector::size_type i = 0; ++ i < unresolved_locations_.size() /* size may grow in loop! */; ++ ++i) { ++ UnresolvedLocation* location = unresolved_locations_[i]; + location->Resolve(); + delete location; + } diff --git a/deps/v8/patches/001-clang-macros-fix.patch b/deps/v8/patches/001-clang-macros-fix.patch new file mode 100644 index 00000000000..57588826116 --- /dev/null +++ b/deps/v8/patches/001-clang-macros-fix.patch @@ -0,0 +1,23 @@ +diff --git a/deps/v8/src/base/macros.h b/deps/v8/src/base/macros.h +index d404b6120ab..82bec735d64 100644 +--- a/deps/v8/src/base/macros.h ++++ b/deps/v8/src/base/macros.h +@@ -173,7 +173,8 @@ namespace base { + // base::is_trivially_copyable will differ for these cases. + template + struct is_trivially_copyable { +-#if V8_CC_MSVC || (__GNUC__ == 12 && __GNUC_MINOR__ <= 2) ++#if V8_CC_MSVC || (__GNUC__ == 12 && __GNUC_MINOR__ <= 2) || \ ++ (defined(__clang__) && __clang_major__ <= 17) + // Unfortunately, MSVC 2015 is broken in that std::is_trivially_copyable can + // be false even though it should be true according to the standard. + // (status at 2018-02-26, observed on the msvc waterfall bot). +@@ -186,6 +187,8 @@ struct is_trivially_copyable { + // distributions, so the same polyfill is also used. + // See + // https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=aeba3e009b0abfccaf01797556445dbf891cc8dc ++ // ++ // Also observed with an eclectic range of clang++ releases. + static constexpr bool value = + // Copy constructor is trivial or deleted. + (std::is_trivially_copy_constructible::value || diff --git a/deps/v8/patches/002-cpu-profiler-sigprof-fix.patch b/deps/v8/patches/002-cpu-profiler-sigprof-fix.patch new file mode 100644 index 00000000000..e71ae599d57 --- /dev/null +++ b/deps/v8/patches/002-cpu-profiler-sigprof-fix.patch @@ -0,0 +1,17 @@ +diff --git a/deps/v8/src/profiler/cpu-profiler.cc b/deps/v8/src/profiler/cpu-profiler.cc +index c94e8f95457..d22ce2c1400 100644 +--- a/deps/v8/src/profiler/cpu-profiler.cc ++++ b/deps/v8/src/profiler/cpu-profiler.cc +@@ -51,6 +51,12 @@ class CpuSampler : public sampler::Sampler { + #if V8_HEAP_USE_PKU_JIT_WRITE_PROTECT + i::RwxMemoryWriteScope::SetDefaultPermissionsForSignalHandler(); + #endif ++ ++ // (santigimeno): It prevents a crash when handling a `SIGPROF` signal while ++ // shutting down the profiler. ++ if (!processor_->running()) { ++ return; ++ } + TickSample* sample = processor_->StartTickSample(); + if (sample == nullptr) { + ProfilerStats::Instance()->AddReason( diff --git a/deps/v8/patches/003-heap-snapshot-generator-header.patch b/deps/v8/patches/003-heap-snapshot-generator-header.patch new file mode 100644 index 00000000000..d1895312900 --- /dev/null +++ b/deps/v8/patches/003-heap-snapshot-generator-header.patch @@ -0,0 +1,26 @@ +diff --git a/deps/v8/src/profiler/heap-snapshot-generator.h b/deps/v8/src/profiler/heap-snapshot-generator.h +index d7ae312d8c9..b2e20514f80 100644 +--- a/deps/v8/src/profiler/heap-snapshot-generator.h ++++ b/deps/v8/src/profiler/heap-snapshot-generator.h +@@ -724,7 +724,7 @@ class HeapSnapshotJSONSerializer { + HeapSnapshotJSONSerializer(const HeapSnapshotJSONSerializer&) = delete; + HeapSnapshotJSONSerializer& operator=(const HeapSnapshotJSONSerializer&) = + delete; +- void Serialize(v8::OutputStream* stream); ++ void Serialize(v8::OutputStream* stream, bool redact = false); + + private: + V8_INLINE static bool StringsMatch(void* key1, void* key2) { +@@ -739,9 +739,9 @@ class HeapSnapshotJSONSerializer { + V8_INLINE int to_node_index(int entry_index); + void SerializeEdge(HeapGraphEdge* edge, bool first_edge); + void SerializeEdges(); +- void SerializeImpl(); +- void SerializeNode(const HeapEntry* entry); +- void SerializeNodes(); ++ void SerializeImpl(bool redact = false); ++ void SerializeNode(const HeapEntry* entry, bool redact = false); ++ void SerializeNodes(bool redact = false); + void SerializeSnapshot(); + void SerializeTraceTree(); + void SerializeTraceNode(AllocationTraceNode* node); diff --git a/deps/v8/patches/004-heap-snapshot-generator-redact.patch b/deps/v8/patches/004-heap-snapshot-generator-redact.patch new file mode 100644 index 00000000000..0c07c469760 --- /dev/null +++ b/deps/v8/patches/004-heap-snapshot-generator-redact.patch @@ -0,0 +1,78 @@ +diff --git a/deps/v8/src/profiler/heap-snapshot-generator.cc b/deps/v8/src/profiler/heap-snapshot-generator.cc +index 38e75f4243d..714e16075bc 100644 +--- a/deps/v8/src/profiler/heap-snapshot-generator.cc ++++ b/deps/v8/src/profiler/heap-snapshot-generator.cc +@@ -3072,7 +3072,7 @@ bool HeapSnapshotGenerator::FillReferences() { + // type, name, id, self_size, edge_count, trace_node_id, detachedness. + const int HeapSnapshotJSONSerializer::kNodeFieldsCount = 7; + +-void HeapSnapshotJSONSerializer::Serialize(v8::OutputStream* stream) { ++void HeapSnapshotJSONSerializer::Serialize(v8::OutputStream* stream, bool redact) { + v8::base::ElapsedTimer timer; + timer.Start(); + if (AllocationTracker* allocation_tracker = +@@ -3081,7 +3081,7 @@ void HeapSnapshotJSONSerializer::Serialize(v8::OutputStream* stream) { + } + DCHECK_NULL(writer_); + writer_ = new OutputStreamWriter(stream); +- SerializeImpl(); ++ SerializeImpl(redact); + delete writer_; + writer_ = nullptr; + +@@ -3092,7 +3092,7 @@ void HeapSnapshotJSONSerializer::Serialize(v8::OutputStream* stream) { + timer.Stop(); + } + +-void HeapSnapshotJSONSerializer::SerializeImpl() { ++void HeapSnapshotJSONSerializer::SerializeImpl(bool redact) { + DCHECK_EQ(0, snapshot_->root()->index()); + writer_->AddCharacter('{'); + writer_->AddString("\"snapshot\":{"); +@@ -3100,7 +3100,9 @@ void HeapSnapshotJSONSerializer::SerializeImpl() { + if (writer_->aborted()) return; + writer_->AddString("},\n"); + writer_->AddString("\"nodes\":["); +- SerializeNodes(); ++ // This is where strings are copied into the strings_ cache so redaction must ++ // be performed here ++ SerializeNodes(redact); + if (writer_->aborted()) return; + writer_->AddString("],\n"); + writer_->AddString("\"edges\":["); +@@ -3226,7 +3228,8 @@ void HeapSnapshotJSONSerializer::SerializeEdges() { + } + } + +-void HeapSnapshotJSONSerializer::SerializeNode(const HeapEntry* entry) { ++void HeapSnapshotJSONSerializer::SerializeNode(const HeapEntry* entry, ++ bool redact) { + // The buffer needs space for 5 unsigned ints, 1 size_t, 1 uint8_t, 7 commas, + // \n and \0 + static const int kBufferSize = +@@ -3240,7 +3243,11 @@ void HeapSnapshotJSONSerializer::SerializeNode(const HeapEntry* entry) { + } + buffer_pos = utoa(entry->type(), buffer, buffer_pos); + buffer[buffer_pos++] = ','; +- buffer_pos = utoa(GetStringId(entry->name()), buffer, buffer_pos); ++ if (redact && entry->type() == HeapEntry::kString) { ++ buffer_pos = utoa(GetStringId("(redacted)"), buffer, buffer_pos); ++ } else { ++ buffer_pos = utoa(GetStringId(entry->name()), buffer, buffer_pos); ++ } + buffer[buffer_pos++] = ','; + buffer_pos = utoa(entry->id(), buffer, buffer_pos); + buffer[buffer_pos++] = ','; +@@ -3256,10 +3263,10 @@ void HeapSnapshotJSONSerializer::SerializeNode(const HeapEntry* entry) { + writer_->AddString(buffer.begin()); + } + +-void HeapSnapshotJSONSerializer::SerializeNodes() { ++void HeapSnapshotJSONSerializer::SerializeNodes(bool redact) { + const std::deque& entries = snapshot_->entries(); + for (const HeapEntry& entry : entries) { +- SerializeNode(&entry); ++ SerializeNode(&entry, redact); + if (writer_->aborted()) return; + } + } diff --git a/deps/v8/patches/005-output-stream-escape.patch b/deps/v8/patches/005-output-stream-escape.patch new file mode 100644 index 00000000000..07cda914cb1 --- /dev/null +++ b/deps/v8/patches/005-output-stream-escape.patch @@ -0,0 +1,65 @@ +diff --git a/deps/v8/src/profiler/output-stream-writer.h b/deps/v8/src/profiler/output-stream-writer.h +index c6d144d8a76..3934a33c822 100644 +--- a/deps/v8/src/profiler/output-stream-writer.h ++++ b/deps/v8/src/profiler/output-stream-writer.h +@@ -36,6 +36,48 @@ struct MaxDecimalDigitsIn<8> { + static const int kUnsigned = 20; + }; + ++namespace { ++ void EscapeAndAppendString(const char* value, std::string* result) { ++ *result += '"'; ++ while (*value) { ++ unsigned char c = *value++; ++ switch (c) { ++ case '\b': ++ *result += "\\b"; ++ break; ++ case '\f': ++ *result += "\\f"; ++ break; ++ case '\n': ++ *result += "\\n"; ++ break; ++ case '\r': ++ *result += "\\r"; ++ break; ++ case '\t': ++ *result += "\\t"; ++ break; ++ case '\"': ++ *result += "\\\""; ++ break; ++ case '\\': ++ *result += "\\\\"; ++ break; ++ default: ++ if (c < '\x20' || c == '\x7F') { ++ char number_buffer[8]; ++ base::OS::SNPrintF(number_buffer, arraysize(number_buffer), "\\u%04X", ++ static_cast(c)); ++ *result += number_buffer; ++ } else { ++ *result += c; ++ } ++ } ++ } ++ *result += '"'; ++} ++} // namespace ++ + class OutputStreamWriter { + public: + explicit OutputStreamWriter(v8::OutputStream* stream) +@@ -73,6 +115,11 @@ class OutputStreamWriter { + } + } + void AddNumber(unsigned n) { AddNumberImpl(n, "%u"); } ++ void EscapeAndAddString(const char* s) { ++ std::string escaped; ++ EscapeAndAppendString(s, &escaped); ++ AddString(escaped.c_str()); ++ } + void Finalize() { + if (aborted_) return; + DCHECK(chunk_pos_ < chunk_size_); diff --git a/deps/v8/patches/006-profile-generator-json-fix.patch b/deps/v8/patches/006-profile-generator-json-fix.patch new file mode 100644 index 00000000000..75bf739dcda --- /dev/null +++ b/deps/v8/patches/006-profile-generator-json-fix.patch @@ -0,0 +1,58 @@ +diff --git a/deps/v8/src/profiler/profile-generator.cc b/deps/v8/src/profiler/profile-generator.cc +index 8b4319be9fe..6937534dae8 100644 +--- a/deps/v8/src/profiler/profile-generator.cc ++++ b/deps/v8/src/profiler/profile-generator.cc +@@ -803,17 +803,26 @@ void CpuProfileJSONSerializer::SerializePositionTicks( + + void CpuProfileJSONSerializer::SerializeCallFrame( + const v8::CpuProfileNode* node) { +- writer_->AddString("\"functionName\":\""); +- writer_->AddString(node->GetFunctionNameStr()); +- writer_->AddString("\",\"lineNumber\":"); +- writer_->AddNumber(node->GetLineNumber() - 1); +- writer_->AddString(",\"columnNumber\":"); +- writer_->AddNumber(node->GetColumnNumber() - 1); ++ writer_->AddString("\"functionName\":"); ++ writer_->EscapeAndAddString(node->GetFunctionNameStr()); ++ if (node->GetLineNumber()) { ++ writer_->AddString(",\"lineNumber\":"); ++ writer_->AddNumber(node->GetLineNumber() - 1); ++ } ++ ++ if (node->GetColumnNumber()) { ++ writer_->AddString(",\"columnNumber\":"); ++ writer_->AddNumber(node->GetColumnNumber() - 1); ++ } ++ + writer_->AddString(",\"scriptId\":"); + writer_->AddNumber(node->GetScriptId()); +- writer_->AddString(",\"url\":\""); +- writer_->AddString(node->GetScriptResourceNameStr()); +- writer_->AddCharacter('"'); ++ ++ const char* url = node->GetScriptResourceNameStr(); ++ if (url) { ++ writer_->AddString(",\"url\":"); ++ writer_->EscapeAndAddString(url); ++ } + } + + void CpuProfileJSONSerializer::SerializeChildren(const v8::CpuProfileNode* node, +@@ -874,12 +883,13 @@ void CpuProfileJSONSerializer::SerializeNodes() { + + void CpuProfileJSONSerializer::SerializeTimeDeltas() { + int count = profile_->samples_count(); +- uint64_t lastTime = profile_->start_time().since_origin().InMicroseconds(); ++ base::TimeTicks lastTimestamp = profile_->start_time(); + for (int i = 0; i < count; i++) { +- uint64_t ts = profile_->sample(i).timestamp.since_origin().InMicroseconds(); +- writer_->AddNumber(static_cast(ts - lastTime)); ++ int delta = static_cast( ++ (profile_->sample(i).timestamp - lastTimestamp).InMicroseconds()); ++ writer_->AddString(std::to_string(delta).c_str()); + if (i != (count - 1)) writer_->AddString(","); +- lastTime = ts; ++ lastTimestamp = profile_->sample(i).timestamp; + } + } + diff --git a/deps/v8/patches/007-redacted-heap-snapshot-api.patch b/deps/v8/patches/007-redacted-heap-snapshot-api.patch new file mode 100644 index 00000000000..ce9bfe04e5f --- /dev/null +++ b/deps/v8/patches/007-redacted-heap-snapshot-api.patch @@ -0,0 +1,20 @@ +diff --git a/deps/v8/src/api/api.cc b/deps/v8/src/api/api.cc +index 2dd476dda34..cc1b8d41680 100644 +--- a/deps/v8/src/api/api.cc ++++ b/deps/v8/src/api/api.cc +@@ -11268,6 +11268,15 @@ void HeapSnapshot::Serialize(OutputStream* stream, + serializer.Serialize(stream); + } + ++RedactedHeapSnapshot::RedactedHeapSnapshot(const HeapSnapshot* snapshot): ++ snapshot_(snapshot) { ++} ++ ++void RedactedHeapSnapshot::Serialize(OutputStream* stream) const { ++ i::HeapSnapshotJSONSerializer serializer(ToInternal(snapshot_)); ++ serializer.Serialize(stream, true); ++} ++ + // static + STATIC_CONST_MEMBER_DEFINITION const SnapshotObjectId + HeapProfiler::kUnknownObjectId; diff --git a/deps/v8/patches/008-redacted-heap-snapshot-header.patch b/deps/v8/patches/008-redacted-heap-snapshot-header.patch new file mode 100644 index 00000000000..9e4eacea71f --- /dev/null +++ b/deps/v8/patches/008-redacted-heap-snapshot-header.patch @@ -0,0 +1,22 @@ +diff --git a/deps/v8/include/v8-profiler.h b/deps/v8/include/v8-profiler.h +index 3ec0cd4bb31..8cc07269d65 100644 +--- a/deps/v8/include/v8-profiler.h ++++ b/deps/v8/include/v8-profiler.h +@@ -686,6 +686,17 @@ class V8_EXPORT HeapSnapshot { + SerializationFormat format = kJSON) const; + }; + ++/** ++ * Wrapper to provide redacted serialization for HeapSnapshot ++ */ ++class V8_EXPORT RedactedHeapSnapshot { ++ public: ++ RedactedHeapSnapshot() = delete; ++ RedactedHeapSnapshot(const HeapSnapshot* snapshot); ++ void Serialize(OutputStream* stream) const; ++ private: ++ const HeapSnapshot* snapshot_; ++}; + + /** + * An interface for reporting progress and controlling long-running diff --git a/deps/v8/patches/README.md b/deps/v8/patches/README.md new file mode 100644 index 00000000000..422b6b24e16 --- /dev/null +++ b/deps/v8/patches/README.md @@ -0,0 +1,25 @@ +# V8 Patches for N|Solid + +This directory contains individual patches applied to the V8 dependency for N|Solid-specific features and fixes. + +## Patches + +- **000-allocation-tracker-fix.patch**: Fixes iterator invalidation in allocation-tracker.cc +- **001-clang-macros-fix.patch**: Fixes is_trivially_copyable for Clang versions <= 17 in base/macros.h +- **002-cpu-profiler-sigprof-fix.patch**: Prevents crash when handling SIGPROF signal during profiler shutdown in cpu-profiler.cc +- **003-heap-snapshot-generator-header.patch**: Updates header for redaction support in heap-snapshot-generator.h +- **004-heap-snapshot-generator-redact.patch**: Adds redaction support to heap snapshot serialization in heap-snapshot-generator.cc +- **005-output-stream-escape.patch**: Adds string escaping functions to output-stream-writer.h +- **006-profile-generator-json-fix.patch**: Improves JSON serialization in profile-generator.cc +- **007-redacted-heap-snapshot-api.patch**: Implements RedactedHeapSnapshot in api.cc +- **008-redacted-heap-snapshot-header.patch**: Adds RedactedHeapSnapshot class to v8-profiler.h + +## Usage + +The V8 patches are applied using the `apply-patches.sh` script as a developer tool. This script should be run after checking out the repository or when V8 patches need to be updated. +The script can be executed from either location: + +- From the deps/v8 directory: `cd deps/v8 && ./apply-patches.sh` +- From the repository root: `deps/v8/apply-patches.sh` + +The script is idempotent - it can be run multiple times safely, as it will skip patches that are already applied and only apply those that aren't. diff --git a/deps/v8/src/heap/cppgc/marking-state.h b/deps/v8/src/heap/cppgc/marking-state.h index 4ce1ce40741..3153407f4f2 100644 --- a/deps/v8/src/heap/cppgc/marking-state.h +++ b/deps/v8/src/heap/cppgc/marking-state.h @@ -342,7 +342,7 @@ class MutatorMarkingState final : public BasicMarkingState { ~MutatorMarkingState() override = default; inline bool MarkNoPush(HeapObjectHeader& header) { - return MutatorMarkingState::BasicMarkingState::MarkNoPush(header); + return BasicMarkingState::MarkNoPush(header); } inline void ReTraceMarkedWeakContainer(cppgc::Visitor&, HeapObjectHeader&); diff --git a/deps/zlib/BUILD.gn b/deps/zlib/BUILD.gn index 378bd0df75c..9f3938021f7 100644 --- a/deps/zlib/BUILD.gn +++ b/deps/zlib/BUILD.gn @@ -70,7 +70,7 @@ source_set("zlib_common_headers") { use_arm_neon_optimizations = false if ((current_cpu == "arm" || current_cpu == "arm64") && !(is_win && !is_clang)) { - # TODO(richard.townsend@arm.com): Optimizations temporarily disabled for + # TODO(ritownsend@google.com): Optimizations temporarily disabled for # Windows on Arm MSVC builds, see http://crbug.com/v8/10012. if (arm_use_neon) { use_arm_neon_optimizations = true @@ -173,12 +173,15 @@ if (use_arm_neon_optimizations) { } } -config("zlib_inflate_chunk_simd_config") { +config("zlib_data_chunk_simd_config") { if (use_x86_x64_optimizations) { defines = [ "INFLATE_CHUNK_SIMD_SSE2" ] if (current_cpu == "x64") { - defines += [ "INFLATE_CHUNK_READ_64LE" ] + defines += [ + "INFLATE_CHUNK_READ_64LE", + "DEFLATE_CHUNK_WRITE_64LE", + ] } } @@ -186,12 +189,15 @@ config("zlib_inflate_chunk_simd_config") { defines = [ "INFLATE_CHUNK_SIMD_NEON" ] if (current_cpu == "arm64") { - defines += [ "INFLATE_CHUNK_READ_64LE" ] + defines += [ + "INFLATE_CHUNK_READ_64LE", + "DEFLATE_CHUNK_WRITE_64LE", + ] } } } -source_set("zlib_inflate_chunk_simd") { +source_set("zlib_data_chunk_simd") { visibility = [ ":*" ] if (use_x86_x64_optimizations || use_arm_neon_optimizations) { @@ -213,7 +219,7 @@ source_set("zlib_inflate_chunk_simd") { configs += [ "//build/config/compiler:no_chromium_code" ] configs += [ ":zlib_warnings" ] - public_configs = [ ":zlib_inflate_chunk_simd_config" ] + public_configs = [ ":zlib_data_chunk_simd_config" ] public_deps = [ ":zlib_common_headers" ] } @@ -336,7 +342,7 @@ component("zlib") { if (use_x86_x64_optimizations || use_arm_neon_optimizations) { deps += [ ":zlib_adler32_simd", - ":zlib_inflate_chunk_simd", + ":zlib_data_chunk_simd", ":zlib_slide_hash_simd", ] diff --git a/deps/zlib/CMakeLists.txt b/deps/zlib/CMakeLists.txt index 59d77c3a413..f90e719ef4d 100644 --- a/deps/zlib/CMakeLists.txt +++ b/deps/zlib/CMakeLists.txt @@ -3,7 +3,7 @@ set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) project(zlib C) -set(VERSION "1.3.0.1") +set(VERSION "1.3.1") set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") @@ -47,6 +47,7 @@ if (ENABLE_SIMD_OPTIMIZATIONS) add_definitions(-DINFLATE_CHUNK_SIMD_SSE2) add_definitions(-DADLER32_SIMD_SSSE3) add_definitions(-DINFLATE_CHUNK_READ_64LE) + add_definitions(-DDEFLATE_CHUNK_WRITE_64LE) add_definitions(-DCRC32_SIMD_SSE42_PCLMUL) if (ENABLE_SIMD_AVX512) add_definitions(-DCRC32_SIMD_AVX512_PCLMUL) @@ -64,6 +65,7 @@ if (ENABLE_SIMD_OPTIMIZATIONS) add_definitions(-DINFLATE_CHUNK_SIMD_NEON) add_definitions(-DADLER32_SIMD_NEON) add_definitions(-DINFLATE_CHUNK_READ_64LE) + add_definitions(-DDEFLATE_CHUNK_WRITE_64LE) add_definitions(-DCRC32_ARMV8_CRC32) add_definitions(-DDEFLATE_SLIDE_HASH_NEON) # Required by CPU features detection code. @@ -83,10 +85,13 @@ if (ENABLE_SIMD_OPTIMIZATIONS) add_definitions(-DDEFLATE_SLIDE_HASH_RVV) add_definitions(-DADLER32_SIMD_RVV) - # TODO(cavalcantii): add remaining flags as we port optimizations to RVV. # chunk_copy is required for READ64 and unconditional decode of literals. add_definitions(-DINFLATE_CHUNK_GENERIC) add_definitions(-DINFLATE_CHUNK_READ_64LE) + add_definitions(-DDEFLATE_CHUNK_WRITE_64LE) + + # TODO(cavalcantii): only missing optimization is SLIDE_HASH, got port it + # to RISCV. # Tested with clang-17, unaligned loads are required by read64 & chunk_copy. # TODO(cavalcantii): replace internal clang flags for -munaligned-access @@ -267,7 +272,9 @@ if(MINGW) endif(MINGW) add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) set_target_properties(zlib PROPERTIES SOVERSION 1) @@ -386,6 +393,7 @@ if (BUILD_MINIZIP_BIN) add_executable(minizip_bin contrib/minizip/minizip.c contrib/minizip/ioapi.c contrib/minizip/ioapi.h contrib/minizip/unzip.c contrib/minizip/unzip.h contrib/minizip/zip.c contrib/minizip/zip.h + contrib/minizip/ints.h contrib/minizip/skipset.h ) target_link_libraries(minizip_bin zlib) endif() diff --git a/deps/zlib/OWNERS b/deps/zlib/OWNERS index 3a821578a74..333dabdbae6 100644 --- a/deps/zlib/OWNERS +++ b/deps/zlib/OWNERS @@ -1,4 +1,3 @@ -agl@chromium.org cavalcantii@chromium.org -cblume@chromium.org -scroggo@google.com +hans@chromium.org +agl@chromium.org #{LAST_RESORT_SUGGESTION} diff --git a/deps/zlib/README.chromium b/deps/zlib/README.chromium index 92c5bfd1af2..1f7c7460451 100644 --- a/deps/zlib/README.chromium +++ b/deps/zlib/README.chromium @@ -1,9 +1,9 @@ Name: zlib Short Name: zlib URL: http://zlib.net/ -Version: 1.3.0.1 -Revision: ac8f12c97d1afd9bafa9c710f827d40a407d3266 -CPEPrefix: cpe:/a:zlib:zlib:1.3.0.1 +Version: 1.3.1 +Revision: 51b7f2abdade71cd9bb0e7a373ef2610ec6f9daf +CPEPrefix: cpe:/a:zlib:zlib:1.3.1 Security Critical: yes Shipped: yes License: Zlib @@ -21,14 +21,17 @@ also implements the zlib (RFC 1950) and gzip (RFC 1952) wrapper formats. Local Modifications: - Only source code from the zlib distribution used to build the zlib and minizip libraries are present. Many other files have been omitted. Only *.c - and *.h files from the upstream root directory and contrib/minizip were - imported. + and *.h files from the upstream root directory, contrib/minizip and + examples/zpipe.c were imported. + - The files named '*simd*' are original x86/Arm/RISC-V specific optimizations. - The contents of the google directory are original Chromium-specific additions. + - The contents of the 'contrib' of directory are either Chromium-specific + additions or heavily patched zlib files (e.g. inffast_chunk*). - Added chromeconf.h - Plus the changes in 'patches' folder. - Code in contrib/ other than contrib/minizip was added to match zlib's contributor layout. - - In sync with 1.2.13 official release + - In sync with 1.3.1 official release - ZIP reader modified to allow for progress callbacks during extraction. - ZIP reader modified to add detection of AES encrypted content. diff --git a/deps/zlib/contrib/bench/zlib_bench.cc b/deps/zlib/contrib/bench/zlib_bench.cc index 6df296c8721..5d84b8c9cb6 100644 --- a/deps/zlib/contrib/bench/zlib_bench.cc +++ b/deps/zlib/contrib/bench/zlib_bench.cc @@ -18,18 +18,19 @@ * g++|clang++ -O3 -Wall -std=c++11 zlib_bench.cc -lstdc++ -lz */ +#include +#include +#include +#include + #include #include #include #include +#include #include #include -#include -#include -#include -#include - #include "zlib.h" void error_exit(const char* error, int code) { diff --git a/deps/zlib/contrib/minizip/Makefile b/deps/zlib/contrib/minizip/Makefile index aac76e07f6b..b3e050a0416 100644 --- a/deps/zlib/contrib/minizip/Makefile +++ b/deps/zlib/contrib/minizip/Makefile @@ -1,5 +1,5 @@ -CC=cc -CFLAGS := $(CFLAGS) -O -I../.. +CC?=cc +CFLAGS := -O $(CFLAGS) -I../.. UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a @@ -9,13 +9,21 @@ ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a all: miniunz minizip -miniunz: $(UNZ_OBJS) +miniunz.o: miniunz.c unzip.h iowin32.h +minizip.o: minizip.c zip.h iowin32.h ints.h +unzip.o: unzip.c unzip.h crypt.h +zip.o: zip.c zip.h crypt.h skipset.h ints.h +ioapi.o: ioapi.c ioapi.h ints.h +iowin32.o: iowin32.c iowin32.h ioapi.h +mztools.o: mztools.c unzip.h + +miniunz: $(UNZ_OBJS) $(CC) $(CFLAGS) -o $@ $(UNZ_OBJS) -minizip: $(ZIP_OBJS) +minizip: $(ZIP_OBJS) $(CC) $(CFLAGS) -o $@ $(ZIP_OBJS) -test: miniunz minizip +test: miniunz minizip @rm -f test.* @echo hello hello hello > test.txt ./minizip test test.txt diff --git a/deps/zlib/contrib/minizip/README.chromium b/deps/zlib/contrib/minizip/README.chromium index ceaff34f0f3..ee70ec59ad1 100644 --- a/deps/zlib/contrib/minizip/README.chromium +++ b/deps/zlib/contrib/minizip/README.chromium @@ -1,8 +1,8 @@ Name: ZIP file API for reading file entries in a ZIP archive Short Name: minizip URL: https://github.com/madler/zlib/tree/master/contrib/minizip -Version: 1.3.0.1 -Revision: 643e17b7498d12ab8d15565662880579692f769d +Version: 1.3.1.1 +Revision: ef24c4c7502169f016dcd2a26923dbaf3216748c License: Zlib License File: //third_party/zlib/LICENSE Shipped: yes @@ -14,6 +14,13 @@ Minizip provides API on top of zlib that can enumerate and extract ZIP archive files. See minizip.md for chromium build instructions. Local Modifications: +- OS macro tweaks for Android and Fuchsia + 0000-build.patch (the contrib/minizip/ parts) + 0008-minizip-zip-unzip-tools.patch (crrev.com/886990) + +- Fix build on UWP. (crrev.com/750639) + 0004-fix-uwp.patch + - Fixed uncompressing files with wrong uncompressed size set crrev.com/268940 0014-minizip-unzip-with-incorrect-size.patch @@ -27,3 +34,8 @@ Local Modifications: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT section 4.6.9. (see crrev.com/1002476) 0016-minizip-parse-unicode-path-extra-field.patch + +- Added support for zip64 archives that have extra bytes on front (for example, + large CRX files). + 0018-support-prefixed-zip64.patch + diff --git a/deps/zlib/contrib/minizip/ints.h b/deps/zlib/contrib/minizip/ints.h new file mode 100644 index 00000000000..4c84375b213 --- /dev/null +++ b/deps/zlib/contrib/minizip/ints.h @@ -0,0 +1,57 @@ +/* ints.h -- create integer types for 8, 16, 32, and 64 bits + * Copyright (C) 2024 Mark Adler + * For conditions of distribution and use, see the copyright notice in zlib.h + * + * There exist compilers with limits.h, but not stdint.h or inttypes.h. + */ + +#ifndef INTS_H +#define INTS_H +#include +#if defined(UCHAR_MAX) && UCHAR_MAX == 0xff + typedef signed char i8_t; + typedef unsigned char ui8_t; +#else +# error "no 8-bit integer" +#endif +#if defined(USHRT_MAX) && USHRT_MAX == 0xffff + typedef short i16_t; + typedef unsigned short ui16_t; +#elif defined(UINT_MAX) && UINT_MAX == 0xffff + typedef int i16_t; + typedef unsigned ui16_t; +#else +# error "no 16-bit integer" +#endif +#if defined(UINT_MAX) && UINT_MAX == 0xffffffff + typedef int i32_t; + typedef unsigned ui32_t; +# define PI32 "d" +# define PUI32 "u" +#elif defined(ULONG_MAX) && ULONG_MAX == 0xffffffff + typedef long i32_t; + typedef unsigned long ui32_t; +# define PI32 "ld" +# define PUI32 "lu" +#else +# error "no 32-bit integer" +#endif +#if defined(ULONG_MAX) && ULONG_MAX == 0xffffffffffffffff + typedef long i64_t; + typedef unsigned long ui64_t; +# define PI64 "ld" +# define PUI64 "lu" +#elif defined(ULLONG_MAX) && ULLONG_MAX == 0xffffffffffffffff + typedef long long i64_t; + typedef unsigned long long ui64_t; +# define PI64 "lld" +# define PUI64 "llu" +#elif defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 0xffffffffffffffff + typedef long long i64_t; + typedef unsigned long long ui64_t; +# define PI64 "lld" +# define PUI64 "llu" +#else +# error "no 64-bit integer" +#endif +#endif diff --git a/deps/zlib/contrib/minizip/ioapi.h b/deps/zlib/contrib/minizip/ioapi.h index a2d2e6e60d9..f3b193d8030 100644 --- a/deps/zlib/contrib/minizip/ioapi.h +++ b/deps/zlib/contrib/minizip/ioapi.h @@ -18,8 +18,8 @@ */ -#ifndef _ZLIBIOAPI64_H -#define _ZLIBIOAPI64_H +#ifndef ZLIBIOAPI64_H +#define ZLIBIOAPI64_H #if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) @@ -67,39 +67,12 @@ #endif #endif -/* -#ifndef ZPOS64_T - #ifdef _WIN32 - #define ZPOS64_T fpos_t - #else - #include - #define ZPOS64_T uint64_t - #endif -#endif -*/ - #ifdef HAVE_MINIZIP64_CONF_H #include "mz64conf.h" #endif -/* a type chosen by DEFINE */ -#ifdef HAVE_64BIT_INT_CUSTOM -typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; -#else -#ifdef HAS_STDINT_H -#include "stdint.h" -typedef uint64_t ZPOS64_T; -#else - - - -#if defined(_MSC_VER) || defined(__BORLANDC__) -typedef unsigned __int64 ZPOS64_T; -#else -typedef unsigned long long int ZPOS64_T; -#endif -#endif -#endif +#include "ints.h" +typedef ui64_t ZPOS64_T; /* Maximum unsigned 32-bit value used as placeholder for zip64 */ #ifndef MAXU32 diff --git a/deps/zlib/contrib/minizip/iowin32.c b/deps/zlib/contrib/minizip/iowin32.c index 3f6867fd7e4..393c98676f0 100644 --- a/deps/zlib/contrib/minizip/iowin32.c +++ b/deps/zlib/contrib/minizip/iowin32.c @@ -88,7 +88,7 @@ static voidpf win32_build_iowin(HANDLE hFile) { } voidpf ZCALLBACK win32_open64_file_func(voidpf opaque, const void* filename, int mode) { - const char* mode_fopen = NULL; + (void)opaque; DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; HANDLE hFile = NULL; @@ -116,7 +116,7 @@ voidpf ZCALLBACK win32_open64_file_func(voidpf opaque, const void* filename, int voidpf ZCALLBACK win32_open64_file_funcA(voidpf opaque, const void* filename, int mode) { - const char* mode_fopen = NULL; + (void)opaque; DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; HANDLE hFile = NULL; @@ -139,7 +139,7 @@ voidpf ZCALLBACK win32_open64_file_funcA(voidpf opaque, const void* filename, in voidpf ZCALLBACK win32_open64_file_funcW(voidpf opaque, const void* filename, int mode) { - const char* mode_fopen = NULL; + (void)opaque; DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; HANDLE hFile = NULL; @@ -158,7 +158,7 @@ voidpf ZCALLBACK win32_open64_file_funcW(voidpf opaque, const void* filename, in voidpf ZCALLBACK win32_open_file_func(voidpf opaque, const char* filename, int mode) { - const char* mode_fopen = NULL; + (void)opaque; DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; HANDLE hFile = NULL; @@ -186,6 +186,7 @@ voidpf ZCALLBACK win32_open_file_func(voidpf opaque, const char* filename, int m uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void* buf,uLong size) { + (void)opaque; uLong ret=0; HANDLE hFile = NULL; if (stream!=NULL) @@ -207,6 +208,7 @@ uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void* buf,uLo uLong ZCALLBACK win32_write_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) { + (void)opaque; uLong ret=0; HANDLE hFile = NULL; if (stream!=NULL) @@ -246,6 +248,7 @@ static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *n } long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream) { + (void)opaque; long ret=-1; HANDLE hFile = NULL; if (stream!=NULL) @@ -268,6 +271,7 @@ long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream) { } ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream) { + (void)opaque; ZPOS64_T ret= (ZPOS64_T)-1; HANDLE hFile = NULL; if (stream!=NULL) @@ -292,6 +296,7 @@ ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream) { long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) { + (void)opaque; DWORD dwMoveMethod=0xFFFFFFFF; HANDLE hFile = NULL; @@ -329,6 +334,7 @@ long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset, } long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) { + (void)opaque; DWORD dwMoveMethod=0xFFFFFFFF; HANDLE hFile = NULL; long ret=-1; @@ -367,6 +373,7 @@ long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T off } int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream) { + (void)opaque; int ret=-1; if (stream!=NULL) @@ -384,6 +391,7 @@ int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream) { } int ZCALLBACK win32_error_file_func(voidpf opaque, voidpf stream) { + (void)opaque; int ret=-1; if (stream!=NULL) { diff --git a/deps/zlib/contrib/minizip/miniunz.c b/deps/zlib/contrib/minizip/miniunz.c index 5b4312e5647..f4ad16bdd37 100644 --- a/deps/zlib/contrib/minizip/miniunz.c +++ b/deps/zlib/contrib/minizip/miniunz.c @@ -39,6 +39,9 @@ #endif +#ifndef _CRT_SECURE_NO_WARNINGS +# define _CRT_SECURE_NO_WARNINGS +#endif #include #include #include @@ -79,10 +82,11 @@ /* change_file_date : change the date/time of a file filename : the filename of the file where date/time must be modified - dosdate : the new date at the MSDos format (4 bytes) + dosdate : the new date at the MSDOS format (4 bytes) tmu_date : the SAME new date at the tm_unz format */ static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_date) { #ifdef _WIN32 + (void)tmu_date; HANDLE hFile; FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite; @@ -93,8 +97,7 @@ static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_dat LocalFileTimeToFileTime(&ftLocal,&ftm); SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); CloseHandle(hFile); -#else -#if defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__) +#elif defined(__unix__) || defined(__unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__) (void)dosdate; struct utimbuf ut; struct tm newdate; @@ -116,7 +119,6 @@ static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_dat (void)dosdate; (void)tmu_date; #endif -#endif } @@ -125,9 +127,9 @@ static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_dat static int mymkdir(const char* dirname) { int ret=0; -#if defined(_WIN32) +#ifdef _WIN32 ret = _mkdir(dirname); -#elif defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__) +#elif defined(__unix__) || defined(__unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__) ret = mkdir (dirname,0775); #else (void)dirname; @@ -238,7 +240,7 @@ static int do_list(unzFile uf) { printf(" ------ ------ ---- ----- ---- ---- ------ ----\n"); for (i=0;i #include #include @@ -58,6 +61,7 @@ #endif #include "zip.h" +#include "ints.h" #ifdef _WIN32 #define USEWIN32IOAPI @@ -73,6 +77,7 @@ /* f: name of file to get info on, tmzip: return value: access, modification and creation times, dt: dostime */ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) { + (void)tmzip; int ret = 0; { FILETIME ftLocal; @@ -90,8 +95,7 @@ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) { } return ret; } -#else -#if defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__) +#elif defined(__unix__) || defined(__unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__) /* f: name of file to get info on, tmzip: return value: access, modification and creation times, dt: dostime */ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) { @@ -142,7 +146,6 @@ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) { return 0; } #endif -#endif @@ -191,7 +194,7 @@ static int getFileCrc(const char* filenameinzip, void* buf, unsigned long size_b do { err = ZIP_OK; - size_read = fread(buf,1,size_buf,fin); + size_read = (unsigned long)fread(buf,1,size_buf,fin); if (size_read < size_buf) if (feof(fin)==0) { @@ -223,7 +226,7 @@ static int isLargeFile(const char* filename) { FSEEKO_FUNC(pFile, 0, SEEK_END); pos = (ZPOS64_T)FTELLO_FUNC(pFile); - printf("File : %s is %llu bytes\n", filename, pos); + printf("File : %s is %"PUI64" bytes\n", filename, pos); if(pos >= 0xffffffff) largeFile = 1; @@ -243,7 +246,7 @@ int main(int argc, char *argv[]) { char filename_try[MAXFILENAME+16]; int zipok; int err=0; - size_t size_buf=0; + unsigned long size_buf=0; void* buf=NULL; const char* password=NULL; @@ -305,7 +308,7 @@ int main(int argc, char *argv[]) { } else { - int i,len; + int len; int dot_found=0; zipok = 1 ; diff --git a/deps/zlib/contrib/minizip/mztools.c b/deps/zlib/contrib/minizip/mztools.c index c8d23756155..f86c1e71b09 100644 --- a/deps/zlib/contrib/minizip/mztools.c +++ b/deps/zlib/contrib/minizip/mztools.c @@ -5,6 +5,9 @@ */ /* Code */ +#ifndef _CRT_SECURE_NO_WARNINGS +# define _CRT_SECURE_NO_WARNINGS +#endif #include #include #include @@ -140,28 +143,28 @@ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char* /* Central directory entry */ { - char header[46]; + char central[46]; char* comment = ""; int comsize = (int) strlen(comment); - WRITE_32(header, 0x02014b50); - WRITE_16(header + 4, version); - WRITE_16(header + 6, version); - WRITE_16(header + 8, gpflag); - WRITE_16(header + 10, method); - WRITE_16(header + 12, filetime); - WRITE_16(header + 14, filedate); - WRITE_32(header + 16, crc); - WRITE_32(header + 20, cpsize); - WRITE_32(header + 24, uncpsize); - WRITE_16(header + 28, fnsize); - WRITE_16(header + 30, extsize); - WRITE_16(header + 32, comsize); - WRITE_16(header + 34, 0); /* disk # */ - WRITE_16(header + 36, 0); /* int attrb */ - WRITE_32(header + 38, 0); /* ext attrb */ - WRITE_32(header + 42, currentOffset); + WRITE_32(central, 0x02014b50); + WRITE_16(central + 4, version); + WRITE_16(central + 6, version); + WRITE_16(central + 8, gpflag); + WRITE_16(central + 10, method); + WRITE_16(central + 12, filetime); + WRITE_16(central + 14, filedate); + WRITE_32(central + 16, crc); + WRITE_32(central + 20, cpsize); + WRITE_32(central + 24, uncpsize); + WRITE_16(central + 28, fnsize); + WRITE_16(central + 30, extsize); + WRITE_16(central + 32, comsize); + WRITE_16(central + 34, 0); /* disk # */ + WRITE_16(central + 36, 0); /* int attrb */ + WRITE_32(central + 38, 0); /* ext attrb */ + WRITE_32(central + 42, currentOffset); /* Header */ - if (fwrite(header, 1, 46, fpOutCD) == 46) { + if (fwrite(central, 1, 46, fpOutCD) == 46) { offsetCD += 46; /* Filename */ @@ -215,23 +218,23 @@ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char* /* Final central directory */ { int entriesZip = entries; - char header[22]; + char end[22]; char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools"; int comsize = (int) strlen(comment); if (entriesZip > 0xffff) { entriesZip = 0xffff; } - WRITE_32(header, 0x06054b50); - WRITE_16(header + 4, 0); /* disk # */ - WRITE_16(header + 6, 0); /* disk # */ - WRITE_16(header + 8, entriesZip); /* hack */ - WRITE_16(header + 10, entriesZip); /* hack */ - WRITE_32(header + 12, offsetCD); /* size of CD */ - WRITE_32(header + 16, offset); /* offset to CD */ - WRITE_16(header + 20, comsize); /* comment */ + WRITE_32(end, 0x06054b50); + WRITE_16(end + 4, 0); /* disk # */ + WRITE_16(end + 6, 0); /* disk # */ + WRITE_16(end + 8, entriesZip); /* hack */ + WRITE_16(end + 10, entriesZip); /* hack */ + WRITE_32(end + 12, offsetCD); /* size of CD */ + WRITE_32(end + 16, offset); /* offset to CD */ + WRITE_16(end + 20, comsize); /* comment */ /* Header */ - if (fwrite(header, 1, 22, fpOutCD) == 22) { + if (fwrite(end, 1, 22, fpOutCD) == 22) { /* Comment field */ if (comsize > 0) { diff --git a/deps/zlib/contrib/minizip/skipset.h b/deps/zlib/contrib/minizip/skipset.h new file mode 100644 index 00000000000..5e648b9d234 --- /dev/null +++ b/deps/zlib/contrib/minizip/skipset.h @@ -0,0 +1,361 @@ +// skipset.h -- set operations using a skiplist +// Copyright (C) 2024 Mark Adler +// See MiniZip_info.txt for the license. + +// This implements a skiplist set, i.e. just keys, no data, with ~O(log n) time +// insert and search operations. The application defines the type of a key, and +// provides a function to compare two keys. + +// This header is not definitions of functions found in another source file -- +// it creates the set functions, with the application's key type, right where +// the #include is. Before this header is #included, these must be defined: +// +// 1. A macro or typedef for set_key_t, the type of a key. +// 2. A macro or function set_cmp(a, b) to compare two keys. The return values +// are < 0 for a < b, 0 for a == b, and > 0 for a > b. +// 3. A macro or function set_drop(s, k) to release the key k's resources, if +// any, when doing a set_end() or set_clear(). s is a pointer to the set +// that key is in, for use with set_free() if desired. +// +// Example usage: +// +// typedef int set_key_t; +// #define set_cmp(a, b) ((a) < (b) ? -1 : (a) == (b) ? 0 : 1) +// #define set_drop(s, k) +// #include "skipset.h" +// +// int test(void) { // return 0: good, 1: bad, -1: out of memory +// set_t set; +// if (setjmp(set.env)) +// return -1; +// set_start(&set); +// set_insert(&set, 2); +// set_insert(&set, 1); +// set_insert(&set, 7); +// int bad = !set_found(&set, 2); +// bad = bad || set_found(&set, 5); +// set_end(&set); +// return bad; +// } +// +// Interface summary (see more details below): +// - set_t is the type of the set being operated on (a set_t pointer is passed) +// - set_start() initializes a new, empty set (initialize set.env first) +// - set_insert() inserts a new key into the set, or not if it's already there +// - set_found() determines whether or not a key is in the set +// - set_end() ends the use of the set, freeing all memory +// - set_clear() empties the set, equivalent to set_end() and then set_start() +// - set_ok() checks if set appears to be usable, i.e. started and not ended +// +// Auxiliary functions available to the application: +// - set_alloc() allocates memory with optional tracking (#define SET_TRACK) +// - set_free() deallocates memory allocated by set_alloc() +// - set_rand() returns 32 random bits (seeded by set_start()) + +#ifndef SKIPSET_H +#define SKIPSET_H + +#include // realloc(), free(), NULL, size_t +#include // ptrdiff_t +#include // jmp_buf, longjmp() +#include // ENOMEM +#include // time(), clock() +#include // assert.h +#include "ints.h" // i16_t, ui32_t, ui64_t + +// Structures and functions below noted as "--private--" should not be used by +// the application. set_t is partially private and partially public -- see the +// comments there. + +// There is no POSIX random() in MSVC, and rand() is awful. For portability, we +// cannot rely on a library function for random numbers. Instead we use the +// fast and effective algorithm below, invented by Melissa O'Neill. + +// *Really* minimal PCG32 code / (c) 2014 M.E. O'Neill / www.pcg-random.org +// Licensed under Apache License 2.0 (NO WARRANTY, etc. see website) +// --private-- Random number generator state. +typedef struct { + ui64_t state; // 64-bit generator state + ui64_t inc; // 63-bit sequence id +} set_rand_t; +// --private-- Initialize the state *gen using seed and seq. seed seeds the +// advancing 64-bit state. seq is a sequence selection constant. +void set_seed(set_rand_t *gen, ui64_t seed, ui64_t seq) { + gen->inc = (seq << 1) | 1; + gen->state = (seed + gen->inc) * 6364136223846793005ULL + gen->inc; +} +// Return 32 random bits, advancing the state *gen. +ui32_t set_rand(set_rand_t *gen) { + ui64_t state = gen->state; + gen->state = state * 6364136223846793005ULL + gen->inc; + ui32_t mix = (ui32_t)(((state >> 18) ^ state) >> 27); + int rot = state >> 59; + return (mix >> rot) | (mix << ((-rot) & 31)); +} +// End of PCG32 code. + +// --private-- Linked-list node. +typedef struct set_node_s set_node_t; +struct set_node_s { + set_key_t key; // the key (not used for head or path) + i16_t size; // number of allocated pointers in right[] + i16_t fill; // number of pointers in right[] filled in + set_node_t **right; // pointer for each level, each to the right +}; + +// A set. The application sets env, may use gen with set_rand(), and may read +// allocs and memory. The remaining variables are --private-- . +typedef struct set_s { + set_node_t *head; // skiplist head -- no key, just links + set_node_t *path; // right[] is path to key from set_found() + set_node_t *node; // node under construction, in case of longjmp() + i16_t depth; // maximum depth of the skiplist + ui64_t ran; // a precious trove of random bits + set_rand_t gen; // random number generator state + jmp_buf env; // setjmp() environment for allocation errors +#ifdef SET_TRACK + size_t allocs; // number of allocations + size_t memory; // total amount of allocated memory (>= requests) +#endif +} set_t; + +// Memory allocation and deallocation. set_alloc(set, ptr, size) returns a +// pointer to an allocation of size bytes if ptr is NULL, or the previous +// allocation ptr resized to size bytes. set_alloc() will never return NULL. +// set_free(set, ptr) frees an allocation created by set_alloc(). These may be +// used by the application. e.g. if allocation tracking is desired. +#ifdef SET_TRACK +// Track the number of allocations and the total backing memory size. +# if defined(_WIN32) +# include +# define SET_ALLOC_SIZE(ptr) _msize(ptr) +# elif defined(__MACH__) +# include +# define SET_ALLOC_SIZE(ptr) malloc_size(ptr) +# elif defined(__linux__) +# include +# define SET_ALLOC_SIZE(ptr) malloc_usable_size(ptr) +# elif defined(__FreeBSD__) +# include +# define SET_ALLOC_SIZE(ptr) malloc_usable_size(ptr) +# elif defined(__NetBSD__) +# include +# define SET_ALLOC_SIZE(ptr) malloc_usable_size(ptr) +# else // e.g. OpenBSD +# define SET_ALLOC_SIZE(ptr) 0 +# endif +// With tracking. +void *set_alloc(set_t *set, void *ptr, size_t size) { + size_t had = ptr == NULL ? 0 : SET_ALLOC_SIZE(ptr); + void *mem = realloc(ptr, size); + if (mem == NULL) + longjmp(set->env, ENOMEM); + set->allocs += ptr == NULL; + set->memory += SET_ALLOC_SIZE(mem) - had; + return mem; +} +void set_free(set_t *set, void *ptr) { + if (ptr != NULL) { + set->allocs--; + set->memory -= SET_ALLOC_SIZE(ptr); + free(ptr); + } +} +#else +// Without tracking. +void *set_alloc(set_t *set, void *ptr, size_t size) { + void *mem = realloc(ptr, size); + if (mem == NULL) + longjmp(set->env, ENOMEM); + return mem; +} +void set_free(set_t *set, void *ptr) { + (void)set; + free(ptr); +} +#endif + +// --private-- Grow node's array right[] as needed to be able to hold at least +// want links. If fill is true, assure that the first want links are filled in, +// setting them to set->head if not previously filled in. Otherwise it is +// assumed that the first want links are about to be filled in. +void set_grow(set_t *set, set_node_t *node, int want, int fill) { + if (node->size < want) { + int more = node->size ? node->size : 1; + while (more < want) + more <<= 1; + node->right = set_alloc(set, node->right, more * sizeof(set_node_t *)); + node->size = (i16_t)more; + } + int i; + if (fill) + for (i = node->fill; i < want; i++) + node->right[i] = set->head; + node->fill = (i16_t)want; +} + +// --private-- Return a new node. key is left uninitialized. +set_node_t *set_node(set_t *set) { + set_node_t *node = set_alloc(set, NULL, sizeof(set_node_t)); + node->size = 0; + node->fill = 0; + node->right = NULL; + return node; +} + +// --private-- Free the list linked from head, along with the keys. +void set_sweep(set_t *set) { + set_node_t *step = set->head->right[0]; + while (step != set->head) { + set_node_t *next = step->right[0]; // save link to next node + set_drop(set, step->key); + set_free(set, step->right); + set_free(set, step); + step = next; + } +} + +// Initialize a new set. set->env must be initialized using setjmp() before +// set_start() is called. A longjmp(set->env, ENOMEM) will be used to handle a +// memory allocation failure during any of the operations. (See setjmp.h and +// errno.h.) The set can still be used if this happens, assuming that it didn't +// happen during set_start(). Whether set_start() completed or not, set_end() +// can be used to free the set's memory after a longjmp(). +void set_start(set_t *set) { +#ifdef SET_TRACK + set->allocs = 0; + set->memory = 0; +#endif + set->head = set->path = set->node = NULL; // in case set_node() fails + set->path = set_node(set); + set->head = set_node(set); + set_grow(set, set->head, 1, 1); // one link back to head for an empty set + *(unsigned char *)&set->head->key = 137; // set id + set->depth = 0; + set_seed(&set->gen, ((ui64_t)(ptrdiff_t)set << 32) ^ + ((ui64_t)time(NULL) << 12) ^ clock(), 0); + set->ran = 1; +} + +// Return true if *set appears to be in a usable state. If *set has been zeroed +// out, then set_ok(set) will be false and set_end(set) will be safe. +int set_ok(set_t *set) { + return set->head != NULL && + set->head->right != NULL && + *(unsigned char *)&set->head->key == 137; +} + +// Empty the set. This frees the memory used for the previous set contents. +// After set_clear(), *set is ready for use, as if after a set_start(). +void set_clear(set_t *set) { + assert(set_ok(set) && "improper use"); + + // Free all the keys and their nodes. + set_sweep(set); + + // Leave the head and path allocations as is. Clear their contents, with + // head pointing to itself and setting depth to zero, for an empty set. + set->head->right[0] = set->head; + set->head->fill = 1; + set->path->fill = 0; + set->depth = 0; +} + +// Done using the set -- free all allocations. The only operation on *set +// permitted after this is set_start(). Though another set_end() would do no +// harm. This can be done at any time after a set_start(), or after a longjmp() +// on any allocation failure, including during a set_start(). +void set_end(set_t *set) { + if (set->head != NULL) { + // Empty the set and free the head node. + if (set->head->right != NULL) { + set_sweep(set); + set_free(set, set->head->right); + } + set_free(set, set->head); + set->head = NULL; + } + if (set->path != NULL) { + // Free the path work area. + set_free(set, set->path->right); + set_free(set, set->path); + set->path = NULL; + } + if (set->node != NULL) { + // Free the node that was under construction when longjmp() hit. + set_drop(set, set->node->key); + set_free(set, set->node->right); + set_free(set, set->node); + set->node = NULL; + } +} + +// Look for key. Return 1 if found or 0 if not. This also puts the path to get +// there in set->path, for use by set_insert(). +int set_found(set_t *set, set_key_t key) { + assert(set_ok(set) && "improper use"); + + // Start at depth and work down and right as determined by key comparisons. + set_node_t *head = set->head, *here = head; + int i = set->depth; + set_grow(set, set->path, i + 1, 0); + do { + while (here->right[i] != head && + set_cmp(here->right[i]->key, key) < 0) + here = here->right[i]; + set->path->right[i] = here; + } while (i--); + + // See if the key matches. + here = here->right[0]; + return here != head && set_cmp(here->key, key) == 0; +} + +// Insert the key key. Return 0 on success, or 1 if key is already in the set. +int set_insert(set_t *set, set_key_t key) { + assert(set_ok(set) && "improper use"); + + if (set_found(set, key)) + // That key is already in the set. + return 1; + + // Randomly generate a new level-- level 0 with probability 1/2, 1 with + // probability 1/4, 2 with probability 1/8, etc. + int level = 0; + for (;;) { + if (set->ran == 1) + // Ran out. Get another 32 random bits. + set->ran = set_rand(&set->gen) | (1ULL << 32); + int bit = set->ran & 1; + set->ran >>= 1; + if (bit) + break; + assert(level < 32767 && + "Overhead, without any fuss, the stars were going out."); + level++; + } + if (level > set->depth) { + // The maximum depth is now deeper. Update the structures. + set_grow(set, set->path, level + 1, 1); + set_grow(set, set->head, level + 1, 1); + set->depth = (i16_t)level; + } + + // Make a new node for the provided key, and insert it in the lists up to + // and including level. + set->node = set_node(set); + set->node->key = key; + set_grow(set, set->node, level + 1, 0); + int i; + for (i = 0; i <= level; i++) { + set->node->right[i] = set->path->right[i]->right[i]; + set->path->right[i]->right[i] = set->node; + } + set->node = NULL; + return 0; +} + +#else +#error ** another skiplist set already created here +// Would need to implement a prefix in order to support multiple sets. +#endif diff --git a/deps/zlib/contrib/minizip/unzip.c b/deps/zlib/contrib/minizip/unzip.c index 3576a8504dd..95a945c0ac5 100644 --- a/deps/zlib/contrib/minizip/unzip.c +++ b/deps/zlib/contrib/minizip/unzip.c @@ -88,7 +88,7 @@ #ifndef CASESENSITIVITYDEFAULT_NO -# if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) +# if (!defined(__unix__) && !defined(__unix) || defined(__CYGWIN__)) && !defined(CASESENSITIVITYDEFAULT_YES) # define CASESENSITIVITYDEFAULT_NO # endif #endif @@ -113,7 +113,7 @@ const char unz_copyright[] = " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll"; -/* unz_file_info_interntal contain internal info about a file in zipfile*/ +/* unz_file_info64_internal contain internal info about a file in zipfile*/ typedef struct unz_file_info64_internal_s { ZPOS64_T offset_curfile;/* relative offset of local header 8 bytes */ @@ -336,7 +336,6 @@ extern int ZEXPORT unzStringFileNameCompare (const char* fileName1, #define CENTRALDIRINVALID ((ZPOS64_T)(-1)) #endif - /* Locate the Central directory of a zipfile (at the end, just before the global comment) @@ -467,7 +466,7 @@ local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) return CENTRALDIRINVALID; - /* number of the disk with the start of the zip64 end of central directory */ + /* number of the disk with the start of the zip64 end of central directory */ if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) return CENTRALDIRINVALID; if (uL != 0) @@ -483,6 +482,46 @@ local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib if (uL != 1) return CENTRALDIRINVALID; + /* If bytes are pre-pended to the archive, relativeOffset must be advanced + by that many bytes. The central dir must exist between the specified + relativeOffset and uPosFound. */ + if (relativeOffset > uPosFound) + return CENTRALDIRINVALID; + const int BUFSIZE = 1024 * 4; + buf = (unsigned char*)ALLOC(BUFSIZE); + if (buf==NULL) + return CENTRALDIRINVALID; + // Zip64 EOCDR is at least 48 bytes long. + while (uPosFound - relativeOffset >= 48) { + int found = 0; + uLong uReadSize = uPosFound - relativeOffset; + if (uReadSize > BUFSIZE) { + uReadSize = BUFSIZE; + } + if (ZSEEK64(*pzlib_filefunc_def, filestream, relativeOffset, ZLIB_FILEFUNC_SEEK_SET) != 0) { + break; + } + if (ZREAD64(*pzlib_filefunc_def, filestream, buf, uReadSize) != uReadSize) { + break; + } + for (int i = 0; i < uReadSize - 3; ++i) { + // Looking for 0x06064b50, the Zip64 EOCDR signature. + if (buf[i] == 0x50 && buf[i + 1] == 0x4b && + buf[i + 2] == 0x06 && buf[i + 3] == 0x06) + { + relativeOffset += i; + found = 1; + break; + } + } + if (found) { + break; + } + // Re-read the last 3 bytes, in case they're the front of the signature. + relativeOffset += uReadSize - 3; + } + free(buf); + /* Goto end of central directory record */ if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0) return CENTRALDIRINVALID; @@ -514,9 +553,9 @@ local unzFile unzOpenInternal(const void *path, ZPOS64_T central_pos; uLong uL; - uLong number_disk; /* number of the current dist, used for + uLong number_disk; /* number of the current disk, used for spanning ZIP, unsupported, always 0*/ - uLong number_disk_with_CD; /* number the the disk with central dir, used + uLong number_disk_with_CD; /* number the disk with central dir, used for spanning ZIP, unsupported, always 0*/ ZPOS64_T number_entry_CD; /* total number of entries in the central dir @@ -1006,6 +1045,8 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file, { uLong uSizeRead; + file_info.size_filename = fileNameSize; + if (fileNameSize < fileNameBufferSize) { *(szFileName + fileNameSize) = '\0'; @@ -1682,7 +1723,7 @@ extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len) { uInt i; for(i=0;iread_buffer[i] = - zdecode(s->keys,s->pcrc_32_tab, + (char)zdecode(s->keys,s->pcrc_32_tab, pfile_in_zip_read_info->read_buffer[i]); } # endif diff --git a/deps/zlib/contrib/minizip/unzip.h b/deps/zlib/contrib/minizip/unzip.h index 14105840f6d..ceb614e7832 100644 --- a/deps/zlib/contrib/minizip/unzip.h +++ b/deps/zlib/contrib/minizip/unzip.h @@ -306,13 +306,17 @@ extern int ZEXPORT unzGetCurrentFileInfo(unzFile file, Get Info about the current file if pfile_info!=NULL, the *pfile_info structure will contain some info about the current file - if szFileName!=NULL, the filemane string will be copied in szFileName + if szFileName!=NULL, the filename string will be copied in szFileName (fileNameBufferSize is the size of the buffer) if extraField!=NULL, the extra field information will be copied in extraField (extraFieldBufferSize is the size of the buffer). This is the Central-header version of the extra field if szComment!=NULL, the comment string of the file will be copied in szComment (commentBufferSize is the size of the buffer) + The file name and comment will be zero-terminated if there is room in the + provided buffer. Otherwise the buffer will contain as much as will fit. If at + least 65537 bytes of room is provided, then the result will always be + complete and zero-terminated. */ diff --git a/deps/zlib/contrib/minizip/zip.c b/deps/zlib/contrib/minizip/zip.c index e2e9da07c5f..93d2612e29a 100644 --- a/deps/zlib/contrib/minizip/zip.c +++ b/deps/zlib/contrib/minizip/zip.c @@ -25,8 +25,10 @@ #include #include #include -#include #include +#ifndef ZLIB_CONST +# define ZLIB_CONST +#endif #include "zlib.h" #include "zip.h" @@ -123,6 +125,19 @@ typedef struct linkedlist_data_s } linkedlist_data; +// zipAlreadyThere() set functions for a set of zero-terminated strings, and +// a block_t type for reading the central directory datablocks. +typedef char *set_key_t; +#define set_cmp(a, b) strcmp(a, b) +#define set_drop(s, k) set_free(s, k) +#include "skipset.h" +typedef struct { + unsigned char *next; // next byte in datablock data + size_t left; // number of bytes left in data (at least) + linkedlist_datablock_internal *node; // current datablock +} block_t; + + typedef struct { z_stream stream; /* zLib stream structure for inflate */ @@ -174,6 +189,10 @@ typedef struct char *globalcomment; #endif + // Support for zipAlreadyThere(). + set_t set; // set for detecting name collisions + block_t block; // block for reading the central directory + } zip64_internal; @@ -264,6 +283,228 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) return ZIP_OK; } +// zipAlreadyThere() operations. "set" in the zip internal structure keeps the +// set of names that are in the under-construction central directory so far. A +// skipset provides ~O(log n) time insertion and searching. Central directory +// records, stored in a linked list of allocated memory datablocks, is read +// through "block" in the zip internal structure. + +// The block_*() functions support extracting the central directory file names +// from the datablocks. They are designed to support a growing directory by +// automatically continuing once more data has been appended to the linked +// datablocks. + +// Initialize *block to the head of list. This should only be called once the +// list has at least some data in it, i.e. list->first_block is not NULL. +local void block_init(block_t *block, linkedlist_data *list) { + block->node = list->first_block; + block->next = block->node->data; + block->left = block->node->filled_in_this_block; +} + +// Mark *block as bad, with all subsequent reads returning end, even if more +// data is added to the datablocks. This is invoked if the central directory is +// invalid, so there is no longer any point in attempting to interpret it. +local void block_stop(block_t *block) { + block->left = 0; + block->next = NULL; +} + +// Return true if *block has reached the end of the data in the datablocks. +local int block_end(block_t *block) { + linkedlist_datablock_internal *node = block->node; + if (node == NULL) + // This block was previously terminated with extreme prejudice. + return 1; + if (block->next < node->data + node->filled_in_this_block) + // There are more bytes to read in the current datablock. + return 0; + while (node->next_datablock != NULL) { + if (node->filled_in_this_block != 0) + // There are some bytes in a later datablock. + return 0; + node = node->next_datablock; + } + // Reached the end of the list of datablocks. There's nothing. + return 1; +} + +// Return one byte from *block, or -1 if the end is reached. +local int block_get(block_t *block) { + while (block->left == 0) { + if (block->node == NULL) + // We've been marked bad. Return end. + return -1; + // Update left in case more was filled in since we were last here. + block->left = block->node->filled_in_this_block - + (block->next - block->node->data); + if (block->left != 0) + // There was indeed more data appended in the current datablock. + break; + if (block->node->next_datablock == NULL) + // No more data here, and there is no next datablock. At the end. + return -1; + // Try the next datablock for more data. + block->node = block->node->next_datablock; + block->next = block->node->data; + block->left = block->node->filled_in_this_block; + } + // We have a byte to return. + block->left--; + return *block->next++; +} + +// Return a 16-bit unsigned little-endian value from block, or a negative value +// if the end is reached. +local long block_get2(block_t *block) { + long got = block_get(block); + return got | ((unsigned long)block_get(block) << 8); +} + +// Read up to len bytes from block into buf. Return the number of bytes read. +local size_t block_read(block_t *block, unsigned char *buf, size_t len) { + size_t need = len; + while (need) { + if (block->left == 0) { + // Get a byte to update and step through the linked list as needed. + int got = block_get(block); + if (got == -1) + // Reached the end. + break; + *buf++ = (unsigned char)got; + need--; + continue; + } + size_t take = need > block->left ? block->left : need; + memcpy(buf, block->next, take); + block->next += take; + block->left -= take; + buf += take; + need -= take; + } + return len - need; // return the number of bytes copied +} + +// Skip n bytes in block. Return 0 on success or -1 if there are less than n +// bytes to the end. +local int block_skip(block_t *block, size_t n) { + while (n > block->left) { + n -= block->left; + block->next += block->left; + block->left = 0; + if (block_get(block) == -1) + return -1; + n--; + } + block->next += n; + block->left -= n; + return 0; +} + +// Process the next central directory record at *block. Return the allocated, +// zero-terminated file name, or NULL for end of input or invalid data. If +// invalid, *block is marked bad. This uses *set for the allocation of memory. +local char *block_central_name(block_t *block, set_t *set) { + char *name = NULL; + for (;;) { + if (block_end(block)) + // At the end of the central directory (so far). + return NULL; + + // Check for a central directory record signature. + if (block_get2(block) != (CENTRALHEADERMAGIC & 0xffff) || + block_get2(block) != (CENTRALHEADERMAGIC >> 16)) + // Incorrect signature. + break; + + // Go through the remaining fixed-length portion of the record, + // extracting the lengths of the three variable-length fields. + block_skip(block, 24); + unsigned flen = block_get2(block); // file name length + unsigned xlen = block_get2(block); // extra field length + unsigned clen = block_get2(block); // comment field length + if (block_skip(block, 12) == -1) + // Premature end of the record. + break; + + // Extract the name and skip over the extra and comment fields. + name = set_alloc(set, NULL, flen + 1); + if (block_read(block, (unsigned char *)name, flen) < flen || + block_skip(block, xlen + clen) == -1) + // Premature end of the record. + break; + + // Check for embedded nuls in the name. + if (memchr(name, 0, flen) != NULL) { + // This name can never match the zero-terminated name provided to + // zipAlreadyThere(), so we discard it and go back to get another + // name. (Who the heck is putting nuls inside their zip file entry + // names anyway?) + set_free(set, name); + continue; + } + + // All good. Return the zero-terminated file name. + name[flen] = 0; + return name; + } + + // Invalid signature or premature end of the central directory record. + // Abandon trying to process the central directory. + set_free(set, name); + block_stop(block); + return NULL; +} + +// Return 0 if name is not in the central directory so far, 1 if it is, -1 if +// the central directory is invalid, -2 if out of memory, or ZIP_PARAMERROR if +// file is NULL. +extern int ZEXPORT zipAlreadyThere(zipFile file, char const *name) { + zip64_internal *zip = file; + if (zip == NULL) + return ZIP_PARAMERROR; + if (zip->central_dir.first_block == NULL) + // No central directory yet, so no, name isn't there. + return 0; + if (setjmp(zip->set.env)) { + // Memory allocation failure. + set_end(&zip->set); + return -2; + } + if (!set_ok(&zip->set)) { + // This is the first time here with some central directory content. We + // construct this set of names only on demand. Prepare set and block. + set_start(&zip->set); + block_init(&zip->block, &zip->central_dir); + } + + // Update the set of names from the current central directory contents. + // This reads any new central directory records since the last time we were + // here. + for (;;) { + char *there = block_central_name(&zip->block, &zip->set); + if (there == NULL) { + if (zip->block.next == NULL) + // The central directory is invalid. + return -1; + break; + } + + // Add there to the set. + if (set_insert(&zip->set, there)) + // There's already a duplicate in the central directory! We'll just + // let this be and carry on. + set_free(&zip->set, there); + } + + // Return true if name is in the central directory. + size_t len = strlen(name); + char *copy = set_alloc(&zip->set, NULL, len + 1); + strcpy(copy, name); + int found = set_found(&zip->set, copy); + set_free(&zip->set, copy); + return found; +} /****************************************************************************/ @@ -551,7 +792,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib for (i=(int)uReadSize-3; (i--)>0;) { - // Signature "0x07064b50" Zip64 end of central directory locater + // Signature "0x07064b50" Zip64 end of central directory locator if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07)) { uPosFound = uReadPos+(unsigned)i; @@ -575,7 +816,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK) return 0; - /* number of the disk with the start of the zip64 end of central directory */ + /* number of the disk with the start of the zip64 end of central directory */ if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK) return 0; if (uL != 0) @@ -843,6 +1084,7 @@ extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* glo ziinit.number_entry = 0; ziinit.add_position_when_writing_offset = 0; init_linkedlist(&(ziinit.central_dir)); + memset(&ziinit.set, 0, sizeof(set_t)); // make sure set appears dormant @@ -1027,7 +1269,6 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c int err = ZIP_OK; # ifdef NOCRYPT - (crcForCrypting); if (password != NULL) return ZIP_PARAMERROR; # endif @@ -1412,7 +1653,7 @@ extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned i else #endif { - zi->ci.stream.next_in = (Bytef*)(uintptr_t)buf; + zi->ci.stream.next_in = buf; zi->ci.stream.avail_in = len; while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) @@ -1608,7 +1849,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si if((uLong)(datasize + 4) > zi->ci.size_centralExtraFree) { - // we can not write more data to the buffer that we have room for. + // we cannot write more data to the buffer that we have room for. return ZIP_BADZIPFILE; } @@ -1871,6 +2112,8 @@ extern int ZEXPORT zipClose(zipFile file, const char* global_comment) { } free_linkedlist(&(zi->central_dir)); + set_end(&zi->set); // set was zeroed, so this is safe + pos = centraldir_pos_inzip - zi->add_position_when_writing_offset; if(pos >= 0xffffffff || zi->number_entry >= 0xFFFF) { diff --git a/deps/zlib/contrib/minizip/zip.h b/deps/zlib/contrib/minizip/zip.h index 3e230d3405f..1f7f0b263d4 100644 --- a/deps/zlib/contrib/minizip/zip.h +++ b/deps/zlib/contrib/minizip/zip.h @@ -35,7 +35,7 @@ See header of zip.h -*/ + */ #ifndef _zip12_H #define _zip12_H @@ -127,12 +127,12 @@ extern zipFile ZEXPORT zipOpen64(const void *pathname, int append); If the zipfile cannot be opened, the return value is NULL. Else, the return value is a zipFile Handle, usable with other function of this zip package. -*/ + */ /* Note : there is no delete function into a zipfile. If you want delete file into a zipfile, you must open a zipfile, and create another Of course, you can use RAW reading and writing to copy the file you did not want delete -*/ + */ extern zipFile ZEXPORT zipOpen2(const char *pathname, int append, @@ -186,7 +186,7 @@ extern int ZEXPORT zipOpenNewFileInZip64(zipFile file, zip64 is set to 1 if a zip64 extended information block should be added to the local file header. this MUST be '1' if the uncompressed size is >= 0xffffffff. -*/ + */ extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, @@ -311,12 +311,12 @@ extern int ZEXPORT zipWriteInFileInZip(zipFile file, unsigned len); /* Write data in the zipfile -*/ + */ extern int ZEXPORT zipCloseFileInZip(zipFile file); /* Close the current file in the zipfile -*/ + */ extern int ZEXPORT zipCloseFileInZipRaw(zipFile file, uLong uncompressed_size, @@ -326,17 +326,23 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_size, uLong crc32); +extern int ZEXPORT zipAlreadyThere(zipFile file, + char const* name); +/* + See if name is already in file's central directory. + */ + /* Close the current file in the zipfile, for file opened with parameter raw=1 in zipOpenNewFileInZip2 uncompressed_size and crc32 are value for the uncompressed size -*/ + */ extern int ZEXPORT zipClose(zipFile file, const char* global_comment); /* Close the zipfile -*/ + */ extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader); @@ -355,7 +361,7 @@ extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHea Remove ZIP64 Extra information from a Local File Header extra field data zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001); -*/ + */ #ifdef __cplusplus } diff --git a/deps/zlib/contrib/tests/fuzzers/BUILD.gn b/deps/zlib/contrib/tests/fuzzers/BUILD.gn index d7db4b3459b..1538482f2ec 100644 --- a/deps/zlib/contrib/tests/fuzzers/BUILD.gn +++ b/deps/zlib/contrib/tests/fuzzers/BUILD.gn @@ -43,3 +43,9 @@ fuzzer_test("zlib_deflate_fuzzer") { sources = [ "deflate_fuzzer.cc" ] deps = [ "../../../:zlib" ] } + +fuzzer_test("minizip_unzip_fuzzer") { + sources = [ "minizip_unzip_fuzzer.cc" ] + deps = [ "../../../:minizip" ] + include_dirs = [ "//third_party/zlib/contrib/minizip" ] +} diff --git a/deps/zlib/contrib/tests/fuzzers/minizip_unzip_fuzzer.cc b/deps/zlib/contrib/tests/fuzzers/minizip_unzip_fuzzer.cc new file mode 100644 index 00000000000..3b9fa446bfb --- /dev/null +++ b/deps/zlib/contrib/tests/fuzzers/minizip_unzip_fuzzer.cc @@ -0,0 +1,119 @@ +// Copyright 2025 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include +#include +#include +#include + +#include "unzip.h" + +// Fuzzer builds often have NDEBUG set, so roll our own assert macro. +#define ASSERT(cond) \ + do { \ + if (!(cond)) { \ + fprintf(stderr, "%s:%d Assert failed: %s\n", __FILE__, __LINE__, #cond); \ + exit(1); \ + } \ + } while (0) + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + // Mock read-only filesystem with only one file, file_data. In the calls + // below, 'opaque' points to file_data, and 'strm' points to the file's seek + // position, which is heap allocated so that failing to "close" it triggers a + // leak error. + std::vector file_data(data, data + size); + zlib_filefunc64_def file_func = { + .zopen64_file = [](void* opaque, const void* filename, + int mode) -> void* { + ASSERT(mode == (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_EXISTING)); + return new size_t(0); + }, + .zread_file = [](void* opaque, void* strm, void* buf, + uLong size) -> uLong { + std::vector* vec = static_cast*>(opaque); + size_t* pos = static_cast(strm); + if (*pos >= vec->size()) { + return 0; + } + size = std::min(static_cast(size), vec->size() - *pos); + memcpy(buf, vec->data() + *pos, size); + (*pos) += size; + return size; + }, + .zwrite_file = [](void*, void*, const void*, uLong) -> uLong { + ASSERT(0 && "Writing is not supported."); + return 0; + }, + .ztell64_file = [](void*, void* strm) -> ZPOS64_T { + return *static_cast(strm); + }, + .zseek64_file = [](void* opaque, void* strm, ZPOS64_T offset, + int origin) -> long { + std::vector* vec = static_cast*>(opaque); + size_t* pos = static_cast(strm); + switch (origin) { + case ZLIB_FILEFUNC_SEEK_SET: + *pos = offset; + break; + case ZLIB_FILEFUNC_SEEK_CUR: + *pos = *pos + offset; + break; + case ZLIB_FILEFUNC_SEEK_END: + *pos = vec->size() + offset; + break; + default: + ASSERT(0 && "Invalid origin"); + } + return 0; + }, + .zclose_file = [](void*, void* strm) -> int { + delete static_cast(strm); + return 0; + }, + .zerror_file = [](void*, void*) -> int { return 0; }, + .opaque = &file_data}; + + unzFile uzf = unzOpen2_64("foo.zip", &file_func); + if (uzf == NULL) { + return 0; + } + + while (true) { + unz_file_info64 info = {0}; + + // TODO: Pass nullptrs and different buffer sizes to cover more code. + char filename[UINT16_MAX + 1]; // +1 for the null terminator. + char extra[UINT16_MAX]; // No null terminator. + char comment[UINT16_MAX + 1]; // +1 for the null terminator. + + if (unzGetCurrentFileInfo64(uzf, &info, filename, sizeof(filename), extra, + sizeof(extra), comment, sizeof(comment)) == UNZ_OK) { + ASSERT(info.size_filename <= UINT16_MAX); + ASSERT(info.size_file_extra <= UINT16_MAX); + ASSERT(info.size_file_comment <= UINT16_MAX); + + ASSERT(filename[info.size_filename] == '\0'); + ASSERT(comment[info.size_file_comment] == '\0'); + } + + if (unzOpenCurrentFile(uzf) == UNZ_OK) { + while (true) { + char buffer[4096]; + int num_read = unzReadCurrentFile(uzf, buffer, sizeof(buffer)); + if (num_read <= 0) { + break; + } + } + unzCloseCurrentFile(uzf); + } + + if (unzGoToNextFile(uzf) != UNZ_OK) { + break; + } + } + + unzClose(uzf); + return 0; +} diff --git a/deps/zlib/deflate.c b/deps/zlib/deflate.c index 8a5281c2b6c..872ba790178 100644 --- a/deps/zlib/deflate.c +++ b/deps/zlib/deflate.c @@ -1,5 +1,5 @@ /* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -69,7 +69,7 @@ #endif const char deflate_copyright[] = - " deflate 1.3.0.1 Copyright 1995-2023 Jean-loup Gailly and Mark Adler "; + " deflate 1.3.1 Copyright 1995-2024 Jean-loup Gailly and Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -485,14 +485,7 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, s->window = (Bytef *) ZALLOC(strm, s->w_size + WINDOW_PADDING, 2*sizeof(Byte)); - /* Avoid use of unitialized values in the window, see crbug.com/1137613 and - * crbug.com/1144420 */ - zmemzero(s->window, (s->w_size + WINDOW_PADDING) * (2 * sizeof(Byte))); s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); - /* Avoid use of uninitialized value, see: - * https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11360 - */ - zmemzero(s->prev, s->w_size * sizeof(Pos)); s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); s->high_water = 0; /* nothing written to s->window yet */ @@ -551,6 +544,13 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, deflateEnd (strm); return Z_MEM_ERROR; } + /* Avoid use of unitialized values in the window, see crbug.com/1137613 and + * crbug.com/1144420 */ + zmemzero(s->window, (s->w_size + WINDOW_PADDING) * (2 * sizeof(Byte))); + /* Avoid use of uninitialized value, see: + * https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11360 + */ + zmemzero(s->prev, s->w_size * sizeof(Pos)); #ifdef LIT_MEM s->d_buf = (ushf *)(s->pending_buf + (s->lit_bufsize << 1)); s->l_buf = s->pending_buf + (s->lit_bufsize << 2); @@ -790,7 +790,11 @@ int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) { put = Buf_size - s->bi_valid; if (put > bits) put = bits; +#if defined(DEFLATE_CHUNK_WRITE_64LE) + s->bi_buf |= (uint64_t)((value & ((1ULL << put) - 1)) << s->bi_valid); +#else s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid); +#endif /* DEFLATE_CHUNK_WRITE_64LE */ s->bi_valid += put; _tr_flush_bits(s); value >>= put; @@ -1663,13 +1667,21 @@ local uInt longest_match(deflate_state *s, IPos cur_match) { */ local void check_match(deflate_state *s, IPos start, IPos match, int length) { /* check that the match is indeed a match */ - if (zmemcmp(s->window + match, - s->window + start, length) != EQUAL) { - fprintf(stderr, " start %u, match %u, length %d\n", - start, match, length); + Bytef *back = s->window + (int)match, *here = s->window + start; + IPos len = length; + if (match == (IPos)-1) { + /* match starts one byte before the current window -- just compare the + subsequent length-1 bytes */ + back++; + here++; + len--; + } + if (zmemcmp(back, here, len) != EQUAL) { + fprintf(stderr, " start %u, match %d, length %d\n", + start, (int)match, length); do { - fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); - } while (--length != 0); + fprintf(stderr, "(%02x %02x)", *back++, *here++); + } while (--len != 0); z_error("invalid match"); } if (z_verbose > 1) { @@ -2106,13 +2118,7 @@ local block_state deflate_slow(deflate_state *s, int flush) { uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; /* Do not insert strings in hash table beyond this. */ - if (s->prev_match == -1) { - /* The window has slid one byte past the previous match, - * so the first byte cannot be compared. */ - check_match(s, s->strstart, s->prev_match + 1, s->prev_length - 1); - } else { - check_match(s, s->strstart - 1, s->prev_match, s->prev_length); - } + check_match(s, s->strstart - 1, s->prev_match, s->prev_length); _tr_tally_dist(s, s->strstart - 1 - s->prev_match, s->prev_length - MIN_MATCH, bflush); diff --git a/deps/zlib/deflate.h b/deps/zlib/deflate.h index 099d3594319..b699f6b73b3 100644 --- a/deps/zlib/deflate.h +++ b/deps/zlib/deflate.h @@ -1,5 +1,5 @@ /* deflate.h -- internal compression state - * Copyright (C) 1995-2018 Jean-loup Gailly + * Copyright (C) 1995-2024 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -13,6 +13,10 @@ #ifndef DEFLATE_H #define DEFLATE_H +#if defined(DEFLATE_CHUNK_WRITE_64LE) +#include +#endif + #include "zutil.h" /* define NO_GZIP when compiling if you want to disable gzip header and @@ -52,7 +56,11 @@ #define MAX_BITS 15 /* All codes must not exceed MAX_BITS bits */ +#if defined(DEFLATE_CHUNK_WRITE_64LE) +#define Buf_size 64 +#else #define Buf_size 16 +#endif /* size of bit buffer in bi_buf */ #define INIT_STATE 42 /* zlib header -> BUSY_STATE */ @@ -261,7 +269,11 @@ typedef struct internal_state { ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ #endif +#if defined(DEFLATE_CHUNK_WRITE_64LE) + uint64_t bi_buf; +#else ush bi_buf; +#endif /* Output buffer. bits are inserted starting at the bottom (least * significant bits). */ diff --git a/deps/zlib/google/OWNERS b/deps/zlib/google/OWNERS index 868af3cc662..1bd83ac482e 100644 --- a/deps/zlib/google/OWNERS +++ b/deps/zlib/google/OWNERS @@ -2,5 +2,4 @@ satorux@chromium.org # compression_utils* asvitkine@chromium.org -isherman@chromium.org cavalcantii@chromium.org diff --git a/deps/zlib/google/compression_utils.cc b/deps/zlib/google/compression_utils.cc index 0ba31101489..d50c969504b 100644 --- a/deps/zlib/google/compression_utils.cc +++ b/deps/zlib/google/compression_utils.cc @@ -89,19 +89,18 @@ bool GzipUncompress(const std::string& input, std::string* output) { return false; } -bool GzipUncompress(base::span input, - base::span output) { - return GzipUncompress(base::as_bytes(input), base::as_bytes(output)); +bool GzipUncompress(base::span input, base::span output) { + return GzipUncompress(base::as_bytes(input), base::as_writable_bytes(output)); } bool GzipUncompress(base::span input, - base::span output) { + base::span output) { uLongf uncompressed_size = GetUncompressedSize(input); if (uncompressed_size > output.size()) return false; return zlib_internal::GzipUncompressHelper( - reinterpret_cast(const_cast(output.data())), - &uncompressed_size, reinterpret_cast(input.data()), + reinterpret_cast(output.data()), &uncompressed_size, + reinterpret_cast(input.data()), static_cast(input.size())) == Z_OK; } diff --git a/deps/zlib/google/compression_utils.h b/deps/zlib/google/compression_utils.h index ea399816f60..fd81153076d 100644 --- a/deps/zlib/google/compression_utils.h +++ b/deps/zlib/google/compression_utils.h @@ -43,12 +43,11 @@ bool GzipUncompress(const std::string& input, std::string* output); // needed. |output|'s size must be at least as large as the return value from // GetUncompressedSize. // Returns true for success. -bool GzipUncompress(base::span input, - base::span output); +bool GzipUncompress(base::span input, base::span output); // Like the above method, but using uint8_t instead. bool GzipUncompress(base::span input, - base::span output); + base::span output); // Uncompresses the data in |input| using gzip, and writes the results to // |output|, which must NOT be the underlying string of |input|, and is resized diff --git a/deps/zlib/google/test/data/create_symlink_test_zips.py b/deps/zlib/google/test/data/create_symlink_test_zips.py new file mode 100644 index 00000000000..833887acaf7 --- /dev/null +++ b/deps/zlib/google/test/data/create_symlink_test_zips.py @@ -0,0 +1,48 @@ +# Creates zip files for symlink-related tests. +import zipfile + + +def make_zip(filename): + return zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED) + + +def make_link(zf, target, link): + zip_info = zipfile.ZipInfo(link) + zip_info.external_attr = 0o120777 << 16 # lrwxrwxrwx + zf.writestr(zip_info, target) + + +def make_file(zf, path, content): + zf.writestr(zipfile.ZipInfo(path), content) + + +def make_test_zips(): + with make_zip('symlinks.zip') as zf: + make_file(zf, 'a.txt', 'A') + make_file(zf, 'b.txt', 'B') + make_file(zf, 'dir/c.txt', 'C') + make_link(zf, '../a.txt', 'dir/a_link') + make_link(zf, 'b.txt', 'b_link') + make_link(zf, 'dir/c.txt', 'c_link') + + with make_zip('symlink_evil_relative_path.zip') as zf: + make_file(zf, 'dir/a.txt', 'A') + make_link(zf, 'dir/../dir/../../outside.txt', 'evil_link') + + with make_zip('symlink_absolute_path.zip') as zf: + make_link(zf, '/absolute/path/to/outside.txt', 'absolute_link') + + with make_zip('symlink_too_large.zip') as zf: + make_link(zf, 'a' * 10000, 'big_link') + + with make_zip('symlink_follow_own_link.zip') as zf: + make_link(zf, 'file', 'link') + make_file(zf, 'link', 'Hello world') + + with make_zip('symlink_duplicate_link.zip') as zf: + make_link(zf, 'target_1', 'link') + make_link(zf, 'target_2', 'link') + + +if __name__ == '__main__': + make_test_zips() diff --git a/deps/zlib/google/test/data/symlink_absolute_path.zip b/deps/zlib/google/test/data/symlink_absolute_path.zip new file mode 100644 index 00000000000..0bcf88b67d7 Binary files /dev/null and b/deps/zlib/google/test/data/symlink_absolute_path.zip differ diff --git a/deps/zlib/google/test/data/symlink_duplicate_link.zip b/deps/zlib/google/test/data/symlink_duplicate_link.zip new file mode 100644 index 00000000000..19830110a10 Binary files /dev/null and b/deps/zlib/google/test/data/symlink_duplicate_link.zip differ diff --git a/deps/zlib/google/test/data/symlink_evil_relative_path.zip b/deps/zlib/google/test/data/symlink_evil_relative_path.zip new file mode 100644 index 00000000000..9aded0337de Binary files /dev/null and b/deps/zlib/google/test/data/symlink_evil_relative_path.zip differ diff --git a/deps/zlib/google/test/data/symlink_follow_own_link.zip b/deps/zlib/google/test/data/symlink_follow_own_link.zip new file mode 100644 index 00000000000..933ede55632 Binary files /dev/null and b/deps/zlib/google/test/data/symlink_follow_own_link.zip differ diff --git a/deps/zlib/google/test/data/symlink_too_large.zip b/deps/zlib/google/test/data/symlink_too_large.zip new file mode 100644 index 00000000000..f226aedf21e Binary files /dev/null and b/deps/zlib/google/test/data/symlink_too_large.zip differ diff --git a/deps/zlib/google/test/data/symlinks.zip b/deps/zlib/google/test/data/symlinks.zip new file mode 100644 index 00000000000..24e3fbdcca8 Binary files /dev/null and b/deps/zlib/google/test/data/symlinks.zip differ diff --git a/deps/zlib/google/test_data.filelist b/deps/zlib/google/test_data.filelist index 0a9d20bcea6..5b29f3665e3 100644 --- a/deps/zlib/google/test_data.filelist +++ b/deps/zlib/google/test_data.filelist @@ -15,11 +15,18 @@ test/data/Repeated File Name.zip test/data/SJIS Bug 846195.zip test/data/Windows Special Names.zip test/data/Wrong CRC.zip +test/data/create_symlink_test_zips.py test/data/create_test_zip.sh test/data/empty.zip test/data/evil.zip test/data/evil_via_absolute_file_name.zip test/data/evil_via_invalid_utf8.zip +test/data/symlink_absolute_path.zip +test/data/symlink_duplicate_link.zip +test/data/symlink_evil_relative_path.zip +test/data/symlink_follow_own_link.zip +test/data/symlink_too_large.zip +test/data/symlinks.zip test/data/test.zip test/data/test/foo.txt test/data/test/foo/bar.txt diff --git a/deps/zlib/google/zip.cc b/deps/zlib/google/zip.cc index 87065b91887..48c821e4219 100644 --- a/deps/zlib/google/zip.cc +++ b/deps/zlib/google/zip.cc @@ -4,13 +4,16 @@ #include "third_party/zlib/google/zip.h" +#include #include #include #include "base/files/file.h" #include "base/files/file_enumerator.h" +#include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/functional/bind.h" +#include "base/functional/callback.h" #include "base/logging.h" #include "base/memory/ptr_util.h" #include "base/strings/string_util.h" @@ -23,6 +26,11 @@ namespace zip { namespace { +#if defined(OS_POSIX) +// The maximum allowed size of a symbolic link in bytes. +constexpr uint64_t kMaxSymlinkFileSize = 8192; +#endif + bool IsHiddenFile(const base::FilePath& file_path) { return file_path.BaseName().value()[0] == '.'; } @@ -36,6 +44,34 @@ bool CreateDirectory(const base::FilePath& extract_dir, return ok; } +#if defined(OS_POSIX) +// Creates a symbolic link at |extract_dir|/|target| to |link|. Fails if |link| +// points outside of |extract_dir|. +bool CreateSymbolicLink(const base::FilePath& extract_dir, + const base::FilePath& target, + const base::FilePath& link) { + const base::FilePath full_link_path = extract_dir.Append(link); + if (target.IsAbsolute()) { + LOG(ERROR) << "Won't create link with an absolute target " + << Redact(target); + return false; + } + std::optional absolute_target = + base::MakeAbsoluteFilePathNoResolveSymbolicLinks( + full_link_path.DirName().Append(target)); + if (!absolute_target) { + LOG(ERROR) << "Failed to make an absolute path to " << Redact(target); + return false; + } + if (!extract_dir.IsParent(*absolute_target)) { + LOG(ERROR) << "Won't create link with target outside extract dir " + << Redact(target); + return false; + } + return base::CreateSymbolicLink(target, full_link_path); +} +#endif // defined(OS_POSIX) + // Creates a WriterDelegate that can write a file at |extract_dir|/|entry_path|. std::unique_ptr CreateFilePathWriterDelegate( const base::FilePath& extract_dir, @@ -113,6 +149,95 @@ class DirectFileAccessor : public FileAccessor { const base::FilePath src_dir_; }; +// |symlink_creator| may be null in which case symbolic link entries are +// considered errors. +bool UnzipImpl( + const base::PlatformFile& src_file, + WriterFactory writer_factory, + DirectoryCreator directory_creator, + UnzipOptions options, + base::RepeatingCallback + symlink_creator) { + ZipReader reader; + reader.SetEncoding(std::move(options.encoding)); + reader.SetPassword(std::move(options.password)); + + if (!reader.OpenFromPlatformFile(src_file)) { + LOG(ERROR) << "Cannot open ZIP from file handle " << src_file; + return false; + } + + while (const ZipReader::Entry* const entry = reader.Next()) { + if (entry->is_unsafe) { + LOG(ERROR) << "Found unsafe entry " << Redact(entry->path) << " in ZIP"; + if (!options.continue_on_error) { + return false; + } + continue; + } + + if (options.filter && !options.filter.Run(entry->path)) { + VLOG(1) << "Skipped ZIP entry " << Redact(entry->path); + continue; + } + + if (entry->is_directory) { + // It's a directory. + if (!directory_creator.Run(entry->path)) { + LOG(ERROR) << "Cannot create directory " << Redact(entry->path); + if (!options.continue_on_error) { + return false; + } + } + + continue; + } + +#if defined(OS_POSIX) + if (entry->is_symbolic_link) { + if (!symlink_creator) { + LOG(ERROR) << "Skipping symbolic link " << Redact(entry->path); + if (!options.continue_on_error) { + return false; + } + continue; + } + std::string target; + if (!reader.ExtractCurrentEntryToString(kMaxSymlinkFileSize, &target)) { + LOG(ERROR) << "Failed to read link target " << Redact(entry->path); + if (!options.continue_on_error) { + return false; + } + continue; + } + if (!symlink_creator.Run(base::FilePath(target), entry->path)) { + LOG(ERROR) << "Failed to create symbolic link " << Redact(entry->path); + if (!options.continue_on_error) { + return false; + } + continue; + } + continue; + } +#endif // defined(OS_POSIX) + + // It's a file. + std::unique_ptr writer = writer_factory.Run(entry->path); + if (!writer || + (options.progress ? !reader.ExtractCurrentEntryWithListener( + writer.get(), options.progress) + : !reader.ExtractCurrentEntry(writer.get()))) { + LOG(ERROR) << "Cannot extract file " << Redact(entry->path) + << " from ZIP"; + if (!options.continue_on_error) { + return false; + } + } + } + + return reader.ok(); +} + } // namespace std::ostream& operator<<(std::ostream& out, const Progress& progress) { @@ -132,15 +257,17 @@ bool Zip(const ZipParams& params) { DCHECK(params.dest_file.empty()); zip_writer = internal::ZipWriter::CreateWithFd(params.dest_fd, file_accessor); - if (!zip_writer) + if (!zip_writer) { return false; + } } #endif if (!zip_writer) { zip_writer = internal::ZipWriter::Create(params.dest_file, file_accessor); - if (!zip_writer) + if (!zip_writer) { return false; + } } zip_writer->SetProgressCallback(params.progress_callback, @@ -148,7 +275,7 @@ bool Zip(const ZipParams& params) { zip_writer->SetRecursive(params.recursive); zip_writer->ContinueOnError(params.continue_on_error); - if (!params.include_hidden_files || params.filter_callback) + if (!params.include_hidden_files || params.filter_callback) { zip_writer->SetFilterCallback(base::BindRepeating( [](const ZipParams* const params, const base::FilePath& path) -> bool { return (params->include_hidden_files || !IsHiddenFile(path)) && @@ -156,16 +283,19 @@ bool Zip(const ZipParams& params) { params->filter_callback.Run(params->src_dir.Append(path))); }, ¶ms)); + } if (params.src_files.empty()) { // No source items are specified. Zip the entire source directory. zip_writer->SetRecursive(true); - if (!zip_writer->AddDirectoryContents(base::FilePath())) + if (!zip_writer->AddDirectoryContents(base::FilePath())) { return false; + } } else { // Only zip the specified source items. - if (!zip_writer->AddMixedEntries(params.src_files)) + if (!zip_writer->AddMixedEntries(params.src_files)) { return false; + } } return zip_writer->Close(); @@ -173,7 +303,8 @@ bool Zip(const ZipParams& params) { bool Unzip(const base::FilePath& src_file, const base::FilePath& dest_dir, - UnzipOptions options) { + UnzipOptions options, + UnzipSymlinkOption symlink_option) { base::File file(src_file, base::File::FLAG_OPEN | base::File::FLAG_READ); if (!file.IsValid()) { PLOG(ERROR) << "Cannot open " << Redact(src_file) << ": " @@ -184,63 +315,27 @@ bool Unzip(const base::FilePath& src_file, DLOG_IF(WARNING, !base::IsDirectoryEmpty(dest_dir)) << "ZIP extraction directory is not empty: " << dest_dir; - return Unzip(file.GetPlatformFile(), - base::BindRepeating(&CreateFilePathWriterDelegate, dest_dir), - base::BindRepeating(&CreateDirectory, dest_dir), - std::move(options)); + base::RepeatingCallback + symlink_creator; +#if defined(OS_POSIX) + if (symlink_option == UnzipSymlinkOption::PRESERVE) { + symlink_creator = base::BindRepeating(&CreateSymbolicLink, dest_dir); + } +#endif // defined(OS_POSIX) + + return UnzipImpl(file.GetPlatformFile(), + base::BindRepeating(&CreateFilePathWriterDelegate, dest_dir), + base::BindRepeating(&CreateDirectory, dest_dir), + std::move(options), symlink_creator); } bool Unzip(const base::PlatformFile& src_file, WriterFactory writer_factory, DirectoryCreator directory_creator, UnzipOptions options) { - ZipReader reader; - reader.SetEncoding(std::move(options.encoding)); - reader.SetPassword(std::move(options.password)); - - if (!reader.OpenFromPlatformFile(src_file)) { - LOG(ERROR) << "Cannot open ZIP from file handle " << src_file; - return false; - } - - while (const ZipReader::Entry* const entry = reader.Next()) { - if (entry->is_unsafe) { - LOG(ERROR) << "Found unsafe entry " << Redact(entry->path) << " in ZIP"; - if (!options.continue_on_error) - return false; - continue; - } - - if (options.filter && !options.filter.Run(entry->path)) { - VLOG(1) << "Skipped ZIP entry " << Redact(entry->path); - continue; - } - - if (entry->is_directory) { - // It's a directory. - if (!directory_creator.Run(entry->path)) { - LOG(ERROR) << "Cannot create directory " << Redact(entry->path); - if (!options.continue_on_error) - return false; - } - - continue; - } - - // It's a file. - std::unique_ptr writer = writer_factory.Run(entry->path); - if (!writer || - (options.progress ? !reader.ExtractCurrentEntryWithListener( - writer.get(), options.progress) - : !reader.ExtractCurrentEntry(writer.get()))) { - LOG(ERROR) << "Cannot extract file " << Redact(entry->path) - << " from ZIP"; - if (!options.continue_on_error) - return false; - } - } - - return reader.ok(); + return UnzipImpl(src_file, writer_factory, directory_creator, + std::move(options), + /*symlink_creator=*/{}); } bool ZipWithFilterCallback(const base::FilePath& src_dir, diff --git a/deps/zlib/google/zip.h b/deps/zlib/google/zip.h index ea8778681da..3a574849944 100644 --- a/deps/zlib/google/zip.h +++ b/deps/zlib/google/zip.h @@ -193,6 +193,19 @@ struct UnzipOptions { bool continue_on_error = false; }; +// Option of the Unzip function to control handling of symbolic link entries. +enum class UnzipSymlinkOption { + // Don't preserve internal symbolic links. On POSIX, consider symbolic link + // entries as errors. On other platforms, links are not differentiated from + // regular files. + DONT_PRESERVE, +#if defined(OS_POSIX) + // Preserve internal symbolic links. Links which point outside of the + // extraction directory or specify an absolute target are rejected. + PRESERVE, +#endif +}; + typedef base::RepeatingCallback( const base::FilePath&)> WriterFactory; @@ -206,13 +219,16 @@ bool Unzip(const base::PlatformFile& zip_file, DirectoryCreator directory_creator, UnzipOptions options = {}); -// Unzips the contents of |zip_file| into |dest_dir|. -// This function does not overwrite any existing file. -// A filename collision will result in an error. -// Therefore, |dest_dir| should initially be an empty directory. -bool Unzip(const base::FilePath& zip_file, - const base::FilePath& dest_dir, - UnzipOptions options = {}); +// Unzips the contents of |zip_file| into |dest_dir|. This function does not +// overwrite any existing file. A filename collision will result in an error. +// Therefore, |dest_dir| should initially be an empty directory. If +// |allow_symlinks| is set internal symbolics links will be preserved. Else, +// symbolic link entries are considered errors. +bool Unzip( + const base::FilePath& zip_file, + const base::FilePath& dest_dir, + UnzipOptions options = {}, + UnzipSymlinkOption symlink_option = UnzipSymlinkOption::DONT_PRESERVE); } // namespace zip diff --git a/deps/zlib/google/zip_internal.cc b/deps/zlib/google/zip_internal.cc index e6b5a4fc3bc..f33da592cf8 100644 --- a/deps/zlib/google/zip_internal.cc +++ b/deps/zlib/google/zip_internal.cc @@ -397,14 +397,14 @@ Compression GetCompressionMethod(const base::FilePath& path) { // Skip the leading dot. - base::FilePath::StringPieceType ext_without_dot = ext; + base::FilePath::StringViewType ext_without_dot = ext; DCHECK_EQ(ext_without_dot.front(), FILE_PATH_LITERAL('.')); ext_without_dot.remove_prefix(1); // Well known filename extensions of files that a likely to be already // compressed. The extensions are in lower case without the leading dot. static constexpr auto kExts = - base::MakeFixedFlatSet({ + base::MakeFixedFlatSet({ FILE_PATH_LITERAL("3g2"), // FILE_PATH_LITERAL("3gp"), // FILE_PATH_LITERAL("7z"), // diff --git a/deps/zlib/google/zip_internal.h b/deps/zlib/google/zip_internal.h index f107d7fe883..550cab0bbd7 100644 --- a/deps/zlib/google/zip_internal.h +++ b/deps/zlib/google/zip_internal.h @@ -7,6 +7,8 @@ #include +#include + #include "base/time/time.h" #include "build/build_config.h" @@ -79,8 +81,10 @@ bool ZipOpenNewFileInZip(zipFile zip_file, // PNG...) then the compression method is simply kStored. Compression GetCompressionMethod(const base::FilePath& path); -const int kZipMaxPath = 256; -const int kZipBufSize = 8192; +// ZIP file names are up to 2^16 - 1, buffers should be 1 larger (for \0). +inline constexpr int kZipMaxPath = UINT16_MAX + 1; + +inline constexpr int kZipBufSize = 8192; } // namespace internal } // namespace zip diff --git a/deps/zlib/google/zip_reader.cc b/deps/zlib/google/zip_reader.cc index 182a802ad84..f71fcf51778 100644 --- a/deps/zlib/google/zip_reader.cc +++ b/deps/zlib/google/zip_reader.cc @@ -9,6 +9,7 @@ #include #include "base/check.h" +#include "base/containers/heap_array.h" #include "base/files/file.h" #include "base/files/file_util.h" #include "base/functional/bind.h" @@ -209,16 +210,17 @@ bool ZipReader::OpenEntry() { // Get entry info. unz_file_info64 info = {}; - char path_in_zip[internal::kZipMaxPath] = {}; + auto path_in_zip = base::HeapArray::WithSize(internal::kZipMaxPath); if (const UnzipError err{unzGetCurrentFileInfo64( - zip_file_, &info, path_in_zip, sizeof(path_in_zip) - 1, nullptr, 0, - nullptr, 0)}; + zip_file_, &info, path_in_zip.data(), path_in_zip.size() - 1, + nullptr, 0, nullptr, 0)}; err != UNZ_OK) { LOG(ERROR) << "Cannot get entry from ZIP: " << err; return false; } - entry_.path_in_original_encoding = path_in_zip; + DCHECK(path_in_zip[info.size_filename] == '\0'); + entry_.path_in_original_encoding = path_in_zip.data(); // Convert path from original encoding to Unicode. std::u16string path_in_utf16; @@ -260,8 +262,10 @@ bool ZipReader::OpenEntry() { #if defined(OS_POSIX) entry_.posix_mode = (info.external_fa >> 16L) & (S_IRWXU | S_IRWXG | S_IRWXO); + entry_.is_symbolic_link = S_ISLNK(info.external_fa >> 16L); #else entry_.posix_mode = 0; + entry_.is_symbolic_link = false; #endif return true; diff --git a/deps/zlib/google/zip_reader.h b/deps/zlib/google/zip_reader.h index 0dbf50b87b6..3caacc0bedd 100644 --- a/deps/zlib/google/zip_reader.h +++ b/deps/zlib/google/zip_reader.h @@ -143,6 +143,9 @@ class ZipReader { // Entry POSIX permissions (POSIX systems only). int posix_mode; + + // True if the entry is a symbolic link (POSIX systems only). + bool is_symbolic_link = false; }; ZipReader(); diff --git a/deps/zlib/google/zip_reader_unittest.cc b/deps/zlib/google/zip_reader_unittest.cc index 46c0beb1453..d77838cb5e7 100644 --- a/deps/zlib/google/zip_reader_unittest.cc +++ b/deps/zlib/google/zip_reader_unittest.cc @@ -887,6 +887,31 @@ TEST_F(ZipReaderTest, WrongCrc) { EXPECT_EQ("This file has been changed after its CRC was computed.", contents); } +// The Unicode Path Extra field overrides the regular filename. Make sure the +// size_filename field is also correctly updated (ZipReader has a DCHECK for +// this). +TEST_F(ZipReaderTest, WrongFilenameLength) { + static const char test_data[] = { + 0x50, 0x4b, 0x03, 0x04, 0x0a, 0x03, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x71, + 0x91, 0x4e, 0xbc, 0x2c, 0x7f, 0x06, 0x09, 0x00, 0x00, 0x00, 0x09, 0x00, + 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xc8, 0xfe, 0x20, 0xc8, 0xfe, 0xc8, + 0xfe, 0x2e, 0x74, 0x78, 0x74, 0xed, 0x95, 0x9c, 0xea, 0xb5, 0xad, 0xeb, + 0xa7, 0x90, 0x50, 0x4b, 0x01, 0x02, 0x3f, 0x03, 0x0a, 0x03, 0x00, 0x00, + 0x00, 0x00, 0xd0, 0x71, 0x91, 0x4e, 0xbc, 0x2c, 0x7f, 0x06, 0x09, 0x00, + 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x17, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x20, 0x80, 0xc9, 0x81, 0x00, 0x00, 0x00, 0x00, + 0xc8, 0xfe, 0x20, 0xc8, 0xfe, 0xc8, 0xfe, 0x2e, 0x74, 0x78, 0x74, 0x75, + 0x70, 0x13, 0x00, 0x01, 0xe9, 0x73, 0xbf, 0xc8, 0xec, 0x83, 0x88, 0x20, + 0xeb, 0xac, 0xb8, 0xec, 0x84, 0x9c, 0x2e, 0x74, 0x78, 0x74, 0x50, 0x4b, + 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x50, 0x00, + 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00}; + + std::string test_string(test_data, sizeof(test_data)); + ZipReader reader; + ASSERT_TRUE(reader.OpenFromString(test_string)); + reader.Next(); +} + class FileWriterDelegateTest : public ::testing::Test { protected: void SetUp() override { diff --git a/deps/zlib/google/zip_unittest.cc b/deps/zlib/google/zip_unittest.cc index 2bcfa309281..150844ae3eb 100644 --- a/deps/zlib/google/zip_unittest.cc +++ b/deps/zlib/google/zip_unittest.cc @@ -60,8 +60,9 @@ std::vector GetRelativePaths(const base::FilePath& dir, bool CreateFile(const std::string& content, base::FilePath* file_path, base::File* file) { - if (!base::CreateTemporaryFile(file_path)) + if (!base::CreateTemporaryFile(file_path)) { return false; + } if (!base::WriteFile(*file_path, content)) { return false; @@ -93,8 +94,9 @@ class ProgressWriterDelegate : public zip::WriterDelegate { private: void LogProgressIfNecessary() { const base::TimeTicks now = base::TimeTicks::Now(); - if (next_progress_report_time_ > now) + if (next_progress_report_time_ > now) { return; + } next_progress_report_time_ = now + progress_period_; LogProgress(); @@ -184,8 +186,9 @@ class VirtualFileSystem : public zip::FileAccessor { DCHECK(subdirs); const auto it = file_tree_.find(path); - if (it == file_tree_.end()) + if (it == file_tree_.end()) { return false; + } for (const base::FilePath& file : it->second.files) { DCHECK(!file.empty()); @@ -204,8 +207,9 @@ class VirtualFileSystem : public zip::FileAccessor { DCHECK(!path.IsAbsolute()); DCHECK(info); - if (!file_tree_.count(path)) + if (!file_tree_.count(path)) { return false; + } info->is_directory = !files_.count(path); info->last_modified = @@ -309,8 +313,9 @@ class ZipTest : public PlatformTest { size_t expected_count = 0; for (const base::FilePath& path : zip_contents_) { - if (expect_hidden_files || path.BaseName().value()[0] != '.') + if (expect_hidden_files || path.BaseName().value()[0] != '.') { ++expected_count; + } } EXPECT_EQ(expected_count, count); @@ -788,8 +793,8 @@ TEST_F(ZipTest, UnzipMixedPaths) { "c/NUL", // Disappears on Windows "nul.very long extension", // Disappears on Windows #ifndef OS_APPLE - "CASE", // Conflicts with "Case" - "case", // Conflicts with "Case" + "CASE", // Conflicts with "Case" + "case", // Conflicts with "Case" #endif #endif " NUL.txt", // @@ -956,6 +961,90 @@ TEST_F(ZipTest, UnzipOnlyDirectories) { EXPECT_FALSE(base::PathExists(dir_foo_bar.AppendASCII("quux.txt"))); } +#if defined(OS_POSIX) + +TEST_F(ZipTest, UnzipSymlinks) { + ASSERT_TRUE(zip::Unzip(GetDataDirectory().AppendASCII("symlinks.zip"), + test_dir_, /*options=*/{}, + zip::UnzipSymlinkOption::PRESERVE)); + + EXPECT_TRUE(base::PathExists(test_dir_.AppendASCII("a.txt"))); + EXPECT_TRUE(base::PathExists(test_dir_.AppendASCII("b.txt"))); + EXPECT_TRUE(base::PathExists(test_dir_.AppendASCII("dir/c.txt"))); + base::FilePath target; + ASSERT_TRUE( + base::ReadSymbolicLink(test_dir_.AppendASCII("dir/a_link"), &target)); + EXPECT_EQ(target.AsUTF8Unsafe(), "../a.txt"); + ASSERT_TRUE(base::ReadSymbolicLink(test_dir_.AppendASCII("b_link"), &target)); + EXPECT_EQ(target.AsUTF8Unsafe(), "b.txt"); + ASSERT_TRUE(base::ReadSymbolicLink(test_dir_.AppendASCII("c_link"), &target)); + EXPECT_EQ(target.AsUTF8Unsafe(), "dir/c.txt"); +} + +TEST_F(ZipTest, UnzipRejectsSymlinks) { + EXPECT_FALSE(zip::Unzip(GetDataDirectory().AppendASCII("symlinks.zip"), + test_dir_, /*options=*/{}, + zip::UnzipSymlinkOption::DONT_PRESERVE)); +} + +TEST_F(ZipTest, UnzipSkipsSymlinks) { + ASSERT_TRUE(zip::Unzip(GetDataDirectory().AppendASCII("symlinks.zip"), + test_dir_, + { + .continue_on_error = true, + }, + zip::UnzipSymlinkOption::DONT_PRESERVE)); + + EXPECT_TRUE(base::PathExists(test_dir_.AppendASCII("a.txt"))); + EXPECT_TRUE(base::PathExists(test_dir_.AppendASCII("b.txt"))); + EXPECT_TRUE(base::PathExists(test_dir_.AppendASCII("dir/c.txt"))); + EXPECT_FALSE(base::PathExists(test_dir_.AppendASCII("dir/a_link"))); + EXPECT_FALSE(base::PathExists(test_dir_.AppendASCII("b_link"))); + EXPECT_FALSE(base::PathExists(test_dir_.AppendASCII("c_link"))); +} + +TEST_F(ZipTest, UnzipSymlinksRejectsEvilRelativePath) { + const base::FilePath zip_path = + GetDataDirectory().AppendASCII("symlink_evil_relative_path.zip"); + ASSERT_TRUE(base::PathExists(zip_path)); + EXPECT_FALSE(zip::Unzip(zip_path, test_dir_, /*options=*/{}, + zip::UnzipSymlinkOption::PRESERVE)); +} + +TEST_F(ZipTest, UnzipSymlinksRejectsAbsolutePath) { + const base::FilePath zip_path = + GetDataDirectory().AppendASCII("symlink_absolute_path.zip"); + ASSERT_TRUE(base::PathExists(zip_path)); + EXPECT_FALSE(zip::Unzip(zip_path, test_dir_, /*options=*/{}, + zip::UnzipSymlinkOption::PRESERVE)); +} + +TEST_F(ZipTest, UnzipSymlinksRejectsSymlinkTooLarge) { + const base::FilePath zip_path = + GetDataDirectory().AppendASCII("symlink_too_large.zip"); + ASSERT_TRUE(base::PathExists(zip_path)); + EXPECT_FALSE(zip::Unzip(zip_path, test_dir_, /*options=*/{}, + zip::UnzipSymlinkOption::PRESERVE)); +} + +TEST_F(ZipTest, UnzipSymlinksNoFollowOwnLink) { + const base::FilePath zip_path = + GetDataDirectory().AppendASCII("symlink_follow_own_link.zip"); + ASSERT_TRUE(base::PathExists(zip_path)); + EXPECT_FALSE(zip::Unzip(zip_path, test_dir_, /*options=*/{}, + zip::UnzipSymlinkOption::PRESERVE)); +} + +TEST_F(ZipTest, UnzipSymlinksRejectsDuplicateLink) { + const base::FilePath zip_path = + GetDataDirectory().AppendASCII("symlink_duplicate_link.zip"); + ASSERT_TRUE(base::PathExists(zip_path)); + EXPECT_FALSE(zip::Unzip(zip_path, test_dir_, /*options=*/{}, + zip::UnzipSymlinkOption::PRESERVE)); +} + +#endif // defined(OS_POSIX) + // Tests that a ZIP archive containing SJIS-encoded file names can be correctly // extracted if the encoding is specified. TEST_F(ZipTest, UnzipSjis) { diff --git a/deps/zlib/gzguts.h b/deps/zlib/gzguts.h index f9375047e8c..eba72085bb7 100644 --- a/deps/zlib/gzguts.h +++ b/deps/zlib/gzguts.h @@ -1,5 +1,5 @@ /* gzguts.h -- zlib internal header definitions for gz* operations - * Copyright (C) 2004-2019 Mark Adler + * Copyright (C) 2004-2024 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -210,9 +210,5 @@ char ZLIB_INTERNAL *gz_strwinerror(DWORD error); /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t value -- needed when comparing unsigned to z_off64_t, which is signed (possible z_off64_t types off_t, off64_t, and long are all signed) */ -#ifdef INT_MAX -# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) -#else unsigned ZLIB_INTERNAL gz_intmax(void); -# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) -#endif +#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) diff --git a/deps/zlib/gzlib.c b/deps/zlib/gzlib.c index 0d3ebf8d297..7136395f89a 100644 --- a/deps/zlib/gzlib.c +++ b/deps/zlib/gzlib.c @@ -1,5 +1,5 @@ /* gzlib.c -- zlib functions common to reading and writing gzip files - * Copyright (C) 2004-2019 Mark Adler + * Copyright (C) 2004-2024 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -566,20 +566,20 @@ void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) { #endif } -#ifndef INT_MAX /* portably return maximum value for an int (when limits.h presumed not available) -- we need to do this to cover cases where 2's complement not used, since C standard permits 1's complement and sign-bit representations, otherwise we could just use ((unsigned)-1) >> 1 */ unsigned ZLIB_INTERNAL gz_intmax(void) { - unsigned p, q; - - p = 1; +#ifdef INT_MAX + return INT_MAX; +#else + unsigned p = 1, q; do { q = p; p <<= 1; p++; } while (p > q); return q >> 1; -} #endif +} diff --git a/deps/zlib/inftrees.c b/deps/zlib/inftrees.c index 73d5a776987..98cfe164458 100644 --- a/deps/zlib/inftrees.c +++ b/deps/zlib/inftrees.c @@ -1,5 +1,5 @@ /* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2023 Mark Adler + * Copyright (C) 1995-2024 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -9,7 +9,7 @@ #define MAXBITS 15 const char inflate_copyright[] = - " inflate 1.3.0.1 Copyright 1995-2023 Mark Adler "; + " inflate 1.3.1 Copyright 1995-2024 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -57,7 +57,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; static const unsigned short lext[31] = { /* Length codes 257..285 extra */ 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 70, 200}; + 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 77}; static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, diff --git a/deps/zlib/inftrees.h b/deps/zlib/inftrees.h index f11f29c0761..6e7f0fa2a8a 100644 --- a/deps/zlib/inftrees.h +++ b/deps/zlib/inftrees.h @@ -41,7 +41,7 @@ typedef struct { examples/enough.c found in the zlib distribution. The arguments to that program are the number of symbols, the initial root table size, and the maximum bit length of a code. "enough 286 10 15" for literal/length codes - returns returns 1332, and "enough 30 9 15" for distance codes returns 592. + returns 1332, and "enough 30 9 15" for distance codes returns 592. The initial root table size (10 or 9) is found in the fifth argument of the inflate_table() calls in inflate.c and infback.c. If the root table size is changed, then these maximum sizes would be need to be recalculated and diff --git a/deps/zlib/patches/0006-fix-check_match.patch b/deps/zlib/patches/0006-fix-check_match.patch deleted file mode 100644 index b21c363b1ec..00000000000 --- a/deps/zlib/patches/0006-fix-check_match.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 8304bdda5293ffd5b3efce8e4f54904b387029d6 Mon Sep 17 00:00:00 2001 -From: Hans Wennborg -Date: Wed, 23 Sep 2020 16:36:38 +0200 -Subject: [PATCH] Avoid crashing in check_match when prev_match == -1 - -prev_match can be set to -1 after sliding the window. In that case, the -window has slid past the first byte of the last match, which means it -cannot be compared in check_match. - -This would cause zlib to crash on some inputs to deflate when built -with ZLIB_DEBUG enabled. - -Check for this situation and avoid crashing by not trying to compare -the first byte. - -Bug: 1113142 ---- - third_party/zlib/deflate.c | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -diff --git a/third_party/zlib/deflate.c b/third_party/zlib/deflate.c -index cfdd2f46b230..d70732ec6fc2 100644 ---- a/third_party/zlib/deflate.c -+++ b/third_party/zlib/deflate.c -@@ -2060,7 +2060,13 @@ local block_state deflate_slow(s, flush) - uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; - /* Do not insert strings in hash table beyond this. */ - -- check_match(s, s->strstart-1, s->prev_match, s->prev_length); -+ if (s->prev_match == -1) { -+ /* The window has slid one byte past the previous match, -+ * so the first byte cannot be compared. */ -+ check_match(s, s->strstart, s->prev_match+1, s->prev_length-1); -+ } else { -+ check_match(s, s->strstart-1, s->prev_match, s->prev_length); -+ } - - _tr_tally_dist(s, s->strstart -1 - s->prev_match, - s->prev_length - MIN_MATCH, bflush); --- -2.28.0.681.g6f77f65b4e-goog - diff --git a/deps/zlib/patches/0008-minizip-zip-unzip-tools.patch b/deps/zlib/patches/0008-minizip-zip-unzip-tools.patch index 273a8c98011..a359e0f72b0 100644 --- a/deps/zlib/patches/0008-minizip-zip-unzip-tools.patch +++ b/deps/zlib/patches/0008-minizip-zip-unzip-tools.patch @@ -9,7 +9,7 @@ Subject: [PATCH] Build minizip zip and unzip tools 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/third_party/zlib/contrib/minizip/miniunz.c b/third_party/zlib/contrib/minizip/miniunz.c -index 8ada038dbd4e7..5b4312e5647cd 100644 +index 616c30325e07c..f4ad16bdd377b 100644 --- a/third_party/zlib/contrib/minizip/miniunz.c +++ b/third_party/zlib/contrib/minizip/miniunz.c @@ -12,7 +12,7 @@ @@ -30,31 +30,26 @@ index 8ada038dbd4e7..5b4312e5647cd 100644 // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions #define FOPEN_FUNC(filename, mode) fopen(filename, mode) #define FTELLO_FUNC(stream) ftello(stream) -@@ -94,7 +94,7 @@ static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_dat +@@ -97,7 +97,7 @@ static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_dat + LocalFileTimeToFileTime(&ftLocal,&ftm); SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); CloseHandle(hFile); - #else --#if defined(unix) || defined(__APPLE__) -+#if defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__) +-#elif defined(__unix__) || defined(__unix) || defined(__APPLE__) ++#elif defined(__unix__) || defined(__unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__) (void)dosdate; struct utimbuf ut; struct tm newdate; -@@ -125,11 +125,9 @@ static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_dat - - static int mymkdir(const char* dirname) { +@@ -129,7 +129,7 @@ static int mymkdir(const char* dirname) { int ret=0; --#ifdef _WIN32 -+#if defined(_WIN32) + #ifdef _WIN32 ret = _mkdir(dirname); --#elif unix -- ret = mkdir (dirname,0775); --#elif __APPLE__ -+#elif defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__) +-#elif defined(__unix__) || defined(__unix) || defined(__APPLE__) ++#elif defined(__unix__) || defined(__unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__) ret = mkdir (dirname,0775); #else (void)dirname; diff --git a/third_party/zlib/contrib/minizip/minizip.c b/third_party/zlib/contrib/minizip/minizip.c -index 26ee8d029efe6..9eb3956a55e00 100644 +index a44e36a01869d..53fdd363e6222 100644 --- a/third_party/zlib/contrib/minizip/minizip.c +++ b/third_party/zlib/contrib/minizip/minizip.c @@ -12,8 +12,7 @@ @@ -76,14 +71,12 @@ index 26ee8d029efe6..9eb3956a55e00 100644 // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions #define FOPEN_FUNC(filename, mode) fopen(filename, mode) #define FTELLO_FUNC(stream) ftello(stream) -@@ -92,7 +91,7 @@ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) { +@@ -96,7 +95,7 @@ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) { + } return ret; } - #else --#if defined(unix) || defined(__APPLE__) -+#if defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__) +-#elif defined(__unix__) || defined(__unix) || defined(__APPLE__) ++#elif defined(__unix__) || defined(__unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__) /* f: name of file to get info on, tmzip: return value: access, modification and creation times, dt: dostime */ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) { --- -2.31.1.818.g46aad6cb9e-goog diff --git a/deps/zlib/patches/0015-minizip-unzip-enable-decryption.patch b/deps/zlib/patches/0015-minizip-unzip-enable-decryption.patch index 966e83c7dc5..feeeb1c4007 100644 --- a/deps/zlib/patches/0015-minizip-unzip-enable-decryption.patch +++ b/deps/zlib/patches/0015-minizip-unzip-enable-decryption.patch @@ -18,17 +18,6 @@ diff --git a/third_party/zlib/contrib/minizip/unzip.c b/third_party/zlib/contrib index 82275d6c1775d..c8a01b23efd42 100644 --- a/third_party/zlib/contrib/minizip/unzip.c +++ b/third_party/zlib/contrib/minizip/unzip.c -@@ -68,10 +68,6 @@ - #include - #include - --#ifndef NOUNCRYPT -- #define NOUNCRYPT --#endif -- - #include "zlib.h" - #include "unzip.h" - @@ -1502,6 +1498,7 @@ extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int* method, zdecode(s->keys,s->pcrc_32_tab,source[i]); diff --git a/deps/zlib/patches/0016-minizip-parse-unicode-path-extra-field.patch b/deps/zlib/patches/0016-minizip-parse-unicode-path-extra-field.patch index 9a99a8ae027..73ea055d5bb 100644 --- a/deps/zlib/patches/0016-minizip-parse-unicode-path-extra-field.patch +++ b/deps/zlib/patches/0016-minizip-parse-unicode-path-extra-field.patch @@ -21,6 +21,20 @@ Date: Thu May 12 03:29:52 2022 +0000 Commit-Queue: Alex Danilo Cr-Commit-Position: refs/heads/main@{#1002476} +commit 5a56f75b0da23a10f2c6d9068029a00e53425ddf +Author: Hans Wennborg +Date: Fri May 16 15:48:19 2025 +0200 + + [minizip] Set filename length when using the Unicode Path Extra field + + This is a follow-up to crrev.com/1002476 which added support for parsing + the Unicode Path Extra field, which overrides the regular filename. It + also needs to update the filename length. + + Bug: 40623474 + Change-Id: Ifab65f470736b45b1b51a1cc130a5753a2b20583 + Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6553931 + diff --git a/third_party/zlib/contrib/minizip/unzip.c b/third_party/zlib/contrib/minizip/unzip.c index c8a01b23efd42..42677cff82c96 100644 --- a/third_party/zlib/contrib/minizip/unzip.c @@ -93,6 +107,8 @@ index c8a01b23efd42..42677cff82c96 100644 + { + uLong uSizeRead; + ++ file_info.size_filename = fileNameSize; ++ + if (fileNameSize < fileNameBufferSize) + { + *(szFileName + fileNameSize) = '\0'; diff --git a/deps/zlib/patches/0017-deflate-move-zmemzero-after-null-check.patch b/deps/zlib/patches/0017-deflate-move-zmemzero-after-null-check.patch new file mode 100644 index 00000000000..ac8ade53621 --- /dev/null +++ b/deps/zlib/patches/0017-deflate-move-zmemzero-after-null-check.patch @@ -0,0 +1,49 @@ +From 93f86001b67609106c658fe0908a9b7931245b8a Mon Sep 17 00:00:00 2001 +From: pedro martelletto +Date: Thu, 3 Apr 2025 16:46:42 +0000 +Subject: [PATCH] [zlib] Deflate: move zmemzero after NULL check + +ZALLOC() might fail, in which case dereferencing the returned pointer +results in undefined behaviour. N.B. These conditions are not reachable +from Chromium, as Chromium will abort rather than return nullptr from +malloc. Found by libfido2's fuzz harness. +--- + third_party/zlib/deflate.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/third_party/zlib/deflate.c b/third_party/zlib/deflate.c +index 8a5281c2b6cd8..49496bb3b0561 100644 +--- a/third_party/zlib/deflate.c ++++ b/third_party/zlib/deflate.c +@@ -485,14 +485,7 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, + s->window = (Bytef *) ZALLOC(strm, + s->w_size + WINDOW_PADDING, + 2*sizeof(Byte)); +- /* Avoid use of unitialized values in the window, see crbug.com/1137613 and +- * crbug.com/1144420 */ +- zmemzero(s->window, (s->w_size + WINDOW_PADDING) * (2 * sizeof(Byte))); + s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); +- /* Avoid use of uninitialized value, see: +- * https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11360 +- */ +- zmemzero(s->prev, s->w_size * sizeof(Pos)); + s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); + + s->high_water = 0; /* nothing written to s->window yet */ +@@ -551,6 +544,13 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, + deflateEnd (strm); + return Z_MEM_ERROR; + } ++ /* Avoid use of unitialized values in the window, see crbug.com/1137613 and ++ * crbug.com/1144420 */ ++ zmemzero(s->window, (s->w_size + WINDOW_PADDING) * (2 * sizeof(Byte))); ++ /* Avoid use of uninitialized value, see: ++ * https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11360 ++ */ ++ zmemzero(s->prev, s->w_size * sizeof(Pos)); + #ifdef LIT_MEM + s->d_buf = (ushf *)(s->pending_buf + (s->lit_bufsize << 1)); + s->l_buf = s->pending_buf + (s->lit_bufsize << 2); +-- +2.49.0.504.g3bcea36a83-goog + diff --git a/deps/zlib/patches/0018-support-prefixed-zip64.patch b/deps/zlib/patches/0018-support-prefixed-zip64.patch new file mode 100644 index 00000000000..9e1b4732344 --- /dev/null +++ b/deps/zlib/patches/0018-support-prefixed-zip64.patch @@ -0,0 +1,82 @@ +commit 410a23e8a442e3de4f8df29339946a7d826120d0 +Author: Joshua Pawlicki +Date: Wed May 14 10:58:18 2025 -0700 + + [zip]: Allow zip64 files to have prepended content. + + This was already supported for non-zip64 files. + + Fixed: 414848094 + Change-Id: I3bd79f4b5175d8abca8d8e81f26373037868dcf8 + Cq-Include-Trybots: luci.chromium.try:ios-blink-dbg-fyi + Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6533087 + Commit-Queue: Joshua Pawlicki + Auto-Submit: Joshua Pawlicki + Reviewed-by: Hans Wennborg + Cr-Commit-Position: refs/heads/main@{#1460236} + +commit 3daf10f4a4cd6dbfaaaef6a90091f7c6c3148a24 +Author: Hans Wennborg +Date: Fri May 16 15:35:36 2025 +0200 + + [minizip] Fix possible infinite loop in unz64local_SearchCentralDir64 + + This is a follow-up to crrev.com/1460236, where `uPosFound - 48` could + overflow, resulting in a possible readSize of 3, which meant the loop + did not make progress. + + Bug: 414848094 + Change-Id: Icda653b2c9ac59161fb2aba9ac287fe510ee8653 + Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6554217 + +diff --git a/third_party/zlib/contrib/minizip/unzip.c b/third_party/zlib/contrib/minizip/unzip.c +index a39e1752f6d2e..2c8a73e87e011 100644 +--- a/third_party/zlib/contrib/minizip/unzip.c ++++ b/third_party/zlib/contrib/minizip/unzip.c +@@ -482,6 +482,44 @@ local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib + if (uL != 1) + return CENTRALDIRINVALID; + ++ /* If bytes are pre-pended to the archive, relativeOffset must be advanced ++ by that many bytes. The central dir must exist between the specified ++ relativeOffset and uPosFound. */ ++ const int BUFSIZE = 1024 * 4; ++ buf = (unsigned char*)ALLOC(BUFSIZE); ++ if (buf==NULL) ++ return CENTRALDIRINVALID; ++ if (relativeOffset > uPosFound) ++ return CENTRALDIRINVALID; ++ // Zip64 EOCDR is at least 48 bytes long. ++ while (relativeOffset + 48 <= uPosFound) { ++ int found = 0; ++ uLong uReadSize = uPosFound - relativeOffset; ++ if (uReadSize > BUFSIZE) { ++ uReadSize = BUFSIZE; ++ } ++ if (ZSEEK64(*pzlib_filefunc_def, filestream, relativeOffset, ZLIB_FILEFUNC_SEEK_SET) != 0) { ++ break; ++ } ++ if (ZREAD64(*pzlib_filefunc_def, filestream, buf, uReadSize) != uReadSize) { ++ break; ++ } ++ for (int i = 0; i < uReadSize - 3; ++i) { ++ // Looking for 0x06064b50, the Zip64 EOCDR signature. ++ if (buf[i] == 0x50 && buf[i + 1] == 0x4b && ++ buf[i + 2] == 0x06 && buf[i + 3] == 0x06) ++ { ++ relativeOffset += i; ++ found = 1; ++ break; ++ } ++ } ++ if (found) { ++ break; ++ } ++ // Re-read the last 3 bytes, in case they're the front of the signature. ++ relativeOffset += uReadSize - 3; ++ } ++ free(buf); ++ + /* Goto end of central directory record */ + if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0) + return CENTRALDIRINVALID; diff --git a/deps/zlib/test/minigzip.c b/deps/zlib/test/minigzip.c index c72356dbccf..134e10e6c3e 100644 --- a/deps/zlib/test/minigzip.c +++ b/deps/zlib/test/minigzip.c @@ -303,7 +303,7 @@ static void error(const char *msg) { #ifdef USE_MMAP /* MMAP version, Miguel Albrecht */ /* Try compressing the input file at once using mmap. Return Z_OK if - * if success, Z_ERRNO otherwise. + * success, Z_ERRNO otherwise. */ static int gz_compress_mmap(FILE *in, gzFile out) { int len; diff --git a/deps/zlib/trees.c b/deps/zlib/trees.c index 38135273c9c..7359429702f 100644 --- a/deps/zlib/trees.c +++ b/deps/zlib/trees.c @@ -1,5 +1,5 @@ /* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1995-2021 Jean-loup Gailly + * Copyright (C) 1995-2024 Jean-loup Gailly * detect_data_type() function provided freely by Cosmin Truta, 2006 * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -141,11 +141,18 @@ local TCONST static_tree_desc static_bl_desc = * Output a short LSB first on the stream. * IN assertion: there is enough room in pendingBuf. */ +#if defined(DEFLATE_CHUNK_WRITE_64LE) +#define put_short(s, w) { \ + uint16_t data = (uint16_t)(w); \ + zmemcpy(&s->pending_buf[s->pending], &data, sizeof(data)); \ + s->pending += 2; \ + } +#else #define put_short(s, w) { \ put_byte(s, (uch)((w) & 0xff)); \ put_byte(s, (uch)((ush)(w) >> 8)); \ } - +#endif /* DEFLATE_CHUNK_WRITE_64LE */ /* =========================================================================== * Reverse the first len bits of a code, using straightforward code (a faster * method would use a table) @@ -164,6 +171,13 @@ local unsigned bi_reverse(unsigned code, int len) { * Flush the bit buffer, keeping at most 7 bits in it. */ local void bi_flush(deflate_state *s) { +#if defined(DEFLATE_CHUNK_WRITE_64LE) + while (s->bi_valid >= 16) { + put_short(s, s->bi_buf); + s->bi_buf >>= 16; + s->bi_valid -= 16; + } +#endif /* DEFLATE_CHUNK_WRITE_64LE */ if (s->bi_valid == 16) { put_short(s, s->bi_buf); s->bi_buf = 0; @@ -173,12 +187,21 @@ local void bi_flush(deflate_state *s) { s->bi_buf >>= 8; s->bi_valid -= 8; } + + Assert(s->bi_valid >= 0 && s->bi_valid <= 7, "bad bi_flush"); } /* =========================================================================== * Flush the bit buffer and align the output on a byte boundary */ local void bi_windup(deflate_state *s) { +#if defined(DEFLATE_CHUNK_WRITE_64LE) + while (s->bi_valid >= 16) { + put_short(s, s->bi_buf); + s->bi_buf >>= 16; + s->bi_valid -= 16; + } +#endif /* DEFLATE_CHUNK_WRITE_64LE */ if (s->bi_valid > 8) { put_short(s, s->bi_buf); } else if (s->bi_valid > 0) { @@ -248,7 +271,28 @@ local void gen_trees_header(void); * Send a value on a given number of bits. * IN assertion: length <= 16 and value fits in length bits. */ +#if defined(DEFLATE_CHUNK_WRITE_64LE) +local void send_bits(deflate_state *s, uint64_t value, int length) +{ + Tracevv((stderr," l %2d v %4llx ", length, (unsigned long long)value)); + Assert(s->bi_valid >= 0 && s->bi_valid <= 63, "invalid bi_valid"); + Assert(length > 0 && length <= 15, "invalid length"); #ifdef ZLIB_DEBUG + s->bits_sent += (ulg)length; +#endif + + s->bi_buf |= (value << s->bi_valid); + s->bi_valid += length; + + if (s->bi_valid >= Buf_size) { + zmemcpy(&s->pending_buf[s->pending], &s->bi_buf, sizeof(s->bi_buf)); + s->pending += 8; + s->bi_valid -= Buf_size; + s->bi_buf = value >> (length - s->bi_valid); + } + Assert(s->bi_valid >= 0 && s->bi_valid <= 63, "invalid bi_valid"); +} +#elif defined(ZLIB_DEBUG) local void send_bits(deflate_state *s, int value, int length) { Tracevv((stderr," l %2d v %4x ", length, value)); Assert(length > 0 && length <= 15, "invalid length"); @@ -268,8 +312,7 @@ local void send_bits(deflate_state *s, int value, int length) { s->bi_valid += length; } } -#else /* !ZLIB_DEBUG */ - +#else /* !ZLIB_DEBUG && !DEFLATE_CHUNK_WRITE_64LE */ #define send_bits(s, value, length) \ { int len = length;\ if (s->bi_valid > (int)Buf_size - len) {\ @@ -283,7 +326,7 @@ local void send_bits(deflate_state *s, int value, int length) { s->bi_valid += len;\ }\ } -#endif /* ZLIB_DEBUG */ +#endif /* DEFLATE_CHUNK_WRITE_64LE */ /* the arguments must not have side effects */ diff --git a/deps/zlib/zconf.h b/deps/zlib/zconf.h index 4f2ebbb755e..d72d337f701 100644 --- a/deps/zlib/zconf.h +++ b/deps/zlib/zconf.h @@ -1,5 +1,5 @@ /* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -312,14 +312,6 @@ # endif #endif -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - /* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have diff --git a/deps/zlib/zconf.h.cmakein b/deps/zlib/zconf.h.cmakein index 310c43928a2..0abe3bc9d8f 100644 --- a/deps/zlib/zconf.h.cmakein +++ b/deps/zlib/zconf.h.cmakein @@ -1,5 +1,5 @@ /* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -302,14 +302,6 @@ # endif #endif -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - /* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have diff --git a/deps/zlib/zconf.h.in b/deps/zlib/zconf.h.in index fb76ffe312a..62adc8d8431 100644 --- a/deps/zlib/zconf.h.in +++ b/deps/zlib/zconf.h.in @@ -1,5 +1,5 @@ /* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -300,14 +300,6 @@ # endif #endif -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - /* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have diff --git a/deps/zlib/zlib.3 b/deps/zlib/zlib.3 index adc5b7f03e8..c716020ea9c 100644 --- a/deps/zlib/zlib.3 +++ b/deps/zlib/zlib.3 @@ -1,4 +1,4 @@ -.TH ZLIB 3 "xx Aug 2023" +.TH ZLIB 3 "22 Jan 2024" .SH NAME zlib \- compression/decompression library .SH SYNOPSIS @@ -105,9 +105,9 @@ before asking for help. Send questions and/or comments to zlib@gzip.org, or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). .SH AUTHORS AND LICENSE -Version 1.2.3.0.1 +Version 1.3.1 .LP -Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler +Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler .LP This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/deps/zlib/zlib.gyp b/deps/zlib/zlib.gyp index 25f570fbe7b..9753250e427 100644 --- a/deps/zlib/zlib.gyp +++ b/deps/zlib/zlib.gyp @@ -134,7 +134,7 @@ # ], # }, # zlib_crc32_simd { - 'target_name': 'zlib_inflate_chunk_simd', + 'target_name': 'zlib_data_chunk_simd', 'type': 'static_library', 'conditions': [ ['target_arch in "ia32 x64" and OS!="ios"', { @@ -167,9 +167,9 @@ 'include_dirs': [ '<(ZLIB_ROOT)' ], }, 'sources': [ - ' 2 ? 9 : 2 - (err)] #define ERR_RETURN(strm,err) \ return (strm->msg = ERR_MSG(err), (err)) diff --git a/doc/api/assert.md b/doc/api/assert.md index 847dfcfd74c..32194c2bd8c 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -1092,6 +1092,7 @@ added: v10.0.0 * `asyncFn` {Function|Promise} * `error` {RegExp|Function} * `message` {string} +* Returns: {Promise} Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately calls the function and awaits the returned promise to complete. It will then @@ -2036,6 +2037,7 @@ added: v10.0.0 * `asyncFn` {Function|Promise} * `error` {RegExp|Function|Object|Error} * `message` {string} +* Returns: {Promise} Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately calls the function and awaits the returned promise to complete. It will then diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 7844b840c9c..38042f46559 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -1096,7 +1096,7 @@ added: v19.8.0 --> * `view` {TypedArray} The {TypedArray} to copy. -* `offset` {integer} The starting offset within `view`. **Default:**: `0`. +* `offset` {integer} The starting offset within `view`. **Default:** `0`. * `length` {integer} The number of elements from `view` to copy. **Default:** `view.length - offset`. * Returns: {Buffer} diff --git a/doc/api/cli.md b/doc/api/cli.md index d39b090ba6c..219b24a92b7 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -206,30 +206,18 @@ The valid arguments for the `--allow-fs-read` flag are: * Multiple paths can be allowed using multiple `--allow-fs-read` flags. Example `--allow-fs-read=/folder1/ --allow-fs-read=/folder1/` -Paths delimited by comma (`,`) are no longer allowed. -When passing a single flag with a comma a warning will be displayed. - Examples can be found in the [File System Permissions][] documentation. -Relative paths are NOT yet supported by the CLI flag. - The initializer module also needs to be allowed. Consider the following example: ```console -$ node --experimental-permission t.js -node:internal/modules/cjs/loader:162 - const result = internalModuleStat(filename); - ^ +$ node --experimental-permission index.js Error: Access to this API has been restricted - at stat (node:internal/modules/cjs/loader:162:18) - at Module._findPath (node:internal/modules/cjs/loader:640:16) - at resolveMainPath (node:internal/modules/run_main:15:25) - at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:53:24) at node:internal/main/run_main_module:23:47 { code: 'ERR_ACCESS_DENIED', permission: 'FileSystemRead', - resource: '/Users/rafaelgss/repos/os/node/t.js' + resource: '/Users/rafaelgss/repos/os/node/index.js' } ``` @@ -265,8 +253,6 @@ When passing a single flag with a comma a warning will be displayed. Examples can be found in the [File System Permissions][] documentation. -Relative paths are NOT supported through the CLI flag. - ### `--allow-wasi` + + + + + + + + + + + + + + + + + + + +### DEP0198: Creating SHAKE-128 and SHAKE-256 digests without an explicit `options.outputLength` + + + +Type: Documentation-only (supports [`--pending-deprecation`][]) + +Creating SHAKE-128 and SHAKE-256 digests without an explicit `options.outputLength` is deprecated. + [NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf [RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3 [RFC 8247 Section 2.4]: https://www.rfc-editor.org/rfc/rfc8247#section-2.4 diff --git a/doc/api/esm.md b/doc/api/esm.md index 3100d5756cd..aea83fb712d 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -1159,7 +1159,7 @@ resolution for ESM specifiers is [commonjs-extension-resolution-loader][]. [`path.dirname()`]: path.md#pathdirnamepath [`process.dlopen`]: process.md#processdlopenmodule-filename-flags [`url.fileURLToPath()`]: url.md#urlfileurltopathurl-options -[cjs-module-lexer]: https://github.com/nodejs/cjs-module-lexer/tree/1.2.2 +[cjs-module-lexer]: https://github.com/nodejs/cjs-module-lexer/tree/2.0.0 [commonjs-extension-resolution-loader]: https://github.com/nodejs/loaders-test/tree/main/commonjs-extension-resolution-loader [custom https loader]: module.md#import-from-https [import.meta.resolve]: #importmetaresolvespecifier diff --git a/doc/api/modules.md b/doc/api/modules.md index 3c0c87ff662..8eb8a39cabb 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -204,8 +204,8 @@ regarding which files are parsed as ECMAScript modules. 3. The file has a `.js` extension, the closest `package.json` does not contain `"type": "commonjs"`, and the module contains ES module syntax. -If the ES Module being loaded meet the requirements, `require()` can load it and -return the module namespace object. In this case it is similar to dynamic +If the ES Module being loaded meets the requirements, `require()` can load it and +return the [module namespace object][]. In this case it is similar to dynamic `import()` but is run synchronously and returns the name space object directly. @@ -213,7 +213,7 @@ With the following ES Modules: ```mjs // distance.mjs -export function distance(a, b) { return (b.x - a.x) ** 2 + (b.y - a.y) ** 2; } +export function distance(a, b) { return Math.sqrt((b.x - a.x) ** 2 + (b.y - a.y) ** 2); } ``` ```mjs @@ -249,8 +249,8 @@ This property is experimental and can change in the future. It should only be us by tools converting ES modules into CommonJS modules, following existing ecosystem conventions. Code authored directly in CommonJS should avoid depending on it. -When a ES Module contains both named exports and a default export, the result returned by `require()` -is the module namespace object, which places the default export in the `.default` property, similar to +When an ES Module contains both named exports and a default export, the result returned by `require()` +is the [module namespace object][], which places the default export in the `.default` property, similar to the results returned by `import()`. To customize what should be returned by `require(esm)` directly, the ES Module can export the desired value using the string name `"module.exports"`. @@ -265,7 +265,7 @@ export default class Point { // `distance` is lost to CommonJS consumers of this module, unless it's // added to `Point` as a static property. -export function distance(a, b) { return (b.x - a.x) ** 2 + (b.y - a.y) ** 2; } +export function distance(a, b) { return Math.sqrt((b.x - a.x) ** 2 + (b.y - a.y) ** 2); } export { Point as 'module.exports' } ``` @@ -289,7 +289,7 @@ named exports attached to it as properties. For example with the example above, ```mjs -export function distance(a, b) { return (b.x - a.x) ** 2 + (b.y - a.y) ** 2; } +export function distance(a, b) { return Math.sqrt((b.x - a.x) ** 2 + (b.y - a.y) ** 2); } export default class Point { constructor(x, y) { this.x = x; this.y = y; } @@ -342,7 +342,7 @@ require(X) from module at path Y a. return the core module b. STOP 2. If X begins with '/' - a. set Y to be the file system root + a. set Y to the file system root 3. If X begins with './' or '/' or '../' a. LOAD_AS_FILE(Y + X) b. LOAD_AS_DIRECTORY(Y + X) @@ -369,7 +369,7 @@ LOAD_AS_FILE(X) 1. MAYBE_DETECT_AND_LOAD(X.js) c. If the SCOPE/package.json contains "type" field, 1. If the "type" field is "module", load X.js as an ECMAScript module. STOP. - 2. If the "type" field is "commonjs", load X.js as an CommonJS module. STOP. + 2. If the "type" field is "commonjs", load X.js as a CommonJS module. STOP. d. MAYBE_DETECT_AND_LOAD(X.js) 3. If X.json is a file, load X.json to a JavaScript Object. STOP 4. If X.node is a file, load X.node as binary addon. STOP @@ -380,7 +380,7 @@ LOAD_INDEX(X) b. If no scope was found, load X/index.js as a CommonJS module. STOP. c. If the SCOPE/package.json contains "type" field, 1. If the "type" field is "module", load X/index.js as an ECMAScript module. STOP. - 2. Else, load X/index.js as an CommonJS module. STOP. + 2. Else, load X/index.js as a CommonJS module. STOP. 2. If X/index.json is a file, parse X/index.json to a JavaScript object. STOP 3. If X/index.node is a file, load X/index.node as binary addon. STOP @@ -1291,6 +1291,7 @@ This section was moved to [`process.features.require_module`]: process.md#processfeaturesrequire_module [`require.main`]: #requiremain [exports shortcut]: #exports-shortcut +[module namespace object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import#module_namespace_object [module resolution]: #all-together [native addons]: addons.md [subpath exports]: packages.md#subpath-exports diff --git a/doc/api/path.md b/doc/api/path.md index a0619d12287..62552782808 100644 --- a/doc/api/path.md +++ b/doc/api/path.md @@ -315,17 +315,19 @@ added: v0.11.2 * `path` {string} * Returns: {boolean} -The `path.isAbsolute()` method determines if `path` is an absolute path. +The `path.isAbsolute()` method determines if the literal `path` is absolute. +Therefore, it’s not safe for mitigating path traversals. If the given `path` is a zero-length string, `false` will be returned. For example, on POSIX: ```js -path.isAbsolute('/foo/bar'); // true -path.isAbsolute('/baz/..'); // true -path.isAbsolute('qux/'); // false -path.isAbsolute('.'); // false +path.isAbsolute('/foo/bar'); // true +path.isAbsolute('/baz/..'); // true +path.isAbsolute('/baz/../..'); // true +path.isAbsolute('qux/'); // false +path.isAbsolute('.'); // false ``` On Windows: diff --git a/doc/api/perf_hooks.md b/doc/api/perf_hooks.md index 0bdf8626f47..1113b618378 100644 --- a/doc/api/perf_hooks.md +++ b/doc/api/perf_hooks.md @@ -1849,7 +1849,7 @@ const obs = new PerformanceObserver((list, observer) => { performance.clearMeasures(); observer.disconnect(); }); -obs.observe({ entryTypes: ['measure'], buffered: true }); +obs.observe({ entryTypes: ['measure'] }); setTimeout(() => {}, 1000); ``` @@ -1884,7 +1884,7 @@ const obs = new PerformanceObserver((list) => { performance.clearMeasures(); obs.disconnect(); }); -obs.observe({ entryTypes: ['function'], buffered: true }); +obs.observe({ entryTypes: ['function'] }); require('some-module'); ``` diff --git a/doc/api/permissions.md b/doc/api/permissions.md index 80516643e89..ab010cf4d95 100644 --- a/doc/api/permissions.md +++ b/doc/api/permissions.md @@ -500,15 +500,8 @@ will be restricted. ```console $ node --experimental-permission index.js -node:internal/modules/cjs/loader:171 - const result = internalModuleStat(filename); - ^ Error: Access to this API has been restricted - at stat (node:internal/modules/cjs/loader:171:18) - at Module._findPath (node:internal/modules/cjs/loader:627:16) - at resolveMainPath (node:internal/modules/run_main:19:25) - at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:24) at node:internal/main/run_main_module:23:47 { code: 'ERR_ACCESS_DENIED', permission: 'FileSystemRead', @@ -588,6 +581,43 @@ does not exist, the wildcard will not be added, and access will be limited to yet, make sure to explicitly include the wildcard: `/my-path/folder-do-not-exist/*`. +#### Using the Permission Model with `npx` + +If you're using [`npx`][] to execute a Node.js script, you can enable the +Permission Model by passing the `--node-options` flag. For example: + +```bash +npx --node-options="--permission" package-name +``` + +This sets the `NODE_OPTIONS` environment variable for all Node.js processes +spawned by [`npx`][], without affecting the `npx` process itself. + +**FileSystemRead Error with `npx`** + +The above command will likely throw a `FileSystemRead` invalid access error +because Node.js requires file system read access to locate and execute the +package. To avoid this: + +1. **Using a Globally Installed Package** + Grant read access to the global `node_modules` directory by running: + + ```bash + npx --node-options="--permission --allow-fs-read=$(npm prefix -g)" package-name + ``` + +2. **Using the `npx` Cache** + If you are installing the package temporarily or relying on the `npx` cache, + grant read access to the npm cache directory: + + ```bash + npx --node-options="--permission --allow-fs-read=$(npm config get cache)" package-name + ``` + +Any arguments you would normally pass to `node` (e.g., `--allow-*` flags) can +also be passed through the `--node-options` flag. This flexibility makes it +easy to configure permissions as needed when using `npx`. + #### Permission Model constraints There are constraints you need to know before using this system: @@ -627,6 +657,7 @@ There are constraints you need to know before using this system: [`--allow-wasi`]: cli.md#--allow-wasi [`--allow-worker`]: cli.md#--allow-worker [`--experimental-permission`]: cli.md#--experimental-permission +[`npx`]: https://docs.npmjs.com/cli/commands/npx [`permission.has()`]: process.md#processpermissionhasscope-reference [relative-url string]: https://url.spec.whatwg.org/#relative-url-with-fragment-string [special schemes]: https://url.spec.whatwg.org/#special-scheme diff --git a/doc/api/util.md b/doc/api/util.md index d57230966cb..0bc8f1e8a60 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -286,7 +286,7 @@ corresponding argument. Supported specifiers are: * `%s`: `String` will be used to convert all values except `BigInt`, `Object` and `-0`. `BigInt` values will be represented with an `n` and Objects that - have no user defined `toString` function are inspected using `util.inspect()` + have neither a user defined `toString` function nor `Symbol.toPrimitive` function are inspected using `util.inspect()` with options `{ depth: 0, colors: false, compact: 3 }`. * `%d`: `Number` will be used to convert all values except `BigInt` and `Symbol`. diff --git a/doc/api/zlib.md b/doc/api/zlib.md index b4c763a130a..fe026b44e39 100644 --- a/doc/api/zlib.md +++ b/doc/api/zlib.md @@ -599,7 +599,6 @@ Allowed flush values. * `zlib.constants.Z_FULL_FLUSH` * `zlib.constants.Z_FINISH` * `zlib.constants.Z_BLOCK` -* `zlib.constants.Z_TREES` Return codes for the compression/decompression functions. Negative values are errors, positive values are used for special but normal diff --git a/doc/api_assets/style.css b/doc/api_assets/style.css index 1288b1a5956..bcf6b88b94b 100644 --- a/doc/api_assets/style.css +++ b/doc/api_assets/style.css @@ -295,6 +295,10 @@ li.picker-header a span { line-height: 1.5; } +#api-section-documentation .api_stability { + position: static; +} + .api_stability * { color: var(--white) !important; } @@ -365,6 +369,11 @@ p { padding-bottom: 2rem; } +/* prevent the module-level sticky stability header from overlapping the section headers when clicked */ +#apicontent:has(> .api_stability) a { + scroll-margin-top: 50px; +} + table { border-collapse: collapse; margin: 0 0 1.5rem; @@ -826,6 +835,12 @@ kbd { position: relative; top: 0; } + .api_stability { + top: 0; + } + #apicontent a { + scroll-margin-top: 0; + } } @media not screen, (max-height: 1000px) { diff --git a/doc/changelogs/CHANGELOG_V20.md b/doc/changelogs/CHANGELOG_V20.md index 96eb7e54301..33c7c3dbe19 100644 --- a/doc/changelogs/CHANGELOG_V20.md +++ b/doc/changelogs/CHANGELOG_V20.md @@ -9,6 +9,7 @@ +20.19.5
        20.19.4
        20.19.3
        20.19.2
        @@ -73,6 +74,157 @@ * [io.js](CHANGELOG_IOJS.md) * [Archive](CHANGELOG_ARCHIVE.md) + + +## 2025-09-03, Version 20.19.5 'Iron' (LTS), @marco-ippolito + +### Notable Changes + +* \[[`f5b293ad48`](https://github.com/nodejs/node/commit/f5b293ad48)] - **doc**: add JonasBa to collaborators (Jonas Badalic) [#58355](https://github.com/nodejs/node/pull/58355) +* \[[`4e6ae787c6`](https://github.com/nodejs/node/commit/4e6ae787c6)] - **doc**: add puskin to collaborators (Giovanni Bucci) [#58308](https://github.com/nodejs/node/pull/58308) +* \[[`d06db658fc`](https://github.com/nodejs/node/commit/d06db658fc)] - **doc**: add Filip Skokan to TSC (Rafael Gonzaga) [#58499](https://github.com/nodejs/node/pull/58499) +* \[[`3c6206cac9`](https://github.com/nodejs/node/commit/3c6206cac9)] - **doc**: add @geeksilva97 to collaborators (Edy Silva) [#57241](https://github.com/nodejs/node/pull/57241) + +### Commits + +* \[[`ea20403467`](https://github.com/nodejs/node/commit/ea20403467)] - **build**: fix uvwasi pkgname (Antoine du Hamel) [#58270](https://github.com/nodejs/node/pull/58270) +* \[[`c647aa4b30`](https://github.com/nodejs/node/commit/c647aa4b30)] - **build**: fix pointer compression builds (Joyee Cheung) [#58171](https://github.com/nodejs/node/pull/58171) +* \[[`d2c5e609ae`](https://github.com/nodejs/node/commit/d2c5e609ae)] - **build**: disable v8\_enable\_pointer\_compression\_shared\_cage on non-64bit (Shelley Vohr) [#58867](https://github.com/nodejs/node/pull/58867) +* \[[`84d5c4d244`](https://github.com/nodejs/node/commit/84d5c4d244)] - **build**: search for libnode.so in multiple places (Jan Staněk) [#58213](https://github.com/nodejs/node/pull/58213) +* \[[`068c439552`](https://github.com/nodejs/node/commit/068c439552)] - **crypto**: fix SHAKE128/256 breaking change introduced with OpenSSL 3.4 (Filip Skokan) [#58942](https://github.com/nodejs/node/pull/58942) +* \[[`edff105c34`](https://github.com/nodejs/node/commit/edff105c34)] - **debugger**: fix behavior of plain object exec in debugger repl (Dario Piotrowicz) [#57498](https://github.com/nodejs/node/pull/57498) +* \[[`0473e35b7f`](https://github.com/nodejs/node/commit/0473e35b7f)] - **deps**: update zlib to 1.3.1-470d3a2 (Node.js GitHub Bot) [#58628](https://github.com/nodejs/node/pull/58628) +* \[[`1218dbbea5`](https://github.com/nodejs/node/commit/1218dbbea5)] - **deps**: update zlib to 1.3.0.1-motley-780819f (Node.js GitHub Bot) [#57768](https://github.com/nodejs/node/pull/57768) +* \[[`0e3cd9ec00`](https://github.com/nodejs/node/commit/0e3cd9ec00)] - **deps**: update zlib to 1.3.0.1-motley-788cb3c (Node.js GitHub Bot) [#56655](https://github.com/nodejs/node/pull/56655) +* \[[`a194dd9bd4`](https://github.com/nodejs/node/commit/a194dd9bd4)] - **deps**: update archs files for openssl-3.0.16 (Node.js GitHub Bot) [#57335](https://github.com/nodejs/node/pull/57335) +* \[[`cc9b79ca70`](https://github.com/nodejs/node/commit/cc9b79ca70)] - **deps**: upgrade openssl sources to quictls/openssl-3.0.16 (Node.js GitHub Bot) [#57335](https://github.com/nodejs/node/pull/57335) +* \[[`82c46d5358`](https://github.com/nodejs/node/commit/82c46d5358)] - **deps**: update cjs-module-lexer to 2.1.0 (Node.js GitHub Bot) [#57180](https://github.com/nodejs/node/pull/57180) +* \[[`43e3f9b26b`](https://github.com/nodejs/node/commit/43e3f9b26b)] - **deps**: update cjs-module-lexer to 2.0.0 (Michael Dawson) [#56855](https://github.com/nodejs/node/pull/56855) +* \[[`91282ff16b`](https://github.com/nodejs/node/commit/91282ff16b)] - **deps**: update corepack to 0.33.0 (Node.js GitHub Bot) [#58566](https://github.com/nodejs/node/pull/58566) +* \[[`b76bca6f38`](https://github.com/nodejs/node/commit/b76bca6f38)] - **deps**: update acorn to 8.15.0 (Node.js GitHub Bot) [#58711](https://github.com/nodejs/node/pull/58711) +* \[[`ae11481011`](https://github.com/nodejs/node/commit/ae11481011)] - **deps**: update acorn to 8.14.1 (Node.js GitHub Bot) [#57382](https://github.com/nodejs/node/pull/57382) +* \[[`142d701201`](https://github.com/nodejs/node/commit/142d701201)] - **deps**: update minimatch to 10.0.3 (Node.js GitHub Bot) [#58712](https://github.com/nodejs/node/pull/58712) +* \[[`fee082d684`](https://github.com/nodejs/node/commit/fee082d684)] - **deps**: update llhttp to 9.3.0 (Fedor Indutny) [#58144](https://github.com/nodejs/node/pull/58144) +* \[[`c06f6f3f05`](https://github.com/nodejs/node/commit/c06f6f3f05)] - **dns**: remove redundant code using common variable (Deokjin Kim) [#57386](https://github.com/nodejs/node/pull/57386) +* \[[`cded8e7e77`](https://github.com/nodejs/node/commit/cded8e7e77)] - **dns**: fix parse memory leaky (theanarkh) [#58973](https://github.com/nodejs/node/pull/58973) +* \[[`182ae67233`](https://github.com/nodejs/node/commit/182ae67233)] - **dns**: fix dns query cache implementation (Ethan Arrowood) [#58404](https://github.com/nodejs/node/pull/58404) +* \[[`621b66a297`](https://github.com/nodejs/node/commit/621b66a297)] - **doc**: add review guidelines for collaborator nominations (Antoine du Hamel) [#57449](https://github.com/nodejs/node/pull/57449) +* \[[`b1009b5b72`](https://github.com/nodejs/node/commit/b1009b5b72)] - **doc**: explicit mention arbitrary code execution as a vuln (Rafael Gonzaga) [#57426](https://github.com/nodejs/node/pull/57426) +* \[[`f5b293ad48`](https://github.com/nodejs/node/commit/f5b293ad48)] - **doc**: add JonasBa to collaborators (Jonas Badalic) [#58355](https://github.com/nodejs/node/pull/58355) +* \[[`4e6ae787c6`](https://github.com/nodejs/node/commit/4e6ae787c6)] - **doc**: add puskin to collaborators (Giovanni Bucci) [#58308](https://github.com/nodejs/node/pull/58308) +* \[[`530473f479`](https://github.com/nodejs/node/commit/530473f479)] - **doc**: add ovflowd back to core collaborators (Claudio W.) [#58911](https://github.com/nodejs/node/pull/58911) +* \[[`38e8bbc131`](https://github.com/nodejs/node/commit/38e8bbc131)] - **doc**: add info on how project manages social media (Michael Dawson) [#57318](https://github.com/nodejs/node/pull/57318) +* \[[`d06bb4dcc2`](https://github.com/nodejs/node/commit/d06bb4dcc2)] - **doc**: ping nodejs/tsc for each security pull request (Rafael Gonzaga) [#57309](https://github.com/nodejs/node/pull/57309) +* \[[`d06db658fc`](https://github.com/nodejs/node/commit/d06db658fc)] - **doc**: add Filip Skokan to TSC (Rafael Gonzaga) [#58499](https://github.com/nodejs/node/pull/58499) +* \[[`8c3bc156ed`](https://github.com/nodejs/node/commit/8c3bc156ed)] - **doc**: clarify `path.isAbsolute` is not path traversal mitigation (Eric Fortis) [#57073](https://github.com/nodejs/node/pull/57073) +* \[[`e688410bda`](https://github.com/nodejs/node/commit/e688410bda)] - **doc**: fix rendering of DEP0174 description (David Sanders) [#56835](https://github.com/nodejs/node/pull/56835) +* \[[`e6a0c6a0fa`](https://github.com/nodejs/node/commit/e6a0c6a0fa)] - **doc**: add missing assert return types (Colin Ihrig) [#57219](https://github.com/nodejs/node/pull/57219) +* \[[`026b3cab6a`](https://github.com/nodejs/node/commit/026b3cab6a)] - **doc**: add 1ilsang to triage team (1ilsang) [#57183](https://github.com/nodejs/node/pull/57183) +* \[[`3c6206cac9`](https://github.com/nodejs/node/commit/3c6206cac9)] - **doc**: add @geeksilva97 to collaborators (Edy Silva) [#57241](https://github.com/nodejs/node/pull/57241) +* \[[`ef3a4675c7`](https://github.com/nodejs/node/commit/ef3a4675c7)] - **doc**: fix web.libera.chat link in pull-requests.md (Samuel Bronson) [#57076](https://github.com/nodejs/node/pull/57076) +* \[[`1db42b76f7`](https://github.com/nodejs/node/commit/1db42b76f7)] - **doc**: remove buffered flag from performance hooks examples (Pavel Romanov) [#52607](https://github.com/nodejs/node/pull/52607) +* \[[`b73a1356ce`](https://github.com/nodejs/node/commit/b73a1356ce)] - **doc**: add `module namespace object` links (Dario Piotrowicz) [#57093](https://github.com/nodejs/node/pull/57093) +* \[[`09368db20f`](https://github.com/nodejs/node/commit/09368db20f)] - **doc**: disambiguate pseudo-code statement (Dario Piotrowicz) [#57092](https://github.com/nodejs/node/pull/57092) +* \[[`2c3dc569a1`](https://github.com/nodejs/node/commit/2c3dc569a1)] - **doc**: fix wrong articles used to address modules (Dario Piotrowicz) [#57090](https://github.com/nodejs/node/pull/57090) +* \[[`cd8259cb4e`](https://github.com/nodejs/node/commit/cd8259cb4e)] - **doc**: `modules.md`: fix `distance` definition (Alexander “weej” Jones) [#57046](https://github.com/nodejs/node/pull/57046) +* \[[`7b0ea9ab2d`](https://github.com/nodejs/node/commit/7b0ea9ab2d)] - **doc**: fix wrong verb form (Dario Piotrowicz) [#57091](https://github.com/nodejs/node/pull/57091) +* \[[`14fcfc242b`](https://github.com/nodejs/node/commit/14fcfc242b)] - **doc**: add a note about `require('../common')` in testing documentation (Aditi) [#56953](https://github.com/nodejs/node/pull/56953) +* \[[`bc7d18b6ea`](https://github.com/nodejs/node/commit/bc7d18b6ea)] - **doc**: recommend writing tests in new files and including comments (Joyee Cheung) [#57028](https://github.com/nodejs/node/pull/57028) +* \[[`acd4d7f269`](https://github.com/nodejs/node/commit/acd4d7f269)] - **doc**: improve documentation on argument validation (Aditi) [#56954](https://github.com/nodejs/node/pull/56954) +* \[[`4cd6b3ca73`](https://github.com/nodejs/node/commit/4cd6b3ca73)] - **doc**: buffer: fix typo on `Buffer.copyBytesFrom(` `offset` option (tpoisseau) [#57015](https://github.com/nodejs/node/pull/57015) +* \[[`01220607f2`](https://github.com/nodejs/node/commit/01220607f2)] - **doc**: update cleanup to trust on vuln db automation (Rafael Gonzaga) [#57004](https://github.com/nodejs/node/pull/57004) +* \[[`77a0505a32`](https://github.com/nodejs/node/commit/77a0505a32)] - **doc**: update post sec release process (Rafael Gonzaga) [#56907](https://github.com/nodejs/node/pull/56907) +* \[[`77dbcfce5f`](https://github.com/nodejs/node/commit/77dbcfce5f)] - **doc**: add section about using npx with permission model (Rafael Gonzaga) [#56539](https://github.com/nodejs/node/pull/56539) +* \[[`73e51407b7`](https://github.com/nodejs/node/commit/73e51407b7)] - **doc**: remove RedYetiDev from triagers team (Aviv Keller) [#55947](https://github.com/nodejs/node/pull/55947) +* \[[`9a36cbb792`](https://github.com/nodejs/node/commit/9a36cbb792)] - **doc**: fix relative path mention in --allow-fs (Rafael Gonzaga) [#55791](https://github.com/nodejs/node/pull/55791) +* \[[`04d9c5baeb`](https://github.com/nodejs/node/commit/04d9c5baeb)] - **doc**: add scroll margin to links (Roman Reiss) [#58982](https://github.com/nodejs/node/pull/58982) +* \[[`959a67f6ff`](https://github.com/nodejs/node/commit/959a67f6ff)] - **doc**: make Stability labels not sticky in Stability index (Livia Medeiros) [#58291](https://github.com/nodejs/node/pull/58291) +* \[[`8757a5532f`](https://github.com/nodejs/node/commit/8757a5532f)] - **doc**: update release key for aduh95 (Antoine du Hamel) [#58877](https://github.com/nodejs/node/pull/58877) +* \[[`6fa0626327`](https://github.com/nodejs/node/commit/6fa0626327)] - **doc,src,test**: fix typos (Noritaka Kobayashi) [#58477](https://github.com/nodejs/node/pull/58477) +* \[[`9991788e4a`](https://github.com/nodejs/node/commit/9991788e4a)] - **http**: coerce content-length to number (Marco Ippolito) [#57458](https://github.com/nodejs/node/pull/57458) +* \[[`ff5cf8a428`](https://github.com/nodejs/node/commit/ff5cf8a428)] - **http2**: fix check for `frame->hd.type` (hanguanqiang) [#57644](https://github.com/nodejs/node/pull/57644) +* \[[`2f333b6c51`](https://github.com/nodejs/node/commit/2f333b6c51)] - **lib**: optimize `prepareStackTrace` on builtin frames (Chengzhong Wu) [#56299](https://github.com/nodejs/node/pull/56299) +* \[[`cdf985071f`](https://github.com/nodejs/node/commit/cdf985071f)] - **lib**: suppress source map lookup exceptions (Chengzhong Wu) [#56299](https://github.com/nodejs/node/pull/56299) +* \[[`faa08b14ed`](https://github.com/nodejs/node/commit/faa08b14ed)] - **lib**: fixup incorrect argument order in assertEncoding (James M Snell) [#57177](https://github.com/nodejs/node/pull/57177) +* \[[`a683cd1232`](https://github.com/nodejs/node/commit/a683cd1232)] - **meta**: add IlyasShabi to collaborators (Ilyas Shabi) [#58916](https://github.com/nodejs/node/pull/58916) +* \[[`b145bb28aa`](https://github.com/nodejs/node/commit/b145bb28aa)] - **meta**: bump codecov/codecov-action from 5.4.2 to 5.4.3 (dependabot\[bot]) [#58551](https://github.com/nodejs/node/pull/58551) +* \[[`2c59789001`](https://github.com/nodejs/node/commit/2c59789001)] - **meta**: bump ossf/scorecard-action from 2.4.1 to 2.4.2 (dependabot\[bot]) [#58550](https://github.com/nodejs/node/pull/58550) +* \[[`4095337e96`](https://github.com/nodejs/node/commit/4095337e96)] - **meta**: bump rtCamp/action-slack-notify from 2.3.2 to 2.3.3 (dependabot\[bot]) [#58108](https://github.com/nodejs/node/pull/58108) +* \[[`631fed8e39`](https://github.com/nodejs/node/commit/631fed8e39)] - **meta**: move one or more collaborators to emeritus (Node.js GitHub Bot) [#58456](https://github.com/nodejs/node/pull/58456) +* \[[`7d2f7180b6`](https://github.com/nodejs/node/commit/7d2f7180b6)] - **meta**: bump codecov/codecov-action from 5.4.0 to 5.4.2 (dependabot\[bot]) [#58110](https://github.com/nodejs/node/pull/58110) +* \[[`1558551ea5`](https://github.com/nodejs/node/commit/1558551ea5)] - **meta**: bump actions/download-artifact from 4.2.1 to 4.3.0 (dependabot\[bot]) [#58106](https://github.com/nodejs/node/pull/58106) +* \[[`e1f12fe737`](https://github.com/nodejs/node/commit/e1f12fe737)] - **meta**: ignore mailmap changes in linux ci (Jonas Badalic) [#58356](https://github.com/nodejs/node/pull/58356) +* \[[`1b78eb1313`](https://github.com/nodejs/node/commit/1b78eb1313)] - **meta**: bump actions/setup-node from 4.3.0 to 4.4.0 (dependabot\[bot]) [#58111](https://github.com/nodejs/node/pull/58111) +* \[[`2b8449c39a`](https://github.com/nodejs/node/commit/2b8449c39a)] - **meta**: bump actions/setup-python from 5.5.0 to 5.6.0 (dependabot\[bot]) [#58107](https://github.com/nodejs/node/pull/58107) +* \[[`833b70bbc5`](https://github.com/nodejs/node/commit/833b70bbc5)] - **meta**: allow penetration testing on live system with prior authorization (Matteo Collina) [#57966](https://github.com/nodejs/node/pull/57966) +* \[[`c6a88561f5`](https://github.com/nodejs/node/commit/c6a88561f5)] - **meta**: bump actions/setup-python from 5.4.0 to 5.5.0 (dependabot\[bot]) [#57718](https://github.com/nodejs/node/pull/57718) +* \[[`9046ef4fb3`](https://github.com/nodejs/node/commit/9046ef4fb3)] - **meta**: bump peter-evans/create-pull-request from 7.0.7 to 7.0.8 (dependabot\[bot]) [#57717](https://github.com/nodejs/node/pull/57717) +* \[[`46388a4e2a`](https://github.com/nodejs/node/commit/46388a4e2a)] - **meta**: bump actions/cache from 4.2.2 to 4.2.3 (dependabot\[bot]) [#57715](https://github.com/nodejs/node/pull/57715) +* \[[`d3970685bd`](https://github.com/nodejs/node/commit/d3970685bd)] - **meta**: bump actions/setup-node from 4.2.0 to 4.3.0 (dependabot\[bot]) [#57714](https://github.com/nodejs/node/pull/57714) +* \[[`47004ef37f`](https://github.com/nodejs/node/commit/47004ef37f)] - **meta**: bump actions/upload-artifact from 4.6.1 to 4.6.2 (dependabot\[bot]) [#57713](https://github.com/nodejs/node/pull/57713) +* \[[`4abe83ec03`](https://github.com/nodejs/node/commit/4abe83ec03)] - **meta**: add some clarification to the nomination process (James M Snell) [#57503](https://github.com/nodejs/node/pull/57503) +* \[[`45e9b88363`](https://github.com/nodejs/node/commit/45e9b88363)] - **meta**: remove collaborator self-nomination (Rich Trott) [#57537](https://github.com/nodejs/node/pull/57537) +* \[[`d10949b7d8`](https://github.com/nodejs/node/commit/d10949b7d8)] - **meta**: edit collaborator nomination process (Antoine du Hamel) [#57483](https://github.com/nodejs/node/pull/57483) +* \[[`704562fb7a`](https://github.com/nodejs/node/commit/704562fb7a)] - **meta**: move ovflowd to emeritus (Claudio W.) [#57443](https://github.com/nodejs/node/pull/57443) +* \[[`3f981b8537`](https://github.com/nodejs/node/commit/3f981b8537)] - **meta**: bump codecov/codecov-action from 5.3.1 to 5.4.0 (dependabot\[bot]) [#57257](https://github.com/nodejs/node/pull/57257) +* \[[`7e1ff7b332`](https://github.com/nodejs/node/commit/7e1ff7b332)] - **meta**: bump ossf/scorecard-action from 2.4.0 to 2.4.1 (dependabot\[bot]) [#57253](https://github.com/nodejs/node/pull/57253) +* \[[`8d4ec412b9`](https://github.com/nodejs/node/commit/8d4ec412b9)] - **meta**: move RaisinTen back to collaborators, triagers and SEA champion (Darshan Sen) [#57292](https://github.com/nodejs/node/pull/57292) +* \[[`cc2abb5d17`](https://github.com/nodejs/node/commit/cc2abb5d17)] - **meta**: bump peter-evans/create-pull-request from 7.0.6 to 7.0.7 (dependabot\[bot]) [#57259](https://github.com/nodejs/node/pull/57259) +* \[[`4fad2b8758`](https://github.com/nodejs/node/commit/4fad2b8758)] - **meta**: bump actions/cache from 4.2.0 to 4.2.2 (dependabot\[bot]) [#57256](https://github.com/nodejs/node/pull/57256) +* \[[`5f5bb8b986`](https://github.com/nodejs/node/commit/5f5bb8b986)] - **meta**: bump actions/upload-artifact from 4.6.0 to 4.6.1 (dependabot\[bot]) [#57255](https://github.com/nodejs/node/pull/57255) +* \[[`e949359a56`](https://github.com/nodejs/node/commit/e949359a56)] - **meta**: bump `actions/setup-python` from 5.3.0 to 5.4.0 (dependabot\[bot]) [#56867](https://github.com/nodejs/node/pull/56867) +* \[[`d3c5ad7510`](https://github.com/nodejs/node/commit/d3c5ad7510)] - **meta**: bump `peter-evans/create-pull-request` from 7.0.5 to 7.0.6 (dependabot\[bot]) [#56866](https://github.com/nodejs/node/pull/56866) +* \[[`56decfe2d1`](https://github.com/nodejs/node/commit/56decfe2d1)] - **meta**: bump `codecov/codecov-action` from 5.0.7 to 5.3.1 (dependabot\[bot]) [#56864](https://github.com/nodejs/node/pull/56864) +* \[[`52e518444d`](https://github.com/nodejs/node/commit/52e518444d)] - **meta**: bump `actions/cache` from 4.1.2 to 4.2.0 (dependabot\[bot]) [#56862](https://github.com/nodejs/node/pull/56862) +* \[[`9cac93d9c3`](https://github.com/nodejs/node/commit/9cac93d9c3)] - **meta**: bump `actions/stale` from 9.0.0 to 9.1.0 (dependabot\[bot]) [#56860](https://github.com/nodejs/node/pull/56860) +* \[[`ecf4252f7c`](https://github.com/nodejs/node/commit/ecf4252f7c)] - **meta**: update last name for jkrems (Jan Martin) [#57006](https://github.com/nodejs/node/pull/57006) +* \[[`e8beaaaedf`](https://github.com/nodejs/node/commit/e8beaaaedf)] - **meta**: bump `actions/upload-artifact` from 4.4.3 to 4.6.0 (dependabot\[bot]) [#56861](https://github.com/nodejs/node/pull/56861) +* \[[`5462c257f8`](https://github.com/nodejs/node/commit/5462c257f8)] - **meta**: bump `actions/setup-node` from 4.1.0 to 4.2.0 (dependabot\[bot]) [#56868](https://github.com/nodejs/node/pull/56868) +* \[[`89c37891a0`](https://github.com/nodejs/node/commit/89c37891a0)] - **meta**: move one or more collaborators to emeritus (Node.js GitHub Bot) [#56889](https://github.com/nodejs/node/pull/56889) +* \[[`2a0175c291`](https://github.com/nodejs/node/commit/2a0175c291)] - **meta**: add @nodejs/url as codeowner (Chengzhong Wu) [#56783](https://github.com/nodejs/node/pull/56783) +* \[[`c12aae1e78`](https://github.com/nodejs/node/commit/c12aae1e78)] - **meta**: bump github/codeql-action from 3.28.18 to 3.29.2 (dependabot\[bot]) [#58922](https://github.com/nodejs/node/pull/58922) +* \[[`4ef09990f1`](https://github.com/nodejs/node/commit/4ef09990f1)] - **meta**: bump github/codeql-action from 3.28.16 to 3.28.18 (dependabot\[bot]) [#58552](https://github.com/nodejs/node/pull/58552) +* \[[`889654eb2c`](https://github.com/nodejs/node/commit/889654eb2c)] - **meta**: bump github/codeql-action from 3.28.11 to 3.28.16 (dependabot\[bot]) [#58112](https://github.com/nodejs/node/pull/58112) +* \[[`091e5c1bb9`](https://github.com/nodejs/node/commit/091e5c1bb9)] - **meta**: bump github/codeql-action from 3.28.10 to 3.28.13 (dependabot\[bot]) [#57716](https://github.com/nodejs/node/pull/57716) +* \[[`01415153de`](https://github.com/nodejs/node/commit/01415153de)] - **meta**: bump github/codeql-action from 3.28.8 to 3.28.10 (dependabot\[bot]) [#57254](https://github.com/nodejs/node/pull/57254) +* \[[`72ea8aac34`](https://github.com/nodejs/node/commit/72ea8aac34)] - **meta**: bump `github/codeql-action` from 3.27.5 to 3.28.8 (dependabot\[bot]) [#56859](https://github.com/nodejs/node/pull/56859) +* \[[`99a271e588`](https://github.com/nodejs/node/commit/99a271e588)] - **meta**: bump step-security/harden-runner from 2.12.0 to 2.12.2 (dependabot\[bot]) [#58923](https://github.com/nodejs/node/pull/58923) +* \[[`b4c4c02490`](https://github.com/nodejs/node/commit/b4c4c02490)] - **meta**: bump step-security/harden-runner from 2.11.0 to 2.12.0 (dependabot\[bot]) [#58109](https://github.com/nodejs/node/pull/58109) +* \[[`5361bb9157`](https://github.com/nodejs/node/commit/5361bb9157)] - **meta**: bump step-security/harden-runner from 2.10.4 to 2.11.0 (dependabot\[bot]) [#57258](https://github.com/nodejs/node/pull/57258) +* \[[`28e33acf30`](https://github.com/nodejs/node/commit/28e33acf30)] - **meta**: bump `step-security/harden-runner` from 2.10.2 to 2.10.4 (dependabot\[bot]) [#56863](https://github.com/nodejs/node/pull/56863) +* \[[`fad773cede`](https://github.com/nodejs/node/commit/fad773cede)] - **module**: throw error when re-runing errored module jobs (Joyee Cheung) [#58957](https://github.com/nodejs/node/pull/58957) +* \[[`2531185423`](https://github.com/nodejs/node/commit/2531185423)] - **module**: allow cycles in require() in the CJS handling in ESM loader (Joyee Cheung) [#58598](https://github.com/nodejs/node/pull/58598) +* \[[`ed43b69689`](https://github.com/nodejs/node/commit/ed43b69689)] - **module**: clarify cjs global-like error on ModuleJobSync (Carlos Espa) [#56491](https://github.com/nodejs/node/pull/56491) +* \[[`6e02db1b12`](https://github.com/nodejs/node/commit/6e02db1b12)] - **module**: handle instantiated async module jobs in require(esm) (Joyee Cheung) [#58067](https://github.com/nodejs/node/pull/58067) +* \[[`badba50d30`](https://github.com/nodejs/node/commit/badba50d30)] - **module**: fix incorrect formatting in require(esm) cycle error message (haykam821) [#57453](https://github.com/nodejs/node/pull/57453) +* \[[`939ecf8906`](https://github.com/nodejs/node/commit/939ecf8906)] - **module**: handle cached linked async jobs in require(esm) (Joyee Cheung) [#57187](https://github.com/nodejs/node/pull/57187) +* \[[`ba7f8a0353`](https://github.com/nodejs/node/commit/ba7f8a0353)] - **module**: improve error message from asynchronicity in require(esm) (Joyee Cheung) [#57126](https://github.com/nodejs/node/pull/57126) +* \[[`c1e7fa2586`](https://github.com/nodejs/node/commit/c1e7fa2586)] - **module**: handle .mjs in .js handler in CommonJS (Joyee Cheung) [#55590](https://github.com/nodejs/node/pull/55590) +* \[[`41f3dfd21b`](https://github.com/nodejs/node/commit/41f3dfd21b)] - **module**: fix require.resolve() crash on non-string paths (Aditi) [#56942](https://github.com/nodejs/node/pull/56942) +* \[[`043dcdd628`](https://github.com/nodejs/node/commit/043dcdd628)] - **os**: fix GetInterfaceAddresses memory lieaky (theanarkh) [#58940](https://github.com/nodejs/node/pull/58940) +* \[[`9b74e9bfd9`](https://github.com/nodejs/node/commit/9b74e9bfd9)] - **permission**: ignore internalModuleStat on module loading (Rafael Gonzaga) [#55797](https://github.com/nodejs/node/pull/55797) +* \[[`611a147b45`](https://github.com/nodejs/node/commit/611a147b45)] - **readline**: fix unresolved promise on abortion (Daniel Venable) [#54030](https://github.com/nodejs/node/pull/54030) +* \[[`f891ae3421`](https://github.com/nodejs/node/commit/f891ae3421)] - **repl**: avoid deprecated `require.extensions` in tab completion (baki gul) [#58653](https://github.com/nodejs/node/pull/58653) +* \[[`7ba44290bf`](https://github.com/nodejs/node/commit/7ba44290bf)] - **repl**: fix tab completion not working with computer string properties (Dario Piotrowicz) [#58709](https://github.com/nodejs/node/pull/58709) +* \[[`eb842048b2`](https://github.com/nodejs/node/commit/eb842048b2)] - **src**: do not format single string argument for THROW\_ERR\_\* (Joyee Cheung) [#57126](https://github.com/nodejs/node/pull/57126) +* \[[`4f004937ec`](https://github.com/nodejs/node/commit/4f004937ec)] - **src**: fixup errorhandling more in various places (James M Snell) [#57852](https://github.com/nodejs/node/pull/57852) +* \[[`5daa7fe2e2`](https://github.com/nodejs/node/commit/5daa7fe2e2)] - **src**: fix module buffer allocation (X-BW) [#57738](https://github.com/nodejs/node/pull/57738) +* \[[`586b1be11b`](https://github.com/nodejs/node/commit/586b1be11b)] - **src**: fix build when using shared simdutf (Antoine du Hamel) [#58407](https://github.com/nodejs/node/pull/58407) +* \[[`563e61f012`](https://github.com/nodejs/node/commit/563e61f012)] - **src**: fix possible dereference of null pointer (Eusgor) [#58459](https://github.com/nodejs/node/pull/58459) +* \[[`cbec07ea0b`](https://github.com/nodejs/node/commit/cbec07ea0b)] - **src**: fix FIPS init error handling (Tobias Nießen) [#58379](https://github.com/nodejs/node/pull/58379) +* \[[`80fb80e71b`](https://github.com/nodejs/node/commit/80fb80e71b)] - **src**: fix -Wunreachable-code in src/node\_api.cc (Shelley Vohr) [#58901](https://github.com/nodejs/node/pull/58901) +* \[[`5e97719860`](https://github.com/nodejs/node/commit/5e97719860)] - **test**: skip test-http-imports on macos (Marco Ippolito) [#59745](https://github.com/nodejs/node/pull/59745) +* \[[`69c43bdfcc`](https://github.com/nodejs/node/commit/69c43bdfcc)] - **test**: fix internet/test-dns (Michaël Zasso) [#59660](https://github.com/nodejs/node/pull/59660) +* \[[`6fd58e0338`](https://github.com/nodejs/node/commit/6fd58e0338)] - **tools**: update coverage GitHub Actions to fixed version (Rich Trott) [#59512](https://github.com/nodejs/node/pull/59512) +* \[[`eb7bbce73e`](https://github.com/nodejs/node/commit/eb7bbce73e)] - **tools**: disable failing coverage jobs (Antoine du Hamel) [#58770](https://github.com/nodejs/node/pull/58770) +* \[[`65b1669936`](https://github.com/nodejs/node/commit/65b1669936)] - **util**: fix formatting of objects with built-in Symbol.toPrimitive (Shima Ryuhei) [#57832](https://github.com/nodejs/node/pull/57832) +* \[[`8a29f13bec`](https://github.com/nodejs/node/commit/8a29f13bec)] - **util**: fix parseEnv incorrectly splitting multiple ‘=‘ in value (HEESEUNG) [#57421](https://github.com/nodejs/node/pull/57421) +* \[[`077d5020c4`](https://github.com/nodejs/node/commit/077d5020c4)] - **v8**: fix missing callback in heap utils destroy (Ruben Bridgewater) [#58846](https://github.com/nodejs/node/pull/58846) +* \[[`34ae9f8b18`](https://github.com/nodejs/node/commit/34ae9f8b18)] - **vm**: import call should return a promise in the current context (Chengzhong Wu) [#58309](https://github.com/nodejs/node/pull/58309) +* \[[`0dd3a8d6d1`](https://github.com/nodejs/node/commit/0dd3a8d6d1)] - **win,build**: fix MSVS v17.14 compilation issue (StefanStojanovic) [#58902](https://github.com/nodejs/node/pull/58902) +* \[[`1b83a2bd2d`](https://github.com/nodejs/node/commit/1b83a2bd2d)] - **zlib**: remove mentions of unexposed Z\_TREES constant (Jimmy Leung) [#58371](https://github.com/nodejs/node/pull/58371) +* \[[`9dc9604502`](https://github.com/nodejs/node/commit/9dc9604502)] - **zlib**: fix pointer alignment (jhofstee) [#57727](https://github.com/nodejs/node/pull/57727) + ## 2025-07-15, Version 20.19.4 'Iron' (LTS), @RafaelGSS diff --git a/doc/changelogs/NSOLID_CHANGELOG_V6_NODE_V20.md b/doc/changelogs/NSOLID_CHANGELOG_V6_NODE_V20.md new file mode 100644 index 00000000000..b354d4fb302 --- /dev/null +++ b/doc/changelogs/NSOLID_CHANGELOG_V6_NODE_V20.md @@ -0,0 +1,75 @@ +# N|Solid Changelog + + + +## 2025-10-29, Version 20.19.5-nsolid-v6.0.2 'Iron' + +### Commits + +* \[[`9dae5aaa10`](https://github.com/nodesource/nsolid/commit/9dae5aaa10)] - Merge tag 'v20.19.5' into node-v20.19.5-nsolid-v6.0.2-release (Santiago Gimeno) +* \[[`263eeee871`](https://github.com/nodesource/nsolid/commit/263eeee871)] - **agents**: improve debug logging and fix win crash (Santiago Gimeno) [#376](https://github.com/nodesource/nsolid/pull/376) +* \[[`0d71f54201`](https://github.com/nodesource/nsolid/commit/0d71f54201)] - **agents**: guard StartWritesDone() in grpc streams (Santiago Gimeno) [#379](https://github.com/nodesource/nsolid/pull/379) +* \[[`60e905e951`](https://github.com/nodesource/nsolid/commit/60e905e951)] - **build,deps**: add v8 patch management system (Santiago Gimeno) [#381](https://github.com/nodesource/nsolid/pull/381) +* \[[`40a9809378`](https://github.com/nodesource/nsolid/commit/40a9809378)] - **deps**: add missing files to grpc and curl gyp files (Santiago Gimeno) [#380](https://github.com/nodesource/nsolid/pull/380) +* \[[`4e24bbc857`](https://github.com/nodesource/nsolid/commit/4e24bbc857)] - **deps**: add missing source file to libcurl gyp (Santiago Gimeno) +* \[[`159dbbf9a5`](https://github.com/nodesource/nsolid/commit/159dbbf9a5)] - **deps**: add support for exporting Summary via OTLP (Santiago Gimeno) [#371](https://github.com/nodesource/nsolid/pull/371) +* \[[`def02f8e29`](https://github.com/nodesource/nsolid/commit/def02f8e29)] - **deps**: update opentelemetry-cpp to 1.23.0 (Santiago Gimeno) [#371](https://github.com/nodesource/nsolid/pull/371) +* \[[`590fe44283`](https://github.com/nodesource/nsolid/commit/590fe44283)] - **deps**: update libcurl to 8.16.0 (Santiago Gimeno) [#370](https://github.com/nodesource/nsolid/pull/370) +* \[[`bb1320cb5d`](https://github.com/nodesource/nsolid/commit/bb1320cb5d)] - **deps**: update grpc to 1.75.0 (Santiago Gimeno) [#369](https://github.com/nodesource/nsolid/pull/369) +* \[[`b665e3d776`](https://github.com/nodesource/nsolid/commit/b665e3d776)] - **doc**: explain NSOLID\_DISABLE\_PACKAGE\_SCAN better (Santiago Gimeno) [#362](https://github.com/nodesource/nsolid/pull/362) +* \[[`dca0a2780b`](https://github.com/nodesource/nsolid/commit/dca0a2780b)] - **src**: clamp idle time to avoid underflow in metrics (Santiago Gimeno) [#372](https://github.com/nodesource/nsolid/pull/372) +* \[[`f2fc4d6c4a`](https://github.com/nodesource/nsolid/commit/f2fc4d6c4a)] - **test**: fix flaky test-grpc-packages (Santiago Gimeno) [#368](https://github.com/nodesource/nsolid/pull/368) + +## 2025-09-17, Version 20.19.4-nsolid-v6.0.1 'Iron' + +### Commits + +* \[[`b8cce4f42e`](https://github.com/nodesource/nsolid/commit/b8cce4f42e)] - **src**: allow missing process title in metrics update (Santiago Gimeno) [#364](https://github.com/nodesource/nsolid/pull/364) +* \[[`71eff2f67c`](https://github.com/nodesource/nsolid/commit/71eff2f67c)] - **src**: handle nameless user @ ProcessMetrics::Update (Santiago Gimeno) [#364](https://github.com/nodesource/nsolid/pull/364) + +## 2025-08-27, Version 20.19.4-nsolid-v6.0.0 'Iron' + +### Commits + +* \[[`6fe5981de3`](https://github.com/nodesource/nsolid/commit/6fe5981de3)] - **agents**: enable compression in GrpcAgent (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`71e8ba668f`](https://github.com/nodesource/nsolid/commit/71e8ba668f)] - **agents**: fix crash accessing cont prof queue (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`247cac1d84`](https://github.com/nodesource/nsolid/commit/247cac1d84)] - **agents**: optimize span collector message sending (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`daaac13d07`](https://github.com/nodesource/nsolid/commit/daaac13d07)] - **agents**: support `contCpuProfile` command in the GRPC interface (Juan José Arboleda) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`9089a4c079`](https://github.com/nodesource/nsolid/commit/9089a4c079)] - **agents**: fix cont profiling timestamp calculation (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`4e0c43991d`](https://github.com/nodesource/nsolid/commit/4e0c43991d)] - **agents**: add continuous profiling to gRPC agent (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`c104e14a91`](https://github.com/nodesource/nsolid/commit/c104e14a91)] - **agents**: grow AssetStream to support cont profiling (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`bccb1f9930`](https://github.com/nodesource/nsolid/commit/bccb1f9930)] - **agents**: add ExportContinuousProfile rpc (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`254f5fb7db`](https://github.com/nodesource/nsolid/commit/254f5fb7db)] - **build**: real fix for test-grpc-packages (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`99969bdfde`](https://github.com/nodesource/nsolid/commit/99969bdfde)] - **build,test**: make test-grpc-packages pass again (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`59e320ef98`](https://github.com/nodesource/nsolid/commit/59e320ef98)] - **deps**: bump nsolid-cli to solve vulnerabilities (Minwoo) [nodesource/nsolid-private#14](https://github.com/nodesource/nsolid-private/pull/14) +* \[[`1fb74be9f6`](https://github.com/nodesource/nsolid/commit/1fb74be9f6)] - **deps**: update grpc to 1.74.0 (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`8cc1e530b5`](https://github.com/nodesource/nsolid/commit/8cc1e530b5)] - **deps**: add support for exporting Summary via OTLP (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`80d38209d2`](https://github.com/nodesource/nsolid/commit/80d38209d2)] - **deps**: update to opentelemetry 1.22.0 (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`eb250dbdbb`](https://github.com/nodesource/nsolid/commit/eb250dbdbb)] - **deps**: update protobuf to 32.0 (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`df016815fa`](https://github.com/nodesource/nsolid/commit/df016815fa)] - **deps**: update grpc to 1.73.1 (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`ce088f59ca`](https://github.com/nodesource/nsolid/commit/ce088f59ca)] - **deps**: update protobuf to 31.1 (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`8220e771b9`](https://github.com/nodesource/nsolid/commit/8220e771b9)] - **deps**: update libcurl to 8.15.0 (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`5eb93c4d33`](https://github.com/nodesource/nsolid/commit/5eb93c4d33)] - **deps**: update protobuf to 30.2 and grpc to 1.72.0 (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`b6b2fc4d00`](https://github.com/nodesource/nsolid/commit/b6b2fc4d00)] - **deps**: add support for exporting Summary via OTLP (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`10735208d9`](https://github.com/nodesource/nsolid/commit/10735208d9)] - **deps**: update opentelemetry-cpp to 1.21.0 (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`b3afa67166`](https://github.com/nodesource/nsolid/commit/b3afa67166)] - **deps**: update json to 3.12.0 (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`b09d6f87d4`](https://github.com/nodesource/nsolid/commit/b09d6f87d4)] - **deps**: update libcurl to 8.13.0 (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`4610f35626`](https://github.com/nodesource/nsolid/commit/4610f35626)] - **deps,win**: fix grpc build (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`bba804e112`](https://github.com/nodesource/nsolid/commit/bba804e112)] - **deps,win**: fix protobuf abseil-cpp compilation (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`3af7d8174e`](https://github.com/nodesource/nsolid/commit/3af7d8174e)] - **lib**: only use gRPC to connect to SaaS (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`c870caec35`](https://github.com/nodesource/nsolid/commit/c870caec35)] - **lib**: add continuous CPU profiling configuration (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`4f84d0b0c7`](https://github.com/nodesource/nsolid/commit/4f84d0b0c7)] - **src**: make AsyncTSQueue C++17 compatible (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`a96b9884a1`](https://github.com/nodesource/nsolid/commit/a96b9884a1)] - **src**: add fast api call to get spanId and traceId (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`88d649df02`](https://github.com/nodesource/nsolid/commit/88d649df02)] - **src**: add fast api calls to push span strings (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`3017d63746`](https://github.com/nodesource/nsolid/commit/3017d63746)] - **src**: add batching options to AsyncTSQueue (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`2a575a03ba`](https://github.com/nodesource/nsolid/commit/2a575a03ba)] - **src**: optimize async notifications in enqueue (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`a4bc3fd57e`](https://github.com/nodesource/nsolid/commit/a4bc3fd57e)] - **src**: add batched support callback in AsyncTSQueue (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`ed8f6e5518`](https://github.com/nodesource/nsolid/commit/ed8f6e5518)] - **src**: fix thread-safety issues @ ContinuousProfiler (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`cf85b9fc27`](https://github.com/nodesource/nsolid/commit/cf85b9fc27)] - **src**: store hasEbpfSupport metadata in info.proto (RafaelGSS) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`74c6a1e4fa`](https://github.com/nodesource/nsolid/commit/74c6a1e4fa)] - **src**: integrate ContinuousProfiler with EnvList (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`2d8d138edf`](https://github.com/nodesource/nsolid/commit/2d8d138edf)] - **src**: implement ContinuousProfiler class (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`27823e079b`](https://github.com/nodesource/nsolid/commit/27823e079b)] - **test**: fix test-zmq-packages.mjs agents test (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`50f9000e25`](https://github.com/nodesource/nsolid/commit/50f9000e25)] - **test**: add gRPC continuous profiling tests (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`f1d9a0c02e`](https://github.com/nodesource/nsolid/commit/f1d9a0c02e)] - **test**: add continuous profiling configuration tests (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`5ecc8bc78a`](https://github.com/nodesource/nsolid/commit/5ecc8bc78a)] - **tools**: fix linting in update-protobuf.sh updater (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) +* \[[`2f90535d80`](https://github.com/nodesource/nsolid/commit/2f90535d80)] - **tools**: add script to regenerate protofiles (Santiago Gimeno) [#359](https://github.com/nodesource/nsolid/pull/359) diff --git a/doc/contributing/managing-social-media-acounts.md b/doc/contributing/managing-social-media-acounts.md new file mode 100644 index 00000000000..3095e0ab740 --- /dev/null +++ b/doc/contributing/managing-social-media-acounts.md @@ -0,0 +1,49 @@ +# Managing social media accounts + +The project obtains and manages social media accounts in order to help +promote the project and to share content that benefits the ecosystem. + +Currently the project has the following social media accounts: + +* [bluesky](https://bsky.app/profile/nodejs.org) +* [twitter](https://x.com/nodejs) +* [Facebook](https://www.facebook.com/nodejsfoundation) +* [LinkedIn](https://www.linkedin.com/company/node.js-foundation/) + +## bluesky + +Bluesky is managed directly by the project. Automation is used +to request posts/reposts as outlined in +[nodejs/bluesky](https://github.com/nodejs/bluesky). + +Login credentials are available to members of the Technical +Steering Committee, but are not to be used directly except +in exceptional circumstances. + +## Twitter/X + +Day to day management of the Twitter/X account has been +delegated to the Foundation Staff. + +In addition, it has been agreed that Releasers may login +and post when doing a release, and TSC members may post +an announcement of a release if a releaser is not able to +do it themselves. + +Login credentials are available to members of the Technical +Steering Committee. Releasers may request access by +opening an issue in the nodejs/admin repo asking for access. + +## Facebook + +Day to day management of the Facebook account has been +delegated to the Foundation Staff. + +No project members have access to the Facebook account. + +## Linkedin + +Day to day management of the LinkedIn account has been +delegated to the Foundation Staff. + +No project members have access to the LinkedIn account. diff --git a/doc/contributing/pull-requests.md b/doc/contributing/pull-requests.md index 2c1849b67ad..fb2318f7137 100644 --- a/doc/contributing/pull-requests.md +++ b/doc/contributing/pull-requests.md @@ -59,7 +59,7 @@ help, questions, and discussions. development of Node.js core specifically. Node.js also has an unofficial IRC channel: -[#Node.js](https://web.libera.chat/?channels=node.js). +[#Node.js](https://web.libera.chat/#node.js). ## Setting up your local environment diff --git a/doc/contributing/security-release-process.md b/doc/contributing/security-release-process.md index d2eef2c6dad..6ba435c9bd2 100644 --- a/doc/contributing/security-release-process.md +++ b/doc/contributing/security-release-process.md @@ -60,6 +60,9 @@ The current security stewards are documented in the main Node.js * Use the "summary" feature in HackerOne. Example [2038134](https://hackerone.com/reports/2038134) * `git node security --add-report=report_id` * `git node security --remove-report=report_id` + * Ensure to ping the Node.js TSC team for review of the PRs prior to the release date. + * Adding individuals with expertise in the report topic is also a viable option if + communicated properly with nodejs/security and TSC. * [ ] 3\. **Assigning Severity and Writing Team Summary:** * [ ] Assign a severity and write a team summary on HackerOne for the reports @@ -160,14 +163,10 @@ security announcements for more information. ## Post-Release -* [ ] 1\. **Merge the Next Security Release PR:** - * This involves moving the `vulnerabilities.json` file from - `security-release/next-security-release` to the `security-release/YYYY-MM-DD` - folder and merging the PR. - -* [ ] 2\. **Cleanup:** +* [ ] 1\. **Cleanup:** * [ ] `git node security --cleanup`. This command will: - * Close PRs and backports. + * Update next-security-release folder + * Close all PRs and backports labeled with `Security Release`. * Close HackerOne reports: * Close Resolved * Request Disclosure @@ -178,7 +177,7 @@ security announcements for more information. Then uncheck the Public Disclosure on HackerOne box at the bottom of the page. ![screenshot of HackerOne CVE form](https://github.com/nodejs/node/assets/26234614/e22e4f33-7948-4dd2-952e-2f9166f5568d) - * [ ] PR machine-readable JSON descriptions of the vulnerabilities to the [core](https://github.com/nodejs/security-wg/tree/HEAD/vuln/core) + * PR machine-readable JSON descriptions of the vulnerabilities to the [core](https://github.com/nodejs/security-wg/tree/HEAD/vuln/core) vulnerability DB. * [ ] Add yourself as a steward in the [Security Release Stewards](https://github.com/nodejs/node/blob/HEAD/doc/contributing/security-release-process.md#security-release-stewards) diff --git a/doc/contributing/strategic-initiatives.md b/doc/contributing/strategic-initiatives.md index cd4072f6d19..3b8bb4aafaf 100644 --- a/doc/contributing/strategic-initiatives.md +++ b/doc/contributing/strategic-initiatives.md @@ -18,7 +18,7 @@ agenda to ensure they are active and have the support they need. | Startup Snapshot | [Joyee Cheung][joyeecheung] | | | V8 Currency | [Michaël Zasso][targos] | | | Next-10 | [Michael Dawson][mhdawson] | | -| Single executable apps | | | +| Single executable apps | [Darshan Sen][RaisinTen] | | | Performance | | | | Primordials | [Benjamin Gruenbaum][benjamingr] | | @@ -43,6 +43,7 @@ agenda to ensure they are active and have the support they need. +[RaisinTen]: https://github.com/RaisinTen [aduh95]: https://github.com/aduh95 [benjamingr]: https://github.com/benjamingr [jasnell]: https://github.com/jasnell diff --git a/doc/contributing/writing-tests.md b/doc/contributing/writing-tests.md index 0a6af29bf04..8c67ed2c941 100644 --- a/doc/contributing/writing-tests.md +++ b/doc/contributing/writing-tests.md @@ -21,9 +21,22 @@ Add tests when: ## Test directory structure See [directory structure overview][] for outline of existing test and locations. -When deciding on whether to expand an existing test file or create a new one, -consider going through the files related to the subsystem. -For example, look for `test-streams` when writing a test for `lib/streams.js`. + +## How to write a good test + +A good test should be written in a style that is optimial for debugging +when it fails. + +In principle, when adding a new test, it should be placed in a new file. +Unless there is strong motivation to do so, refrain from appending +new test cases to an existing file. Similar to the reproductions we ask +for in the issue tracker, a good test should be as minimal and isolated as +possible to facilitate debugging. + +A good test should come with comments explaining what it tries to test, +so that when it fails, other contributors can fix it with the full context +of its intention, and be able to modify it in good confidence when the context +changes. ## Test structure diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 7c663920188..60deb453ee3 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -606,7 +606,7 @@ function matchHeader(self, state, field, value) { break; case 'content-length': state.contLen = true; - self._contentLength = value; + self._contentLength = +value; self._removedContLen = false; break; case 'date': diff --git a/lib/dns.js b/lib/dns.js index 18288b7d6f2..215dfd3d48c 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -55,6 +55,8 @@ const { getDefaultResultOrder, setDefaultResultOrder, errorCodes: dnsErrorCodes, + validDnsOrders, + validFamilies, } = require('internal/dns/utils'); const { Resolver, @@ -197,7 +199,6 @@ function onlookupall(err, addresses) { // Easy DNS A/AAAA look up // lookup(hostname, [options,] callback) -const validFamilies = [0, 4, 6]; function lookup(hostname, options, callback) { let hints = 0; let family = 0; @@ -251,7 +252,7 @@ function lookup(hostname, options, callback) { dnsOrder = options.verbatim ? 'verbatim' : 'ipv4first'; } if (options?.order != null) { - validateOneOf(options.order, 'options.order', ['ipv4first', 'ipv6first', 'verbatim']); + validateOneOf(options.order, 'options.order', validDnsOrders); dnsOrder = options.order; } } diff --git a/lib/internal/crypto/hash.js b/lib/internal/crypto/hash.js index fda2017fa0c..f5b89cd9ac3 100644 --- a/lib/internal/crypto/hash.js +++ b/lib/internal/crypto/hash.js @@ -3,6 +3,7 @@ const { ObjectSetPrototypeOf, ReflectApply, + StringPrototypeReplace, StringPrototypeToLowerCase, Symbol, } = primordials; @@ -33,6 +34,8 @@ const { lazyDOMException, normalizeEncoding, encodingsMap, + isPendingDeprecation, + getDeprecationWarningEmitter, } = require('internal/util'); const { @@ -63,6 +66,25 @@ const LazyTransform = require('internal/streams/lazy_transform'); const kState = Symbol('kState'); const kFinalized = Symbol('kFinalized'); +/** + * @param {string} name + */ +function normalizeAlgorithm(name) { + return StringPrototypeReplace(StringPrototypeToLowerCase(name), '-', ''); +} + +const maybeEmitDeprecationWarning = getDeprecationWarningEmitter( + 'DEP0198', + 'Creating SHAKE128/256 digests without an explicit options.outputLength is deprecated.', + undefined, + false, + (algorithm) => { + if (!isPendingDeprecation()) return false; + const normalized = normalizeAlgorithm(algorithm); + return normalized === 'shake128' || normalized === 'shake256'; + }, +); + function Hash(algorithm, options) { if (!new.target) return new Hash(algorithm, options); @@ -80,6 +102,9 @@ function Hash(algorithm, options) { this[kState] = { [kFinalized]: false, }; + if (!isCopy && xofLen === undefined) { + maybeEmitDeprecationWarning(algorithm); + } ReflectApply(LazyTransform, this, [options]); } @@ -213,6 +238,12 @@ function hash(algorithm, input, outputEncoding = 'hex') { } } } + // TODO: ideally we have to ship https://github.com/nodejs/node/pull/58121 so + // that a proper DEP0198 deprecation can be done here as well. + const normalizedAlgorithm = normalizeAlgorithm(algorithm); + if (normalizedAlgorithm === 'shake128' || normalizedAlgorithm === 'shake256') { + return new Hash(algorithm).update(input).digest(normalized); + } return oneShotDigest(algorithm, getCachedHashId(algorithm), getHashCache(), input, normalized, encodingsMap[normalized]); } diff --git a/lib/internal/debugger/inspect_repl.js b/lib/internal/debugger/inspect_repl.js index b4f454152dc..0c6e3470694 100644 --- a/lib/internal/debugger/inspect_repl.js +++ b/lib/internal/debugger/inspect_repl.js @@ -56,6 +56,7 @@ const { fileURLToPath } = require('internal/url'); const { customInspectSymbol, SideEffectFreeRegExpPrototypeSymbolReplace } = require('internal/util'); const { inspect: utilInspect } = require('internal/util/inspect'); +const { isObjectLiteral } = require('internal/repl/utils'); const debuglog = require('internal/util/debuglog').debuglog('inspect'); const SHORTCUTS = { @@ -573,8 +574,15 @@ function createRepl(inspector) { if (input === '\n') return lastCommand; // Add parentheses: exec process.title => exec("process.title"); const match = RegExpPrototypeExec(/^\s*(?:exec|p)\s+([^\n]*)/, input); + input = match ? match[1] : input; + + if (isObjectLiteral(input)) { + // Add parentheses to make sure `input` is parsed as an expression + input = `(${StringPrototypeTrim(input)})\n`; + } + if (match) { - lastCommand = `exec(${JSONStringify(match[1])})`; + lastCommand = `exec(${JSONStringify(input)})`; } else { lastCommand = input; } diff --git a/lib/internal/dns/promises.js b/lib/internal/dns/promises.js index b2804aa663c..73918410e67 100644 --- a/lib/internal/dns/promises.js +++ b/lib/internal/dns/promises.js @@ -25,6 +25,8 @@ const { getDefaultResultOrder, setDefaultResultOrder, setDefaultResolver, + validDnsOrders, + validFamilies, } = require('internal/dns/utils'); const { @@ -257,7 +259,6 @@ function createLookupPromise(family, hostname, all, hints, dnsOrder) { }); } -const validFamilies = [0, 4, 6]; /** * Get the IP address for a given hostname. * @param {string} hostname - The hostname to resolve (ex. 'nodejs.org'). @@ -305,7 +306,7 @@ function lookup(hostname, options) { dnsOrder = options.verbatim ? 'verbatim' : 'ipv4first'; } if (options?.order != null) { - validateOneOf(options.order, 'options.order', ['ipv4first', 'ipv6first', 'verbatim']); + validateOneOf(options.order, 'options.order', validDnsOrders); dnsOrder = options.order; } } diff --git a/lib/internal/dns/utils.js b/lib/internal/dns/utils.js index a79a5b846a6..b0ea4bf99ae 100644 --- a/lib/internal/dns/utils.js +++ b/lib/internal/dns/utils.js @@ -200,6 +200,8 @@ class ResolverBase { let defaultResolver; let dnsOrder; +const validDnsOrders = ['verbatim', 'ipv4first', 'ipv6first']; +const validFamilies = [0, 4, 6]; function initializeDns() { const orderFromCLI = getOptionValue('--dns-result-order'); @@ -207,7 +209,7 @@ function initializeDns() { dnsOrder ??= 'verbatim'; } else { // Allow the deserialized application to override order from CLI. - validateOneOf(orderFromCLI, '--dns-result-order', ['verbatim', 'ipv4first', 'ipv6first']); + validateOneOf(orderFromCLI, '--dns-result-order', validDnsOrders); dnsOrder = orderFromCLI; } @@ -279,7 +281,7 @@ function emitInvalidHostnameWarning(hostname) { } function setDefaultResultOrder(value) { - validateOneOf(value, 'dnsOrder', ['verbatim', 'ipv4first', 'ipv6first']); + validateOneOf(value, 'dnsOrder', validDnsOrders); dnsOrder = value; } @@ -353,4 +355,6 @@ module.exports = { errorCodes, createResolverClass, initializeDns, + validDnsOrders, + validFamilies, }; diff --git a/lib/internal/errors.js b/lib/internal/errors.js index efad1be9c34..8e52916a9c2 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -1715,9 +1715,18 @@ E('ERR_PARSE_ARGS_UNKNOWN_OPTION', (option, allowPositionals) => { E('ERR_PERFORMANCE_INVALID_TIMESTAMP', '%d is not a valid timestamp', TypeError); E('ERR_PERFORMANCE_MEASURE_INVALID_OPTIONS', '%s', TypeError); -E('ERR_REQUIRE_ASYNC_MODULE', 'require() cannot be used on an ESM ' + - 'graph with top-level await. Use import() instead. To see where the' + - ' top-level await comes from, use --experimental-print-required-tla.', Error); +E('ERR_REQUIRE_ASYNC_MODULE', function(filename, parentFilename) { + let message = 'require() cannot be used on an ESM ' + + 'graph with top-level await. Use import() instead. To see where the' + + ' top-level await comes from, use --experimental-print-required-tla.'; + if (parentFilename) { + message += `\n From ${parentFilename} `; + } + if (filename) { + message += `\n Requiring ${filename} `; + } + return message; +}, Error); E('ERR_REQUIRE_CYCLE_MODULE', '%s', Error); E('ERR_REQUIRE_ESM', function(filename, hasEsmSyntax, parentPath = null, packageJsonPath = null) { diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js index 124432afd43..a63d2d2b6a4 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -155,7 +155,7 @@ function lazyLoadFs() { function assertEncoding(encoding) { if (encoding && !Buffer.isEncoding(encoding)) { const reason = 'is invalid encoding'; - throw new ERR_INVALID_ARG_VALUE(encoding, 'encoding', reason); + throw new ERR_INVALID_ARG_VALUE('encoding', encoding, reason); } } diff --git a/lib/internal/heap_utils.js b/lib/internal/heap_utils.js index c39d811ab79..6d72fb1d628 100644 --- a/lib/internal/heap_utils.js +++ b/lib/internal/heap_utils.js @@ -53,11 +53,12 @@ class HeapSnapshotStream extends Readable { this[kHandle].readStart(); } - _destroy() { + _destroy(err, callback) { // Release the references on the handle so that // it can be garbage collected. this[kHandle][owner_symbol] = undefined; this[kHandle] = undefined; + callback(err); } [kUpdateTimer]() { diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 37a0c4c50b0..45c82605d55 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -101,6 +101,9 @@ const kIsMainSymbol = Symbol('kIsMainSymbol'); const kIsCachedByESMLoader = Symbol('kIsCachedByESMLoader'); const kRequiredModuleSymbol = Symbol('kRequiredModuleSymbol'); const kIsExecuting = Symbol('kIsExecuting'); + +const kFormat = Symbol('kFormat'); + // Set first due to cycle with ESM loader functions. module.exports = { kModuleSource, @@ -164,13 +167,13 @@ const policy = getLazy( ); const shouldReportRequiredModules = getLazy(() => process.env.WATCH_REPORT_DEPENDENCIES); -const permission = require('internal/process/permission'); const { vm_dynamic_import_default_internal, } = internalBinding('symbols'); const { codes: { + ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_VALUE, ERR_INVALID_MODULE_SPECIFIER, ERR_REQUIRE_CYCLE_MODULE, @@ -226,6 +229,9 @@ function internalRequire(module, id) { * @param {string} filename Absolute path to the file */ function stat(filename) { + // Guard against internal bugs where a non-string filename is passed in by mistake. + assert(typeof filename === 'string'); + filename = path.toNamespacedPath(filename); if (statCache !== null) { const result = statCache.get(filename); @@ -449,10 +455,6 @@ function initializeCJS() { // TODO(joyeecheung): deprecate this in favor of a proper hook? Module.runMain = require('internal/modules/run_main').executeUserEntryPoint; - - if (getOptionValue('--experimental-require-module')) { - Module._extensions['.mjs'] = loadESMFromCJS; - } } // Given a module name, and a list of paths to test, returns the first @@ -662,14 +664,7 @@ function resolveExports(nmPath, request) { // We don't cache this in case user extends the extensions. function getDefaultExtensions() { const extensions = ObjectKeys(Module._extensions); - if (!getOptionValue('--experimental-require-module')) { - return extensions; - } - // If the .mjs extension is added by --experimental-require-module, - // remove it from the supported default extensions to maintain - // compatibility. - // TODO(joyeecheung): allow both .mjs and .cjs? - return ArrayPrototypeFilter(extensions, (ext) => ext !== '.mjs' || Module._extensions['.mjs'] !== loadESMFromCJS); + return extensions; } /** @@ -718,11 +713,11 @@ Module._findPath = function(request, paths, isMain) { // For each path for (let i = 0; i < paths.length; i++) { // Don't search further if path doesn't exist - // or doesn't have permission to it const curPath = paths[i]; - if (insidePath && curPath && - ((permission.isEnabled() && !permission.has('fs.read', curPath)) || _stat(curPath) < 1) - ) { + if (typeof curPath !== 'string') { + throw new ERR_INVALID_ARG_TYPE('paths', 'array of strings', paths); + } + if (insidePath && curPath && _stat(curPath) < 1) { continue; } @@ -1281,10 +1276,6 @@ Module.prototype.load = function(filename) { this.paths = Module._nodeModulePaths(path.dirname(filename)); const extension = findLongestRegisteredExtension(filename); - // allow .mjs to be overridden - if (StringPrototypeEndsWith(filename, '.mjs') && !Module._extensions['.mjs']) { - throw new ERR_REQUIRE_ESM(filename, true); - } Module._extensions[extension](this, filename); this.loaded = true; @@ -1320,9 +1311,10 @@ let requireModuleWarningMode; * Resolve and evaluate it synchronously as ESM if it's ESM. * @param {Module} mod CJS module instance * @param {string} filename Absolute path of the file. + * @param {string} format Format of the module. If it had types, this would be what it is after type-stripping. + * @param {string} source Source the module. If it had types, this would have the type stripped. */ -function loadESMFromCJS(mod, filename) { - const source = getMaybeCachedSource(mod, filename); +function loadESMFromCJS(mod, filename, format, source) { const cascadedLoader = require('internal/modules/esm/loader').getOrInitializeCascadedLoader(); const isMain = mod[kIsMainSymbol]; if (isMain) { @@ -1498,7 +1490,9 @@ function wrapSafe(filename, content, cjsModuleInstance, format) { * `exports`) to the file. Returns exception, if any. * @param {string} content The source code of the module * @param {string} filename The file path of the module - * @param {'module'|'commonjs'|undefined} format Intended format of the module. + * @param { + * 'module'|'commonjs'|'commonjs-typescript'|'module-typescript' + * } format Intended format of the module. */ Module.prototype._compile = function(content, filename, format) { let moduleURL; @@ -1520,9 +1514,7 @@ Module.prototype._compile = function(content, filename, format) { } if (format === 'module') { - // Pass the source into the .mjs extension handler indirectly through the cache. - this[kModuleSource] = content; - loadESMFromCJS(this, filename); + loadESMFromCJS(this, filename, format, content); return; } @@ -1550,22 +1542,72 @@ Module.prototype._compile = function(content, filename, format) { /** * Get the source code of a module, using cached ones if it's cached. + * After this returns, mod[kFormat], mod[kModuleSource] and mod[kURL] will be set. * @param {Module} mod Module instance whose source is potentially already cached. * @param {string} filename Absolute path to the file of the module. - * @returns {string} + * @returns {{source: string, format?: string}} */ -function getMaybeCachedSource(mod, filename) { - // If already analyzed the source, then it will be cached. - let content; - if (mod[kModuleSource] !== undefined) { - content = mod[kModuleSource]; +function loadSource(mod, filename, formatFromNode) { + if (formatFromNode !== undefined) { + mod[kFormat] = formatFromNode; + } + const format = mod[kFormat]; + + let source = mod[kModuleSource]; + if (source !== undefined) { mod[kModuleSource] = undefined; } else { // TODO(joyeecheung): we can read a buffer instead to speed up // compilation. - content = fs.readFileSync(filename, 'utf8'); + source = fs.readFileSync(filename, 'utf8'); + } + return { source, format }; +} + +function reconstructErrorStack(err, parentPath, parentSource) { + const errLine = StringPrototypeSplit( + StringPrototypeSlice(err.stack, StringPrototypeIndexOf( + err.stack, ' at ')), '\n', 1)[0]; + const { 1: line, 2: col } = + RegExpPrototypeExec(/(\d+):(\d+)\)/, errLine) || []; + if (line && col) { + const srcLine = StringPrototypeSplit(parentSource, '\n')[line - 1]; + const frame = `${parentPath}:${line}\n${srcLine}\n${StringPrototypeRepeat(' ', col - 1)}^\n`; + setArrowMessage(err, frame); + } +} + +/** + * Generate the legacy ERR_REQUIRE_ESM for the cases where require(esm) is disabled. + * @param {Module} mod The module being required. + * @param {undefined|object} pkg Data of the nearest package.json of the module. + * @param {string} content Source code of the module. + * @param {string} filename Filename of the module + * @returns {Error} + */ +function getRequireESMError(mod, pkg, content, filename) { + // This is an error path because `require` of a `.js` file in a `"type": "module"` scope is not allowed. + const parent = mod[kModuleParent]; + const parentPath = parent?.filename; + const packageJsonPath = pkg?.path ? path.resolve(pkg.path, 'package.json') : null; + const usesEsm = containsModuleSyntax(content, filename); + const err = new ERR_REQUIRE_ESM(filename, usesEsm, parentPath, + packageJsonPath); + // Attempt to reconstruct the parent require frame. + const parentModule = Module._cache[parentPath]; + if (parentModule) { + let parentSource; + try { + ({ source: parentSource } = loadSource(parentModule, parentPath)); + } catch { + // Continue regardless of error. + } + if (parentSource) { + // TODO(joyeecheung): trim off internal frames from the stack. + reconstructErrorStack(err, parentPath, parentSource); + } } - return content; + return err; } /** @@ -1574,57 +1616,25 @@ function getMaybeCachedSource(mod, filename) { * @param {string} filename The file path of the module */ Module._extensions['.js'] = function(module, filename) { - // If already analyzed the source, then it will be cached. - const content = getMaybeCachedSource(module, filename); - - let format; - if (StringPrototypeEndsWith(filename, '.js')) { - const pkg = packageJsonReader.readPackageScope(filename) || { __proto__: null }; - // Function require shouldn't be used in ES modules. - if (pkg.data?.type === 'module') { - if (getOptionValue('--experimental-require-module')) { - module._compile(content, filename, 'module'); - return; - } - - // This is an error path because `require` of a `.js` file in a `"type": "module"` scope is not allowed. - const parent = module[kModuleParent]; - const parentPath = parent?.filename; - const packageJsonPath = path.resolve(pkg.path, 'package.json'); - const usesEsm = containsModuleSyntax(content, filename); - const err = new ERR_REQUIRE_ESM(filename, usesEsm, parentPath, - packageJsonPath); - // Attempt to reconstruct the parent require frame. - if (Module._cache[parentPath]) { - let parentSource; - try { - parentSource = fs.readFileSync(parentPath, 'utf8'); - } catch { - // Continue regardless of error. - } - if (parentSource) { - const errLine = StringPrototypeSplit( - StringPrototypeSlice(err.stack, StringPrototypeIndexOf( - err.stack, ' at ')), '\n', 1)[0]; - const { 1: line, 2: col } = - RegExpPrototypeExec(/(\d+):(\d+)\)/, errLine) || []; - if (line && col) { - const srcLine = StringPrototypeSplit(parentSource, '\n')[line - 1]; - const frame = `${parentPath}:${line}\n${srcLine}\n${ - StringPrototypeRepeat(' ', col - 1)}^\n`; - setArrowMessage(err, frame); - } - } - } - throw err; - } else if (pkg.data?.type === 'commonjs') { - format = 'commonjs'; - } - } else if (StringPrototypeEndsWith(filename, '.cjs')) { + let format, pkg; + if (StringPrototypeEndsWith(filename, '.cjs')) { format = 'commonjs'; + } else if (StringPrototypeEndsWith(filename, '.mjs')) { + format = 'module'; + } else if (StringPrototypeEndsWith(filename, '.js')) { + pkg = packageJsonReader.readPackageScope(filename) || { __proto__: null }; + const typeFromPjson = pkg.data?.type; + if (typeFromPjson === 'module' || typeFromPjson === 'commonjs' || !typeFromPjson) { + format = typeFromPjson; + } } - - module._compile(content, filename, format); + const { source, format: loadedFormat } = loadSource(module, filename, format); + // Function require shouldn't be used in ES modules when require(esm) is disabled. + if (loadedFormat === 'module' && !getOptionValue('--experimental-require-module')) { + const err = getRequireESMError(module, pkg, source, filename); + throw err; + } + module._compile(source, filename, loadedFormat); }; /** diff --git a/lib/internal/modules/esm/loader.js b/lib/internal/modules/esm/loader.js index d9b2c75dd97..e85f4b3acc3 100644 --- a/lib/internal/modules/esm/loader.js +++ b/lib/internal/modules/esm/loader.js @@ -36,12 +36,23 @@ const { getDefaultConditions, } = require('internal/modules/esm/utils'); const { kImplicitAssertType } = require('internal/modules/esm/assert'); -const { ModuleWrap, kEvaluating, kEvaluated } = internalBinding('module_wrap'); +const { + ModuleWrap, + kEvaluated, + kEvaluating, + kInstantiated, + kErrored, + throwIfPromiseRejected, +} = internalBinding('module_wrap'); const { urlToFilename, } = require('internal/modules/helpers'); let defaultResolve, defaultLoad, defaultLoadSync, importMetaInitializer; +let debug = require('internal/util/debuglog').debuglog('esm', (fn) => { + debug = fn; +}); + /** * @typedef {import('./hooks.js').HooksProxy} HooksProxy * @typedef {import('./module_job.js').ModuleJobBase} ModuleJobBase @@ -75,6 +86,23 @@ function getTranslators() { return translators; } +/** + * Generate message about potential race condition caused by requiring a cached module that has started + * async linking. + * @param {string} filename Filename of the module being required. + * @param {string|undefined} parentFilename Filename of the module calling require(). + * @returns {string} Error message. + */ +function getRaceMessage(filename, parentFilename) { + let raceMessage = `Cannot require() ES Module ${filename} because it is not yet fully loaded. `; + raceMessage += 'This may be caused by a race condition if the module is simultaneously dynamically '; + raceMessage += 'import()-ed via Promise.all(). Try await-ing the import() sequentially in a loop instead.'; + if (parentFilename) { + raceMessage += ` (from ${parentFilename})`; + } + return raceMessage; +} + /** * @type {HooksProxy} * Multiple loader instances exist for various, specific reasons (see code comments at site). @@ -295,20 +323,58 @@ class ModuleLoader { // TODO(joyeecheung): ensure that imported synchronous graphs are evaluated // synchronously so that any previously imported synchronous graph is already // evaluated at this point. + // TODO(joyeecheung): add something similar to CJS loader's requireStack to help + // debugging the the problematic links in the graph for import. + debug('importSyncForRequire', parent?.filename, '->', filename, job); if (job !== undefined) { mod[kRequiredModuleSymbol] = job.module; + const parentFilename = urlToFilename(parent?.filename); + // TODO(node:55782): this race may stop to happen when the ESM resolution and loading become synchronous. + if (!job.module) { + assert.fail(getRaceMessage(filename, parentFilename)); + } if (job.module.async) { - throw new ERR_REQUIRE_ASYNC_MODULE(); + throw new ERR_REQUIRE_ASYNC_MODULE(filename, parentFilename); } - if (job.module.getStatus() !== kEvaluated) { - const parentFilename = urlToFilename(parent?.filename); - let message = `Cannot require() ES Module ${filename} in a cycle.`; - if (parentFilename) { - message += ` (from ${parentFilename})`; - } - throw new ERR_REQUIRE_CYCLE_MODULE(message); + const status = job.module.getStatus(); + debug('Module status', job, status); + if (status === kEvaluated) { + return { wrap: job.module, namespace: job.module.getNamespaceSync(filename, parentFilename) }; + } else if (status === kInstantiated) { + // When it's an async job cached by another import request, + // which has finished linking but has not started its + // evaluation because the async run() task would be later + // in line. Then start the evaluation now with runSync(), which + // is guaranteed to finish by the time the other run() get to it, + // and the other task would just get the cached evaluation results, + // similar to what would happen when both are async. + mod[kRequiredModuleSymbol] = job.module; + const { namespace } = job.runSync(parent); + return { wrap: job.module, namespace: namespace || job.module.getNamespace() }; + } else if (status === kErrored) { + // If the module was previously imported and errored, throw the error. + throw job.module.getError(); + } + // When the cached async job have already encountered a linking + // error that gets wrapped into a rejection, but is still later + // in line to throw on it, just unwrap and throw the linking error + // from require(). + if (job.instantiated) { + throwIfPromiseRejected(job.instantiated); } - return { wrap: job.module, namespace: job.module.getNamespaceSync() }; + if (status !== kEvaluating) { + assert.fail(`Unexpected module status ${status}. ` + + getRaceMessage(filename, parentFilename)); + } + let message = `Cannot require() ES Module ${filename} in a cycle.`; + if (parentFilename) { + message += ` (from ${parentFilename})`; + } + message += ' A cycle involving require(esm) is not allowed to maintain '; + message += 'invariants mandated by the ECMAScript specification. '; + message += 'Try making at least part of the dependency in the graph lazily loaded.'; + throw new ERR_REQUIRE_CYCLE_MODULE(message); + } // TODO(joyeecheung): refactor this so that we pre-parse in C++ and hit the // cache here, or use a carrier object to carry the compiled module script @@ -320,7 +386,7 @@ class ModuleLoader { job = new ModuleJobSync(this, url, kEmptyObject, wrap, isMain, inspectBrk); this.loadCache.set(url, kImplicitAssertType, job); mod[kRequiredModuleSymbol] = job.module; - return { wrap: job.module, namespace: job.runSync().namespace }; + return { wrap: job.module, namespace: job.runSync(parent).namespace }; } /** diff --git a/lib/internal/modules/esm/module_job.js b/lib/internal/modules/esm/module_job.js index 0c8f031080a..3b68647e455 100644 --- a/lib/internal/modules/esm/module_job.js +++ b/lib/internal/modules/esm/module_job.js @@ -21,8 +21,14 @@ let debug = require('internal/util/debuglog').debuglog('esm', (fn) => { debug = fn; }); -const { ModuleWrap, kInstantiated } = internalBinding('module_wrap'); - +const { + ModuleWrap, + kErrored, + kEvaluated, + kEvaluating, + kInstantiated, + kUninstantiated, +} = internalBinding('module_wrap'); const { decorateErrorStack, kEmptyObject } = require('internal/util'); const { getSourceMapsEnabled, @@ -31,6 +37,7 @@ const assert = require('internal/assert'); const resolvedPromise = PromiseResolve(); const { setHasStartedUserESMExecution, + urlToFilename, } = require('internal/modules/helpers'); const { getOptionValue } = require('internal/options'); const noop = FunctionPrototype; @@ -52,6 +59,37 @@ const isCommonJSGlobalLikeNotDefinedError = (errorMessage) => (globalLike) => errorMessage === `${globalLike} is not defined`, ); + +/** + * + * @param {Error} e + * @param {string} url + * @returns {void} + */ +const explainCommonJSGlobalLikeNotDefinedError = (e, url) => { + if (e?.name === 'ReferenceError' && + isCommonJSGlobalLikeNotDefinedError(e.message)) { + e.message += ' in ES module scope'; + + if (StringPrototypeStartsWith(e.message, 'require ')) { + e.message += ', you can use import instead'; + } + + const packageConfig = + StringPrototypeStartsWith(url, 'file://') && + RegExpPrototypeExec(/\.js(\?[^#]*)?(#.*)?$/, url) !== null && + require('internal/modules/esm/resolve') + .getPackageScopeConfig(url); + if (packageConfig.type === 'module') { + e.message += + '\nThis file is being treated as an ES module because it has a ' + + `'.js' file extension and '${packageConfig.pjsonPath}' contains ` + + '"type": "module". To treat it as a CommonJS script, rename it ' + + 'to use the \'.cjs\' file extension.'; + } + } +}; + class ModuleJobBase { constructor(url, importAttributes, isMain, inspectBrk) { this.importAttributes = importAttributes; @@ -239,22 +277,46 @@ class ModuleJob extends ModuleJobBase { } } - runSync() { + runSync(parent) { assert(this.module instanceof ModuleWrap); - if (this.instantiated !== undefined) { - return { __proto__: null, module: this.module }; + let status = this.module.getStatus(); + + debug('ModuleJob.runSync()', status, this.module); + // FIXME(joyeecheung): this cannot fully handle < kInstantiated. Make the linking + // fully synchronous instead. + if (status === kUninstantiated) { + this.module.async = this.module.instantiateSync(); + status = this.module.getStatus(); } + if (status === kInstantiated || status === kErrored) { + const filename = urlToFilename(this.url); + const parentFilename = urlToFilename(parent?.filename); + this.module.async ??= this.module.isGraphAsync(); - this.module.instantiate(); - this.instantiated = PromiseResolve(); - const timeout = -1; - const breakOnSigint = false; - setHasStartedUserESMExecution(); - this.module.evaluate(timeout, breakOnSigint); - return { __proto__: null, module: this.module }; + if (this.module.async && !getOptionValue('--experimental-print-required-tla')) { + throw new ERR_REQUIRE_ASYNC_MODULE(filename, parentFilename); + } + if (status === kInstantiated) { + setHasStartedUserESMExecution(); + const namespace = this.module.evaluateSync(filename, parentFilename); + return { __proto__: null, module: this.module, namespace }; + } + throw this.module.getError(); + } else if (status === kEvaluating || status === kEvaluated) { + // kEvaluating can show up when this is being used to deal with CJS <-> CJS cycles. + // Allow it for now, since we only need to ban ESM <-> CJS cycles which would be + // detected earlier during the linking phase, though the CJS handling in the ESM + // loader won't be able to emit warnings on pending circular exports like what + // the CJS loader does. + // TODO(joyeecheung): remove the re-invented require() in the ESM loader and + // always handle CJS using the CJS loader to eliminate the quirks. + return { __proto__: null, module: this.module, namespace: this.module.getNamespaceSync() }; + } + assert.fail(`Unexpected module status ${status}.`); } async run() { + debug('ModuleJob.run()', this.module); await this.instantiate(); const timeout = -1; const breakOnSigint = false; @@ -262,27 +324,7 @@ class ModuleJob extends ModuleJobBase { try { await this.module.evaluate(timeout, breakOnSigint); } catch (e) { - if (e?.name === 'ReferenceError' && - isCommonJSGlobalLikeNotDefinedError(e.message)) { - e.message += ' in ES module scope'; - - if (StringPrototypeStartsWith(e.message, 'require ')) { - e.message += ', you can use import instead'; - } - - const packageConfig = - StringPrototypeStartsWith(this.module.url, 'file://') && - RegExpPrototypeExec(/\.js(\?[^#]*)?(#.*)?$/, this.module.url) !== null && - require('internal/modules/esm/resolve') - .getPackageScopeConfig(this.module.url); - if (packageConfig.type === 'module') { - e.message += - '\nThis file is being treated as an ES module because it has a ' + - `'.js' file extension and '${packageConfig.pjsonPath}' contains ` + - '"type": "module". To treat it as a CommonJS script, rename it ' + - 'to use the \'.cjs\' file extension.'; - } - } + explainCommonJSGlobalLikeNotDefinedError(e, this.module.url); throw e; } return { __proto__: null, module: this.module }; @@ -351,7 +393,11 @@ class ModuleJobSync extends ModuleJobBase { async run() { // This path is hit by a require'd module that is imported again. const status = this.module.getStatus(); - if (status > kInstantiated) { + debug('ModuleJobSync.run()', status, this.module); + // If the module was previously required and errored, reject from import() again. + if (status === kErrored) { + throw this.module.getError(); + } else if (status > kInstantiated) { if (this.evaluationPromise) { await this.evaluationPromise; } @@ -371,7 +417,8 @@ class ModuleJobSync extends ModuleJobBase { `Status = ${status}`); } - runSync() { + runSync(parent) { + debug('ModuleJobSync.runSync()', this.module); // TODO(joyeecheung): add the error decoration logic from the async instantiate. this.module.async = this.module.instantiateSync(); // If --experimental-print-required-tla is true, proceeds to evaluation even @@ -380,12 +427,19 @@ class ModuleJobSync extends ModuleJobBase { // TODO(joyeecheung): track the asynchroniticy using v8::Module::HasTopLevelAwait() // and we'll be able to throw right after compilation of the modules, using acron // to find and print the TLA. + const parentFilename = urlToFilename(parent?.filename); + const filename = urlToFilename(this.url); if (this.module.async && !getOptionValue('--experimental-print-required-tla')) { - throw new ERR_REQUIRE_ASYNC_MODULE(); + throw new ERR_REQUIRE_ASYNC_MODULE(filename, parentFilename); } setHasStartedUserESMExecution(); - const namespace = this.module.evaluateSync(); - return { __proto__: null, module: this.module, namespace }; + try { + const namespace = this.module.evaluateSync(filename, parentFilename); + return { __proto__: null, module: this.module, namespace }; + } catch (e) { + explainCommonJSGlobalLikeNotDefinedError(e, this.module.url); + throw e; + } } } diff --git a/lib/internal/readline/interface.js b/lib/internal/readline/interface.js index e1381b5341a..05ff898bfce 100644 --- a/lib/internal/readline/interface.js +++ b/lib/internal/readline/interface.js @@ -32,12 +32,14 @@ const { SafeStringIterator, } = primordials; -const { codes } = require('internal/errors'); - const { - ERR_INVALID_ARG_VALUE, - ERR_USE_AFTER_CLOSE, -} = codes; + AbortError, + codes: { + ERR_INVALID_ARG_VALUE, + ERR_USE_AFTER_CLOSE, + }, +} = require('internal/errors'); + const { validateAbortSignal, validateArray, @@ -111,6 +113,7 @@ const kPrompt = Symbol('_prompt'); const kPushToKillRing = Symbol('_pushToKillRing'); const kPushToUndoStack = Symbol('_pushToUndoStack'); const kQuestionCallback = Symbol('_questionCallback'); +const kQuestionReject = Symbol('_questionReject'); const kRedo = Symbol('_redo'); const kRedoStack = Symbol('_redoStack'); const kRefreshLine = Symbol('_refreshLine'); @@ -1126,6 +1129,7 @@ class Interface extends InterfaceConstructor { } else { // This readline instance is finished this.close(); + this[kQuestionReject]?.(new AbortError('Aborted with Ctrl+C')); } break; @@ -1137,6 +1141,7 @@ class Interface extends InterfaceConstructor { if (this.cursor === 0 && this.line.length === 0) { // This readline instance is finished this.close(); + this[kQuestionReject]?.(new AbortError('Aborted with Ctrl+D')); } else if (this.cursor < this.line.length) { this[kDeleteRight](); } @@ -1392,6 +1397,7 @@ module.exports = { kQuestion, kQuestionCallback, kQuestionCancel, + kQuestionReject, kRefreshLine, kSawKeyPress, kSawReturnAt, diff --git a/lib/internal/repl/utils.js b/lib/internal/repl/utils.js index 126f8ae85d0..79a2c55dff1 100644 --- a/lib/internal/repl/utils.js +++ b/lib/internal/repl/utils.js @@ -739,6 +739,22 @@ function setupReverseSearch(repl) { return { reverseSearch }; } +const startsWithBraceRegExp = /^\s*{/; +const endsWithSemicolonRegExp = /;\s*$/; + +/** + * Checks if some provided code represents an object literal. + * This is helpful to prevent confusing repl code evaluations where + * strings such as `{ a : 1 }` would get interpreted as block statements + * rather than object literals. + * @param {string} code the code to check + * @returns {boolean} true if the code represents an object literal, false otherwise + */ +function isObjectLiteral(code) { + return RegExpPrototypeExec(startsWithBraceRegExp, code) !== null && + RegExpPrototypeExec(endsWithSemicolonRegExp, code) === null; +} + module.exports = { REPL_MODE_SLOPPY: Symbol('repl-sloppy'), REPL_MODE_STRICT, @@ -746,4 +762,5 @@ module.exports = { kStandaloneREPL: Symbol('kStandaloneREPL'), setupPreview, setupReverseSearch, + isObjectLiteral, }; diff --git a/lib/internal/source_map/prepare_stack_trace.js b/lib/internal/source_map/prepare_stack_trace.js index f06ea6380ce..ad065c6cac2 100644 --- a/lib/internal/source_map/prepare_stack_trace.js +++ b/lib/internal/source_map/prepare_stack_trace.js @@ -53,9 +53,15 @@ function prepareStackTraceWithSourceMaps(error, trace) { const sm = fileName === lastFileName ? lastSourceMap : findSourceMap(fileName); - lastSourceMap = sm; - lastFileName = fileName; + // Only when a source map is found, cache it for the next iteration. + // This is a performance optimization to avoid interleaving with JS builtin function + // invalidating the cache. + // - at myFunc (file:///path/to/file.js:1:2) + // - at Array.map () + // - at myFunc (file:///path/to/file.js:3:4) if (sm) { + lastSourceMap = sm; + lastFileName = fileName; return `${kStackLineAt}${serializeJSStackFrame(sm, callSite, trace[i + 1])}`; } } catch (err) { diff --git a/lib/internal/source_map/source_map_cache.js b/lib/internal/source_map/source_map_cache.js index 9defc32da8e..c50a44464a2 100644 --- a/lib/internal/source_map/source_map_cache.js +++ b/lib/internal/source_map/source_map_cache.js @@ -157,6 +157,9 @@ function maybeCacheSourceMap(filename, content, moduleInstance, isGeneratedSourc } const data = dataFromUrl(filename, sourceMapURL); + // `data` could be null if the source map is invalid. + // In this case, create a cache entry with null data with source url for test coverage. + const entry = { __proto__: null, lineLengths: lineLengths(content), @@ -279,6 +282,8 @@ function sourceMapFromDataUrl(sourceURL, url) { const parsedData = JSONParse(decodedData); return sourcesToAbsolute(sourceURL, parsedData); } catch (err) { + // TODO(legendecas): warn about invalid source map JSON string. + // But it could be verbose. debug(err); return null; } @@ -333,26 +338,38 @@ function sourceMapCacheToObject() { /** * Find a source map for a given actual source URL or path. + * + * This function may be invoked from user code or test runner, this must not throw + * any exceptions. * @param {string} sourceURL - actual source URL or path * @returns {import('internal/source_map/source_map').SourceMap | undefined} a source map or undefined if not found */ function findSourceMap(sourceURL) { - if (RegExpPrototypeExec(kLeadingProtocol, sourceURL) === null) { - sourceURL = pathToFileURL(sourceURL).href; - } - if (!SourceMap) { - SourceMap = require('internal/source_map/source_map').SourceMap; - } - const entry = getModuleSourceMapCache().get(sourceURL) ?? generatedSourceMapCache.get(sourceURL); - if (entry === undefined) { + if (typeof sourceURL !== 'string') { return undefined; } - let sourceMap = entry.sourceMap; - if (sourceMap === undefined) { - sourceMap = new SourceMap(entry.data, { lineLengths: entry.lineLengths }); - entry.sourceMap = sourceMap; + + SourceMap ??= require('internal/source_map/source_map').SourceMap; + try { + if (RegExpPrototypeExec(kLeadingProtocol, sourceURL) === null) { + // If the sourceURL is an invalid path, this will throw an error. + sourceURL = pathToFileURL(sourceURL).href; + } + const entry = getModuleSourceMapCache().get(sourceURL) ?? generatedSourceMapCache.get(sourceURL); + if (entry?.data == null) { + return undefined; + } + + let sourceMap = entry.sourceMap; + if (sourceMap === undefined) { + sourceMap = new SourceMap(entry.data, { lineLengths: entry.lineLengths }); + entry.sourceMap = sourceMap; + } + return sourceMap; + } catch (err) { + debug(err); + return undefined; } - return sourceMap; } module.exports = { diff --git a/lib/internal/util.js b/lib/internal/util.js index 0c34a5ea4e5..bcc8bdd58da 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -104,8 +104,8 @@ function getDeprecationWarningEmitter( shouldEmitWarning = () => true, ) { let warned = false; - return function() { - if (!warned && shouldEmitWarning()) { + return function(arg) { + if (!warned && shouldEmitWarning(arg)) { warned = true; if (code !== undefined) { if (!codesWarned.has(code)) { @@ -994,4 +994,6 @@ module.exports = { setOwnProperty, pendingDeprecate, WeakReference, + isPendingDeprecation, + getDeprecationWarningEmitter, }; diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 873e9d5f561..ecf5622fcb3 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -2125,27 +2125,32 @@ function hasBuiltInToString(value) { value = proxyTarget; } - // Check if value has a custom Symbol.toPrimitive transformation. - if (typeof value[SymbolToPrimitive] === 'function') { - return false; - } + let hasOwnToString = ObjectPrototypeHasOwnProperty; + let hasOwnToPrimitive = ObjectPrototypeHasOwnProperty; - // Count objects that have no `toString` function as built-in. + // Count objects without `toString` and `Symbol.toPrimitive` function as built-in. if (typeof value.toString !== 'function') { - return true; - } - - // The object has a own `toString` property. Thus it's not not a built-in one. - if (ObjectPrototypeHasOwnProperty(value, 'toString')) { + if (typeof value[SymbolToPrimitive] !== 'function') { + return true; + } else if (ObjectPrototypeHasOwnProperty(value, SymbolToPrimitive)) { + return false; + } + hasOwnToString = returnFalse; + } else if (ObjectPrototypeHasOwnProperty(value, 'toString')) { + return false; + } else if (typeof value[SymbolToPrimitive] !== 'function') { + hasOwnToPrimitive = returnFalse; + } else if (ObjectPrototypeHasOwnProperty(value, SymbolToPrimitive)) { return false; } - // Find the object that has the `toString` property as own property in the - // prototype chain. + // Find the object that has the `toString` property or `Symbol.toPrimitive` property + // as own property in the prototype chain. let pointer = value; do { pointer = ObjectGetPrototypeOf(pointer); - } while (!ObjectPrototypeHasOwnProperty(pointer, 'toString')); + } while (!hasOwnToString(pointer, 'toString') && + !hasOwnToPrimitive(pointer, SymbolToPrimitive)); // Check closer if the object is a built-in. const descriptor = ObjectGetOwnPropertyDescriptor(pointer, 'constructor'); @@ -2154,6 +2159,10 @@ function hasBuiltInToString(value) { builtInObjects.has(descriptor.value.name); } +function returnFalse() { + return false; +} + const firstErrorLine = (error) => StringPrototypeSplit(error.message, '\n', 1)[0]; let CIRCULAR_ERROR_MESSAGE; function tryStringify(arg) { diff --git a/lib/readline/promises.js b/lib/readline/promises.js index 286222bfab9..dfac30ea821 100644 --- a/lib/readline/promises.js +++ b/lib/readline/promises.js @@ -12,6 +12,7 @@ const { Interface: _Interface, kQuestion, kQuestionCancel, + kQuestionReject, } = require('internal/readline/interface'); const { @@ -54,6 +55,8 @@ class Interface extends _Interface { }; } + this[kQuestionReject] = reject; + this[kQuestion](query, cb); }); } diff --git a/lib/repl.js b/lib/repl.js index abd7ca512e6..87f54b28fe0 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -171,6 +171,7 @@ const { kStandaloneREPL, setupPreview, setupReverseSearch, + isObjectLiteral, } = require('internal/repl/utils'); const { constants: { @@ -441,13 +442,8 @@ function REPLServer(prompt, let awaitPromise = false; const input = code; - // It's confusing for `{ a : 1 }` to be interpreted as a block - // statement rather than an object literal. So, we first try - // to wrap it in parentheses, so that it will be interpreted as - // an expression. Note that if the above condition changes, - // lib/internal/repl/utils.js needs to be changed to match. - if (RegExpPrototypeExec(/^\s*{/, code) !== null && - RegExpPrototypeExec(/;\s*$/, code) === null) { + if (isObjectLiteral(code)) { + // Add parentheses to make sure `code` is parsed as an expression code = `(${StringPrototypeTrim(code)})\n`; wrappedCmd = true; } @@ -1213,7 +1209,7 @@ const importRE = /\bimport\s*\(\s*['"`](([\w@./:-]+\/)?(?:[\w@./:-]*))(?![^'"`]) const requireRE = /\brequire\s*\(\s*['"`](([\w@./:-]+\/)?(?:[\w@./:-]*))(?![^'"`])$/; const fsAutoCompleteRE = /fs(?:\.promises)?\.\s*[a-z][a-zA-Z]+\(\s*["'](.*)/; const simpleExpressionRE = - /(?:[\w$'"`[{(](?:\w|\$|['"`\]})])*\??\.)*[a-zA-Z_$](?:\w|\$)*\??\.?$/; + /(?:[\w$'"`[{(](?:(\w| |\t)*?['"`]|\$|['"`\]})])*\??(?:\.|])?)*?(?:[a-zA-Z_$])?(?:\w|\$)*\??\.?$/; const versionedFileNamesRe = /-\d+\.\d+/; function isIdentifier(str) { @@ -1344,7 +1340,7 @@ function complete(line, callback) { filter = completeOn; if (this.allowBlockingCompletions) { const subdir = match[2] || ''; - const extensions = ObjectKeys(this.context.require.extensions); + const extensions = ObjectKeys(CJSModule._extensions); const indexes = ArrayPrototypeMap(extensions, (extension) => `index${extension}`); ArrayPrototypePush(indexes, 'package.json', 'index'); diff --git a/lib/zlib.js b/lib/zlib.js index 2fc3b88d72c..09986a16d51 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -315,7 +315,7 @@ ZlibBase.prototype._final = function(callback) { // This is currently only used to figure out which flush flag to use for the // last chunk. // Roughly, the following holds: -// Z_NO_FLUSH (< Z_TREES) < Z_BLOCK < Z_PARTIAL_FLUSH < +// Z_NO_FLUSH < Z_BLOCK < Z_PARTIAL_FLUSH < // Z_SYNC_FLUSH < Z_FULL_FLUSH < Z_FINISH const flushiness = []; const kFlushFlagList = [Z_NO_FLUSH, Z_BLOCK, Z_PARTIAL_FLUSH, diff --git a/src/README.md b/src/README.md index 565ac0df5ce..036bd13f5b3 100644 --- a/src/README.md +++ b/src/README.md @@ -589,6 +589,68 @@ void InitializeHttpParser(Local target, } ``` +### Argument validation in public APIs vs. internal code + +#### Public API argument sanitization + +When arguments come directly from user code, Node.js will typically validate them at the +JavaScript layer and throws user-friendly +[errors](https://github.com/nodejs/node/blob/main/doc/contributing/using-internal-errors.md) +(e.g., `ERR_INVALID_*`), if they are invalid. This helps end users +quickly understand and fix mistakes in their own code. + +This approach ensures that the error message pinpoints which argument is wrong +and how it should be fixed. Additionally, problems in user code do not cause +mysterious crashes or hard-to-diagnose failures deeper in the engine. + +Example from `zlib.js`: + +```js +function crc32(data, value = 0) { + if (typeof data !== 'string' && !isArrayBufferView(data)) { + throw new ERR_INVALID_ARG_TYPE('data', ['Buffer', 'TypedArray', 'DataView','string'], data); + } + validateUint32(value, 'value'); + return crc32Native(data, value); +} +``` + +The corresponding C++ assertion code for the above example from it's binding `node_zlib.cc`: + +```cpp +CHECK(args[0]->IsArrayBufferView() || args[0]->IsString()); +CHECK(args[1]->IsUint32()); +``` + +#### Internal code and C++ binding checks + +Inside Node.js’s internal layers, especially the C++ [binding function][]s +typically assume their arguments have already been checked and sanitized +by the upper-level (JavaScript) callers. As a result, internal C++ code +often just uses `CHECK()` or similar assertions to confirm that the +types/values passed in are correct. If that assertion fails, Node.js will +crash or abort with an internal diagnostic message. This is to avoid +re-validating every internal function argument repeatedly which can slow +down the system. + +However, in a less common case where the API is implemented completely in +C++, the arguments would be validated directly in C++, with the errors +thrown using `THROW_ERR_INVALID_*` macros from `src/node_errors.h`. + +For example in `worker_threads.moveMessagePortToContext`: + +```cpp +void MessagePort::MoveToContext(const FunctionCallbackInfo& args) { + Environment* env = Environment::GetCurrent(args); + if (!args[0]->IsObject() || + !env->message_port_constructor_template()->HasInstance(args[0])) { + return THROW_ERR_INVALID_ARG_TYPE(env, + "The \"port\" argument must be a MessagePort instance"); + } + // ... +} +``` + ### Exception handling diff --git a/src/acorn_version.h b/src/acorn_version.h index b4e18696f8b..a8af314b687 100644 --- a/src/acorn_version.h +++ b/src/acorn_version.h @@ -2,5 +2,5 @@ // Refer to tools/dep_updaters/update-acorn.sh #ifndef SRC_ACORN_VERSION_H_ #define SRC_ACORN_VERSION_H_ -#define ACORN_VERSION "8.14.0" +#define ACORN_VERSION "8.15.0" #endif // SRC_ACORN_VERSION_H_ diff --git a/src/api/environment.cc b/src/api/environment.cc index 7f7eb695c0e..18c8bcd6e92 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -530,8 +530,11 @@ MaybeLocal LoadEnvironment(Environment* env, return LoadEnvironment( env, [&](const StartExecutionCallbackInfo& info) -> MaybeLocal { - Local main_script = - ToV8Value(env->context(), main_script_source_utf8).ToLocalChecked(); + Local main_script; + if (!ToV8Value(env->context(), main_script_source_utf8) + .ToLocal(&main_script)) { + return {}; + } return info.run_cjs->Call( env->context(), Null(env->isolate()), 1, &main_script); }, diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index cc19df09f17..2388c60486e 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -724,9 +724,9 @@ void ChannelWrap::Setup() { } /* We do the call to ares_init_option for caller. */ - const int optmask = - ARES_OPT_FLAGS | ARES_OPT_TIMEOUTMS | - ARES_OPT_SOCK_STATE_CB | ARES_OPT_TRIES; + const int optmask = ARES_OPT_FLAGS | ARES_OPT_TIMEOUTMS | + ARES_OPT_SOCK_STATE_CB | ARES_OPT_TRIES | + ARES_OPT_QUERY_CACHE; r = ares_init_options(&channel_, &options, optmask); if (r != ARES_SUCCESS) { @@ -1319,6 +1319,8 @@ int SoaTraits::Parse( if (status != ARES_SUCCESS) return status; + auto cleanup = OnScopeLeave([&]() { ares_free_data(soa_out); }); + Local soa_record = Object::New(env->isolate()); soa_record->Set(env->context(), @@ -1345,8 +1347,6 @@ int SoaTraits::Parse( Integer::NewFromUnsigned( env->isolate(), soa_out->minttl)).Check(); - ares_free_data(soa_out); - wrap->CallOnComplete(soa_record); return ARES_SUCCESS; } diff --git a/src/cjs_module_lexer_version.h b/src/cjs_module_lexer_version.h index 72a66ba9e90..8d754aadde0 100644 --- a/src/cjs_module_lexer_version.h +++ b/src/cjs_module_lexer_version.h @@ -2,5 +2,5 @@ // Refer to tools/dep_updaters/update-cjs-module-lexer.sh #ifndef SRC_CJS_MODULE_LEXER_VERSION_H_ #define SRC_CJS_MODULE_LEXER_VERSION_H_ -#define CJS_MODULE_LEXER_VERSION "1.4.1" +#define CJS_MODULE_LEXER_VERSION "2.1.0" #endif // SRC_CJS_MODULE_LEXER_VERSION_H_ diff --git a/src/crypto/crypto_hash.cc b/src/crypto/crypto_hash.cc index da301e43315..aa02ff76326 100644 --- a/src/crypto/crypto_hash.cc +++ b/src/crypto/crypto_hash.cc @@ -341,10 +341,22 @@ bool Hash::HashInit(const EVP_MD* md, Maybe xof_md_len) { } md_len_ = EVP_MD_size(md); + bool is_xof = (EVP_MD_flags(md) & EVP_MD_FLAG_XOF) != 0; + if (is_xof && !xof_md_len.IsJust() && md_len_ == 0) { + const char* name = OBJ_nid2sn(EVP_MD_type(md)); + if (name != nullptr) { + if (strcmp(name, "SHAKE128") == 0) { + md_len_ = 16; + } else if (strcmp(name, "SHAKE256") == 0) { + md_len_ = 32; + } + } + } + if (xof_md_len.IsJust() && xof_md_len.FromJust() != md_len_) { // This is a little hack to cause createHash to fail when an incorrect // hashSize option was passed for a non-XOF hash function. - if ((EVP_MD_flags(md) & EVP_MD_FLAG_XOF) == 0) { + if (!is_xof) { EVPerr(EVP_F_EVP_DIGESTFINALXOF, EVP_R_NOT_XOF_OR_INVALID_LENGTH); return false; } diff --git a/src/debug_utils.cc b/src/debug_utils.cc index 9d36082db67..df4ad4e9a1e 100644 --- a/src/debug_utils.cc +++ b/src/debug_utils.cc @@ -471,7 +471,7 @@ std::vector NativeSymbolDebuggingContext::GetLoadedLibraries() { DWORD size_2 = 0; // First call to get the size of module array needed if (EnumProcessModules(process_handle, nullptr, 0, &size_1)) { - MallocedBuffer modules(size_1); + MallocedBuffer modules(size_1 / sizeof(HMODULE)); // Second call to populate the module array if (EnumProcessModules(process_handle, modules.data, size_1, &size_2)) { @@ -480,16 +480,15 @@ std::vector NativeSymbolDebuggingContext::GetLoadedLibraries() { i++) { WCHAR module_name[MAX_PATH]; // Obtain and report the full pathname for each module - if (GetModuleFileNameExW(process_handle, - modules.data[i], - module_name, - arraysize(module_name) / sizeof(WCHAR))) { + if (GetModuleFileNameW( + modules.data[i], module_name, arraysize(module_name))) { DWORD size = WideCharToMultiByte( CP_UTF8, 0, module_name, -1, nullptr, 0, nullptr, nullptr); char* str = new char[size]; WideCharToMultiByte( CP_UTF8, 0, module_name, -1, str, size, nullptr, nullptr); list.emplace_back(str); + delete str; } } } diff --git a/src/debug_utils.h b/src/debug_utils.h index e8b32d453ac..5437636393d 100644 --- a/src/debug_utils.h +++ b/src/debug_utils.h @@ -51,6 +51,7 @@ void NODE_EXTERN_PRIVATE FWrite(FILE* file, const std::string& str); V(NGTCP2_DEBUG) \ V(SEA) \ V(WASI) \ + V(MODULE) \ V(MKSNAPSHOT) \ V(SNAPSHOT_SERDES) \ V(PERMISSION_MODEL) \ diff --git a/src/js_stream.cc b/src/js_stream.cc index 0d13066f54c..b7e63d6509d 100644 --- a/src/js_stream.cc +++ b/src/js_stream.cc @@ -116,10 +116,13 @@ int JSStream::DoWrite(WriteWrap* w, HandleScope scope(env()->isolate()); Context::Scope context_scope(env()->context()); + int value_int = UV_EPROTO; + MaybeStackBuffer, 16> bufs_arr(count); for (size_t i = 0; i < count; i++) { - bufs_arr[i] = - Buffer::Copy(env(), bufs[i].base, bufs[i].len).ToLocalChecked(); + if (!Buffer::Copy(env(), bufs[i].base, bufs[i].len).ToLocal(&bufs_arr[i])) { + return value_int; + } } Local argv[] = { @@ -129,7 +132,6 @@ int JSStream::DoWrite(WriteWrap* w, TryCatchScope try_catch(env()); Local value; - int value_int = UV_EPROTO; if (!MakeCallback(env()->onwrite_string(), arraysize(argv), argv).ToLocal(&value) || diff --git a/src/js_udp_wrap.cc b/src/js_udp_wrap.cc index a4f183025df..51e4f8c45ff 100644 --- a/src/js_udp_wrap.cc +++ b/src/js_udp_wrap.cc @@ -99,8 +99,9 @@ ssize_t JSUDPWrap::Send(uv_buf_t* bufs, MaybeStackBuffer, 16> buffers(nbufs); for (size_t i = 0; i < nbufs; i++) { - buffers[i] = Buffer::Copy(env(), bufs[i].base, bufs[i].len) - .ToLocalChecked(); + if (!Buffer::Copy(env(), bufs[i].base, bufs[i].len).ToLocal(&buffers[i])) { + return value_int; + } total_len += bufs[i].len; } diff --git a/src/module_wrap.cc b/src/module_wrap.cc index a061eafe1de..a906376ce80 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -25,6 +25,7 @@ using v8::Array; using v8::ArrayBufferView; using v8::Context; using v8::EscapableHandleScope; +using v8::Exception; using v8::FixedArray; using v8::Function; using v8::FunctionCallbackInfo; @@ -33,15 +34,22 @@ using v8::HandleScope; using v8::Int32; using v8::Integer; using v8::Isolate; +using v8::JustVoid; using v8::Local; +using v8::Maybe; using v8::MaybeLocal; +using v8::Message; using v8::MicrotaskQueue; using v8::Module; using v8::ModuleRequest; +using v8::Name; +using v8::Nothing; +using v8::Null; using v8::Object; using v8::ObjectTemplate; using v8::PrimitiveArray; using v8::Promise; +using v8::PromiseRejectEvent; using v8::ScriptCompiler; using v8::ScriptOrigin; using v8::String; @@ -588,6 +596,43 @@ void ModuleWrap::InstantiateSync(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(module->IsGraphAsync()); } +Maybe ThrowIfPromiseRejected(Realm* realm, Local promise) { + Isolate* isolate = realm->isolate(); + Local context = realm->context(); + if (promise->State() != Promise::PromiseState::kRejected) { + return JustVoid(); + } + // The rejected promise is created by V8, so we don't get a chance to mark + // it as resolved before the rejection happens from evaluation. But we can + // tell the promise rejection callback to treat it as a promise rejected + // before handler was added which would remove it from the unhandled + // rejection handling, since we are converting it into an error and throw + // from here directly. + Local type = + Integer::New(isolate, + static_cast( + PromiseRejectEvent::kPromiseHandlerAddedAfterReject)); + Local args[] = {type, promise, Undefined(isolate)}; + if (realm->promise_reject_callback() + ->Call(context, Undefined(isolate), arraysize(args), args) + .IsEmpty()) { + return Nothing(); + } + Local exception = promise->Result(); + Local message = Exception::CreateMessage(isolate, exception); + AppendExceptionLine( + realm->env(), exception, message, ErrorHandlingMode::MODULE_ERROR); + isolate->ThrowException(exception); + return Nothing(); +} + +void ThrowIfPromiseRejected(const FunctionCallbackInfo& args) { + if (!args[0]->IsPromise()) { + return; + } + ThrowIfPromiseRejected(Realm::GetCurrent(args), args[0].As()); +} + void ModuleWrap::EvaluateSync(const FunctionCallbackInfo& args) { Realm* realm = Realm::GetCurrent(args); Isolate* isolate = args.GetIsolate(); @@ -612,29 +657,7 @@ void ModuleWrap::EvaluateSync(const FunctionCallbackInfo& args) { CHECK(result->IsPromise()); Local promise = result.As(); - if (promise->State() == Promise::PromiseState::kRejected) { - // The rejected promise is created by V8, so we don't get a chance to mark - // it as resolved before the rejection happens from evaluation. But we can - // tell the promise rejection callback to treat it as a promise rejected - // before handler was added which would remove it from the unhandled - // rejection handling, since we are converting it into an error and throw - // from here directly. - Local type = v8::Integer::New( - isolate, - static_cast( - v8::PromiseRejectEvent::kPromiseHandlerAddedAfterReject)); - Local args[] = {type, promise, Undefined(isolate)}; - if (env->promise_reject_callback() - ->Call(context, Undefined(isolate), arraysize(args), args) - .IsEmpty()) { - return; - } - Local exception = promise->Result(); - Local message = - v8::Exception::CreateMessage(isolate, exception); - AppendExceptionLine( - env, exception, message, ErrorHandlingMode::MODULE_ERROR); - isolate->ThrowException(exception); + if (ThrowIfPromiseRejected(realm, promise).IsNothing()) { return; } @@ -652,7 +675,7 @@ void ModuleWrap::EvaluateSync(const FunctionCallbackInfo& args) { FPrintF(stderr, "%s\n", reason); } } - THROW_ERR_REQUIRE_ASYNC_MODULE(env); + THROW_ERR_REQUIRE_ASYNC_MODULE(env, args[0], args[1]); return; } @@ -674,15 +697,14 @@ void ModuleWrap::GetNamespaceSync(const FunctionCallbackInfo& args) { return realm->env()->ThrowError( "Cannot get namespace, module has not been instantiated"); case v8::Module::Status::kInstantiated: + case v8::Module::Status::kEvaluating: case v8::Module::Status::kEvaluated: case v8::Module::Status::kErrored: break; - case v8::Module::Status::kEvaluating: - UNREACHABLE(); } if (module->IsGraphAsync()) { - return THROW_ERR_REQUIRE_ASYNC_MODULE(realm->env()); + return THROW_ERR_REQUIRE_ASYNC_MODULE(realm->env(), args[0], args[1]); } Local result = module->GetModuleNamespace(); args.GetReturnValue().Set(result); @@ -724,6 +746,16 @@ void ModuleWrap::GetStatus(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(module->GetStatus()); } +void ModuleWrap::IsGraphAsync(const FunctionCallbackInfo& args) { + Isolate* isolate = args.GetIsolate(); + ModuleWrap* obj; + ASSIGN_OR_RETURN_UNWRAP(&obj, args.This()); + + Local module = obj->module_.Get(isolate); + + args.GetReturnValue().Set(module->IsGraphAsync()); +} + void ModuleWrap::GetError(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); ModuleWrap* obj; @@ -821,16 +853,23 @@ static MaybeLocal ImportModuleDynamically( }; Local result; - if (import_callback->Call( - context, - Undefined(isolate), - arraysize(import_args), - import_args).ToLocal(&result)) { - CHECK(result->IsPromise()); - return handle_scope.Escape(result.As()); + if (!import_callback + ->Call( + context, Undefined(isolate), arraysize(import_args), import_args) + .ToLocal(&result)) { + return {}; } - return MaybeLocal(); + // Wrap the returned value in a promise created in the referrer context to + // avoid dynamic scopes. + Local resolver; + if (!Promise::Resolver::New(context).ToLocal(&resolver)) { + return {}; + } + if (resolver->Resolve(context, result).IsNothing()) { + return {}; + } + return handle_scope.Escape(resolver->GetPromise()); } void ModuleWrap::SetImportModuleDynamicallyCallback( @@ -1064,6 +1103,7 @@ void ModuleWrap::CreatePerIsolateProperties(IsolateData* isolate_data, isolate, tpl, "createCachedData", CreateCachedData); SetProtoMethodNoSideEffect(isolate, tpl, "getNamespace", GetNamespace); SetProtoMethodNoSideEffect(isolate, tpl, "getStatus", GetStatus); + SetProtoMethodNoSideEffect(isolate, tpl, "isGraphAsync", IsGraphAsync); SetProtoMethodNoSideEffect(isolate, tpl, "getError", GetError); SetConstructorFunction(isolate, target, "ModuleWrap", tpl); isolate_data->set_module_wrap_constructor_template(tpl); @@ -1080,6 +1120,7 @@ void ModuleWrap::CreatePerIsolateProperties(IsolateData* isolate_data, target, "createRequiredModuleFacade", CreateRequiredModuleFacade); + SetMethod(isolate, target, "throwIfPromiseRejected", ThrowIfPromiseRejected); } void ModuleWrap::CreatePerContextProperties(Local target, @@ -1119,11 +1160,13 @@ void ModuleWrap::RegisterExternalReferences( registry->Register(GetNamespace); registry->Register(GetStatus); registry->Register(GetError); + registry->Register(IsGraphAsync); registry->Register(CreateRequiredModuleFacade); registry->Register(SetImportModuleDynamicallyCallback); registry->Register(SetInitializeImportMetaObjectCallback); + registry->Register(ThrowIfPromiseRejected); } } // namespace loader } // namespace node diff --git a/src/module_wrap.h b/src/module_wrap.h index 51b127209af..860495d8db6 100644 --- a/src/module_wrap.h +++ b/src/module_wrap.h @@ -110,6 +110,7 @@ class ModuleWrap : public BaseObject { static void Instantiate(const v8::FunctionCallbackInfo& args); static void Evaluate(const v8::FunctionCallbackInfo& args); static void GetNamespace(const v8::FunctionCallbackInfo& args); + static void IsGraphAsync(const v8::FunctionCallbackInfo& args); static void GetStatus(const v8::FunctionCallbackInfo& args); static void GetError(const v8::FunctionCallbackInfo& args); diff --git a/src/node.cc b/src/node.cc index 97d2b972999..c98acbcf28c 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1180,10 +1180,7 @@ InitializeOncePerProcessInternal(const std::vector& args, } #endif if (!crypto::ProcessFipsOptions()) { - // XXX: ERR_GET_REASON does not return something that is - // useful as an exit code at all. - result->exit_code_ = - static_cast(ERR_GET_REASON(ERR_peek_error())); + result->exit_code_ = ExitCode::kGenericUserError; result->early_return_ = true; result->errors_.emplace_back( "OpenSSL error when trying to enable FIPS:\n" + diff --git a/src/node_api.cc b/src/node_api.cc index d8a203ba420..326e51330f9 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -693,9 +693,9 @@ void napi_module_register_by_symbol(v8::Local exports, napi_addon_register_func init, int32_t module_api_version) { node::Environment* node_env = node::Environment::GetCurrent(context); + CHECK_NOT_NULL(node_env); std::string module_filename = ""; if (init == nullptr) { - CHECK_NOT_NULL(node_env); node_env->ThrowError("Module has no declared entry point."); return; } @@ -1046,8 +1046,7 @@ napi_create_external_buffer(napi_env env, #if defined(V8_ENABLE_SANDBOX) return napi_set_last_error(env, napi_no_external_buffers_allowed); -#endif - +#else v8::Isolate* isolate = env->isolate; // The finalizer object will delete itself after invoking the callback. @@ -1069,6 +1068,7 @@ napi_create_external_buffer(napi_env env, // as it will be deleted when the buffer to which it is associated // is finalized. // coverity[leaked_storage] +#endif // V8_ENABLE_SANDBOX } napi_status NAPI_CDECL napi_create_buffer_copy(napi_env env, diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 3b26372f24b..60ed678217e 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -1185,7 +1185,12 @@ bool ContextifyScript::EvalMachine(Local context, return false; } - args.GetReturnValue().Set(result.ToLocalChecked()); + // We checked for res being empty previously so this is a bit redundant + // but still safer than using ToLocalChecked. + Local res; + if (!result.ToLocal(&res)) return false; + + args.GetReturnValue().Set(res); return true; } diff --git a/src/node_dotenv.cc b/src/node_dotenv.cc index d22783cb779..9d2bc526572 100644 --- a/src/node_dotenv.cc +++ b/src/node_dotenv.cc @@ -155,7 +155,16 @@ void Dotenv::ParseContent(const std::string_view input) { // If there is no equal character, then ignore everything auto equal = content.find('='); if (equal == std::string_view::npos) { - break; + auto newline = content.find('\n'); + if (newline != std::string_view::npos) { + // If we used `newline` only, + // the '\n' might remain and cause an empty-line parse + content.remove_prefix(newline + 1); + } else { + content = {}; + } + // No valid data here, skip to next line + continue; } key = content.substr(0, equal); @@ -199,7 +208,9 @@ void Dotenv::ParseContent(const std::string_view input) { store_.insert_or_assign(std::string(key), multi_line_value); auto newline = content.find('\n', closing_quote + 1); if (newline != std::string_view::npos) { - content.remove_prefix(newline); + content.remove_prefix(newline + 1); + } else { + content = {}; } continue; } @@ -220,7 +231,7 @@ void Dotenv::ParseContent(const std::string_view input) { if (newline != std::string_view::npos) { value = content.substr(0, newline); store_.insert_or_assign(std::string(key), value); - content.remove_prefix(newline); + content.remove_prefix(newline + 1); } } else { // Example: KEY="value" @@ -230,8 +241,13 @@ void Dotenv::ParseContent(const std::string_view input) { // since there could be newline characters inside the value. auto newline = content.find('\n', closing_quote + 1); if (newline != std::string_view::npos) { - content.remove_prefix(newline); + // Use +1 to discard the '\n' itself => next line + content.remove_prefix(newline + 1); + } else { + content = {}; } + // No valid data here, skip to next line + continue; } } else { // Regular key value pair. @@ -247,15 +263,21 @@ void Dotenv::ParseContent(const std::string_view input) { if (hash_character != std::string_view::npos) { value = content.substr(0, hash_character); } - content.remove_prefix(newline); + store_.insert_or_assign(std::string(key), trim_spaces(value)); + content.remove_prefix(newline + 1); } else { // In case the last line is a single key/value pair // Example: KEY=VALUE (without a newline at the EOF) - value = content.substr(0); + value = content; + auto hash_char = value.find('#'); + if (hash_char != std::string_view::npos) { + value = content.substr(0, hash_char); + } + store_.insert_or_assign(std::string(key), trim_spaces(value)); + content = {}; } - value = trim_spaces(value); - store_.insert_or_assign(std::string(key), value); + store_.insert_or_assign(std::string(key), trim_spaces(value)); } } } diff --git a/src/node_errors.h b/src/node_errors.h index d5e2f86f516..7cacf416b6e 100644 --- a/src/node_errors.h +++ b/src/node_errors.h @@ -105,11 +105,21 @@ void OOMErrorHandler(const char* location, const v8::OOMDetails& details); V(ERR_WORKER_INIT_FAILED, Error) \ V(ERR_PROTO_ACCESS, Error) +// If the macros are used as ERR_*(isolate, message) or +// THROW_ERR_*(isolate, message) with a single string argument, do run +// formatter on the message, and allow the caller to pass in a message +// directly with characters that would otherwise need escaping if used +// as format string unconditionally. #define V(code, type) \ template \ inline v8::Local code( \ v8::Isolate* isolate, const char* format, Args&&... args) { \ - std::string message = SPrintF(format, std::forward(args)...); \ + std::string message; \ + if (sizeof...(Args) == 0) { \ + message = format; \ + } else { \ + message = SPrintF(format, std::forward(args)...); \ + } \ v8::Local js_code = OneByteString(isolate, #code); \ v8::Local js_msg = \ v8::String::NewFromUtf8(isolate, \ @@ -198,10 +208,6 @@ ERRORS_WITH_CODE(V) "creating Workers") \ V(ERR_NON_CONTEXT_AWARE_DISABLED, \ "Loading non context-aware native addons has been disabled") \ - V(ERR_REQUIRE_ASYNC_MODULE, \ - "require() cannot be used on an ESM graph with top-level await. Use " \ - "import() instead. To see where the top-level await comes from, use " \ - "--experimental-print-required-tla.") \ V(ERR_SCRIPT_EXECUTION_INTERRUPTED, \ "Script execution was interrupted by `SIGINT`") \ V(ERR_TLS_PSK_SET_IDENTIY_HINT_FAILED, "Failed to set PSK identity hint") \ @@ -231,6 +237,28 @@ inline void THROW_ERR_SCRIPT_EXECUTION_TIMEOUT(Environment* env, THROW_ERR_SCRIPT_EXECUTION_TIMEOUT(env, message.str().c_str()); } +inline void THROW_ERR_REQUIRE_ASYNC_MODULE( + Environment* env, + v8::Local filename, + v8::Local parent_filename) { + static constexpr const char* prefix = + "require() cannot be used on an ESM graph with top-level await. Use " + "import() instead. To see where the top-level await comes from, use " + "--experimental-print-required-tla."; + std::string message = prefix; + if (!parent_filename.IsEmpty() && parent_filename->IsString()) { + Utf8Value utf8(env->isolate(), parent_filename); + message += "\n From "; + message += utf8.out(); + } + if (!filename.IsEmpty() && filename->IsString()) { + Utf8Value utf8(env->isolate(), filename); + message += "\n Requiring "; + message += +utf8.out(); + } + THROW_ERR_REQUIRE_ASYNC_MODULE(env, message.c_str()); +} + inline v8::Local ERR_BUFFER_TOO_LARGE(v8::Isolate* isolate) { char message[128]; snprintf(message, sizeof(message), diff --git a/src/node_file.cc b/src/node_file.cc index ece5ea0795a..1f7f3427159 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -1049,6 +1049,8 @@ static void ExistsSync(const FunctionCallbackInfo& args) { } // Used to speed up module loading. Returns an array [string, boolean] +// Do not expose this function through public API as it doesn't hold +// Permission Model checks. static void InternalModuleReadJSON(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); Isolate* isolate = env->isolate(); @@ -1056,8 +1058,6 @@ static void InternalModuleReadJSON(const FunctionCallbackInfo& args) { CHECK(args[0]->IsString()); node::Utf8Value path(isolate, args[0]); - THROW_IF_INSUFFICIENT_PERMISSIONS( - env, permission::PermissionScope::kFileSystemRead, path.ToStringView()); if (strlen(*path) != path.length()) { args.GetReturnValue().Set(Array::New(isolate)); @@ -1153,8 +1153,6 @@ static void InternalModuleStat(const FunctionCallbackInfo& args) { CHECK(args[0]->IsString()); node::Utf8Value path(env->isolate(), args[0]); - THROW_IF_INSUFFICIENT_PERMISSIONS( - env, permission::PermissionScope::kFileSystemRead, path.ToStringView()); uv_fs_t req; int rc = uv_fs_stat(env->event_loop(), &req, *path, nullptr); diff --git a/src/node_http2.cc b/src/node_http2.cc index c190252e5a5..d0c30fdfc06 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -1214,7 +1214,7 @@ int Http2Session::OnFrameNotSent(nghttp2_session* handle, // closed but the Http2Session will still be up causing a memory leak. // Therefore, if the GOAWAY frame couldn't be send due to // ERR_SESSION_CLOSING we should force close from our side. - if (frame->hd.type != 0x03) { + if (frame->hd.type != NGHTTP2_GOAWAY) { return 0; } } diff --git a/src/node_http_common.h b/src/node_http_common.h index b58e8cb5607..e2e13e9972f 100644 --- a/src/node_http_common.h +++ b/src/node_http_common.h @@ -414,8 +414,11 @@ class NgRcBufPointer : public MemoryRetainer { const char* header_name = reinterpret_cast(ptr.data()); v8::Eternal& eternal = static_str_map[header_name]; if (eternal.IsEmpty()) { - v8::Local str = - GetInternalizedString(env, ptr).ToLocalChecked(); + v8::Local str; + if (!GetInternalizedString(env, ptr).ToLocal(&str)) { + ptr.reset(); + return {}; + } eternal.Set(env->isolate(), str); return str; } diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 663f7da5b90..8ded2021920 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -1200,6 +1200,10 @@ void ConnectionsList::Expired(const FunctionCallbackInfo& args) { const llhttp_settings_t Parser::settings = { Proxy::Raw, + + // on_protocol + nullptr, + Proxy::Raw, Proxy::Raw, @@ -1220,6 +1224,8 @@ const llhttp_settings_t Parser::settings = { Proxy::Raw, Proxy::Raw, + // on_protocol_complete + nullptr, // on_url_complete nullptr, // on_status_complete diff --git a/src/node_i18n.cc b/src/node_i18n.cc index 1ddae30e972..44040057999 100644 --- a/src/node_i18n.cc +++ b/src/node_i18n.cc @@ -172,7 +172,7 @@ MaybeLocal TranscodeLatin1ToUcs2(Environment* env, const char* source, const size_t source_length, UErrorCode* status) { - MaybeStackBuffer destbuf(source_length); + MaybeStackBuffer destbuf(source_length); auto actual_length = simdutf::convert_latin1_to_utf16le(source, source_length, destbuf.out()); if (actual_length == 0) { @@ -216,7 +216,7 @@ MaybeLocal TranscodeUcs2FromUtf8(Environment* env, UErrorCode* status) { size_t expected_utf16_length = simdutf::utf16_length_from_utf8(source, source_length); - MaybeStackBuffer destbuf(expected_utf16_length); + MaybeStackBuffer destbuf(expected_utf16_length); auto actual_length = simdutf::convert_utf8_to_utf16le(source, source_length, destbuf.out()); diff --git a/src/node_os.cc b/src/node_os.cc index ce2af8d83b7..ddaf61d5eb6 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -192,6 +192,9 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo& args) { return args.GetReturnValue().SetUndefined(); } + auto cleanup = + OnScopeLeave([&]() { uv_free_interface_addresses(interfaces, count); }); + Local no_scope_id = Integer::New(isolate, -1); std::vector> result; result.reserve(count * 7); @@ -243,7 +246,6 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo& args) { } } - uv_free_interface_addresses(interfaces, count); args.GetReturnValue().Set(Array::New(isolate, result.data(), result.size())); } diff --git a/src/node_version.h b/src/node_version.h index b51c1658c71..56bddf624fa 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -24,7 +24,7 @@ #define NODE_MAJOR_VERSION 20 #define NODE_MINOR_VERSION 19 -#define NODE_PATCH_VERSION 4 +#define NODE_PATCH_VERSION 5 #define NODE_VERSION_IS_LTS 1 #define NODE_VERSION_LTS_CODENAME "Iron" @@ -36,7 +36,7 @@ #define NSOLID_MINOR_VERSION 0 #define NSOLID_PATCH_VERSION 2 -#define NSOLID_VERSION_IS_RELEASE 0 +#define NSOLID_VERSION_IS_RELEASE 1 #ifndef NODE_STRINGIFY #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n) diff --git a/src/node_zlib.cc b/src/node_zlib.cc index 66370e41659..a537e766722 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -493,20 +493,22 @@ class CompressionStream : public AsyncWrap, public ThreadPoolWork { } static void* AllocForBrotli(void* data, size_t size) { - size += sizeof(size_t); + constexpr size_t offset = std::max(sizeof(size_t), alignof(max_align_t)); + size += offset; CompressionStream* ctx = static_cast(data); char* memory = UncheckedMalloc(size); if (UNLIKELY(memory == nullptr)) return nullptr; *reinterpret_cast(memory) = size; ctx->unreported_allocations_.fetch_add(size, std::memory_order_relaxed); - return memory + sizeof(size_t); + return memory + offset; } static void FreeForZlib(void* data, void* pointer) { if (UNLIKELY(pointer == nullptr)) return; CompressionStream* ctx = static_cast(data); - char* real_pointer = static_cast(pointer) - sizeof(size_t); + constexpr size_t offset = std::max(sizeof(size_t), alignof(max_align_t)); + char* real_pointer = static_cast(pointer) - offset; size_t real_size = *reinterpret_cast(real_pointer); ctx->unreported_allocations_.fetch_sub(real_size, std::memory_order_relaxed); diff --git a/src/nsolid/nsolid_api.cc b/src/nsolid/nsolid_api.cc index fcc856e18de..728f726aa46 100644 --- a/src/nsolid/nsolid_api.cc +++ b/src/nsolid/nsolid_api.cc @@ -606,6 +606,10 @@ void EnvInst::uv_metrics_cb_(nsuv::ns_prepare* handle, EnvInst* envinst) { // Use the previous values to calculate the values for this loop iteration. loop_duration = metrics_cb_time - envinst->prev_metrics_cb_time_; loop_idle_time = idle_time - envinst->prev_loop_idle_time_; + // Clamp loop_idle_time to avoid unsigned underflow in loop_proc_time when + // clock skew causes idle_time to be slightly larger than loop_duration. + if (loop_idle_time > loop_duration) + loop_idle_time = loop_duration; loop_proc_time = loop_duration - loop_idle_time; events_procd = metrics->events - envinst->prev_events_processed_; events_waiting = metrics->events_waiting - envinst->prev_events_waiting_; @@ -2157,6 +2161,12 @@ void EnvInst::get_event_loop_stats_(EnvInst* envinst, uint64_t loop_idle_time = uv_metrics_idle_time(envinst->event_loop()); uint64_t loop_diff = stor->current_hrtime_ - stor->prev_call_time_; uint64_t idle_diff = loop_idle_time - stor->prev_idle_time_; + // On some platforms the clocks backing loop_diff and idle_diff can differ by + // a few hundred nanoseconds when the loop is nearly 100% idle, making + // idle_diff slightly larger than loop_diff. Clamp to avoid unsigned + // underflow in proc_diff and bogus utilization values. + if (idle_diff > loop_diff) + idle_diff = loop_diff; uint64_t proc_diff = loop_diff - idle_diff; uint64_t count_diff = metrics->loop_count - stor->loop_iterations; auto entry_exit = envinst->provider_times(); diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index f3e783233ba..bdb59a35e96 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -53,10 +53,12 @@ MaybeLocal PipeWrap::Instantiate(Environment* env, EscapableHandleScope handle_scope(env->isolate()); AsyncHooks::DefaultTriggerAsyncIdScope trigger_scope(parent); CHECK_EQ(false, env->pipe_constructor_template().IsEmpty()); - Local constructor = env->pipe_constructor_template() - ->GetFunction(env->context()) - .ToLocalChecked(); - CHECK_EQ(false, constructor.IsEmpty()); + Local constructor; + if (!env->pipe_constructor_template() + ->GetFunction(env->context()) + .ToLocal(&constructor)) { + return {}; + } Local type_value = Int32::New(env->isolate(), type); return handle_scope.EscapeMaybe( constructor->NewInstance(env->context(), 1, &type_value)); diff --git a/src/quic/sessionticket.h b/src/quic/sessionticket.h index 4700af57439..106447f00f6 100644 --- a/src/quic/sessionticket.h +++ b/src/quic/sessionticket.h @@ -58,7 +58,7 @@ class SessionTicket final : public MemoryRetainer { }; // SessionTicket::AppData is a utility class that is used only during the -// generation or access of TLS stateless sesson tickets. It exists solely to +// generation or access of TLS stateless session tickets. It exists solely to // provide a easier way for Session::Application instances to set relevant // metadata in the session ticket when it is created, and the exract and // subsequently verify that data when a ticket is received and is being diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index 6c70f270baf..84191ff46ee 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -59,10 +59,12 @@ MaybeLocal TCPWrap::Instantiate(Environment* env, EscapableHandleScope handle_scope(env->isolate()); AsyncHooks::DefaultTriggerAsyncIdScope trigger_scope(parent); CHECK_EQ(env->tcp_constructor_template().IsEmpty(), false); - Local constructor = env->tcp_constructor_template() - ->GetFunction(env->context()) - .ToLocalChecked(); - CHECK_EQ(constructor.IsEmpty(), false); + Local constructor; + if (!env->tcp_constructor_template() + ->GetFunction(env->context()) + .ToLocal(&constructor)) { + return {}; + } Local type_value = Int32::New(env->isolate(), type); return handle_scope.EscapeMaybe( constructor->NewInstance(env->context(), 1, &type_value)); diff --git a/src/util.cc b/src/util.cc index b24b588aff3..5450b0931a7 100644 --- a/src/util.cc +++ b/src/util.cc @@ -791,8 +791,11 @@ v8::Maybe GetValidatedFd(Environment* env, const bool is_out_of_range = fd < 0 || fd > INT32_MAX; if (is_out_of_range || !IsSafeJsInt(input)) { - Utf8Value utf8_value( - env->isolate(), input->ToDetailString(env->context()).ToLocalChecked()); + Local str; + if (!input->ToDetailString(env->context()).ToLocal(&str)) { + return v8::Nothing(); + } + Utf8Value utf8_value(env->isolate(), str); if (is_out_of_range && !std::isinf(fd)) { THROW_ERR_OUT_OF_RANGE(env, "The value of \"fd\" is out of range. " diff --git a/src/zlib_version.h b/src/zlib_version.h index 3b53884aae2..67856b28ad6 100644 --- a/src/zlib_version.h +++ b/src/zlib_version.h @@ -2,5 +2,5 @@ // Refer to tools/dep_updaters/update-zlib.sh #ifndef SRC_ZLIB_VERSION_H_ #define SRC_ZLIB_VERSION_H_ -#define ZLIB_VERSION "1.3.0.1-motley-82a5fec" +#define ZLIB_VERSION "1.3.1-470d3a2" #endif // SRC_ZLIB_VERSION_H_ diff --git a/test/agents/test-grpc-blocked-loop.mjs b/test/agents/test-grpc-blocked-loop.mjs index 90e72999a68..977e877bd34 100644 --- a/test/agents/test-grpc-blocked-loop.mjs +++ b/test/agents/test-grpc-blocked-loop.mjs @@ -69,7 +69,7 @@ const { // }, function checkBlockedLoopData(blocked, metadata, agentId, threadId) { console.dir(blocked, { depth: null }); - assert.strictEqual(blocked.common.requestId, ''); + validateString(blocked.common.requestId, 'common.requestId'); assert.strictEqual(blocked.common.command, 'loop_blocked'); // From here check at least that all the fields are present validateObject(blocked.common.recorded, 'recorded'); @@ -119,7 +119,7 @@ function checkBlockedLoopData(blocked, metadata, agentId, threadId) { // } function checkUnblockedLoopData(blocked, metadata, agentId, threadId, bInfo) { console.dir(blocked, { depth: null }); - assert.strictEqual(blocked.common.requestId, ''); + validateString(blocked.common.requestId, 'common.requestId'); assert.strictEqual(blocked.common.command, 'loop_unblocked'); // From here check at least that all the fields are present validateObject(blocked.common.recorded, 'recorded'); diff --git a/test/cctest/node_test_fixture.cc b/test/cctest/node_test_fixture.cc index d2662604d14..66c3591049f 100644 --- a/test/cctest/node_test_fixture.cc +++ b/test/cctest/node_test_fixture.cc @@ -20,9 +20,6 @@ void NodeTestEnvironment::SetUp() { NodeZeroIsolateTestFixture::platform.reset( new node::NodePlatform(kV8ThreadPoolSize, tracing_controller)); v8::V8::InitializePlatform(NodeZeroIsolateTestFixture::platform.get()); -#ifdef V8_ENABLE_SANDBOX - ASSERT_TRUE(v8::V8::InitializeSandbox()); -#endif cppgc::InitializeProcess( NodeZeroIsolateTestFixture::platform->GetPageAllocator()); diff --git a/test/common/README.md b/test/common/README.md index eef654963d5..8dbe4f0cd79 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -1,6 +1,29 @@ # Node.js Core Test Common Modules This directory contains modules used to test the Node.js implementation. +All tests must begin by requiring the `common` module: + +```js +require('../common'); +``` + +This is not just a convenience for exporting helper functions etc; it also performs +several other tasks: + +* Verifies that no unintended globals have been leaked to ensure that tests + don't accidentally pollute the global namespace. + +* Some tests assume a default umask of `0o022`. To enforce this assumption, + the common module sets the unmask at startup. Tests that require a + different umask can override this setting after loading the module. + +* Some tests specify runtime flags (example, `--expose-internals`) via a + comment at the top of the file: `// Flags: --expose-internals`. + If the test is run without those flags, the common module automatically + spawns a child process with proper flags. This ensures that the tests + always run under the expected conditions. Because of this behaviour, the + common module must be loaded first so that any code below it is not + executed until the process has been re-spawned with the correct flags. ## Table of contents diff --git a/test/common/index.js b/test/common/index.js index 171fb854326..7150e7f843d 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -947,6 +947,17 @@ function expectRequiredModule(mod, expectation, checkESModule = true) { assert.deepStrictEqual(clone, { ...expectation }); } +function expectRequiredTLAError(err) { + const message = /require\(\) cannot be used on an ESM graph with top-level await/; + if (typeof err === 'string') { + assert.match(err, /ERR_REQUIRE_ASYNC_MODULE/); + assert.match(err, message); + } else { + assert.strictEqual(err.code, 'ERR_REQUIRE_ASYNC_MODULE'); + assert.match(err.message, message); + } +} + const common = { allowGlobals, buildType, @@ -956,6 +967,7 @@ const common = { defaultAutoSelectFamilyAttemptTimeout, expectsError, expectRequiredModule, + expectRequiredTLAError, expectWarning, getArrayBufferViews, getBufferSources, diff --git a/test/common/nsolid-grpc-agent/index.js b/test/common/nsolid-grpc-agent/index.js index a86bbb9089b..2bac8acf3a9 100644 --- a/test/common/nsolid-grpc-agent/index.js +++ b/test/common/nsolid-grpc-agent/index.js @@ -16,7 +16,7 @@ const { function checkExitData(data, metadata, agentId, expectedData) { console.dir(data, { depth: null }); - assert.strictEqual(data.common.requestId, ''); + validateString(data.common.requestId, 'common.requestId'); assert.strictEqual(data.common.command, 'exit'); // From here check at least that all the fields are present validateObject(data.common.recorded, 'recorded'); diff --git a/test/es-module/es-module.status b/test/es-module/es-module.status index 58a422dc152..36d4b4d6a1c 100644 --- a/test/es-module/es-module.status +++ b/test/es-module/es-module.status @@ -13,3 +13,7 @@ test-esm-loader-http-imports: PASS,FLAKY [$arch==arm || $arch==arm64] # https://github.com/nodejs/node/issues/47297 test-wasm-web-api: SKIP + +[$system==macos] +# https://github.com/nodejs/node/pull/59551#issuecomment-3248510249 +test-http-imports: SKIP diff --git a/test/es-module/test-import-module-retry-require-errored.js b/test/es-module/test-import-module-retry-require-errored.js new file mode 100644 index 00000000000..79afa20aa70 --- /dev/null +++ b/test/es-module/test-import-module-retry-require-errored.js @@ -0,0 +1,17 @@ +// This tests that after failing to import an ESM that rejects, +// retrying with require() still throws. + +'use strict'; +const common = require('../common'); +const assert = require('assert'); + +(async () => { + await assert.rejects(import('../fixtures/es-modules/throw-error.mjs'), { + message: 'test', + }); + assert.throws(() => { + require('../fixtures/es-modules/throw-error.mjs'); + }, { + message: 'test', + }); +})().catch(common.mustNotCall()); diff --git a/test/es-module/test-import-preload-require-cycle.js b/test/es-module/test-import-preload-require-cycle.js new file mode 100644 index 00000000000..c47b64ba584 --- /dev/null +++ b/test/es-module/test-import-preload-require-cycle.js @@ -0,0 +1,20 @@ +'use strict'; + +// This tests that --import preload does not break CJS entry points that contains +// require cycles. + +require('../common'); +const fixtures = require('../common/fixtures'); +const { spawnSyncAndAssert } = require('../common/child_process'); + +spawnSyncAndAssert( + process.execPath, + [ + '--import', + fixtures.fileURL('import-require-cycle/preload.mjs'), + fixtures.path('import-require-cycle/c.js'), + ], + { + stdout: /cycle equality true/, + } +); diff --git a/test/es-module/test-require-module-error-catching.js b/test/es-module/test-require-module-error-catching.js index c314513d9bb..5400564b318 100644 --- a/test/es-module/test-require-module-error-catching.js +++ b/test/es-module/test-require-module-error-catching.js @@ -17,5 +17,5 @@ assert.throws(() => { require('../fixtures/es-modules/reference-error-esm.js'); }, { name: 'ReferenceError', - message: 'exports is not defined' + message: 'exports is not defined in ES module scope' }); diff --git a/test/es-module/test-require-module-instantiated.mjs b/test/es-module/test-require-module-instantiated.mjs new file mode 100644 index 00000000000..9dd50f31d36 --- /dev/null +++ b/test/es-module/test-require-module-instantiated.mjs @@ -0,0 +1,4 @@ +import '../common/index.mjs'; +import assert from 'node:assert'; +import { b, c } from '../fixtures/es-modules/require-module-instantiated/a.mjs'; +assert.strictEqual(b, c); diff --git a/test/es-module/test-require-module-retry-import-errored-2.js b/test/es-module/test-require-module-retry-import-errored-2.js new file mode 100644 index 00000000000..3504d9932c6 --- /dev/null +++ b/test/es-module/test-require-module-retry-import-errored-2.js @@ -0,0 +1,16 @@ +// This tests that after failing to require an ESM that throws, +// retrying with import() still rejects. + +'use strict'; +const common = require('../common'); +const assert = require('assert'); + +assert.throws(() => { + require('../fixtures/es-modules/throw-error.mjs'); +}, { + message: 'test', +}); + +assert.rejects(import('../fixtures/es-modules/throw-error.mjs'), { + message: 'test', +}).catch(common.mustNotCall()); diff --git a/test/es-module/test-require-module-tla-execution.js b/test/es-module/test-require-module-tla-execution.js new file mode 100644 index 00000000000..bdd222d1f8f --- /dev/null +++ b/test/es-module/test-require-module-tla-execution.js @@ -0,0 +1,26 @@ +'use strict'; + +// Tests that require(esm) with top-level-await throws before execution starts +// if --experimental-print-required-tla is not enabled. + +const common = require('../common'); +const assert = require('assert'); +const { spawnSyncAndExit } = require('../common/child_process'); +const fixtures = require('../common/fixtures'); + +{ + spawnSyncAndExit(process.execPath, [ + fixtures.path('es-modules/tla/require-execution.js'), + ], { + signal: null, + status: 1, + stderr(output) { + assert.doesNotMatch(output, /I am executed/); + common.expectRequiredTLAError(output); + assert.match(output, /From .*require-execution\.js/); + assert.match(output, /Requiring .*execution\.mjs/); + return true; + }, + stdout: '' + }); +} diff --git a/test/es-module/test-require-module-tla-nested.js b/test/es-module/test-require-module-tla-nested.js new file mode 100644 index 00000000000..583cd7cd0c9 --- /dev/null +++ b/test/es-module/test-require-module-tla-nested.js @@ -0,0 +1,15 @@ +'use strict'; + +// Tests that require(esm) throws for top-level-await in inner graphs. + +const common = require('../common'); +const assert = require('assert'); + +assert.throws(() => { + require('../fixtures/es-modules/tla/parent.mjs'); +}, (err) => { + common.expectRequiredTLAError(err); + assert.match(err.message, /From .*test-require-module-tla-nested\.js/); + assert.match(err.message, /Requiring .*parent\.mjs/); + return true; +}); diff --git a/test/es-module/test-require-module-tla-print-execution.js b/test/es-module/test-require-module-tla-print-execution.js new file mode 100644 index 00000000000..40992ae32e0 --- /dev/null +++ b/test/es-module/test-require-module-tla-print-execution.js @@ -0,0 +1,29 @@ +'use strict'; + +// Tests that require(esm) with top-level-await throws after execution +// if --experimental-print-required-tla is enabled. + +const common = require('../common'); +const assert = require('assert'); +const { spawnSyncAndExit } = require('../common/child_process'); +const fixtures = require('../common/fixtures'); + +{ + spawnSyncAndExit(process.execPath, [ + '--experimental-print-required-tla', + fixtures.path('es-modules/tla/require-execution.js'), + ], { + signal: null, + status: 1, + stderr(output) { + assert.match(output, /I am executed/); + common.expectRequiredTLAError(output); + assert.match(output, /Error: unexpected top-level await at.*execution\.mjs:3/); + assert.match(output, /await Promise\.resolve\('hi'\)/); + assert.match(output, /From .*require-execution\.js/); + assert.match(output, /Requiring .*execution\.mjs/); + return true; + }, + stdout: '' + }); +} diff --git a/test/es-module/test-require-module-tla-rejected.js b/test/es-module/test-require-module-tla-rejected.js new file mode 100644 index 00000000000..0c1f8de2c30 --- /dev/null +++ b/test/es-module/test-require-module-tla-rejected.js @@ -0,0 +1,15 @@ +'use strict'; + +// Tests that require(esm) throws for rejected top-level await. + +const common = require('../common'); +const assert = require('assert'); + +assert.throws(() => { + require('../fixtures/es-modules/tla/rejected.mjs'); +}, (err) => { + common.expectRequiredTLAError(err); + assert.match(err.message, /From .*test-require-module-tla-rejected\.js/); + assert.match(err.message, /Requiring .*rejected\.mjs/); + return true; +}); diff --git a/test/es-module/test-require-module-tla-resolved.js b/test/es-module/test-require-module-tla-resolved.js new file mode 100644 index 00000000000..f35bb68b7dc --- /dev/null +++ b/test/es-module/test-require-module-tla-resolved.js @@ -0,0 +1,15 @@ +'use strict'; + +// Tests that require(esm) throws for resolved top-level-await. + +const common = require('../common'); +const assert = require('assert'); + +assert.throws(() => { + require('../fixtures/es-modules/tla/resolved.mjs'); +}, (err) => { + common.expectRequiredTLAError(err); + assert.match(err.message, /From .*test-require-module-tla-resolved\.js/); + assert.match(err.message, /Requiring .*resolved\.mjs/); + return true; +}); diff --git a/test/es-module/test-require-module-tla-unresolved.js b/test/es-module/test-require-module-tla-unresolved.js new file mode 100644 index 00000000000..35cf12c4461 --- /dev/null +++ b/test/es-module/test-require-module-tla-unresolved.js @@ -0,0 +1,15 @@ +'use strict'; + +// Tests that require(esm) throws for unresolved top-level-await. + +const common = require('../common'); +const assert = require('assert'); + +assert.throws(() => { + require('../fixtures/es-modules/tla/unresolved.mjs'); +}, (err) => { + common.expectRequiredTLAError(err); + assert.match(err.message, /From .*test-require-module-tla-unresolved\.js/); + assert.match(err.message, /Requiring .*unresolved\.mjs/); + return true; +}); diff --git a/test/es-module/test-require-module-tla.js b/test/es-module/test-require-module-tla.js deleted file mode 100644 index 9b38b1cab3f..00000000000 --- a/test/es-module/test-require-module-tla.js +++ /dev/null @@ -1,63 +0,0 @@ -// Flags: --experimental-require-module -'use strict'; - -require('../common'); -const assert = require('assert'); -const { spawnSyncAndExit } = require('../common/child_process'); -const fixtures = require('../common/fixtures'); - -const message = /require\(\) cannot be used on an ESM graph with top-level await/; -const code = 'ERR_REQUIRE_ASYNC_MODULE'; - -assert.throws(() => { - require('../fixtures/es-modules/tla/rejected.mjs'); -}, { message, code }); - -assert.throws(() => { - require('../fixtures/es-modules/tla/unresolved.mjs'); -}, { message, code }); - - -assert.throws(() => { - require('../fixtures/es-modules/tla/resolved.mjs'); -}, { message, code }); - -// Test TLA in inner graphs. -assert.throws(() => { - require('../fixtures/es-modules/tla/parent.mjs'); -}, { message, code }); - -{ - spawnSyncAndExit(process.execPath, [ - '--experimental-require-module', - fixtures.path('es-modules/tla/require-execution.js'), - ], { - signal: null, - status: 1, - stderr(output) { - assert.doesNotMatch(output, /I am executed/); - assert.match(output, message); - return true; - }, - stdout: '' - }); -} - -{ - spawnSyncAndExit(process.execPath, [ - '--experimental-require-module', - '--experimental-print-required-tla', - fixtures.path('es-modules/tla/require-execution.js'), - ], { - signal: null, - status: 1, - stderr(output) { - assert.match(output, /I am executed/); - assert.match(output, /Error: unexpected top-level await at.*execution\.mjs:3/); - assert.match(output, /await Promise\.resolve\('hi'\)/); - assert.match(output, message); - return true; - }, - stdout: '' - }); -} diff --git a/test/fixtures/dotenv/valid.env b/test/fixtures/dotenv/valid.env index 120488d5791..6df454da653 100644 --- a/test/fixtures/dotenv/valid.env +++ b/test/fixtures/dotenv/valid.env @@ -6,6 +6,8 @@ BASIC=basic # previous line intentionally left blank AFTER_LINE=after_line +A="B=C" +B=C=D EMPTY= EMPTY_SINGLE_QUOTES='' EMPTY_DOUBLE_QUOTES="" diff --git a/test/fixtures/es-modules/require-module-instantiated/a.mjs b/test/fixtures/es-modules/require-module-instantiated/a.mjs new file mode 100644 index 00000000000..2918d414621 --- /dev/null +++ b/test/fixtures/es-modules/require-module-instantiated/a.mjs @@ -0,0 +1,2 @@ +export { default as b } from './b.cjs'; +export { default as c } from './c.mjs'; diff --git a/test/fixtures/es-modules/require-module-instantiated/b.cjs b/test/fixtures/es-modules/require-module-instantiated/b.cjs new file mode 100644 index 00000000000..1e23a5d46d2 --- /dev/null +++ b/test/fixtures/es-modules/require-module-instantiated/b.cjs @@ -0,0 +1 @@ +module.exports = require('./c.mjs'); diff --git a/test/fixtures/es-modules/require-module-instantiated/c.mjs b/test/fixtures/es-modules/require-module-instantiated/c.mjs new file mode 100644 index 00000000000..a5b4faccf9a --- /dev/null +++ b/test/fixtures/es-modules/require-module-instantiated/c.mjs @@ -0,0 +1,3 @@ +const foo = 1; +export default foo; +export { foo as 'module.exports' }; diff --git a/test/fixtures/import-require-cycle/a.js b/test/fixtures/import-require-cycle/a.js new file mode 100644 index 00000000000..595a5085cf5 --- /dev/null +++ b/test/fixtures/import-require-cycle/a.js @@ -0,0 +1 @@ +module.exports.b = require('./b.js'); diff --git a/test/fixtures/import-require-cycle/b.js b/test/fixtures/import-require-cycle/b.js new file mode 100644 index 00000000000..869be257319 --- /dev/null +++ b/test/fixtures/import-require-cycle/b.js @@ -0,0 +1 @@ +module.exports.a = require('./a.js'); diff --git a/test/fixtures/import-require-cycle/c.js b/test/fixtures/import-require-cycle/c.js new file mode 100644 index 00000000000..39099ad7607 --- /dev/null +++ b/test/fixtures/import-require-cycle/c.js @@ -0,0 +1,3 @@ +const obj = require('./b.js'); + +console.log('cycle equality', obj.a.b === obj); diff --git a/test/fixtures/import-require-cycle/preload.mjs b/test/fixtures/import-require-cycle/preload.mjs new file mode 100644 index 00000000000..83690b86fea --- /dev/null +++ b/test/fixtures/import-require-cycle/preload.mjs @@ -0,0 +1,10 @@ +import * as mod from "module"; + +// This API is not available on v20.x. We are just checking that a +// using a --import preload to force the ESM loader to load CJS +// still handles CJS <-> CJS cycles just fine. +// mod.registerHooks({ +// load(url, context, nextLoad) { +// return nextLoad(url, context); +// }, +// }); diff --git a/test/fixtures/permission/fs-read.js b/test/fixtures/permission/fs-read.js index 03261d975ab..5679387cfd6 100644 --- a/test/fixtures/permission/fs-read.js +++ b/test/fixtures/permission/fs-read.js @@ -281,6 +281,13 @@ const regularFile = __filename; permission: 'FileSystemRead', // resource: path.toNamespacedPath(blockedFolder), })); + assert.throws(() => { + fs.readdirSync(blockedFolder, { recursive: true }); + }, common.expectsError({ + code: 'ERR_ACCESS_DENIED', + permission: 'FileSystemRead', + resource: path.toNamespacedPath(blockedFolder), + })); assert.throws(() => { fs.readdirSync(blockedFolder); }, common.expectsError({ diff --git a/test/fixtures/permission/main-module.js b/test/fixtures/permission/main-module.js new file mode 100644 index 00000000000..cac52e04ddd --- /dev/null +++ b/test/fixtures/permission/main-module.js @@ -0,0 +1 @@ +require('./required-module'); \ No newline at end of file diff --git a/test/fixtures/permission/main-module.mjs b/test/fixtures/permission/main-module.mjs new file mode 100644 index 00000000000..e7c28f7f6ca --- /dev/null +++ b/test/fixtures/permission/main-module.mjs @@ -0,0 +1 @@ +import './required-module.mjs'; \ No newline at end of file diff --git a/test/fixtures/permission/required-module.js b/test/fixtures/permission/required-module.js new file mode 100644 index 00000000000..e8dbf442c5b --- /dev/null +++ b/test/fixtures/permission/required-module.js @@ -0,0 +1 @@ +console.log('ok'); \ No newline at end of file diff --git a/test/fixtures/permission/required-module.mjs b/test/fixtures/permission/required-module.mjs new file mode 100644 index 00000000000..e8dbf442c5b --- /dev/null +++ b/test/fixtures/permission/required-module.mjs @@ -0,0 +1 @@ +console.log('ok'); \ No newline at end of file diff --git a/test/internet/test-dns.js b/test/internet/test-dns.js index abf94314b1b..0b485e6daa3 100644 --- a/test/internet/test-dns.js +++ b/test/internet/test-dns.js @@ -482,9 +482,9 @@ TEST(function test_resolveCname_failure(done) { TEST(async function test_resolveTxt(done) { function validateResult(result) { - assert.ok(Array.isArray(result[0])); - assert.strictEqual(result.length, 1); - assert(result[0][0].startsWith('v=spf1')); + assert.ok(result.length > 0); + assert.ok(result.every((elem) => Array.isArray(elem) && elem.length === 1)); + assert.ok(result.some((elem) => elem[0].startsWith('v=spf1'))); } validateResult(await dnsPromises.resolveTxt(addresses.TXT_HOST)); diff --git a/test/parallel/test-crypto-default-shake-lengths.js b/test/parallel/test-crypto-default-shake-lengths.js new file mode 100644 index 00000000000..1e558814ca0 --- /dev/null +++ b/test/parallel/test-crypto-default-shake-lengths.js @@ -0,0 +1,18 @@ +// Flags: --pending-deprecation +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); + +const { createHash } = require('crypto'); + +common.expectWarning({ + DeprecationWarning: { + DEP0198: 'Creating SHAKE128/256 digests without an explicit options.outputLength is deprecated.', + } +}); + +{ + createHash('shake128').update('test').digest(); +} diff --git a/test/parallel/test-crypto-fips.js b/test/parallel/test-crypto-fips.js index 8a8a8089a3c..3dfbd1fdd40 100644 --- a/test/parallel/test-crypto-fips.js +++ b/test/parallel/test-crypto-fips.js @@ -22,13 +22,16 @@ const FIPS_ENABLE_ERROR_STRING = 'OpenSSL error when trying to enable FIPS:'; const CNF_FIPS_ON = fixtures.path('openssl_fips_enabled.cnf'); const CNF_FIPS_OFF = fixtures.path('openssl_fips_disabled.cnf'); +const kNoFailure = 0; +const kGenericUserError = 1; + let num_children_ok = 0; function sharedOpenSSL() { return process.config.variables.node_shared_openssl; } -function testHelper(stream, args, expectedOutput, cmd, env) { +function testHelper(stream, args, expectedStatus, expectedOutput, cmd, env) { const fullArgs = args.concat(['-e', `console.log(${cmd})`]); const child = spawnSync(process.execPath, fullArgs, { cwd: path.dirname(process.execPath), @@ -55,6 +58,7 @@ function testHelper(stream, args, expectedOutput, cmd, env) { // Normal path where we expect either FIPS enabled or disabled. assert.strictEqual(getFipsValue, expectedOutput); } + assert.strictEqual(child.status, expectedStatus); childOk(child); } @@ -65,6 +69,7 @@ function testHelper(stream, args, expectedOutput, cmd, env) { testHelper( testFipsCrypto() ? 'stdout' : 'stderr', ['--enable-fips'], + testFipsCrypto() ? kNoFailure : kGenericUserError, testFipsCrypto() ? FIPS_ENABLED : FIPS_ENABLE_ERROR_STRING, 'process.versions', process.env); @@ -73,6 +78,7 @@ testHelper( testHelper( testFipsCrypto() ? 'stdout' : 'stderr', ['--force-fips'], + testFipsCrypto() ? kNoFailure : kGenericUserError, testFipsCrypto() ? FIPS_ENABLED : FIPS_ENABLE_ERROR_STRING, 'process.versions', process.env); @@ -84,6 +90,7 @@ if (!sharedOpenSSL()) { testHelper( 'stdout', [], + kNoFailure, FIPS_DISABLED, 'require("crypto").getFips()', { ...process.env, 'OPENSSL_CONF': ' ' }); @@ -93,6 +100,7 @@ if (!sharedOpenSSL()) { testHelper( 'stderr', [], + kGenericUserError, 'Calling crypto.setFips() is not supported in workers', 'new worker_threads.Worker(\'require("crypto").setFips(true);\', { eval: true })', process.env); @@ -119,6 +127,7 @@ if (!sharedOpenSSL() && !common.hasOpenSSL3) { testHelper( 'stdout', [`--openssl-config=${CNF_FIPS_ON}`], + kNoFailure, testFipsCrypto() ? FIPS_ENABLED : FIPS_DISABLED, 'require("crypto").getFips()', process.env); @@ -127,6 +136,7 @@ if (!sharedOpenSSL() && !common.hasOpenSSL3) { testHelper( 'stdout', [], + kNoFailure, testFipsCrypto() ? FIPS_ENABLED : FIPS_DISABLED, 'require("crypto").getFips()', Object.assign({}, process.env, { 'OPENSSL_CONF': CNF_FIPS_ON })); @@ -135,6 +145,7 @@ if (!sharedOpenSSL() && !common.hasOpenSSL3) { testHelper( 'stdout', [`--openssl-config=${CNF_FIPS_ON}`], + kNoFailure, testFipsCrypto() ? FIPS_ENABLED : FIPS_DISABLED, 'require("crypto").getFips()', Object.assign({}, process.env, { 'OPENSSL_CONF': CNF_FIPS_OFF })); @@ -148,6 +159,7 @@ if (!common.hasOpenSSL3) { testHelper( 'stdout', [`--openssl-config=${CNF_FIPS_OFF}`], + kNoFailure, FIPS_DISABLED, 'require("crypto").getFips()', Object.assign({}, process.env, { 'OPENSSL_CONF': CNF_FIPS_ON })); @@ -156,6 +168,7 @@ if (!common.hasOpenSSL3) { testHelper( testFipsCrypto() ? 'stdout' : 'stderr', ['--enable-fips', `--openssl-config=${CNF_FIPS_OFF}`], + testFipsCrypto() ? kNoFailure : kGenericUserError, testFipsCrypto() ? FIPS_ENABLED : FIPS_UNSUPPORTED_ERROR_STRING, 'require("crypto").getFips()', process.env); @@ -163,6 +176,7 @@ if (!common.hasOpenSSL3) { testHelper( testFipsCrypto() ? 'stdout' : 'stderr', ['--force-fips', `--openssl-config=${CNF_FIPS_OFF}`], + testFipsCrypto() ? kNoFailure : kGenericUserError, testFipsCrypto() ? FIPS_ENABLED : FIPS_UNSUPPORTED_ERROR_STRING, 'require("crypto").getFips()', process.env); @@ -170,6 +184,7 @@ if (!common.hasOpenSSL3) { testHelper( testFipsCrypto() ? 'stdout' : 'stderr', ['--enable-fips'], + testFipsCrypto() ? kNoFailure : kGenericUserError, testFipsCrypto() ? FIPS_ENABLED : FIPS_UNSUPPORTED_ERROR_STRING, 'require("crypto").getFips()', process.env); @@ -178,6 +193,7 @@ if (!common.hasOpenSSL3) { testHelper( testFipsCrypto() ? 'stdout' : 'stderr', ['--force-fips'], + testFipsCrypto() ? kNoFailure : kGenericUserError, testFipsCrypto() ? FIPS_ENABLED : FIPS_UNSUPPORTED_ERROR_STRING, 'require("crypto").getFips()', process.env); @@ -186,6 +202,7 @@ if (!common.hasOpenSSL3) { testHelper( testFipsCrypto() ? 'stdout' : 'stderr', ['--enable-fips'], + testFipsCrypto() ? kNoFailure : kGenericUserError, testFipsCrypto() ? FIPS_ENABLED : FIPS_UNSUPPORTED_ERROR_STRING, 'require("crypto").getFips()', Object.assign({}, process.env, { 'OPENSSL_CONF': CNF_FIPS_OFF })); @@ -194,6 +211,7 @@ if (!common.hasOpenSSL3) { testHelper( testFipsCrypto() ? 'stdout' : 'stderr', ['--force-fips'], + testFipsCrypto() ? kNoFailure : kGenericUserError, testFipsCrypto() ? FIPS_ENABLED : FIPS_UNSUPPORTED_ERROR_STRING, 'require("crypto").getFips()', Object.assign({}, process.env, { 'OPENSSL_CONF': CNF_FIPS_OFF })); @@ -202,6 +220,7 @@ if (!common.hasOpenSSL3) { testHelper( testFipsCrypto() ? 'stdout' : 'stderr', [], + testFipsCrypto() ? kNoFailure : kGenericUserError, testFipsCrypto() ? FIPS_ENABLED : FIPS_UNSUPPORTED_ERROR_STRING, '(require("crypto").setFips(true),' + 'require("crypto").getFips())', @@ -211,6 +230,7 @@ if (!common.hasOpenSSL3) { testHelper( testFipsCrypto() ? 'stdout' : 'stderr', [], + testFipsCrypto() ? kNoFailure : kGenericUserError, testFipsCrypto() ? FIPS_DISABLED : FIPS_UNSUPPORTED_ERROR_STRING, '(require("crypto").setFips(true),' + 'require("crypto").setFips(false),' + @@ -221,6 +241,7 @@ if (!common.hasOpenSSL3) { testHelper( testFipsCrypto() ? 'stdout' : 'stderr', [`--openssl-config=${CNF_FIPS_OFF}`], + testFipsCrypto() ? kNoFailure : kGenericUserError, testFipsCrypto() ? FIPS_ENABLED : FIPS_UNSUPPORTED_ERROR_STRING, '(require("crypto").setFips(true),' + 'require("crypto").getFips())', @@ -230,6 +251,7 @@ if (!common.hasOpenSSL3) { testHelper( 'stdout', [`--openssl-config=${CNF_FIPS_ON}`], + kNoFailure, FIPS_DISABLED, '(require("crypto").setFips(false),' + 'require("crypto").getFips())', @@ -239,6 +261,7 @@ if (!common.hasOpenSSL3) { testHelper( testFipsCrypto() ? 'stdout' : 'stderr', ['--enable-fips'], + testFipsCrypto() ? kNoFailure : kGenericUserError, testFipsCrypto() ? FIPS_DISABLED : FIPS_UNSUPPORTED_ERROR_STRING, '(require("crypto").setFips(false),' + 'require("crypto").getFips())', @@ -248,6 +271,7 @@ if (!common.hasOpenSSL3) { testHelper( 'stderr', ['--force-fips'], + kGenericUserError, testFipsCrypto() ? FIPS_ERROR_STRING2 : FIPS_UNSUPPORTED_ERROR_STRING, 'require("crypto").setFips(false)', process.env); @@ -256,6 +280,7 @@ if (!common.hasOpenSSL3) { testHelper( testFipsCrypto() ? 'stdout' : 'stderr', ['--force-fips'], + testFipsCrypto() ? kNoFailure : kGenericUserError, testFipsCrypto() ? FIPS_ENABLED : FIPS_UNSUPPORTED_ERROR_STRING, '(require("crypto").setFips(true),' + 'require("crypto").getFips())', @@ -265,6 +290,7 @@ if (!common.hasOpenSSL3) { testHelper( 'stderr', ['--force-fips', '--enable-fips'], + kGenericUserError, testFipsCrypto() ? FIPS_ERROR_STRING2 : FIPS_UNSUPPORTED_ERROR_STRING, 'require("crypto").setFips(false)', process.env); @@ -273,6 +299,7 @@ if (!common.hasOpenSSL3) { testHelper( 'stderr', ['--enable-fips', '--force-fips'], + kGenericUserError, testFipsCrypto() ? FIPS_ERROR_STRING2 : FIPS_UNSUPPORTED_ERROR_STRING, 'require("crypto").setFips(false)', process.env); diff --git a/test/parallel/test-crypto-hash.js b/test/parallel/test-crypto-hash.js index 8a946ac55ad..af2146982c7 100644 --- a/test/parallel/test-crypto-hash.js +++ b/test/parallel/test-crypto-hash.js @@ -7,7 +7,6 @@ const assert = require('assert'); const crypto = require('crypto'); const fs = require('fs'); -const { hasOpenSSL } = common; const fixtures = require('../common/fixtures'); let cryptoType; @@ -183,21 +182,19 @@ assert.throws( // Test XOF hash functions and the outputLength option. { - // Default outputLengths. Since OpenSSL 3.4 an outputLength is mandatory - if (!hasOpenSSL(3, 4)) { - assert.strictEqual(crypto.createHash('shake128').digest('hex'), - '7f9c2ba4e88f827d616045507605853e'); - assert.strictEqual(crypto.createHash('shake128', null).digest('hex'), - '7f9c2ba4e88f827d616045507605853e'); - assert.strictEqual(crypto.createHash('shake256').digest('hex'), - '46b9dd2b0ba88d13233b3feb743eeb24' + - '3fcd52ea62b81b82b50c27646ed5762f'); - assert.strictEqual(crypto.createHash('shake256', { outputLength: 0 }) - .copy() // Default outputLength. - .digest('hex'), - '46b9dd2b0ba88d13233b3feb743eeb24' + - '3fcd52ea62b81b82b50c27646ed5762f'); - } + // Default outputLengths. + assert.strictEqual(crypto.createHash('shake128').digest('hex'), + '7f9c2ba4e88f827d616045507605853e'); + assert.strictEqual(crypto.createHash('shake128', null).digest('hex'), + '7f9c2ba4e88f827d616045507605853e'); + assert.strictEqual(crypto.createHash('shake256').digest('hex'), + '46b9dd2b0ba88d13233b3feb743eeb24' + + '3fcd52ea62b81b82b50c27646ed5762f'); + assert.strictEqual(crypto.createHash('shake256', { outputLength: 0 }) + .copy() // Default outputLength. + .digest('hex'), + '46b9dd2b0ba88d13233b3feb743eeb24' + + '3fcd52ea62b81b82b50c27646ed5762f'); // Short outputLengths. assert.strictEqual(crypto.createHash('shake128', { outputLength: 0 }) diff --git a/test/parallel/test-crypto-oneshot-hash.js b/test/parallel/test-crypto-oneshot-hash.js index 69051c43d9e..56b4c04a65a 100644 --- a/test/parallel/test-crypto-oneshot-hash.js +++ b/test/parallel/test-crypto-oneshot-hash.js @@ -31,9 +31,6 @@ const methods = crypto.getHashes(); const input = fs.readFileSync(fixtures.path('utf8_test_text.txt')); for (const method of methods) { - // Skip failing tests on OpenSSL 3.4.0 - if (method.startsWith('shake') && common.hasOpenSSL(3, 4)) - continue; for (const outputEncoding of ['buffer', 'hex', 'base64', undefined]) { const oldDigest = crypto.createHash(method).update(input).digest(outputEncoding || 'hex'); const digestFromBuffer = crypto.hash(method, input, outputEncoding); diff --git a/test/parallel/test-debugger-exec.js b/test/parallel/test-debugger-exec.js index 51bc7497345..536e0128ea2 100644 --- a/test/parallel/test-debugger-exec.js +++ b/test/parallel/test-debugger-exec.js @@ -60,6 +60,11 @@ async function waitInitialBreak() { /\[ 'undefined', 'function' \]/, 'non-paused exec can see global but not module-scope values' ); + + // Ref: https://github.com/nodejs/node/issues/46808 + await cli.waitForPrompt(); + await cli.command('exec { a: 1 }'); + assert.match(cli.output, /\{ a: 1 \}/); } finally { await cli.quit(); } diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js index a6b3e459aa0..7d67b09d58f 100644 --- a/test/parallel/test-dns.js +++ b/test/parallel/test-dns.js @@ -415,7 +415,7 @@ assert.throws(() => { (answer) => Object.assign({ domain }, answer) ), }), port, address); - }, cases.length * 2 - 1)); + }, cases.length * 2)); server.bind(0, common.mustCall(() => { const address = server.address(); diff --git a/test/parallel/test-dotenv.js b/test/parallel/test-dotenv.js index 3c81bf98782..0115496875e 100644 --- a/test/parallel/test-dotenv.js +++ b/test/parallel/test-dotenv.js @@ -82,3 +82,5 @@ assert.strictEqual(process.env.DONT_EXPAND_SQUOTED, 'dontexpand\\nnewlines'); assert.strictEqual(process.env.EXPORT_EXAMPLE, 'ignore export'); // Ignore spaces before double quotes to avoid quoted strings as value assert.strictEqual(process.env.SPACE_BEFORE_DOUBLE_QUOTES, 'space before double quotes'); +assert.strictEqual(process.env.A, 'B=C'); +assert.strictEqual(process.env.B, 'C=D'); diff --git a/test/parallel/test-fs-internal-assertencoding.js b/test/parallel/test-fs-internal-assertencoding.js new file mode 100644 index 00000000000..ea88517b908 --- /dev/null +++ b/test/parallel/test-fs-internal-assertencoding.js @@ -0,0 +1,15 @@ +'use strict'; + +// Tests to verify that a correctly formatted invalid encoding error +// is thrown. Originally the internal assertEncoding utility was +// reversing the arguments when constructing the ERR_INVALID_ARG_VALUE +// error. + +require('../common'); +const { opendirSync } = require('node:fs'); +const { throws } = require('node:assert'); + +throws(() => opendirSync('.', { encoding: 'no' }), { + code: 'ERR_INVALID_ARG_VALUE', + message: 'The argument \'encoding\' is invalid encoding. Received \'no\'', +}); diff --git a/test/parallel/test-http-client-parse-error.js b/test/parallel/test-http-client-parse-error.js index 5d0ad4b1463..c2167aaabcf 100644 --- a/test/parallel/test-http-client-parse-error.js +++ b/test/parallel/test-http-client-parse-error.js @@ -47,7 +47,7 @@ server.listen(0, common.mustCall(() => { assert.strictEqual(req.socket.listenerCount('end'), 1); common.expectsError({ code: 'HPE_INVALID_CONSTANT', - message: 'Parse Error: Expected HTTP/' + message: 'Parse Error: Expected HTTP/, RTSP/ or ICE/' })(e); countdown.dec(); })); diff --git a/test/parallel/test-http-content-length-mismatch.js b/test/parallel/test-http-content-length-mismatch.js index 540acbe759d..2d4714694d8 100644 --- a/test/parallel/test-http-content-length-mismatch.js +++ b/test/parallel/test-http-content-length-mismatch.js @@ -78,3 +78,23 @@ function shouldThrowOnFewerBytes() { shouldThrowOnMoreBytes(); shouldNotThrow(); shouldThrowOnFewerBytes(); + + +{ + const server = http.createServer(common.mustCall((req, res) => { + res.strictContentLength = true; + // Pass content-length as string + res.setHeader('content-length', '5'); + res.end('12345'); + })); + + + server.listen(0, common.mustCall(() => { + http.get({ port: server.address().port }, common.mustCall((res) => { + res.resume().on('end', common.mustCall(() => { + assert.strictEqual(res.statusCode, 200); + server.close(); + })); + })); + })); +} diff --git a/test/parallel/test-http2-premature-close.js b/test/parallel/test-http2-premature-close.js index a9b08f55d8a..df30c429188 100644 --- a/test/parallel/test-http2-premature-close.js +++ b/test/parallel/test-http2-premature-close.js @@ -29,9 +29,9 @@ async function requestAndClose(server) { // Send a valid HEADERS frame const headersFrame = Buffer.concat([ Buffer.from([ - 0x00, 0x00, 0x0c, // Length: 12 bytes + 0x00, 0x00, 0x0e, // Length: 14 bytes 0x01, // Type: HEADERS - 0x05, // Flags: END_HEADERS + END_STREAM + 0x04, // Flags: END_HEADERS (streamId >> 24) & 0xFF, // Stream ID: high byte (streamId >> 16) & 0xFF, (streamId >> 8) & 0xFF, @@ -41,7 +41,7 @@ async function requestAndClose(server) { 0x82, // Indexed Header Field Representation (Predefined ":method: GET") 0x84, // Indexed Header Field Representation (Predefined ":path: /") 0x86, // Indexed Header Field Representation (Predefined ":scheme: http") - 0x44, 0x0a, // Custom ":authority: localhost" + 0x41, 0x09, // ":authority: localhost" Length: 9 bytes 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, ]), ]); diff --git a/test/parallel/test-permission-fs-internal-module-stat.js b/test/parallel/test-permission-fs-internal-module-stat.js new file mode 100644 index 00000000000..68e02f7f963 --- /dev/null +++ b/test/parallel/test-permission-fs-internal-module-stat.js @@ -0,0 +1,19 @@ +// Flags: --expose-internals --experimental-permission --allow-fs-read=test/common* --allow-fs-read=tools* --allow-fs-read=test/parallel* --allow-child-process +'use strict'; + +const common = require('../common'); +common.skipIfWorker(); + +if (!common.hasCrypto) { + common.skip('no crypto'); +} + +const { internalBinding } = require('internal/test/binding'); +const fixtures = require('../common/fixtures'); + +const blockedFile = fixtures.path('permission', 'deny', 'protected-file.md'); +const internalFsBinding = internalBinding('fs'); + +{ + internalFsBinding.internalModuleStat(blockedFile); +} diff --git a/test/parallel/test-permission-fs-require.js b/test/parallel/test-permission-fs-require.js new file mode 100644 index 00000000000..6a2e9201dac --- /dev/null +++ b/test/parallel/test-permission-fs-require.js @@ -0,0 +1,76 @@ +// Flags: --experimental-permission --allow-fs-read=* --allow-child-process +'use strict'; + +const common = require('../common'); +common.skipIfWorker(); +const fixtures = require('../common/fixtures'); + +const assert = require('node:assert'); +const { spawnSync } = require('node:child_process'); + +{ + const mainModule = fixtures.path('permission', 'main-module.js'); + const requiredModule = fixtures.path('permission', 'required-module.js'); + const { status, stdout, stderr } = spawnSync( + process.execPath, + [ + '--experimental-permission', + '--allow-fs-read', mainModule, + '--allow-fs-read', requiredModule, + mainModule, + ] + ); + + assert.strictEqual(status, 0, stderr.toString()); + assert.strictEqual(stdout.toString(), 'ok\n'); +} + +{ + // When required module is not passed as allowed path + const mainModule = fixtures.path('permission', 'main-module.js'); + const { status, stderr } = spawnSync( + process.execPath, + [ + '--experimental-permission', + '--allow-fs-read', mainModule, + mainModule, + ] + ); + + assert.strictEqual(status, 1, stderr.toString()); + assert.match(stderr.toString(), /Error: Access to this API has been restricted/); +} + +{ + // ESM loader test + const mainModule = fixtures.path('permission', 'main-module.mjs'); + const requiredModule = fixtures.path('permission', 'required-module.mjs'); + const { status, stdout, stderr } = spawnSync( + process.execPath, + [ + '--experimental-permission', + '--allow-fs-read', mainModule, + '--allow-fs-read', requiredModule, + mainModule, + ] + ); + + assert.strictEqual(status, 0, stderr.toString()); + assert.strictEqual(stdout.toString(), 'ok\n'); +} + +{ + // When required module is not passed as allowed path (ESM) + const mainModule = fixtures.path('permission', 'main-module.mjs'); + const { status, stderr } = spawnSync( + process.execPath, + [ + '--experimental-permission', + '--allow-fs-read', mainModule, + mainModule, + ] + ); + + assert.strictEqual(status, 1, stderr.toString()); + assert.match(stderr.toString(), /Error: Access to this API has been restricted/); +} diff --git a/test/parallel/test-process-versions.js b/test/parallel/test-process-versions.js index 4be85458c48..ecb6047b04a 100644 --- a/test/parallel/test-process-versions.js +++ b/test/parallel/test-process-versions.js @@ -4,7 +4,7 @@ const assert = require('assert'); // Import of pure js (non-shared) deps for comparison const acorn = require('../../deps/acorn/acorn/package.json'); -const cjs_module_lexer = require('../../deps/cjs-module-lexer/package.json'); +const cjs_module_lexer = require('../../deps/cjs-module-lexer/src/package.json'); const expected_keys = [ 'ares', diff --git a/test/parallel/test-readline-promises-interface.js b/test/parallel/test-readline-promises-interface.js index b7ce0c4ff20..a984bd20ed9 100644 --- a/test/parallel/test-readline-promises-interface.js +++ b/test/parallel/test-readline-promises-interface.js @@ -948,6 +948,22 @@ for (let i = 0; i < 12; i++) { rli.close(); } + // Aborting a question with ctrl+C + { + const [rli, fi] = getInterface({ terminal: true }); + assert.rejects(rli.question('hello?'), { name: 'AbortError' }) + .then(common.mustCall()); + fi.emit('keypress', '.', { ctrl: true, name: 'c' }); + } + + // Aborting a question with ctrl+D + { + const [rli, fi] = getInterface({ terminal: true }); + assert.rejects(rli.question('hello?'), { name: 'AbortError' }) + .then(common.mustCall()); + fi.emit('keypress', '.', { ctrl: true, name: 'd' }); + } + (async () => { const [rli] = getInterface({ terminal }); const signal = AbortSignal.abort('boom'); diff --git a/test/parallel/test-repl-tab-complete-computed-props.js b/test/parallel/test-repl-tab-complete-computed-props.js new file mode 100644 index 00000000000..830da99b4c3 --- /dev/null +++ b/test/parallel/test-repl-tab-complete-computed-props.js @@ -0,0 +1,130 @@ +'use strict'; + +const common = require('../common'); +const ArrayStream = require('../common/arraystream'); +const { describe, it, before, after } = require('node:test'); +const assert = require('assert'); + +const repl = require('repl'); + +function prepareREPL() { + const input = new ArrayStream(); + const replServer = repl.start({ + prompt: '', + input, + output: process.stdout, + allowBlockingCompletions: true, + }); + + // Some errors are passed to the domain, but do not callback + replServer._domain.on('error', assert.ifError); + + return { replServer, input }; +} + +function testCompletion(replServer, { input, expectedCompletions }) { + replServer.complete( + input, + common.mustCall((_error, data) => { + assert.deepStrictEqual(data, [expectedCompletions, input]); + }), + ); +} + +describe('REPL tab object completion on computed properties', () => { + describe('simple string cases', () => { + let replServer; + + before(() => { + const { replServer: server, input } = prepareREPL(); + replServer = server; + + input.run([ + ` + const obj = { + one: 1, + innerObj: { two: 2 }, + 'inner object': { three: 3 }, + }; + + const oneStr = 'one'; + `, + ]); + }); + + after(() => { + replServer.close(); + }); + + it('works with double quoted strings', () => testCompletion(replServer, { + input: 'obj["one"].toFi', + expectedCompletions: ['obj["one"].toFixed'], + })); + + it('works with single quoted strings', () => testCompletion(replServer, { + input: "obj['one'].toFi", + expectedCompletions: ["obj['one'].toFixed"], + })); + + it('works with template strings', () => testCompletion(replServer, { + input: 'obj[`one`].toFi', + expectedCompletions: ['obj[`one`].toFixed'], + })); + + it('works with nested objects', () => { + testCompletion(replServer, { + input: 'obj["innerObj"].tw', + expectedCompletions: ['obj["innerObj"].two'], + }); + testCompletion(replServer, { + input: 'obj["innerObj"].two.tofi', + expectedCompletions: ['obj["innerObj"].two.toFixed'], + }); + }); + + it('works with nested objects combining different type of strings', () => testCompletion(replServer, { + input: 'obj["innerObj"][`two`].tofi', + expectedCompletions: ['obj["innerObj"][`two`].toFixed'], + })); + + it('works with strings with spaces', () => testCompletion(replServer, { + input: 'obj["inner object"].th', + expectedCompletions: ['obj["inner object"].three'], + })); + }); + + describe('variables as indexes', () => { + let replServer; + + before(() => { + const { replServer: server, input } = prepareREPL(); + replServer = server; + + input.run([ + ` + const oneStr = 'One'; + const helloWorldStr = 'Hello' + ' ' + 'World'; + + const obj = { + [oneStr]: 1, + ['Hello World']: 'hello world!', + }; + `, + ]); + }); + + after(() => { + replServer.close(); + }); + + it('works with a simple variable', () => testCompletion(replServer, { + input: 'obj[oneStr].toFi', + expectedCompletions: ['obj[oneStr].toFixed'], + })); + + it('works with a computed variable', () => testCompletion(replServer, { + input: 'obj[helloWorldStr].tolocaleup', + expectedCompletions: ['obj[helloWorldStr].toLocaleUpperCase'], + })); + }); +}); diff --git a/test/parallel/test-require-resolve-invalid-paths.js b/test/parallel/test-require-resolve-invalid-paths.js new file mode 100644 index 00000000000..efe929d0c30 --- /dev/null +++ b/test/parallel/test-require-resolve-invalid-paths.js @@ -0,0 +1,18 @@ +'use strict'; + +require('../common'); +const assert = require('assert'); + +// Test invalid `paths` entries: Ensure non-string entries throw an error +{ + const paths = [1, false, null, undefined, () => {}, {}]; + paths.forEach((value) => { + assert.throws( + () => require.resolve('.', { paths: [value] }), + { + name: 'TypeError', + code: 'ERR_INVALID_ARG_TYPE', + } + ); + }); +} diff --git a/test/parallel/test-runner-source-maps-invalid-json.js b/test/parallel/test-runner-source-maps-invalid-json.js new file mode 100644 index 00000000000..508e2d43211 --- /dev/null +++ b/test/parallel/test-runner-source-maps-invalid-json.js @@ -0,0 +1,12 @@ +// Flags: --enable-source-maps +'use strict'; + +require('../common'); +const test = require('node:test'); + +// Verify that test runner can handle invalid source maps. + +test('ok', () => {}); + +// eslint-disable-next-line @stylistic/js/spaced-comment +//# sourceMappingURL=data:application/json;base64,-1 diff --git a/test/parallel/test-util-format.js b/test/parallel/test-util-format.js index 8d2cab5a9c7..9d6419b6608 100644 --- a/test/parallel/test-util-format.js +++ b/test/parallel/test-util-format.js @@ -290,6 +290,68 @@ assert.strictEqual(util.format('%s', -Infinity), '-Infinity'); assert.strictEqual(util.format('%s', objectWithToPrimitive + ''), 'default context'); } +// built-in toPrimitive is the same behavior as inspect +{ + const date = new Date('2023-10-01T00:00:00Z'); + assert.strictEqual(util.format('%s', date), util.inspect(date)); + + const symbol = Symbol('foo'); + assert.strictEqual(util.format('%s', symbol), util.inspect(symbol)); +} + +// Prototype chain handling for toString +{ + function hasToStringButNoToPrimitive() {} + + hasToStringButNoToPrimitive.prototype.toString = function() { + return 'hasToStringButNoToPrimitive'; + }; + + let obj = new hasToStringButNoToPrimitive(); + assert.strictEqual(util.format('%s', obj.toString()), 'hasToStringButNoToPrimitive'); + + function inheritsFromHasToStringButNoToPrimitive() {} + Object.setPrototypeOf(inheritsFromHasToStringButNoToPrimitive.prototype, + hasToStringButNoToPrimitive.prototype); + obj = new inheritsFromHasToStringButNoToPrimitive(); + assert.strictEqual(util.format('%s', obj.toString()), 'hasToStringButNoToPrimitive'); +} + +// Prototype chain handling for Symbol.toPrimitive +{ + function hasToPrimitiveButNoToString() {} + + hasToPrimitiveButNoToString.prototype[Symbol.toPrimitive] = function() { + return 'hasToPrimitiveButNoToString'; + }; + + let obj = new hasToPrimitiveButNoToString(); + assert.strictEqual(util.format('%s', obj[Symbol.toPrimitive]()), 'hasToPrimitiveButNoToString'); + function inheritsFromHasToPrimitiveButNoToString() {} + Object.setPrototypeOf(inheritsFromHasToPrimitiveButNoToString.prototype, + hasToPrimitiveButNoToString.prototype); + obj = new inheritsFromHasToPrimitiveButNoToString(); + assert.strictEqual(util.format('%s', obj[Symbol.toPrimitive]()), 'hasToPrimitiveButNoToString'); +} + +// Prototype chain handling for both toString and Symbol.toPrimitive +{ + function hasBothToStringAndToPrimitive() {} + hasBothToStringAndToPrimitive.prototype.toString = function() { + return 'toString'; + }; + hasBothToStringAndToPrimitive.prototype[Symbol.toPrimitive] = function() { + return 'toPrimitive'; + }; + let obj = new hasBothToStringAndToPrimitive(); + assert.strictEqual(util.format('%s', obj.toString()), 'toString'); + function inheritsFromHasBothToStringAndToPrimitive() {} + Object.setPrototypeOf(inheritsFromHasBothToStringAndToPrimitive.prototype, + hasBothToStringAndToPrimitive.prototype); + obj = new inheritsFromHasBothToStringAndToPrimitive(); + assert.strictEqual(util.format('%s', obj.toString()), 'toString'); +} + // JSON format specifier assert.strictEqual(util.format('%j'), '%j'); assert.strictEqual(util.format('%j', 42), '42'); diff --git a/test/parallel/test-util-parse-env.js b/test/parallel/test-util-parse-env.js index 13d2fda37a0..80ab736dd38 100644 --- a/test/parallel/test-util-parse-env.js +++ b/test/parallel/test-util-parse-env.js @@ -11,6 +11,8 @@ const fs = require('node:fs'); const validContent = fs.readFileSync(validEnvFilePath, 'utf8'); assert.deepStrictEqual(util.parseEnv(validContent), { + A: 'B=C', + B: 'C=D', AFTER_LINE: 'after_line', BACKTICKS: 'backticks', BACKTICKS_INSIDE_DOUBLE: '`backticks` work inside double quotes', diff --git a/test/parallel/test-vm-module-dynamic-import-promise.js b/test/parallel/test-vm-module-dynamic-import-promise.js new file mode 100644 index 00000000000..63493212cd3 --- /dev/null +++ b/test/parallel/test-vm-module-dynamic-import-promise.js @@ -0,0 +1,135 @@ +// Flags: --experimental-vm-modules +'use strict'; + +const common = require('../common'); + +const assert = require('assert'); +const { createContext, Script, SourceTextModule } = require('vm'); + +// Verifies that a `import` call returns a promise created in the context +// where the `import` was called, not the context of `importModuleDynamically` +// callback. + +async function testScript() { + const ctx = createContext(); + + const mod1 = new SourceTextModule('export const a = 1;', { + context: ctx, + }); + // No import statements, so must not link statically. + await mod1.link(common.mustNotCall()); + + const script2 = new Script(` + const promise = import("mod1"); + if (Object.getPrototypeOf(promise) !== Promise.prototype) { + throw new Error('Expected promise to be created in the current context'); + } + globalThis.__result = promise; + `, { + importModuleDynamically: common.mustCall((specifier, referrer) => { + assert.strictEqual(specifier, 'mod1'); + assert.strictEqual(referrer, script2); + return mod1; + }), + }); + script2.runInContext(ctx); + + // Wait for the promise to resolve. + await ctx.__result; +} + +async function testScriptImportFailed() { + const ctx = createContext(); + + const mod1 = new SourceTextModule('export const a = 1;', { + context: ctx, + }); + // No import statements, so must not link statically. + await mod1.link(common.mustNotCall()); + + const err = new Error('import failed'); + const script2 = new Script(` + const promise = import("mod1"); + if (Object.getPrototypeOf(promise) !== Promise.prototype) { + throw new Error('Expected promise to be created in the current context'); + } + globalThis.__result = promise; + `, { + importModuleDynamically: common.mustCall((specifier, referrer) => { + throw err; + }), + }); + script2.runInContext(ctx); + + // Wait for the promise to reject. + await assert.rejects(ctx.__result, err); +} + +async function testModule() { + const ctx = createContext(); + + const mod1 = new SourceTextModule('export const a = 1;', { + context: ctx, + }); + // No import statements, so must not link statically. + await mod1.link(common.mustNotCall()); + + const mod2 = new SourceTextModule(` + const promise = import("mod1"); + if (Object.getPrototypeOf(promise) !== Promise.prototype) { + throw new Error('Expected promise to be created in the current context'); + } + await promise; + `, { + context: ctx, + importModuleDynamically: common.mustCall((specifier, referrer) => { + assert.strictEqual(specifier, 'mod1'); + assert.strictEqual(referrer, mod2); + return mod1; + }), + }); + // No import statements, so must not link statically. + await mod2.link(common.mustNotCall()); + await mod2.evaluate(); +} + +async function testModuleImportFailed() { + const ctx = createContext(); + + const mod1 = new SourceTextModule('export const a = 1;', { + context: ctx, + }); + // No import statements, so must not link statically. + await mod1.link(common.mustNotCall()); + + const err = new Error('import failed'); + ctx.__err = err; + const mod2 = new SourceTextModule(` + const promise = import("mod1"); + if (Object.getPrototypeOf(promise) !== Promise.prototype) { + throw new Error('Expected promise to be created in the current context'); + } + await promise.then(() => { + throw new Error('Expected promise to be rejected'); + }, (e) => { + if (e !== globalThis.__err) { + throw new Error('Expected promise to be rejected with "import failed"'); + } + }); + `, { + context: ctx, + importModuleDynamically: common.mustCall((specifier, referrer) => { + throw err; + }), + }); + // No import statements, so must not link statically. + await mod2.link(common.mustNotCall()); + await mod2.evaluate(); +} + +Promise.all([ + testScript(), + testScriptImportFailed(), + testModule(), + testModuleImportFailed(), +]).then(common.mustCall()); diff --git a/test/sequential/test-heapdump.js b/test/sequential/test-heapdump.js index 1388623e61f..ee025f57fb8 100644 --- a/test/sequential/test-heapdump.js +++ b/test/sequential/test-heapdump.js @@ -8,6 +8,7 @@ if (!common.isMainThread) const { writeHeapSnapshot, getHeapSnapshot } = require('v8'); const assert = require('assert'); const fs = require('fs'); +const { promises: { pipeline }, PassThrough } = require('stream'); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); @@ -76,3 +77,13 @@ process.chdir(tmpdir.path); JSON.parse(data); })); } + +{ + const passthrough = new PassThrough(); + passthrough.on('data', common.mustCallAtLeast(1)); + + pipeline( + getHeapSnapshot(), + passthrough, + ).then(common.mustCall()); +} diff --git a/tools/dep_updaters/update-cjs-module-lexer.sh b/tools/dep_updaters/update-cjs-module-lexer.sh index 44167e2f93e..1d12546ab45 100755 --- a/tools/dep_updaters/update-cjs-module-lexer.sh +++ b/tools/dep_updaters/update-cjs-module-lexer.sh @@ -27,7 +27,8 @@ console.log(name); EOF )" -CURRENT_VERSION=$("$NODE" -p "require('./deps/cjs-module-lexer/package.json').version") + +CURRENT_VERSION=$("$NODE" -p "require('./deps/cjs-module-lexer/src/package.json').version") # This function exit with 0 if new version and current version are the same compare_dependency_version "cjs-module-lexer" "$NEW_VERSION" "$CURRENT_VERSION" @@ -44,15 +45,53 @@ cleanup () { trap cleanup INT TERM EXIT -cd "$WORKSPACE" - -"$NODE" "$NPM" init --yes +CJS_MODULE_LEXER_ZIP="cjs-module-lexer-$NEW_VERSION" -"$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts "cjs-module-lexer@$NEW_VERSION" +# remove existing source and built files +rm -rf "$DEPS_DIR/cjs-module-lexer/src" +rm -rf "$DEPS_DIR/cjs-module-lexer/dist" +rm "$DEPS_DIR/cjs-module-lexer/lexer.js" -rm -rf "$DEPS_DIR/cjs-module-lexer" +cd "$WORKSPACE" -mv node_modules/cjs-module-lexer "$DEPS_DIR/cjs-module-lexer" +curl -sL -o "$CJS_MODULE_LEXER_ZIP.zip" "https://github.com/nodejs/cjs-module-lexer/archive/refs/tags/$NEW_VERSION.zip" + +log_and_verify_sha256sum "cjs-module-lexer" "$CJS_MODULE_LEXER_ZIP.zip" + +echo "Unzipping..." +unzip "$CJS_MODULE_LEXER_ZIP.zip" -d "src" +mv "src/$CJS_MODULE_LEXER_ZIP" "$DEPS_DIR/cjs-module-lexer/src" +rm "$CJS_MODULE_LEXER_ZIP.zip" +cd "$ROOT" + +( + # remove components we don't need to keep in nodejs/deps + # these are files that we don't need to build from source + cd "$DEPS_DIR/cjs-module-lexer/src" + rm -rf bench + rm -rf .github || true + rm -rf test + rm .gitignore + rm .travis.yml + rm CODE_OF_CONDUCT.md + rm CONTRIBUTING.md + + # Rebuild components from source + rm lib/*.* + "$NODE" "$NPM" install --ignore-scripts + "$NODE" "$NPM" run build-wasm + "$NODE" "$NPM" run build + "$NODE" "$NPM" prune --production + + # remove files we don't need in Node.js + rm -rf node_modules + + # copy over the built files to the expected locations + mv dist .. + cp lexer.js .. + cp LICENSE .. + cp README.md .. +) # update cjs_module_lexer_version.h cat > "$BASE_DIR/src/cjs_module_lexer_version.h" << EOL diff --git a/tools/install.py b/tools/install.py index c14c418f325..d964d5a2efe 100755 --- a/tools/install.py +++ b/tools/install.py @@ -232,9 +232,19 @@ def files(options, action): link_path = abspath(options.install_path, 'lib/libnode.so') try_symlink(options, so_name, link_path) else: - output_lib = 'libnode.' + options.variables.get('shlib_suffix') - action(options, [os.path.join(options.build_dir, output_lib)], - os.path.join(options.variables.get('libdir'), output_lib)) + # Ninja and Makefile generators output the library in different directories; + # find out which one we have, and install first found + output_lib_name = 'libnode.' + options.variables.get('shlib_suffix') + output_lib_candidate_paths = [ + os.path.join(options.build_dir, output_lib_name), + os.path.join(options.build_dir, "lib", output_lib_name), + ] + try: + output_lib = next(filter(os.path.exists, output_lib_candidate_paths)) + except StopIteration as not_found: + raise RuntimeError("No libnode.so to install!") from not_found + action(options, [output_lib], + os.path.join(options.variables.get('libdir'), output_lib_name)) if not options.is_win: # Install nsolid -> node compatibility symlink. diff --git a/tools/v8_gypfiles/features.gypi b/tools/v8_gypfiles/features.gypi index c768d7a0f13..45700e940c9 100644 --- a/tools/v8_gypfiles/features.gypi +++ b/tools/v8_gypfiles/features.gypi @@ -253,6 +253,11 @@ # Sets -DV8_ENABLE_SANDBOX. 'v8_enable_sandbox%': 0, + # Enable support for external code range relative to the pointer compression + # cage. + # Sets -DV8_EXTERNAL_CODE_SPACE. + 'v8_enable_external_code_space%': 0, + # Experimental feature for collecting per-class zone memory stats. # Requires use_rtti = true 'v8_enable_precise_zone_stats%': 0, @@ -371,6 +376,9 @@ ['v8_enable_sandbox==1', { 'defines': ['V8_ENABLE_SANDBOX',], }], + ['v8_enable_external_code_space==1', { + 'defines': ['V8_EXTERNAL_CODE_SPACE',], + }], ['v8_enable_object_print==1', { 'defines': ['OBJECT_PRINT',], }],