Filter container interfaces from device discovery and policies
Build and Deploy Gateway / build-and-push (push) Successful in 11s
Build and Deploy Gateway / deploy (push) Successful in 14s

This commit is contained in:
2026-08-07 17:16:36 +03:00
parent 53e6cf2146
commit 608f8cfcf2
8 changed files with 68 additions and 16 deletions
+3 -3
View File
@@ -1,11 +1,11 @@
import crypto from 'node:crypto';
import net from 'node:net';
import { spawnSync } from 'node:child_process';
import { isDeviceInterface } from '../adapters/neighbors.js';
const COMMAND_OPTIONS = { encoding: 'utf8', timeout: 2_000, killSignal: 'SIGKILL' };
const DEVICE_ID_PATTERN = /^dev_[a-f0-9]{16}$/;
const MAC_PATTERN = /^[0-9a-f]{2}(?::[0-9a-f]{2}){5}$/;
const INTERFACE_PATTERN = /^[a-z0-9_.:-]{1,15}$/i;
const CHAIN_PATTERN = /^[a-z0-9_-]{1,26}$/i;
const MARK_PATTERN = /^(?:0x)?[0-9a-f]+$/i;
const MAX_DEVICES = 512;
@@ -36,8 +36,8 @@ export function normalizeDirectDevices(value) {
};
const tuple = `${normalized.ip}|${normalized.mac}|${normalized.interface}`;
if (!DEVICE_ID_PATTERN.test(normalized.id) || !net.isIPv4(normalized.ip)
|| !MAC_PATTERN.test(normalized.mac) || !INTERFACE_PATTERN.test(normalized.interface)
|| normalized.interface.startsWith('br-') || ids.has(normalized.id) || tuples.has(tuple)) {
|| !MAC_PATTERN.test(normalized.mac) || !isDeviceInterface(normalized.interface)
|| ids.has(normalized.id) || tuples.has(tuple)) {
throw new Error('Некорректная или повторяющаяся device policy identity');
}
ids.add(normalized.id);