Module: CodexNotify::ConfigDiagnostics
- Defined in:
- lib/codex_notify/config_diagnostics.rb
Class Method Summary collapse
- .warn_deprecated_cli_token(stderr:) ⇒ Object
- .warn_deprecated_repository_credentials(path, keys, stderr:) ⇒ Object
- .warn_deprecated_tool_config(path, keys, stderr:) ⇒ Object
- .warn_if_env_file_insecure(path, stderr:) ⇒ Object
- .warn_if_file_insecure(path, label:, stderr:) ⇒ Object
- .warn_ignored_repository_credentials(path, keys, policy: nil, stderr:) ⇒ Object
- .warn_ignored_repository_policy(path, stderr:) ⇒ Object
Class Method Details
.warn_deprecated_cli_token(stderr:) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/codex_notify/config_diagnostics.rb', line 25 def warn_deprecated_cli_token(stderr:) stderr.puts( 'WARNING: --token is deprecated because command-line arguments may be visible in process lists ' \ 'and shell history; use SLACK_BOT_TOKEN or a permission-restricted env file.' ) end |
.warn_deprecated_repository_credentials(path, keys, stderr:) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/codex_notify/config_diagnostics.rb', line 32 def warn_deprecated_repository_credentials(path, keys, stderr:) stderr.puts( "WARNING: insecure legacy mode loaded repository Slack settings #{keys.join(' and ')} from automatically " \ "discovered env file #{path}; this temporary compatibility mode will be removed in a future major release. " \ 'Configure a trusted destination profile and use CODEX_NOTIFY_DESTINATION.' ) end |
.warn_deprecated_tool_config(path, keys, stderr:) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/codex_notify/config_diagnostics.rb', line 54 def warn_deprecated_tool_config(path, keys, stderr:) stderr.puts( "WARNING: #{keys.join(', ')} loaded from legacy codex-notify env file #{path}; " \ 'move trusted settings to the XDG config file.' ) end |
.warn_if_env_file_insecure(path, stderr:) ⇒ Object
21 22 23 |
# File 'lib/codex_notify/config_diagnostics.rb', line 21 def warn_if_env_file_insecure(path, stderr:) warn_if_file_insecure(path, label: 'env file', stderr:) end |
.warn_if_file_insecure(path, label:, stderr:) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/codex_notify/config_diagnostics.rb', line 7 def warn_if_file_insecure(path, label:, stderr:) stat = File.stat(path) return unless stat.file? return if (stat.mode & 0o077).zero? = format('%04o', stat.mode & 0o777) stderr.puts( "WARNING: #{label} #{path} has permissions #{}; " \ "use `chmod 600 #{path}` to restrict access to secrets." ) rescue NotImplementedError, SystemCallError nil end |
.warn_ignored_repository_credentials(path, keys, policy: nil, stderr:) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/codex_notify/config_diagnostics.rb', line 47 def warn_ignored_repository_credentials(path, keys, policy: nil, stderr:) reason = policy ? " under the #{policy} policy" : '' stderr.puts( "WARNING: ignored #{keys.join(', ')} from automatically discovered repository env file #{path}#{reason}." ) end |
.warn_ignored_repository_policy(path, stderr:) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/codex_notify/config_diagnostics.rb', line 40 def warn_ignored_repository_policy(path, stderr:) stderr.puts( "WARNING: ignored CODEX_NOTIFY_ENV_POLICY from automatically discovered repository env file #{path}; " \ 'the policy must come from trusted configuration.' ) end |