Compare commits

..
6 Commits
Author SHA1 Message Date
Sven Luethi 57195a822b modified: .github/workflows/python-publish.yml 2025-11-25 01:25:42 +01:00
Sven Luethi 0590caeebd modified: src/netbox_plugin_bind_provisioner/__init__.py
Update version string
2025-11-25 00:13:06 +01:00
Sven Luethi 962be7a048 modified: src/netbox_plugin_bind_provisioner/management/commands/bind-transfer-endpoint.py
Fixes broken dns responses to UDP endpoint (denyRequest function replaced)
2025-11-25 00:03:36 +01:00
Sven Luethi 204a946a84 modified: README.md
Removes the warning for step 4 from the installation guide. The warning said not to run migrations
as the plugin did not have its own models. Since v0.9.6 it does so this was forgotten to be removed.
2025-11-24 13:51:42 +01:00
Sven Luethi d72dc5a115 modified: .github/workflows/python-publish.yml 2025-11-23 16:45:46 +01:00
Sven Luethi b659268117 modified: .github/workflows/python-publish.yml
Update flow
2025-11-23 16:43:27 +01:00
4 changed files with 42 additions and 56 deletions

No files matched your search

+12 -40
View File
@@ -6,7 +6,7 @@
# separate terms of service, privacy policy, and support
# documentation.
name: Upload Python Package
name: Create and Upload Python Package
on:
release:
@@ -16,9 +16,12 @@ permissions:
contents: read
jobs:
release-build:
build-and-publish:
name: Build and Publish
environment: pypi
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -26,45 +29,14 @@ jobs:
with:
python-version: "3.x"
- name: Build release distributions
- name: Install build tools
run: |
# NOTE: put your own distribution build steps here.
python -m pip install --upgrade pip
python -m pip install build
python -m build
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist/
- name: Build release
run: |
python -m build --sdist --wheel
pypi-publish:
runs-on: ubuntu-latest
needs:
- release-build
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
# Dedicated environments with protections for publishing are strongly recommended.
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
environment:
name: pypi
# OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
# url: https://pypi.org/p/YOURPROJECT
#
# ALTERNATIVE: if your GitHub Release name is the PyPI project version string
# ALTERNATIVE: exactly, uncomment the following line instead:
# url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }}
steps:
- name: Retrieve release distributions
uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/
- name: Publish release distributions to PyPI
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
+1 -1
View File
@@ -109,7 +109,7 @@ This guide assumes:
This allows the plugin to map requests to the right dns view using the tsig
signature from each request.
4. Run migrations (This step is not yet required. Just adding for completeness)
4. Run migrations
```
python3 netbox/manage.py migrate
```
@@ -5,7 +5,7 @@ from django.utils.translation import gettext_lazy as _
from django.dispatch import receiver
from django.conf import settings
__version__ = "0.9.6"
__version__ = "0.9.8"
logger = logging.getLogger(__name__)
@@ -260,17 +260,15 @@ class DNSBaseRequestHandler(socketserver.BaseRequestHandler):
# Replace the rdataset for the given name and type
zone.replace_rdataset(name, rdataset)
return zone
def denyRequest(self, query, rcode: dns.rcode = dns.rcode.REFUSED):
response = dns.message.make_response(query)
response.set_rcode(rcode)
wire = response.to_wire(multi=False)
length = len(wire).to_bytes(2, byteorder="big")
self.request.sendall(length + wire)
# def denyRequest(self, query, rcode: dns.rcode = dns.rcode.REFUSED):
# response = dns.message.make_response(query)
# response.set_rcode(rcode)
# wire = response.to_wire(multi=False)
# length = len(wire).to_bytes(2, byteorder="big")
# self.request.sendall(length + wire)
def denyRequestBadTSIG(self, wire, tsig_error: dns.rcode):
@@ -292,6 +290,13 @@ class DNSBaseRequestHandler(socketserver.BaseRequestHandler):
class UDPRequestHandler(DNSBaseRequestHandler):
def denyRequest(self, query, rcode: dns.rcode = dns.rcode.REFUSED):
response = dns.message.make_response(query)
response.set_rcode(rcode)
wire = response.to_wire(multi=False)
sock = self.request[1]
sock.sendto(wire, self.client_address)
def handle(self):
data, sock = self.request
peer = self.client_address[0]
@@ -301,7 +306,7 @@ class UDPRequestHandler(DNSBaseRequestHandler):
query = dns.message.from_wire(
data,
keyring=self.server.keyring,
continue_on_error=True,
continue_on_error=False,
ignore_trailing=True
)
except Exception as e:
@@ -328,12 +333,13 @@ class UDPRequestHandler(DNSBaseRequestHandler):
return
# Identify TSIG key used
key_name = query.keyname.canonicalize().to_text() if query.keyname else None
if not key_name:
if not query.had_tsig:
logger.warning(f"Request denied from {peer}: No TSIG key used")
self.denyRequest(query)
return
key_name = query.keyname.canonicalize().to_text()
# Check if key matches a view
nb_view = self.server.tsig_view_map.get(key_name)
if not nb_view:
@@ -387,6 +393,13 @@ class UDPRequestHandler(DNSBaseRequestHandler):
class TCPRequestHandler(DNSBaseRequestHandler):
def denyRequest(self, query, rcode: dns.rcode = dns.rcode.REFUSED):
response = dns.message.make_response(query)
response.set_rcode(rcode)
wire = response.to_wire(multi=False)
length = len(wire).to_bytes(2, byteorder="big")
self.request.sendall(length + wire)
def handle(self):
MAX_WIRE = 65535
# MAX_WIRE = 2000 # For testing fragmentation
@@ -443,12 +456,13 @@ class TCPRequestHandler(DNSBaseRequestHandler):
return
# Identify TSIG key used
key_name = query.keyname.canonicalize().to_text() if query.keyname else None
if not key_name:
if not query.had_tsig:
logger.warning(f"Request denied from {peer}: No TSIG key used")
self.denyRequest(query)
return
key_name = query.keyname.canonicalize().to_text()
# Check if the key matches a view
nb_view = self.server.tsig_view_map.get(key_name)
if not nb_view:
@@ -630,7 +644,7 @@ class Command(BaseCommand):
name=key_name_obj, secret=secret, algorithm=algorithm_str
)
self.tsig_view_map[key_name_str] = nb_view
logger.debug(f"Loaded TSIG key: {key_name_str} (view: {nb_view.name})")
logger.debug(f"Loaded TSIG key: {key_name_str} view: {nb_view.name}")
if not self.keyring:
msg = "No TSIG keys found in database."