From 041a27bafd41ebf4f53bd7e9408b22c8435eaf6a Mon Sep 17 00:00:00 2001 From: xmok <30526133+xmok@users.noreply.github.com> Date: Wed, 25 Oct 2023 19:38:08 +0500 Subject: [PATCH] make sure TTL is 0-86400 inclusive when add or update --- dns/dnsManager.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dns/dnsManager.py b/dns/dnsManager.py index 7142455b6..8746c212f 100755 --- a/dns/dnsManager.py +++ b/dns/dnsManager.py @@ -257,6 +257,10 @@ def addDNSRecord(self, userID = None, data = None): recordType = data['recordType'] recordName = data['recordName'] ttl = int(data['ttl']) + if ttl < 0: + raise ValueError("TTL: The item must be greater than 0") + elif ttl > 86400: + raise ValueError("TTL: The item must be lesser than 86401") admin = Administrator.objects.get(pk=userID) if ACLManager.checkOwnershipZone(zoneDomain, admin, currentACL) == 1: @@ -444,6 +448,10 @@ def updateRecord(self, userID = None, data = None): if data['ttlNow'] != None: record.ttl = int(data['ttlNow']) + if record.ttl < 0: + raise ValueError("TTL: The item must be greater than 0") + elif record.ttl > 86400: + raise ValueError("TTL: The item must be lesser than 86401") if data['priorityNow'] != None: record.prio = int(data['priorityNow']) @@ -826,6 +834,10 @@ def addDNSRecordCloudFlare(self, userID = None, data = None): recordType = data['recordType'] recordName = data['recordName'] ttl = int(data['ttl']) + if ttl < 0: + raise ValueError("TTL: The item must be greater than 0") + elif ttl > 86400: + raise ValueError("TTL: The item must be lesser than 86401") admin = Administrator.objects.get(pk=userID) self.admin = admin