generator-hl-challenge
Advanced tools
Comparing version 1.5.27 to 1.5.28
@@ -20,3 +20,3 @@ const Generator = require('yeoman-generator'); | ||
//Ask the user for the resource UUID from resource editor if not provided generate a random UUID | ||
{ | ||
@@ -36,3 +36,3 @@ type: 'input', | ||
{ | ||
name: 'alpine-base-hl: empty base alpine image with flag and user handling, for your own custom service', | ||
name: 'alpine-base-hl: empty base alpine image with flag and user handling, for your own custom service', | ||
short: 'alpine-base-hl', | ||
@@ -42,3 +42,3 @@ value: 'alpine-base-hl' | ||
{ | ||
name: 'alpine-nginx-hl: NGINX web server for static web sites', | ||
name: 'alpine-nginx-hl: NGINX web server for static web sites', | ||
short: 'alpine-nginx-hl', | ||
@@ -48,3 +48,3 @@ value: 'alpine-nginx-hl' | ||
{ | ||
name: 'alpine-nginx-php-hl: NGINX-PHP web server for static and dynamic web sites', | ||
name: 'alpine-nginx-php-hl: NGINX-PHP web server for static and dynamic web sites', | ||
short: 'alpine-nginx-php-hl', | ||
@@ -54,3 +54,3 @@ value: 'alpine-nginx-php-hl' | ||
{ | ||
name: 'alpine-python-flask-hl: PYTHON-FLASK web application', | ||
name: 'alpine-python-flask-hl: PYTHON-FLASK web application', | ||
short: 'alpine-python-flask-hl', | ||
@@ -60,3 +60,3 @@ value: 'alpine-python-flask-hl' | ||
{ | ||
name: 'alpine-ttyd-hl: WEB-SHELL based on ttyd (without authentication)', | ||
name: 'alpine-ttyd-hl: WEB-SHELL based on ttyd (without authentication)', | ||
short: 'alpine-ttyd-hl', | ||
@@ -66,3 +66,3 @@ value: 'alpine-ttyd-hl' | ||
{ | ||
name: 'alpine-siab-hl: WEB-SHELL based on shell in a box (with authentication)', | ||
name: 'alpine-siab-hl: WEB-SHELL based on shell in a box (with authentication)', | ||
short: 'alpine-siab-hl', | ||
@@ -72,3 +72,3 @@ value: 'alpine-siab-hl' | ||
{ | ||
name: 'alpine-tinyproxy-hl: HTTP/HTTPS Proxy based on tinyproxy', | ||
name: 'alpine-tinyproxy-hl: HTTP/HTTPS Proxy based on tinyproxy', | ||
short: 'alpine-tinyproxy-hl', | ||
@@ -78,3 +78,3 @@ value: 'alpine-tinyproxy-hl' | ||
{ | ||
name: 'alpine-openssh-server-hl: SSH docker server', | ||
name: 'alpine-openssh-server-hl: SSH docker server', | ||
short: 'alpine-openssh-server-hl', | ||
@@ -84,3 +84,3 @@ value: 'alpine-openssh-server-hl' | ||
{ | ||
name: 'alpine-nginx-nodejs-hl: NODEJS node app.js (Hello World)', | ||
name: 'alpine-nginx-nodejs-hl: NODEJS node app.js (Hello World)', | ||
short: 'alpine-nginx-nodejs-hl', | ||
@@ -90,3 +90,3 @@ value: 'alpine-nginx-nodejs-hl' | ||
{ | ||
name: 'alpine-nginx-nodejs-websocketd-hl: NODEJS npm start (Node and Websocket Service)', | ||
name: 'alpine-nginx-nodejs-websocketd-hl: NODEJS npm start (Node and Websocket Service)', | ||
short: 'alpine-nginx-nodejs-websocketd-hl', | ||
@@ -96,3 +96,3 @@ value: 'alpine-nginx-nodejs-websocketd-hl' | ||
{ | ||
name: 'alpine-binary-c-dynamic-hl: Execuable C with compiled flag', | ||
name: 'alpine-binary-c-dynamic-hl: Execuable C with compiled flag', | ||
short: 'alpine-binary-c-dynamic-hl', | ||
@@ -103,3 +103,3 @@ value: 'alpine-binary-c-dynamic-hl' | ||
{ | ||
name: 'alpine-binary-c-hl: Execuable C binary', | ||
name: 'alpine-binary-c-hl: Execuable C binary', | ||
short: 'alpine-binary-c-hl', | ||
@@ -110,3 +110,3 @@ value: 'alpine-binary-c-hl' | ||
{ | ||
name: 'alpine-unitd-hl: Unitd web server : Small unitd web service (static page)', | ||
name: 'alpine-unitd-hl: Unitd web server : Small unitd web service (static page)', | ||
short: 'alpine-unitd-hl', | ||
@@ -117,3 +117,3 @@ value: 'alpine-unitd-hl' | ||
{ | ||
name: 'alpine-nginx-theia-ide: Alpine Linux, s6 startup, NGINX and static web site, Theia web IDE', | ||
name: 'alpine-nginx-theia-ide: Alpine Linux, s6 startup, NGINX and static web site, Theia web IDE', | ||
short: 'alpine-nginx-theia-ide', | ||
@@ -123,3 +123,3 @@ value: 'alpine-nginx-theia-ide' | ||
{ | ||
name: 'alpine-apache2-hl: Alpine apache2 web server', | ||
name: 'alpine-apache2-hl: Alpine apache2 web server', | ||
short: 'alpine-apache2-hl', | ||
@@ -132,22 +132,22 @@ value: 'alpine-apache2-hl' | ||
}, | ||
// Not needed at the moment | ||
// { | ||
// type: 'list', | ||
// name: 'rdocker', | ||
// message: 'What type of container are you developing?', | ||
// choices: [ | ||
// { | ||
// name: 'A normal web application, hosted through a reverse proxy with HTTPS (idocker)', | ||
// short: 'idocker', | ||
// value: false, | ||
// }, | ||
// { | ||
// name: 'Any other type of network service (rdocker)', | ||
// short: 'rdocker', | ||
// value: true, | ||
// } | ||
// ], | ||
// default: false, | ||
// }, | ||
{ | ||
type: 'list', | ||
name: 'dockerType', | ||
message: 'What type of container are you developing?', | ||
choices: [ | ||
{ | ||
name: 'A normal web application, hosted through a reverse proxy with HTTPS (idocker)', | ||
short: 'idocker', | ||
value: 'idocker', | ||
}, | ||
{ | ||
name: 'Any other type of network service (rdocker)', | ||
short: 'rdocker', | ||
value: 'rdocker', | ||
} | ||
], | ||
default: false, | ||
}, | ||
{ | ||
type: 'confirm', | ||
@@ -158,3 +158,25 @@ name: 'goldnugget', | ||
}, | ||
{ | ||
when: (answers) => answers.goldnugget, | ||
type: 'list', | ||
name: 'flagType', | ||
message: 'What type of flag do you want to use?', | ||
choices: [ | ||
{ | ||
name: 'A flag in a file (file flag)', | ||
short: 'file flag', | ||
value: 'file', | ||
}, | ||
{ | ||
name: 'A flag in an environment variable (env flag)', | ||
short: 'env flag', | ||
value: 'env', | ||
} | ||
], | ||
default: false | ||
}, | ||
{ | ||
type: 'input', | ||
@@ -186,5 +208,5 @@ name: 'authorName', | ||
for (const tpl of tplFiles.map(x => x.split(':'))) { | ||
if (fs.existsSync(this.templatePath(tpl[0]) + '.' + this.answers.image)){ | ||
if (fs.existsSync(this.templatePath(tpl[0]) + '.' + this.answers.image)) { | ||
tpl[1] = tpl[0]; | ||
tpl[0]+= '.' + this.answers.image; | ||
tpl[0] += '.' + this.answers.image; | ||
} | ||
@@ -199,10 +221,13 @@ this.fs.copyTpl( | ||
if (this.answers.goldnugget && this.answers.uuid) { | ||
this.fs.write( | ||
this.destinationPath(this.answers.uuid + '.gn'), | ||
'GOLDNUGGET=SED_GOLDNUGGET' | ||
); | ||
this.fs.write( | ||
this.destinationPath(this.answers.uuid + '.env'), | ||
'GOLDNUGGET=SED_GOLDNUGGET' | ||
); | ||
if (this.answers.env) { | ||
this.fs.write( | ||
this.destinationPath(this.answers.uuid + '.env'), | ||
'GOLDNUGGET=SED_GOLDNUGGET' | ||
); | ||
} else { | ||
this.fs.write( | ||
this.destinationPath(this.answers.uuid + '.gn'), | ||
'GOLDNUGGET=SED_GOLDNUGGET' | ||
); | ||
} | ||
this.fs.copyTpl( | ||
@@ -213,5 +238,3 @@ this.templatePath('flag-deploy-scripts'), | ||
); | ||
} | ||
if (!this.answers.goldnugget) { | ||
} else if (!this.answers.goldnugget) { | ||
this.fs.write( | ||
@@ -225,7 +248,52 @@ this.destinationPath('root/no_gn_flag.md'), | ||
this.fs.copyTpl( | ||
this.templatePath(this.answers.image), | ||
this.destinationPath('root'), | ||
this.answers | ||
this.templatePath(this.answers.image), | ||
this.destinationPath('root'), | ||
this.answers | ||
); | ||
} | ||
} | ||
const configFolder = this.answers.dockerType === 'idocker' ? 'idocker' : 'rdocker'; | ||
const name = this.answers.name; | ||
let dockermanagerFile = 'dockermanager_no_gn.json'; | ||
if (this.answers.goldnugget) { | ||
dockermanagerFile = `dockermanager_${this.answers.flagType}_gn.json`; | ||
} | ||
const composeFile = 'compose.yml'; | ||
const filesToCopy = [dockermanagerFile, composeFile]; | ||
filesToCopy.forEach((file) => { | ||
let fileContents = this.fs.read(this.templatePath(`configs/${configFolder}/${file}`)); | ||
// replace resname with the provided name in compose.yml | ||
if (file === composeFile) { | ||
fileContents = fileContents.replace(/resname/g, name); | ||
// replace env_file with uuid.env in compose.yml | ||
if (this.answers.flagType === 'env') { | ||
fileContents = fileContents.replace(/env_file:\n\s+-.*\.env/gm, `env_file:\n - ./${this.answers.uuid}.env`); | ||
fileContents = fileContents.replace(/\.\/[a-f0-9\-]{36}---.*\.gn/gm, ''); | ||
} | ||
// replace volumes with uuid---hobo.gn in compose.yml | ||
if (this.answers.flagType === 'file') { | ||
fileContents = fileContents.replace(/volumes:\n\s+-.*\.gn/gm, `volumes:\n - ./${this.answers.uuid}---hobo.gn:/goldnugget/${this.answers.uuid}.gn`); | ||
fileContents = fileContents.replace(/volumes:\n\s+-.*\.env/gm, ''); | ||
} | ||
} | ||
if (file === dockermanagerFile) { | ||
const dockermanager = JSON.parse(fileContents); | ||
dockermanager.name = name; | ||
dockermanager.container = `REGISTRY_BASE_URL/${name}:stable`; | ||
dockermanager.network = name; | ||
dockermanager.containeryml = `${dockermanager.type}.yml`; | ||
fileContents = JSON.stringify(dockermanager, null, 2); | ||
} | ||
this.fs.write(this.destinationPath(`configs/${configFolder}/${file}`), fileContents); | ||
}); | ||
} | ||
@@ -232,0 +300,0 @@ |
{ | ||
"name": "generator-hl-challenge", | ||
"version": "1.5.27", | ||
"version": "1.5.28", | ||
"description": "Hacking-Lab Challenge container generator", | ||
@@ -5,0 +5,0 @@ "files": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9435614
272
50934
4