Filter container interfaces from device discovery and policies
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user