envameleon 0.3.0-x86_64-linux-gnu → 0.5.0-x86_64-linux-gnu

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: 1cc7e48bb7f0460d9e1b42d2974ce9df77cb9047c40a276e2c9a11a7d7743735
4
- data.tar.gz: 908ceb85660ad861a233288a418cae5b88b710431debaa321f8d0ff68392e138
3
+ metadata.gz: 679b2edecfa6145e7c8007a3ae023579c17e4a68bb6573cefd19559bbb024d10
4
+ data.tar.gz: ad0f3affa48a4de68549429e1e75719412f876332687c5594051e26192ca9fd0
5
5
  SHA512:
6
- metadata.gz: ffc6352b2d2bc9e330056f8efd11cf4d82df10fa13d3b5ca2af5b38eaf95b230eab0f9dfc8b8a5eb6d4df8aa727f869a43380237be8576aa3cac75da3bb9ae46
7
- data.tar.gz: e4a38cc0f7aaa59b7a9eb28ba046a98e2aa9c0bdbbfd5f016586930b3b70c2186c9bf4bde181e64df69e8f5ec2f1f72575f161aded8091c2c68620861b479793
6
+ metadata.gz: 0677554c7bd854b632177f454a7572555c06356e5fe7cb7c98c732469200646916f408bc93c60ddb6d30d3619d25597e0373b0beccc76b60d035b2f8dc28fb38
7
+ data.tar.gz: b1a7fc48a396c3d58172039a4bffa772856babad5106ab4973efe946ef2f9ab90e683494f2d9232089a058159f0e58a4e6890215476ae2bc396d31dd0641eb87
data/README.md CHANGED
@@ -90,22 +90,23 @@ ENVameleon publishes precompiled native gems for its supported CRuby minors on:
90
90
  The macOS and Windows gems contain the documented pure-Ruby no-ops. There is no
91
91
  native code to compile on those systems. Linux is split into `-linux-gnu` and
92
92
  `-linux-musl` gems so a glibc binary is never mistaken for a musl binary. These
93
- native gems require RubyGems 3.3.22 or newer; musl users should use Bundler
93
+ multi-ABI gems require RubyGems 3.3.22 or newer; musl users should use Bundler
94
94
  2.5.6 or newer.
95
95
 
96
- Each precompiled Linux gem contains a separate binary for every supported Ruby
97
- minor and has no extension build hook. When Linux runs a newer Ruby API,
98
- RubyGems or Bundler selects the generic source gem instead. That gem runs
99
- `extconf.rb` and requires a C compiler, Make, and the Ruby headers. macOS and
100
- Windows continue to select their compiler-free no-op gems. If neither a native
101
- nor source fallback applies on Linux, `require "envameleon"` fails closed
102
- instead of silently exposing the process environment.
96
+ RubyGems and Bundler 4.1 or newer prefer a content-addressed gem containing
97
+ only the binary for your Ruby minor. Older clients use the multi-ABI gem,
98
+ which bundles every supported Ruby minor for that platform. Neither format
99
+ needs a compiler. If there is no precompiled binary for your Ruby, the generic
100
+ source gem runs `extconf.rb` and requires a C compiler, Make, and the Ruby
101
+ headers. macOS and Windows continue to select their compiler-free no-op gems.
102
+ If neither a native nor source fallback applies on Linux, `require "envameleon"`
103
+ fails closed instead of silently exposing the process environment.
103
104
 
104
105
  Every GitHub release includes the gems and `SHA256SUMS`. Release gems also have
105
106
  GitHub build-provenance attestations, which can be checked with:
106
107
 
107
108
  ```console
108
- gh attestation verify envameleon-0.2.0-x86_64-linux-gnu.gem --repo kpumuk/envameleon
109
+ gh attestation verify envameleon-0.5.0-x86_64-linux-gnu.gem --repo kpumuk/envameleon
109
110
  ```
110
111
 
111
112
  [Back to top](#readme-top).
@@ -119,7 +120,7 @@ ENV.mask_proc_data
119
120
  # SECRET=example becomes SECRET=e*****e in /proc/self/environ
120
121
 
121
122
  ENV.scrub_proc_data
122
- # /proc/self/environ now holds only NUL bytes
123
+ # /proc/self/environ now holds NUL bytes except for any LD_LIBRARY_PATH entry
123
124
 
124
125
  ENV.drop_proc_data
125
126
  # /proc/self/environ is now zero bytes long
@@ -127,8 +128,8 @@ ENV.drop_proc_data
127
128
 
128
129
  | Method | Result in `/proc/self/environ` | File length | Permissions |
129
130
  | --- | --- | --- | --- |
130
- | `ENV.mask_proc_data` | Names plus the first and last value byte | Unchanged | None |
131
- | `ENV.scrub_proc_data` | NUL bytes | Unchanged | None |
131
+ | `ENV.mask_proc_data` | Names plus the first and last value byte; `LD_LIBRARY_PATH` untouched | Unchanged | None |
132
+ | `ENV.scrub_proc_data` | NUL bytes except for `LD_LIBRARY_PATH` | Unchanged | None |
132
133
  | `ENV.drop_proc_data` | Empty | Zero | `CAP_SYS_RESOURCE` |
133
134
 
134
135
  Choose the least power you need.
@@ -137,8 +138,14 @@ Choose the least power you need.
137
138
  > `ENV.drop_proc_data` requires `CAP_SYS_RESOURCE` on Linux. Without it, the
138
139
  > method raises `Errno::EPERM`.
139
140
 
140
- Masking works on raw bytes, not characters. It replaces all value bytes except
141
- the first and last with `*`. Values shorter than three bytes stay unchanged.
141
+ Masking works on raw bytes, not characters. For entries it masks, it replaces
142
+ all value bytes except the first and last with `*`. Values shorter than three
143
+ bytes stay unchanged.
144
+
145
+ Masking and scrubbing leave the original `LD_LIBRARY_PATH` entry visible on all
146
+ Linux systems because the musl dynamic linker still uses its original bytes to
147
+ find libraries. Changing or deleting the variable in Ruby's `ENV` does not
148
+ change the original entry. Dropping hides it without rewriting the bytes.
142
149
 
143
150
  [Back to top](#readme-top).
144
151
 
@@ -158,7 +165,8 @@ start. This makes `/proc/self/environ` truly zero-length. Linux requires the
158
165
 
159
166
  ## Process Inheritance
160
167
 
161
- Call a method before `fork` and each child inherits the changed proc view. Ruby
168
+ Call a method before `fork` and each child inherits the changed proc view.
169
+ `fork` copies the changed bytes and does not rebuild them from Ruby `ENV`. Ruby
162
170
  `ENV` remains available in the parent and children. The test suite checks this
163
171
  with a second fork for all three methods.
164
172
 
@@ -167,36 +175,48 @@ proc environment. That program must load ENVameleon and call a method itself.
167
175
 
168
176
  ### Forking servers
169
177
 
170
- You may call a method in the parent before it forks. You may also call it from a
171
- worker boot hook. These examples use scrubbing, which needs no extra right.
178
+ Call the method in the parent before it forks so workers inherit the changed
179
+ view. Scrubbing leaves `LD_LIBRARY_PATH` visible in both the parent and workers.
180
+
181
+ Do not rely on a worker boot hook alone. It changes only the worker. The parent
182
+ runs as the same user, so anyone who can read the worker's files can also read
183
+ `/proc/<parent pid>/environ`.
184
+
185
+ These examples use scrubbing, which needs no extra right. In the Unicorn, Puma,
186
+ and Karafka examples, a failed call stops the server before it starts work.
172
187
 
173
188
  #### Unicorn
174
189
 
190
+ Call the method at the top of the Unicorn config file. The master evaluates it
191
+ before it forks workers.
192
+
175
193
  ```ruby
194
+ # config/unicorn.rb
176
195
  require "envameleon"
177
196
 
178
- after_fork do |_server, _worker|
179
- ENV.scrub_proc_data
180
- end
197
+ ENV.scrub_proc_data
181
198
  ```
182
199
 
183
200
  #### Puma
184
201
 
185
- Use `before_worker_boot` for cluster workers. In single mode, call the method
186
- during app boot.
202
+ Call the method at the top of `config/puma.rb`. This works in single and
203
+ cluster mode.
187
204
 
188
205
  ```ruby
206
+ # config/puma.rb
189
207
  require "envameleon"
190
208
 
191
- before_worker_boot do
192
- ENV.scrub_proc_data
193
- end
209
+ ENV.scrub_proc_data
194
210
  ```
195
211
 
212
+ Puma logs and ignores errors raised in `before_worker_boot`. A failed call
213
+ there leaves the worker running with its environment visible.
214
+
196
215
  #### Sidekiq
197
216
 
198
217
  Standard Sidekiq uses threads. Its startup hook runs before work begins. Sidekiq
199
- Enterprise Swarm runs the hook in each child.
218
+ Enterprise Swarm runs the hook in each child. The swarm parent is a separate
219
+ process and keeps its own view. See [Security Limits](#security-limits).
200
220
 
201
221
  ```ruby
202
222
  require "envameleon"
@@ -208,15 +228,15 @@ end
208
228
 
209
229
  #### Karafka
210
230
 
211
- The `app.running` event runs in the server process. In Swarm mode, it runs in
212
- each forked node.
231
+ Call the method at the top of `karafka.rb`. Both `karafka server` and the Swarm
232
+ supervisor load this file before they start work. Swarm nodes inherit the
233
+ changed view. The `app.running` event never runs in the Swarm supervisor.
213
234
 
214
235
  ```ruby
236
+ # karafka.rb
215
237
  require "envameleon"
216
238
 
217
- Karafka::App.monitor.subscribe("app.running") do
218
- ENV.scrub_proc_data
219
- end
239
+ ENV.scrub_proc_data
220
240
  ```
221
241
 
222
242
  If a child calls `ENV.drop_proc_data`, it must still have the needed Linux right.
@@ -235,9 +255,22 @@ ENVameleon changes only what `/proc/self/environ` shows. It does not erase every
235
255
  copy of a secret. It gives no protection from memory disclosure, debuggers, or
236
256
  core dumps.
237
257
 
258
+ ENVameleon changes only the process that calls it and the children it forks
259
+ later. Any other process started with the secret still shows it in
260
+ `/proc/<pid>/environ`. That includes the parent, PID 1 in a container, wrapper
261
+ shells, and process managers. A process running as the same user can usually
262
+ read those files. Start the app with `exec` so no wrapper shell stays behind.
263
+
238
264
  Dropping leaves the old bytes in memory. Masking keeps variable names and the
239
- outer bytes of each value. Short values remain fully visible. Scrubbing
240
- overwrites the old proc range, but a secret may still exist elsewhere.
265
+ outer bytes of masked values. Short values remain fully visible. Masking and
266
+ scrubbing both leave `LD_LIBRARY_PATH` visible in `/proc/self/environ` if it was
267
+ present at startup and has not already been overwritten.
268
+
269
+ Code that saved a pointer into the original environment before Ruby started,
270
+ such as the dynamic linker or a preloaded library, sees any bytes that masking
271
+ or scrubbing rewrites, even though Ruby's `ENV` stays unchanged. Neither method
272
+ can restore an entry that a long process title or other code has already
273
+ overwritten.
241
274
 
242
275
  [Back to top](#readme-top).
243
276
 
@@ -262,15 +295,22 @@ Build the macOS and Windows no-op gems and the Linux source fallback with:
262
295
  bundle exec rake gem
263
296
  ```
264
297
 
265
- Native builds run inside the versioned image selected by the
266
- checksum-locked `rake-compiler-dock` gem. The image installs the exact Bundler
267
- version recorded in `Gemfile.lock`; Bundler then validates its own locked
268
- checksum and installs every other dependency from the prepared local cache:
298
+ Native builds run in a container image pinned by digest for each platform.
299
+ The build checks the SHA-256 checksums of RubyGems 4.1.1 and the Bundler version
300
+ in `Gemfile.lock` before installing them. Bundler then checks the locked
301
+ dependencies and installs them from the local cache. If a `rake-compiler-dock`
302
+ update changes its image version, update the version and digests in
303
+ [`.github/scripts/native_platforms.rb`](.github/scripts/native_platforms.rb)
304
+ in the same change; native build tasks reject an image version mismatch.
305
+
306
+ Each native build produces the platform's multi-ABI gem and one
307
+ hash-named gem per supported Ruby ABI. Start with an empty `pkg` directory and
308
+ run the verifier with RubyGems 4.1 or newer on the host:
269
309
 
270
310
  ```console
271
311
  bundle cache --all-platforms
272
312
  bundle exec rake gem:x86_64-linux-gnu
273
- ruby .github/scripts/verify_native_gem.rb pkg/envameleon-0.2.0-x86_64-linux-gnu.gem x86_64-linux-gnu
313
+ ruby .github/scripts/verify_native_gem.rb pkg x86_64-linux-gnu
274
314
  ```
275
315
 
276
316
  ## License
Binary file
Binary file
Binary file
Binary file
metadata CHANGED
@@ -1,122 +1,134 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: envameleon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.5.0
5
5
  platform: x86_64-linux-gnu
6
6
  authors:
7
- - Dmytro Shteflyuk
7
+ - Dmytro Shteflyuk
8
8
  bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
- - !ruby/object:Gem::Dependency
13
- name: rake
14
- requirement: !ruby/object:Gem::Requirement
15
- requirements:
16
- - - "~>"
17
- - !ruby/object:Gem::Version
18
- version: '13.2'
19
- type: :development
20
- prerelease: false
21
- version_requirements: !ruby/object:Gem::Requirement
22
- requirements:
23
- - - "~>"
24
- - !ruby/object:Gem::Version
25
- version: '13.2'
26
- - !ruby/object:Gem::Dependency
27
- name: rake-compiler
28
- requirement: !ruby/object:Gem::Requirement
29
- requirements:
30
- - - "~>"
31
- - !ruby/object:Gem::Version
32
- version: 1.3.1
33
- type: :development
34
- prerelease: false
35
- version_requirements: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: 1.3.1
40
- - !ruby/object:Gem::Dependency
41
- name: rake-compiler-dock
42
- requirement: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '1.12'
47
- type: :development
48
- prerelease: false
49
- version_requirements: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '1.12'
54
- - !ruby/object:Gem::Dependency
55
- name: standard
56
- requirement: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '1.56'
61
- type: :development
62
- prerelease: false
63
- version_requirements: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '1.56'
68
- - !ruby/object:Gem::Dependency
69
- name: test-unit
70
- requirement: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '3.7'
75
- type: :development
76
- prerelease: false
77
- version_requirements: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '3.7'
82
- description: Scrub, mask, or drop Linux's /proc/self/environ view without changing
83
- Ruby's ENV.
12
+ - !ruby/object:Gem::Dependency
13
+ name: rake
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ -
17
+ - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: "13.2"
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ -
25
+ - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: "13.2"
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake-compiler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ -
33
+ - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: 1.3.2
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ -
41
+ - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.3.2
44
+ - !ruby/object:Gem::Dependency
45
+ name: rake-compiler-dock
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ -
49
+ - ~>
50
+ - !ruby/object:Gem::Version
51
+ version: "1.12"
52
+ type: :development
53
+ prerelease: false
54
+ version_requirements: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ -
57
+ - ~>
58
+ - !ruby/object:Gem::Version
59
+ version: "1.12"
60
+ - !ruby/object:Gem::Dependency
61
+ name: standard
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ -
65
+ - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: "1.56"
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ -
73
+ - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: "1.56"
76
+ - !ruby/object:Gem::Dependency
77
+ name: test-unit
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ -
81
+ - ~>
82
+ - !ruby/object:Gem::Version
83
+ version: "3.7"
84
+ type: :development
85
+ prerelease: false
86
+ version_requirements: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ -
89
+ - ~>
90
+ - !ruby/object:Gem::Version
91
+ version: "3.7"
92
+ description: "Scrub, mask, or drop Linux's /proc/self/environ view without changing Ruby's ENV."
84
93
  executables: []
85
94
  extensions: []
86
95
  extra_rdoc_files: []
87
96
  files:
88
- - LICENSE.txt
89
- - README.md
90
- - lib/envameleon.rb
91
- - lib/envameleon/3.2/envameleon.so
92
- - lib/envameleon/3.3/envameleon.so
93
- - lib/envameleon/3.4/envameleon.so
94
- - lib/envameleon/4.0/envameleon.so
95
- homepage: https://github.com/kpumuk/envameleon
97
+ - LICENSE.txt
98
+ - README.md
99
+ - lib/envameleon.rb
100
+ - lib/envameleon/3.2/envameleon.so
101
+ - lib/envameleon/3.3/envameleon.so
102
+ - lib/envameleon/3.4/envameleon.so
103
+ - lib/envameleon/4.0/envameleon.so
104
+ homepage: "https://github.com/kpumuk/envameleon"
96
105
  licenses:
97
- - MIT
106
+ - MIT
98
107
  metadata:
99
- bug_tracker_uri: https://github.com/kpumuk/envameleon/issues
100
- rubygems_mfa_required: 'true'
101
- source_code_uri: https://github.com/kpumuk/envameleon
108
+ bug_tracker_uri: "https://github.com/kpumuk/envameleon/issues"
109
+ rubygems_mfa_required: "true"
110
+ source_code_uri: "https://github.com/kpumuk/envameleon"
102
111
  rdoc_options: []
103
112
  require_paths:
104
- - lib
113
+ - lib
105
114
  required_ruby_version: !ruby/object:Gem::Requirement
106
115
  requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- version: 3.2.0
110
- - - "<"
111
- - !ruby/object:Gem::Version
112
- version: 4.1.0.dev
116
+ -
117
+ - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: 3.2.0
120
+ -
121
+ - "<"
122
+ - !ruby/object:Gem::Version
123
+ version: 4.1.0.dev
113
124
  required_rubygems_version: !ruby/object:Gem::Requirement
114
125
  requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: 3.3.22
126
+ -
127
+ - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: 3.3.22
118
130
  requirements: []
119
- rubygems_version: 4.0.6
131
+ rubygems_version: 4.1.1
120
132
  specification_version: 4
121
133
  summary: Leave no ENVidence.
122
134
  test_files: []