console1984 0.1.21 → 0.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d83291f898d099af3d70445ee2f7a9946fab213fcf2932629118926cb17529e9
4
- data.tar.gz: 12cc2e2fffcef01d10139744015ec59857e4f1bbaa5a5a6d0c9bcbd052b82180
3
+ metadata.gz: a67c07da2418015b191eb5bdf297d0356cc21b628ab767baeb9bad25b0ec049f
4
+ data.tar.gz: 43f01780c1c444fb9a62de3ffe54aa18b877666087ffe72dfed42d0ff4a5067a
5
5
  SHA512:
6
- metadata.gz: 7ea7adb1db1f616e53be2222be1afbf8830c097c50d7c21506dda2bef0fc99e5434e9c02702725068465f3b6d3d441089525b6b976b257c8cfd5d1996307ffba
7
- data.tar.gz: 42d0b445e453c657c5100538cd29a7822c4aa43cfb87f94c3be6a01e3d059dfa0e4e7b060ab02e9e0fc8da939db445cad2148320b5bdd4e0fc8bf889833ca8bc
6
+ metadata.gz: 29020efa4419ba5ab3d156ab5739a0d51afd2ba28f5fd4f2d702b13f9cc7d4145ed3564d686ebfc748b371a4a7adf094013dba93f882ab0c641c58a1b8b306fd
7
+ data.tar.gz: 51519e6c79206461115304b3edf7b471901608e4f5d0ff87874922ee42227b75b0e251f2370eabe750fbb8f1568179f5d6d027dc8b7406881e9abd70ac7c6115
data/README.md CHANGED
@@ -14,7 +14,7 @@ If you are looking for the auditing tool, check [`audits1984`](https://github.co
14
14
 
15
15
  ## Installation
16
16
 
17
- **Important:** `console1984` depends on [Active Record encryption](https://edgeguides.rubyonrails.org/active_record_encryption.html) which is a Rails 7 feature. Since no gem for Rails 7 has been released yet, you need to run Rails edge in your project (point the gem to latest `main` in the [repo](https://github.com/rails/rails)).
17
+ **Important:** `console1984` depends on [Active Record encryption](https://guides.rubyonrails.org/active_record_encryption.html) which is a Rails 7 feature.
18
18
 
19
19
  Add it to your `Gemfile`:
20
20
 
@@ -35,7 +35,7 @@ By default, console1984 is only enabled in `production`. You can configure the t
35
35
  config.console1984.protected_environments = %i[ production staging ]
36
36
  ```
37
37
 
38
- Finally, you need to [configure Active Record Encryption](https://edgeguides.rubyonrails.org/active_record_encryption.html#setup) in your
38
+ Finally, you need to [configure Active Record Encryption](https://guides.rubyonrails.org/active_record_encryption.html#setup) in your
39
39
  project. This is because the library stores the tracked console commands encrypted.
40
40
 
41
41
  ## How it works
@@ -66,7 +66,7 @@ Check out [`audits1984`](https://github.com/basecamp/audits1984), a companion au
66
66
 
67
67
  ### Access to encrypted data
68
68
 
69
- By default, `console1984` won't decrypt data encrypted with [Active Record encryption](https://edgeguides.rubyonrails.org/active_record_encryption.html). Users will just see the ciphertexts.
69
+ By default, `console1984` won't decrypt data encrypted with [Active Record encryption](https://guides.rubyonrails.org/active_record_encryption.html). Users will just see the ciphertexts.
70
70
 
71
71
  To decrypt data, enter the command `decrypt!`. It will ask for a justification, and these accesses will be flagged internally as sensitive.
72
72
 
@@ -127,7 +127,7 @@ In the default protected mode, trying to read data from a protected system will
127
127
  irb(main)> Rails.cache.read("some key") # raises Console1984::Errors::ProtectedConnection
128
128
  ```
129
129
 
130
- Running `decrypt!` will switch you to unprotected mode and let you access these systems normally. The system will ask for a justfication and will flag those accesses as sensitive.
130
+ Running `decrypt!` will switch you to unprotected mode and let you access these systems normally. The system will ask for a justification and will flag those accesses as sensitive.
131
131
 
132
132
  This will work for systems that use Ruby sockets as the underlying communication mechanism.
133
133
 
@@ -143,18 +143,19 @@ When starting a console session, `console1984` will eager load all the applicati
143
143
 
144
144
  These config options are namespaced in `config.console1984`:
145
145
 
146
- | Name | Description |
147
- | ------------------------------------------- | ------------------------------------------------------------ |
148
- | `protected_environments` | The list of environments where `console1984` will act on. Defaults to `%i[ production ]`. |
149
- | `protected_urls` | The list of URLs corresponding with external systems to protect. |
150
- | `session_logger` | The system used to record session data. The default logger is `Console1984::SessionsLogger::Database`. |
146
+ | Name | Description |
147
+ |---------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
148
+ | `protected_environments` | The list of environments where `console1984` will act on. Defaults to `%i[ production ]`. |
149
+ | `protected_urls` | The list of URLs corresponding with external systems to protect. |
150
+ | `session_logger` | The system used to record session data. The default logger is `Console1984::SessionsLogger::Database`. |
151
151
  | `username_resolver` | Configure how the current user is determined for a given console session. The default is `Console1984::Username::EnvResolver.new("CONSOLE_USER")`, which returns the value of the environment variable `CONSOLE_USER`. |
152
- | `production_data_warning` | The text to show when a console session starts. |
153
- | `enter_unprotected_encryption_mode_warning` | The text to show when user enters into unprotected mode. |
154
- | `enter_protected_mode_warning` | The text to show when user go backs to protected mode. |
155
- | `incinerate` | Whether incinerate sessions automatically after a period of time or not. Default to `true`. |
156
- | `incinerate_after` | The period to keep sessions around before incinerate them. Default `30.days`. |
157
- | `incineration_queue` | The name of the queue for session incineration jobs. Default `console1984_incineration`. |
152
+ | `ask_for_username_if_empty` | If `true`, the console will ask for a username if it is empty. If `false`, it will raise an error if no username is set. Defaults to `false`. |
153
+ | `production_data_warning` | The text to show when a console session starts. |
154
+ | `enter_unprotected_encryption_mode_warning` | The text to show when user enters into unprotected mode. |
155
+ | `enter_protected_mode_warning` | The text to show when user go backs to protected mode. |
156
+ | `incinerate` | Whether incinerate sessions automatically after a period of time or not. Default to `true`. |
157
+ | `incinerate_after` | The period to keep sessions around before incinerate them. Default `30.days`. |
158
+ | `incineration_queue` | The name of the queue for session incineration jobs. Default `console1984_incineration`. |
158
159
 
159
160
  ### SSH Config
160
161
 
@@ -7,7 +7,7 @@ class Console1984::Config
7
7
  PROTECTIONS_CONFIG_FILE_PATH = Console1984::Engine.root.join("config/protections.yml")
8
8
 
9
9
  PROPERTIES = %i[
10
- session_logger username_resolver shield command_executor
10
+ session_logger username_resolver ask_for_username_if_empty shield command_executor
11
11
  protected_environments protected_urls
12
12
  production_data_warning enter_unprotected_encryption_mode_warning enter_protected_mode_warning
13
13
  incinerate incinerate_after incineration_queue
@@ -54,6 +54,7 @@ class Console1984::Config
54
54
  self.incinerate = true
55
55
  self.incinerate_after = 30.days
56
56
  self.incineration_queue = "console1984_incineration"
57
+ self.ask_for_username_if_empty = false
57
58
 
58
59
  self.debug = false
59
60
  self.test_mode = false
@@ -23,5 +23,8 @@ module Console1984
23
23
  # Attempt to incinerate a session ahead of time as determined by
24
24
  # +config.console1984.incinerate_after+.
25
25
  class ForbiddenIncineration < StandardError; end
26
+
27
+ # The console username is not set. Only raised when `config.ask_for_username_if_empty = false`.
28
+ class MissingUsername < StandardError; end
26
29
  end
27
30
  end
@@ -55,6 +55,6 @@ module Console1984::Shield::Modes
55
55
 
56
56
  private
57
57
  def current_username
58
- username_resolver.current
58
+ Console1984.supervisor.current_username
59
59
  end
60
60
  end
@@ -35,6 +35,10 @@ class Console1984::Supervisor
35
35
  IRB.CurrentContext.exit
36
36
  end
37
37
 
38
+ def current_username
39
+ @current_username ||= username_resolver.current.presence || handle_empty_username
40
+ end
41
+
38
42
  private
39
43
  def require_dependencies
40
44
  Kernel.silence_warnings do
@@ -61,7 +65,11 @@ class Console1984::Supervisor
61
65
  session_logger.finish_session
62
66
  end
63
67
 
64
- def current_username
65
- username_resolver.current
68
+ def handle_empty_username
69
+ if Console1984.config.ask_for_username_if_empty
70
+ ask_for_value "Please, enter your name:"
71
+ else
72
+ raise Console1984::Errors::MissingUsername
73
+ end
66
74
  end
67
75
  end
@@ -13,6 +13,6 @@ class Console1984::Username::EnvResolver
13
13
 
14
14
  private
15
15
  def username
16
- @username ||= ENV[@key]&.humanize || "Unnamed"
16
+ @username ||= ENV[@key]&.humanize
17
17
  end
18
18
  end
@@ -1,3 +1,3 @@
1
1
  module Console1984
2
- VERSION = '0.1.21'
2
+ VERSION = '0.1.24'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: console1984
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.21
4
+ version: 0.1.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jorge Manrubia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-22 00:00:00.000000000 Z
11
+ date: 2022-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize