Browse Source

validate hostname as a fqdn

master
Edoardo Putti 7 years ago
parent
commit
6259025d24
1 changed files with 5 additions and 0 deletions
  1. +5
    -0
      request_server.py

+ 5
- 0
request_server.py View File

@ -1,5 +1,6 @@
#!/usr/bin/env python3
from fqdn import FQDN
import json
import logging
import os.path
@ -70,6 +71,10 @@ def main():
request_id = str(uuid.uuid4())
logger.info('Request id %s', request_id)
if request['keyType'].endswith('_host'):
if not FQDN(request['hostName']).is_valid:
exit_bad('bad FQDN: <%s>' % (request['hostName'],))
logger.info('Writing request to target directory')
with open(os.path.join(REQUESTS_PATH, request_id), 'w') as stream:
stream.write(json.dumps(request))


Loading…
Cancel
Save