Repository navigation
Made CMDB class insertion fail closed and rollback restore state - #98
Merged
Merged
Conversation
A class the insertion API could not insert was treated as one that
already existed, so {"vars":{"good":"x"},"classes":{"default: ":"any::"}}
installed the variable and returned true. EvalContextClassPutTagsSet()
chops trailing whitespace off a copy of the name for its emptiness test,
refusing a default-namespace class of whitespace only, but files the
class under the name as given.
- A class name with whitespace at either end is invalid.
- A class that exists is found by its canonical identity (namespace,
canonified name) before inserting, not by the raw name, so 'pre-class'
no longer replaces 'pre_class'. Existing classes stay benign and are
left alone and never rolled back.
- Any other failed class insertion rolls back what the call installed and
makes LoadCMDBData() return false. The CMDBTestFailInsertion seam now
covers classes too.
- A variable that exists already makes the file invalid, so rollback only
ever removes what the load itself added. The loader runs on a cleared
context, before augments, so nothing legitimate is refused.
Changelog: None
Ticket: none
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Automatic reviews are disabled for this repository. Configure in Code Review Settings. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Brings in JsonParseStrict() and JsonParseFileStrict() (djbclark/libntech tendcf-integration cc892efae, from fix/json-strict-parse), which refuse a duplicate object member and trailing input after the document. The commits are on the fork's tendcf-integration, not upstream NorthernTechHQ/libntech. Changelog: None Ticket: none Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
host_specific.json was parsed with JsonParseFile(): a repeated object
member replaced the earlier one before validation saw it ({"vars":{
"good":null,"good":"ok"}} loaded), and anything after the first complete
document was ignored. LoadCMDBData() now reads the file with
JsonParseFileStrict() and rejects either, installing nothing.
ReadJsonFile() keeps its behaviour for the augments callers; both share
a static helper that takes the strict flag. Also spells out the headers
cmdb.c and cmdb_test.c used through others (class.h, ctype.h, set.h,
string_lib.h, var_expressions.h).
Unit tests: a repeated member at the top level, in classes, in variables
and in a nested object, with an invalid earlier duplicate; trailing {},
a letter and a bracket; whitespace after the document still loads.
Changelog: None
Ticket: none
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…B data Each file has a good variable and class beside the offending text; the agent run must report the parse refusal and define neither. Changelog: None Ticket: none Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This was referenced Nov 14, 2026
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.
A class the insertion API cannot insert was treated as one that already exists, so a file with a whitespace-only class name still installed its variables. Stacked on
cmdb-fail-closed; found in review of frdminc/tendcf#41."x "becomesx_).pre-classno longer replacespre_class. Existing classes are skipped and never rolled back (the benign case of ENT-10336: Fixed misleading error msg when adding class to CMDB cfengine/core#5263). Any other failed insertion rolls back everything this call installed andLoadCMDBData()returns false.generic_agent.c), so nothing legitimate is refused.CMDBTestFailInsertionalso covers classes (no change inAddCMDBVariable(), which Fixed crash on JSON null values in host_specific.json cfengine/core#6507 touches).Tests (
tests/unit/cmdb_test.c): whitespace-only and edge-whitespace class names next to a good variable and class install nothing; an existing class and an aliased one stay as they were while the rest loads; an existing variable is refused and keeps its value; a forced failure removesdash-class(stored asdash_class) and leaves an aliasedpre_classalone; a forced class failure rolls back earlier classes and installs no variable. Not run locally; fork CI and the Linux gate run them.Not changed:
CMDBTestFailInsertionstays a production global (cmdb_testlinkslibpromises.la).Phase 2 (A2 of the same review): the loader read the file with
JsonParseFile(), so a repeated object member replaced the earlier one before validation saw it ({"vars":{"good":null,"good":"ok"}}loaded) and anything after the first document was ignored.libntechis bumped to djbclark/libntechcc892efae(JsonParseFileStrict()) andLoadCMDBData()uses it;ReadJsonFile()keeps its lenient behaviour for the augments callers. Unit tests cover repeated members (top level,classes,variables, nested) and trailing input, plus whitespace after the document still loading; acceptance 17 and 18 cover a repeated member and trailing input. Not run locally.Closes #97
Prior art / docs checked: libntech
JsonParseStrict()docs at the pin; cfengine#5263 (ENT-10336) made "class exists" benign on purpose, kept; searched cfengine/core and djbclark/core issues and PRs for CMDB class validation, found no other change.🤖 Generated with Claude Code