2022-08-15 07:15:42 -06:00
|
|
|
require 'json'
|
2022-08-15 07:59:41 -06:00
|
|
|
require 'yaml'
|
2022-08-15 08:04:15 -06:00
|
|
|
require "uri"
|
2022-08-15 07:59:41 -06:00
|
|
|
|
|
|
|
def get_os install
|
|
|
|
lst = []
|
|
|
|
if install['Linux'].length > 1
|
|
|
|
lst.push 'linux'
|
|
|
|
end
|
|
|
|
if install['MacOS'].length > 1
|
|
|
|
lst.push 'macos'
|
|
|
|
end
|
|
|
|
if install['Windows'].length > 1
|
|
|
|
lst.push 'windows'
|
|
|
|
end
|
|
|
|
return lst
|
|
|
|
end
|
2022-08-15 07:15:42 -06:00
|
|
|
|
2022-08-15 08:04:15 -06:00
|
|
|
def get_urls str
|
|
|
|
return URI.extract(str).uniq
|
|
|
|
end
|
|
|
|
|
2022-08-15 08:19:18 -06:00
|
|
|
def migrate jsonfile, category
|
2022-08-15 08:18:05 -06:00
|
|
|
file = File.read(jsonfile)
|
|
|
|
data_hash = JSON.parse(file)
|
2022-08-15 07:15:42 -06:00
|
|
|
|
2022-08-15 08:18:05 -06:00
|
|
|
data_hash.each do | name, obj |
|
|
|
|
filename = name.gsub(' ','_')+".yaml"
|
|
|
|
# Make object
|
|
|
|
new_obj = {}
|
|
|
|
new_obj['name'] = name
|
|
|
|
new_obj['description'] = obj['Description']
|
|
|
|
new_obj['urls'] = get_urls obj['Data']
|
2022-08-15 08:19:18 -06:00
|
|
|
new_obj['category'] = category
|
2022-08-15 08:18:05 -06:00
|
|
|
new_obj['types'] = []
|
|
|
|
if obj['Install'] != nil
|
|
|
|
new_obj['os'] = get_os(obj['Install'])
|
|
|
|
end
|
|
|
|
new_obj['lang'] = [] # parse DATA
|
|
|
|
new_obj['tags'] = []
|
|
|
|
|
|
|
|
# Convert to YAML
|
|
|
|
yaml_data = YAML.dump(new_obj)
|
2022-08-15 07:59:41 -06:00
|
|
|
|
2022-08-15 08:18:05 -06:00
|
|
|
# Save yaml file
|
|
|
|
puts filename
|
|
|
|
#File.write("./data/#{filename}", yaml_data)
|
|
|
|
end
|
|
|
|
end
|
2022-08-15 07:59:41 -06:00
|
|
|
|
2022-08-15 08:19:18 -06:00
|
|
|
migrate './data.json', 'tool'
|
|
|
|
migrate './Bookmarklets/data.json', 'bookmarklet'
|
|
|
|
migrate './Browser Extensions/data.json', 'browser-addon'
|
|
|
|
migrate './Burp and ZAP Extensions/data.json', 'tool-addon'
|