Skip to content

Commit

Permalink
Bump typescript and axios
Browse files Browse the repository at this point in the history
* Bump axios due to CVE-2023-45857

* Bump typescript, only in resolutions, to 4.6.4 - needed for newer axios

Signed-off-by: Miki <[email protected]>
  • Loading branch information
AMoo-Miki committed Nov 13, 2023
1 parent 524fd93 commit 93e4fb2
Show file tree
Hide file tree
Showing 41 changed files with 87 additions and 73 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Add support for TLS v1.3 ([#5133](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5133))
- [CVE-2023-45133] Add package resolution for `@babel/traverse` to `7.23.2` to fix vulnerability ([#5309](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5309))
- [CVE-2023-45133] Bump all babel dependencies from `7.16.x` to `7.22.9` to fix upstream vulnerability ([#5428](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5428))
- [CVE-2023-45857] Bump `axios` from `0.27.2` to `1.6.1` ([#5470](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5470))
- [CVE-2023-46234] Bump `eslint-import-resolver-webpack` from `0.11.1` to `0.13.8` and `browserify-sign` from `4.2.1` to `4.2.2` ([#5414](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5414/))

### 📈 Features/Enhancements
Expand Down Expand Up @@ -112,6 +113,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Add @bandinib-amzn as maintainer ([#5113](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5113))
- Add @bandinib-amzn to CODEOWNERS file. ([#5456](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5456))
- Bump `chromedriver` from `107.0.3` to `119.0.1` ([#5465](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5465))
- Bump `typescript` resolution from `4.0.2` to `4.6.4` ([#5470](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5470))

### 🪛 Refactoring

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"**/node-jose": "^2.2.0",
"**/nth-check": "^2.0.1",
"**/trim": "^0.0.3",
"**/typescript": "4.0.2",
"**/typescript": "4.6.4",
"**/unset-value": "^2.0.1",
"**/jest-config": "npm:@amoo-miki/[email protected]",
"**/jest-jasmine2": "npm:@amoo-miki/[email protected]",
Expand Down
4 changes: 2 additions & 2 deletions packages/osd-babel-preset/common_preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
*/

const plugins = [
'@babel/plugin-transform-class-properties',
'@babel/plugin-transform-private-methods',
require.resolve('@babel/plugin-transform-class-properties'),
require.resolve('@babel/plugin-transform-private-methods'),
require.resolve('babel-plugin-add-module-exports'),

// Optional Chaining proposal is stage 4 (https://github.com/tc39/proposal-optional-chaining)
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-cross-platform/src/repo_root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const readOpenSearchDashboardsPkgJson = (dir: string) => {
return json;
}
} catch (error) {
if (error && error.code === 'ENOENT') {
if (error?.code === 'ENOENT') {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/osd-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dependencies": {
"@babel/core": "^7.22.9",
"@osd/utils": "1.0.0",
"axios": "^0.27.2",
"axios": "^1.6.1",
"chalk": "^4.1.0",
"cheerio": "0.22.0",
"dedent": "^0.7.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { ToolingLog } from '../tooling_log';

const isConcliftOnGetError = (error: any) => {
return (
isAxiosResponseError(error) && error.config.method === 'GET' && error.response.status === 409
isAxiosResponseError(error) && error.config?.method === 'GET' && error.response.status === 409
);
};

Expand Down
2 changes: 1 addition & 1 deletion packages/osd-opensearch-archiver/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export function runCli() {
output: process.stdout,
});

await new Promise((resolveInput) => {
await new Promise<void>((resolveInput) => {
rl.question(`Press enter when you're done`, () => {
rl.close();
resolveInput();
Expand Down
6 changes: 3 additions & 3 deletions packages/osd-test/src/failed_tests_reporter/github_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* under the License.
*/

import Axios, { AxiosRequestConfig, AxiosInstance } from 'axios';
import Axios, { AxiosRequestConfig, AxiosInstance, AxiosHeaderValue } from 'axios';
import parseLinkHeader from 'parse-link-header';
import { ToolingLog, isAxiosResponseError, isAxiosRequestError } from '@osd/dev-utils';

Expand Down Expand Up @@ -206,7 +206,7 @@ export class GithubApi {
): Promise<{
status: number;
statusText: string;
headers: Record<string, string | string[] | undefined>;
headers: Record<string, AxiosHeaderValue | undefined>;
data: T;
}> {
const executeRequest = !this.dryRun || options.safeForDryRun;
Expand All @@ -231,7 +231,7 @@ export class GithubApi {
const githubApiFailed = isAxiosResponseError(error) && error.response.status >= 500;
const errorResponseLog =
isAxiosResponseError(error) &&
`[${error.config.method} ${error.config.url}] ${error.response.status} ${error.response.statusText} Error`;
`[${error.config?.method} ${error.config?.url}] ${error.response.status} ${error.response.statusText} Error`;

if ((unableToReachGithub || githubApiFailed) && attempt < maxAttempts) {
const waitMs = 1000 * attempt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,17 @@ export class LifecyclePhase<Args extends readonly any[]> {
private readonly beforeSubj = new Rx.Subject<void>();
public readonly before$ = this.beforeSubj.asObservable();

private readonly afterSubj = this.options.singular
? new Rx.ReplaySubject<void>(1)
: new Rx.Subject<void>();
public readonly after$ = this.afterSubj.asObservable();
private readonly afterSubj: Rx.Subject<void>;
public readonly after$: Rx.Observable<void>;

constructor(
private readonly options: {
singular?: boolean;
} = {}
) {}
) {

Check warning on line 54 in packages/osd-test/src/functional_test_runner/lib/lifecycle_phase.ts

View check run for this annotation

Codecov / codecov/patch

packages/osd-test/src/functional_test_runner/lib/lifecycle_phase.ts#L54

Added line #L54 was not covered by tests
this.afterSubj = this.options.singular ? new Rx.ReplaySubject<void>(1) : new Rx.Subject<void>();
this.after$ = this.afterSubj.asObservable();
}

public add(fn: (...args: Args) => Promise<void> | void) {
this.handlers.push(fn);
Expand Down
4 changes: 2 additions & 2 deletions packages/osd-ui-shared-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@osd/i18n": "1.0.0",
"@osd/monaco": "1.0.0",
"abortcontroller-polyfill": "^1.4.0",
"axios": "^0.27.2",
"axios": "^1.6.1",
"compression-webpack-plugin": "npm:@amoo-miki/[email protected]",
"core-js": "^3.6.5",
"custom-event-polyfill": "^0.3.0",
Expand Down Expand Up @@ -51,4 +51,4 @@
"val-loader": "^2.1.2",
"webpack": "npm:@amoo-miki/[email protected]"
}
}
}
11 changes: 11 additions & 0 deletions packages/osd-ui-shared-deps/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ exports.getWebpackConfig = ({ dev = false } = {}) => ({
},
],
},
{
test: /worker_proxy_service\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
babelrc: false,
presets: [require.resolve('@osd/babel-preset/webpack_preset')],
},
},
},
],
},

Expand Down
2 changes: 1 addition & 1 deletion src/core/public/application/application_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ describe('#start()', () => {
// Create an app and a promise that allows us to control when the app completes mounting
const createWaitingApp = (props: Partial<App>): [App, () => void] => {
let finishMount: () => void;
const mountPromise = new Promise((resolve) => (finishMount = resolve));
const mountPromise = new Promise<void>((resolve) => (finishMount = resolve));
const app = {
id: 'some-id',
title: 'some-title',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('ApplicationService', () => {
const { register } = service.setup(setupDeps);

let resolveMount: () => void;
const promise = new Promise((resolve) => {
const promise = new Promise<void>((resolve) => {
resolveMount = resolve;
});

Expand Down Expand Up @@ -111,7 +111,7 @@ describe('ApplicationService', () => {
const { register } = service.setup(setupDeps);

let resolveMount: () => void;
const promise = new Promise((resolve) => {
const promise = new Promise<void>((resolve) => {
resolveMount = resolve;
});

Expand Down Expand Up @@ -453,7 +453,7 @@ describe('ApplicationService', () => {
const { register } = service.setup(setupDeps);

let resolveMount: () => void;
const promise = new Promise((resolve) => {
const promise = new Promise<void>((resolve) => {
resolveMount = resolve;
});

Expand Down Expand Up @@ -491,7 +491,7 @@ describe('ApplicationService', () => {
const { register } = service.setup(setupDeps);

let resolveMount: () => void;
const promise = new Promise((resolve) => {
const promise = new Promise<void>((resolve) => {
resolveMount = resolve;
});

Expand Down
2 changes: 1 addition & 1 deletion src/core/public/application/ui/app_container.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('AppContainer', () => {
});

const flushPromises = async () => {
await new Promise(async (resolve) => {
await new Promise<void>(async (resolve) => {
setImmediate(() => resolve());
});
};
Expand Down
7 changes: 5 additions & 2 deletions src/core/public/chrome/chrome_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ import { ChromeService } from './chrome_service';
import { getAppInfo } from '../application/utils';

class FakeApp implements App {
public title = `${this.id} App`;
public title: string;
public mount = () => () => {};
constructor(public id: string, public chromeless?: boolean) {}

constructor(public id: string, public chromeless?: boolean) {
this.title = `${this.id} App`;
}
}
const store = new Map();
const originalLocalStorage = window.localStorage;
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/chrome/chrome_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ interface ConstructorParams {
browserSupportsCsp: boolean;
}

interface StartDeps {
export interface StartDeps {
application: InternalApplicationStart;
docLinks: DocLinksStart;
http: HttpStart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,9 @@ describe('RecentlyAccessed#start()', () => {

// @ts-expect-error to allow redeclaring a readonly prop
delete window.localStorage;
// @ts-expect-error
window.localStorage = new LocalStorageMock();
});
beforeEach(() => localStorage.clear());
// @ts-expect-error
afterAll(() => (window.localStorage = originalLocalStorage));

const getStart = async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/context/context_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { PluginOpaqueId } from '../../server';
import { IContextContainer, ContextContainer, HandlerFunction } from '../../utils/context';
import { CoreContext } from '../core_system';

interface StartDeps {
export interface StartDeps {
pluginDependencies: ReadonlyMap<PluginOpaqueId, PluginOpaqueId[]>;
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/public/core_app/core_app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ import type { InjectedMetadataSetup } from '../injected_metadata';
import { renderApp as renderErrorApp, setupUrlOverflowDetection } from './errors';
import { renderApp as renderStatusApp } from './status';

interface SetupDeps {
export interface SetupDeps {
application: InternalApplicationSetup;
http: HttpSetup;
injectedMetadata: InjectedMetadataSetup;
notifications: NotificationsSetup;
}

interface StartDeps {
export interface StartDeps {
application: InternalApplicationStart;
http: HttpStart;
notifications: NotificationsStart;
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { deepFreeze } from '@osd/std';
import { parse } from 'semver';
import { InjectedMetadataSetup } from '../injected_metadata';

interface StartDeps {
export interface StartDeps {
injectedMetadata: InjectedMetadataSetup;
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/public/fatal_errors/fatal_errors_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { InjectedMetadataSetup } from '../injected_metadata';
import { FatalErrorsScreen } from './fatal_errors_screen';
import { FatalErrorInfo, getErrorInfo } from './get_error_info';

interface Deps {
export interface Deps {
i18n: I18nStart;
injectedMetadata: InjectedMetadataSetup;
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/public/http/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ export class Fetch {
}

private shorthand(method: string): HttpHandler {
// ToDo: find why 'TResponseBody' of HttpHandler is not assignable to type 'HttpResponse<any>'
// @ts-expect-error
return (pathOrOptions: string | HttpFetchOptionsWithPath, options?: HttpFetchOptions) => {
const optionsWithPath = validateFetchArguments(pathOrOptions, options);
return this.fetch({ ...optionsWithPath, method });
Expand Down
10 changes: 6 additions & 4 deletions src/core/public/injected_metadata/injected_metadata_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ export interface InjectedMetadataParams {
* @internal
*/
export class InjectedMetadataService {
private state = deepFreeze(
this.params.injectedMetadata
) as InjectedMetadataParams['injectedMetadata'];
private state: InjectedMetadataParams['injectedMetadata'];

constructor(private readonly params: InjectedMetadataParams) {}
constructor(private readonly params: InjectedMetadataParams) {
this.state = deepFreeze(
this.params.injectedMetadata
) as InjectedMetadataParams['injectedMetadata'];
}

public start(): InjectedMetadataStart {
return this.setup();
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/integrations/integrations_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { CoreService } from '../../types';
import { MomentService } from './moment';
import { StylesService } from './styles';

interface Deps {
export interface Deps {
uiSettings: IUiSettingsClient;
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/public/notifications/notifications_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ import { ToastsService, ToastsSetup, ToastsStart } from './toasts';
import { IUiSettingsClient } from '../ui_settings';
import { OverlayStart } from '../overlays';

interface SetupDeps {
export interface SetupDeps {
uiSettings: IUiSettingsClient;
}

interface StartDeps {
export interface StartDeps {
i18n: I18nStart;
overlays: OverlayStart;
targetDomElement: HTMLElement;
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/rendering/rendering_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { InternalApplicationStart } from '../application';
import { OverlayStart } from '../overlays';
import { AppWrapper, AppContainer } from './app_containers';

interface StartDeps {
export interface StartDeps {
application: InternalApplicationStart;
chrome: InternalChromeStart;
overlays: OverlayStart;
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/ui_settings/ui_settings_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class UiSettingsApi {
* before sending the next request
*/
public batchSet(key: string, value: any) {
return new Promise<UiSettingsApiResponse>((resolve, reject) => {
return new Promise<UiSettingsApiResponse | undefined>((resolve, reject) => {
const prev = this.pendingChanges || NOOP_CHANGES;

this.pendingChanges = {
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/ui_settings/ui_settings_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ You can use \`IUiSettingsClient.get("${key}", defaultValue)\`, which will just r
this.setLocally(key, newVal);

try {
const { settings } = await this.api.batchSet(key, newVal);
const { settings } = (await this.api.batchSet(key, newVal)) || {};
this.cache = defaultsDeep({}, defaults, settings);
this.saved$.next({ key, newValue: newVal, oldValue: initialVal });
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/ui_settings/ui_settings_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { UiSettingsApi } from './ui_settings_api';
import { UiSettingsClient } from './ui_settings_client';
import { IUiSettingsClient } from './types';

interface UiSettingsServiceDeps {
export interface UiSettingsServiceDeps {
http: HttpSetup;
injectedMetadata: InjectedMetadataSetup;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/context/context_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { PluginOpaqueId } from '../../server';
import { IContextContainer, ContextContainer, HandlerFunction } from '../../utils/context';
import { CoreContext } from '../core_context';

interface SetupDeps {
export interface SetupDeps {
pluginDependencies: ReadonlyMap<PluginOpaqueId, PluginOpaqueId[]>;
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/http_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import {
import { RequestHandlerContext } from '../../server';
import { registerCoreHandlers } from './lifecycle_handlers';

interface SetupDeps {
export interface SetupDeps {
context: ContextSetup;
}

Expand Down
Loading

0 comments on commit 93e4fb2

Please sign in to comment.