From f12508560056d8828356a8448ceb8c362d73e319 Mon Sep 17 00:00:00 2001 From: Bill Church Date: Tue, 11 Sep 2018 15:13:32 -0400 Subject: [PATCH 1/4] update jsthints --- index.js | 6 ++++-- server/app.js | 2 ++ server/socket.js | 2 ++ server/util.js | 2 ++ workspace/extensions/webssh2/server/app.js | 10 +++++++++- workspace/extensions/webssh2/server/socket.js | 8 ++++++-- workspace/extensions/webssh2/server/util.js | 4 +++- 7 files changed, 28 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 13b1b43..2173768 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,12 @@ -// index.js +'use strict' +/* jshint esversion: 6, asi: true, node: true */ /* + * index.js + * * WebSSH2 - Web to SSH2 gateway * Bill Church - https://github.com/billchurch/WebSSH2 - May 2017 * */ -'use strict' var config = require('./server/app').config var server = require('./server/app').server diff --git a/server/app.js b/server/app.js index c91a0dd..bd4ffe1 100644 --- a/server/app.js +++ b/server/app.js @@ -1,3 +1,5 @@ +'use strict' +/* jshint esversion: 6, asi: true, node: true */ // app.js var path = require('path') diff --git a/server/socket.js b/server/socket.js index d788b05..577607c 100644 --- a/server/socket.js +++ b/server/socket.js @@ -1,3 +1,5 @@ +'use strict' +/* jshint esversion: 6, asi: true, node: true */ // socket.js // private diff --git a/server/util.js b/server/util.js index 2bf52c6..634926f 100644 --- a/server/util.js +++ b/server/util.js @@ -1,3 +1,5 @@ +'use strict' +/* jshint esversion: 6, asi: true, node: true */ // util.js // private diff --git a/workspace/extensions/webssh2/server/app.js b/workspace/extensions/webssh2/server/app.js index dae3eb7..bd4ffe1 100644 --- a/workspace/extensions/webssh2/server/app.js +++ b/workspace/extensions/webssh2/server/app.js @@ -1,3 +1,5 @@ +'use strict' +/* jshint esversion: 6, asi: true, node: true */ // app.js var path = require('path') @@ -35,6 +37,11 @@ app.disable('x-powered-by') // static files app.use(express.static(publicPath, expressOptions)) +app.get('/reauth', function (req, res, next) { + var r = req.headers.referer || '/' + res.status(401).send('') +}) + app.get('/ssh/host/:host?', function (req, res, next) { res.sendFile(path.join(path.join(publicPath, 'client.htm'))) // capture, assign, and validated variables @@ -60,7 +67,8 @@ app.get('/ssh/host/:host?', function (req, res, next) { tabStopWidth: (validator.isInt(req.query.tabStopWidth + '', {min: 1, max: 100}) && req.query.tabStopWidth) ? req.query.tabStopWidth : config.terminal.tabStopWidth, bellStyle: ((req.query.bellStyle) && (['sound', 'none'].indexOf(req.query.bellStyle) > -1)) ? req.query.bellStyle : config.terminal.bellStyle }, - allowreplay: (validator.isBoolean(req.headers.allowreplay + '') ? myutil.parseBool(req.headers.allowreplay) : false), + allowreplay: config.options.challengeButton || (validator.isBoolean(req.headers.allowreplay + '') ? myutil.parseBool(req.headers.allowreplay) : false), + allowreauth: config.options.allowreauth || false, mrhsession: ((validator.isAlphanumeric(req.headers.mrhsession + '') && req.headers.mrhsession) ? req.headers.mrhsession : 'none'), serverlog: { client: config.serverlog.client || false, diff --git a/workspace/extensions/webssh2/server/socket.js b/workspace/extensions/webssh2/server/socket.js index a43cebd..577607c 100644 --- a/workspace/extensions/webssh2/server/socket.js +++ b/workspace/extensions/webssh2/server/socket.js @@ -1,3 +1,5 @@ +'use strict' +/* jshint esversion: 6, asi: true, node: true */ // socket.js // private @@ -7,7 +9,8 @@ var SSH = require('ssh2').Client // var fs = require('fs') // var hostkeys = JSON.parse(fs.readFileSync('./hostkeyhashes.json', 'utf8')) var termCols, termRows -var menuData = ' Start Log Download Log' +var menuData = ' Start Log' + + ' Download Log' // public module.exports = function socket (socket) { @@ -24,7 +27,7 @@ module.exports = function socket (socket) { termRows = rows }) conn.on('banner', function connOnBanner (data) { - // need to convert to cr/lf for proper formatting + // need to convert to cr/lf for proper formatting data = data.replace(/\r?\n/g, '\r\n') socket.emit('data', data.toString('utf-8')) }) @@ -40,6 +43,7 @@ module.exports = function socket (socket) { socket.emit('status', 'SSH CONNECTION ESTABLISHED') socket.emit('statusBackground', 'green') socket.emit('allowreplay', socket.request.session.ssh.allowreplay) + socket.emit('allowreauth', socket.request.session.ssh.allowreauth) conn.shell({ term: socket.request.session.ssh.term, cols: termCols, diff --git a/workspace/extensions/webssh2/server/util.js b/workspace/extensions/webssh2/server/util.js index 546a0b5..634926f 100644 --- a/workspace/extensions/webssh2/server/util.js +++ b/workspace/extensions/webssh2/server/util.js @@ -1,3 +1,5 @@ +'use strict' +/* jshint esversion: 6, asi: true, node: true */ // util.js // private @@ -12,7 +14,7 @@ exports.basicAuth = function basicAuth (req, res, next) { req.session.userpassword = myAuth.pass debug('myAuth.name: ' + myAuth.name.yellow.bold.underline + ' and password ' + ((myAuth.pass) ? 'exists'.yellow.bold.underline - : 'is blank'.underline.red.bold)) + : 'is blank'.underline.red.bold)) next() } else { res.statusCode = 401 From 7cb17becaf0aab4fe8c14174ee7b51f13e9689f9 Mon Sep 17 00:00:00 2001 From: Bill Church Date: Tue, 11 Sep 2018 15:32:52 -0400 Subject: [PATCH 2/4] update changelog, increment version --- ChangeLog.md | 4 +- bin/startup_script_webssh_commands.sh | 63 ----------------------- build.sh | 2 +- package.json | 2 +- revsync.sh | 12 +++++ sync.sh | 2 +- workspace/extensions/webssh2/ChangeLog.md | 13 ++++- workspace/extensions/webssh2/index.js | 5 +- workspace/extensions/webssh2/package.json | 63 +++++++++++++++++++---- 9 files changed, 85 insertions(+), 81 deletions(-) delete mode 100644 bin/startup_script_webssh_commands.sh create mode 100755 revsync.sh diff --git a/ChangeLog.md b/ChangeLog.md index 255ee36..5fd129b 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,11 +1,11 @@ # Change Log -## [0.2.5] TBD +## [0.2.5] 20180911 ### Added - Reauth function thanks to @vbeskrovny and @vvalchev (9bbc116) - Controlled by `config.json` option `options.allowreauth` true presents reauth dialog and false hides dialog ### Changed - `options.challengeButton` enabled - - previously this configuraiton option did nothing, this now enables the Credentials button site-wide regardless of the `allowreplay` header value + - previously this configuration option did nothing, this now enables the Credentials button site-wide regardless of the `allowreplay` header value ## [0.2.4] 2018-07-18 ### Added diff --git a/bin/startup_script_webssh_commands.sh b/bin/startup_script_webssh_commands.sh deleted file mode 100644 index bcb92bf..0000000 --- a/bin/startup_script_webssh_commands.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# Filename: /config/startup_script_webssh_commands.sh -# Initializes WebSSH2 tmm-to-node listener -# WebSSHVSIP should be the IP on an existing BIGIP virtual server assigned to -# the WebSSH2 service. -# -# bill@f5.com February 2018 - -export myFileName=$0 -export REMOTEUSER=root -export WEBSSHVSIP= - -# check to see if we're in /config/startup, if not add ourselves -IN_STARTUP=`grep startup_script_webssh_commands.sh /config/startup | wc -l` -if [ $IN_STARTUP -eq 0 ]; then - echo Adding script to /config/startup and ensuring correct permissions... - logger -p local0.notice -t $myFileName Adding $0 to /config/startup and ensuring correct permissions... - chmod 755 /config/startup - chmod 755 /config/startup_script_webssh_commands.sh - echo /config/startup_script_webssh_commands.sh \& >> /config/startup - echo >> /config/startup -fi - -# Limit to 13 times in while-loop, ie. 12 x 10 secs sleep = 2 mins. -MAX_LOOP=13 - -while true -do -# check to see if tmm interface is up -IPLINKLIST=$(ip link list tmm 2>&1) -if [ $? -eq 0 ]; then - if [ ! -z $WEBSSHVSIP ]; then - IPADDRADD=$(/sbin/ip addr add $WEBSSHVSIP/32 dev tmm 2>&1) - if [ $? -eq 0 ]; then - # success - echo SUCCESS $IPADDRADD - logger -p local0.notice -t $myFileName IPADDRADD: SUCCESS: $IPADDRADD - else - # failure - echo FAILURE $IPADDRADD - logger -p local0.notice -t $myFileName IPADDRADD: FAILURE: $IPADDRADD - fi - else - echo FAILURE: WEBSSHVSIP not specified. - echo Open $0 and set the WEBSSHVSIP and try again - echo - logger -p local0.notice -t $myFileName IPADDRADD: FAILURE: NO WEBSSHVSIP SPECIFIED - fi - exit -fi -# If tmm interface is not up yet, script sleep 10 seconds and check again. -sleep 10 - -# Safety check not to run this script in background beyond 2 mins (ie. 12 times in while-loop). -if [ "$MAX_LOOP" -eq 1 ]; then - logger -p local0.notice -t $myFileName tmm interface not up within 2 minutes. Exiting script. - logger -p local0.notice -t $myFileName IPLINKLIST: $IPLINKLIST - exit -fi -((MAX_LOOP--)) -done - -# End of file /config/startup_script_webssh_commands.sh diff --git a/build.sh b/build.sh index 162364e..2fe4d59 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,7 @@ #!/bin/bash ## Syncs from BIG-IP and builds a release based on version in extensions/ephemeral_auth/package.json -ilxhost=root@192.168.30.210 +ilxhost=root@192.168.30.216 workspace_name=webssh2 package_name=BIG-IP-13.1.0.8-ILX-WebSSH2 pua_location=/Users/bill/Documents/GitHub/f5-pua/bin diff --git a/package.json b/package.json index acab24d..4cde826 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webssh2", - "version": "0.2.3", + "version": "0.2.5", "ignore": [ ".gitignore" ], diff --git a/revsync.sh b/revsync.sh new file mode 100755 index 0000000..7257f84 --- /dev/null +++ b/revsync.sh @@ -0,0 +1,12 @@ +#!/bin/bash +ilxhost=root@192.168.30.216 +workspace_name=webssh2 +package_name=BIG-IP-13.1.0.8-ILX-WebSSH2 +pua_location=/Users/bill/Documents/GitHub/f5-pua/bin +echo 'hello' +rsync -e 'ssh -ax' -av --delete --exclude='.DS_Store' --exclude extensions/$workspace_name/node_modules workspace/. $ilxhost:/var/ilx/workspaces/Common/$workspace_name/. + +ssh $ilxhost chown -R root.sdm /var/ilx/workspaces/Common/$workspace_name/ +ssh $ilxhost chmod -R ug+rwX,o-w /var/ilx/workspaces/Common/$workspace_name/ +ssh $ilxhost chmod u+rw,go-w /var/ilx/workspaces/Common/$workspace_name/version +ssh $ilxhost chmod u+rw,go-w /var/ilx/workspaces/Common/$workspace_name/node_version diff --git a/sync.sh b/sync.sh index 0e1809c..7600357 100755 --- a/sync.sh +++ b/sync.sh @@ -1,5 +1,5 @@ #!/bin/bash -ilxhost=root@192.168.30.210 +ilxhost=root@192.168.30.216 workspace_name=webssh2 package_name=BIG-IP-13.1.0.8-ILX-WebSSH2 pua_location=/Users/bill/Documents/GitHub/f5-pua/bin diff --git a/workspace/extensions/webssh2/ChangeLog.md b/workspace/extensions/webssh2/ChangeLog.md index e7bc383..5fd129b 100644 --- a/workspace/extensions/webssh2/ChangeLog.md +++ b/workspace/extensions/webssh2/ChangeLog.md @@ -1,4 +1,12 @@ # Change Log +## [0.2.5] 20180911 +### Added +- Reauth function thanks to @vbeskrovny and @vvalchev (9bbc116) + - Controlled by `config.json` option `options.allowreauth` true presents reauth dialog and false hides dialog +### Changed +- `options.challengeButton` enabled + - previously this configuration option did nothing, this now enables the Credentials button site-wide regardless of the `allowreplay` header value + ## [0.2.4] 2018-07-18 ### Added - Browser title window now changes with xterm escape sequences (see http://tldp.org/HOWTO/Xterm-Title-3.html) @@ -15,6 +23,9 @@ ## [0.2.3] unreleased +### Fixed +- ESC]0; is now removed from log files when using the browser-side logging feature + ## [0.2.0] 2018-02-10 Mostly client (browser) related changes in this release @@ -165,5 +176,3 @@ and events in the application (not including the ssh2 module debug) ## [0.0.1] - 2016-06-28 ### Added - Initial proof of concept and release. For historical purposes only. - - diff --git a/workspace/extensions/webssh2/index.js b/workspace/extensions/webssh2/index.js index 13b1b43..b1faa1b 100644 --- a/workspace/extensions/webssh2/index.js +++ b/workspace/extensions/webssh2/index.js @@ -1,5 +1,8 @@ -// index.js +'use strict' +/* jshint esversion: 6, asi: true, node: true */ /* + * index.js + * * WebSSH2 - Web to SSH2 gateway * Bill Church - https://github.com/billchurch/WebSSH2 - May 2017 * diff --git a/workspace/extensions/webssh2/package.json b/workspace/extensions/webssh2/package.json index bbaf6a0..4cde826 100644 --- a/workspace/extensions/webssh2/package.json +++ b/workspace/extensions/webssh2/package.json @@ -1,6 +1,6 @@ { "name": "webssh2", - "version": "0.2.4", + "version": "0.2.5", "ignore": [ ".gitignore" ], @@ -17,27 +17,70 @@ "contributors": [ { "name": "Bill Church", - "email": "bill@f5.com" + "email": "wmchurch@gmail.com" } ], "engines": { - "node": "6.9.1" + "node": "6" }, "bugs": { "url": "https://github.com/billchurch/WebSSH2/issues" }, "dependencies": { "basic-auth": "^2.0.0", - "colors": "^1.1.2", - "compression": "^1.7.1", + "colors": "^1.3.1", + "compression": "^1.7.3", "debug": "^3.1.0", - "express": "^4.16.1", + "express": "^4.16.3", "express-session": "^1.15.6", "morgan": "^1.9.0", "read-config": "^2.0.0", - "socket.io": "^2.0.4", - "ssh2": "^0.5.5", - "validator": "^9.0.0" + "socket.io": "^2.1.1", + "ssh2": "^0.6.1", + "validator": "^10.5.0" + }, + "scripts": { + "start": "node index.js", + "build": "webpack --progress --colors --config scripts/webpack.prod.js", + "builddev": "webpack --progress --colors --config scripts/webpack.dev.js", + "analyze": "webpack --json --config scripts/webpack.prod.js | webpack-bundle-size-analyzer", + "test": "snyk test", + "watch": "nodemon index.js", + "standard": "standard --verbose --fix | snazzy", + "cleanmac": "find . -name '.DS_Store' -type f -delete" + }, + "devDependencies": { + "@fortawesome/fontawesome": "^1.1.8", + "@fortawesome/fontawesome-free-solid": "^5.0.13", + "ajv": "^6.5.2", + "bithound": "^1.7.0", + "clean-webpack-plugin": "^0.1.19", + "copy-webpack-plugin": "^4.5.2", + "css-loader": "^1.0.0", + "extract-text-webpack-plugin": "^4.0.0-beta.0", + "file-loader": "^1.1.11", + "nodemon": "^1.18.3", + "postcss-discard-comments": "^4.0.0", + "snazzy": "^7.1.1", + "snyk": "^1.90.0", + "standard": "^11.0.1", + "style-loader": "^0.21.0", + "uglifyjs-webpack-plugin": "^1.2.7", + "url-loader": "^1.0.1", + "webpack": "^4.16.5", + "webpack-cli": "^3.1.0", + "webpack-merge": "^4.1.4", + "webpack-stream": "^5.1.0", + "xterm": "^3.5.1" + }, + "standard": { + "ignore": [ + "client/public/webssh2.bundle.js", + "bigip/*", + "screenshots/*", + "bin/*", + "build/*", + "workspace/*" + ] } } - From 263494f11c78f2c918fa7be6c1064c5a98625672 Mon Sep 17 00:00:00 2001 From: Bill Church Date: Tue, 11 Sep 2018 15:44:06 -0400 Subject: [PATCH 3/4] updated debug non-essential, update debug package --- package.json | 2 +- workspace/extensions/webssh2/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4cde826..70856ed 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "basic-auth": "^2.0.0", "colors": "^1.3.1", "compression": "^1.7.3", - "debug": "^3.1.0", + "debug": "^4.0.0", "express": "^4.16.3", "express-session": "^1.15.6", "morgan": "^1.9.0", diff --git a/workspace/extensions/webssh2/package.json b/workspace/extensions/webssh2/package.json index 4cde826..70856ed 100644 --- a/workspace/extensions/webssh2/package.json +++ b/workspace/extensions/webssh2/package.json @@ -30,7 +30,7 @@ "basic-auth": "^2.0.0", "colors": "^1.3.1", "compression": "^1.7.3", - "debug": "^3.1.0", + "debug": "^4.0.0", "express": "^4.16.3", "express-session": "^1.15.6", "morgan": "^1.9.0", From 86fba56b92df714354b1e62c546709703b07600e Mon Sep 17 00:00:00 2001 From: Bill Church Date: Tue, 11 Sep 2018 15:45:07 -0400 Subject: [PATCH 4/4] update changelog --- ChangeLog.md | 1 + workspace/extensions/webssh2/ChangeLog.md | 1 + workspace/extensions/webssh2/README.md | 11 ++++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 5fd129b..2ea9f4a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -6,6 +6,7 @@ ### Changed - `options.challengeButton` enabled - previously this configuration option did nothing, this now enables the Credentials button site-wide regardless of the `allowreplay` header value +- Updated debug module to v4 ## [0.2.4] 2018-07-18 ### Added diff --git a/workspace/extensions/webssh2/ChangeLog.md b/workspace/extensions/webssh2/ChangeLog.md index 5fd129b..2ea9f4a 100644 --- a/workspace/extensions/webssh2/ChangeLog.md +++ b/workspace/extensions/webssh2/ChangeLog.md @@ -6,6 +6,7 @@ ### Changed - `options.challengeButton` enabled - previously this configuration option did nothing, this now enables the Credentials button site-wide regardless of the `allowreplay` header value +- Updated debug module to v4 ## [0.2.4] 2018-07-18 ### Added diff --git a/workspace/extensions/webssh2/README.md b/workspace/extensions/webssh2/README.md index d0044e3..a438dcd 100644 --- a/workspace/extensions/webssh2/README.md +++ b/workspace/extensions/webssh2/README.md @@ -1,6 +1,7 @@ # WebSSH2 -[![GitHub version](https://badge.fury.io/gh/billchurch%2Fwebssh2.svg)](https://badge.fury.io/gh/billchurch%2Fwebssh2) [![Build Status](https://travis-ci.org/billchurch/WebSSH2.svg?branch=master)](https://travis-ci.org/billchurch/WebSSH2) [![Known Vulnerabilities](https://snyk.io/test/github/billchurch/webssh2/badge.svg)](https://snyk.io/test/github/billchurch/webssh2) [![bitHound Overall Score](https://www.bithound.io/github/billchurch/WebSSH2/badges/score.svg)](https://www.bithound.io/github/billchurch/WebSSH2) [![bitHound Dependencies](https://www.bithound.io/github/billchurch/WebSSH2/badges/dependencies.svg)](https://www.bithound.io/github/billchurch/WebSSH2/master/dependencies/npm) [![NSP Status](https://nodesecurity.io/orgs/billchurch/projects/b0a0d9df-1340-43ef-9736-ef983c057764/badge)](https://nodesecurity.io/orgs/billchurch/projects/b0a0d9df-1340-43ef-9736-ef983c057764) [![Greenkeeper badge](https://badges.greenkeeper.io/billchurch/WebSSH2.svg)](https://greenkeeper.io/) +[![GitHub version](https://badge.fury.io/gh/billchurch%2Fwebssh2.svg)](https://badge.fury.io/gh/billchurch%2Fwebssh2) [![Build Status](https://travis-ci.org/billchurch/WebSSH2.svg?branch=master)](https://travis-ci.org/billchurch/WebSSH2) [![Known Vulnerabilities](https://snyk.io/test/github/billchurch/webssh2/badge.svg)](https://snyk.io/test/github/billchurch/webssh2) [![NSP Status](https://nodesecurity.io/orgs/billchurch/projects/b0a0d9df-1340-43ef-9736-ef983c057764/badge)](https://nodesecurity.io/orgs/billchurch/projects/b0a0d9df-1340-43ef-9736-ef983c057764) [![Greenkeeper badge](https://badges.greenkeeper.io/billchurch/WebSSH2.svg)](https://greenkeeper.io/) +[![Buy Me A Coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/billchurch) Web SSH Client using ssh2, socket.io, xterm.js, and express @@ -8,6 +9,14 @@ A bare bones example of an HTML5 web-based terminal emulator and SSH client. We WebSSH2 v0.2.0 demo +# Requirements +Node v6.x or above. If using