Skip to content

Reload agent labels on agent reload#32838

Merged
vikman90 merged 2 commits into
4.14.1from
fix/32817-agent-labels-reload
Oct 29, 2025
Merged

Reload agent labels on agent reload#32838
vikman90 merged 2 commits into
4.14.1from
fix/32817-agent-labels-reload

Conversation

@vikman90
Copy link
Copy Markdown
Member

@vikman90 vikman90 commented Oct 27, 2025

Description

This pull request addresses issue #32817 by ensuring agent labels are reloaded when the agent reloads, alongside the client buffer reload.

Proposed Changes

  • Added the reload of agent labels in the agent reload flow for both UNIX and Windows.
  • Ensured labels are refreshed immediately after a configuration change via the interface.

Results and Evidence

This is the base configuration:

{
  "data": {
    "labels": [
      {
        "value": "Value A",
        "key": "A",
        "hidden": "no"
      }
    ]
  },
  "error": 0
}

After modifying agent.conf through the interface (XML):

<labels>
  <label key="b">Value B</label>
</labels>

Then the agent log shows a reload event:

2025/10/27 13:07:57 wazuh-agentd: INFO: Agent is reloading due to shared configuration changes.
2025/10/27 13:08:05 wazuh-agentd: INFO: SIGNAL [(10)-(User defined signal 1)] Received. Reload agentd.

A subsequent configuration query returns the expected label information in JSON format:

{
  "data": {
    "labels": [
      {
        "value": "Value A",
        "key": "A",
        "hidden": "no"
      },
      {
        "value": "Value B",
        "key": "b",
        "hidden": "no"
      }
    ]
  },
  "error": 0
}

Additionally, the alerts show the updated labels set:

Alert
{
  "_index": "wazuh-alerts-4.x-2025.10.27",
  "_id": "ike4JZoBnkVPBbkqnR0l",
  "_version": 1,
  "_score": null,
  "_source": {
    "syscheck": {
      "uname_after": "root",
      "mtime_after": "2025-05-07T08:23:19",
      "size_after": "55",
      "gid_after": "0",
      "mode": "realtime",
      "path": "/root/test/s6/aarch64/command/seekablepipe",
      "sha1_after": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
      "gname_after": "root",
      "uid_after": "0",
      "perm_after": "rwxrwxrwx",
      "event": "deleted",
      "md5_after": "d41d8cd98f00b204e9800998ecf8427e",
      "sha256_after": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
      "inode_after": 393964
    },
    "input": {
      "type": "log"
    },
    "agent": {
      "ip": "127.0.0.1",
      "name": "Rocket-old",
      "id": "002",
      "labels": {
        "A": "Value A",
        "b": "Value B"
      }
    },
    "manager": {
      "name": "wazuh.manager"
    },
    "rule": {
      "mail": false,
      "level": 7,
      "pci_dss": [
        "11.5"
      ],
      "hipaa": [
        "164.312.c.1",
        "164.312.c.2"
      ],
      "tsc": [
        "PI1.4",
        "PI1.5",
        "CC6.1",
        "CC6.8",
        "CC7.2",
        "CC7.3"
      ],
      "description": "File deleted.",
      "groups": [
        "ossec",
        "syscheck",
        "syscheck_entry_deleted",
        "syscheck_file"
      ],
      "nist_800_53": [
        "SI.7"
      ],
      "gdpr": [
        "II_5.1.f"
      ],
      "firedtimes": 835,
      "mitre": {
        "technique": [
          "File Deletion",
          "Data Destruction"
        ],
        "id": [
          "T1070.004",
          "T1485"
        ],
        "tactic": [
          "Defense Evasion",
          "Impact"
        ]
      },
      "id": "553",
      "gpg13": [
        "4.11"
      ]
    },
    "location": "syscheck",
    "decoder": {
      "name": "syscheck_deleted"
    },
    "id": "1761569447.2887016",
    "full_log": "File '/root/test/s6/aarch64/command/seekablepipe' deleted\nMode: realtime\n",
    "timestamp": "2025-10-27T12:50:47.002+0000"
  },
  "fields": {
    "syscheck.mtime_after": [
      "2025-05-07T08:23:19.000Z"
    ],
    "timestamp": [
      "2025-10-27T12:50:47.002Z"
    ]
  },
  "sort": [
    1761569447002
  ]
}

Artifacts Affected

  • wazuh-agentd (UNIX)
  • wazuh-agent.exe (Windows)

Configuration Changes

No configuration changes required.

Documentation Updates

Not applicable.

Tests Introduced

This functionality should be validated through system tests.

  • Valgrind
  • ThreadSanitizer

Valgrind

==67886== LEAK SUMMARY:
==67886==    definitely lost: 0 bytes in 0 blocks
==67886==    indirectly lost: 0 bytes in 0 blocks
==67886==      possibly lost: 1,152 bytes in 4 blocks
==67886==    still reachable: 51,900 bytes in 57 blocks
==67886==         suppressed: 0 bytes in 0 blocks

Review Checklist

  • Code changes reviewed
  • Relevant evidence provided
  • Tests cover the new functionality
  • Configuration changes documented
  • Developer documentation reflects the changes
  • Meets requirements and/or definition of done
  • No unresolved dependencies with other issues

@vikman90 vikman90 requested review from MarcelKemp and cborla October 27, 2025 12:25
@vikman90 vikman90 self-assigned this Oct 27, 2025
@vikman90 vikman90 added type/bug Something isn't working module/agent Issues related to the agent daemon labels Oct 27, 2025
@vikman90 vikman90 changed the base branch from main to 4.14.1 October 27, 2025 12:27
@vikman90 vikman90 force-pushed the fix/32817-agent-labels-reload branch from 8b48837 to fa20724 Compare October 27, 2025 14:48
Copy link
Copy Markdown
Member

@MarcelKemp MarcelKemp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Comment thread src/client-agent/agentd.c
Copy link
Copy Markdown
Member

@cborla cborla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGMT

  • Code changes reviewed
  • Relevant evidence provided
  • Tests cover the new functionality
  • Configuration changes documented
  • Developer documentation reflects the changes
  • Meets requirements and/or definition of done
  • No unresolved dependencies with other issues

@vikman90 vikman90 force-pushed the fix/32817-agent-labels-reload branch from fa20724 to b28855c Compare October 27, 2025 16:22
@vikman90 vikman90 merged commit ee0e1f9 into 4.14.1 Oct 29, 2025
30 checks passed
@vikman90 vikman90 deleted the fix/32817-agent-labels-reload branch October 29, 2025 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module/agent Issues related to the agent daemon type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<labels> configuration not applied during agent hot reload via Centralized configuration

3 participants