machinery-tool 1.22.1 → 1.22.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.git_revision +1 -1
- data/NEWS +10 -0
- data/bin/machinery +1 -1
- data/lib/analyze_changed_config_files_diffs_task.rb +6 -6
- data/lib/autoyast.rb +2 -2
- data/lib/build_task.rb +10 -7
- data/lib/cli.rb +1005 -801
- data/lib/compare_task.rb +11 -7
- data/lib/comparison.rb +2 -2
- data/lib/config_base.rb +1 -1
- data/lib/config_task.rb +1 -1
- data/lib/containerize_task.rb +3 -3
- data/lib/containerized_app.rb +1 -1
- data/lib/copy_task.rb +1 -1
- data/lib/current_user.rb +1 -1
- data/lib/deploy_task.rb +6 -4
- data/lib/diff_widget.rb +67 -63
- data/lib/docker_system.rb +12 -8
- data/lib/dpkg_database.rb +1 -1
- data/lib/element_filter.rb +7 -4
- data/lib/exceptions.rb +23 -5
- data/lib/export_task.rb +1 -1
- data/lib/exporter.rb +1 -1
- data/lib/file_diff.rb +1 -1
- data/lib/file_scope.rb +1 -1
- data/lib/file_validator.rb +7 -4
- data/lib/filter.rb +97 -93
- data/lib/filter_option_parser.rb +2 -2
- data/lib/hint.rb +64 -59
- data/lib/html.rb +1 -1
- data/lib/inspect_task.rb +12 -12
- data/lib/inspector.rb +3 -3
- data/lib/json_validation_error_cleaner.rb +1 -1
- data/lib/json_validator.rb +4 -4
- data/lib/kiwi_config.rb +8 -4
- data/lib/list_task.rb +10 -9
- data/lib/local_system.rb +11 -5
- data/lib/logged_cheetah.rb +1 -1
- data/lib/man_task.rb +10 -6
- data/lib/managed_files_database.rb +1 -1
- data/lib/manifest.rb +5 -5
- data/lib/migration.rb +16 -10
- data/lib/mountpoints.rb +1 -1
- data/lib/move_task.rb +1 -1
- data/lib/remote_system.rb +7 -7
- data/lib/remove_task.rb +1 -1
- data/lib/renderer.rb +177 -172
- data/lib/rpm.rb +4 -4
- data/lib/rpm_database.rb +1 -1
- data/lib/scope.rb +2 -2
- data/lib/scope_file_access_archive.rb +1 -1
- data/lib/scope_file_access_flat.rb +1 -1
- data/lib/scope_file_store.rb +1 -1
- data/lib/serve_html_task.rb +6 -2
- data/lib/server.rb +19 -12
- data/lib/show_task.rb +10 -6
- data/lib/static_html.rb +1 -1
- data/lib/system.rb +10 -10
- data/lib/system_description.rb +14 -13
- data/lib/system_description_memory_store.rb +1 -1
- data/lib/system_description_store.rb +9 -9
- data/lib/tarball.rb +8 -2
- data/lib/upgrade_format_task.rb +11 -6
- data/lib/validate_task.rb +2 -2
- data/lib/version.rb +1 -1
- data/lib/workload_mapper.rb +2 -2
- data/lib/workload_mapper_dsl.rb +1 -1
- data/lib/zypper.rb +40 -17
- data/machinery-helper/machinery_helper.go +35 -16
- data/machinery-helper/version.go +1 -1
- data/man/generated/machinery.1.gz +0 -0
- data/manual/site/sitemap.xml +24 -24
- data/plugins/changed_config_files/changed_config_files_inspector.rb +59 -56
- data/plugins/changed_config_files/changed_config_files_model.rb +23 -21
- data/plugins/changed_config_files/changed_config_files_renderer.rb +56 -52
- data/plugins/changed_managed_files/changed_managed_files_inspector.rb +52 -50
- data/plugins/changed_managed_files/changed_managed_files_model.rb +23 -21
- data/plugins/changed_managed_files/changed_managed_files_renderer.rb +43 -39
- data/plugins/environment/environment_inspector.rb +25 -23
- data/plugins/environment/environment_model.rb +5 -3
- data/plugins/groups/groups_inspector.rb +30 -28
- data/plugins/groups/groups_model.rb +18 -17
- data/plugins/groups/groups_renderer.rb +29 -25
- data/plugins/os/os_inspector.rb +120 -118
- data/plugins/os/os_model.rb +139 -134
- data/plugins/os/os_renderer.rb +13 -9
- data/plugins/packages/packages_inspector.rb +99 -86
- data/plugins/packages/packages_model.rb +35 -34
- data/plugins/packages/packages_renderer.rb +47 -39
- data/plugins/patterns/patterns_inspector.rb +70 -68
- data/plugins/patterns/patterns_model.rb +19 -18
- data/plugins/patterns/patterns_renderer.rb +36 -32
- data/plugins/repositories/repositories_inspector.rb +162 -156
- data/plugins/repositories/repositories_model.rb +50 -49
- data/plugins/repositories/repositories_renderer.rb +48 -44
- data/plugins/repositories/schema/system-description-repositories.schema-v10.json +0 -1
- data/plugins/services/services_inspector.rb +187 -176
- data/plugins/services/services_model.rb +37 -36
- data/plugins/services/services_renderer.rb +28 -24
- data/plugins/unmanaged_files/unmanaged_files_inspector.rb +102 -99
- data/plugins/unmanaged_files/unmanaged_files_model.rb +64 -56
- data/plugins/unmanaged_files/unmanaged_files_renderer.rb +44 -40
- data/plugins/users/users_inspector.rb +67 -65
- data/plugins/users/users_model.rb +37 -36
- data/plugins/users/users_renderer.rb +31 -27
- data/schema/migrations/migrate1to2.rb +1 -1
- data/schema/migrations/migrate2to3.rb +1 -1
- data/schema/migrations/migrate3to4.rb +1 -1
- data/schema/migrations/migrate4to5.rb +1 -1
- data/schema/migrations/migrate5to6.rb +1 -1
- data/schema/migrations/migrate6to7.rb +1 -1
- data/schema/migrations/migrate7to8.rb +1 -1
- data/schema/migrations/migrate8to9.rb +1 -1
- data/schema/migrations/migrate9to10.rb +1 -1
- metadata +2 -2
@@ -15,59 +15,63 @@
|
|
15
15
|
# To contact SUSE about this file by physical or electronic mail,
|
16
16
|
# you may find current contact information at www.suse.com
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
module Machinery
|
19
|
+
class Ui
|
20
|
+
class UnmanagedFilesRenderer < Machinery::Ui::Renderer
|
21
|
+
def content(description)
|
22
|
+
return unless description["unmanaged_files"]
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
+
list do
|
25
|
+
file_status = description["unmanaged_files"].extracted
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
if description["unmanaged_files"].elements.empty?
|
28
|
+
puts "There are no unmanaged files."
|
29
|
+
elsif !file_status.nil?
|
30
|
+
puts "Files extracted: #{file_status ? "yes" : "no"}"
|
31
|
+
end
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
33
|
+
if description["unmanaged_files"]
|
34
|
+
description["unmanaged_files"].each do |p|
|
35
|
+
if description["unmanaged_files"].contains_metadata?
|
36
|
+
item "#{p.name} (#{p.type})" do
|
37
|
+
puts "User/Group: #{p.user}:#{p.group}" if p.user || p.group
|
38
|
+
puts "Mode: #{p.mode}" if p.mode
|
39
|
+
puts "Size: #{number_to_human_size(p.size)}" if p.size
|
40
|
+
if p.files && p.dirs
|
41
|
+
puts "Files: #{p.files}"
|
42
|
+
puts "Directories: #{p.dirs}"
|
43
|
+
end
|
44
|
+
if p.file_objects
|
45
|
+
puts "File Objects: #{p.file_objects}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
else
|
49
|
+
item "#{p.name} (#{p.type})"
|
44
50
|
end
|
45
51
|
end
|
46
|
-
else
|
47
|
-
item "#{p.name} (#{p.type})"
|
48
52
|
end
|
49
53
|
end
|
50
54
|
end
|
51
|
-
end
|
52
|
-
end
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
-
|
56
|
+
def display_name
|
57
|
+
"Unmanaged Files"
|
58
|
+
end
|
57
59
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
def compare_content_changed(changed_elements)
|
61
|
+
list do
|
62
|
+
changed_elements.each do |one, two|
|
63
|
+
changes = []
|
64
|
+
relevant_attributes = (one.attributes.keys & two.attributes.keys)
|
63
65
|
|
64
|
-
|
65
|
-
|
66
|
-
|
66
|
+
relevant_attributes.each do |attribute|
|
67
|
+
if one[attribute] != two[attribute]
|
68
|
+
changes << "#{attribute}: #{one[attribute]} <> #{two[attribute]}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
item "#{one.name} (#{changes.join(", ")})"
|
67
73
|
end
|
68
74
|
end
|
69
|
-
|
70
|
-
item "#{one.name} (#{changes.join(", ")})"
|
71
75
|
end
|
72
76
|
end
|
73
77
|
end
|
@@ -15,84 +15,86 @@
|
|
15
15
|
# To contact SUSE about this file by physical or electronic mail,
|
16
16
|
# you may find current contact information at www.suse.com
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
module Machinery
|
19
|
+
class UsersInspector < Machinery::Inspector
|
20
|
+
has_priority 50
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
def initialize(system, description)
|
23
|
+
@system = system
|
24
|
+
@description = description
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
def inspect(_filter, _options = {})
|
28
|
+
passwd = @system.read_file("/etc/passwd")
|
29
|
+
shadow = @system.read_file("/etc/shadow", privileged: true)
|
29
30
|
|
30
|
-
|
31
|
+
users = passwd ? parse_users(passwd, shadow) : []
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
@description.users = UsersScope.new(users.sort_by(&:name))
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
def summary
|
37
|
+
"Found #{Machinery.pluralize(@description.users.size, "%d user")}."
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
+
private
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
def parse_users(passwd, shadow)
|
43
|
+
passwd = Machinery.scrub(passwd)
|
44
|
+
users = passwd.lines.map { |l| l.split(":").first }
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
users.map do |user|
|
47
|
+
attributes = passwd_attributes(passwd, user)
|
48
|
+
attributes.merge!(shadow_attributes(shadow, user)) if shadow
|
48
49
|
|
49
|
-
|
50
|
+
User.new(attributes)
|
51
|
+
end
|
50
52
|
end
|
51
|
-
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
name:
|
54
|
+
def passwd_attributes(passwd, user)
|
55
|
+
line = passwd.lines.find { |l| l.start_with?("#{user}:") }
|
56
|
+
user, passwd, uid, gid, comment, home, shell = line.split(":").map(&:chomp)
|
57
|
+
|
58
|
+
# In case the inspected machine uses NIS, /etc/passwd will contain a
|
59
|
+
# placeholder entry like this:
|
60
|
+
#
|
61
|
+
# +::::::
|
62
|
+
#
|
63
|
+
# We need to handle it correctly, which means setting non-string attributes
|
64
|
+
# to nil.
|
65
|
+
uid = Machinery.is_int?(uid) ? uid.to_i : nil
|
66
|
+
gid = Machinery.is_int?(gid) ? gid.to_i : nil
|
67
|
+
|
68
|
+
{
|
69
|
+
name: user,
|
69
70
|
password: passwd,
|
70
|
-
uid:
|
71
|
-
gid:
|
72
|
-
comment:
|
73
|
-
home:
|
74
|
-
shell:
|
75
|
-
}
|
76
|
-
end
|
77
|
-
|
78
|
-
def shadow_attributes(shadow, user)
|
79
|
-
line = shadow.lines.find { |l| l.start_with?("#{user}:") }
|
80
|
-
if line
|
81
|
-
user, passwd, changed, min, max, warn, inactive, expire = line.split(":").map(&:chomp)
|
82
|
-
|
83
|
-
result = {
|
84
|
-
encrypted_password: passwd
|
71
|
+
uid: uid,
|
72
|
+
gid: gid,
|
73
|
+
comment: comment,
|
74
|
+
home: home,
|
75
|
+
shell: shell
|
85
76
|
}
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
77
|
+
end
|
78
|
+
|
79
|
+
def shadow_attributes(shadow, user)
|
80
|
+
line = shadow.lines.find { |l| l.start_with?("#{user}:") }
|
81
|
+
if line
|
82
|
+
user, passwd, changed, min, max, warn, inactive, expire = line.split(":").map(&:chomp)
|
83
|
+
|
84
|
+
result = {
|
85
|
+
encrypted_password: passwd
|
86
|
+
}
|
87
|
+
result[:last_changed_date] = changed.to_i unless changed.empty?
|
88
|
+
result[:min_days] = min.to_i unless min.empty?
|
89
|
+
result[:max_days] = max.to_i unless max.empty?
|
90
|
+
result[:warn_days] = warn.to_i unless warn.empty?
|
91
|
+
result[:disable_days] = inactive.to_i unless inactive.empty?
|
92
|
+
result[:disabled_date] = expire.to_i unless expire.empty?
|
93
|
+
|
94
|
+
result
|
95
|
+
else
|
96
|
+
{}
|
97
|
+
end
|
96
98
|
end
|
97
99
|
end
|
98
100
|
end
|
@@ -15,50 +15,51 @@
|
|
15
15
|
# To contact SUSE about this file by physical or electronic mail,
|
16
16
|
# you may find current contact information at www.suse.com
|
17
17
|
|
18
|
+
module Machinery
|
19
|
+
class User < Machinery::Object
|
20
|
+
IGNORED_ATTRIBUTES_IN_COMPARISON = [
|
21
|
+
"password",
|
22
|
+
"encrypted_password",
|
23
|
+
"last_changed_date",
|
24
|
+
"min_days",
|
25
|
+
"max_days",
|
26
|
+
"warn_days"
|
27
|
+
].freeze
|
18
28
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
"max_days",
|
26
|
-
"warn_days"
|
27
|
-
]
|
29
|
+
# User objects contain some information which is not relevant in the context of comparison (e.g.
|
30
|
+
# metadata like "last_changed_date"). In order to ignore these attributes during comparison we
|
31
|
+
# have to overwrite some methods.
|
32
|
+
def eql?(other)
|
33
|
+
relevant_attributes = (attributes.keys & other.attributes.keys) -
|
34
|
+
IGNORED_ATTRIBUTES_IN_COMPARISON
|
28
35
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
relevant_attributes = (attributes.keys & other.attributes.keys) -
|
34
|
-
IGNORED_ATTRIBUTES_IN_COMPARISON
|
36
|
+
relevant_attributes.all? do |attribute|
|
37
|
+
self[attribute] == other[attribute]
|
38
|
+
end
|
39
|
+
end
|
35
40
|
|
36
|
-
|
37
|
-
|
41
|
+
def hash
|
42
|
+
@attributes.reject { |k, _v| IGNORED_ATTRIBUTES_IN_COMPARISON.include?(k) }.hash
|
38
43
|
end
|
39
44
|
end
|
40
45
|
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
46
|
+
class UsersScope < Machinery::Array
|
47
|
+
include Machinery::Scope
|
45
48
|
|
46
|
-
class
|
47
|
-
include Machinery::Scope
|
49
|
+
has_elements class: User
|
48
50
|
|
49
|
-
|
51
|
+
def compare_with(other)
|
52
|
+
only_self = self - other
|
53
|
+
only_other = other - self
|
54
|
+
common = self & other
|
55
|
+
changed = Machinery::Scope.extract_changed_elements(only_self, only_other, :name)
|
50
56
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
only_self,
|
59
|
-
only_other,
|
60
|
-
changed,
|
61
|
-
common
|
62
|
-
].map { |e| (e && !e.empty?) ? e : nil }
|
57
|
+
[
|
58
|
+
only_self,
|
59
|
+
only_other,
|
60
|
+
changed,
|
61
|
+
common
|
62
|
+
].map { |e| e && !e.empty? ? e : nil }
|
63
|
+
end
|
63
64
|
end
|
64
65
|
end
|
@@ -15,41 +15,45 @@
|
|
15
15
|
# To contact SUSE about this file by physical or electronic mail,
|
16
16
|
# you may find current contact information at www.suse.com
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
module Machinery
|
19
|
+
class Ui
|
20
|
+
class UsersRenderer < Machinery::Ui::Renderer
|
21
|
+
def content(description)
|
22
|
+
return unless description.users
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
|
24
|
+
if description.users.any? { |a| a[:comment] == "" || a[:uid].nil? || a[:gid].nil? }
|
25
|
+
na_note("user info, user ID or group ID")
|
26
|
+
end
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
list do
|
29
|
+
description.users.each do |user|
|
30
|
+
info = user.comment.empty? ? "N/A" : user.comment
|
31
|
+
uid = user.uid || "N/A"
|
32
|
+
gid = user.gid || "N/A"
|
33
|
+
item "#{user.name} (#{info}, uid: #{uid}, gid: #{gid}, shell: #{user.shell})"
|
34
|
+
end
|
35
|
+
end
|
32
36
|
end
|
33
|
-
end
|
34
|
-
end
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
|
38
|
+
def display_name
|
39
|
+
"Users"
|
40
|
+
end
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
def compare_content_changed(changed_elements)
|
43
|
+
list do
|
44
|
+
changed_elements.each do |one, two|
|
45
|
+
changes = []
|
46
|
+
relevant_attributes = ["uid", "gid", "comment", "shell", "home"]
|
45
47
|
|
46
|
-
|
47
|
-
|
48
|
-
|
48
|
+
relevant_attributes.each do |attribute|
|
49
|
+
if one[attribute] != two[attribute]
|
50
|
+
changes << "#{attribute}: #{one[attribute]} <> #{two[attribute]}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
item "#{one.name} (#{changes.join(", ")})"
|
49
55
|
end
|
50
56
|
end
|
51
|
-
|
52
|
-
item "#{one.name} (#{changes.join(", ")})"
|
53
57
|
end
|
54
58
|
end
|
55
59
|
end
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# To contact SUSE about this file by physical or electronic mail,
|
16
16
|
# you may find current contact information at www.suse.com
|
17
17
|
|
18
|
-
class Migrate1To2 < Migration
|
18
|
+
class Machinery::Migrate1To2 < Machinery::Migration
|
19
19
|
desc <<-EOT
|
20
20
|
Schema version 2 introduces an "extracted" flag for the config_files,
|
21
21
|
changed_managed_files and unmanaged_files scope, indicating whether the
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# To contact SUSE about this file by physical or electronic mail,
|
16
16
|
# you may find current contact information at www.suse.com
|
17
17
|
|
18
|
-
class Migrate2To3 < Migration
|
18
|
+
class Machinery::Migrate2To3 < Machinery::Migration
|
19
19
|
desc <<-EOT
|
20
20
|
Schema version 3 stores the analyzed data under the directory
|
21
21
|
"analyze" and config files diffs in the config_file_diffs
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# To contact SUSE about this file by physical or electronic mail,
|
16
16
|
# you may find current contact information at www.suse.com
|
17
17
|
|
18
|
-
class Migrate3To4 < Migration
|
18
|
+
class Machinery::Migrate3To4 < Machinery::Migration
|
19
19
|
desc <<-EOT
|
20
20
|
Schema version 4 adds a "type" attribute to changed_managed_files and config_files
|
21
21
|
in order to support other file types like links.
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# To contact SUSE about this file by physical or electronic mail,
|
16
16
|
# you may find current contact information at www.suse.com
|
17
17
|
|
18
|
-
class Migrate4To5 < Migration
|
18
|
+
class Machinery::Migrate4To5 < Machinery::Migration
|
19
19
|
desc <<-EOT
|
20
20
|
Schema version 5 adds a "environment" scope which stores information about the inspected system.
|
21
21
|
EOT
|