Commit 7100dcf7 authored by mark burdett's avatar mark burdett
Browse files

Issue #3292570 by mfb: Create new release branch with Sentry JS 7.x

Verify bundle against published release hashes
parent 767fbde1
Loading
Loading
Loading
Loading
+2 −2

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+76 −20
Original line number Diff line number Diff line
@@ -3,25 +3,81 @@
 * Installs @sentry/browser and updates library version.
 */

const Bourne = require('@hapi/bourne');
const crypto = require('crypto');
const fs = require('fs');
const got = require('got');
const stream = require('stream');
const pipeline = require('util').promisify(stream.pipeline);
const process = require('process');
const yaml = require('js-yaml');
const fs = require('fs').promises;

const copyJs = fs.copyFile('node_modules/@sentry/tracing/build/bundle.tracing.min.js', 'js/bundle.tracing.min.js');
const copyMap = fs.copyFile('node_modules/@sentry/tracing/build/bundle.tracing.min.js.map', 'js/bundle.tracing.min.js.map');

let libraries;
const readYaml = fs.readFile('raven.libraries.yml', 'utf8')
  .then((contents) => { libraries = yaml.load(contents); });

let version;
const readJson = fs.readFile('package-lock.json', 'utf8')
  .then((contents) => { version = JSON.parse(contents).dependencies['@sentry/tracing'].version; });

const updateVersion = Promise.all([readYaml, readJson])
  .then(() => { libraries['sentry-browser'].version = version; });

const writeVersion = Promise.all([updateVersion])
  .then(() => fs.writeFile('raven.libraries.yml', yaml.dump(libraries)));

Promise.all([copyJs, copyMap, writeVersion])
  .then(() => console.log('Achievement unlocked.'));
const readJson = fs.promises.readFile('package-lock.json')
  .then((contents) => version = JSON.parse(contents).dependencies['@sentry/tracing'].version);
const librariesFile = 'raven.libraries.yml';
let libraries;
const readYaml = fs.promises.readFile(librariesFile)
  .then((contents) => libraries = yaml.load(contents));
Promise.all([readJson, readYaml])
  .then(() => {
    libraries['sentry-browser'].version = version;
    const writeVersion = fs.promises.writeFile(librariesFile, yaml.dump(libraries));
    const destination = 'js/';
    const jsFile = 'bundle.tracing.min.js';
    const url = ['https://browser.sentry-cdn.com', version, jsFile].join('/');
    const jsHash = crypto.createHash('sha384');
    const mapHash = crypto.createHash('sha384');
    const fetchJs = pipeline(
      got.stream(url),
      new stream.Transform({
        transform(data, encoding, callback) {
          jsHash.update(data);
          this.push(data);
          callback();
        }
      }),
      fs.createWriteStream(destination + jsFile)
    );
    const mapSuffix = '.map';
    const fetchMap = pipeline(
      got.stream(url + mapSuffix),
      new stream.Transform({
        transform(data, encoding, callback) {
          mapHash.update(data);
          this.push(data);
          callback();
        }
      }),
      fs.createWriteStream(destination + jsFile + mapSuffix)
    );
    const releaseUrl = ['https://release-registry.services.sentry.io/sdks/sentry.javascript.browser', version].join('/');
    let releaseData;
    const fetchReleaseData = got(releaseUrl, {
      parseJson: text => Bourne.parse(text)
    }).json()
      .then((parsed) => releaseData = parsed);
    Promise.all([fetchJs, fetchMap, writeVersion, fetchReleaseData])
      .then(() => {
        const calculatedJsHash = jsHash.digest('base64');
        const calculatedMapHash = mapHash.digest('base64');
        const publishedJsHash = releaseData.files[jsFile].checksums['sha384-base64'];
        const publishedMapHash = releaseData.files[jsFile + mapSuffix].checksums['sha384-base64'];
        console.log('Verifying ' + jsFile + '...');
        console.log('calculated: ' + calculatedJsHash);
        console.log(' published: ' + publishedJsHash);
        if (calculatedJsHash !== publishedJsHash) {
          throw new Error('Hash mismatch!');
        }
        console.log('Verifying ' + jsFile + mapSuffix + '...');
        console.log('calculated: ' + calculatedMapHash);
        console.log(' published: ' + publishedMapHash);
        if (calculatedMapHash !== publishedMapHash) {
          throw new Error('Hash mismatch!');
        }
        console.log('Achievement unlocked.');
      })
      .catch(error => {
        console.error(error.message);
        process.exit(1);
      });
  });
+54 −68
Original line number Diff line number Diff line
@@ -8,74 +8,66 @@
      "hasInstallScript": true,
      "license": "GPL-2.0-or-later",
      "devDependencies": {
        "@sentry/tracing": "^6.3.5",
        "@hapi/bourne": "^3.0.0",
        "@sentry/tracing": "^7.7.0",
        "js-yaml": "^4.1.0"
      }
    },
    "node_modules/@sentry/hub": {
      "version": "6.19.7",
      "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-6.19.7.tgz",
      "integrity": "sha512-y3OtbYFAqKHCWezF0EGGr5lcyI2KbaXW2Ik7Xp8Mu9TxbSTuwTe4rTntwg8ngPjUQU3SUHzgjqVB8qjiGqFXCA==",
      "dev": true,
      "dependencies": {
        "@sentry/types": "6.19.7",
        "@sentry/utils": "6.19.7",
        "tslib": "^1.9.3"
      },
      "engines": {
        "node": ">=6"
      }
    "node_modules/@hapi/bourne": {
      "version": "3.0.0",
      "resolved": "https://registry.npmjs.org/@hapi/bourne/-/bourne-3.0.0.tgz",
      "integrity": "sha512-Waj1cwPXJDucOib4a3bAISsKJVb15MKi9IvmTI/7ssVEm6sywXGjVJDhl6/umt1pK1ZS7PacXU3A1PmFKHEZ2w==",
      "dev": true
    },
    "node_modules/@sentry/minimal": {
      "version": "6.19.7",
      "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-6.19.7.tgz",
      "integrity": "sha512-wcYmSJOdvk6VAPx8IcmZgN08XTXRwRtB1aOLZm+MVHjIZIhHoBGZJYTVQS/BWjldsamj2cX3YGbGXNunaCfYJQ==",
    "node_modules/@sentry/hub": {
      "version": "7.7.0",
      "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-7.7.0.tgz",
      "integrity": "sha512-6gydK234+a0nKhBRDdIJ7Dp42CaiW2juTiHegUVDq+482balVzbZyEAmESCmuzKJhx5BhlCElVxs/cci1NjMpg==",
      "dev": true,
      "dependencies": {
        "@sentry/hub": "6.19.7",
        "@sentry/types": "6.19.7",
        "@sentry/types": "7.7.0",
        "@sentry/utils": "7.7.0",
        "tslib": "^1.9.3"
      },
      "engines": {
        "node": ">=6"
        "node": ">=8"
      }
    },
    "node_modules/@sentry/tracing": {
      "version": "6.19.7",
      "resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-6.19.7.tgz",
      "integrity": "sha512-ol4TupNnv9Zd+bZei7B6Ygnr9N3Gp1PUrNI761QSlHtPC25xXC5ssSD3GMhBgyQrcvpuRcCFHVNNM97tN5cZiA==",
      "version": "7.7.0",
      "resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-7.7.0.tgz",
      "integrity": "sha512-HNmvTwemuc21q/K6HXsSp9njkne6N1JQ71TB+QGqYU5VtxsVgYSUhhYqV6WcHz7LK4Hj6TvNFoeu69/rO0ysgw==",
      "dev": true,
      "dependencies": {
        "@sentry/hub": "6.19.7",
        "@sentry/minimal": "6.19.7",
        "@sentry/types": "6.19.7",
        "@sentry/utils": "6.19.7",
        "@sentry/hub": "7.7.0",
        "@sentry/types": "7.7.0",
        "@sentry/utils": "7.7.0",
        "tslib": "^1.9.3"
      },
      "engines": {
        "node": ">=6"
        "node": ">=8"
      }
    },
    "node_modules/@sentry/types": {
      "version": "6.19.7",
      "resolved": "https://registry.npmjs.org/@sentry/types/-/types-6.19.7.tgz",
      "integrity": "sha512-jH84pDYE+hHIbVnab3Hr+ZXr1v8QABfhx39KknxqKWr2l0oEItzepV0URvbEhB446lk/S/59230dlUUIBGsXbg==",
      "version": "7.7.0",
      "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.7.0.tgz",
      "integrity": "sha512-4x8O7uerSGLnYC10krHl9t8h7xXHn5FextqKYbTCXCnx2hC8D+9lz8wcbQAFo0d97wiUYqI8opmEgFVGx7c5hQ==",
      "dev": true,
      "engines": {
        "node": ">=6"
        "node": ">=8"
      }
    },
    "node_modules/@sentry/utils": {
      "version": "6.19.7",
      "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-6.19.7.tgz",
      "integrity": "sha512-z95ECmE3i9pbWoXQrD/7PgkBAzJYR+iXtPuTkpBjDKs86O3mT+PXOT3BAn79w2wkn7/i3vOGD2xVr1uiMl26dA==",
      "version": "7.7.0",
      "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.7.0.tgz",
      "integrity": "sha512-fD+ROSFpeJlK7bEvUT2LOW7QqgjBpXJwVISKZ0P2fuzclRC3KoB2pbZgBM4PXMMTiSzRGWhvfRRjBiBvQJBBJQ==",
      "dev": true,
      "dependencies": {
        "@sentry/types": "6.19.7",
        "@sentry/types": "7.7.0",
        "tslib": "^1.9.3"
      },
      "engines": {
        "node": ">=6"
        "node": ">=8"
      }
    },
    "node_modules/argparse": {
@@ -104,54 +96,48 @@
    }
  },
  "dependencies": {
    "@sentry/hub": {
      "version": "6.19.7",
      "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-6.19.7.tgz",
      "integrity": "sha512-y3OtbYFAqKHCWezF0EGGr5lcyI2KbaXW2Ik7Xp8Mu9TxbSTuwTe4rTntwg8ngPjUQU3SUHzgjqVB8qjiGqFXCA==",
      "dev": true,
      "requires": {
        "@sentry/types": "6.19.7",
        "@sentry/utils": "6.19.7",
        "tslib": "^1.9.3"
      }
    "@hapi/bourne": {
      "version": "3.0.0",
      "resolved": "https://registry.npmjs.org/@hapi/bourne/-/bourne-3.0.0.tgz",
      "integrity": "sha512-Waj1cwPXJDucOib4a3bAISsKJVb15MKi9IvmTI/7ssVEm6sywXGjVJDhl6/umt1pK1ZS7PacXU3A1PmFKHEZ2w==",
      "dev": true
    },
    "@sentry/minimal": {
      "version": "6.19.7",
      "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-6.19.7.tgz",
      "integrity": "sha512-wcYmSJOdvk6VAPx8IcmZgN08XTXRwRtB1aOLZm+MVHjIZIhHoBGZJYTVQS/BWjldsamj2cX3YGbGXNunaCfYJQ==",
    "@sentry/hub": {
      "version": "7.7.0",
      "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-7.7.0.tgz",
      "integrity": "sha512-6gydK234+a0nKhBRDdIJ7Dp42CaiW2juTiHegUVDq+482balVzbZyEAmESCmuzKJhx5BhlCElVxs/cci1NjMpg==",
      "dev": true,
      "requires": {
        "@sentry/hub": "6.19.7",
        "@sentry/types": "6.19.7",
        "@sentry/types": "7.7.0",
        "@sentry/utils": "7.7.0",
        "tslib": "^1.9.3"
      }
    },
    "@sentry/tracing": {
      "version": "6.19.7",
      "resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-6.19.7.tgz",
      "integrity": "sha512-ol4TupNnv9Zd+bZei7B6Ygnr9N3Gp1PUrNI761QSlHtPC25xXC5ssSD3GMhBgyQrcvpuRcCFHVNNM97tN5cZiA==",
      "version": "7.7.0",
      "resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-7.7.0.tgz",
      "integrity": "sha512-HNmvTwemuc21q/K6HXsSp9njkne6N1JQ71TB+QGqYU5VtxsVgYSUhhYqV6WcHz7LK4Hj6TvNFoeu69/rO0ysgw==",
      "dev": true,
      "requires": {
        "@sentry/hub": "6.19.7",
        "@sentry/minimal": "6.19.7",
        "@sentry/types": "6.19.7",
        "@sentry/utils": "6.19.7",
        "@sentry/hub": "7.7.0",
        "@sentry/types": "7.7.0",
        "@sentry/utils": "7.7.0",
        "tslib": "^1.9.3"
      }
    },
    "@sentry/types": {
      "version": "6.19.7",
      "resolved": "https://registry.npmjs.org/@sentry/types/-/types-6.19.7.tgz",
      "integrity": "sha512-jH84pDYE+hHIbVnab3Hr+ZXr1v8QABfhx39KknxqKWr2l0oEItzepV0URvbEhB446lk/S/59230dlUUIBGsXbg==",
      "version": "7.7.0",
      "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.7.0.tgz",
      "integrity": "sha512-4x8O7uerSGLnYC10krHl9t8h7xXHn5FextqKYbTCXCnx2hC8D+9lz8wcbQAFo0d97wiUYqI8opmEgFVGx7c5hQ==",
      "dev": true
    },
    "@sentry/utils": {
      "version": "6.19.7",
      "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-6.19.7.tgz",
      "integrity": "sha512-z95ECmE3i9pbWoXQrD/7PgkBAzJYR+iXtPuTkpBjDKs86O3mT+PXOT3BAn79w2wkn7/i3vOGD2xVr1uiMl26dA==",
      "version": "7.7.0",
      "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.7.0.tgz",
      "integrity": "sha512-fD+ROSFpeJlK7bEvUT2LOW7QqgjBpXJwVISKZ0P2fuzclRC3KoB2pbZgBM4PXMMTiSzRGWhvfRRjBiBvQJBBJQ==",
      "dev": true,
      "requires": {
        "@sentry/types": "6.19.7",
        "@sentry/types": "7.7.0",
        "tslib": "^1.9.3"
      }
    },
+2 −1
Original line number Diff line number Diff line
@@ -2,7 +2,8 @@
  "name": "drupal-raven",
  "description": "Integrates with Sentry application monitoring and error tracking platform (sentry.io).",
  "devDependencies": {
    "@sentry/tracing": "^6.3.5",
    "@hapi/bourne": "^3.0.0",
    "@sentry/tracing": "^7.7.0",
    "js-yaml": "^4.1.0"
  },
  "scripts": {
Loading