Socket
Socket
Sign inDemoInstall

ssh-config

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ssh-config - npm Package Compare versions

Comparing version 2.0.0-alpha.1 to 2.0.0-alpha.2

46

index.js

@@ -151,2 +151,10 @@ 'use strict'

const formatValue = (value, quoted) => {
if (Array.isArray(value)) {
return value.map(chunk => formatValue(chunk, RE_SPACE.test(chunk))).join(' ')
}
return quoted ? `"${value}"` : value
}
const format = line => {

@@ -159,5 +167,6 @@ str += line.before

else if (line.type === DIRECTIVE) {
str += line.quoted || (line.param == 'IdentityFile' && RE_SPACE.test(line.value))
? `${line.param}${line.separator}"${line.value}"`
: `${line.param}${line.separator}${line.value}`
const quoted = line.quoted
|| (/IdentityFile/i.test(line.param) && RE_SPACE.test(line.value))
const value = formatValue(line.value, quoted)
str += `${line.param}${line.separator}${value}`
}

@@ -248,2 +257,3 @@

while (chr && !RE_LINE_BREAK.test(chr)) {
// backslash escapes only double quotes
if (escaped) {

@@ -253,3 +263,4 @@ val += chr === '"' ? chr : `\\${chr}`

}
else if (chr === '"') {
// ProxyCommand ssh -W "%h:%p" firewall.example.org
else if (chr === '"' && (!val || quoted)) {
quoted = !quoted

@@ -266,3 +277,6 @@ }

if (quoted || escaped) throw new Error('Unexpected line break')
if (quoted || escaped) {
throw new Error(`Unexpected line break at ${val}`)
}
return val.trim()

@@ -306,5 +320,8 @@ }

}
else if (chr === ' ' && val) {
results.push(val)
val = ''
else if (chr === ' ') {
if (val) {
results.push(val)
val = ''
}
// otherwise ignore the space
}

@@ -318,3 +335,5 @@ else {

if (quoted || escaped) throw new Error('Unexpected line break')
if (quoted || escaped) {
throw new Error(`Unexpected line break at ${results.concat(val).join(' ')}`)
}
results.push(val)

@@ -327,9 +346,12 @@ return results.length > 1 ? results : results[0]

const param = parameter()
return {
const multiple = param.toLowerCase() == 'host'
const result = {
type,
param,
separator: separator(),
value: param.toLowerCase() === 'host' ? patterns() : value()
quoted: !multiple && chr === '"',
value: multiple ? patterns() : value()
}
if (!result.quoted) delete result.quoted
return result
}

@@ -336,0 +358,0 @@

{
"name": "ssh-config",
"description": "SSH config parser and stringifier",
"version": "2.0.0-alpha.1",
"version": "2.0.0-alpha.2",
"author": "Chen Yangjian (https://www.cyj.me)",

@@ -15,3 +15,2 @@ "repository": {

"devDependencies": {
"expect.js": "^0.3.1",
"heredoc": "^1.3.1",

@@ -18,0 +17,0 @@ "mocha": "^5.2.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