Skip to content

Commit

Permalink
Fix CQM major defects in CircleEditorDocuments (Samsung#1605)
Browse files Browse the repository at this point in the history
This commit fixes CQM major defects
caused by absence of property checking.

ONE-vscode-DCO-1.0-Signed-off-by: Dayoung Lee <[email protected]>
  • Loading branch information
dayo09 authored Aug 1, 2023
1 parent c8c4d4b commit 463573a
Showing 1 changed file with 47 additions and 36 deletions.
83 changes: 47 additions & 36 deletions src/CircleEditor/CircleEditorDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,35 +476,43 @@ export class CircleEditorDocument
public sendEncodingData(message: any) {
let fbb = flexbuffers.builder();
fbb.startMap();
for (const key in message.data) {
fbb.addKey(key);
const val = message.data[key][0];
const valType = message.data[key][1];
if (valType === "boolean") {
if (val === "true" || val === true) {
fbb.add(true);
} else if (val === "false" || val === false) {
fbb.add(false);
} else {
Balloon.error("'boolean' type must be 'true' or 'false'.", false);
return;
}
} else if (valType === "int") {
const guessType = this.guessExactType(val);
if (guessType === "float") {
Balloon.error("'int' type doesn't include decimal point.", false);
return;
} else if (
guessType === "error" ||
guessType === "not supported type"
) {
Balloon.error("it's not a number", false);
return;

if ("data" in message) {
for (const key in message.data) {
if (Object.prototype.hasOwnProperty.call(message.data, key)) {
fbb.addKey(key);

const val = message.data[key][0];
const valType = message.data[key][1];

if (valType === "boolean") {
if (val === "true" || val === true) {
fbb.add(true);
} else if (val === "false" || val === false) {
fbb.add(false);
} else {
Balloon.error("'boolean' type must be 'true' or 'false'.", false);
return;
}
} else if (valType === "int") {
const guessType = this.guessExactType(val);
if (guessType === "float") {
Balloon.error("'int' type doesn't include decimal point.", false);
return;
} else if (
guessType === "error" ||
guessType === "not supported type"
) {
Balloon.error("it's not a number", false);
return;
}
} else {
fbb.add(String(val));
}
}
} else {
fbb.add(String(val));
}
}

fbb.end();
const res = fbb.finish();
const data = Array.from(res);
Expand Down Expand Up @@ -533,19 +541,22 @@ export class CircleEditorDocument
resData._subgraphIdx = subgraphIdx;
resData._nodeIdx = operatorIdx;
resData._type = new Object();

for (const key in customObj) {
let customObjDataType: any = typeof customObj[key];
if (customObjDataType === "number") {
customObjDataType = this.guessExactType(customObj[key]);
if (
customObjDataType === "error" ||
customObjDataType === "not supported type"
) {
Balloon.error("It's not a number.", false);
return;
if (Object.prototype.hasOwnProperty.call(customObj, key)) {
let customObjDataType: any = typeof customObj[key];
if (customObjDataType === "number") {
customObjDataType = this.guessExactType(customObj[key]);
if (
customObjDataType === "error" ||
customObjDataType === "not supported type"
) {
Balloon.error("It's not a number.", false);
return;
}
}
resData._type[key] = customObjDataType;
}
resData._type[key] = customObjDataType;
}
let responseData = { command: "setCustomOpAttrT", data: resData };

Expand Down

0 comments on commit 463573a

Please sign in to comment.