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

nomics-platform

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nomics-platform - npm Package Compare versions

Comparing version 0.5.8 to 0.6.0

example/index.js

64

lib/audit/index.js
const url = require('url')
const { spawn } = require('child_process')
const net = require('net')
const teenytest = require('teenytest')
const Info = require('./info')
const Market = require('./market')
const Trade = require('./trade')
module.exports = async function (options) {
module.exports = function (options) {
if (options.length < 1) {
return new Error('audit requires at least one argument: a url to and endpoint or a script file to run as an endpoint.')
console.log('audit requires at least one argument: a url to and endpoint or a script file to run as an endpoint.')
process.exit(1)
}

@@ -24,26 +22,17 @@ const endpoint = options[0]

async function auditURL (u) {
const results = []
results.push(...await Info(u))
results.push(...await Market(u))
results.push(...await Trade(u))
console.log(results.map((r) => r.toString()).join('\n'))
const anyRequiredFailures = results.some((r) => r.required && !r.pass)
if (anyRequiredFailures) {
return new Error('\x1B[31mAudit Failed: One or more required audits failed\x1B[0m')
}
const anyOptionalFailures = results.some((r) => !r.required && !r.pass)
if (anyOptionalFailures) {
console.log('\x1B[33mAudit Passed, but some optional audits failed\x1B[0m')
} else {
console.log('\x1B[32mAudit Passed\x1b[0m')
}
function auditURL (u) {
return new Promise((resolve, reject) => {
process.chdir(__dirname)
process.env.NOMICS_PLATFORM_URL_ROOT = u
teenytest('test/*.js', {plugins: ['teenytest-promise']}, (err, passing) => {
if (err || !passing) {
reject(new Error('Audit Failed'))
} else {
resolve()
}
})
})
}
async function auditCommand (command, options) {
function auditCommand (command, options) {
const parts = command.split(' ')

@@ -57,10 +46,5 @@ const child = spawn(parts[0], parts.slice(1))

child.stdout.on('data', (data) => {
console.log(`server: ${data}`)
})
child.stdout.on('data', (data) => console.log(`server: ${data}`))
child.stderr.on('data', (data) => console.log(`server: ${data}`))
child.stderr.on('data', (data) => {
console.log(`server: ${data}`)
})
return new Promise(async (resolve, reject) => {

@@ -74,4 +58,10 @@ child.on('error', reject)

}
const result = await auditURL(`http://localhost:${port}${path}`)
let err
try {
err = await auditURL(`http://localhost:${port}${path}`)
} catch (e) {
err = e
}
await new Promise((resolve, reject) => {

@@ -82,3 +72,3 @@ child.on('exit', resolve)

resolve(result)
resolve(err)
})

@@ -85,0 +75,0 @@ }

var audit = require('./audit')
class UsageError extends Error {}
module.exports = async function (argv) {
var err = await run(argv)
if (err) {
console.log('\n' + err.toString() + '\n')
if (err instanceof UsageError) {
usage()
}
module.exports = function (argv) {
if (argv.length < 1) {
usage()
process.exit(1)
}
}
async function run (argv) {
if (argv.length < 1) {
return new UsageError('Command is required')
}
var command = argv[0]
var options = argv.slice(1)
switch (command) {
case 'audit': return audit(options)
default: return new UsageError('Unknown command: ' + command)
default:
usage()
process.exit(1)
}

@@ -32,4 +24,5 @@ }

'Commands:',
'\taudit [url] [path-to-root]'
'\taudit url',
'\taudit "command to run server on localhost:3000" [path to root]'
].join('\n\t'))
}
{
"name": "nomics-platform",
"version": "0.5.8",
"version": "0.6.0",
"description": "Nomics Platform Toolkit",

@@ -30,3 +30,4 @@ "keywords": [

"cli": "node bin/nomics-platform.js",
"lint": "eslint **/*.js"
"lint": "eslint **/*.js",
"test": "yarn cli audit \"node ./example/index.js\""
},

@@ -39,7 +40,10 @@ "devDependencies": {

"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-standard": "^3.1.0"
"eslint-plugin-standard": "^3.1.0",
"express": "^4.16.3"
},
"dependencies": {
"axios": "^0.18.0"
"axios": "^0.18.0",
"teenytest": "^5.1.1",
"teenytest-promise": "^1.0.0"
}
}
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