You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

sslping-cli

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sslping-cli - npm Package Compare versions

Comparing version

to
1.0.5

npm-shrinkwrap.json

7

package.json
{
"name": "sslping-cli",
"version": "1.0.4",
"version": "1.0.5",
"description": "CLI for sslping.com",

@@ -8,3 +8,3 @@ "main": "index.js",

"test": "echo \"Error: no test specified\" && exit 1",
"prepublish": "babel src/index.js >index.js"
"prepublish": "babel src/index.js > lib/index.js"
},

@@ -28,7 +28,6 @@ "repository": {

"bin": {
"sslping-cli": "./index.js"
"sslping-cli": "./lib/index.js"
},
"dependencies": {
"async": "*",
"elegant-status": "*",
"node-fetch": "^1.6.0",

@@ -35,0 +34,0 @@ "optimist": "*",

# What is sslping.com
https://sslping.com allows you to monitor your SSL/TLS certificates and
security configuration easily and for free. You'll receive an email if your
security configuration easily for free. You'll receive an email if your
certificates expire, or if a misconfiguration is detected.
# Usage
# Install
This CLI allows you to bulk-load servers to sslping.com
You need node.js to use sslping-cli.
Install with `npm install -g sslping-cli`
Usage: `sslping-cli -u [email] -p [password] server[:port] ...`
# Usage
Example: `sslping-cli -u me@mydomain -p myPassword google.com facebook.com twitter.com`
or `cat servers.txt | xargs sslping-cli -u me@mydomain -p myPassword`
This CLI allows you to import new servers to sslping, and to export a JSON document with all your servers and status.
Servers are then added to your account (and checked!).
Help: `sslping-cli --help`
Import example: `sslping-cli -u me@mydomain -p myPassword import google.com facebook.com twitter.com`
or `cat servers.txt | xargs sslping-cli -u me@mydomain -p myPassword --quiet=true import > imported.csv`
Export example: `sslping-cli -u me@mydomain -p myPassword --quiet=true export > myservers.json`
**Note: JSON export format may change in the future (ie. this route is used by the react webapp)**
#!/usr/bin/env node
global.Promise = global.Promise ? Promise : require('promise-polyfill');
const status = require('elegant-status');
const Optimist = require('optimist');

@@ -11,25 +10,14 @@ const async = require('async');

//const SSLPING = 'http://127.0.0.1:8080';
const QUEUE_LIMIT = 10;
const QUEUE_LIMIT = 10; // reasonnable default, 10 servers at a time
const argv = Optimist
.usage("Bulk load servers to https://sslping.com\nUsage: $0 -u [user] -p [password] server[:port]...")
.usage(`Bulk import and export servers to https://sslping.com
Usage: $0 -u <user> -p <password> [--quiet=true] import|export server[:port]...`)
.demand(['user', 'password'])
.describe('user=email', "address for your sslping.com address")
.alias('user', 'u')
.describe('password', "password")
.alias('password', 'p')
.describe('quiet', false)
.argv
// get the rest of the arguments, add port 443 if missing
const hosts = argv._.map( host => {
const [hostname, port] = host.split(':');
return `${hostname}:${port || 443}`;
});
if (hosts.length == 0) {
console.error("You must specify a list of servers to import");
process.exit(1);
}
const {user, password} = argv
/**

@@ -42,2 +30,6 @@ * Get the token for this user/pwd

function getTokenFor(email, password) {
if (!argv.quiet) {
console.info("Connecting...");
}
return fetch(

@@ -54,3 +46,5 @@ `${SSLPING}/api/v1/login`,

}
console.info("Connected and authenticated");
if (!argv.quiet) {
console.info("Connected and authenticated");
}
return res.json()

@@ -61,2 +55,16 @@ }).then(({token}) => token);

/**
* Get the hosts we should import from the command line
*/
function getImportHosts() {
if (argv._.length == 0) {
console.error("You must specify a list of servers to import");
process.exit(1);
}
return argv._.map((host) => {
const [hostname, port] = host.split(':');
return `${hostname}:${port || 443}`;
});
}
/**
* Add a single check

@@ -68,3 +76,2 @@ * @param {String} token

function addSingleCheck(token, host) {
const _status = status(`${host}`);
return fetch(

@@ -81,6 +88,6 @@ `${SSLPING}/api/v1/user/checks/${host}`,

if (res.status > 400) {
_status(false);
console.log(res);
console.error(`failed \t${host}\t(status=${res.status})`);
return null
}
_status(true)
console.info(`done\t${host}`);
return res.json()

@@ -91,2 +98,23 @@ });

/**
* Get a JSON report for all hosts
* @param {String} token
* @return {Promise} the resulting promise
*/
function getAllHosts(token) {
return fetch(SSLPING + '/api/v1/user/checks', {
method: 'GET',
headers: {
'content-type': 'application/json',
'securitytoken': token
}
}).then((res) => {
if (res.status >= 400) {
console.error(`failed to get servers (status=${res.status})`)
return null
}
return res.json()
})
}
/**
* Now let's do it...

@@ -98,16 +126,46 @@ *

*/
getTokenFor(user, password)
.then( (token)=> {
const worker = (host, cb) => {
addSingleCheck(token, host)
.then( result => cb())
};
const queue = async.queue(worker, QUEUE_LIMIT);
queue.drain = () => process.exit(0);
for (const host in hosts) {
queue.push(hosts[host]);
if (argv._.length < 1) {
console.error("You must at least provide a command (import or export)")
process.exit(1)
}
const command = argv._.shift()
const {user, password} = argv
getTokenFor(user, password).then(function (token) {
switch (command) {
case "import": {
const hosts = getImportHosts()
if (hosts.length == 0) {
console.error("You must specify a list of servers to import");
process.exit(1);
}
var worker = function worker(host, cb) {
addSingleCheck(token, host).then(function (result) {
return cb()
})
}
var queue = async.queue(worker, QUEUE_LIMIT);
queue.drain = function () {
return process.exit(0)
}
for (var host in hosts) {
queue.push(hosts[host])
}
break
}
case "export": {
var result = getAllHosts(token).then( res => {
console.log(JSON.stringify(res, null, 4))
})
break
}
}
})
.catch( (err)=> console.error(err));
.catch((err) => {
console.error(err);
process.exit(1)
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.