Skip to content

eBPF-based security platform

Documentation: add a page on developing with both roles locally

Daniel Borkmann2d1742580e01
diff --git a/Documentation/contribute/develop-locally.rst b/Documentation/contribute/develop-locally.rst
new file mode 100644
index 00000000..d4a20de9
--- /dev/null
+++ b/Documentation/contribute/develop-locally.rst
@@ -0,0 +1,565 @@
+..
+ SPDX-License-Identifier: BSD-2-Clause
+ Copyright (c) 2026 Authors of shirudo
+
+:page-type: How-to
+:audience: shirudo contributors
+
+Develop locally
+===============
+
+This page sets up both roles on one machine, so that you can change
+shirudo and see the result end to end. Your host is the operator: it
+runs ``shirudo`` and ``shirudo-build`` from your checkout, a local OCI
+registry and a local OpenTelemetry Collector. The test VM is the target:
+it boots from your checkout the way a production target boots. You then
+take one package through its whole life: write it, publish it, install
+it, watch its data arrive in the collector, update it and remove it. The
+last section shows how to rebuild after a change to shirudo itself.
+
+.. list-table::
+ :header-rows: 1
+ :widths: 30 70
+
+ * - Where
+ - What runs there
+ * - Host, as the operator
+ - ``shirudo`` and ``shirudo-build`` from the checkout, the registry
+ on ``127.0.0.1:5000``, the collector on ``127.0.0.1:4318``.
+ * - Test VM, as the target
+ - The runtime image built from the checkout. It reaches the host
+ as ``10.0.2.2`` and sees the checkout as ``/workspace/shirudo``.
+
+Before you begin
+----------------
+
+- A checkout that builds, as :doc:`developer-guide` describes.
+- The test VM's prerequisites and root on the host, as
+ :doc:`/start/quickstart` lists them. Run every host command on this
+ page as root, in the root of your checkout.
+- Docker, for the registry and the collector.
+- Two terminals on the host, one of them for the collector's output.
+
+Set up the operator shell
+-------------------------
+
+1. Build ``shirudo`` and the helper:
+
+ .. code-block:: console
+
+ operator$ make
+ operator$ make shirudo-build
+
+2. Put both on the ``PATH`` of this shell, and name the helper:
+
+ .. code-block:: console
+
+ operator$ export PATH="$PWD:$PWD/tools/shirudo-build:$PATH"
+ operator$ export SHIRUDO_BUILD="$PWD/tools/shirudo-build/shirudo-build"
+
+3. Make a directory for your work. Git ignores ``build/``, and the test VM
+ sees it as ``/workspace/shirudo/build/dev``:
+
+ .. code-block:: console
+
+ operator$ DEV=$PWD/build/dev
+ operator$ mkdir -p "$DEV"
+
+Start the registry and the collector
+------------------------------------
+
+1. Run a registry on the host's loopback interface:
+
+ .. code-block:: console
+
+ operator$ docker run -d --name shirudo-registry -p 127.0.0.1:5000:5000 docker.io/library/registry:3
+
+2. Write ``build/dev/otelcol.yaml``, a collector configuration that
+ prints every record it receives:
+
+ .. code-block:: yaml
+
+ receivers:
+ otlp:
+ protocols:
+ http:
+ endpoint: 0.0.0.0:4318
+
+ exporters:
+ debug:
+ verbosity: detailed
+
+ service:
+ pipelines:
+ logs:
+ receivers: [otlp]
+ exporters: [debug]
+ metrics:
+ receivers: [otlp]
+ exporters: [debug]
+
+3. Run the collector on the host's loopback interface:
+
+ .. code-block:: console
+
+ operator$ docker run -d --name shirudo-otelcol -p 127.0.0.1:4318:4318 -v "$DEV/otelcol.yaml:/etc/otelcol-contrib/config.yaml:ro" docker.io/otel/opentelemetry-collector-contrib:0.164.0
+
+4. In the second terminal, follow what the collector receives:
+
+ .. code-block:: console
+
+ operator$ docker logs -f shirudo-otelcol
+
+ Both containers speak plain HTTP, which is safe only on your own
+ host. A production target speaks HTTPS with TLS 1.3 and a hybrid
+ ML-KEM key exchange, see :doc:`/operate/telemetry`.
+
+Boot the target
+---------------
+
+1. Boot a test VM named ``dev``:
+
+ .. code-block:: console
+
+ operator$ make -C testing vm VM_NAME=dev
+
+ The first run builds the kernel, the disk image and the bundle, which
+ takes a while. :doc:`testing` describes the test VM.
+
+2. Name the bundle's signing key in the operator shell:
+
+ .. code-block:: console
+
+ operator$ KEYS=$PWD/build/test-vm/host-bundle-bpf-next-verity.operator/keys
+
+ The test VM trusts this key for upatches and config images. The
+ bundle generates a new one every time it is rebuilt.
+
+3. Open a root shell on the target:
+
+ .. code-block:: console
+
+ operator$ make -C testing vm-ssh VM_NAME=dev
+
+4. Make ``shirudo`` name the trusted binary in this shell:
+
+ .. code-block:: console
+
+ target# alias shirudo=shirudo-runtime
+
+ ``shirudo-runtime`` runs the binary on the runtime image, the only
+ one the target lets read and change shirudo's state, see
+ :ref:`runtime-invocation`.
+
+Connect the target to the registry and the collector
+----------------------------------------------------
+
+A target reads its repositories and its export destination from the
+signed config image, not from files on its root file system (see
+:doc:`/operate/deliver-packages`). Build a config that adds both, starting
+from the config the target runs, and activate it.
+
+1. On the target, copy the running config into the VM's result share:
+
+ .. code-block:: console
+
+ target# mkdir /mnt/shirudo-out/config-root
+ target# cp -a /run/shirudo/config/etc /run/shirudo/config/keys /mnt/shirudo-out/config-root/
+
+ The host sees the share as ``build/test-vm/vms/dev/result/``.
+
+2. On the host, take the copy as the source of the new config:
+
+ .. code-block:: console
+
+ operator$ cp -a build/test-vm/vms/dev/result/config-root "$DEV/config-root"
+
+3. Send the map exports and keepalives to the collector:
+
+ .. code-block:: console
+
+ operator$ printf '%s\n' 'map_export.otel_endpoint = http://10.0.2.2:4318' 'map_export.otel_insecure = true' >> "$DEV/config-root/etc/shirudo/shirudo.conf"
+
+ ``map_export.otel_insecure`` allows cleartext OTLP to a host other
+ than the target itself.
+
+4. Register the registry as the repository ``dev``, with the
+ certificate whose key signs its index:
+
+ .. code-block:: console
+
+ operator$ mkdir -p "$DEV/config-root/etc/shirudo/bpm/registries.d" "$DEV/config-root/etc/shirudo/bpm/keys"
+ operator$ printf '%s\n' 'endpoint = oci://10.0.2.2:5000' 'key_file = /etc/shirudo/bpm/keys/dev.der' > "$DEV/config-root/etc/shirudo/bpm/registries.d/dev.conf"
+ operator$ cp "$KEYS/cert.der" "$DEV/config-root/etc/shirudo/bpm/keys/dev.der"
+
+5. Build and sign the config image, and verify it:
+
+ .. code-block:: console
+
+ operator$ tools/gen-image/shirudo-gen-image --source "$DEV/config-root" --output "$DEV/config-1" --keys-dir "$KEYS" --kind config --builder "$SHIRUDO_BUILD"
+ bcca2bcd9661e77b094bd4197b335482a3a168ef693e2fc6706a37b62d0bcce9
+ operator$ shirudo image verify "$DEV/config-1" --cert "$KEYS/cert.der"
+ bcca2bcd9661e77b094bd4197b335482a3a168ef693e2fc6706a37b62d0bcce9
+
+ Both commands print the config's root hash.
+
+6. On the target, activate the config:
+
+ .. code-block:: console
+
+ target# shirudo image update /workspace/shirudo/build/dev/config-1
+ target# shirudo image status
+ {"root_hash":"bcca2bcd9661e77b094bd4197b335482a3a168ef693e2fc6706a37b62d0bcce9","pcr":14,"sequence":2,"reset_count":1,"restart_count":0,"pending":false,"consistent":true}
+ target# shirudo bpm config register list
+ dev
+
+ ``root_hash`` is the hash the host printed, ``pending`` is ``false``
+ and ``consistent`` is ``true``.
+
+7. Let the target's package commands and services reach the registry
+ over plain HTTP:
+
+ .. code-block:: console
+
+ target# mkdir -p /etc/shirudo/bpm
+ target# echo BPM_OCI_SCHEME=http > /etc/shirudo/bpm/environment
+ target# export BPM_OCI_SCHEME=http
+
+ The services read ``/etc/shirudo/bpm/environment``. Your shell needs
+ the variable as well.
+
+8. Check the collector's terminal. Every five seconds, the target's
+ keepalive timer sends a record with ``EventName:
+ shirudo.keepalive``.
+
+Write a package
+---------------
+
+The package ``exec-count`` counts program executions by command name. A
+Lua decoder turns the map into the record the target exports, the same
+way a real upatch's data reaches a collector.
+
+1. Make the package directory, with links to the checkout's headers:
+
+ .. code-block:: console
+
+ operator$ mkdir -p "$DEV/exec-count/decoders"
+ operator$ ln -s "$PWD/vendor" "$DEV/exec-count/vendor"
+ operator$ ln -s "$PWD/bpf" "$DEV/exec-count/bpf"
+
+ ``shirudo-build`` compiles in the package directory. It takes the
+ libbpf headers and ``vmlinux.h`` from ``vendor/`` and
+ ``shirudo_decoder.h`` from ``bpf/lib/``. An installed operator
+ package brings its own copies and needs no links.
+
+2. Write ``build/dev/exec-count/exec-count.bpf.c``:
+
+ .. literalinclude:: develop-locally/exec-count.bpf.c
+ :language: c
+
+ The program runs at every successful ``execve(2)`` and adds one to the
+ entry of the new command's name in the hash map ``execs``. The
+ manifest in ``.rodata`` names the Lua decoder for the map and the
+ signal it produces, a log record. :doc:`/upatches/decoders` explains
+ each field. A upatch that keeps records rather than counters keeps
+ them in an arena with a serializer, see
+ :doc:`/upatches/maps-arenas-serializers`.
+
+3. Write ``build/dev/exec-count/decoders/execs.lua``:
+
+ .. literalinclude:: develop-locally/execs-1.0.lua
+ :language: lua
+
+ The target calls ``decode`` with a snapshot of the map, each entry's
+ key and value in hex. It returns the counts by name, which become the
+ body of the log record.
+
+4. Write ``build/dev/exec-count/Beefile``:
+
+ .. code-block:: toml
+
+ [package]
+ name = "exec-count"
+ description = "Counts program executions by command name"
+ license = "GPL-2.0 OR BSD-2-Clause"
+
+ [[upatches]]
+ source = "exec-count.bpf.c"
+
+5. Write ``build/dev/exec-count/README.md``, which ``shirudo bpm info``
+ prints for whoever inspects the package:
+
+ .. code-block:: markdown
+
+ # exec-count
+
+ Counts program executions by command name. A Lua decoder exports the
+ counts as the body of one OTLP log record per snapshot of the execs map.
+
+Build and publish it
+--------------------
+
+1. Build version 1.0.0:
+
+ .. code-block:: console
+
+ operator$ (cd "$DEV" && shirudo bpm build exec-count --version 1.0.0 --keys-dir "$KEYS")
+ wrote /tmp/shirudo-bpm-build.<random>/0.upatch (insns=1664 sig=4853 data=5104 sections=3 maps=2 progs=1 decoders=1 name=exec-count)
+ wrote /tmp/shirudo-bpm-build.<random>/0.unload.upatch (insns=1320 sig=4853 data=2808 sections=2 maps=1 progs=1 decoders=0 name=exec-count UNLOAD)
+ <checkout>/build/dev/exec-count-1.0.0.bee
+
+ ``<random>`` is the suffix of a temporary directory and
+ ``<checkout>`` your checkout. The builder compiles and signs the
+ upatch with its decoder (``decoders=1``), signs an unload directive for
+ it and writes ``build/dev/exec-count-1.0.0.bee``.
+
+2. Push it to the registry and add it to the registry's signed index:
+
+ .. code-block:: console
+
+ operator$ BPM_OCI_SCHEME=http shirudo bpm push "$DEV/exec-count-1.0.0.bee" oci://127.0.0.1:5000/dev/exec-count --keys-dir "$KEYS"
+ oci://127.0.0.1:5000/dev/exec-count:1.0.0
+
+ The index holds one package per version. A package built again under
+ a version the index lists already is refused with ``bpm push: the
+ repository index already lists exec-count 1.0.0 with different
+ content``, and every build differs, since every signature does. Give
+ every change a new version.
+
+Install it
+----------
+
+1. On the target, fetch the repository's index:
+
+ .. code-block:: console
+
+ target# shirudo bpm repo update dev
+
+ The command prints nothing when it succeeds.
+
+2. Install the package from the repository:
+
+ .. code-block:: console
+
+ target# shirudo bpm install dev/exec-count
+ upatch load: --no-precheck, pre-flight state check skipped
+ loaded signed loader: prog_fd=11 keyring=335804852 sig=4853B insns=208 data=5104B
+ loader ok, retval=0 (maps=2 progs=1)
+ attached + pinned prog 0 (raw_tracepoint) -> /run/shirudo/bpffs/upatches/exec-count/link
+ pinned map 0 (execs, type=1) -> /run/shirudo/bpffs/upatches/exec-count/maps/execs
+ upatch load: name=exec-count keyring=335804852 progs=1
+ upatch load: chain extended, value=23d80b8e3a30de1d5a556616d9d3eb388bbdb4bbc97f4e9fa81311909a3437ca
+ upatch load measured: name=exec-count chain=23d80b8e3a30de1d5a556616d9d3eb388bbdb4bbc97f4e9fa81311909a3437ca
+
+ The target checks the package against the signed index, requires its
+ certificate to match the target's, and loads the upatch. The kernel
+ checks the signature, and the target measures the load.
+
+3. List the installed packages and the loaded upatches:
+
+ .. code-block:: console
+
+ target# shirudo bpm list
+ exec-count 1.0.0 dev
+ target# shirudo upatch list
+ upatches (/var/lib/shirudo/upatches):
+ loaded type kind payload-sha256 name
+ yes load bpf 00357162c0dfd6dc.. exec-count
+
+Watch the data
+--------------
+
+1. Run a few commands on the target:
+
+ .. code-block:: console
+
+ target# date; uname -a; id
+
+2. Check the collector's terminal. Every five seconds, the target's
+ map-export timer reads the map, runs the decoder and sends a record:
+
+ .. code-block:: text
+
+ LogRecord #0
+ ObservedTimestamp: 2026-10-29 23:29:10.608332126 +0000 UTC
+ Timestamp: 2026-10-29 23:29:10.608332126 +0000 UTC
+ SeverityText: INFO
+ SeverityNumber: Info(9)
+ EventName: shirudo.bpf.map.snapshot
+ Body: Map({"execs":[{"command":"modprobe","count":19},{"command":"9","count":17},{"command":"shirudo-runtime","count":16},{"command":"shirudo","count":16},{"command":"date","count":8},{"command":"uname","count":7},...]})
+ Attributes:
+ -> shirudo.upatch.name: Str(exec-count)
+ -> shirudo.upatch.location: Str(tracing/btf_trace_sched_process_exec)
+ -> shirudo.map.name: Str(execs)
+ -> shirudo.map.type: Str(hash)
+ -> shirudo.map.max_entries: Int(1024)
+ -> shirudo.map.n_entries: Int(50)
+ -> shirudo.map.n_cpus: Int(1)
+ -> shirudo.map.serialized: Bool(false)
+ -> shirudo.map.truncated: Bool(false)
+
+ The body is what the decoder returned, shortened here. It counts
+ every execution on the guest, the target's own timers included, so
+ your counts differ. The attributes name the upatch, its attach point
+ and the map, see :doc:`/reference/formats/otlp`.
+
+3. While you work on a decoder, run it by hand against the live map:
+
+ .. code-block:: console
+
+ target# shirudo upatch map exec-count execs --json --peek
+ {"execs":[{"command":"modprobe","count":16},{"command":"shirudo","count":11},{"command":"shirudo-runtime","count":11},{"command":"date","count":8},...]}
+
+ The command prints the decoder's result as one JSON document,
+ shortened here, or the decoder's error. ``--peek`` leaves a serializer-backed map undrained;
+ a hash map is never drained.
+
+Update it
+---------
+
+1. Change the decoder to report the total as well. Replace ``decode`` in
+ ``build/dev/exec-count/decoders/execs.lua``:
+
+ .. literalinclude:: develop-locally/execs-1.1.lua
+ :language: lua
+ :start-at: function decode
+
+2. Build and push version 1.1.0:
+
+ .. code-block:: console
+
+ operator$ (cd "$DEV" && shirudo bpm build exec-count --version 1.1.0 --keys-dir "$KEYS")
+ operator$ BPM_OCI_SCHEME=http shirudo bpm push "$DEV/exec-count-1.1.0.bee" oci://127.0.0.1:5000/dev/exec-count --keys-dir "$KEYS"
+ oci://127.0.0.1:5000/dev/exec-count:1.1.0
+
+3. On the target, fetch the index and upgrade:
+
+ .. code-block:: console
+
+ target# shirudo bpm repo update dev
+ target# shirudo bpm upgrade
+ upatch unload: --no-precheck, pre-flight state check skipped
+ loaded signed loader: prog_fd=11 keyring=335804852 sig=4853B insns=165 data=2808B
+ upatch unload: payload matches for 'exec-count'
+ upatch unload: chain extended, value=422dadf3d3e5b1abbc6a9257ccaabecc5259998ad2ace271b52c62a85e728602
+ upatch unload measured: name=exec-count chain=422dadf3d3e5b1abbc6a9257ccaabecc5259998ad2ace271b52c62a85e728602
+ upatch unload: detached + unpinned exec-count
+ upatch load: --no-precheck, pre-flight state check skipped
+ loaded signed loader: prog_fd=11 keyring=335804852 sig=4853B insns=208 data=5168B
+ loader ok, retval=0 (maps=2 progs=1)
+ attached + pinned prog 0 (raw_tracepoint) -> /run/shirudo/bpffs/upatches/exec-count/link
+ pinned map 0 (execs, type=1) -> /run/shirudo/bpffs/upatches/exec-count/maps/execs
+ upatch load: name=exec-count keyring=335804852 progs=1
+ upatch load: chain extended, value=5d01da4114c32805d9863fb76cf7d760c1d86a1839ef4d5f79b41685b833d46b
+ upatch load measured: name=exec-count chain=5d01da4114c32805d9863fb76cf7d760c1d86a1839ef4d5f79b41685b833d46b
+ target# shirudo bpm list
+ exec-count 1.1.0 dev
+
+ ``upgrade`` unloads the old version with its signed unload directive
+ and loads the new one, and restores the old one if the new one fails
+ to load. The two commands act at once: from building the new version
+ to running it on the target takes a few seconds. The target's package
+ timer does the same by itself about a minute after each of its runs,
+ which is what a production target relies on; ``journalctl -u
+ shirudo-bpm-repo-update.service`` on the target shows its runs.
+
+4. Check the collector's terminal. The records now carry ``total``, and
+ the counts start again from zero, since the new version has a new map.
+
+Remove it
+---------
+
+1. Uninstall the package on the target:
+
+ .. code-block:: console
+
+ target# shirudo bpm uninstall exec-count
+ upatch unload: --no-precheck, pre-flight state check skipped
+ loaded signed loader: prog_fd=11 keyring=335804852 sig=4853B insns=165 data=2808B
+ upatch unload: payload matches for 'exec-count'
+ upatch unload: chain extended, value=2bf2d8fda256c469544e6d33638bb23fc0801e650bba4068411a779c698ab131
+ upatch unload measured: name=exec-count chain=2bf2d8fda256c469544e6d33638bb23fc0801e650bba4068411a779c698ab131
+ upatch unload: detached + unpinned exec-count
+
+ The target runs the package's signed unload directive, measures the
+ unload and deletes the package. ``shirudo bpm list`` prints nothing
+ and ``shirudo upatch list`` prints ``(none persisted)``.
+
+2. Check the collector's terminal. The map records stop, and the
+ keepalives go on.
+
+The registry keeps every version you pushed. ``bpm upgrade`` only
+upgrades installed packages, so it does not bring the package back. To
+start over with an empty registry, remove the container as `Clean up`_
+shows and start it again.
+
+Change shirudo
+--------------
+
+The host runs the operator commands from your checkout, so a change to
+them takes effect as soon as you rebuild. The target runs the runtime
+image of the bundle the VM booted with, so a change to anything the
+target runs takes a new bundle and a new VM.
+
+- After a change to an operator command, ``shirudo-build`` or the package
+ tools, rebuild:
+
+ .. code-block:: console
+
+ operator$ make && make shirudo-build
+
+- After a change to the target side, such as a ``builtin-*.c`` command
+ the target runs, ``util/``, the BPF programs under ``bpf/`` or the boot
+ integration, replace the VM:
+
+ .. code-block:: console
+
+ operator$ make -C testing vm-clean VM_NAME=dev
+ operator$ make -C testing vm VM_NAME=dev
+
+ ``make -C testing vm`` rebuilds the bundle from your checkout and boots
+ a new VM, which takes about two minutes once the kernel and the disk
+ image exist. It refuses a name that still has state, hence
+ ``vm-clean``. ``shirudo status`` on the target then prints a new
+ ``Version-ID``. The target accepts only the binary on its
+ authenticated runtime image, so there is no faster way to run changed
+ target code. The rebuilt bundle has a new signing key, so repeat this
+ page from `Boot the target`_ with an empty registry: remove and start
+ ``shirudo-registry`` again, build a new config, and build and push your
+ packages again.
+
+- Test what you can on the host first. The unit tests and the operator
+ tests run in seconds without a VM:
+
+ .. code-block:: console
+
+ operator$ make -C testing unit
+ operator$ make -C testing functional/<family> VM=0
+
+ Then run the target tests your change touches by hand in the VM, and
+ the whole family for a verdict, as :doc:`testing` describes.
+
+Clean up
+--------
+
+1. Stop the VM and remove its state:
+
+ .. code-block:: console
+
+ operator$ make -C testing vm-clean VM_NAME=dev
+
+2. Remove the containers:
+
+ .. code-block:: console
+
+ operator$ docker rm -f shirudo-registry shirudo-otelcol
+
+Next steps
+----------
+
+- :doc:`/upatches/decoders` for decoders and metrics.
+- :doc:`/upatches/maps-arenas-serializers` for upatches that keep
+ records.
+- :doc:`/operate/deliver-packages` and :doc:`/operate/telemetry` for the
+ production setup this page reproduces.
+- :doc:`testing` to write and run tests.
diff --git a/Documentation/contribute/develop-locally/exec-count.bpf.c b/Documentation/contribute/develop-locally/exec-count.bpf.c
new file mode 100644
index 00000000..0b74c3a4
--- /dev/null
+++ b/Documentation/contribute/develop-locally/exec-count.bpf.c
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
+#include "vmlinux.h"
+#include <bpf/bpf_helpers.h>
+#include <bpf/bpf_tracing.h>
+#include "shirudo_decoder.h"
+
+char _license[] SEC("license") = "Dual BSD/GPL";
+
+struct {
+ __uint(type, BPF_MAP_TYPE_HASH);
+ __uint(max_entries, 1024);
+ __type(key, char[16]);
+ __type(value, __u64);
+} execs SEC(".maps");
+
+const struct shirudo_decoder_manifest execs_decoder SEC(".rodata") = {
+ .magic = SHIRUDO_DECODER_MANIFEST_MAGIC,
+ .version = SHIRUDO_UPATCH_DECODER_VERSION,
+ .language = SHIRUDO_UPATCH_DECODER_LANG_LUA,
+ .api_version = 1,
+ .input_format = SHIRUDO_UPATCH_DECODER_INPUT_MAP_V1,
+ .export_signal = SHIRUDO_UPATCH_DECODER_EXPORT_LOG,
+ .upatch = "exec-count",
+ .map = "execs",
+ .source = "decoders/execs.lua",
+ .entrypoint = "decode",
+};
+
+SEC("tp_btf/sched_process_exec")
+int BPF_PROG(count_exec, struct task_struct *p, pid_t old_pid,
+ struct linux_binprm *bprm)
+{
+ char comm[16] = {};
+ __u64 zero = 0, *n;
+
+ bpf_get_current_comm(comm, sizeof(comm));
+ n = bpf_map_lookup_elem(&execs, comm);
+ if (!n) {
+ bpf_map_update_elem(&execs, comm, &zero, BPF_NOEXIST);
+ n = bpf_map_lookup_elem(&execs, comm);
+ }
+ if (n)
+ __sync_fetch_and_add(n, 1);
+ return 0;
+}
diff --git a/Documentation/contribute/develop-locally/execs-1.0.lua b/Documentation/contribute/develop-locally/execs-1.0.lua
new file mode 100644
index 00000000..a1370c92
--- /dev/null
+++ b/Documentation/contribute/develop-locally/execs-1.0.lua
@@ -0,0 +1,28 @@
+-- SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
+
+local function command(hex)
+ local name = {}
+
+ for i = 1, #hex - 1, 2 do
+ local byte = tonumber(hex:sub(i, i + 1), 16)
+
+ if byte == 0 then
+ break
+ end
+ name[#name + 1] = string.char(byte)
+ end
+ return table.concat(name)
+end
+
+function decode(input)
+ local execs = {}
+
+ for _, entry in ipairs(input.data.entries) do
+ execs[#execs + 1] = {
+ command = command(entry.key_hex),
+ count = tonumber(shirudo.hex_u64(entry.value_hex, 0)),
+ }
+ end
+ table.sort(execs, function(a, b) return a.count > b.count end)
+ return { execs = execs }
+end
diff --git a/Documentation/contribute/develop-locally/execs-1.1.lua b/Documentation/contribute/develop-locally/execs-1.1.lua
new file mode 100644
index 00000000..62cdf614
--- /dev/null
+++ b/Documentation/contribute/develop-locally/execs-1.1.lua
@@ -0,0 +1,28 @@
+-- SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
+
+local function command(hex)
+ local name = {}
+
+ for i = 1, #hex - 1, 2 do
+ local byte = tonumber(hex:sub(i, i + 1), 16)
+
+ if byte == 0 then
+ break
+ end
+ name[#name + 1] = string.char(byte)
+ end
+ return table.concat(name)
+end
+
+function decode(input)
+ local execs, total = {}, 0
+
+ for _, entry in ipairs(input.data.entries) do
+ local count = tonumber(shirudo.hex_u64(entry.value_hex, 0))
+
+ execs[#execs + 1] = { command = command(entry.key_hex), count = count }
+ total = total + count
+ end
+ table.sort(execs, function(a, b) return a.count > b.count end)
+ return { total = total, execs = execs }
+end
diff --git a/Documentation/contribute/developer-guide.rst b/Documentation/contribute/developer-guide.rst
index e5fc46a6..2e5d7c0c 100644
--- a/Documentation/contribute/developer-guide.rst
+++ b/Documentation/contribute/developer-guide.rst
@@ -465,6 +465,8 @@ Before you send a change:
Next steps
----------
+- :doc:`develop-locally` to run both roles on one machine and change
+ shirudo end to end.
- :doc:`testing` to run and write tests.
- :doc:`contributing` for the commit message and the sign-off.
- :doc:`coding-style` for the C code.
diff --git a/Documentation/contribute/index.rst b/Documentation/contribute/index.rst
index 3003182f..3a18ae47 100644
--- a/Documentation/contribute/index.rst
+++ b/Documentation/contribute/index.rst
@@ -8,6 +8,8 @@ Contribute
These pages are for developers who change shirudo itself: its code, its
tests, its build and this documentation. Start with
:doc:`/contribute/developer-guide` to build from a clone, then
+:doc:`/contribute/develop-locally` to run the operator and a target on
+one machine and take a package through its life, and
:doc:`/contribute/testing` to run the tests in the test VM that plays a
target. :doc:`/contribute/test-coverage` shows what the tests cover and
what they do not. Before you send a change, read
@@ -19,6 +21,7 @@ security-relevant path.
:titlesonly:
developer-guide
+ develop-locally
testing
test-coverage
coding-style