Skip to content

Commit

Permalink
upgrade mocha@8 to mocha@9 (VULN-5521, VULN-5526) (#4036)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlhunter authored Feb 8, 2024
1 parent d0e2e25 commit eae0c8c
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 115 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"jszip": "^3.5.0",
"knex": "^2.4.2",
"mkdirp": "^3.0.1",
"mocha": "8",
"mocha": "^9",
"multer": "^1.4.5-lts.1",
"nock": "^11.3.3",
"nyc": "^15.1.0",
Expand Down
18 changes: 10 additions & 8 deletions packages/datadog-plugin-mysql/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const { ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/c

const { expectedSchema, rawExpectedSchema } = require('./naming')

const ddpv = require('mocha/package.json').version

describe('Plugin', () => {
let mysql
let tracer
Expand Down Expand Up @@ -319,7 +321,7 @@ describe('Plugin', () => {
connection.query('SELECT 1 + 1 AS solution', () => {
try {
expect(connection._protocol._queue[0].sql).to.equal(
`/*dddbs='serviced',dde='tester',ddps='test',ddpv='8.4.0'*/ SELECT 1 + 1 AS solution`)
`/*dddbs='serviced',dde='tester',ddps='test',ddpv='${ddpv}'*/ SELECT 1 + 1 AS solution`)
} catch (e) {
done(e)
}
Expand All @@ -333,7 +335,7 @@ describe('Plugin', () => {
connection.query('SELECT 1 + 1 AS solution', () => {
try {
expect(connection._protocol._queue[0].sql).to.equal(
`/*dddbs='db',dde='tester',ddps='test',ddpv='8.4.0'*/ SELECT 1 + 1 AS solution`)
`/*dddbs='db',dde='tester',ddps='test',ddpv='${ddpv}'*/ SELECT 1 + 1 AS solution`)
} catch (e) {
done(e)
}
Expand All @@ -347,7 +349,7 @@ describe('Plugin', () => {
connection.query('SELECT 1 + 1 AS solution', () => {
try {
expect(connection._protocol._queue[0].sql).to.equal(
`/*dddbs='remappedDB',dde='tester',ddps='test',ddpv='8.4.0'*/ SELECT 1 + 1 AS solution`)
`/*dddbs='remappedDB',dde='tester',ddps='test',ddpv='${ddpv}'*/ SELECT 1 + 1 AS solution`)
} catch (e) {
done(e)
}
Expand Down Expand Up @@ -375,7 +377,7 @@ describe('Plugin', () => {
connection.query('SELECT 1 + 1 AS solution', () => {
try {
expect(connection._protocol._queue[0].sql).to.equal(
`/*dddbs='serviced',dde='tester',ddps='test',ddpv='8.4.0'*/ SELECT 1 + 1 AS solution`)
`/*dddbs='serviced',dde='tester',ddps='test',ddpv='${ddpv}'*/ SELECT 1 + 1 AS solution`)
} catch (e) {
done(e)
}
Expand Down Expand Up @@ -422,7 +424,7 @@ describe('Plugin', () => {
try {
expect(connection._protocol._queue[0].sql).to.equal(
`/*dddbs='~!%40%23%24%25%5E%26*()_%2B%7C%3F%3F%2F%3C%3E',dde='tester',` +
`ddps='test',ddpv='8.4.0'*/ SELECT 1 + 1 AS solution`)
`ddps='test',ddpv='${ddpv}'*/ SELECT 1 + 1 AS solution`)
done()
} catch (e) {
done(e)
Expand Down Expand Up @@ -459,7 +461,7 @@ describe('Plugin', () => {
const spanId = traces[0][0].span_id.toString(16).padStart(16, '0')

expect(queryText).to.equal(
`/*dddbs='post',dde='tester',ddps='test',ddpv='8.4.0',` +
`/*dddbs='post',dde='tester',ddps='test',ddpv='${ddpv}',` +
`traceparent='00-${traceId}-${spanId}-00'*/ SELECT 1 + 1 AS solution`)
}).then(done, done)
const clock = sinon.useFakeTimers(new Date())
Expand Down Expand Up @@ -502,7 +504,7 @@ describe('Plugin', () => {
pool.query('SELECT 1 + 1 AS solution', () => {
try {
expect(pool._allConnections[0]._protocol._queue[0].sql).to.equal(
`/*dddbs='post',dde='tester',ddps='test',ddpv='8.4.0'*/ SELECT 1 + 1 AS solution`)
`/*dddbs='post',dde='tester',ddps='test',ddpv='${ddpv}'*/ SELECT 1 + 1 AS solution`)
} catch (e) {
done(e)
}
Expand Down Expand Up @@ -539,7 +541,7 @@ describe('Plugin', () => {
const spanId = traces[0][0].span_id.toString(16).padStart(16, '0')

expect(queryText).to.equal(
`/*dddbs='post',dde='tester',ddps='test',ddpv='8.4.0',` +
`/*dddbs='post',dde='tester',ddps='test',ddpv='${ddpv}',` +
`traceparent='00-${traceId}-${spanId}-00'*/ SELECT 1 + 1 AS solution`)
}).then(done, done)
const clock = sinon.useFakeTimers(new Date())
Expand Down
12 changes: 7 additions & 5 deletions packages/datadog-plugin-mysql2/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const { ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/c

const { expectedSchema, rawExpectedSchema } = require('./naming')

const ddpv = require('mocha/package.json').version

describe('Plugin', () => {
let mysql2
let tracer
Expand Down Expand Up @@ -366,7 +368,7 @@ describe('Plugin', () => {
const connect = connection.query('SELECT 1 + 1 AS solution', (...args) => {
try {
expect(connect.sql).to.equal(`/*dddbs='serviced',dde='tester',` +
`ddps='test',ddpv='8.4.0'*/ SELECT 1 + 1 AS solution`)
`ddps='test',ddpv='${ddpv}'*/ SELECT 1 + 1 AS solution`)
} catch (e) {
done(e)
}
Expand Down Expand Up @@ -412,7 +414,7 @@ describe('Plugin', () => {
try {
expect(connect.sql).to.equal(
`/*dddbs='~!%40%23%24%25%5E%26*()_%2B%7C%3F%3F%2F%3C%3E',dde='tester',` +
`ddps='test',ddpv='8.4.0'*/ SELECT 1 + 1 AS solution`)
`ddps='test',ddpv='${ddpv}'*/ SELECT 1 + 1 AS solution`)
done()
} catch (e) {
done(e)
Expand Down Expand Up @@ -449,7 +451,7 @@ describe('Plugin', () => {
const spanId = traces[0][0].span_id.toString(16).padStart(16, '0')

expect(queryText).to.equal(
`/*dddbs='post',dde='tester',ddps='test',ddpv='8.4.0',` +
`/*dddbs='post',dde='tester',ddps='test',ddpv='${ddpv}',` +
`traceparent='00-${traceId}-${spanId}-00'*/ SELECT 1 + 1 AS solution`)
}).then(done, done)
const clock = sinon.useFakeTimers(new Date())
Expand Down Expand Up @@ -492,7 +494,7 @@ describe('Plugin', () => {
const queryPool = pool.query('SELECT 1 + 1 AS solution', () => {
try {
expect(queryPool.sql).to.equal(
`/*dddbs='post',dde='tester',ddps='test',ddpv='8.4.0'*/ SELECT 1 + 1 AS solution`)
`/*dddbs='post',dde='tester',ddps='test',ddpv='${ddpv}'*/ SELECT 1 + 1 AS solution`)
} catch (e) {
done(e)
}
Expand Down Expand Up @@ -529,7 +531,7 @@ describe('Plugin', () => {
const spanId = traces[0][0].span_id.toString(16).padStart(16, '0')

expect(queryText).to.equal(
`/*dddbs='post',dde='tester',ddps='test',ddpv='8.4.0',` +
`/*dddbs='post',dde='tester',ddps='test',ddpv='${ddpv}',` +
`traceparent='00-${traceId}-${spanId}-00'*/ SELECT 1 + 1 AS solution`)
}).then(done, done)
const clock = sinon.useFakeTimers(new Date())
Expand Down
14 changes: 8 additions & 6 deletions packages/datadog-plugin-pg/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const net = require('net')
const { expectedSchema, rawExpectedSchema } = require('./naming')
const EventEmitter = require('events')

const ddpv = require('mocha/package.json').version

const clients = {
pg: pg => pg.Client
}
Expand Down Expand Up @@ -371,7 +373,7 @@ describe('Plugin', () => {
if (client.queryQueue[0] !== undefined) {
try {
expect(client.queryQueue[0].text).to.equal(
`/*dddbs='serviced',dde='tester',ddps='test',ddpv='8.4.0'*/ SELECT $1::text as message`)
`/*dddbs='serviced',dde='tester',ddps='test',ddpv='${ddpv}'*/ SELECT $1::text as message`)
} catch (e) {
done(e)
}
Expand Down Expand Up @@ -429,7 +431,7 @@ describe('Plugin', () => {
try {
expect(clientDBM.queryQueue[0].text).to.equal(
`/*dddbs='~!%40%23%24%25%5E%26*()_%2B%7C%3F%3F%2F%3C%3E',dde='tester',` +
`ddps='test',ddpv='8.4.0'*/ SELECT $1::text as message`)
`ddps='test',ddpv='${ddpv}'*/ SELECT $1::text as message`)
done()
} catch (e) {
done(e)
Expand Down Expand Up @@ -570,7 +572,7 @@ describe('Plugin', () => {
const spanId = traces[0][0].span_id.toString(16).padStart(16, '0')

expect(queryText).to.equal(
`/*dddbs='post',dde='tester',ddps='test',ddpv='8.4.0',` +
`/*dddbs='post',dde='tester',ddps='test',ddpv='${ddpv}',` +
`traceparent='00-${traceId}-${spanId}-00'*/ SELECT $1::text as message`)
}).then(done, done)

Expand Down Expand Up @@ -616,7 +618,7 @@ describe('Plugin', () => {

agent.use(traces => {
expect(queryText).to.equal(
`/*dddbs='post',dde='tester',ddps='test',ddpv='8.4.0'` +
`/*dddbs='post',dde='tester',ddps='test',ddpv='${ddpv}'` +
`*/ SELECT $1::text as message`)
}).then(done, done)

Expand All @@ -640,7 +642,7 @@ describe('Plugin', () => {

agent.use(traces => {
expect(queryText).to.equal(
`/*dddbs='post',dde='tester',ddps='test',ddpv='8.4.0'` +
`/*dddbs='post',dde='tester',ddps='test',ddpv='${ddpv}'` +
`*/ SELECT $1::text as message`)
}).then(done, done)

Expand Down Expand Up @@ -674,7 +676,7 @@ describe('Plugin', () => {

agent.use(traces => {
expect(queryText).to.equal(
`/*dddbs='post',dde='tester',ddps='test',ddpv='8.4.0'` +
`/*dddbs='post',dde='tester',ddps='test',ddpv='${ddpv}'` +
`*/ SELECT $1::text as greeting`)
}).then(done, done)

Expand Down
Loading

0 comments on commit eae0c8c

Please sign in to comment.