[DO NOT MERGE] feat(core): add opt-in assertion instrumentation - #6592
[DO NOT MERGE] feat(core): add opt-in assertion instrumentation#6592antonis wants to merge 11 commits into
8 issues
Medium
values: null crashes the assertion reporter via Object.keys - `packages/core/src/js/assertion.ts:201-202`
values !== undefined allows null through to flattenValues, where Object.keys(null) throws a TypeError and breaks the reporting path.
Variadic assertion arguments beyond arguments[1] are silently dropped - `packages/core/src/js/tools/sentryAssertionBabelPlugin.ts:458-461`
Only arguments[1] is captured, so variadic helpers like console.assert(condition, fmt, ...args) or invariant(condition, fmt, ...args) lose their substitution values in Sentry and produce un-interpolated %s messages. Any side effects in extra arguments are also removed from the AST.
`new Error()` uses scoped `Error` binding and may crash if shadowed - `packages/core/src/js/tools/sentryAssertionBabelPlugin.ts:506`
The transform emits new Error() at the assertion call site without referencing the global constructor. A local let Error, parameter named Error, or module-scoped alias shadows the global and can cause a TypeError: Error is not a constructor crash when the assertion fires.
includeNodeModules allowlist misses Windows paths in addSentryCaptureAssertionsPlugin - `packages/core/src/js/tools/sentryBabelTransformerUtils.ts:168-170`
The includeNodeModules allowlist check does not normalize backslashes before matching fragments, so on Windows the plugin will not be pushed for allowlisted dependency paths. The plugin itself correctly normalizes via toPosixPath. Have you considered normalizing args.filename before the allowlist .includes() checks?
flattenValues is not defensive against throwing getters - `packages/core/src/js/assertion.ts:136-139`
Accessing values[key] in the loop can trigger a throwing getter, breaking the reporting path's no-throw guarantee.
`values` guard does not prevent `null`, crashing the reporter path - `packages/core/src/js/assertion.ts:199-200`
values !== undefined on line 201 allows null into flattenValues, where Object.keys(null) throws a TypeError and breaks the reporting path. The Babel transform emits only object literals, but manual calls that bypass the TypeScript contract can crash the safe reporter.
Also found at:
packages/core/src/js/index.ts:119packages/core/src/js/assertion.ts:170-171
`includeNodeModules` allowlist silently skips Windows node_modules paths - `packages/core/src/js/tools/sentryAssertionBabelPlugin.ts:217-219`
The Metro transformer wrapper (addSentryCaptureAssertionsPlugin) mirrors the plugin's isNodeModulesExcluded check but omits toPosixPath normalization, so allowlist fragments with forward slashes never match Windows backslash filenames and the plugin is never pushed for those dependencies.
Also found at:
packages/core/src/js/tools/sentryAssertionBabelPlugin.ts:378packages/core/src/js/tools/sentryBabelTransformerUtils.ts:17packages/core/src/js/tools/sentryBabelTransformerUtils.ts:169-170packages/core/test/tools/sentryBabelTransformer.test.ts:246-250
Dedup test relies on uncleaned module-level state - `packages/core/test/assertion.test.ts:120-130`
The deduplication test assumes a fresh reportedSites Set, but assertion.ts keeps it at module level with no reset mechanism, so siteIds accumulate across tests and can cause order-dependent failures.
4 skills analyzed
| Skill | Findings | Duration | Cost |
|---|---|---|---|
| security-review | 0 | 3m 55s | $1.26 |
| code-review | 4 | 16m 28s | $2.81 |
| find-bugs | 4 | 32m 31s | $8.49 |
| gha-security-review | 0 | 26m 55s | $0.09 |
⏱ 79m 49s · 15.8M in / 953.3k out · $12.66