Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ssh-config

Package Overview
Dependencies
Maintainers
1
Versions
42
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 4.1.0 to 4.1.1

types/index.d.ts

10

History.md

@@ -0,1 +1,11 @@

4.1.1 / 2021-10-21
==================
## What's Changed
* docs: `.prepend` and type definitions by @cyjake in https://github.com/cyjake/ssh-config/pull/47
* fix: improper parsing of ProxyCommand with quotation marks by @tanhakabir in https://github.com/cyjake/ssh-config/pull/48
**Full Changelog**: https://github.com/cyjake/ssh-config/compare/v4.1.0...v4.1.1
4.1.0 / 2021-10-20

@@ -2,0 +12,0 @@ ==================

56

index.js

@@ -8,3 +8,3 @@ 'use strict'

const RE_SECTION_DIRECTIVE = /^(Host|Match)$/i
const RE_MULTI_VALUE_DIRECTIVE = /^(GlobalKnownHostsFile|Host|IPQoS|SendEnv|UserKnownHostsFile)$/i
const RE_MULTI_VALUE_DIRECTIVE = /^(GlobalKnownHostsFile|Host|IPQoS|SendEnv|UserKnownHostsFile|ProxyCommand)$/i
const RE_QUOTE_DIRECTIVE = /^(?:CertificateFile|IdentityFile|User)$/i

@@ -16,6 +16,2 @@ const RE_SINGLE_LINE_DIRECTIVE = /^(Include|IdentityFile)$/i

function compare(line, opts) {
return opts.hasOwnProperty(line.param) && opts[line.param] === line.value
}
const MULTIPLE_VALUE_PROPS = [

@@ -29,2 +25,20 @@ 'IdentityFile',

function compare(line, opts) {
return opts.hasOwnProperty(line.param) && opts[line.param] === line.value
}
function getIndent(config) {
for (const line of config) {
if (RE_SECTION_DIRECTIVE.test(line.param)) {
for (const subline of line.config) {
if (subline.before) {
return subline.before
}
}
}
}
return ' '
}
class SSHConfig extends Array {

@@ -112,16 +126,3 @@ /**

append(opts) {
let indent = ' '
outer:
for (const line of this) {
if (RE_SECTION_DIRECTIVE.test(line.param)) {
for (const subline of line.config) {
if (subline.before) {
indent = subline.before
break outer
}
}
}
}
const indent = getIndent(this)
const lastEntry = this.length > 0 ? this[this.length - 1] : null

@@ -165,17 +166,4 @@ let config = lastEntry && lastEntry.config || this

*/
prepend(opts, beforeFirstSection = false) {
let indent = ' '
outer:
for (const line of this) {
if (RE_SECTION_DIRECTIVE.test(line.param)) {
for (const subline of line.config) {
if (subline.before) {
indent = subline.before
break outer
}
}
}
}
prepend(opts, beforeFirstSection = false) {
const indent = getIndent(this)
let config = this

@@ -182,0 +170,0 @@ let i = 0

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

@@ -12,3 +12,4 @@ "repository": {

"index.js",
"src"
"src",
"types"
],

@@ -15,0 +16,0 @@ "devDependencies": {

@@ -157,2 +157,58 @@ # SSH Config Parser & Stringifier

### `.prepend` sections
But appending options to the end of the config isn't very effective if your config is organizated per the recommendations of ssh_config(5) that the generic options are at at the end of the config, such as:
```
Host ness
HostName lochness.com
User dinosaur
IdentityFile ~/.ssh/id_rsa
```
The config could get messy if you put new options after the line of `IdentityFile`. To work around this issue, it is recommended that `.prepend` should be used instead. For the example above, we can prepend new options at the beginning of the config:
```js
config.prepend({
Host: 'tahoe',
HostName 'tahoe.com',
})
```
The result would be:
```
Host tahoe
HostName tahoe.com
Host ness
HostName lochness.com
User dinosaur
IdentityFile ~/.ssh/id_rsa
```
If there are generic options at the beginning of the config, and you'd like the prepended section put before the first existing section, please turn on the second argument of `.prepend`:
```js
config.prepend({
Host: 'tahoe',
HostName 'tahoe.com',
}, true)
```
The result would be like:
```
IdentityFile ~/.ssh/id_rsa
Host tahoe
HostName tahoe.com
Host ness
HostName lochness.com
User dinosaur
```
## References

@@ -159,0 +215,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