Created
October 8, 2021 15:32
-
-
Save mikz/7b793e5b2b6bf4c95f67707e8fc9cd30 to your computer and use it in GitHub Desktop.
Revisions
-
mikz created this gist
Oct 8, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ #!/usr/bin/env ruby require 'csv' require 'open-uri' require 'json' uri = URI.open('https://www.coi.cz/userdata/files/dokumenty-ke-stazeni/open-data/rizikove.csv') domains = CSV.read(uri).to_a.flatten $globalid = 0 def generate_id $globalid += 1 "B8C7FA8A-66E8-400F-AB2B-C36E64DD%05d" % $globalid end def make_rule(domain) { id: generate_id, name: domain, content: {trigger: {"url-filter"=>"https?://+([^:/]+\\.)?#{domain}[:/]", "url-filter-is-case-sensitive"=>false}, action: {type: 'block'}}} end puts JSON.pretty_generate([{ rules: domains.flat_map(&method(:make_rule)), id: "BFA55950-8BEF-4391-B263-3C67BDFC0362", name: "Rizikové weby podle ČOI", createdAt: 655398187.740042 } ])