Comparing version 3.54.0 to 3.55.0
{ | ||
"name": "dd-trace", | ||
"version": "3.54.0", | ||
"version": "3.55.0", | ||
"description": "Datadog APM tracing client for JavaScript", | ||
@@ -72,3 +72,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"@datadog/native-appsec": "7.1.0", | ||
"@datadog/native-appsec": "7.1.1", | ||
"@datadog/native-iast-rewriter": "2.3.0", | ||
@@ -75,0 +75,0 @@ "@datadog/native-iast-taint-tracking": "1.7.0", |
@@ -47,2 +47,5 @@ 'use strict' | ||
// Message sent by jest's main process to workers to run a test suite (=test file) | ||
// https://github.com/jestjs/jest/blob/1d682f21c7a35da4d3ab3a1436a357b980ebd0fa/packages/jest-worker/src/types.ts#L37 | ||
const CHILD_MESSAGE_CALL = 1 | ||
// Maximum time we'll wait for the tracer to flush | ||
@@ -52,3 +55,3 @@ const FLUSH_TIMEOUT = 10000 | ||
let skippableSuites = [] | ||
let knownTests = [] | ||
let knownTests = {} | ||
let isCodeCoverageEnabled = false | ||
@@ -78,2 +81,3 @@ let isSuitesSkippingEnabled = false | ||
const retriedTestsToNumAttempts = new Map() | ||
const newTestsTestStatuses = new Map() | ||
@@ -107,2 +111,9 @@ // based on https://github.com/facebook/jest/blob/main/packages/jest-circus/src/formatNodeAssertErrors.ts#L41 | ||
function getEfdStats (testStatuses) { | ||
return testStatuses.reduce((acc, testStatus) => { | ||
acc[testStatus]++ | ||
return acc | ||
}, { pass: 0, fail: 0 }) | ||
} | ||
function getWrappedEnvironment (BaseEnvironment, jestVersion) { | ||
@@ -130,5 +141,8 @@ return class DatadogEnvironment extends BaseEnvironment { | ||
if (this.isEarlyFlakeDetectionEnabled) { | ||
const hasKnownTests = !!knownTests.jest | ||
earlyFlakeDetectionNumRetries = this.testEnvironmentOptions._ddEarlyFlakeDetectionNumRetries | ||
try { | ||
this.knownTestsForThisSuite = this.getKnownTestsForSuite(this.testEnvironmentOptions._ddKnownTests) | ||
this.knownTestsForThisSuite = hasKnownTests | ||
? (knownTests.jest[this.testSuite] || []) | ||
: this.getKnownTestsForSuite(this.testEnvironmentOptions._ddKnownTests) | ||
} catch (e) { | ||
@@ -153,3 +167,3 @@ // If there has been an error parsing the tests, we'll disable Early Flake Deteciton | ||
} | ||
return knownTestsForSuite.jest?.[this.testSuite] || [] | ||
return knownTestsForSuite | ||
} | ||
@@ -251,2 +265,15 @@ | ||
event.test.fn = originalTestFns.get(event.test) | ||
// We'll store the test statuses of the retries | ||
if (this.isEarlyFlakeDetectionEnabled) { | ||
const testName = getJestTestName(event.test) | ||
const originalTestName = removeEfdStringFromTestName(testName) | ||
const isNewTest = retriedTestsToNumAttempts.has(originalTestName) | ||
if (isNewTest) { | ||
if (newTestsTestStatuses.has(originalTestName)) { | ||
newTestsTestStatuses.get(originalTestName).push(status) | ||
} else { | ||
newTestsTestStatuses.set(originalTestName, [status]) | ||
} | ||
} | ||
} | ||
}) | ||
@@ -518,2 +545,24 @@ } | ||
/** | ||
* If Early Flake Detection (EFD) is enabled the logic is as follows: | ||
* - If all attempts for a test are failing, the test has failed and we will let the test process fail. | ||
* - If just a single attempt passes, we will prevent the test process from failing. | ||
* The rationale behind is the following: you may still be able to block your CI pipeline by gating | ||
* on flakiness (the test will be considered flaky), but you may choose to unblock the pipeline too. | ||
*/ | ||
if (isEarlyFlakeDetectionEnabled) { | ||
let numFailedTestsToIgnore = 0 | ||
for (const testStatuses of newTestsTestStatuses.values()) { | ||
const { pass, fail } = getEfdStats(testStatuses) | ||
if (pass > 0) { // as long as one passes, we'll consider the test passed | ||
numFailedTestsToIgnore += fail | ||
} | ||
} | ||
// If every test that failed was an EFD retry, we'll consider the suite passed | ||
if (numFailedTestsToIgnore !== 0 && result.results.numFailedTests === numFailedTestsToIgnore) { | ||
result.results.success = true | ||
} | ||
} | ||
return result | ||
@@ -630,3 +679,2 @@ }) | ||
config.testEnvironmentOptions._ddTestCodeCoverageEnabled = isCodeCoverageEnabled | ||
config.testEnvironmentOptions._ddKnownTests = knownTests | ||
}) | ||
@@ -807,2 +855,34 @@ | ||
const ChildProcessWorker = childProcessWorker.default | ||
shimmer.wrap(ChildProcessWorker.prototype, 'send', send => function (request) { | ||
if (!isEarlyFlakeDetectionEnabled) { | ||
return send.apply(this, arguments) | ||
} | ||
const [type] = request | ||
// eslint-disable-next-line | ||
// https://github.com/jestjs/jest/blob/1d682f21c7a35da4d3ab3a1436a357b980ebd0fa/packages/jest-worker/src/workers/ChildProcessWorker.ts#L424 | ||
if (type === CHILD_MESSAGE_CALL) { | ||
// This is the message that the main process sends to the worker to run a test suite (=test file). | ||
// In here we modify the config.testEnvironmentOptions to include the known tests for the suite. | ||
// This way the suite only knows about the tests that are part of it. | ||
const args = request[request.length - 1] | ||
if (args.length > 1) { | ||
return send.apply(this, arguments) | ||
} | ||
if (!args[0]?.config) { | ||
return send.apply(this, arguments) | ||
} | ||
const [{ globalConfig, config, path: testSuiteAbsolutePath }] = args | ||
const testSuite = getTestSuitePath(testSuiteAbsolutePath, globalConfig.rootDir || process.cwd()) | ||
const suiteKnownTests = knownTests.jest?.[testSuite] || [] | ||
args[0].config = { | ||
...config, | ||
testEnvironmentOptions: { | ||
...config.testEnvironmentOptions, | ||
_ddKnownTests: suiteKnownTests | ||
} | ||
} | ||
} | ||
return send.apply(this, arguments) | ||
}) | ||
shimmer.wrap(ChildProcessWorker.prototype, '_onMessage', _onMessage => function () { | ||
@@ -809,0 +889,0 @@ const [code, data] = arguments[0] |
@@ -71,3 +71,6 @@ 'use strict' | ||
result.then( | ||
innerAsyncResource.bind(() => producerFinishCh.publish(undefined)), | ||
innerAsyncResource.bind(res => { | ||
producerFinishCh.publish(undefined) | ||
producerCommitCh.publish(res) | ||
}), | ||
innerAsyncResource.bind(err => { | ||
@@ -81,8 +84,2 @@ if (err) { | ||
result.then(res => { | ||
if (producerCommitCh.hasSubscribers) { | ||
producerCommitCh.publish(res) | ||
} | ||
}) | ||
return result | ||
@@ -89,0 +86,0 @@ } catch (e) { |
@@ -24,3 +24,3 @@ 'use strict' | ||
addHook({ name: 'oracledb', versions: ['5'] }, oracledb => { | ||
addHook({ name: 'oracledb', versions: ['>=5'] }, oracledb => { | ||
shimmer.wrap(oracledb.Connection.prototype, 'execute', execute => { | ||
@@ -27,0 +27,0 @@ return function wrappedExecute (dbQuery, ...args) { |
@@ -23,7 +23,11 @@ 'use strict' | ||
'sqreen/lib/package-reader/index.js', | ||
'ws/lib/websocket-server.js' | ||
'ws/lib/websocket-server.js', | ||
'google-gax/build/src/grpc.js', | ||
'cookie-signature/index.js' | ||
) | ||
const EXCLUDED_PATHS_FROM_STACK = [ | ||
path.join('node_modules', 'object-hash', path.sep) | ||
path.join('node_modules', 'object-hash', path.sep), | ||
path.join('node_modules', 'aws-sdk', 'lib', 'util.js'), | ||
path.join('node_modules', 'keygrip', path.sep) | ||
] | ||
@@ -30,0 +34,0 @@ class WeakHashAnalyzer extends Analyzer { |
@@ -117,2 +117,6 @@ const fs = require('fs') | ||
if (commitsToUpload === null) { | ||
return callback(new Error('git rev-list failed')) | ||
} | ||
callback(null, commitsToUpload) | ||
@@ -256,5 +260,4 @@ }) | ||
const latestCommits = getLatestCommits() | ||
let latestCommits = getLatestCommits() | ||
log.debug(`There were ${latestCommits.length} commits since last month.`) | ||
const [headCommit] = latestCommits | ||
@@ -273,2 +276,3 @@ const getOnFinishGetCommitsToUpload = (hasCheckedShallow) => (err, commitsToUpload) => { | ||
if (hasCheckedShallow || !isShallowRepository()) { | ||
const [headCommit] = latestCommits | ||
return generateAndUploadPackFiles({ | ||
@@ -286,2 +290,5 @@ url, | ||
unshallowRepository() | ||
// The latest commits change after unshallowing | ||
latestCommits = getLatestCommits() | ||
getCommitsToUpload({ | ||
@@ -288,0 +295,0 @@ url, |
@@ -30,2 +30,3 @@ 'use strict' | ||
const defaultWafObfuscatorValueRegex = '(?i)(?:p(?:ass)?w(?:or)?d|pass(?:_?phrase)?|secret|(?:api_?|private_?|public_?|access_?|secret_?)key(?:_?id)?|token|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)(?:\\s*=[^;]|"\\s*:\\s*"[^"]+")|bearer\\s+[a-z0-9\\._\\-]+|token:[a-z0-9]{13}|gh[opsu]_[0-9a-zA-Z]{36}|ey[I-L][\\w=-]+\\.ey[I-L][\\w=-]+(?:\\.[\\w.+\\/=-]+)?|[\\-]{5}BEGIN[a-z\\s]+PRIVATE\\sKEY[\\-]{5}[^\\-]+[\\-]{5}END[a-z\\s]+PRIVATE\\sKEY|ssh-rsa\\s*[a-z0-9\\/\\.+]{100,}' | ||
const runtimeId = uuid() | ||
@@ -295,3 +296,3 @@ function maybeFile (filepath) { | ||
version: this.version, | ||
'runtime-id': uuid() | ||
'runtime-id': runtimeId | ||
}) | ||
@@ -828,2 +829,3 @@ | ||
tagger.add(tags, options.tracing_tags) | ||
if (Object.keys(tags).length) tags['runtime-id'] = runtimeId | ||
@@ -830,0 +832,0 @@ this._setUnit(opts, 'sampleRate', options.tracing_sampling_rate) |
@@ -31,3 +31,3 @@ const cp = require('child_process') | ||
const GIT_REV_LIST_MAX_BUFFER = 8 * 1024 * 1024 // 8MB | ||
const GIT_REV_LIST_MAX_BUFFER = 12 * 1024 * 1024 // 12MB | ||
@@ -57,7 +57,11 @@ function sanitizedExec ( | ||
return result | ||
} catch (e) { | ||
} catch (err) { | ||
if (errorMetric) { | ||
incrementCountMetric(errorMetric.name, { ...errorMetric.tags, exitCode: e.status }) | ||
incrementCountMetric(errorMetric.name, { | ||
...errorMetric.tags, | ||
errorType: err.code, | ||
exitCode: err.status || err.errno | ||
}) | ||
} | ||
log.error(e) | ||
log.error(err) | ||
return '' | ||
@@ -134,3 +138,6 @@ } finally { | ||
log.error(err) | ||
incrementCountMetric(TELEMETRY_GIT_COMMAND_ERRORS, { command: 'unshallow', exitCode: err.status }) | ||
incrementCountMetric( | ||
TELEMETRY_GIT_COMMAND_ERRORS, | ||
{ command: 'unshallow', errorType: err.code, exitCode: err.status || err.errno } | ||
) | ||
const upstreamRemote = sanitizedExec('git', ['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{upstream}']) | ||
@@ -145,3 +152,6 @@ try { | ||
log.error(err) | ||
incrementCountMetric(TELEMETRY_GIT_COMMAND_ERRORS, { command: 'unshallow', exitCode: err.status }) | ||
incrementCountMetric( | ||
TELEMETRY_GIT_COMMAND_ERRORS, | ||
{ command: 'unshallow', errorType: err.code, exitCode: err.status || err.errno } | ||
) | ||
// We use sanitizedExec here because if this last option fails, we'll give up. | ||
@@ -182,3 +192,6 @@ sanitizedExec( | ||
log.error(`Get latest commits failed: ${err.message}`) | ||
incrementCountMetric(TELEMETRY_GIT_COMMAND_ERRORS, { command: 'get_local_commits', errorType: err.status }) | ||
incrementCountMetric( | ||
TELEMETRY_GIT_COMMAND_ERRORS, | ||
{ command: 'get_local_commits', errorType: err.status } | ||
) | ||
return [] | ||
@@ -189,3 +202,3 @@ } | ||
function getCommitsRevList (commitsToExclude, commitsToInclude) { | ||
let result = [] | ||
let result = null | ||
@@ -214,3 +227,6 @@ const commitsToExcludeString = commitsToExclude.map(commit => `^${commit}`) | ||
log.error(`Get commits to upload failed: ${err.message}`) | ||
incrementCountMetric(TELEMETRY_GIT_COMMAND_ERRORS, { command: 'get_objects', errorType: err.status }) | ||
incrementCountMetric( | ||
TELEMETRY_GIT_COMMAND_ERRORS, | ||
{ command: 'get_objects', errorType: err.code, exitCode: err.status || err.errno } // err.status might be null | ||
) | ||
} | ||
@@ -255,3 +271,6 @@ distributionMetric(TELEMETRY_GIT_COMMAND_MS, { command: 'get_objects' }, Date.now() - startTime) | ||
log.error(err) | ||
incrementCountMetric(TELEMETRY_GIT_COMMAND_ERRORS, { command: 'pack_objects', errorType: err.status }) | ||
incrementCountMetric( | ||
TELEMETRY_GIT_COMMAND_ERRORS, | ||
{ command: 'pack_objects', exitCode: err.status || err.errno, errorType: err.code } | ||
) | ||
/** | ||
@@ -273,3 +292,6 @@ * The generation of pack files in the temporary folder (from `os.tmpdir()`) | ||
log.error(err) | ||
incrementCountMetric(TELEMETRY_GIT_COMMAND_ERRORS, { command: 'pack_objects', errorType: err.status }) | ||
incrementCountMetric( | ||
TELEMETRY_GIT_COMMAND_ERRORS, | ||
{ command: 'pack_objects', exitCode: err.status || err.errno, errorType: err.code } | ||
) | ||
} | ||
@@ -276,0 +298,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1682221
48938
+ Added@datadog/native-appsec@7.1.1(transitive)
+ Added@types/node@22.5.5(transitive)
+ Addedpath-to-regexp@0.1.11(transitive)
- Removed@datadog/native-appsec@7.1.0(transitive)
- Removed@types/node@22.5.4(transitive)
- Removedpath-to-regexp@0.1.10(transitive)
Updated@datadog/native-appsec@7.1.1