Install the agent by hand
These steps do what install.sh does, one command at a time, for agent 0.2.2. They write the same files, so install.sh --uninstall removes them as well.
The commands use sudo; as root, leave it out. They run on Debian, Ubuntu, RHEL and its relatives, Amazon Linux and Alpine, on amd64 and arm64.
Before you start
You need an API key of scope agent: create an account, then a key.
Then pick the mode. In Docker mode the agent runs in containers of the agent image, which Docker pulls by its digest; the server needs Docker for it. In binary mode the static agent binary and Trivy run on the host, and the steps that read images and send the report run as the system user vulnpocalypse. install.sh takes Docker mode when Docker runs on the server.
1. Directories
sudo mkdir -p /etc/vulnpocalypse /usr/local/lib/vulnpocalypse sudo mkdir -p -m 700 /var/lib/vulnpocalypse
/var/lib/vulnpocalypse holds the work directory of a run and a copy of the last report and answer.
2. Settings
Make the settings file readable by root only, then open it in an editor and paste the settings. This way the key goes into the file without passing a command line, where the shell history, the sudo log and the process list would keep it.
sudo touch /etc/vulnpocalypse/agent.conf sudo chmod 600 /etc/vulnpocalypse/agent.conf sudoedit /etc/vulnpocalypse/agent.conf
# Vulnpocalypse agent settings. The agent reads KEY=value lines; a shell does not run this file. # KEY: agent key (upload only). URL: the service. NAME: the server name in the dashboard. # PATHS: app directories whose lockfiles are scanned. IMAGES: all, none or a list of images. # EXCLUDE_IMAGES: images that are not scanned. MODE: docker or binary. KEY=YOUR_KEY URL=https://vulnpocalypse.ch NAME=web-1 MODE=docker PATHS= IMAGES=all EXCLUDE_IMAGES=
Write each setting as NAME=value without spaces around the equals sign; run.sh reads some of them with sed.
| Setting | What it is |
|---|---|
KEY | The agent key, in place of YOUR_KEY. A key of scope agent can send reports and do nothing else. |
URL | The address of Vulnpocalypse. |
NAME | The server name on the dashboard. Without it the server is called server- and the first 6 characters of the server id. |
MODE | docker or binary. In binary mode, write MODE=binary. |
PATHS | App directories whose lockfiles the agent reads (package-lock.json, requirements.txt, go.mod and others), separated by spaces or commas. |
IMAGES | all for the images of the running containers, none, or a list of images. |
EXCLUDE_IMAGES | Images the agent leaves out. |
3. Server id
A random UUID that tells the dashboard which server a report comes from. The command keeps the file of an earlier install, so the server keeps its history.
[ -s /etc/vulnpocalypse/server-id ] || cat /proc/sys/kernel/random/uuid | sudo tee /etc/vulnpocalypse/server-id
4. The wrapper
run.sh runs the steps of a run, each in a process of its own, and is what the daily timer starts. Download it, read it, check its SHA-256 sum and install it. It is the file that install.sh writes.
cd "$(mktemp -d)" curl -fsSLO https://vulnpocalypse.ch/run.sh less run.sh echo "7c928ca72459369e57bb60a0fb493aeb6002858836e0a379352bab4a3da3eba7 run.sh" | sha256sum -c sudo install -m 755 run.sh /usr/local/lib/vulnpocalypse/run.sh
sha256sum -c prints run.sh: OK. What a run reads and sends: what the agent collects.
5. The agent
Docker mode
Pull the agent image by its digest. Docker checks the content against the digest, and run.sh starts only an image that is pinned this way.
sudo docker pull ghcr.io/cdutsov/vulnpocalypse/agent:0.2.2@sha256:638fa6d29e1207057b225e81033c478d021119bc3bceb06e7449d0ad8d723924
Binary mode
Download the agent and Trivy, check both SHA-256 sums and install them. The agent runs Trivy offline to list the packages; Trivy does not download or send anything. The case picks the files of the architecture of the server.
case $(uname -m) in x86_64) arch=amd64 trivy=trivy_0.75.0_Linux-64bit.tar.gz ;; aarch64) arch=arm64 trivy=trivy_0.75.0_Linux-ARM64.tar.gz ;; esac curl -fsSLO https://vulnpocalypse.ch/dl/agent/0.2.2/vulnpocalypse-agent-0.2.2-linux-$arch curl -fsSLO https://github.com/aquasecurity/trivy/releases/download/v0.75.0/$trivy cat >SHA256SUMS <<'EOF' 975aee9439bae602b87e6ece247120de64ad7c331cc3b6e42fa809751b5cca20 vulnpocalypse-agent-0.2.2-linux-amd64 67d1d3a1fbae406d00cce4377bc8ca199582ffe56bf17a3b65a694a6c72e31be vulnpocalypse-agent-0.2.2-linux-arm64 c6e65abddb348e25f10549df887045629cf28cc72453cd1c63acb717316b3f3f trivy_0.75.0_Linux-64bit.tar.gz a1ee9f6ffb7d112b64ff726a2a0717c21175c1114361391f4a132956751a13b3 trivy_0.75.0_Linux-ARM64.tar.gz EOF grep -e "linux-$arch\$" -e " $trivy\$" SHA256SUMS | sha256sum -c tar -xzf "$trivy" trivy sudo install -m 755 vulnpocalypse-agent-0.2.2-linux-$arch /usr/local/lib/vulnpocalypse/vulnpocalypse-agent sudo install -m 755 trivy /usr/local/lib/vulnpocalypse/trivy
sha256sum -c prints OK for both files. The steps that read images and send the report run as the system user vulnpocalypse, without a home directory or a login shell:
sudo useradd --system --user-group --no-create-home --home-dir /nonexistent --shell /sbin/nologin vulnpocalypse
On Alpine:
sudo addgroup -S vulnpocalypse sudo adduser -S -D -H -h /nonexistent -s /sbin/nologin -G vulnpocalypse vulnpocalypse
6. Look before sending
A dry run prints the report the agent would send, then a summary of it. Nothing leaves the server. The second command prints the summary alone.
sudo /usr/local/lib/vulnpocalypse/run.sh scan --dry-run sudo /usr/local/lib/vulnpocalypse/run.sh scan
7. The first report
sudo /usr/local/lib/vulnpocalypse/run.sh send
The server shows on the dashboard within a minute. A copy of the report and the answer stays in /var/lib/vulnpocalypse/ (last-payload.json.gz, last-response.json).
8. Once a day
This page picked 02:16 at random, as install.sh does, so that servers do not all send in the same minute. Any other time of day works too; it is the local time of the server.
systemd
sudo tee /etc/systemd/system/vulnpocalypse-agent.service >/dev/null <<'EOF' [Unit] Description=Vulnpocalypse agent: send the daily security report After=network-online.target docker.service Wants=network-online.target [Service] Type=oneshot ExecStart=/usr/local/lib/vulnpocalypse/run.sh send Nice=10 IOSchedulingClass=idle TimeoutStartSec=3h MemoryMax=2G CPUQuota=100% NoNewPrivileges=yes ProtectSystem=full ProtectHome=read-only PrivateTmp=yes ProtectKernelTunables=yes ProtectControlGroups=yes RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK EOF sudo tee /etc/systemd/system/vulnpocalypse-agent.timer >/dev/null <<'EOF' [Unit] Description=Vulnpocalypse agent, once a day [Timer] OnCalendar=*-*-* 02:16:00 RandomizedDelaySec=10min Persistent=true [Install] WantedBy=timers.target EOF sudo systemctl daemon-reload sudo systemctl enable --now vulnpocalypse-agent.timer systemctl list-timers vulnpocalypse-agent.timer
A run missed while the server was off follows after the next boot (Persistent=true). The service limits a run to 2 GB of memory, one CPU and 3 hours.
cron, without systemd
echo '16 2 * * * root /usr/local/lib/vulnpocalypse/run.sh send >/dev/null 2>&1' | sudo tee /etc/cron.d/vulnpocalypse-agent
The cron of Alpine (busybox crond) does not read /etc/cron.d; add the line to the crontab of root instead. install.sh --uninstall finds it by the comment at its end.
echo '16 2 * * * /usr/local/lib/vulnpocalypse/run.sh send >/dev/null 2>&1 # vulnpocalypse-agent' | sudo tee -a /etc/crontabs/root
Remove the agent
install.sh removes a manual install too, and lists each file and command:
curl -fsSLO https://vulnpocalypse.ch/install.sh sudo sh install.sh --uninstall
By hand, part by part; leave out the parts you did not install:
# systemd sudo systemctl disable --now vulnpocalypse-agent.timer sudo rm -f /etc/systemd/system/vulnpocalypse-agent.service /etc/systemd/system/vulnpocalypse-agent.timer sudo systemctl daemon-reload # cron, and the line in the crontab of root on Alpine sudo rm -f /etc/cron.d/vulnpocalypse-agent sudo sed -i '/# vulnpocalypse-agent$/d' /etc/crontabs/root # binary mode: the user, with userdel, or with deluser on Alpine sudo userdel vulnpocalypse sudo deluser vulnpocalypse # Docker mode: the image sudo docker rmi ghcr.io/cdutsov/vulnpocalypse/agent:0.2.2@sha256:638fa6d29e1207057b225e81033c478d021119bc3bceb06e7449d0ad8d723924 # both modes: the files sudo rm -rf /etc/vulnpocalypse /usr/local/lib/vulnpocalypse /var/lib/vulnpocalypse
Then delete the server on the dashboard to delete its reports and findings.
Files
For configuration management (Ansible, Salt, Puppet, cloud-init), the files that these steps leave:
| Path | Owner, mode | What |
|---|---|---|
/etc/vulnpocalypse/agent.conf | root, 600 | the settings with the key; run.sh refuses to run when group or others may write it |
/etc/vulnpocalypse/server-id | root, 644 | the server id, kept on reinstall |
/usr/local/lib/vulnpocalypse/run.sh | root, 755 | the wrapper |
/usr/local/lib/vulnpocalypse/vulnpocalypse-agent, trivy | root, 755 | binary mode |
/var/lib/vulnpocalypse/ | root, 700 | the work directory of a run and the copy of the last report; in binary mode run.sh sets 710 with the group vulnpocalypse |
/etc/systemd/system/vulnpocalypse-agent.service, .timer | root, 644 | or /etc/cron.d/vulnpocalypse-agent, or the line in /etc/crontabs/root |
user and group vulnpocalypse | system user | binary mode |
Vulnpocalypse