Skip to content

fix(import_devices): reject a device group containing '+' - #209

Open
TomlDev wants to merge 1 commit into
linuxmuster:feat/per-school-groupsfrom
TomlDev:fix/reject-plus-in-device-group
Open

TomlDev wants to merge 1 commit into
linuxmuster:feat/per-school-groupsfrom
TomlDev:fix/reject-plus-in-device-group

Conversation

@TomlDev

@TomlDev TomlDev commented Oct 1, 2026

Copy link
Copy Markdown

Optional hardening requested in the review of #207, as a separate PR. Refs #206.

Problem

The school-qualified LINBO group id <school>+<group> (#207, #206) is unambiguous only because a group name never contains +. Today only sophomorix guarantees that. linuxmuster-api derives the owning school from the file name, so base7 has to enforce it as well.

Change

validateDeviceRow() rejects a device row whose group (column 3) contains +. The row is skipped like any other invalid row: it returns (False, None), so getDevicesArray() leaves the device out and import-devices does not process it. The check runs before the hostname, MAC and IP checks and silently returns, in the same way as those checks; no new log line is added. The separator is a named constant, LINBO_GROUP_SEPARATOR, in functions/network.py.

validateDeviceRow() receives the plain group from devices.csv (the group column is never stored qualified, see #207), so there is no already-qualified id on this path and every + is rejected, for default-school and for other schools alike.

Tests

tests/test_functions_network.py:

  • a valid group is accepted and returned unchanged, for default-school and a non-default school
  • groups with + (abc+raum101, raum+101, leading and trailing +) are rejected for both
  • the input row is not modified by a rejected row for a non-default school

pytest tests with a stand-in environment module (linuxmuster-common is not installed on my machine): 41 passed (30 before). flake8 (--max-line-length=100) reports nothing new in the changed files.

Base

Based on feat/per-school-groups, where the other per-school group changes go.

'+' separates school and group in the school-qualified LINBO group id
(<school>+<group>), so a group name must not contain it. validateDeviceRow()
now treats such a row as invalid and the device is skipped like any other
invalid row.

Refs linuxmuster#206

Signed-off-by: Tom Lehmann <tom.lehmann@netzint.de>
Assisted-by: Claude
@TomlDev
TomlDev force-pushed the fix/reject-plus-in-device-group branch from 8331021 to a447a21 Compare October 1, 2026 10:43
@TomlDev
TomlDev marked this pull request as ready for review October 2, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant