Permalink
Browse files

API: Reject unknown types (TYPE0)

Fixes #2130.
(cherry picked from commit 24cd86c)
  • Loading branch information...
1 parent 92d4a7e commit 2f72b7ceba9b0d1025e359bb534ce50941d6e460 @zeha zeha committed with mind04 Feb 7, 2015
Showing with 27 additions and 0 deletions.
  1. +4 −0 pdns/ws-auth.cc
  2. +23 −0 regression-tests.api/test_Zones.py
View
@@ -400,6 +400,10 @@ static void gatherRecords(const Value& container, vector<DNSResourceRecord>& new
rr.priority = 0;
rr.disabled = boolFromJson(record, "disabled");
+ if (rr.qtype.getCode() == 0) {
+ throw ApiException("Record "+rr.qname+"/"+stringFromJson(record, "type")+" is of unknown type");
+ }
+
try {
shared_ptr<DNSRecordContent> drc(DNSRecordContent::mastermake(rr.qtype.getCode(), 1, rr.content));
string tmp = drc->serialize(rr.qname);
@@ -704,6 +704,29 @@ def test_zone_rr_update_out_of_zone(self):
self.assertEquals(r.status_code, 422)
self.assertIn('out of zone', r.json()['error'])
+ def test_rrset_unknown_type(self):
+ payload, zone = self.create_zone()
+ name = payload['name']
+ rrset = {
+ 'changetype': 'replace',
+ 'name': name,
+ 'type': 'FAFAFA',
+ 'records': [
+ {
+ "name": name,
+ "type": "FAFAFA",
+ "ttl": 3600,
+ "content": "4.3.2.1",
+ "disabled": False
+ }
+ ]
+ }
+ payload = {'rrsets': [rrset]}
+ r = self.session.patch(self.url("/servers/localhost/zones/" + name), data=json.dumps(payload),
+ headers={'content-type': 'application/json'})
+ self.assertEquals(r.status_code, 422)
+ self.assertIn('unknown type', r.json()['error'])
+
def test_zone_rr_delete_out_of_zone(self):
payload, zone = self.create_zone()
name = payload['name']

0 comments on commit 2f72b7c

Please sign in to comment.