Class: Installation::Clients::SecurityProposal

Inherits:
ProposalClient
  • Object
show all
Includes:
Yast::I18n, Yast::Logger
Defined in:
src/lib/installation/clients/security_proposal.rb

Overview

Firewall and SSH installation proposal client

Constant Summary collapse

[
  LINK_ENABLE_FIREWALL = "security--enable_firewall".freeze,
  LINK_DISABLE_FIREWALL = "security--disable_firewall".freeze,
  LINK_OPEN_SSH_PORT = "security--open_ssh".freeze,
  LINK_BLOCK_SSH_PORT = "security--close_ssh".freeze,
  LINK_ENABLE_SSHD = "security--enable_sshd".freeze,
  LINK_DISABLE_SSHD = "security--disable_sshd".freeze,
  LINK_OPEN_VNC = "security--open_vnc".freeze,
  LINK_CLOSE_VNC = "security--close_vnc".freeze,
  LINK_CPU_MITIGATIONS = "security--cpu_mitigations".freeze
].freeze
"security".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSecurityProposal

Constructor



54
55
56
57
58
59
60
61
# File 'src/lib/installation/clients/security_proposal.rb', line 54

def initialize
  super
  Yast.import "UI"
  Yast.import "HTML"
  textdomain "installation"

  @settings ||= ::Installation::SecuritySettings.instance
end

Instance Attribute Details

#settingsObject

[Installation::SecuritySettings] Stores the proposal settings



37
38
39
# File 'src/lib/installation/clients/security_proposal.rb', line 37

def settings
  @settings
end

Instance Method Details

#ask_user(param) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'src/lib/installation/clients/security_proposal.rb', line 95

def ask_user(param)
  chosen_link = param["chosen_id"]
  result = :next
  log.info "User clicked #{chosen_link}"

  if SERVICES_LINKS.include?(chosen_link)
    call_proposal_action_for(chosen_link)
  elsif chosen_link == LINK_DIALOG
    result = ::Installation::Dialogs::Security.new(@settings).run
  else
    raise "INTERNAL ERROR: unknown action '#{chosen_link}' for proposal client"
  end

  { "workflow_sequence" => result }
end

#descriptionObject



63
64
65
66
67
68
69
70
71
# File 'src/lib/installation/clients/security_proposal.rb', line 63

def description
  {
    # Proposal title
    "rich_text_title" => _("Security"),
    # Menu entry label
    "menu_title"      => _("&Security"),
    "id"              => LINK_DIALOG
  }
end

#make_proposal(_attrs) ⇒ Object



73
74
75
76
77
78
79
80
# File 'src/lib/installation/clients/security_proposal.rb', line 73

def make_proposal(_attrs)
  {
    "preformatted_proposal" => preformatted_proposal,
    "warning_level"         => :warning,
    "links"                 => SERVICES_LINKS,
    "warning"               => warning
  }
end

#preformatted_proposalObject



82
83
84
# File 'src/lib/installation/clients/security_proposal.rb', line 82

def preformatted_proposal
  Yast::HTML.List(proposals)
end

#warningObject



86
87
88
89
90
91
92
93
# File 'src/lib/installation/clients/security_proposal.rb', line 86

def warning
  return nil unless @settings.access_problem?

  # TRANSLATORS: proposal warning text preventing the user to block
  # the root login by error.
  _("The 'root' user uses only SSH key-based authentication. <br>" \
    "With the current settings the user might not be allowed to login.")
end

#writeObject



111
112
113
# File 'src/lib/installation/clients/security_proposal.rb', line 111

def write
  { "success" => true }
end