Module: EnvSensitive Private

Extended by:
T::Helpers
Included in:
ENV, EnvActivation
Defined in:
extend/ENV/sensitive.rb,
extend/ENV.rbi

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Instance Method Summary collapse

Instance Method Details

#clear_sensitive_environment!(&block) ⇒ T.untyped

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • block (T.proc.returns(T.untyped), nil)

Returns:

  • (T.untyped)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'extend/ENV/sensitive.rb', line 20

def clear_sensitive_environment!(&block)
  unless block
    each_key { |key| delete key if sensitive?(key) }
    return
  end

  old_env = to_hash.dup
  begin
    clear_sensitive_environment!
    yield
  ensure
    replace(old_env)
  end
end

#sensitive?(key) ⇒ Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

Returns:

  • (Boolean)


10
11
12
# File 'extend/ENV/sensitive.rb', line 10

def sensitive?(key)
  key.match?(/(cookie|key|token|password|passphrase|auth)/i)
end

#sensitive_environmentHash{String => String}

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



15
16
17
# File 'extend/ENV/sensitive.rb', line 15

def sensitive_environment
  select { |key, _| sensitive?(key) }
end