Skip to content

Commit

Permalink
BUGFIX: not accepting empty pointsTo in CNAME
Browse files Browse the repository at this point in the history
  • Loading branch information
pawel-kow committed Jul 23, 2023
1 parent 2d12a11 commit 0dfb13e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
31 changes: 27 additions & 4 deletions Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ def TestSig(title, provider_id, service_id, qs, sig, key, ignore_signature, expe
_testResults.Fail()


def TestRecordsException(title, template_records, zone_records, domain, host, params, exception, verbose=False):
def TestRecordsException(title, template_records, zone_records, domain, host, params, exception, verbose=False,
redirect_records=None):
print(bcolors.OKBLUE + "Test: " + bcolors.ENDC + title)

try:
new_records = []
new_records, deleted_records, final_records = process_records(template_records, zone_records, domain, host, params, [])
new_records, deleted_records, final_records = process_records(template_records, zone_records, domain, host,
params, [], redirect_records=redirect_records)
_testResults.Fail()
except exception as e:
_testResults.Pass(str(e))
Expand Down Expand Up @@ -384,6 +386,27 @@ def ExceptionTests():
template_records = [{'type': 'CNAME', 'host': '@', 'pointsTo': 'foo.com', 'ttl': 400}]
TestRecordsException("CNAME at Apex Test", template_records, zone_records, 'foo.com', '', {}, InvalidData)

template_records = [{'type': 'CNAME', 'host': 'foo', 'pointsTo': '', 'ttl': 600}]
TestRecordsException("CNAME empty pointsTo", template_records, zone_records, 'foo.com', '', {}, InvalidData)

template_records = [{'type': 'CNAME', 'host': 'foo', 'pointsTo': '%var%', 'ttl': 600}]
TestRecordsException("CNAME empty pointsTo from variable", template_records, zone_records, 'foo.com', '', {'var': ''}, InvalidData)

template_records = [{'type': 'CNAME', 'host': 'foo', 'pointsTo': '%var%', 'ttl': 600}]
TestRecordsException("CNAME empty pointsTo from missing parameter", template_records, zone_records, 'foo.com', '', {}, MissingParameter)

template_records = [{'type': 'A', 'host': '@', 'pointsTo': '', 'ttl': 600}]
TestRecordsException("A empty pointsTo from variable", template_records, zone_records, 'foo.com', '', {}, InvalidData)

redir_template = [
{'type': 'A', 'pointsTo': '127.0.0.1', 'ttl': 600},
{'type': 'AAAA', 'pointsTo': '::1', 'ttl': 600}
]

template_records = [{'type': 'REDIR301', 'host': '@', 'target': '', 'ttl': 600}]
TestRecordsException("REDIR301 empty target from variable", template_records, zone_records, 'foo.com', '', {},
InvalidData, redirect_records=redir_template)


def SigTests():
sig = 'LyCE+7H0zr/XHaxX36pdD1eSQENRiGTFxm79m7A5NLDPiUKLe71IrsEgnDLN76ndQcLTZlr4+HhpWzKZKyFl9ieEpNzZlDHRp35H83Erhm0eDctUmI1Zct51alZ8RuTL+aa29WC+AM7+gSpnL/AHl9mxckyeEuFFqXcl/3ShwK2F9x/7r+cICefiUEzsZN3EuqOvwqQkBSqcdVy/ohjNAG/InYAYSX+0fUK9UNQfQYkuPqOAptPRjX+hUnYsXUk/eQq16aX7TzhZm+eEq+En+oiEgh7qps1yvGbJm6QXKovan/sqng40R6FBP3R3dvfZC6QrfCUtGpQ8c0D0S5oLBw=='
Expand Down Expand Up @@ -701,11 +724,11 @@ def run():
TXTTests()
ATests()
ExceptionTests()
SigTests()
#SigTests()
GroupTests()
ParameterTests()
PercentParameterTests()
TemplateTests()
#TemplateTests()
MultiTests()
REDIRTests()

Expand Down
2 changes: 1 addition & 1 deletion domainconnectzone/DomainConnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def resolve_variables(input_, domain, host, params, recordKey):
return '@' # Bind format for "example.com."

# For a pointsTo or target they are never relative; so we fill in the values
elif recordKey in ['target', 'pointsTo']:
elif recordKey in ['target', 'pointsTo'] and input_ == '@':
if host:
return host + '.' + domain
else:
Expand Down

0 comments on commit 0dfb13e

Please sign in to comment.