From 1515a008f04655596641735fc2441885a6b1a483 Mon Sep 17 00:00:00 2001 From: James Date: Sun, 11 Jun 2017 20:30:44 +1000 Subject: [PATCH] Add checks to check for unknown files --- _validation/app.js | 15 ++++++++++++--- _validation/config.json | 6 +++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/_validation/app.js b/_validation/app.js index 2ebac55..9b2d8ce 100644 --- a/_validation/app.js +++ b/_validation/app.js @@ -184,7 +184,7 @@ function validateTOML(path) { if (field === "vc") { validateContents(tomlDoc, "vc_system", field => { - if (config.vc-systems.indexOf(field) === -1) { + if (config.vc_systems.indexOf(field) === -1) { validationError(`Could not find VC console \"${field}\"!`); } }); @@ -355,13 +355,22 @@ getDirectories(config.directory).forEach(function (game) { let inputDirectoryGame = `${config.directory}/${game}`; currentGame = game; - // Check that everything is lowercase. + // Check that everything is lowercase and is a known file. getFiles(inputDirectoryGame).forEach(file => { - if (!isValidFilename(file)) { + if (config.permitted_files.indexOf(file) === -1) { + validationError(`Unknown file \"${file}\"!`); + } else if (!isValidFilename(file)) { validationError(`File \"${file}\" contains bad characters!`); } }); + // Check that all directories are known. + getDirectories(inputDirectoryGame).forEach(file => { + if (config.permitted_dirs.indexOf(file) === -1) { + validationError(`Unknown directory \"${file}\"!`); + } + }); + // Verify the game's boxart. validateImage(`${inputDirectoryGame}/${config.boxart.filename}`, config.boxart); diff --git a/_validation/config.json b/_validation/config.json index d27618f..71d9739 100644 --- a/_validation/config.json +++ b/_validation/config.json @@ -2,7 +2,11 @@ "directory": "..", "regions": ["jpn", "usa", "eur", "aus", "chn", "kor", "twn", "all"], "gametypes": ["vc", "dsi", "eshop"], - "vc-systems": ["nes", "snes", "gb", "gbc", "gba", "gg"], + "vc_systems": ["nes", "snes", "gb", "gbc", "gba", "gg"], + + "permitted_files": ["boxart.png", "icon.png", "game.dat"], + "permitted_dirs": ["screenshots", "savefiles"], + "boxart": { "filename": "boxart.png", "sizes": [{"width": 328, "height": 300}, {"width": 500, "height": 300}], "type": "image/png"}, "icon": { "filename": "icon.png", "sizes": [{"width": 48, "height": 48}], "type": "image/png"}, "screenshots": { "dirname": "screenshots", "sizes": [{"width": 400, "height": 480}], "type": "image/png"},