Skip to content

Refactor tree parser to the HIM-profile aware vss-tools parser - #210

Open
UlfBj wants to merge 1 commit into
v3.2.5from
refactor/him-tree-parser
Open

UlfBj wants to merge 1 commit into
v3.2.5from
refactor/him-tree-parser

Conversation

@UlfBj

@UlfBj UlfBj commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Refactors VISSR's Go tree parser (utils/treeutils.go) to use the updated, HIM-profile aware binary parser from the vss-tools him-support branch (binary/go_parser datamodel + parserlib, commit ca5b158). The VISSR tree handling predates that update and only knew the VSS-era node types as strings.

The parser data model is vendored into utils (utils/datamodel.go) rather than imported as a module, because the him-support changes are not yet in COVESA/vss-tools and the existing replace directives in go.mod were commented out. The VISSR-specific hardening (error propagation, depth/node caps, mutex, nil guards) and the forest handling (InitForest, service tree registration) are kept.

How it worked before (short version)

Full write-up is in utils/TREEUTILS.md.

  • treeutils.go held a private copy of the vss-tools Go binary parser, with VISSR additions (forest of trees from viss.him, hardening, constructors for dynamically registered service trees).
  • Node_t.NodeType was a string; the known types (sensor, actuator, attribute, branch, struct, property, procedure, iostruct) were string constants. ro, rw, symlink, typedef had none. The default value was in DefaultValue.
  • With leafNodesOnly, every node that was not a branch counted as a leaf, so struct, procedure and iostruct nodes were reported as leaves.
  • Datatype was returned for every node; unit/allowed were suppressed only for branch/struct.

What changed

Area Before After
Node_t.NodeType string NodeTypes_t with constants for all HIM node types (adds RO, RW, SYMLINK, TYPEDEF)
Type mapping none StringToNodetype() / NodetypeToString(); unknown type in a binary file is now a parse error
Default field DefaultValue DefaultAllowed (vss-tools name)
VSSgetType() string NodeTypes_t (use NodetypeToString() for JSON/log output)
Leaf test type != branch IsContainerType() false (branch, struct, procedure, iostruct are never leaves)
Datatype/unit/allowed inconsistent suppressed for container types and symlink via IsTypeWithoutDatatype()
NewSignalNode() type as string type as NodeTypes_t (existing callers compile unchanged, constants are untyped)

Callers updated: vissv2server.go, vissServiceMgr.go, setvalidate.go, and the affected tests.
Unchanged: binary file format, viss.him format, search algorithm, exported function names apart from the type changes above.

Behavior change to review

struct, procedure and iostruct nodes are no longer included in leaf searches (path list files via --pathlist, Data profile get). Non-leaf searches return the same nodes as before.

Verification

  • Read all 8 bundled binary trees in server/vissv2server/forest/ with the old and new parser and diffed a dump of every node (name, type, datatype, unit, min, max, allowed, default, validate, children, uuid, description), the default lists, and wildcard searches. Node dumps, default lists and non-leaf searches are identical. The only difference is the 26 container nodes (3 procedure, 17 iostruct, 6 struct) that are now excluded from leaf lists/searches; nothing was added.
  • go vet is clean for ./utils and ./server/vissv2server/....
  • go test passes for server/vissv2server, server/vissv2server/vissServiceMgr and server/vissv2server/atServer.
  • go test ./utils has 3 failures that are pre-existing on the v3.2.5 tip and unrelated to this change (verified before making any edits): TestExportKeyPair_PrivateFileIs0600, TestExportKeyPair_ECDSA_FileIs0600 (file mode 0666 vs 0600) and TestInitLog_WithLogFile. These look Windows-specific.

Vendor the vss-tools him-support datamodel (typed NodeTypes_t covering all HIM
profiles) into utils and adapt treeutils.go to it, keeping the VISSR hardening
and forest handling. Adds utils/TREEUTILS.md describing the previous
implementation and the changes.

This branch has not been deployed

No deployments
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