Repository navigation
feat: allow-list flags (go-profinet allow-list); exit code 12 policy_denied (v0.23.0) - #59
Merged
Merged
Conversation
…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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 rangesFIRST-LAST--allow-dcp-block— DCP Set blocks (Device/NameOfStation,IP/Parameter, ... orOPTION/SUBOPTION)--allow-list-file— the same as a JSON object (operations,read_indexes,write_indexes,dcp_blocks, the fields ofcontroller.Allowlist); no new dependency--allow-nothing— the only way to get an allow-list that allows nothingThe list is set as
controller.Config.Allowedon the AR commands' controller,RecordClientOptions.Allowedon the record clients (NewRecordClientWith), and as thedcp.SetAllowlistgo-profinet's controller derives from it on the DCP requester ofname set,ip set,signal,reset.Semantics
--allow-nothingproduces 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.profinet.ErrNotAllowed,*controller.NotAllowedError,*dcp.NotAllowedError) → new exit code 12, kind and codepolicy_denied. The JSON error adds"reason": "policy_denied",operation,record(api/slot/subslot/index) orblock, andtarget(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.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
--helpare 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.--helpnames the flags.make checkgreen locally (coverage 95.7 %),make e2egreen.scripts/examples.shgets two examples for the nextmake 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