Skip to content

Add silence attribute to changes body promises (CFE-159)#22

Open
nickanderson wants to merge 2 commits into
masterfrom
CFE-159-silent-changes
Open

Add silence attribute to changes body promises (CFE-159)#22
nickanderson wants to merge 2 commits into
masterfrom
CFE-159-silent-changes

Conversation

@nickanderson

Copy link
Copy Markdown
Owner

Review PR — targets this fork's master for a clean look at the change. The real PR will be opened against cfengine/core upstream.

What

Adds a silence attribute to body changes: a list of change categories whose alert output is suppressed, while classes and the persistent audit log are preserved.

body changes quiet
{
    report_changes => "all";
    silence        => { "content", "perms" };   # or { "all" }
}

Categories: content, add, remove, owner, group, perms, device, mtime, inode, all.

  • Silences the INFO/NOTICE alert and the RecordChange syslog line for the listed categories.
  • Preserves regardless of silence: the persistent audit log (file_changes.log), the checksum_alerts class, the if_changed/if_repaired outcome classes, and the promise's repaired result.
  • Errors (LOG_LEVEL_ERR) are never silenced.
  • Unknown categories emit a warning with a promise reference.

Implementation

  • libpromises/cf3.defs.hFileChangeSilence bitmask enum + silence field.
  • libpromises/mod_files.csilence constraint (string list).
  • libpromises/attributes.c — table-driven parse of the category list.
  • cf-agent/files_changes.c, cf-agent/verify_files_utils.c — gate the alert/RecordChange on silence while always writing the audit log and preserving classes/outcome.

Validation (rebased on upstream/master 7fa5494ca)

  • Static check (tests/static-check/run_checks.sh): gcc + clang -Werror -Wall -Wextra builds + exhaustive cppcheck — clean, no findings.
  • Unit tests (make check): pass.
  • Acceptance: new tests/acceptance/10_files/02_maintain/changes_silent.cf passes; 10_files subsystem green (one unrelated libxml2-version-sensitive XML-edit test aside); 10_files unsafe/immutable 24/24.

🤖 Generated with Claude Code

Comment thread cf-agent/files_changes.c Fixed
Comment thread cf-agent/files_changes.c
{
Log(LOG_LEVEL_VERBOSE, "Preceding promise '%s'", pp->comment);
Log(LOG_LEVEL_INFO, "Hash '%s' for '%s' changed!", HashNameFromId(type), filename);
if (pp->comment)
Comment thread cf-agent/files_changes.c
Log(LOG_LEVEL_INFO, "Hash '%s' for '%s' changed!", HashNameFromId(type), filename);
if (pp->comment)
{
Log(LOG_LEVEL_VERBOSE, "Preceding promise '%s'", pp->comment);
Comment thread cf-agent/files_changes.c
}
else
{
SetPromiseOutcomeClasses(ctx, PROMISE_RESULT_CHANGE, &(attr->classes));
Comment thread cf-agent/files_changes.c
}
else
{
SetPromiseOutcomeClasses(ctx, PROMISE_RESULT_CHANGE, &(attr->classes));
Comment thread cf-agent/files_changes.c
}
else
{
SetPromiseOutcomeClasses(ctx, PROMISE_RESULT_CHANGE, &(attr->classes));
Comment thread cf-agent/files_changes.c
if (!IsChangeSilenced(attr, FILE_CHANGE_SILENCE_DEVICE))
{
Log(LOG_LEVEL_NOTICE, "Device for '%s' changed %ju -> %ju",
file, (uintmax_t) cmpsb.st_dev, (uintmax_t) sb->st_dev);
Comment thread cf-agent/files_changes.c
}
else
{
SetPromiseOutcomeClasses(ctx, PROMISE_RESULT_CHANGE, &(attr->classes));
Comment thread cf-agent/files_changes.c
if (!IsChangeSilenced(attr, FILE_CHANGE_SILENCE_INODE))
{
Log(LOG_LEVEL_NOTICE, "inode for '%s' changed %ju -> %ju",
file, (uintmax_t) cmpsb.st_ino, (uintmax_t) sb->st_ino);
Comment thread cf-agent/files_changes.c
}
else
{
SetPromiseOutcomeClasses(ctx, PROMISE_RESULT_CHANGE, &(attr->classes));
@nickanderson
nickanderson force-pushed the CFE-159-silent-changes branch from 8c57dab to 5350cb7 Compare July 21, 2026 21:06
The `silence` attribute on `body changes` takes a list of change
categories (content, add, remove, owner, group, perms, device, mtime,
inode, or all) whose alert output is suppressed. A silenced category no
longer emits its INFO/NOTICE alert or the RecordChange syslog line, but
the persistent audit log (file_changes.log), the checksum_alerts class,
and the promise outcome classes (if_changed/if_repaired) are all still
recorded. Errors are never silenced.

Ticket: CFE-159
Changelog: Added the `silence` attribute to `body changes`, which suppresses alert output for selected file-change categories while still recording the change classes and the persistent audit log.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nickanderson
nickanderson force-pushed the CFE-159-silent-changes branch from 5350cb7 to a233ef4 Compare July 21, 2026 21:12
CodeQL's cpp/missing-argument-null-check flagged several parameters that
are dereferenced without an explicit null-check in functions touched by
this branch. Add assert() guards documenting the non-null contract, the
same convention neighbouring functions already use (e.g. VerifyDelete's
existing assert(attr != NULL)).

- libpromises/attributes.c: GetContextConstraints() - pp
- cf-agent/verify_files_utils.c: SourceSearchAndCopy() - attr
- cf-agent/verify_files_utils.c: VerifyDelete() - sb
- cf-agent/verify_files_utils.c: VerifyFileAttributes() - dstat

Ticket: CFE-159
Changelog: None
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

2 participants