Repository navigation
Conversation
Added the reactor tests to jenkins, to be able to run them in jenkins. This means we can test cf-reactor on all the different platforms. Signed-off-by: Victor Moene <victor.moene@northern.tech>
Made the logs prettier and added a log file where the xtrace is printed Signed-off-by: Victor Moene <victor.moene@northern.tech>
The guest environment cannot contain "-". On hosts containing "-", the promise fails. The host name is now canonofied. Signed-off-by: Victor Moene <victor.moene@northern.tech>
X509_get_subject_name() now returns a const name. Build a new X509_NAME and set it as both subject and issuer instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Tests that print Pass message but have logs errors will fail with `FAIL (Error printed)` message. Tests which are expected to log errors should use `.error.cf` or `.error.pass.cf` suffix. see: `tests/acceptance/README` Ticket: CFE-3041 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
These tests read files created by their own init bundle, but pre-evaluation calls the read functions before the files exist, logging "Could not examine file" errors which now fail regular tests. Ticket: CFE-3041 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
Errors printed by the command were reported on lines starting with "error:", so testall mistook them for errors of the test itself. Ticket: CFE-3041 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
These tests read files and directories created by their own policy, but pre-evaluation calls the functions before they exist, logging errors which now fail regular tests. Ticket: CFE-3041 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
The agent loads def.json from the directory of the input policy file, so tests in 00_basics/ tried to read this directory as their augments file and logged "Could not open JSON file" errors. Ticket: CFE-3041 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
The test used the 'immediate' body from plucked.sub.cf before it was loaded during pre-evaluation, so the promise is now skipped until the test framework is loaded. Ticket: CFE-3041 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
The test referred to a promise module which never existed and did not run its init and cleanup bundles. Ticket: CFE-3041 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
The check bundle counted lines in files which do not exist until the test bundle has run, but the agent evaluates the functions of all promises before any bundle runs. Ticket: CFE-3041 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
wrong-bundle-type.cf printed the sub-agent output in its DEBUG report, so the sub-agent errors were mistaken for errors of the test, and ifelse.cf used invalid class expressions as false conditions. Ticket: CFE-3041 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
These tests intentionally exercise error paths, the reason is documented in the header of each test. Ticket: CFE-3041 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
Ticket: CFE-3041 Signed-off-by: Nick Anderson <nick@cmdln.org>
Ticket: CFE-3041 Signed-off-by: Nick Anderson <nick@cmdln.org>
Ticket: CFE-3041
The errorpass branch only checked for logged errors and the Pass message, so a test marked test_soft_fail or test_skip_unsupported was reported as FAIL (e.g. process_select_fncalls.error.pass.cf on Windows, which soft fails due to ENT-10217 and logs no errors there). Errorpass tests now go through the regular outcome handling and only differ in requiring at least one logged error on Pass.
Ticket: CFE-3041 Signed-off-by: Nick Anderson <nick@cmdln.org>
Signed-off-by: Dhanraj E <dhanraj@labs.digiscrypt.com>
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
…ptions() public Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
The test promised the current user with policy "present" and expected the promise to be kept. For an existing user, "present" also means "not locked". When run as root, cf-reactor can read /etc/shadow, and if the account's password hash starts with '!' (as root's does on some systems), it is considered locked and gets unlocked. The promise was then repaired instead of kept, and the test modified the root account. As a normal user, /etc/shadow is unreadable, so the account was considered unlocked and the test passed. Instead, we modify the policy to always return "kept" Signed-off-by: Victor Moene <victor.moene@northern.tech>
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
…be created Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
…per.c Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Fixed build against OpenSSL 4
ENT-14766: Prepared cf-reactor event types for package events
ENT-14766: Moved package module wrapper from cf-agent to libpromises
Ticket: ENT-14765 Changelog: `cf-reactor` can now react to a user being added or removed, with the `user_added` and `user_removed` attributes of `when` bodies Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
CFE-3041: Made testall fail regular acceptance tests which log errors
…Jenkins Added reactor tests to make check
ENT-14765: cf-reactor: Added user_added and user_removed events
…-path-overflow fix stack buffer overflow in SaveAsFile backup path construction
Codex Review SummaryThis 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. |
A def.json file containing a JSON null crashed cf-promises and cf-agent
with SIGSEGV. All of these are valid JSON and all crashed:
{"vars": {"k": null}}
{"variables": {"k": null}}
{"classes": {"k": null}}
JsonPrimitiveToString() returns NULL for JSON_PRIMITIVE_TYPE_NULL. For
"vars" and "variables" the NULL was passed straight to
EvalContextVariablePut*(), which reaches xstrdup(); for "classes" it was
passed to CheckContextClassmatch(). Both dereference it. The Log() calls
in between also passed the NULL to a '%s' conversion, which is undefined
behaviour in its own right. The object form of a class specification
crashed the same way when "class_expressions" was any non-null primitive (a
string, number or bool), or a JSON null while "regular_expressions" was set:
JsonIteratorInit() was called on the element, and iterating a primitive is
undefined.
Reject a null per entry with an error naming the variable or class, and
let the loading continue with the remaining entries, the way invalid
input is already handled elsewhere in LoadAugmentsData(). For the class
object form, pick whichever of "class_expressions" and
"regular_expressions" is not a JSON null, and require a JSON array or
object before iterating. An object is still accepted, as before.
Lists that contain a null are left alone: they never crashed, and
RlistFromContainer() installing ["a", null] as a one-element slist (in
"vars", "variables" and "inputs" alike) is pre-existing behaviour this
change keeps.
Changelog: Title
Ticket: none
Signed-off-by: Daniel JB Clark <djbclark@gmail.com>
djbclark
force-pushed
the
fix/def-json-null-crash-r3
branch
from
November 1, 2026 18:21
a33ade7 to
574d5aa
Compare
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.
JsonPrimitiveToString()returns NULL for a JSON null. InLoadAugmentsData()that NULL went toEvalContextVariablePut*()for anullinvarsor a barenullinvariables, and toCheckContextClassmatch()for anullinclasses; cf-promises andcf-agent segfaulted. The class object form crashed too:
JsonIteratorInit()was called on whateverclass_expressions/regular_expressionscontained, so{"classes":{"c":{"class_expressions":null,"regular_expressions":["any"]}}}and
{"classes":{"c":{"class_expressions":"any"}}}both died withSIGSEGV (iterating a JSON primitive is undefined; a number or bool did
the same).
Nulls are now rejected per entry with an error naming the variable or
class. The class object form picks whichever of the two keys is not a
JSON null and requires a JSON array or object before iterating; an
object value is still accepted, as before. Lists that contain a null are
deliberately untouched, in
vars,variablesandinputsalike: theynever crashed, and
["a", null]installing the one-element slist{"a"}is the upstream/master behaviour this branch keeps.
{"value": null}invariableswas already rejected ("Missing value") and stays so; the newtest pins it.
Fixes #22
Also #61 (class object form crash)
Measured on the exact head 574d5aa (one
commit on upstream/master 5ac9805):
37 pass, 0 fail, 1 soft failure (pre-existing augments_classes
CFE-2956), null_values.cf passes.
rc=0, simulate_mode_test 5/5, 29_simulate_mode 7/7, own dir
00_basics/def_json 26 pass / 0 fail / 1 soft failure (same CFE-2956).
generic_agent.c is upstream/master's, when the class check is the
array-only one (the object-valued
class_expressionscase is rejected),when the check is removed (the string, number and bool cases crash), and
when only strings are rejected (the number and bool cases crash).
\N*and has notrailing
.*, so an unexpected extra error between them, an unwantednull_classclass or adef.null_value_objectvariable fails it.cfengine format --checkclean on the new test file and its JSON.Adversary review (omp Claude Opus 5.5, read-only), on the exact head: APPROVE, no P0-P2 (earlier rounds: BLOCK on 51a731c for rejecting object-valued class_expressions, fixed; APPROVE on a33ade7). One P3: a primitive
regular_expressionswith noclass_expressionsalso crashed upstream and is fixed by the same check, but the commit body does not name it and the test has no entry for it.🤖 Generated with Claude Code