mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Fixed issues in Protobuf parsing
This commit is contained in:
parent
05bfa9158d
commit
f831ec6b7e
1 changed files with 9 additions and 9 deletions
|
@ -141,7 +141,7 @@ class Protobuf {
|
||||||
const messageNames = [];
|
const messageNames = [];
|
||||||
const fieldTypes = [];
|
const fieldTypes = [];
|
||||||
this.parsedProto.root.nestedArray.forEach(block => {
|
this.parsedProto.root.nestedArray.forEach(block => {
|
||||||
if (block.constructor.name === "Type") {
|
if (block instanceof protobuf.Type) {
|
||||||
messageNames.push(block.name);
|
messageNames.push(block.name);
|
||||||
this.parsedProto.root.nested[block.name].fieldsArray.forEach(field => {
|
this.parsedProto.root.nested[block.name].fieldsArray.forEach(field => {
|
||||||
fieldTypes.push(field.type);
|
fieldTypes.push(field.type);
|
||||||
|
@ -152,12 +152,12 @@ class Protobuf {
|
||||||
if (messageNames.length === 0) {
|
if (messageNames.length === 0) {
|
||||||
this.mainMessageName = null;
|
this.mainMessageName = null;
|
||||||
} else {
|
} else {
|
||||||
for (const name of messageNames) {
|
// for (const name of messageNames) {
|
||||||
if (!fieldTypes.includes(name)) {
|
// if (!fieldTypes.includes(name)) {
|
||||||
this.mainMessageName = name;
|
// this.mainMessageName = name;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
this.mainMessageName = messageNames[0];
|
this.mainMessageName = messageNames[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ class Protobuf {
|
||||||
*/
|
*/
|
||||||
static appendTypesToFieldNames(schemaRoot) {
|
static appendTypesToFieldNames(schemaRoot) {
|
||||||
for (const block of schemaRoot.nestedArray) {
|
for (const block of schemaRoot.nestedArray) {
|
||||||
if (block.constructor.name === "Type") {
|
if (block instanceof protobuf.Type) {
|
||||||
for (const [fieldName, fieldData] of Object.entries(block.fields)) {
|
for (const [fieldName, fieldData] of Object.entries(block.fields)) {
|
||||||
schemaRoot.nested[block.name].remove(block.fields[fieldName]);
|
schemaRoot.nested[block.name].remove(block.fields[fieldName]);
|
||||||
schemaRoot.nested[block.name].add(new protobuf.Field(`${fieldName} (${fieldData.type})`, fieldData.id, fieldData.type, fieldData.rule));
|
schemaRoot.nested[block.name].add(new protobuf.Field(`${fieldName} (${fieldData.type})`, fieldData.id, fieldData.type, fieldData.rule));
|
||||||
|
@ -306,7 +306,7 @@ class Protobuf {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for submessage fields
|
// Check for submessage fields
|
||||||
if (schemaField.resolvedType !== null && schemaField.resolvedType.constructor.name === "Type") {
|
if (schemaField.resolvedType instanceof protobuf.Type) {
|
||||||
const subMessageType = schemaMessage.fields[schemaFieldName].type;
|
const subMessageType = schemaMessage.fields[schemaFieldName].type;
|
||||||
const schemaSubMessage = this.parsedProto.root.nested[subMessageType];
|
const schemaSubMessage = this.parsedProto.root.nested[subMessageType];
|
||||||
const rawSubMessages = rawDecodedMessage[fieldName];
|
const rawSubMessages = rawDecodedMessage[fieldName];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue