New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

juice-shop-ctf-cli

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

juice-shop-ctf-cli - npm Package Compare versions

Comparing version 4.0.1 to 4.1.0

.dockerignore

3

CONTRIBUTING.md

@@ -67,3 +67,3 @@ # Contributing [![GitHub contributors](https://img.shields.io/github/contributors/bkimminich/juice-shop-ctf.svg)](https://github.com/bkimminich/juice-shop-ctf/graphs/contributors) [![Stories in Ready](https://badge.waffle.io/bkimminich/juice-shop.svg?label=ready&title=Ready)](http://waffle.io/bkimminich/juice-shop)

Thean e2e tests simulate real input to the CLI and verify the printed
The e2e tests simulate real input to the CLI and verify the printed
output to the console.

@@ -90,2 +90,1 @@

> Travis-CI due to their significant execution time.

@@ -7,4 +7,25 @@ const inquirer = require('inquirer')

const writeToZipFile = require('./lib/writeToZipFile')
const readConfigStream = require('./lib/readConfigStream')
const fs = require('fs')
const options = require('./lib/options')
const argv = require('yargs')
.option('config', {
alias: 'c',
describe: 'provide a configuration file'
})
.option('output', {
alias: 'o',
describe: 'change the output file'
})
.help()
.argv
function getConfig (argv, questions) {
if (argv.config) {
return readConfigStream(fs.createReadStream(argv.config))
}
return inquirer.prompt(questions)
}
const juiceShopCtfCli = async () => {

@@ -44,3 +65,3 @@ const questions = [

try {
const {ctfKey, juiceShopUrl, insertHints, insertHintUrls} = await inquirer.prompt(questions)
const {ctfKey, juiceShopUrl, insertHints, insertHintUrls} = await getConfig(argv, questions)
const [secretKey, challenges] = await Promise.all([

@@ -51,3 +72,3 @@ fetchSecretKey(ctfKey),

const data = await generateData(challenges, insertHints, insertHintUrls, secretKey)
const file = await writeToZipFile(data)
const file = await writeToZipFile(data, argv.output)

@@ -54,0 +75,0 @@ console.log()

@@ -9,5 +9,5 @@ const Promise = require('bluebird')

function writeToZipFile ({challenges, hints, flagKeys}) {
function writeToZipFile ({challenges, hints, flagKeys}, desiredFileName) {
return new Promise((resolve, reject) => {
const fileName = 'OWASP_Juice_Shop.' + dateFormat(new Date(), 'yyyy-mm-dd') + '.zip'
const fileName = desiredFileName || 'OWASP_Juice_Shop.' + dateFormat(new Date(), 'yyyy-mm-dd') + '.zip'
zip.file('db/challenges.json', JSON.stringify(challenges))

@@ -14,0 +14,0 @@ zip.file('db/hints.json', JSON.stringify(hints))

{
"name": "juice-shop-ctf-cli",
"version": "4.0.1",
"description": "Command line client to generate INSERT statements for CTFd with the OWASP Juice Shop challenges",
"version": "4.1.0",
"description": "Capture-the-Flag (CTF) environment setup tools for OWASP Juice Shop",
"author": "Bjoern Kimminich <bjoern.kimminich@owasp.org> (https://www.owasp.org/index.php/User:Bjoern_Kimminich)",

@@ -52,8 +52,11 @@ "contributors": [

"colors": "~1.2",
"yargs": "~11.1.0",
"dateformat": "~3.0",
"inquirer": "~5.1",
"inquirer": "~5.2.0",
"jssha": "~2.3",
"js-yaml": "3.11.0",
"node-zip": "~1.1",
"path": "~0.12",
"request": "~2.85",
"joi": "13.1.2",
"request-promise": "~4.2"

@@ -78,2 +81,4 @@ },

"stryker-html-reporter": "~0",
"stryker-javascript-mutator": "~0",
"stryker-mocha-framework": "~0",
"stryker-mocha-runner": "~0"

@@ -94,4 +99,4 @@ },

"nyc": {
"report-dir": "./reports/coverage"
"report-dir": "./build/reports/coverage"
}
}

@@ -31,2 +31,4 @@ # ![Juice Shop CTF Logo](https://raw.githubusercontent.com/bkimminich/juice-shop-ctf/master/images/JuiceShopCTF_Logo_100px.png) OWASP Juice Shop CTF [![OWASP Labs](https://img.shields.io/badge/owasp-lab%20project-f7b73c.svg)](https://www.owasp.org/index.php/OWASP_Project_Inventory#tab=Labs_Projects) [![GitHub release](https://img.shields.io/github/release/bkimminich/juice-shop-ctf.svg)](https://github.com/bkimminich/juice-shop-ctf/releases/latest) [![Twitter Follow](https://img.shields.io/twitter/follow/owasp_juiceshop.svg?style=social&label=Follow)](https://twitter.com/owasp_juiceshop)

### Interactive Mode
Open a command line and run:

@@ -40,2 +42,42 @@

### Configuration File
Instead of answering questions in the CLI you can also provide your desired configuration in a file with the following format:
```yaml
juiceShopUrl: https://juice-shop.herokuapp.com
ctfKey: https://raw.githubusercontent.com/bkimminich/juice-shop/master/ctf.key # can also be actual key instead URL
insertHints: none | free | paid
insertHintUrls: none | free | paid
```
You can then run the generator with:
```
juice-shop-ctf --config myconfig.yml
```
Optionally you can also choose the name of the output file:
```
juice-shop-ctf --config myconfig.yml --output challenges.zip
```
### Docker Container [![Docker Automated build](https://img.shields.io/docker/automated/bkimminich/juice-shop-ctf.svg)](https://registry.hub.docker.com/u/bkimminich/juice-shop-ctf/) [![Docker Pulls](https://img.shields.io/docker/pulls/bkimminich/juice-shop-ctf.svg)](https://registry.hub.docker.com/u/bkimminich/juice-shop-ctf/) [![](https://images.microbadger.com/badges/image/bkimminich/juice-shop-ctf.svg)](https://microbadger.com/images/bkimminich/juice-shop-ctf "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/version/bkimminich/juice-shop-ctf.svg)](https://microbadger.com/images/bkimminich/juice-shop-ctf "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/commit/bkimminich/juice-shop-ctf.svg)](https://microbadger.com/images/bkimminich/juice-shop-ctf "Get your own commit badge on microbadger.com")
Share your current directory with the `/data` volume of your `bkimminich/juice-shop-ctf` Docker container and run the interactive mode with:
```
docker run -ti --rm -v $(pwd):/data bkimminich/juice-shop-ctf
```
Alternatively you can provide a configuration file via:
```
docker run -ti --rm -v $(pwd):/data bkimminich/juice-shop-ctf --config myconfig.yml
```
Choosing the name of the output file is also possible:
```
docker run -ti --rm -v $(pwd):/data bkimminich/juice-shop-ctf --config myconfig.yml --output challenges.zip
```
---
**For detailed step-by-step instructions and examples please refer to

@@ -80,10 +122,15 @@ [the _Setting up CTFd for Juice Shop_ in the _Hosting a CTF event_ chapter](https://bkimminich.gitbooks.io/pwning-owasp-juice-shop/content/part1/ctf.html#setting-up-ctfd-for-juice-shop)

PayPal donations via above button go to the OWASP Foundations and are
earmarked for "Juice Shop". This is the preferred way to support the
project.
earmarked for "Juice Shop". This is the preferred and most convenient
way to support the project.
### Others
### Credit Card (through RegOnline)
[![Flattr](https://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/thing/3856930/bkimminichjuice-shop-on-GitHub)
[![Gratipay](http://img.shields.io/gratipay/team/juice-shop.svg)](https://gratipay.com/juice-shop)
OWASP hosts a
[donation form on RegOnline](https://www.regonline.com/Register/Checkin.aspx?EventID=1044369).
Refer to the
[Credit card donation step-by-step](https://bkimminich.gitbooks.io/pwning-owasp-juice-shop/content/part3/donations.html#credit-card-donation-step-by-step)
guide for help with filling out the donation form correctly.
### Crypto Currency
[![Bitcoin](https://img.shields.io/badge/bitcoin-1AbKfgvw9psQ41NbLi8kufDQTezwG8DRZm-orange.svg)](https://blockchain.info/address/1AbKfgvw9psQ41NbLi8kufDQTezwG8DRZm)

@@ -90,0 +137,0 @@ [![Dash](https://img.shields.io/badge/dash-Xr556RzuwX6hg5EGpkybbv5RanJoZN17kW-blue.svg)](https://explorer.dash.org/address/Xr556RzuwX6hg5EGpkybbv5RanJoZN17kW)

@@ -11,4 +11,11 @@ module.exports = function (config) {

coverageAnalysis: 'perTest',
reporter: ['html', 'progress']
mutator: 'javascript',
reporter: ['html', 'progress'],
htmlReporter: {
baseDir: 'build/reports/mutation'
}
})
if (process.env.TRAVIS_BUILD_NUMBER) {
config.reporter = ['clear-text', 'progress']
}
}

@@ -12,11 +12,24 @@ const chai = require('chai')

const outputFile = 'OWASP_Juice_Shop.' + dateFormat(new Date(), 'yyyy-mm-dd') + '.zip'
const desiredOutputFile = './output.zip'
const configFile = 'config.yml'
const util = require('util')
const execFile = util.promisify(require('child_process').execFile)
const juiceShopCtfCli = [path.join(__dirname, '../../bin/juice-shop-ctf.js')]
function cleanup () {
if (fs.existsSync(outputFile)) {
fs.unlinkSync(outputFile)
}
if (fs.existsSync(configFile)) {
fs.unlinkSync(configFile)
}
if (fs.existsSync(desiredOutputFile)) {
fs.unlinkSync(desiredOutputFile)
}
}
describe('juice-shop-ctf', () => {
beforeEach(() => {
if (fs.existsSync(outputFile)) {
fs.unlinkSync(outputFile)
}
})
beforeEach(cleanup)
after(cleanup)

@@ -73,2 +86,50 @@ it('should accept defaults for all input questions', function () {

})
it('should accept a config file', function () {
fs.writeFileSync(configFile, `
juiceShopUrl: https://juice-shop.herokuapp.com
ctfKey: https://raw.githubusercontent.com/bkimminich/juice-shop/master/ctf.key
insertHints: paid
insertHintUrls: paid`)
this.timeout(15000)
return expect(execFile('npx', [juiceShopCtfCli[0], '--config', configFile]).then(obj => obj.stdout)).to
.eventually.match(/ZIP-archive written to /i)
})
it('should fail when the config file is unparsable', function () {
fs.writeFileSync(configFile, `
juiceShopUrl: https://juice-shop.herokuapp.com
ctfKey: https://raw.githubusercontent.com/bkimminich/juice-shop/master/ctf.key
insertHints`)
this.timeout(15000)
return expect(execFile('npx', [juiceShopCtfCli[0], '--config', configFile]).then(obj => obj.stdout)).to
.eventually.match(/can not read /i)
})
it('should fail when the config file contains invalid values', function () {
fs.writeFileSync(configFile, `
juiceShopUrl: https://juice-shop.herokuapp.com
ctfKey: https://raw.githubusercontent.com/bkimminich/juice-shop/master/ctf.key
insertHints: paid
insertHintUrls: invalidValue`)
this.timeout(15000)
return expect(execFile('npx', [juiceShopCtfCli[0], '--config', configFile]).then(obj => obj.stdout)).to
.eventually.match(/"insertHintUrls" must be one of /i)
})
it('should write the output file to the specified location', function () {
fs.writeFileSync(configFile, `
juiceShopUrl: https://juice-shop.herokuapp.com
ctfKey: https://raw.githubusercontent.com/bkimminich/juice-shop/master/ctf.key
insertHints: paid
insertHintUrls: paid`)
this.timeout(15000)
return expect(execFile('npx', [juiceShopCtfCli[0], '--config', configFile, '--output', desiredOutputFile])
.then(() => fs.existsSync(desiredOutputFile))).to
.eventually.equal(true)
})
})

@@ -39,2 +39,22 @@ const Promise = require('bluebird')

})
it('should be written to the desired ZIP file', () => {
writeToZipFile.__set__({
console: {
log () {}
},
fs: {
writeFileAsync (path, data) {
expect(data).to.match(/challenges.json/)
expect(data).to.match(/hints.json/)
expect(data).to.match(/keys.json/)
expect(data).to.match(/files.json/)
expect(data).to.match(/tags.json/)
expect(path).to.match(/custom\.zip/)
return new Promise(resolve => { resolve() })
}}
})
return expect(writeToZipFile({challenges: {results: []}, flagKeys: {results: []}, hints: {results: []}}, 'custom.zip'))
.to.be.fulfilled
})
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc