module Inspec::Utils::PasswdParser
Public Instance Methods
parse_passwd(content)
click to toggle source
Parse /etc/passwd files.
@param [String] content the raw content of /etc/passwd @return [Array] Collection of passwd entries
# File lib/inspec/utils/parser.rb, line 10 def parse_passwd(content) content.to_s.split("\n").map do |line| next if line[0] == "#" parse_passwd_line(line) end.compact end
parse_passwd_line(line)
click to toggle source
Parse a line of /etc/passwd
@param [String] line a line of /etc/passwd @return [Hash] Map of entries in this line
# File lib/inspec/utils/parser.rb, line 22 def parse_passwd_line(line) x = line.split(":") { # rubocop:disable Layout/AlignHash "user" => x[0], "password" => x[1], "uid" => x[2], "gid" => x[3], "desc" => x[4], "home" => x[5], "shell" => x[6], } end