Skip to content

feat: allow-list flags (go-profinet allow-list); exit code 12 policy_denied (v0.23.0) - #59

Merged
boeboe merged 1 commit into
mainfrom
feat/allow-list-flags
Nov 30, 2026
Merged

boeboe merged 1 commit into
mainfrom
feat/allow-list-flags

Conversation

@boeboe

@boeboe boeboe commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

What

profinetctl exposes go-profinet v0.28.0's allow-list (engineering policy 1.7, SEC-R02; maintainer decision 14 of 2026-11-30), in the library's own vocabulary:

  • --allow-operation — go-profinet's operation classes: connect, read, read-implicit, write, prm-begin, prm-end, other-control, dcp-set (repeatable, comma-separated allowed)
  • --allow-read-index, --allow-write-index — record index ranges FIRST-LAST
  • --allow-dcp-block — DCP Set blocks (Device/NameOfStation, IP/Parameter, ... or OPTION/SUBOPTION)
  • --allow-list-file — the same as a JSON object (operations, read_indexes, write_indexes, dcp_blocks, the fields of controller.Allowlist); no new dependency
  • --allow-nothing — the only way to get an allow-list that allows nothing

The list is set as controller.Config.Allowed on the AR commands' controller, RecordClientOptions.Allowed on the record clients (NewRecordClientWith), and as the dcp.SetAllowlist go-profinet's controller derives from it on the DCP requester of name set, ip set, signal, reset.

Semantics

  • No flag = unchanged behaviour (no allow-list at all).
  • Empty list = allows nothing (go-profinet's rule). Only --allow-nothing produces one: a file without operations is refused (exit 3), as is a range/block whose operation the list does not allow (exit 2 from flags, 3 in a file). So a mistake can't silently give an allow-nothing or allow-everything list.
  • Refusal (profinet.ErrNotAllowed, *controller.NotAllowedError, *dcp.NotAllowedError) → new exit code 12, kind and code policy_denied. The JSON error adds "reason": "policy_denied", operation, record (api/slot/subslot/index) or block, and target (station, mac, ip). Commands with several result parts (device info, status, I&M1–4, topology, topology check) report a refused part as a failed part (exit 7), as they do for any other failure.
  • A malformed value or file is invalid input (3); an excluded combination is a usage error (2), following the CLI's existing table.
  • Not covered (go-profinet SECURITY.md): DCP Identify/Get, LLDP, Release, the Control/Start and Stop brackets, and what belongs to an allowed AR.

Exit code 12 is the next protocol-specific code (11–12 range of the organisation table, CLI-001); docs/exitcodes.md, docs/json-output.md, README ("Allow-list" section with what each command needs), SECURITY.md and --help are updated.

Tests

  • cmd/allow_test.go: parsers (operations, ranges, blocks), flag and file validation (every error path), DCP list derivation, target completion, and in-process runs on the virtual network: refused record read / im read / record write (connect and write ranges; the device stores nothing), refused DCP Sets (signal counter stays 0; Identify/Get still work), refused AR startup (connect, parameter write, --assign-ip), an allowed AR, partial results of topology.
  • internal/errs, internal/runner: exit code 12 and the JSON fields.
  • e2e: flag errors through the binary (exit 2/3 with JSON codes), --help names the flags.
  • make check green locally (coverage 95.7 %), make e2e green. scripts/examples.sh gets two examples for the next make examples-doc (docs/EXAMPLES.md is generated; not regenerated here: the p-net image is not available locally).

Release notes: ## v0.23.0 (minor, new feature).

🤖 Generated with Claude Code

…icy_denied (v0.23.0)

Expose go-profinet v0.28.0's controller.Allowlist and the dcp.SetAllowlist
the controller derives from it (engineering policy 1.7, SEC-R02; maintainer
decision 14 of 2026-11-30): --allow-operation (operation classes),
--allow-read-index / --allow-write-index (record index ranges),
--allow-dcp-block (DCP Set blocks), --allow-list-file (JSON) and
--allow-nothing. No flag: no allow-list, unchanged behaviour. An empty
list allows nothing and only --allow-nothing makes one.

A refusal (profinet.ErrNotAllowed) exits 12 with kind and code
policy_denied; the JSON error adds reason, operation, record or block,
and target.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@boeboe
boeboe merged commit 4d5dfc9 into main Nov 30, 2026
19 checks passed
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