mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 23:33:13 +09:00
security(minimap): fix path traversal in controller file loading
This commit is contained in:
1 parent
5ff7d7ee42
commit
245ceb14fa
1 file changed
+15
-3
@@ -839,7 +839,11 @@ export class ControllerPlugin extends BaseControllerPlugin {
|
|||||||
|
|
||||||
private async loadTagContentFromFile(file: string) {
|
private async loadTagContentFromFile(file: string) {
|
||||||
const fileKey = file.replace("_chart_tags.json", "");
|
const fileKey = file.replace("_chart_tags.json", "");
|
||||||
const filePath = path.join(this.chartTagsPath, file);
|
const filePath = resolveFileInDir(this.chartTagsPath, file);
|
||||||
|
if (filePath === null) {
|
||||||
|
this.logger.warn(`Invalid chart tag file path: ${file}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.lastSeenTagContent.has(fileKey)) {
|
if (!this.lastSeenTagContent.has(fileKey)) {
|
||||||
this.lastSeenTagContent.set(fileKey, new Map());
|
this.lastSeenTagContent.set(fileKey, new Map());
|
||||||
@@ -897,7 +901,11 @@ export class ControllerPlugin extends BaseControllerPlugin {
|
|||||||
|
|
||||||
for (const file of recipeFiles) {
|
for (const file of recipeFiles) {
|
||||||
const tileKey = file.replace(".recipes", "");
|
const tileKey = file.replace(".recipes", "");
|
||||||
const filePath = path.join(this.recipeTilesPath, file);
|
const filePath = resolveFileInDir(this.recipeTilesPath, file);
|
||||||
|
if (filePath === null) {
|
||||||
|
this.logger.warn(`Invalid recipe file path: ${file}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Initialise structures
|
// Initialise structures
|
||||||
this.lastSeenRecipeContent.set(tileKey, new Map());
|
this.lastSeenRecipeContent.set(tileKey, new Map());
|
||||||
@@ -1672,7 +1680,11 @@ export class ControllerPlugin extends BaseControllerPlugin {
|
|||||||
|
|
||||||
for (const file of positionFiles) {
|
for (const file of positionFiles) {
|
||||||
const fileKey = file.replace(".positions", "");
|
const fileKey = file.replace(".positions", "");
|
||||||
const filePath = path.join(this.playerPositionsPath, file);
|
const filePath = resolveFileInDir(this.playerPositionsPath, file);
|
||||||
|
if (filePath === null) {
|
||||||
|
this.logger.warn(`Invalid player positions file path: ${file}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.playerSessions.has(fileKey)) {
|
if (!this.playerSessions.has(fileKey)) {
|
||||||
this.playerSessions.set(fileKey, new Map());
|
this.playerSessions.set(fileKey, new Map());
|
||||||
|
|||||||
Reference in new issue
Block a user