Skip to content

Commit

Permalink
fix(api): disallow generic type format like TYPExxx
Browse files Browse the repository at this point in the history
pdns would convert types like TYPE99 to the named ones (here: SPF),
but our API cannot do so without maintaining a mapping table that
depends on the pdns version. Currently, we would store two distinct
RRsets in our API database, corresponding to only one RRset in pdns.
Worse, if one RRset was deleted (along with the one on pdns), the
other would remain as an orphan.

The only usecase for this would be new types quickly gaining
popularity although pdns does not know them yet. In this case, we
can address the issue again.
  • Loading branch information
peterthomassen committed Apr 3, 2018
1 parent e7f0a2f commit 501b4a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/desecapi/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ def validate_type(self, value):
if value in RRset.RESTRICTED_TYPES:
raise serializers.ValidationError(
"You cannot tinker with the %s RRset." % value)
if value.startswith('TYPE'):
raise serializers.ValidationError(
"Generic type format is not supported.")
return value

def to_representation(self, instance):
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/spec/api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ describe("API", function () {
{'subname': 'd.1', 'ttl': 50, 'type': 'AAAA'},
{'subname': 'd.1', 'ttl': 50, 'type': 'SOA', 'records': ['ns1.desec.io. peter.desec.io. 2018034419 10800 3600 604800 60']},
{'subname': 'd.1', 'ttl': 50, 'type': 'OPT', 'records': ['9999']},
{'subname': 'd.1', 'ttl': 50, 'type': 'TYPE099', 'records': ['v=spf1 mx -all']},
]
);
expect(response).to.have.status(400);
Expand All @@ -317,6 +318,7 @@ describe("API", function () {
{ records: [ 'This field is required.' ] },
{ type: [ 'You cannot tinker with the SOA RRset.' ] },
{ type: [ 'You cannot tinker with the OPT RRset.' ] },
{ type: [ 'Generic type format is not supported.' ] },
]);

return chakram.wait();
Expand Down

0 comments on commit 501b4a1

Please sign in to comment.