train-pgsql 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41f6374cac9f6ad319f2e7621de2d5495e89818f344ea523fff0d9998d183afc
4
- data.tar.gz: c5293e0436f3b9bf3855d95d2fb0d9aa945c14c23c92afdf44fe045d5e84695d
3
+ metadata.gz: bf9046c760c47e717c33a05f1044d3142036509cc0fa883ab7ddc6b9664dc8e0
4
+ data.tar.gz: 901fc8f8862e6eb8ae21d9c8340927653d875d476d55db2accbdff90688a4b5e
5
5
  SHA512:
6
- metadata.gz: 1e7be15922b050254346bf41c6981bc98668f28fdeee08e5407d02906557a10ce8273cc3790437f8ca588e930c009dcae5581f296e49ff77c8460891cc68f2bd
7
- data.tar.gz: fba0f35259a18f66f9de918b75e3e967b237ad0fc5e496b796c435473955bfb1ccd667230c9008b396e7a3fb9c71c8634e9a4815070ef41b1be3350e9305c1d9
6
+ metadata.gz: b34564dc3c47a2be228d7ee67e833d490e533b683775aaac3050dbc17d490509f5935046ecef1b71bef4dcb2af1a5dd0120aa74fd897040fb554889a1135756f
7
+ data.tar.gz: bba454681a04de826b47e109927189a030b9718d17b2c4351b2e293ae73679e594dd746a3e3e22794f238fc757b064dba53c060d7c1d3b81157d65a42749273b
data/README.md CHANGED
@@ -19,17 +19,37 @@ inspec plugin install train-pgsql
19
19
 
20
20
  ## Transport parameters
21
21
 
22
- | Option | Explanation | Default |
23
- | ---------- | ------------------- | ---------- |
24
- | `host` | Hostname | (required) |
25
- | `user` | Username to connect | (required) |
26
- | `password` | Password to connect | (required) |
27
- | `database` | Database to connect | `postgres` |
28
- | `port` | Remote port | `5432` |
22
+ | Option | Explanation | Default | ENV VAR |
23
+ | ---------- | ------------------- | ---------- | ------------ |
24
+ | `host` | Hostname | (required) | `PGHOST` |
25
+ | `user` | Username to connect | (required) | `PGUSER` |
26
+ | `password` | Password to connect | (required) | `PGPASSWORD` |
27
+ | `database` | Database to connect | `postgres` | `PGDATABASE` |
28
+ | `port` | Remote port | `5432` | `PGPORT` |
29
+
30
+
31
+ ## Example use in inspec
32
+ Connect to the postgresql target as such:
33
+ ```bash
34
+ inspec shell -t pgsql://db.host.name --user 'username' --password 'supersecret' --insecure boolean
35
+ ```
36
+ or
37
+ ```bash
38
+ inspec exec -t pgsql://db.host.name --user 'username' --password 'supersecret' --insecure boolean
39
+ ```
29
40
 
30
- ## Example use
41
+ Alternatively you can set all these as environment variables using the following variables and authenticate without the parameters in in the inspec command or the target
42
+ ```bash
43
+ export PGHOST='db.host.name'
44
+ export PGUSER='username'
45
+ export PGPASSWORD='supersecret'
46
+ export PGDATABASE='somedatabase'
47
+ inspec exec -t pgsql://
48
+ ```
31
49
 
32
- This will work for a Cisco IOS XE device with Telnet enabled:
50
+ ## Example use from Ruby
51
+
52
+ This will work if you have postgresql running on `localhost`:
33
53
  ```ruby
34
54
  require "train"
35
55
  train = Train.create("pgsql", {
@@ -41,7 +61,6 @@ conn = train.connection
41
61
  result = conn.run_command("show version\n")
42
62
  conn.close
43
63
  ```
44
-
45
64
  ## Local development
46
65
  If you are building this on a Mac you may run into an issue trying to install this locally due to the `PG` gem not installing due to code signing issues.
47
66
  You can build it and run it in a docker container.
@@ -1,22 +1,22 @@
1
- require "train-pgsql/connection"
1
+ require 'train-pgsql/connection'
2
2
 
3
3
  module TrainPlugins
4
4
  module Pgsql
5
5
  class Transport < Train.plugin(1)
6
- name "pgsql"
6
+ name 'pgsql'
7
7
 
8
- option :host, required: true
9
- option :user, required: true
10
- option :password, required: true
11
- option :database, default: "postgres"
12
- option :port, default: 5432
8
+ option :host, required: true, default: ENV['PGHOST']
9
+ option :user, required: true, default: ENV['PGUSER']
10
+ option :password, required: true, default: ENV['PGPASSWORD']
11
+ option :database, required: false, default: ENV['PGDATABASE'] || 'postgres'
12
+ option :port, required: false, default: ENV['PGPORT'] || 5432
13
13
 
14
14
  # Non documented options for development
15
- option :debug_pgsql, default: false
15
+ option :debug_pgsql, default: false
16
16
 
17
17
  def connection(_instance_opts = nil)
18
18
  @connection ||= TrainPlugins::Pgsql::Connection.new(@options)
19
19
  end
20
20
  end
21
21
  end
22
- end
22
+ end
@@ -1,5 +1,5 @@
1
1
  module TrainPlugins
2
2
  module Pgsql
3
- VERSION = '1.2.1'.freeze
3
+ VERSION = '1.2.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: train-pgsql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cris Barbero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-26 00:00:00.000000000 Z
11
+ date: 2020-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: train