mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-23 00:06:17 -04:00
removing topic regex
This commit is contained in:
parent
fe4a5fbd46
commit
6356145989
1 changed files with 5 additions and 8 deletions
|
@ -50,15 +50,12 @@ class MQTTPublish extends Operation {
|
|||
run(input, args) {
|
||||
const [broker, topic] = args;
|
||||
const mqttUrlRegex = /^(ws|mqtt)s?:\/\/(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]))*|([01]?[0-9][0-9]?|2[0-4][0-9]|25[0-5])(\.([01]?[0-9][0-9]?|2[0-4][0-9]|25[0-5])){3}|(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])))(:([1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?/;
|
||||
const mqttTopicRegex = /^[\u0000-\uFFFF]+(\/[\u0000-\uFFFF]+)+$/;
|
||||
if (mqttUrlRegex.test(broker)) {
|
||||
if (mqttTopicRegex.test(broker)) {
|
||||
const client = mqtt.connect(broker);
|
||||
client.on("connect", () => {
|
||||
client.publish(topic, Buffer.from(input));
|
||||
client.end();
|
||||
});
|
||||
} else throw new OperationError(`Invalid MQTT topic name - ${topic}`);
|
||||
const client = mqtt.connect(broker);
|
||||
client.on("connect", () => {
|
||||
client.publish(topic, Buffer.from(input));
|
||||
client.end();
|
||||
});
|
||||
} else throw new OperationError(`Invalid MQTT broker URL - ${broker}`);
|
||||
return input;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue