Repository navigation
Conversation
Signed-off-by: Victor Moene <victor.moene@northern.tech>
GetProcessStat() asserted on unexpected open() errors, e.g. when the process exited in the meantime. Release builds would loop forever instead. Now logs the error and returns false. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Ticket: CFE-4285 Changelog: Title Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
CFE-4285: Fixed cf-agent assertion failure when reading /proc/<pid>/stat
…ions.c Linked TODOs to new tickets to fix old bugs/TODOs that were already in cf-agent before moving the code. Signed-off-by: Victor Moene <victor.moene@northern.tech>
Better concurrency for cf-reactor static state - No need for map anymore, since watcher keeps track of the promise - No need to keep key as variable anymore, since we do not use a map - No need to run bundle inside watcher.c - No risk of running a bundle from a wrong key between policy reads Signed-off-by: Victor Moene <victor.moene@northern.tech>
Promises are skipped to prevent running them several times. However, on event, we want to run them every single time: - we clear the promise lock cache - we set the default if_elapsed time for bundles run from an events promise to be 0, so it doesn't skip the promises. Fixed also connection cache and custom promise prologue and epilogue. Clear function cache before "then" bundle run Signed-off-by: Victor Moene <victor.moene@northern.tech>
Signed-off-by: Victor Moene <victor.moene@northern.tech>
- Moved mod_methods.c's MethodsParseTreeCheck implementation to PromiseCheckBundleCallArity in policy.c, and made it more generic - Now, MethodsParseTreeCheck and EventsParseTreeCheck both call this new function when calling bundles Signed-off-by: Victor Moene <victor.moene@northern.tech>
ENT-14194: Run policy on event
DiffPkgOperations() and ManifestPkgOperations() only asserted that the operation code and the package name of a record were set, so in a build without asserts a record with an unknown or empty operation code, or an empty name, was reported as a removal. Such records are now skipped with the same error as a record with the wrong number of fields. ManifestPkgOperations() also asserted that at least one record was valid, which aborted a debug build when none was. Like DiffPkgOperations(), it now logs that there is nothing to manifest and returns. Ticket: none Changelog: Title Signed-off-by: Daniel JB Clark <djbclark@gmail.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
djbclark
force-pushed
the
fix/simulate-pkg-record-op-validation
branch
from
October 9, 2026 11:24
00d5366 to
6eb70ad
Compare
djbclark
added a commit
that referenced
this pull request
Oct 9, 2026
…m 08:30 Adds the Tier 2 handoff file itself (the first commit on this branch carried only README.md because the checkout's .git/info/exclude lists docs/handoffs/, which also applies to worktrees) with the advfix2 addendum: fork PR #48 tip 6eb70ad. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.


Fork-internal PR for CI; not an upstream submission. One commit: the diff and manifest reports of
--simulateonlyassert()ed that a package record's operation code and name were set. In a build without asserts (the default release configuration), a record such asx,pkg,,fell through the if/else chain into the remove branch and was reported as a removal that no promise asked for; a debug build aborted. Both readers now check the two fields explicitly and skip a bad record with the error already used for a record with the wrong number of fields. The manifest reader also asserted that at least one record was valid, so a file in which none was aborted a debug build; it now logs that there is nothing to manifest and returns, as the diff reader already did. Three unit tests cover it; all fail on the unfixed code. Found by the adversary review of #41 (finding 1) and its follow-up note on this PR's first version. Adversary security review of this commit (6eb70ad, read-only, static): no findings.Before/after for the guard,
tests/unit/simulate_mode_testbuilt with asserts on (macOS,-UNDEBUG), the library rebuilt in between:Ubuntu 24.04 (
--enable-debug, as root):make -C tests/unit check→All 75 tests passed;tests/acceptance/29_simulate_mode/→ 4 of 4 Pass.ELI5 — auditable without C
You know shell and a little Python. One fact.
What the code is for.
cf-agent --simulatedoesn't install or remove packages. It writes one CSV line per package action it would take,op,name,version,architecture, and at the end turns that log into a report.opis one letter:iinstall,rremove,ppresent,aabsent.The fact. The reader checked the number of fields, but trusted the letter and the name with
assert, which release builds compile out. The branch chain ends in a plainelse, so anything unknown counted as a removal:Skipping bad lines opened a second gap: the manifest report then
asserted that something survived, so a file with only bad lines crashed a debug build (and a release build silently printed an empty report). Now it says "nothing to manifest" and returns, the same way the diff report already did:Only the agent itself writes this file, so this takes a truncated or corrupted record, not an attacker. It matters more once the report is machine-readable (#41), where a phantom removal could be acted on.
How you'd catch me lying, without reading C.
tests/unit/simulate_mode_testfeedsx,bad,,,,bad,,,r,,1.0,and a validi,foo,1.2.3,and checks that the diff report saysPackage 'foo [1.2.3]' would be installedand nothing aboutbador a removal; a second test does the same for the manifest report; a third feeds onlyx,bad,,and an empty line to the manifest report and checks that it returns, logs the two rejections and reports no package. On the unfixed code (asserts off) the first two fail withPackage 'bad' would be removed/would be absentin the captured output, and with asserts on the third aborts on the old assertion (shown above); on the fixed code all five tests pass. Both runs were done with the library rebuilt in between.🤖 Generated with Claude Code