Enforce real folder names

This commit is contained in:
Webber
2020-01-29 23:42:41 +01:00
committed by Webber Takken
parent 2ca91788af
commit 28154ea36e
3 changed files with 23 additions and 6 deletions

View File

@@ -6,6 +6,12 @@ class Input {
return ['all', 'playmode', 'editmode'];
}
static isValidFolderName(folderName) {
const validFolderName = new RegExp(/^(\.|\.\/)?(\.?\w+\/?)*$/);
return validFolderName.test(folderName);
}
static getFromUser() {
// Input variables specified in workflow using "with" prop.
const unityVersion = getInput('unityVersion') || '2019.2.11f1';
@@ -18,6 +24,14 @@ class Input {
throw new Error(`Invalid testMode ${testMode}`);
}
if (!this.isValidFolderName(rawArtifactsPath)) {
throw new Error(`Invalid artifactsPath "${rawArtifactsPath}"`);
}
if (!this.isValidFolderName(rawProjectPath)) {
throw new Error(`Invalid projectPath "${rawProjectPath}"`);
}
// Sanitise input
const projectPath = rawProjectPath.replace(/\/$/, '');
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');