chore(deps): update dependencies

To fix all security vulnerabilities detected by `Dependabot`.

 - remove `shelljs`. replace with `fs` and `console`.
 - remove `uuid`. replace with `@phosphor/coreutils`.

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
Akos Kitta
2023-10-02 18:05:22 +02:00
committed by Akos Kitta
parent ed1cb6bcf9
commit 153e34f11b
17 changed files with 1473 additions and 2749 deletions

View File

@@ -1,4 +1,3 @@
import { MaybePromise } from '@theia/core';
import { Dialog, DialogError } from '@theia/core/lib/browser/dialogs';
import { LabelProvider } from '@theia/core/lib/browser/label-provider';
import { CancellationTokenSource } from '@theia/core/lib/common/cancellation';
@@ -10,13 +9,14 @@ import type {
Progress,
ProgressUpdate,
} from '@theia/core/lib/common/message-service-protocol';
import type { MaybePromise } from '@theia/core/lib/common/types';
import { UUID } from '@theia/core/shared/@phosphor/coreutils';
import { Widget } from '@theia/core/shared/@phosphor/widgets';
import { inject } from '@theia/core/shared/inversify';
import {
WorkspaceInputDialog as TheiaWorkspaceInputDialog,
WorkspaceInputDialogProps,
} from '@theia/workspace/lib/browser/workspace-input-dialog';
import { v4 } from 'uuid';
export class WorkspaceInputDialog extends TheiaWorkspaceInputDialog {
private skipShowErrorMessageOnOpen: boolean;
@@ -161,7 +161,7 @@ export class WorkspaceInputDialogWithProgress<
const cancellationSource = new CancellationTokenSource();
const progress: Progress = {
id: v4(),
id: UUID.uuid4(),
cancel: () => cancellationSource.cancel(),
report: (update: ProgressUpdate) => {
this.setProgressMessage(update);

View File

@@ -7,7 +7,7 @@ import {
CHANNEL_REQUEST_RELOAD,
MenuDto,
} from '@theia/core/lib/electron-common/electron-api';
import { v4 } from 'uuid';
import { UUID } from '@theia/core/shared/@phosphor/coreutils';
import type { Sketch } from '../common/protocol/sketches-service';
import {
CHANNEL_APP_INFO,
@@ -43,7 +43,7 @@ function convertMenu(
}
return menu.map((item) => {
let nodeId = v4();
let nodeId = UUID.uuid4();
if (item.execute) {
if (!item.id) {
throw new Error(

View File

@@ -9,9 +9,9 @@ import { deepClone } from '@theia/core/lib/common/objects';
import { Deferred } from '@theia/core/lib/common/promise-util';
import type { Mutable } from '@theia/core/lib/common/types';
import { BackendApplicationContribution } from '@theia/core/lib/node/backend-application';
import { UUID } from '@theia/core/shared/@phosphor/coreutils';
import { inject, injectable, named } from '@theia/core/shared/inversify';
import { isDeepStrictEqual } from 'util';
import { v4 } from 'uuid';
import { Unknown } from '../common/nls';
import {
Board,
@@ -168,7 +168,7 @@ export class BoardDiscovery
});
const wrapper = {
stream,
uuid: v4(),
uuid: UUID.uuid4(),
dispose: () => {
this.logger.info('disposing requesting cancel');
// Cancelling the stream will kill the discovery `builtin:mdns-discovery process`.

View File

@@ -420,6 +420,29 @@ export namespace LoadSketchRequest {
}
}
export class SketchProfile extends jspb.Message {
getName(): string;
setName(value: string): SketchProfile;
getFqbn(): string;
setFqbn(value: string): SketchProfile;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): SketchProfile.AsObject;
static toObject(includeInstance: boolean, msg: SketchProfile): SketchProfile.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: SketchProfile, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): SketchProfile;
static deserializeBinaryFromReader(message: SketchProfile, reader: jspb.BinaryReader): SketchProfile;
}
export namespace SketchProfile {
export type AsObject = {
name: string,
fqbn: string,
}
}
export class LoadSketchResponse extends jspb.Message {
getMainFile(): string;
setMainFile(value: string): LoadSketchResponse;
@@ -443,6 +466,15 @@ export class LoadSketchResponse extends jspb.Message {
setDefaultPort(value: string): LoadSketchResponse;
getDefaultProtocol(): string;
setDefaultProtocol(value: string): LoadSketchResponse;
clearProfilesList(): void;
getProfilesList(): Array<SketchProfile>;
setProfilesList(value: Array<SketchProfile>): LoadSketchResponse;
addProfiles(value?: SketchProfile, index?: number): SketchProfile;
hasDefaultProfile(): boolean;
clearDefaultProfile(): void;
getDefaultProfile(): SketchProfile | undefined;
setDefaultProfile(value?: SketchProfile): LoadSketchResponse;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): LoadSketchResponse.AsObject;
@@ -464,6 +496,8 @@ export namespace LoadSketchResponse {
defaultFqbn: string,
defaultPort: string,
defaultProtocol: string,
profilesList: Array<SketchProfile.AsObject>,
defaultProfile?: SketchProfile.AsObject,
}
}

View File

@@ -55,6 +55,7 @@ goog.exportSymbol('proto.cc.arduino.cli.commands.v1.NewSketchRequest', null, glo
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.NewSketchResponse', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.SetSketchDefaultsRequest', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.SetSketchDefaultsResponse', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.SketchProfile', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.UpdateIndexRequest', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.UpdateIndexResponse', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.UpdateLibrariesIndexRequest', null, global);
@@ -418,6 +419,27 @@ if (goog.DEBUG && !COMPILED) {
*/
proto.cc.arduino.cli.commands.v1.LoadSketchRequest.displayName = 'proto.cc.arduino.cli.commands.v1.LoadSketchRequest';
}
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.cc.arduino.cli.commands.v1.SketchProfile = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.cc.arduino.cli.commands.v1.SketchProfile, jspb.Message);
if (goog.DEBUG && !COMPILED) {
/**
* @public
* @override
*/
proto.cc.arduino.cli.commands.v1.SketchProfile.displayName = 'proto.cc.arduino.cli.commands.v1.SketchProfile';
}
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
@@ -3196,12 +3218,172 @@ proto.cc.arduino.cli.commands.v1.LoadSketchRequest.prototype.setSketchPath = fun
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* Optional fields that are not set will be set to undefined.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* net/proto2/compiler/js/internal/generator.cc#kKeyword.
* @param {boolean=} opt_includeInstance Deprecated. whether to include the
* JSPB instance for transitional soy proto support:
* http://goto/soy-param-migration
* @return {!Object}
*/
proto.cc.arduino.cli.commands.v1.SketchProfile.prototype.toObject = function(opt_includeInstance) {
return proto.cc.arduino.cli.commands.v1.SketchProfile.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Deprecated. Whether to include
* the JSPB instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.cc.arduino.cli.commands.v1.SketchProfile} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.cc.arduino.cli.commands.v1.SketchProfile.toObject = function(includeInstance, msg) {
var f, obj = {
name: jspb.Message.getFieldWithDefault(msg, 1, ""),
fqbn: jspb.Message.getFieldWithDefault(msg, 2, "")
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}
/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.cc.arduino.cli.commands.v1.SketchProfile}
*/
proto.cc.arduino.cli.commands.v1.SketchProfile.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.cc.arduino.cli.commands.v1.SketchProfile;
return proto.cc.arduino.cli.commands.v1.SketchProfile.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.cc.arduino.cli.commands.v1.SketchProfile} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.cc.arduino.cli.commands.v1.SketchProfile}
*/
proto.cc.arduino.cli.commands.v1.SketchProfile.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {string} */ (reader.readString());
msg.setName(value);
break;
case 2:
var value = /** @type {string} */ (reader.readString());
msg.setFqbn(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.cc.arduino.cli.commands.v1.SketchProfile.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.cc.arduino.cli.commands.v1.SketchProfile.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.cc.arduino.cli.commands.v1.SketchProfile} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.cc.arduino.cli.commands.v1.SketchProfile.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getName();
if (f.length > 0) {
writer.writeString(
1,
f
);
}
f = message.getFqbn();
if (f.length > 0) {
writer.writeString(
2,
f
);
}
};
/**
* optional string name = 1;
* @return {string}
*/
proto.cc.arduino.cli.commands.v1.SketchProfile.prototype.getName = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};
/**
* @param {string} value
* @return {!proto.cc.arduino.cli.commands.v1.SketchProfile} returns this
*/
proto.cc.arduino.cli.commands.v1.SketchProfile.prototype.setName = function(value) {
return jspb.Message.setProto3StringField(this, 1, value);
};
/**
* optional string fqbn = 2;
* @return {string}
*/
proto.cc.arduino.cli.commands.v1.SketchProfile.prototype.getFqbn = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
};
/**
* @param {string} value
* @return {!proto.cc.arduino.cli.commands.v1.SketchProfile} returns this
*/
proto.cc.arduino.cli.commands.v1.SketchProfile.prototype.setFqbn = function(value) {
return jspb.Message.setProto3StringField(this, 2, value);
};
/**
* List of repeated fields within this message type.
* @private {!Array<number>}
* @const
*/
proto.cc.arduino.cli.commands.v1.LoadSketchResponse.repeatedFields_ = [3,4,5];
proto.cc.arduino.cli.commands.v1.LoadSketchResponse.repeatedFields_ = [3,4,5,9];
@@ -3241,7 +3423,10 @@ proto.cc.arduino.cli.commands.v1.LoadSketchResponse.toObject = function(includeI
rootFolderFilesList: (f = jspb.Message.getRepeatedField(msg, 5)) == null ? undefined : f,
defaultFqbn: jspb.Message.getFieldWithDefault(msg, 6, ""),
defaultPort: jspb.Message.getFieldWithDefault(msg, 7, ""),
defaultProtocol: jspb.Message.getFieldWithDefault(msg, 8, "")
defaultProtocol: jspb.Message.getFieldWithDefault(msg, 8, ""),
profilesList: jspb.Message.toObjectList(msg.getProfilesList(),
proto.cc.arduino.cli.commands.v1.SketchProfile.toObject, includeInstance),
defaultProfile: (f = msg.getDefaultProfile()) && proto.cc.arduino.cli.commands.v1.SketchProfile.toObject(includeInstance, f)
};
if (includeInstance) {
@@ -3310,6 +3495,16 @@ proto.cc.arduino.cli.commands.v1.LoadSketchResponse.deserializeBinaryFromReader
var value = /** @type {string} */ (reader.readString());
msg.setDefaultProtocol(value);
break;
case 9:
var value = new proto.cc.arduino.cli.commands.v1.SketchProfile;
reader.readMessage(value,proto.cc.arduino.cli.commands.v1.SketchProfile.deserializeBinaryFromReader);
msg.addProfiles(value);
break;
case 10:
var value = new proto.cc.arduino.cli.commands.v1.SketchProfile;
reader.readMessage(value,proto.cc.arduino.cli.commands.v1.SketchProfile.deserializeBinaryFromReader);
msg.setDefaultProfile(value);
break;
default:
reader.skipField();
break;
@@ -3395,6 +3590,22 @@ proto.cc.arduino.cli.commands.v1.LoadSketchResponse.serializeBinaryToWriter = fu
f
);
}
f = message.getProfilesList();
if (f.length > 0) {
writer.writeRepeatedMessage(
9,
f,
proto.cc.arduino.cli.commands.v1.SketchProfile.serializeBinaryToWriter
);
}
f = message.getDefaultProfile();
if (f != null) {
writer.writeMessage(
10,
f,
proto.cc.arduino.cli.commands.v1.SketchProfile.serializeBinaryToWriter
);
}
};
@@ -3599,6 +3810,81 @@ proto.cc.arduino.cli.commands.v1.LoadSketchResponse.prototype.setDefaultProtocol
};
/**
* repeated SketchProfile profiles = 9;
* @return {!Array<!proto.cc.arduino.cli.commands.v1.SketchProfile>}
*/
proto.cc.arduino.cli.commands.v1.LoadSketchResponse.prototype.getProfilesList = function() {
return /** @type{!Array<!proto.cc.arduino.cli.commands.v1.SketchProfile>} */ (
jspb.Message.getRepeatedWrapperField(this, proto.cc.arduino.cli.commands.v1.SketchProfile, 9));
};
/**
* @param {!Array<!proto.cc.arduino.cli.commands.v1.SketchProfile>} value
* @return {!proto.cc.arduino.cli.commands.v1.LoadSketchResponse} returns this
*/
proto.cc.arduino.cli.commands.v1.LoadSketchResponse.prototype.setProfilesList = function(value) {
return jspb.Message.setRepeatedWrapperField(this, 9, value);
};
/**
* @param {!proto.cc.arduino.cli.commands.v1.SketchProfile=} opt_value
* @param {number=} opt_index
* @return {!proto.cc.arduino.cli.commands.v1.SketchProfile}
*/
proto.cc.arduino.cli.commands.v1.LoadSketchResponse.prototype.addProfiles = function(opt_value, opt_index) {
return jspb.Message.addToRepeatedWrapperField(this, 9, opt_value, proto.cc.arduino.cli.commands.v1.SketchProfile, opt_index);
};
/**
* Clears the list making it empty but non-null.
* @return {!proto.cc.arduino.cli.commands.v1.LoadSketchResponse} returns this
*/
proto.cc.arduino.cli.commands.v1.LoadSketchResponse.prototype.clearProfilesList = function() {
return this.setProfilesList([]);
};
/**
* optional SketchProfile default_profile = 10;
* @return {?proto.cc.arduino.cli.commands.v1.SketchProfile}
*/
proto.cc.arduino.cli.commands.v1.LoadSketchResponse.prototype.getDefaultProfile = function() {
return /** @type{?proto.cc.arduino.cli.commands.v1.SketchProfile} */ (
jspb.Message.getWrapperField(this, proto.cc.arduino.cli.commands.v1.SketchProfile, 10));
};
/**
* @param {?proto.cc.arduino.cli.commands.v1.SketchProfile|undefined} value
* @return {!proto.cc.arduino.cli.commands.v1.LoadSketchResponse} returns this
*/
proto.cc.arduino.cli.commands.v1.LoadSketchResponse.prototype.setDefaultProfile = function(value) {
return jspb.Message.setWrapperField(this, 10, value);
};
/**
* Clears the message field making it undefined.
* @return {!proto.cc.arduino.cli.commands.v1.LoadSketchResponse} returns this
*/
proto.cc.arduino.cli.commands.v1.LoadSketchResponse.prototype.clearDefaultProfile = function() {
return this.setDefaultProfile(undefined);
};
/**
* Returns whether this field is set.
* @return {boolean}
*/
proto.cc.arduino.cli.commands.v1.LoadSketchResponse.prototype.hasDefaultProfile = function() {
return jspb.Message.getField(this, 10) != null;
};

View File

@@ -1,5 +1,5 @@
import { v4 } from 'uuid';
import {
import { UUID } from '@theia/core/shared/@phosphor/coreutils';
import type {
IndexType,
IndexUpdateDidCompleteParams,
IndexUpdateDidFailParams,
@@ -16,10 +16,10 @@ import {
} from './cli-protocol/cc/arduino/cli/commands/v1/commands_pb';
import {
DownloadProgress,
TaskProgress,
DownloadProgressEnd,
DownloadProgressStart,
DownloadProgressUpdate,
DownloadProgressEnd,
TaskProgress,
} from './cli-protocol/cc/arduino/cli/commands/v1/common_pb';
import { CompileResponse } from './cli-protocol/cc/arduino/cli/commands/v1/compile_pb';
import {
@@ -170,7 +170,7 @@ export namespace ExecuteWithProgress {
progressId,
reportResult,
}: ExecuteWithProgress.Options): (response: R) => void {
const uuid = v4();
const uuid = UUID.uuid4();
let message = '';
let url = '';
return (response: R) => {
@@ -330,7 +330,7 @@ export class IndexesUpdateProgressHandler {
onComplete?: (params: IndexUpdateDidCompleteParams) => void;
}
) {
this.progressId = v4();
this.progressId = UUID.uuid4();
this.results = [];
this.total = IndexesUpdateProgressHandler.total(types, additionalUrlsCount);
// Note: at this point, the IDE2 backend might not have any connected clients, so this notification is not delivered to anywhere

View File

@@ -1,3 +1,4 @@
import { UUID } from '@theia/core/shared/@phosphor/coreutils';
import {
Container,
ContainerModule,
@@ -9,7 +10,6 @@ import { rejects } from 'node:assert';
import { posix } from 'node:path';
import PQueue from 'p-queue';
import queryString from 'query-string';
import { v4 } from 'uuid';
import { ArduinoPreferences } from '../../browser/arduino-preferences';
import { AuthenticationClientService } from '../../browser/auth/authentication-client-service';
import { CreateApi } from '../../browser/create/create-api';
@@ -145,7 +145,7 @@ describe('create-api', () => {
}
it('should delete sketch', async () => {
const name = v4();
const name = UUID.uuid4();
const content = 'alma\nkorte';
const posixPath = toPosix(name);
@@ -185,8 +185,8 @@ describe('create-api', () => {
});
it('should rename a sketch folder with all its content', async () => {
const name = v4();
const newName = v4();
const name = UUID.uuid4();
const newName = UUID.uuid4();
const content = 'void setup(){} void loop(){}';
const posixPath = toPosix(name);
const newPosixPath = toPosix(newName);
@@ -214,8 +214,8 @@ describe('create-api', () => {
});
it('should error with HTTP 409 (Conflict) when renaming a sketch and the target already exists', async () => {
const name = v4();
const otherName = v4();
const name = UUID.uuid4();
const otherName = UUID.uuid4();
const content = 'void setup(){} void loop(){}';
const posixPath = toPosix(name);
const otherPosixPath = toPosix(otherName);
@@ -243,7 +243,7 @@ describe('create-api', () => {
});
it('should error with HTTP 422 when reading a file but is a directory', async () => {
const name = v4();
const name = UUID.uuid4();
const content = 'void setup(){} void loop(){}';
const posixPath = toPosix(name);
@@ -257,7 +257,7 @@ describe('create-api', () => {
});
it('should error with HTTP 422 when listing a directory but is a file', async () => {
const name = v4();
const name = UUID.uuid4();
const content = 'void setup(){} void loop(){}';
const posixPath = toPosix(name);
@@ -272,7 +272,7 @@ describe('create-api', () => {
});
it("should error with HTTP 404 when deleting a non-existing directory via the '/files/d' endpoint", async () => {
const name = v4();
const name = UUID.uuid4();
const posixPath = toPosix(name);
const sketches = await createApi.sketches();
@@ -316,7 +316,7 @@ describe('create-api', () => {
});
it("should fetch the sketch when transforming the 'secrets' into '#include' and the sketch is not in the cache", async () => {
const name = v4();
const name = UUID.uuid4();
const posixPath = toPosix(name);
const newSketch = await createApi.createSketch(
posixPath,
@@ -359,7 +359,9 @@ describe('create-api', () => {
const content = 'void setup(){} void loop(){}';
const maxLimit = 10;
const sketchCount = maxLimit + diff;
const sketchNames = [...Array(sketchCount).keys()].map(() => v4());
const sketchNames = [...Array(sketchCount).keys()].map(() =>
UUID.uuid4()
);
const createExecutionQueue = new PQueue({
concurrency: 5,