From 1324db77401e1df2d4af19b52b95315ca096a0b5 Mon Sep 17 00:00:00 2001 From: "pavlis@sinep.local" Date: Mon, 14 Oct 2024 22:16:14 +0200 Subject: [PATCH 1/2] add: SK support --- parser_test.go | 8 ++-- prepare.go | 46 ++++++++++++++++++++ rule.go | 5 +++ testdata/noterror/README.md | 2 + testdata/noterror/sk_alza.sk | 56 ++++++++++++++++++++++++ testdata/noterror/sk_alza.sk.json | 58 +++++++++++++++++++++++++ testdata/noterror/sk_alza.sk.pre | 52 +++++++++++++++++++++++ testdata/noterror/sk_google.sk | 62 +++++++++++++++++++++++++++ testdata/noterror/sk_google.sk.json | 66 +++++++++++++++++++++++++++++ testdata/noterror/sk_google.sk.pre | 58 +++++++++++++++++++++++++ 10 files changed, 409 insertions(+), 4 deletions(-) create mode 100644 testdata/noterror/sk_alza.sk create mode 100644 testdata/noterror/sk_alza.sk.json create mode 100644 testdata/noterror/sk_alza.sk.pre create mode 100644 testdata/noterror/sk_google.sk create mode 100644 testdata/noterror/sk_google.sk.json create mode 100644 testdata/noterror/sk_google.sk.pre diff --git a/parser_test.go b/parser_test.go index 570186bc..cf643bef 100644 --- a/parser_test.go +++ b/parser_test.go @@ -112,7 +112,7 @@ func TestParse(t *testing.T) { if !assert.IsContains([]string{"", "at", "aq", "br", "ch", "de", "edu", "eu", "fr", "gov", "hk", "hm", "int", "it", "jp", "kr", "kz", "mo", "nl", "nz", "pl", "pm", "re", "ro", "ru", "su", "tf", "ee", "tk", "travel", "tv", "tw", "uk", "wf", "yt", "ir", "fi", "rs", "dk", "by", "ua", - "xn--mgba3a4f16a", "xn--p1ai", "se", "nu", "hu"}, extension) { + "xn--mgba3a4f16a", "xn--p1ai", "se", "sk", "nu", "hu"}, extension) { assert.NotZero(t, whoisInfo.Domain.ID) } @@ -130,7 +130,7 @@ func TestParse(t *testing.T) { if !assert.IsContains([]string{"aero", "ai", "at", "aq", "asia", "berlin", "biz", "br", "ch", "cn", "co", "cymru", "de", "edu", "eu", "fr", "gov", "hk", "hm", "in", "int", "it", "jp", "kr", - "la", "london", "me", "mo", "museum", "name", "nl", "nz", "pm", "re", "ro", "ru", "sh", + "la", "london", "me", "mo", "museum", "name", "nl", "nz", "pm", "re", "ro", "ru", "sh", "sk", "kz", "su", "tel", "ee", "tf", "tk", "travel", "tw", "uk", "us", "wales", "wf", "xxx", "yt", "ir", "fi", "rs", "dk", "by", "ua", "xn--mgba3a4f16a", "xn--fiqs8s", "xn--p1ai", "se", "nu", "hu"}, extension) { @@ -169,7 +169,7 @@ func TestParse(t *testing.T) { if !assert.IsContains([]string{"", "ai", "at", "aq", "au", "br", "ca", "ch", "cn", "cx", "de", "edu", "eu", "fr", "gov", "gs", "hk", "hm", "int", "it", "jp", "kr", "kz", "la", "mo", "nl", - "nz", "pl", "pm", "re", "ro", "ru", "su", "tf", "tk", "tw", "uk", "wf", "yt", "ir", "fi", "rs", + "nz", "pl", "pm", "re", "ro", "ru", "su", "sk", "tf", "tk", "tw", "uk", "wf", "yt", "ir", "fi", "rs", "ee", "dk", "by", "ua", "xn--mgba3a4f16a", "xn--fiqs8s", "xn--p1ai", "se", "nu", "hu"}, extension) { assert.NotZero(t, whoisInfo.Registrar.ID) } @@ -181,7 +181,7 @@ func TestParse(t *testing.T) { if !assert.IsContains([]string{"", "aero", "ai", "at", "aq", "asia", "au", "br", "ch", "cn", "de", "edu", "gov", "hk", "hm", "int", "jp", "kr", "kz", "la", "london", "love", "mo", - "museum", "name", "nl", "nz", "pl", "ru", "su", "tk", "top", "ir", "fi", "rs", "dk", "by", "ua", + "museum", "name", "nl", "nz", "pl", "ru", "sk", "su", "tk", "top", "ir", "fi", "rs", "dk", "by", "ua", "xn--mgba3a4f16a", "xn--fiqs8s", "xn--p1ai", "se", "nu", "hu"}, extension) { assert.NotZero(t, whoisInfo.Registrar.ReferralURL) } diff --git a/prepare.go b/prepare.go index d7eb25a8..e52090b8 100644 --- a/prepare.go +++ b/prepare.go @@ -93,6 +93,8 @@ func Prepare(text, ext string) (string, bool) { //nolint:cyclop return prepareUA(text), true case "at": return prepareAT(text), true + case "sk": + return prepareSK(text), true default: return text, false } @@ -1436,3 +1438,47 @@ func prepareAT(text string) string { return result } + +// prepareSK do prepare the .sk domain +func prepareSK(text string) string { + + tokens := map[string]string{ + "Domain registrant": "Registrant", + "Authorised Registrar": "Registrar", + "Administrative Contact": "Administrative", + "Technical Contact": "Technical", + } + + token := "" + result := "" + prefix := "" + + for _, v := range strings.Split(text, "\n") { + + v = strings.TrimSpace(v) + v = strings.Replace(v, "\r", "", -1) + + if v == "" { + token = "" + continue + } + + if strings.Contains(v,":"){ + vs := strings.SplitN(v, ":", 2) + value := strings.TrimSpace(vs[1]) + token = strings.TrimSpace(vs[0]) + + if _, ok := tokens[token]; ok { + prefix = tokens[token] + prefix = fmt.Sprintf("%s ", prefix) + } + + v = fmt.Sprintf("%s%s:%s", prefix, token, value) + + } + result += "\n" + v + } + + return result +} + diff --git a/rule.go b/rule.go index 3d2d3de6..257b0279 100644 --- a/rule.go +++ b/rule.go @@ -73,6 +73,7 @@ var ( "domain registered": "created_date", "modified": "updated_date", "changed": "updated_date", + "updated": "updated_date", "update date": "updated_date", "updated date": "updated_date", "updated on": "updated_date", @@ -98,6 +99,7 @@ var ( "expiry date": "expired_date", "expiration time": "expired_date", "renewal date": "expired_date", + "valid until": "expired_date", "domain expire": "expired_date", "domain expires": "expired_date", "record expires on": "expired_date", @@ -117,6 +119,7 @@ var ( "registrant nic hdl": "registrant_id", "registrant nic handle": "registrant_id", "registrant org id": "registrant_id", + "registrant domain registrant": "registrant_id", "registrant name": "registrant_name", "registrant person": "registrant_name", "registrant contact": "registrant_name", @@ -157,6 +160,7 @@ var ( "registrant contact postalcode": "registrant_postal_code", "registrant contact postal code": "registrant_postal_code", "registrant country": "registrant_country", + "registrant country code": "registrant_country", "registrant country economy": "registrant_country", "registrant contact country": "registrant_country", "registrant phone": "registrant_phone", @@ -185,5 +189,6 @@ var ( "registrant contact email": "registrant_email", "registrant contact e mail": "registrant_email", "registrant abuse contact email": "registrant_email", + "registrar authorised registrar": "registrar_id", } ) diff --git a/testdata/noterror/README.md b/testdata/noterror/README.md index 2f9d3ead..67a38e3c 100644 --- a/testdata/noterror/README.md +++ b/testdata/noterror/README.md @@ -173,6 +173,8 @@ If there is any problem, please feel free to open a new issue. | .sexy | [line.sexy](sexy_line.sexy) | [line.sexy](sexy_line.sexy.json) | √ | | .sh | [git.sh](sh_git.sh) | [git.sh](sh_git.sh.json) | √ | | .sh | [google.sh](sh_google.sh) | [google.sh](sh_google.sh.json) | √ | +| .sk | [alza.sk](sk_alza.sk) | [alza.sk](sk_alza.sk.json) | √ | +| .sk | [google.sk](sk_google.sk) | [google.sk](sk_google.sk.json) | √ | | .su | [git.su](su_git.su) | [git.su](su_git.su.json) | √ | | .su | [google.su](su_google.su) | [google.su](su_google.su.json) | √ | | .tel | [github.tel](tel_github.tel) | [github.tel](tel_github.tel.json) | √ | diff --git a/testdata/noterror/sk_alza.sk b/testdata/noterror/sk_alza.sk new file mode 100644 index 00000000..31dc5466 --- /dev/null +++ b/testdata/noterror/sk_alza.sk @@ -0,0 +1,56 @@ +Domain: alza.sk +Created: 2004-05-21 +Valid Until: 2025-04-24 +Updated: 2024-03-21 +Domain Status: ok +Nameserver: beau.ns.cloudflare.com +Nameserver: gigi.ns.cloudflare.com + +Domain registrant: A24C-154952 +Name: Alza.cz a.s. +Organization: Alza.cz a.s. +Organization ID: 27082440 +Street: Jankovcova 1522/53 +City: Praha 7 +Postal Code: 17000 +Country Code: CZ +Authorised Registrar: ACTI-0024 +Created: 2021-06-28 +Updated: 2023-09-15 + +Registrar: ACTI-0024 +Name: ACTIVE 24, s.r.o. +Organization: ACTIVE 24, s.r.o. +Organization ID: 25115804 +Phone: +421.244460639 +Email: registrace@domeny.cz +Street: Sokolovska 394/17 +City: Praha +Postal Code: 18600 +Country Code: CZ +Created: 2017-09-14 +Updated: 2024-10-10 + +Administrative Contact: A24C-154952 +Name: Alza.cz a.s. +Organization: Alza.cz a.s. +Organization ID: 27082440 +Street: Jankovcova 1522/53 +City: Praha 7 +Postal Code: 17000 +Country Code: CZ +Created: 2021-06-28 +Updated: 2023-09-15 + +Technical Contact: ACTI-0024 +Name: ACTIVE 24, s.r.o. +Organization: ACTIVE 24, s.r.o. +Organization ID: 25115804 +Phone: +421.244460639 +Email: registrace@domeny.cz +Street: Sokolovska 394/17 +City: Praha +Postal Code: 18600 +Country Code: CZ +Created: 2017-09-14 +Updated: 2024-10-10 diff --git a/testdata/noterror/sk_alza.sk.json b/testdata/noterror/sk_alza.sk.json new file mode 100644 index 00000000..5a59bdfa --- /dev/null +++ b/testdata/noterror/sk_alza.sk.json @@ -0,0 +1,58 @@ +{ + "domain": { + "domain": "alza.sk", + "punycode": "alza.sk", + "name": "alza", + "extension": "sk", + "status": [ + "ok" + ], + "name_servers": [ + "beau.ns.cloudflare.com", + "gigi.ns.cloudflare.com" + ], + "created_date": "2004-05-21", + "created_date_in_time": "2004-05-21T00:00:00Z", + "updated_date": "2024-03-21", + "updated_date_in_time": "2024-03-21T00:00:00Z", + "expiration_date": "2025-04-24", + "expiration_date_in_time": "2025-04-24T00:00:00Z" + }, + "registrar": { + "name": "ACTIVE 24, s.r.o.", + "organization": "ACTIVE 24, s.r.o.", + "street": "Sokolovska 394/17", + "city": "Praha", + "postal_code": "18600", + "country": "CZ", + "phone": "+421.244460639", + "email": "registrace@domeny.cz" + }, + "registrant": { + "id": "A24C-154952", + "name": "Alza.cz a.s.", + "organization": "Alza.cz a.s.", + "street": "Jankovcova 1522/53", + "city": "Praha 7", + "postal_code": "17000", + "country": "CZ" + }, + "administrative": { + "name": "Alza.cz a.s.", + "organization": "Alza.cz a.s.", + "street": "Jankovcova 1522/53", + "city": "Praha 7", + "postal_code": "17000", + "country": "CZ" + }, + "technical": { + "name": "ACTIVE 24, s.r.o.", + "organization": "ACTIVE 24, s.r.o.", + "street": "Sokolovska 394/17", + "city": "Praha", + "postal_code": "18600", + "country": "CZ", + "phone": "+421.244460639", + "email": "registrace@domeny.cz" + } +} \ No newline at end of file diff --git a/testdata/noterror/sk_alza.sk.pre b/testdata/noterror/sk_alza.sk.pre new file mode 100644 index 00000000..7faf7c7b --- /dev/null +++ b/testdata/noterror/sk_alza.sk.pre @@ -0,0 +1,52 @@ +Domain:alza.sk +Created:2004-05-21 +Valid Until:2025-04-24 +Updated:2024-03-21 +Domain Status:ok +Nameserver:beau.ns.cloudflare.com +Nameserver:gigi.ns.cloudflare.com +Registrant Domain registrant:A24C-154952 +Registrant Name:Alza.cz a.s. +Registrant Organization:Alza.cz a.s. +Registrant Organization ID:27082440 +Registrant Street:Jankovcova 1522/53 +Registrant City:Praha 7 +Registrant Postal Code:17000 +Registrant Country Code:CZ +Registrar Authorised Registrar:ACTI-0024 +Registrar Created:2021-06-28 +Registrar Updated:2023-09-15 +Registrar Registrar:ACTI-0024 +Registrar Name:ACTIVE 24, s.r.o. +Registrar Organization:ACTIVE 24, s.r.o. +Registrar Organization ID:25115804 +Registrar Phone:+421.244460639 +Registrar Email:registrace@domeny.cz +Registrar Street:Sokolovska 394/17 +Registrar City:Praha +Registrar Postal Code:18600 +Registrar Country Code:CZ +Registrar Created:2017-09-14 +Registrar Updated:2024-10-10 +Administrative Administrative Contact:A24C-154952 +Administrative Name:Alza.cz a.s. +Administrative Organization:Alza.cz a.s. +Administrative Organization ID:27082440 +Administrative Street:Jankovcova 1522/53 +Administrative City:Praha 7 +Administrative Postal Code:17000 +Administrative Country Code:CZ +Administrative Created:2021-06-28 +Administrative Updated:2023-09-15 +Technical Technical Contact:ACTI-0024 +Technical Name:ACTIVE 24, s.r.o. +Technical Organization:ACTIVE 24, s.r.o. +Technical Organization ID:25115804 +Technical Phone:+421.244460639 +Technical Email:registrace@domeny.cz +Technical Street:Sokolovska 394/17 +Technical City:Praha +Technical Postal Code:18600 +Technical Country Code:CZ +Technical Created:2017-09-14 +Technical Updated:2024-10-10 \ No newline at end of file diff --git a/testdata/noterror/sk_google.sk b/testdata/noterror/sk_google.sk new file mode 100644 index 00000000..300924bd --- /dev/null +++ b/testdata/noterror/sk_google.sk @@ -0,0 +1,62 @@ +Domain: google.sk +Created: 2003-07-24 +Valid Until: 2025-07-24 +Updated: 2024-06-22 +Domain Status: clientTransferProhibited, clientUpdateProhibited, clientDeleteProhibited +Nameserver: ns1.google.com +Nameserver: ns2.google.com +Nameserver: ns3.google.com +Nameserver: ns4.google.com + +Domain registrant: mmr-170347 +Name: Domain Administrator +Organization: Google Ireland Holdings Unlimited Company +Organization ID: 369511 +Phone: +353.14361000 +Email: dns-admin@google.com +Street: 70 Sir John Rogerson's Quay +City: Dublin +Postal Code: 2 +Country Code: IE +Authorised Registrar: MARK-0292 +Created: 2019-06-07 +Updated: 2019-06-07 + +Registrar: MARK-0292 +Name: MarkMonitor International Limited +Organization: MarkMonitor International Limited +Organization ID: 4847541 +Phone: +1.2083895740 +Email: registry.admin@markmonitor.com +Street: 12 New Fetter Lane +City: London +Postal Code: EC4A 1JP +Country Code: UK +Created: 2018-06-27 +Updated: 2024-09-30 + +Administrative Contact: mmr-170347 +Name: Domain Administrator +Organization: Google Ireland Holdings Unlimited Company +Organization ID: 369511 +Phone: +353.14361000 +Email: dns-admin@google.com +Street: 70 Sir John Rogerson's Quay +City: Dublin +Postal Code: 2 +Country Code: IE +Created: 2019-06-07 +Updated: 2019-06-07 + +Technical Contact: mmr-170347 +Name: Domain Administrator +Organization: Google Ireland Holdings Unlimited Company +Organization ID: 369511 +Phone: +353.14361000 +Email: dns-admin@google.com +Street: 70 Sir John Rogerson's Quay +City: Dublin +Postal Code: 2 +Country Code: IE +Created: 2019-06-07 +Updated: 2019-06-07 diff --git a/testdata/noterror/sk_google.sk.json b/testdata/noterror/sk_google.sk.json new file mode 100644 index 00000000..42cc5ae7 --- /dev/null +++ b/testdata/noterror/sk_google.sk.json @@ -0,0 +1,66 @@ +{ + "domain": { + "domain": "google.sk", + "punycode": "google.sk", + "name": "google", + "extension": "sk", + "status": [ + "clientTransferProhibited", + "clientUpdateProhibited", + "clientDeleteProhibited" + ], + "name_servers": [ + "ns1.google.com", + "ns2.google.com", + "ns3.google.com", + "ns4.google.com" + ], + "created_date": "2003-07-24", + "created_date_in_time": "2003-07-24T00:00:00Z", + "updated_date": "2024-06-22", + "updated_date_in_time": "2024-06-22T00:00:00Z", + "expiration_date": "2025-07-24", + "expiration_date_in_time": "2025-07-24T00:00:00Z" + }, + "registrar": { + "name": "MarkMonitor International Limited", + "organization": "MarkMonitor International Limited", + "street": "12 New Fetter Lane", + "city": "London", + "postal_code": "EC4A 1JP", + "country": "UK", + "phone": "+1.2083895740", + "email": "registry.admin@markmonitor.com" + }, + "registrant": { + "id": "mmr-170347", + "name": "Domain Administrator", + "organization": "Google Ireland Holdings Unlimited Company", + "street": "70 Sir John Rogerson's Quay", + "city": "Dublin", + "postal_code": "2", + "country": "IE", + "phone": "+353.14361000", + "email": "dns-admin@google.com" + }, + "administrative": { + "name": "Domain Administrator", + "organization": "Google Ireland Holdings Unlimited Company", + "street": "70 Sir John Rogerson's Quay", + "city": "Dublin", + "postal_code": "2", + "country": "IE", + "phone": "+353.14361000", + "email": "dns-admin@google.com" + }, + "technical": { + "name": "Domain Administrator", + "organization": "Google Ireland Holdings Unlimited Company", + "street": "70 Sir John Rogerson's Quay", + "city": "Dublin", + "postal_code": "2", + "country": "IE", + "phone": "+353.14361000", + "email": "dns-admin@google.com" + } +} \ No newline at end of file diff --git a/testdata/noterror/sk_google.sk.pre b/testdata/noterror/sk_google.sk.pre new file mode 100644 index 00000000..50bd8e25 --- /dev/null +++ b/testdata/noterror/sk_google.sk.pre @@ -0,0 +1,58 @@ +Domain:google.sk +Created:2003-07-24 +Valid Until:2025-07-24 +Updated:2024-06-22 +Domain Status:clientTransferProhibited, clientUpdateProhibited, clientDeleteProhibited +Nameserver:ns1.google.com +Nameserver:ns2.google.com +Nameserver:ns3.google.com +Nameserver:ns4.google.com +Registrant Domain registrant:mmr-170347 +Registrant Name:Domain Administrator +Registrant Organization:Google Ireland Holdings Unlimited Company +Registrant Organization ID:369511 +Registrant Phone:+353.14361000 +Registrant Email:dns-admin@google.com +Registrant Street:70 Sir John Rogerson's Quay +Registrant City:Dublin +Registrant Postal Code:2 +Registrant Country Code:IE +Registrar Authorised Registrar:MARK-0292 +Registrar Created:2019-06-07 +Registrar Updated:2019-06-07 +Registrar Registrar:MARK-0292 +Registrar Name:MarkMonitor International Limited +Registrar Organization:MarkMonitor International Limited +Registrar Organization ID:4847541 +Registrar Phone:+1.2083895740 +Registrar Email:registry.admin@markmonitor.com +Registrar Street:12 New Fetter Lane +Registrar City:London +Registrar Postal Code:EC4A 1JP +Registrar Country Code:UK +Registrar Created:2018-06-27 +Registrar Updated:2024-09-30 +Administrative Administrative Contact:mmr-170347 +Administrative Name:Domain Administrator +Administrative Organization:Google Ireland Holdings Unlimited Company +Administrative Organization ID:369511 +Administrative Phone:+353.14361000 +Administrative Email:dns-admin@google.com +Administrative Street:70 Sir John Rogerson's Quay +Administrative City:Dublin +Administrative Postal Code:2 +Administrative Country Code:IE +Administrative Created:2019-06-07 +Administrative Updated:2019-06-07 +Technical Technical Contact:mmr-170347 +Technical Name:Domain Administrator +Technical Organization:Google Ireland Holdings Unlimited Company +Technical Organization ID:369511 +Technical Phone:+353.14361000 +Technical Email:dns-admin@google.com +Technical Street:70 Sir John Rogerson's Quay +Technical City:Dublin +Technical Postal Code:2 +Technical Country Code:IE +Technical Created:2019-06-07 +Technical Updated:2019-06-07 \ No newline at end of file From b900b84a962926f88fa70687333c09199f508b20 Mon Sep 17 00:00:00 2001 From: "pavlis@sinep.local" Date: Thu, 17 Oct 2024 11:09:43 +0200 Subject: [PATCH 2/2] fix: formatting and lint errors --- prepare.go | 11 ++++------- rule.go | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/prepare.go b/prepare.go index e52090b8..791547ff 100644 --- a/prepare.go +++ b/prepare.go @@ -1443,13 +1443,12 @@ func prepareAT(text string) string { func prepareSK(text string) string { tokens := map[string]string{ - "Domain registrant": "Registrant", - "Authorised Registrar": "Registrar", + "Domain registrant": "Registrant", + "Authorised Registrar": "Registrar", "Administrative Contact": "Administrative", "Technical Contact": "Technical", } - token := "" result := "" prefix := "" @@ -1459,14 +1458,13 @@ func prepareSK(text string) string { v = strings.Replace(v, "\r", "", -1) if v == "" { - token = "" continue } - if strings.Contains(v,":"){ + if strings.Contains(v, ":") { vs := strings.SplitN(v, ":", 2) value := strings.TrimSpace(vs[1]) - token = strings.TrimSpace(vs[0]) + token := strings.TrimSpace(vs[0]) if _, ok := tokens[token]; ok { prefix = tokens[token] @@ -1481,4 +1479,3 @@ func prepareSK(text string) string { return result } - diff --git a/rule.go b/rule.go index 257b0279..9194aca2 100644 --- a/rule.go +++ b/rule.go @@ -73,7 +73,7 @@ var ( "domain registered": "created_date", "modified": "updated_date", "changed": "updated_date", - "updated": "updated_date", + "updated": "updated_date", "update date": "updated_date", "updated date": "updated_date", "updated on": "updated_date", @@ -119,7 +119,7 @@ var ( "registrant nic hdl": "registrant_id", "registrant nic handle": "registrant_id", "registrant org id": "registrant_id", - "registrant domain registrant": "registrant_id", + "registrant domain registrant": "registrant_id", "registrant name": "registrant_name", "registrant person": "registrant_name", "registrant contact": "registrant_name",