[comment]: # translation:outdated

[comment]: # ({780b1aa2-780b1aa2})
# 13 Controles van agenten beperken

[comment]: # ({/780b1aa2-780b1aa2})

[comment]: # ({524ddb26-9de656b2})
#### Overzicht

Het is mogelijk om controles aan de agentzijde te beperken door een lijst met items op de zwarte lijst, een witte lijst, of een combinatie van beide te maken.

Gebruik daarvoor een combinatie van twee agent [configuratie](/manual/appendix/config/zabbix_agentd) parameters:

- `AllowKey=<patroon>` - welke controles zijn toegestaan; `<patroon>` wordt gespecificeerd met behulp van een wildcard (\*) expressie.
- `DenyKey=<patroon>` - welke controles zijn verboden; `<patroon>` wordt gespecificeerd met behulp van een wildcard (\*) expressie.

Merk op dat:

- Alle `system.run[*]` items (op afstand uitgevoerde commando's, scripts) standaard zijn uitgeschakeld, zelfs wanneer er geen verboden sleutels zijn gespecificeerd.
- Sinds Zabbix 5.0.2 is de agentparameter EnableRemoteCommands:
  - Verouderd door de Zabbix-agent
  - Niet-ondersteund door Zabbix agent2

Daarom, om op afstand uitgevoerde commando's toe te staan, specificeert u een AllowKey=system.run[\<commando\>,\*] voor elk toegestaan commando, waarbij \* staat voor de wacht- en nowait-modus. Het is ook mogelijk om de AllowKey=system.run[\*] parameter te specificeren om alle commando's met wacht- en nowait-modi toe te staan. Om specifieke op afstand uitgevoerde commando's te verbieden, voegt u DenyKey parameters toe met system.run\[\] commando's vóór de AllowKey=system.run\[\*\] parameter.

[comment]: # ({/524ddb26-9de656b2})

[comment]: # ({3145c750-3145c750})
#### Belangrijke regels

- Een witte lijst zonder een verbodregel is alleen toegestaan voor system.run\[\*\] items. Voor alle andere items zijn AllowKey parameters niet toegestaan zonder een DenyKey parameter; in dit geval **start de Zabbix-agent niet** met alleen AllowKey parameters.
- De volgorde is belangrijk. De gespecificeerde parameters worden één voor één gecontroleerd volgens hun volgorde in het configuratiebestand:
  - Zodra een item sleutel overeenkomt met een toestaan/verbied regel, wordt het item ofwel toegestaan of verboden; en het controleren van de regels stopt. Als een item dus zowel overeenkomt met een toestaan-regel als een verbied-regel, is het resultaat afhankelijk van welke regel als eerste voorkomt.
  - De volgorde heeft ook invloed op de EnableRemoteCommands parameter (indien gebruikt).
- Er worden een onbeperkt aantal AllowKey/DenyKey parameters ondersteund.
- AllowKey, DenyKey regels hebben geen invloed op de HostnameItem, HostMetadataItem, HostInterfaceItem configuratieparameters.
- Sleutelpatroon is een wildcard-expressie waarbij het wildcard (\*) karakter overeenkomt met elk aantal willekeurige tekens op bepaalde posities. Het kan worden gebruikt in zowel de sleutelnaam als de parameters.
- Als een specifieke itemsleutel wordt verboden in de agentconfiguratie, wordt het item als niet-ondersteund gerapporteerd (geen hint wordt gegeven over de reden).
- Zabbix-agent met de --print (-p) command line optie zal sleutels die niet zijn toegestaan door de configuratie niet tonen.
- Zabbix-agent met de --test (-t) command line optie zal een "Niet-ondersteunde itemsleutel." status retourneren voor sleutels die niet zijn toegestaan door de configuratie.
- Geweigerde externe commando's worden niet gelogd in het agent logboek (indien LogRemoteCommands=1).

[comment]: # ({/3145c750-3145c750})

[comment]: # ({new-66ec4bb8})
#### Allow/deny rule order

You can specify an unlimited number of `AllowKey` or `DenyKey` rules, though their order matters.

-   Rules are evaluated one by one, from top to bottom.
-   When an item key matches a rule, it is either allowed or denied, and rule evaluation stops.

For example, when evaluating `vfs.file.contents[/etc/passwd]`, the rules are processed as follows:

```default
AllowKey=vfs.file.contents[/tmp/app.log]    # Item key pattern does not match, agent proceeds to the next rule.
AllowKey=vfs.file.contents[/etc/passwd]     # Item key pattern matches; agent allows the item check and stops rule evaluation.
DenyKey=vfs.file.*[*]                       # Agent ignores the rule, as the evaluation has stopped.
```

The following rule order will deny the item check:

```default
DenyKey=vfs.file.*[*]                       # Item key pattern matches; agent denies the item check and stops rule evaluation.
AllowKey=vfs.file.contents[/etc/passwd]     # Agent ignores the rule, as the evaluation has stopped.
AllowKey=vfs.file.contents[/tmp/app.log]    # Agent ignores the rule, as the evaluation has stopped.
```

[comment]: # ({/new-66ec4bb8})

[comment]: # ({253ad144-253ad144})
#### Gebruikscenario's

[comment]: # ({/253ad144-253ad144})

[comment]: # ({new-19895d10})
##### Allowing specific checks and commands

Allow only two [`vfs.file`](/manual/config/items/itemtypes/zabbix_agent#virtual-file-system-data) item checks and two [`system.run`](/manual/config/items/itemtypes/zabbix_agent#system-data) commands:

```default
AllowKey=vfs.file.contents[/tmp/app.log]
AllowKey=vfs.file.size[/tmp/app.log]
AllowKey=system.run[/usr/bin/uptime]
AllowKey=system.run[/usr/bin/df -h /]
DenyKey=vfs.file.*[*]
```

::: noteclassic
Setting `DenyKey=system.run[*]` is unnecessary, because all other `system.run` commands are denied by default.
:::

[comment]: # ({/new-19895d10})

[comment]: # ({new-3cc5f239})
##### Allowing scripts

Allow Zabbix agent to execute scripts on hosts via all available methods:

-   [Global scripts](/manual/web_interface/frontend_sections/administration/scripts) that can be executed in the frontend or via API (this method always uses the `system.run[myscript.sh]` key)
-   Remote commands from [action operations](/manual/config/notifications/action/operation#operation-details) (this method always uses the `system.run[myscript.sh,nowait]` key)
-   [`system.run`](/manual/config/items/itemtypes/zabbix_agent#system-data) Zabbix agent items with the script, for example:
    -   `system.run[myscript.sh]`
    -   `system.run[myscript.sh,wait]`
    -   `system.run[myscript.sh,nowait]`

```default
AllowKey=system.run[myscript.sh,*]
```

To control the `wait`/`nowait` parameter, you must set a different rule.
For example, you can allow only `system.run[myscript.sh,wait]` items, thus excluding other methods:

```default
AllowKey=system.run[myscript.sh,wait]
```

[comment]: # ({/new-3cc5f239})

[comment]: # ({new-1965a7d7})
##### Securing allow/deny rules

This example shows how to secure overly permissive `AllowKey` or `DenyKey` rules.

Consider the following rules:

```default
AllowKey=system.run["C:\Program^ Files\Zabbix^ Agent^ 2\scripts\test.bat*"]
DenyKey=vfs.file.*
DenyKey=system.cpu.load[*]
```

::: noteclassic
On Windows, you must escape spaces in the path using a caret (`^`).
:::

These rules contain a wildcard (`*`), which can be misused:

-   The `test.bat` script can be executed with any arguments, including unintended ones.
-   The `vfs.file.*` pattern matches only item keys without parameters; however, all [`vfs.file`](/manual/config/items/itemtypes/zabbix_agent#virtual-file-system-data) items require parameters.
-   The `system.cpu.load[*]` pattern matches only item keys with parameters; however [`system.cpu.load`](/manual/config/items/itemtypes/zabbix_agent#system-data) items do not require parameters.

To secure these rules, explicitly allow executing `test.bat` only with specific arguments, and deny correct item key patterns; for example:

```default
AllowKey=system.run["C:\Program^ Files\Zabbix^ Agent^ 2\scripts\test.bat status"]
AllowKey=system.run["C:\Program^ Files\Zabbix^ Agent^ 2\scripts\test.bat version"]
DenyKey=vfs.file.*[*]
DenyKey=system.cpu.load
DenyKey=system.cpu.load[*]
```

You can test the rules by running the following commands, which will return `ZBX_NOTSUPPORTED`.

```bash
cd "C:\Program Files\Zabbix Agent 2"
zabbix_agent2.exe -t system.run["C:\Program^ Files\Zabbix^ Agent^ 2\scripts\test.bat debug"]
zabbix_agent2.exe -t vfs.file.size["C:\ProgramData\MyApp\config.ini"]
zabbix_agent2.exe -t vfs.file.contents["C:\Windows\System32\drivers\etc\hosts"]
zabbix_agent2.exe -t system.cpu.load
zabbix_agent2.exe -t system.cpu.load[all,avg1]
```

[comment]: # ({/new-1965a7d7})

[comment]: # ({c560adaf-16bccaff})
#### Patroonvoorbeelden

|Patroon|Beschrijving|Overeenkomsten|Geen overeenkomst|
|--|------|--|--|
|*\**|Komt overeen met alle mogelijke sleutels met of zonder parameters.|Elk|Geen|
|*vfs.file.contents*|Komt overeen met `vfs.file.contents` zonder parameters.|vfs.file.contents|vfs.file.contents\[/etc/passwd\]|
|*vfs.file.contents\[\]*|Komt overeen met `vfs.file.contents` met lege parameters.|vfs.file.contents\[\]|vfs.file.contents|
|*vfs.file.contents\[\*\]*|Komt overeen met `vfs.file.contents` met willekeurige parameters; komt niet overeen met `vfs.file.contents` zonder vierkante haken.|vfs.file.contents\[\]<br>vfs.file.contents\[/pad/naar/bestand\]|vfs.file.contents|
|*vfs.file.contents\[/etc/passwd,\*\]*|Komt overeen met `vfs.file.contents` waarvan de eerste parameters overeenkomen met /etc/passwd en alle andere parameters een willekeurige waarde hebben (ook leeg).|vfs.file.contents\[/etc/passwd,\]<br>vfs.file.contents\[/etc/passwd,utf8\]|vfs.file.contents\[/etc/passwd\]<br>vfs.file.contents\[/var/log/zabbix\_server.log\]<br>vfs.file.contents\[\]|
|*vfs.file.contents\[\*passwd\*\]*|Komt overeen met `vfs.file.contents` waarvan de eerste parameter overeenkomt met \*passwd\* en geen andere parameters heeft.|vfs.file.contents\[/etc/passwd\]|vfs.file.contents\[/etc/passwd,\]<br>vfs.file.contents\[/etc/passwd, utf8\]|
|*vfs.file.contents\[\*passwd\*,\*\]*|Komt overeen met `vfs.file.contents` waarvan alleen de eerste parameter overeenkomt met \*passwd\* en alle volgende parameters een willekeurige waarde hebben (ook leeg).|vfs.file.contents\[/etc/passwd,\]<br>vfs.file.contents\[/etc/passwd, utf8\]|vfs.file.contents\[/etc/passwd\]<br>vfs.file.contents\[/tmp/test\]|
|*vfs.file.contents\[/var/log/zabbix\_server.log,\*,abc\]*|Komt overeen met `vfs.file.contents` waarvan de eerste parameter overeenkomt met /var/log/zabbix\_server.log, de derde parameter overeenkomt met 'abc' en een willekeurige (ook lege) tweede parameter heeft.|vfs.file.contents\[/var/log/zabbix\_server.log,,abc\]<br>vfs.file.contents\[/var/log/zabbix\_server.log,utf8,abc\]|vfs.file.contents\[/var/log/zabbix\_server.log,,abc,def\]|
|*vfs.file.contents\[/etc/passwd,utf8\]*|Komt overeen met `vfs.file.contents` waarvan de eerste parameter overeenkomt met /etc/passwd, de tweede parameter overeenkomt met 'utf8' en geen andere argumenten heeft.|vfs.file.contents\[/etc/passwd,utf8\]|vfs.file.contents\[/etc/passwd,\]<br>vfs.file.contents\[/etc/passwd,utf16\]|
|*vfs.file.\**|Komt overeen met alle sleutels die beginnen met `vfs.file.` zonder enige parameters.|vfs.file.contents<br>vfs.file.size|vfs.file.contents\[\]<br>vfs.file.size\[/var/log/zabbix\_server.log\]|
|*vfs.file.\*\[\*\]*|Komt overeen met alle sleutels die beginnen met `vfs.file.` met willekeurige parameters.|vfs.file.size.bytes\[\]<br>vfs.file.size\[/var/log/zabbix\_server.log, utf8\]|vfs.file.size.bytes|
|*vfs.\*.contents*|Komt overeen met alle sleutels die beginnen met `vfs.` en eindigen met `.contents` zonder enige parameters.|vfs.mount.point.file.contents<br>vfs..contents|vfs.contents|

[comment]: # ({/c560adaf-16bccaff})
