Skip to content
Detection & ResponseMarkdown

Watch another folder on your devices

Add a folder of your own to file integrity for every device in the realm, through the shared configuration, and see a change in it reported.

API

Your billing service keeps its settings in /opt/billing/config on each server, and a change there that nobody recorded is something you want to hear about. File integrity watches the system’s own folders out of the box; you add yours once, in the configuration every sensor in the realm shares, and each device picks it up by itself.

  • You are an administrator of the realm, in a group holding RealmOwner, with your session in $CVYUH_SESSION (Call the API), and jq to edit the configuration.
  • The realm has enrolled devices, with the folder on them (see Device records). A device starts watching a folder in real time only if the folder is there when the change arrives.
  1. Read the shared configuration, and keep it as it is, to put back later if you need to:

    Terminal window
    curl https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/group/configuration \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" > held.json

    It holds the configuration’s text, xml, and the revision you read it at.

  2. Add a block for the folder after what’s there. The text can hold any number of <agent_config> blocks, so what was there stays as it was:

    Terminal window
    jq --arg dir /opt/billing/config '{revision, xml: (.xml + "\n<agent_config>\n <syscheck>\n <directories realtime=\"yes\" check_all=\"yes\">" + $dir + "</directories>\n </syscheck>\n</agent_config>\n")}' \
    held.json > written.json

    realtime="yes" reports a change as it happens, and check_all="yes" records every checksum, the owner and the permissions. Every setting you can use is in the Configuration reference.

  3. Write it back, with the revision you read:

    Terminal window
    curl -X PUT https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/group/configuration \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d @written.json

    The answer is the configuration’s new revision. It goes out to every device in the realm over each device’s own connection, and each sensor reloads with it, usually within two minutes. A device that’s offline gets it when it reconnects.

Ask one device’s sensor (by its sensor id, from the sensors list), which folders its file monitor watches now:

Terminal window
curl https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/agents/<sensor id>/configuration/files \
-H "Cookie: x-cvyuh-token=$CVYUH_SESSION"

files.directories lists /opt/billing/config once the device has reloaded. If it doesn’t after two minutes, restart the sensor (Sensor actions); if the folder didn’t exist when the sensor started, create it first. Change a file in the folder on that device, and the change appears in the device’s file change alerts, as Security events with preset=fim.

Read the configuration again for its new revision, and write back the text you kept in held.json with it:

Terminal window
curl https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/group/configuration \
-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" > now.json
jq --slurpfile was held.json '{revision, xml: $was[0].xml}' now.json > undone.json
curl -X PUT https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/group/configuration \
-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
-H "Content-Type: application/json" \
-d @undone.json