]> 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, 2 Oct 2025 16:55:36 +0000 (16:55 +0000)
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 6dfada328b6f1fed823a2163a7ce7096a2564724..fe7a17f1f02ed2e731bfd27596042fe55f2479a7 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 cadfaf5d66eb936036f8581b27502dfdc0c50f17..f0a6e31ba40c7efe55e60da9c605d6a83b39da16 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 a03241bcea06cce4b9df14d32c7ca4f0d3087966..ce55b88ba136959f4d1fadf68d34190fb231f1c2 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 d5fdcd55e07bd81c6a446b31cea6709c7e775405..ee5135003d0446b16bb7b4e9bbbdcf373a003130 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 72af4fba506efce623806b6ae7f6fa7f7650e8c0..4150411917a2afb59fb3dff0ca4f6b90c2a42144 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 c89dd9966a453b95598e2489504072ca370cc306..c951b39ce7cfe08c5d702df6316bb2e3128aef43 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 2377115ab3ac4d9b20c5c389e8f36ca887e2d4c0..738de8fee2ea7c0526395b39be7ed923aa447d18 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 dfabd029eba71b6e3fa90eee70b3dc0cd5ad0a27..cb13bc21f4643046f8160e28017cadbcac7b8bdd 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 2745a25baf1e829308aac4bde49c8ac6b7a9109b..5a9f61b2cc8d95f2228f4f9f4df282ba52219399 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 2745a25baf1e829308aac4bde49c8ac6b7a9109b..5a9f61b2cc8d95f2228f4f9f4df282ba52219399 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 03c286f5a24bb9fd1982bf60ad860ec838ef66f0..b042081ebac8db96e8434d58e87b48f03a366dba 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 b997ff9a7353f1cea2772d80e7a96c2237dc7d04..09a63b5352cfd5a862574244fd66dc01bd0132b8 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 35e9da184c0d60e6127776936774fa464e8ace63..02a0886004000b7bd63bbf7cf51635b840bc0f6b 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:',