3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-17 23:25:02 +00:00

Disallow anchors/aliases to objects when loading config YAML

This commit is contained in:
Dragory 2021-08-14 18:22:29 +03:00
parent e8e764c3b7
commit cb8d914fef
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
5 changed files with 96 additions and 3 deletions

View file

@ -19,6 +19,7 @@ import { SimpleError } from "./SimpleError";
import { ZeppelinGlobalConfig, ZeppelinGuildConfig } from "./types";
import { startUptimeCounter } from "./uptime";
import { errorMessage, isDiscordAPIError, isDiscordHTTPError, successMessage } from "./utils";
import { loadYamlSafely } from "./utils/loadYamlSafely";
if (!process.env.KEY) {
// tslint:disable-next-line:no-console
@ -209,7 +210,12 @@ connect().then(async () => {
const key = id === "global" ? "global" : `guild-${id}`;
const row = await guildConfigs.getActiveByKey(key);
if (row) {
return yaml.safeLoad(row.config);
try {
return loadYamlSafely(row.config);
} catch (err) {
logger.error(`Error while loading config "${key}": ${err.message}`);
return {};
}
}
logger.warn(`No config with key "${key}"`);