]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
fwhosts.cgi: Check country code before proceeding
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 25 Sep 2025 15:02:18 +0000 (17:02 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 25 Sep 2025 15:34:43 +0000 (17:34 +0200)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
15 files changed:
config/cfgroot/general-functions.pl
doc/language_issues.en
doc/language_issues.es
doc/language_issues.fr
doc/language_issues.it
doc/language_issues.nl
doc/language_issues.pl
doc/language_issues.ru
doc/language_issues.tr
doc/language_issues.tw
doc/language_issues.zh
doc/language_missings
html/cgi-bin/fwhosts.cgi
langs/de/cgi-bin/de.pl
langs/en/cgi-bin/en.pl

index 33b5605e2e4a24023cdb4fe2c621bdffad73bbfa..94d0e74406de2b0441b8c4333cbff4c78b61b227 100644 (file)
@@ -864,6 +864,14 @@ sub validportrange # used to check a port range
        }
 }
 
+# Checks for a valid country code
+sub validcc($) {
+       my $cc = shift;
+
+       # Must contain of exactly two uppercase characters, or must be A1, A2, or A3
+       return ($cc =~ m/^([A-Z]{2}|A[123])$/);
+}
+
 sub IpInSubnet {
        my $addr = shift;
        my $network = shift;
index 808556beba1fc71aac21ebeaa1b0e5a340a50a17..4376ec232947584739f3b108920b64758de13213 100644 (file)
@@ -942,6 +942,7 @@ WARNING: untranslated string: fwhost err srvexist = This service already exists
 WARNING: untranslated string: fwhost err sub32 = Please add a network, not a single host
 WARNING: untranslated string: fwhost hint = Note
 WARNING: untranslated string: fwhost icmptype = ICMP type:
+WARNING: untranslated string: fwhost invalid country code = Invalid Country Code
 WARNING: untranslated string: fwhost ip_mac = IP/MAC address
 WARNING: untranslated string: fwhost ipsec net = IPsec networks:
 WARNING: untranslated string: fwhost menu = Firewall Groups
index 6f005949a94184b96a941bef7aab39dd75fdf4fb..aa40df21fe6c23f2e3b02afebe9a96caeb4faf83 100644 (file)
@@ -1028,6 +1028,7 @@ WARNING: untranslated string: error message = unknown string
 WARNING: untranslated string: extrahd because it is outside the allowed mount path = unknown string
 WARNING: untranslated string: fwhost cust locationgrp = unknown string
 WARNING: untranslated string: fwhost err hostip = unknown string
+WARNING: untranslated string: fwhost invalid country code = Invalid Country Code
 WARNING: untranslated string: guardian block a host = unknown string
 WARNING: untranslated string: guardian block httpd brute-force = unknown string
 WARNING: untranslated string: guardian block ssh brute-force = unknown string
index 4439b300a2e477b53d1cc47bf2e818fc38ed560a..f4591ca7448b1aa05fad0c91ee31a94a5913db7c 100644 (file)
@@ -1014,6 +1014,7 @@ WARNING: untranslated string: extrahd because it is outside the allowed mount pa
 WARNING: untranslated string: fwdfw syn flood protection = Enable SYN Flood Protection (TCP only)
 WARNING: untranslated string: fwhost cust locationgrp = unknown string
 WARNING: untranslated string: fwhost err hostip = unknown string
+WARNING: untranslated string: fwhost invalid country code = Invalid Country Code
 WARNING: untranslated string: fwhost wg peers = WireGuard Peers
 WARNING: untranslated string: guardian block a host = unknown string
 WARNING: untranslated string: guardian block httpd brute-force = unknown string
index d2e2439c01f57ce81527d774a3e25b613c451a80..f40373b1c6472220df51426e6c217478b9443c6e 100644 (file)
@@ -1116,6 +1116,7 @@ WARNING: untranslated string: fwhost cust location = Location Groups
 WARNING: untranslated string: fwhost cust locationgroup = Location Groups
 WARNING: untranslated string: fwhost cust locationgrp = unknown string
 WARNING: untranslated string: fwhost err hostip = unknown string
+WARNING: untranslated string: fwhost invalid country code = Invalid Country Code
 WARNING: untranslated string: fwhost newlocationgrp = Location Groups
 WARNING: untranslated string: fwhost wg peers = WireGuard Peers
 WARNING: untranslated string: generate ptr = Generate PTR
index 0224acb3a3fd8fda67c7d9e405ae3075e0ba72ca..7339041954a25a31b2e58457f2b10ee6a92ff301 100644 (file)
@@ -1123,6 +1123,7 @@ WARNING: untranslated string: fwhost cust location = Location Groups
 WARNING: untranslated string: fwhost cust locationgroup = Location Groups
 WARNING: untranslated string: fwhost cust locationgrp = unknown string
 WARNING: untranslated string: fwhost err hostip = unknown string
+WARNING: untranslated string: fwhost invalid country code = Invalid Country Code
 WARNING: untranslated string: fwhost newlocationgrp = Location Groups
 WARNING: untranslated string: fwhost wg peers = WireGuard Peers
 WARNING: untranslated string: generate ptr = Generate PTR
index e598262e232bdd2093b495560f3c099497b188b1..ea17e70f0f58e7c95c19592a530e1227fabf452f 100644 (file)
@@ -1223,6 +1223,7 @@ WARNING: untranslated string: fwhost err srvexist = This service already exists
 WARNING: untranslated string: fwhost err sub32 = Please add a network, not a single host
 WARNING: untranslated string: fwhost hint = Note
 WARNING: untranslated string: fwhost icmptype = ICMP type:
+WARNING: untranslated string: fwhost invalid country code = Invalid Country Code
 WARNING: untranslated string: fwhost ip_mac = IP/MAC address
 WARNING: untranslated string: fwhost ipsec net = IPsec networks:
 WARNING: untranslated string: fwhost menu = Firewall Groups
index 9bd9f2a617d78ffe1dab566027ba20ef6c14ced3..9fc1cb383e9c3265765f591ea3961a2f1defc0d7 100644 (file)
@@ -1221,6 +1221,7 @@ WARNING: untranslated string: fwhost err srvexist = This service already exists
 WARNING: untranslated string: fwhost err sub32 = Please add a network, not a single host
 WARNING: untranslated string: fwhost hint = Note
 WARNING: untranslated string: fwhost icmptype = ICMP type:
+WARNING: untranslated string: fwhost invalid country code = Invalid Country Code
 WARNING: untranslated string: fwhost ip_mac = IP/MAC address
 WARNING: untranslated string: fwhost ipsec net = IPsec networks:
 WARNING: untranslated string: fwhost menu = Firewall Groups
index 6517beaa9e86acfae551f57a7940ba10f1257d52..c306058d52bf58d228ab2dc65b64ea6240009eab 100644 (file)
@@ -1063,6 +1063,7 @@ WARNING: untranslated string: fwdfw all subnets = All subnets
 WARNING: untranslated string: fwdfw syn flood protection = Enable SYN Flood Protection (TCP only)
 WARNING: untranslated string: fwhost cust locationgrp = unknown string
 WARNING: untranslated string: fwhost err hostip = unknown string
+WARNING: untranslated string: fwhost invalid country code = Invalid Country Code
 WARNING: untranslated string: fwhost wg peers = WireGuard Peers
 WARNING: untranslated string: generate ptr = Generate PTR
 WARNING: untranslated string: guardian block a host = unknown string
index ac4544bcaed30c23102cc2cbeeb4c9b33fdb9d00..384f8e376929ef6cac5e0a6597980ef36a4ae449 100644 (file)
@@ -1036,6 +1036,7 @@ WARNING: untranslated string: error message = unknown string
 WARNING: untranslated string: extrahd because it is outside the allowed mount path = unknown string
 WARNING: untranslated string: fwhost cust locationgrp = unknown string
 WARNING: untranslated string: fwhost err hostip = unknown string
+WARNING: untranslated string: fwhost invalid country code = Invalid Country Code
 WARNING: untranslated string: guaranteed bandwidth = Guaranteed bandwidth
 WARNING: untranslated string: guardian block a host = unknown string
 WARNING: untranslated string: guardian block httpd brute-force = unknown string
index ac4544bcaed30c23102cc2cbeeb4c9b33fdb9d00..384f8e376929ef6cac5e0a6597980ef36a4ae449 100644 (file)
@@ -1036,6 +1036,7 @@ WARNING: untranslated string: error message = unknown string
 WARNING: untranslated string: extrahd because it is outside the allowed mount path = unknown string
 WARNING: untranslated string: fwhost cust locationgrp = unknown string
 WARNING: untranslated string: fwhost err hostip = unknown string
+WARNING: untranslated string: fwhost invalid country code = Invalid Country Code
 WARNING: untranslated string: guaranteed bandwidth = Guaranteed bandwidth
 WARNING: untranslated string: guardian block a host = unknown string
 WARNING: untranslated string: guardian block httpd brute-force = unknown string
index d0cf1318ea5688317b238c005b48be249b2c1752..9838c50168fb99e3160ae991a3a4e003dffddf06 100644 (file)
 < AES-256-GCM
 < CHACHA20-POLY1305
 < dns servers
+< fwhost invalid country code
 < ids all including informational
 < ids email alerts
 < ids email alert severity
 < endpoint port
 < extrahd because it it outside the allowed mount path
 < fwdfw syn flood protection
+< fwhost invalid country code
 < fwhost wg peers
 < g.dtm
 < g.lite
 < fwhost cust location
 < fwhost cust locationgroup
 < fwhost cust locationlocation
+< fwhost invalid country code
 < fwhost newlocationgrp
 < fwhost wg peers
 < fw red
 < fwhost cust location
 < fwhost cust locationgroup
 < fwhost cust locationlocation
+< fwhost invalid country code
 < fwhost newlocationgrp
 < fwhost wg peers
 < fw red
 < fwhost hint
 < fwhost hosts
 < fwhost icmptype
+< fwhost invalid country code
 < fwhost ipadr
 < fwhost ip_mac
 < fwhost ipsec host
 < fwhost hint
 < fwhost hosts
 < fwhost icmptype
+< fwhost invalid country code
 < fwhost ipadr
 < fwhost ip_mac
 < fwhost ipsec host
 < foreshadow
 < fwdfw all subnets
 < fwdfw syn flood protection
+< fwhost invalid country code
 < fwhost wg peers
 < fw red
 < generate ptr
 < Captive wrong type
 < CHACHA20-POLY1305
 < dns servers
+< fwhost invalid country code
 < guaranteed bandwidth
 < ids all including informational
 < ids email alerts
 < Captive wrong type
 < CHACHA20-POLY1305
 < dns servers
+< fwhost invalid country code
 < guaranteed bandwidth
 < ids all including informational
 < ids email alerts
index a666969b0c949779b77b5b9fcf2b8d31498cf0ec..dd0200a8ed3ba7736bda23611c3625b7c54d600f 100644 (file)
@@ -703,6 +703,10 @@ if ($fwhostsettings{'ACTION'} eq 'savelocationgrp')
        # Check name
        if (!&validhostname($grp)){$errormessage.=$Lang::tr{'fwhost err name'};}
 
+       unless (&General::validcc($fwhostsettings{'COUNTRY_CODE'})) {
+               $errormessage = $Lang::tr{'fwhost invalid country code'};
+       }
+
        # Check for existing group name.
        if (!&checkgroup($grp) && $fwhostsettings{'update'} ne 'on'){
                $errormessage = $Lang::tr{'fwhost err grpexist'};
@@ -714,7 +718,7 @@ if ($fwhostsettings{'ACTION'} eq 'savelocationgrp')
        }
 
        if ($fwhostsettings{'update'} eq 'on'){
-               @target=&Header::escape($fwhostsettings{'COUNTRY_CODE'});
+               @target = $fwhostsettings{'COUNTRY_CODE'};
                $type='Location Group';
 
                #check if host/net exists in grp
index 8ef466cbcda64f00782befaa2eee5abeb504508e..efa0eaf6935dc3cd2834386dc5c5e822599de939 100644 (file)
 'fwhost hint' => 'Hinweis',
 'fwhost hosts' => 'Firewall-Hosts',
 'fwhost icmptype' => 'ICMP-Typ:',
+'fwhost invalid country code' => 'Ungültiger Ländercode',
 'fwhost ip_mac' => 'IP/MAC-Adresse',
 'fwhost ipadr' => 'IP-Adresse:',
 'fwhost ipsec host' => 'IPsec-Clients:',
index 7c8b24f6ad30635693e9e21fef453240c9a6a3bc..3aab75efd92de60f39f5abcbba26ca3120e58bcb 100644 (file)
 'fwhost hint' => 'Note',
 'fwhost hosts' => 'Firewall Hosts',
 'fwhost icmptype' => 'ICMP type:',
+'fwhost invalid country code' => 'Invalid Country Code',
 'fwhost ip_mac' => 'IP/MAC address',
 'fwhost ipadr' => 'IP address:',
 'fwhost ipsec host' => 'IPsec clients:',