# # Python3 reproducer for /usr/lib/nagios/plugins/check_vault_health.py import json import socket import ssl import sys from textwrap import dedent SNAPD_INFO_REQUEST = dedent("""\ GET /v2/snaps/{snap} HTTP/1.1\r Host:\r \r """) SNAPD_SOCKET = '/run/snapd.socket' snapd = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) snapd.connect(SNAPD_SOCKET) snapd.sendall(SNAPD_INFO_REQUEST.format(snap='vault').encode('utf-8')) print(snapd.recv(1024 * 1024).decode('utf-8')) # faulty code # info = json.loads(snapd.recv(1024 * 1024).decode('utf-8').split('\n')[-1]) # # previous release of snapd (lxd container with snapd 2.58+22.04.1 # HTTP/1.1 200 OK Content-Type: application/json Date: Wed, 10 Apr 2024 06:57:46 GMT Content-Length: 1833 {"type":"sync","status-code":200,"status":"OK","result":{"id":"bIb4p4yWWjyZdo2EU64whkZhw9QYYsMH","title":"vault","summary":"Vault is a tool for securely accessing secrets.","description":"A modern system requires access to a multitude of secrets: database\ncredentials, API keys for external services, credentials for service-oriented\narchitecture communication, etc. Understanding who is accessing what secrets\nis already very difficult and platform-specific. Adding on key rolling,\nsecure storage, and detailed audit logs is almost impossible without a custom\nsolution. This is where Vault steps in.\n\nThis snap is maintained by Canonical.","icon":"https://dashboard.snapcraft.io/site_media/appmedia/2017/09/android-chrome-512x512.png","installed-size":304566272,"install-date":"2023-05-19T08:46:25.808773925Z","name":"vault","publisher":{"id":"canonical","username":"canonical","display-name":"Canonical","validation":"verified"},"developer":"canonical","status":"active","type":"app","base":"core18","version":"1.10.6","channel":"1.10/stable","tracking-channel":"1.10/stable","ignore-validation":false,"revision":"2091","confinement":"strict","private":false,"devmode":false,"jailmode":false,"apps":[{"snap":"vault","name":"vault"}],"mounted-from":"/var/lib/snapd/snaps/vault_2091.snap","links":{"contact":["https://github.com/canonical/snap-vault/issues"],"website":["https://github.com/canonical/snap-vault"]},"contact":"https://github.com/canonical/snap-vault/issues","website":"https://github.com/canonical/snap-vault","media":[{"type":"icon","url":"https://dashboard.snapcraft.io/site_media/appmedia/2017/09/android-chrome-512x512.png","width":256,"height":256},{"type":"screenshot","url":"https://dashboard.snapcraft.io/site_media/appmedia/2017/09/Screenshot_from_2017-09-27_14-52-07.png","width":1920,"height":812}]}} # # current release of snapd 2.61.3+22.04 # HTTP/1.1 200 OK Content-Type: application/json Date: Wed, 10 Apr 2024 06:58:40 GMT Transfer-Encoding: chunked 8f4 {"type":"sync","status-code":200,"status":"OK","result":{"id":"bIb4p4yWWjyZdo2EU64whkZhw9QYYsMH","title":"vault","summary":"Vault is a tool for securely accessing secrets.","description":"A modern system requires access to a multitude of secrets: database\ncredentials, API keys for external services, credentials for service-oriented\narchitecture communication, etc. Understanding who is accessing what secrets\nis already very difficult and platform-specific. Adding on key rolling,\nsecure storage, and detailed audit logs is almost impossible without a custom\nsolution. This is where Vault steps in.\n\nThis snap is maintained by Canonical.\n\n**Usage**\n \n* To start the Vault service, edit the configuration file at `/var/snap/vault/common/vault.hcl` and start the service with `sudo snap start vault.vaultd`.\n\n* To use the Vault Client, run `vault` commands. For example: `vault status`.","icon":"https://dashboard.snapcraft.io/site_media/appmedia/2017/09/android-chrome-512x512.png","installed-size":290283520,"install-date":"2024-04-05T10:21:40.548662098Z","name":"vault","publisher":{"id":"canonical","username":"canonical","display-name":"Canonical","validation":"verified"},"developer":"canonical","status":"active","type":"app","base":"core18","version":"1.8.8","channel":"1.8/stable","tracking-channel":"1.8/stable","ignore-validation":false,"revision":"2066","confinement":"strict","private":false,"devmode":false,"jailmode":false,"apps":[{"snap":"vault","name":"vault"}],"mounted-from":"/var/lib/snapd/snaps/vault_2066.snap","links":{"issues":["https://github.com/canonical/snap-vault/issues"],"source":["https://github.com/hashicorp/vault"],"website":["https://github.com/canonical/snap-vault","https://www.vaultproject.io/"]},"contact":"","website":"https://github.com/canonical/snap-vault","media":[{"type":"icon","url":"https://dashboard.snapcraft.io/site_media/appmedia/2017/09/android-chrome-512x512.png","width":256,"height":256},{"type":"screenshot","url":"https://dashboard.snapcraft.io/site_media/appmedia/2024/03/Screenshot_from_2024-03-20_16-12-04-1710965788.png","width":873,"height":500},{"type":"screenshot","url":"https://dashboard.snapcraft.io/site_media/appmedia/2024/03/Screenshot_from_2024-03-20_16-15-49-1710965788.png","width":1793,"height":1068}]}} 0