console1984 0.1.17 → 0.1.21

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: 58a963520fed8a86952cee9b02443b61d42ac4bf0a80d1abaabfd3ff390f431b
4
- data.tar.gz: a63a68db2a2e46a129f4f97f79a59b41a88fe98ecb9d6028d67ca0e8d4b1e6fa
3
+ metadata.gz: d83291f898d099af3d70445ee2f7a9946fab213fcf2932629118926cb17529e9
4
+ data.tar.gz: 12cc2e2fffcef01d10139744015ec59857e4f1bbaa5a5a6d0c9bcbd052b82180
5
5
  SHA512:
6
- metadata.gz: 2bb93f84dc7e078b4d357739b337b2277fce627408cb619c816a04fc94db7451faf7d2095d0861ca211726ce973481161ae47c4add5e185c8813904462d1c011
7
- data.tar.gz: d1b623b30f72e49d744934e4623159bfabf5cd7b9a4fab94fc08c26c30fc8bf1115bd70bf4b92b12609874d6ab75dc0d978663079745df2b9b1e238cadaf11ed
6
+ metadata.gz: 7ea7adb1db1f616e53be2222be1afbf8830c097c50d7c21506dda2bef0fc99e5434e9c02702725068465f3b6d3d441089525b6b976b257c8cfd5d1996307ffba
7
+ data.tar.gz: 42d0b445e453c657c5100538cd29a7822c4aa43cfb87f94c3be6a01e3d059dfa0e4e7b060ab02e9e0fc8da939db445cad2148320b5bdd4e0fc8bf889833ca8bc
data/README.md CHANGED
@@ -35,6 +35,9 @@ 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
39
+ project. This is because the library stores the tracked console commands encrypted.
40
+
38
41
  ## How it works
39
42
 
40
43
  ### Session activity logging
@@ -153,6 +156,27 @@ These config options are namespaced in `config.console1984`:
153
156
  | `incinerate_after` | The period to keep sessions around before incinerate them. Default `30.days`. |
154
157
  | `incineration_queue` | The name of the queue for session incineration jobs. Default `console1984_incineration`. |
155
158
 
159
+ ### SSH Config
160
+
161
+ To automatically set the `CONSOLE_USER` env var for sessions, you'll need to configure SSH on the server to accept the environment variable.
162
+
163
+ On the server, edit `/etc/ssh/sshd_config` to accept the environment variable:
164
+ ```
165
+ AcceptEnv LANG LC_* CONSOLE_USER
166
+ ```
167
+
168
+ Restart the SSH server to use the new config:
169
+ ```bash
170
+ service sshd restart
171
+ ```
172
+
173
+ On the client side, you can provide this env var from your clients by adding the variable to the ssh config:
174
+
175
+ ```
176
+ Host *
177
+ SetEnv CONSOLE_USER=david
178
+ ```
179
+
156
180
  ## About built-in protection mechanisms
157
181
 
158
182
  `console1984` adds many protection mechanisms to prevent tampering. This includes attempts to alter data in auditing tables or monkey patching certain classes to change how the system works. If you find a way to circumvent these tampering controls, please [report an issue](https://github.com/basecamp/console1984/issues).
@@ -25,6 +25,6 @@ module Console1984::Session::Incineratable
25
25
  end
26
26
 
27
27
  def earliest_possible_incineration_date
28
- created_at + Console1984.incinerate_after
28
+ created_at + Console1984.incinerate_after - 1.second
29
29
  end
30
30
  end
@@ -5,7 +5,7 @@ module Console1984::Ext::ActiveRecord::ProtectedAuditableTables
5
5
  %i[ execute exec_query exec_insert exec_delete exec_update exec_insert_all ].each do |method|
6
6
  define_method method do |*args, **kwargs|
7
7
  sql = args.first
8
- if Console1984.command_executor.executing_user_command? && sql =~ auditable_tables_regexp
8
+ if Console1984.command_executor.executing_user_command? && sql.b =~ auditable_tables_regexp
9
9
  raise Console1984::Errors::ForbiddenCommandAttempted, "#{sql}"
10
10
  else
11
11
  super(*args, **kwargs)
@@ -2,13 +2,13 @@
2
2
  module Console1984::Ext::Socket::TcpSocket
3
3
  include Console1984::Freezeable
4
4
 
5
- def write(*args)
5
+ def write(...)
6
6
  protecting do
7
7
  super
8
8
  end
9
9
  end
10
10
 
11
- def write_nonblock(*args)
11
+ def write_nonblock(...)
12
12
  protecting do
13
13
  super
14
14
  end
@@ -17,6 +17,7 @@ class Console1984::Refrigerator
17
17
  end
18
18
 
19
19
  def freeze_internal_instances
20
+ Console1984.freeze # Because it's the root engine module it can't mix Freezable.
20
21
  Console1984.config.freeze unless Console1984.config.test_mode
21
22
  end
22
23
 
@@ -6,6 +6,11 @@ class Console1984::Shield::Modes::Protected
6
6
 
7
7
  thread_mattr_accessor :currently_protected_urls, default: []
8
8
 
9
+ # Materialize the thread attribute before freezing the class. +thread_mattr_accessor+ attributes rely on
10
+ # setting a class variable the first time they are referenced, and that will fail in frozen classes
11
+ # like this one.
12
+ currently_protected_urls
13
+
9
14
  def execute(&block)
10
15
  protecting(&block)
11
16
  end
@@ -64,7 +64,6 @@ class Console1984::Shield
64
64
  if Object.const_defined?(class_string)
65
65
  klass = class_string.constantize
66
66
  klass.prepend(Console1984::Ext::ActiveRecord::ProtectedAuditableTables)
67
- klass.include(Console1984::Freezeable)
68
67
  end
69
68
  end
70
69
  end
@@ -1,3 +1,3 @@
1
1
  module Console1984
2
- VERSION = '0.1.17'
2
+ VERSION = '0.1.21'
3
3
  end
data/lib/console1984.rb CHANGED
@@ -38,7 +38,7 @@ class_loader.setup
38
38
  # the console. For example, to prevent the user from deleting audit trails. See
39
39
  # Console1984::Shield and Console1984::CommandValidator to learn more.
40
40
  module Console1984
41
- include Messages, Freezeable
41
+ include Messages
42
42
 
43
43
  mattr_accessor :supervisor, default: Supervisor.new
44
44
 
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.17
4
+ version: 0.1.21
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-09-24 00:00:00.000000000 Z
11
+ date: 2021-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: activeresource
42
+ name: rails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '7.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '7.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: benchmark-ips
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -261,14 +261,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
261
261
  requirements:
262
262
  - - ">="
263
263
  - !ruby/object:Gem::Version
264
- version: '0'
264
+ version: 2.7.0
265
265
  required_rubygems_version: !ruby/object:Gem::Requirement
266
266
  requirements:
267
267
  - - ">="
268
268
  - !ruby/object:Gem::Version
269
269
  version: '0'
270
270
  requirements: []
271
- rubygems_version: 3.1.4
271
+ rubygems_version: 3.2.32
272
272
  signing_key:
273
273
  specification_version: 4
274
274
  summary: Your Rails console, 1984 style