feat(tia): a TIA connector's export is read, its devices matched #1096

Open
sharang wants to merge 2 commits from feat/tia-export-bundle into main
pull from: feat/tia-export-bundle
Owner

Closes #1090 (part of epic #1095).

A TIA connector (#1094) uploads its export of a TIA Portal project as a zip with manifest.json at the root. This PR is the Prüfwerk side; no TIA installation is needed for it.

Contract (compliance_core::models::tia_export, documented in docs/guide/plc.md):

  • bundle_version 1, tia_version (V20/V21), project, connector;
  • devices with TIA type identifier or order number + firmware;
  • per CPU the security settings (access level, PUT/GET, web server, HTTPS only, OPC UA and its policies, secure PG/HMI only, confidential data protection). Each is {"value": …}, {"unreadable": "<why>"} (Openness throws on some reads), or absent. This lets #1091 tell "off" from "unknown";
  • blocks with kind, language, file in the zip, protected.

Unknown fields are ignored, so a newer connector doesn't break an older Prüfwerk.

Upload (POST /api/v1/targets/{id}/artifacts/upload, kind=plc_project, plc_format=tia_export):

  • Checked on upload: the manifest is read at once, as for supplier SBOMs. A bad file gets 422 with a code (not_zip, no_manifest, manifest_too_large, manifest_invalid, bundle_version) and is not kept.
  • Replacement: a new export replaces the last one, file and all. replace_supplier_sboms is generalised to replace_earlier.
  • API keys: they reach the route with the new scope pruefwerk:uploads.write (registry #158, portal #208, both open).

Devices:

  • Where they're kept: a device with a Siemens order number and firmware is kept on the artifact (plc.devices), not in target.devices. The target editor replaces that list wholesale, so an edit would otherwise wipe them.
  • Combined list: OnboardedTarget::target_devices() joins the entered devices and the exported ones. It feeds the SBOM, the Siemens advisory matching and the Steuerungen page.
  • Duplicates: an entered device with the same order number wins, because it knows the installed firmware.
  • SBOM evidence: reads "configured as PLC_1 in the TIA export …".

Scan: what it doesn't analyse is shown as a skipped stage, never as clean, with three new skip codes and DE/EN wording:

  • block code, until #1093: PlcBlocksNotAnalysed, e.g. "2 (LAD, SCL)";
  • know-how-protected blocks: ProtectedBlocks;
  • devices without an order number or firmware, e.g. GSD devices: DevicesUnmatched.

Not in this PR: block code (#1093), CPU configuration rules (#1091), the connector (#1094), a dashboard upload option for the format (the connector uploads through the API).

Tests:

  • Unit tests: manifest parsing and refusals, device extraction from type identifiers, protected blocks, zip reading with size limits, SBOM evidence.
  • Integration test: refusal, devices on the artifact, replacement and the Steuerungen page.
  • Existing supplier-SBOM and API-key tests pass after the refactor.
  • Clippy with CI flags is clean (core, agent, dashboard server and web); fmt is clean.

Merge timing: please merge this only after the v0.4.20 prod promote. promote.sh pins what stage runs, and otherwise this would ride into prod as part of "0.4.20".

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9

Closes #1090 (part of epic #1095). A TIA connector (#1094) uploads its export of a TIA Portal project as a zip with `manifest.json` at the root. This PR is the Prüfwerk side; no TIA installation is needed for it. **Contract** (`compliance_core::models::tia_export`, documented in docs/guide/plc.md): - `bundle_version` 1, `tia_version` (V20/V21), project, connector; - devices with TIA type identifier or order number + firmware; - per CPU the security settings (access level, PUT/GET, web server, HTTPS only, OPC UA and its policies, secure PG/HMI only, confidential data protection). Each is `{"value": …}`, `{"unreadable": "<why>"}` (Openness throws on some reads), or absent. This lets #1091 tell "off" from "unknown"; - blocks with kind, language, file in the zip, `protected`. Unknown fields are ignored, so a newer connector doesn't break an older Prüfwerk. **Upload** (`POST /api/v1/targets/{id}/artifacts/upload`, `kind=plc_project`, `plc_format=tia_export`): - **Checked on upload:** the manifest is read at once, as for supplier SBOMs. A bad file gets 422 with a `code` (`not_zip`, `no_manifest`, `manifest_too_large`, `manifest_invalid`, `bundle_version`) and is not kept. - **Replacement:** a new export replaces the last one, file and all. `replace_supplier_sboms` is generalised to `replace_earlier`. - **API keys:** they reach the route with the new scope `pruefwerk:uploads.write` (registry #158, portal #208, both open). **Devices**: - **Where they're kept:** a device with a Siemens order number and firmware is kept on the artifact (`plc.devices`), not in `target.devices`. The target editor replaces that list wholesale, so an edit would otherwise wipe them. - **Combined list:** `OnboardedTarget::target_devices()` joins the entered devices and the exported ones. It feeds the SBOM, the Siemens advisory matching and the Steuerungen page. - **Duplicates:** an entered device with the same order number wins, because it knows the installed firmware. - **SBOM evidence:** reads "configured as PLC_1 in the TIA export …". **Scan:** what it doesn't analyse is shown as a skipped stage, never as clean, with three new skip codes and DE/EN wording: - block code, until #1093: `PlcBlocksNotAnalysed`, e.g. "2 (LAD, SCL)"; - know-how-protected blocks: `ProtectedBlocks`; - devices without an order number or firmware, e.g. GSD devices: `DevicesUnmatched`. **Not in this PR:** block code (#1093), CPU configuration rules (#1091), the connector (#1094), a dashboard upload option for the format (the connector uploads through the API). **Tests:** - Unit tests: manifest parsing and refusals, device extraction from type identifiers, protected blocks, zip reading with size limits, SBOM evidence. - Integration test: refusal, devices on the artifact, replacement and the Steuerungen page. - Existing supplier-SBOM and API-key tests pass after the refactor. - Clippy with CI flags is clean (core, agent, dashboard server and web); fmt is clean. **Merge timing:** please merge this only after the v0.4.20 prod promote. `promote.sh` pins what stage runs, and otherwise this would ride into prod as part of "0.4.20". 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
sharang added 1 commit 2026-12-01 13:08:34 +00:00
feat(tia): a TIA connector's export is read, its devices matched
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Agent integration (pull_request) Successful in 5m27s
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Canceled after 15m3s
a9ea12651f
A TIA export (#1090) is a zip with manifest.json at its root: the
project's devices with order number and configured firmware, each
CPU's security settings (value, or why Openness could not read it),
and its blocks, the know-how-protected ones marked.

- PlcFormat::TiaExport; the manifest is read on upload and refused
  with 422 and a code (not_zip, no_manifest, manifest_too_large,
  manifest_invalid, bundle_version); a new export replaces the last.
- Matchable devices are kept on the artifact and join the target's
  controllers (SBOM, Siemens advisories, Steuerungen page); a device
  entered by hand with the same order number wins.
- The scan notes what it does not analyse: block code until #1093,
  protected blocks, devices without order number or firmware.
- API keys reach the upload with pruefwerk:uploads.write
  (tenant-registry #158, portal #208).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
sharang added 1 commit 2026-12-01 13:23:27 +00:00
fix(tia): a type identifier gives only a concrete article and its version
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) In progress
CI / Agent integration (pull_request) Successful in 5m24s
1f3beb5786
Siemens' Openness notes: catalog identifiers carry wildcards
(6SL3040-1MA01-0Axx), drive identifiers a family after the version
(/V5.2.3/S120), some a catalog variant instead (//10002). Only a
concrete article and a V-version are taken; the rest is not matched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
Some checks are pending
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) In progress
CI / Agent integration (pull_request) Successful in 5m24s
You are not authorized to merge this pull request.
This pull request can be merged automatically.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/tia-export-bundle:feat/tia-export-bundle
git checkout feat/tia-export-bundle
Sign in to join this conversation.