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:
parent
e8e764c3b7
commit
cb8d914fef
5 changed files with 96 additions and 3 deletions
|
@ -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}"`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue