Skip to content

Commit

Permalink
fix(deps): upgrade pprof to v3.2.1 [security] (#885)
Browse files Browse the repository at this point in the history
Fixes #879, take two of #883 with correct commit message.

This caused an issue where the proto definitions in `protos/` are incompatible with those returned from pprof. The fix I assumed was to regenerate the protos with `npm run protos`, however this fails because the third_party directory was removed in #486.

To make things work, I instead just imported the same proto definitions from pprof library. I will delete the now unused `protos/` directory for the next major version release as someone could theoretically have been importing them from build, just to be safe.
  • Loading branch information
aabmass authored Jul 24, 2023
1 parent 56e5eb7 commit c140fe5
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
"system-test": "c8 --no-clean mocha build/system-test/test-*.js --timeout=60000",
"samples-test": "echo 'no sample tests'",
"clean": "gts clean",
"compile": "tsc -p . && cp -R protos build",
"compile": "tsc -p .",
"fix": "gts fix",
"lint": "gts check",
"docs": "jsdoc -c .jsdoc.js",
"prelint": "cd samples; npm link ../; npm install",
"prepare": "npm run compile",
"pretest": "npm run compile",
"proto": "mkdir -p protos && pbjs -t static-module -w commonjs -o protos/profiler.js third_party/googleapis/google/devtools/cloudprofiler/v2/profiler.proto && pbts -o protos/profiler.d.ts protos/profiler.js",
"license-check": "jsgl --local .",
"docs-test": "linkinator docs",
"predocs-test": "npm run docs",
Expand All @@ -37,9 +36,9 @@
"extend": "^3.0.2",
"gcp-metadata": "^4.0.0",
"parse-duration": "^1.0.0",
"pprof": "3.2.0",
"pprof": "3.2.1",
"pretty-ms": "^7.0.0",
"protobufjs": "~7.2.0",
"protobufjs": "~7.2.4",
"semver": "^7.0.0",
"teeny-request": "^8.0.0"
},
Expand Down Expand Up @@ -69,12 +68,10 @@
},
"files": [
"build/src",
"build/third_party/cloud-debug-nodejs",
"build/protos"
"build/third_party/cloud-debug-nodejs"
],
"nyc": {
"exclude": [
"protos",
"build/test",
"build/system-test"
]
Expand Down
2 changes: 1 addition & 1 deletion src/profiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import {
DecorateRequestOptions,
} from '@google-cloud/common';
import {heap as heapProfiler, SourceMapper, time as timeProfiler} from 'pprof';
import {perftools} from 'pprof/proto/profile';
import * as msToStr from 'pretty-ms';
import {promisify} from 'util';
import * as zlib from 'zlib';
import * as r from 'teeny-request';

import {perftools} from '../protos/profile';
import {ProfilerConfig} from './config';
import {createLogger} from './logger';

Expand Down
2 changes: 1 addition & 1 deletion system-test/test-start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import * as nock from 'nock';
import {promisify} from 'util';
import * as zlib from 'zlib';

import {perftools} from '../protos/profile';
import {perftools} from 'pprof/proto/profile';
import {RequestProfile} from '../src/profiler';

const API = 'https://cloudprofiler.googleapis.com/v2';
Expand Down
2 changes: 1 addition & 1 deletion test/profiles-for-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import * as path from 'path';
import {SourceMapGenerator} from 'source-map';
import * as tmp from 'tmp';

import {perftools} from '../protos/profile';
import {perftools} from 'pprof/proto/profile';
import {TimeProfile} from '../src/v8-types';

const timeLeaf1 = {
Expand Down
2 changes: 1 addition & 1 deletion test/test-profiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import * as sinon from 'sinon';
import {promisify} from 'util';
import * as zlib from 'zlib';

import {perftools} from '../protos/profile';
import {perftools} from 'pprof/proto/profile';
import {ProfilerConfig} from '../src/config';
import {
parseBackoffDuration,
Expand Down

0 comments on commit c140fe5

Please sign in to comment.