From 602f3b08c4bed19bf0db320057b2f023ab8cb816 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Tue, 6 Feb 2018 22:35:56 +0100 Subject: [PATCH] Add zone check script as pre-commit hook Signed-off-by: Knut Ahlers --- .gitignore | 1 + Makefile | 7 ++ checkZonefile.py | 162 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 170 insertions(+) create mode 100644 checkZonefile.py diff --git a/.gitignore b/.gitignore index 9e817ba..87c7e98 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ zones/db.* +*.pyc diff --git a/Makefile b/Makefile index 860c638..658650f 100644 --- a/Makefile +++ b/Makefile @@ -3,3 +3,10 @@ default: container container: docker build --no-cache --pull -t luzifer/dns . docker push luzifer/dns + +.venv: + virtualenv --python=python3 .venv + ./.venv/bin/pip3 install -r requirements.txt + +auto-hook-pre-commit: .venv + ./.venv/bin/python3 checkZonefile.py diff --git a/checkZonefile.py b/checkZonefile.py new file mode 100644 index 0000000..01f8ec7 --- /dev/null +++ b/checkZonefile.py @@ -0,0 +1,162 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import generateZonefiles as generator + +import re +import sys +import yaml + +MATCH_FQDN = '(?=^.{4,253}$)(^((?!-)[a-zA-Z0-9-]{1,63}(?