Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: dependabot security fixes #356

Merged
merged 25 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ module.exports = {
ecmaVersion: 2018,
},
extends: ['@sentry-internal/sdk'],
ignorePatterns: ['build/**', 'dist/**', 'esm/**', 'examples/**', 'scripts/**', 'src/js/Ionic/**', '__tests__/**'],
plugins: ['@sentry-internal/sdk'],

ignorePatterns: ['build/**', 'dist/**', 'esm/**', 'sample/**', 'scripts/**', 'dangerfile.js', 'src/js/Ionic/**', '__tests__/**'],
overrides: [
{
files: ['*.ts', '*.tsx', '*.d.ts'],
Expand All @@ -22,10 +24,20 @@ module.exports = {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@sentry-internal/sdk/no-async-await': 'off',
'@sentry-internal/sdk/no-optional-chaining': 'off',
'@sentry-internal/sdk/no-nullish-coalescing': 'off',
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-ignore': 'allow-with-description',
},
],
},
},
],
rules: {
'@sentry-internal/sdk/no-async-await': 'off',
'@sentry-internal/sdk/no-optional-chaining': 'off',
'@sentry-internal/sdk/no-nullish-coalescing': 'off',
'@sentry-internal/sdk/no-class-field-initializers': 'off',
'@sentry-internal/sdk/no-unsupported-es6-methods' : 'off',
}
};
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,8 @@ package-lock.json
# Generated Lockfiles
Cartfile.resolved

# Yarn cache
.yarn

# Yalc
sample/yalc.lock
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Dependencies

- Bump `sentry-wizard` to 3.34.2 ([#356](https://github.com/getsentry/sentry-cordova/pull/356))

## 1.4.0

### Features
Expand Down
4 changes: 2 additions & 2 deletions dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async function checkDocs() {

function getCleanTitleWithPrLink() {
const title = danger.github.pr.title;
return title.split(": ").slice(-1)[0].trim().replace(/\.+$/, "") + ` ` + PR_LINK;
return `${title.split(": ").slice(-1)[0].trim().replace(/\.+$/, "") } ${ PR_LINK}`;
}

function getChangelogDetailsHtml() {
Expand All @@ -41,7 +41,7 @@ async function checkChangelog() {

// Check if skipped
const skipChangelog =
danger.github && (danger.github.pr.body + "").toLowerCase().includes("#skip-changelog");
danger.github && (`${danger.github.pr.body }`).toLowerCase().includes("#skip-changelog");

if (skipChangelog) {
return;
Expand Down
40 changes: 21 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,47 +29,49 @@
"@sentry/hub": "7.119.1",
"@sentry/types": "7.119.1",
"@sentry/utils": "7.119.1",
"@sentry/wizard": "^3.32.0"
"@sentry/wizard": "^3.34.2"
},
"devDependencies": {
"@jest/types": "^26.0.0",
"@rollup/plugin-commonjs": "^28.0.1",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^12.1.1",
"@sentry-internal/eslint-config-sdk": "7.119.1",
"@sentry-internal/typescript": "7.119.1",
"@types/cordova": "0.0.34",
"@types/jest": "^24.0.18",
"@types/jest": "^26.0.24",
"@types/node": "^12.7.5",
"codecov": "^3.5.0",
"eslint": "7.6.0",
"jest": "^24.9.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.18.2",
"@types/prettier": "<2.6.0",
"eslint": "^7.13.0",
"jest": "^26.6.3",
"json-schema": "^0.4.0",
"prettier": "^3.3.3",
"prettier-check": "^2.0.0",
"replace-in-file": "^4.1.3",
"rimraf": "^3.0.0",
"replace-in-file": "^8.2.0",
"rollup": "^2.79.2",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-node-resolve": "^4.2.3",
"rollup-plugin-terser": "^4.0.4",
"rollup-plugin-typescript2": "^0.21.0",
"ts-jest": "^24.1.0",
"typescript": "^3.6.3"
"ts-jest": "^26.5.0",
"typescript": "^3.6.3",
"yarn": "^1.22.22"
},
"_devDependencies_notes": "@types/prettier required in order to keep compatibility with older typescript/ serialize-javascript, node-notifier added for patching security issues.",
"scripts": {
"build:bundle": "rollup --config",
"build:typescript": "tsc -p tsconfig.build.json",
"build": "run-s clean build:typescript build:bundle",
"build": "yarn run clean && yarn run build:typescript && yarn run build:bundle",
"clean": "rimraf dist coverage",
"jest": "jest",
"test:watch": "jest --watch",
"test": "jest",
"codecov": "codecov",
"lint": "run-s lint:prettier lint:eslint",
"lint": "yarn run lint:prettier && yarn run lint:eslint",
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
"lint:eslint": "eslint . --cache --format stylish",
"fix": "run-s fix:eslint fix:prettier",
"fix": "yarn run fix:eslint && yarn run fix:prettier",
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
"fix:eslint": "eslint . --format stylish --fix",
"preversion:changelog": "grep -q -F \"## v$npm_package_version\" CHANGELOG.md",
"version:all": "run-s preversion:changelog version:bump test",
"version:all": "yarn run preversion:changelog && yarn run version:bump && yarn run test",
"version:bump": "node ./scripts/versionbump.js && git add -A"
},
"jest": {
Expand Down
44 changes: 20 additions & 24 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,46 @@
import commonjs from 'rollup-plugin-commonjs';
import { terser } from 'rollup-plugin-terser';
import resolve from 'rollup-plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
import commonjs from '@rollup/plugin-commonjs';
import terser from '@rollup/plugin-terser';
import resolve from '@rollup/plugin-node-resolve';
import ts from '@rollup/plugin-typescript';
import typescript from 'typescript';

const terserInstance = terser({
mangle: {
// captureExceptions and captureMessage are public API methods and they don't need to be listed here
// as mangler doesn't touch user-facing thing, however sentryWrapepd is not, and it would be mangled into a minified version.
// We need those full names to correctly detect our internal frames for stripping.
// I listed all of them here just for the clarity sake, as they are all used in the frames manipulation process.
// Preserve public API methods from mangling
reserved: ['captureException', 'captureMessage', 'sentryWrapped'],
properties: {
regex: /^_[^_]/,
regex: /^_[^_]/, // Regex to match properties to mangle
},
},
});

const defaultPlugins = [
typescript({
ts({
tsconfig: 'tsconfig.build.json',
tsconfigOverride: {
compilerOptions: {
declaration: false,
declarationMap: false,
module: 'ES2015',
},
compilerOptions: {
declaration: false,
declarationMap: false,
module: 'ES2015', // Set module to ES2015
},
}),
resolve({
mainFields: ['module'],
mainFields: ['module'], // Use module field for resolution
}),
commonjs(),
commonjs(), // Enable CommonJS module resolution
];

const defaultMinPlugins = [...defaultPlugins, terserInstance];
const defaultMinPlugins = [...defaultPlugins, terserInstance]; // Include terser for minification

export default [
{
input: 'src/js/sentry-cordova.ts',
output: {
file: 'dist/js/sentry-cordova.bundle.min.js',
format: 'cjs',
exports: 'named',
sourcemap: true,
format: 'cjs', // CommonJS format for output
exports: 'named', // Named exports
sourcemap: true, // Generate sourcemaps
},
plugins: defaultMinPlugins,
plugins: defaultMinPlugins, // Use plugins with minification
},
{
input: 'src/js/sentry-cordova.ts',
Expand All @@ -54,6 +50,6 @@ export default [
exports: 'named',
sourcemap: true,
},
plugins: defaultPlugins,
plugins: defaultPlugins, // Use default plugins without minification
},
];
2 changes: 1 addition & 1 deletion sample/www/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ function onDeviceReady() {
tracesSampleRate: 1,
});

console.log('Running cordova-' + cordova.platformId + '@' + cordova.version);
console.log(`Running cordova-${ cordova.platformId }@${ cordova.version}`);
document.getElementById('deviceready').classList.add('ready');
}
15 changes: 8 additions & 7 deletions src/js/__tests__/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line deprecation/deprecation
import { getGlobalObject } from '@sentry/utils';

import type { CordovaOptions } from '../options';
Expand Down Expand Up @@ -32,6 +33,7 @@ jest.mock('../utils', () => {
describe('Tests SDK', () => {
describe('init', () => {
it('Uses SENTRY_RELEASE environment variable if present.', () => {
// eslint-disable-next-line deprecation/deprecation
const window = getGlobalObject<any>();
window.SENTRY_RELEASE = {
id: 'test-release',
Expand All @@ -43,6 +45,7 @@ describe('Tests SDK', () => {
});

it('User release has precedence over SENTRY_RELEASE', () => {
// eslint-disable-next-line deprecation/deprecation
const window = getGlobalObject<any>();
window.SENTRY_RELEASE = {
id: 'test-release',
Expand All @@ -56,15 +59,14 @@ describe('Tests SDK', () => {
});

describe('ios Options', () => {

it('Should include iOS parameters when running on iOS', async () => {
(getPlatform as jest.Mock).mockReturnValue('ios');

const expectedOptions: CordovaOptions = {
environment: 'abc',
// iOS parameters
enableAppHangTracking: true,
appHangTimeoutInterval: 123
appHangTimeoutInterval: 123,
};

Sdk.init(expectedOptions);
Expand All @@ -77,19 +79,18 @@ describe('Tests SDK', () => {
(getPlatform as jest.Mock).mockReturnValue('android');

const expectedOption = {
environment: 'abc'
}
environment: 'abc',
};
const unexpectedOptions = {
appHangTimeoutInterval: 123,
enableAppHangTracking: true
enableAppHangTracking: true,
};

Sdk.init({ ...unexpectedOptions, ...expectedOption });

expect(optionsTest.current).not.toContain(unexpectedOptions);
expect(optionsTest.current?.environment).toEqual(expectedOption.environment);
});
})

});
});
});
2 changes: 1 addition & 1 deletion src/js/__tests__/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ declare global {
const setupGlobals = (): void => {
// @ts-ignore Global
global.Cordova = {
exec: jest.fn(resolve => resolve()),
exec: jest.fn((resolve) => resolve()),
};

// @ts-ignore Global
Expand Down
1 change: 1 addition & 0 deletions src/js/integrations/cordova.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class Cordova implements Integration {
*/
public setupOnce(): void {
addEventProcessor((event: Event) => {
// eslint-disable-next-line deprecation/deprecation
const self = getCurrentHub().getIntegration(Cordova);
if (self) {
return normalizeData(event) as Event;
Expand Down
2 changes: 1 addition & 1 deletion src/js/integrations/eventorigin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class EventOrigin implements Integration {
* @inheritDoc
*/
public setupOnce(): void {
addEventProcessor(event => {
addEventProcessor((event) => {
event.tags = event.tags ?? {};

event.tags['event.origin'] = 'cordova';
Expand Down
7 changes: 3 additions & 4 deletions src/js/integrations/sdkinfo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Integration } from '@sentry/types';
import { addEventProcessor } from '@sentry/core';
import type { Integration } from '@sentry/types';

import { SDK_NAME, SDK_VERSION } from '../version';
import { addEventProcessor } from '@sentry/core';

/** Default SdkInfo instrumentation */
export class SdkInfo implements Integration {
Expand All @@ -19,8 +19,7 @@ export class SdkInfo implements Integration {
* @inheritDoc
*/
public setupOnce(): void {
addEventProcessor(async event => {

addEventProcessor(async (event) => {
event.platform = event.platform || 'javascript';
event.sdk = {
...event.sdk,
Expand Down
Loading
Loading