Add defensive guards for multi-node config updates

This commit is contained in:
Cosimo Ricciardi 2026-05-14 12:10:07 +02:00 committed by Suheb
parent 18a40ed183
commit a11179085b
4 changed files with 6 additions and 2 deletions

View file

@ -254,7 +254,7 @@ export const updateApplicationSettings = (req, res, next) => {
try {
const oldConfig = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
const config = common.addSecureData(JSON.parse(JSON.stringify(req.body)));
const runtimeConfig = JSON.parse(JSON.stringify(oldConfig));
const runtimeConfig = oldConfig;
Object.keys(config).forEach((key) => {
if (key !== 'nodes') {
runtimeConfig[key] = config[key];
@ -298,6 +298,7 @@ export const updateApplicationSettings = (req, res, next) => {
delete fileConfig.allowPasswordUpdate;
delete fileConfig.rtlConfFilePath;
delete fileConfig.rtlPass;
delete fileConfig.multiPass;
fileConfig.nodes?.forEach((node) => {
delete node.authentication?.options;
delete node.authentication?.runeValue;

View file

@ -73,6 +73,7 @@ export class CommonService {
config.nodes?.forEach((node) => {
const appConfigNode = appConfigNodes.get(node.index);
if (appConfigNode?.authentication) {
node.authentication = node.authentication || {};
if (appConfigNode.authentication.macaroonPath) {
node.authentication.macaroonPath = appConfigNode.authentication.macaroonPath;
}

View file

@ -254,7 +254,7 @@ export const updateApplicationSettings = (req, res, next) => {
try {
const oldConfig = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
const config = common.addSecureData(JSON.parse(JSON.stringify(req.body)));
const runtimeConfig = JSON.parse(JSON.stringify(oldConfig));
const runtimeConfig = oldConfig;
Object.keys(config).forEach((key) => {
if (key !== 'nodes') {
runtimeConfig[key] = config[key];
@ -298,6 +298,7 @@ export const updateApplicationSettings = (req, res, next) => {
delete fileConfig.allowPasswordUpdate;
delete fileConfig.rtlConfFilePath;
delete fileConfig.rtlPass;
delete fileConfig.multiPass;
fileConfig.nodes?.forEach((node) => {
delete node.authentication?.options;
delete node.authentication?.runeValue;

View file

@ -82,6 +82,7 @@ export class CommonService {
config.nodes?.forEach((node) => {
const appConfigNode = appConfigNodes.get(node.index);
if (appConfigNode?.authentication) {
node.authentication = node.authentication || {};
if (appConfigNode.authentication.macaroonPath) {
node.authentication.macaroonPath = appConfigNode.authentication.macaroonPath;
}