Archive for the ‘xml’ tag
Exportar passwords de revelation a texto plano con ruby
Revelation tiene la opción de exportar el fichero de contraseñas a texto plano. El problema es que la organización de las entradas no es demasiado buena, porque las pone en una sola columna sin indentación, por lo que resulta dificil ver el anidación de las contraseñas en caso de que se usen carpetas.
Necesitaba tener las contraseñas en texto plano de forma que pudiese ver a simple vista esta información y fuese más facil de mantener. Esto se puede hacer fácilmente con ruby y xml-simple:
require 'rubygems'
require 'xmlsimple'
PASSWORD_FILE="./passwords.xml"
config = XmlSimple.xml_in(PASSWORD_FILE)
ce = config
indent = ""
INDENT_SPACES = " "
def stepin(ce, indent)
if !ce.nil?
indent = indent + INDENT_SPACES
end
ce['entry'].each { |item|
puts indent + item['name'].to_s
if !item['entry'].nil?
stepin(item, indent)
elsif item['entry'].nil? && item['type'] != 'folder'
if item['description'] && !item['description'].to_s.empty?
puts indent + INDENT_SPACES + "description: " + item['description'].to_s
end
item['field'].each { |field_type|
if !field_type['content'].nil?
puts indent +
INDENT_SPACES +
field_type.values[0].gsub("generic-", "") +
": " +
field_type.values[1]
end
}
end
}
end
stepin(ce, indent)
Para que esto funcione basta tener instalado rubygems y xml-simple.