Week Notes 2026.05
Scheme Databases #
I spent a bit of time understanding the sample implementation of SRFI 168: Generic Tuple Store Database and now have a good grasp of how it works.
For a deeper dive into the theory behind this, I also worked through the section on Logic Programming in SICP, where they develop a query system from the ground up. This was a very enjoyable (and enlightening) read.
Generating documentation for a Terraform module #
I had to remind myself that there’s a handy utility for generating documentation
for a Terraform module,
terraform-docs. You can run
it using podman:
podman run --rm --volume "$(pwd):/terraform-docs" --security-opt label=disable \
-u $(id -u) quay.io/terraform-docs/terraform-docs \
markdown /terraform-docs >> README.md
You can also customize the output: checkout the docs.
Update on Pytorch Docker image security #
Last week I was wondering how to address security vulnerabilities in a Docker
image where
the fixes were only available in Ubuntu ESM. We were able to update the base
image to pytorch:2.9.1-cuda12.8-cudnn9-runtime and, by building on an EC2
instance running Ubuntu Pro, pull in the security fixes from Ubuntu ESM
repositories.
After updating the Python dependencies, we got the number of critical and high vulnerabilities down to zero. Briefly. Doing the same build a day later we have no critical but two high vulnerabilities in Python packages.
Our SOC2 policies require us to address critical vulnerabilities within 15 days and high vulnerabilities within 30 days, so keeping this image compliant with policy is going to be an ongoing nightmare.
Golint has been deprecated #
Looking for documention for golint I
learned it was deprecated and frozen in 2024, they suggest using
staticcheck instead. I will have to take a look at
integrating that into our CI/CD pipelines.
To export or not to export, that is the question #
One of my colleagues was confused when I remarked “You don’t need to export that variable, it’s only used in the current shell.” I made a bad job of explaining exported vs non-exported variables, and later suggested this article which gives a good explanation.
I think there was still some confusion about what happens when a shell variable
is used on the command-line. I didn’t think at the time to suggest using set -x, which will make bash display each command before it’s executed:
$ FOO="123"
$ set -x
$ /bin/echo $FOO
+ /bin/echo 123
123
$ /bin/echo '$FOO'
+ /bin/echo '$FOO'
$FOO
It makes no difference whether or not FOO is exported here, as it’s not the
echo command that resolves the variable reference, it’s the shell. Things get a
bit more interesting if you add a subshell to the mix.
In this example, $FOO is expanded by the current shell before the subshell is run:
$ /bin/bash -x -c "/bin/echo $FOO"
+ /bin/bash -x -c '/bin/echo 123'
+ /bin/echo 123
123
In this example, the single quotes suppress the expansion of $FOO by the
current shell; the subshell expands $FOO but, as it was not exported by the
parent shell, this just outputs an empty line:
$ /bin/bash -x -c '/bin/echo $FOO'
+ /bin/bash -x -c '/bin/echo $FOO'
+ /bin/echo
If we export FOO, the single quotes still suppress expansion in the parent
shell, but now the subshell can see the exported variable:
$ export FOO
$ /bin/bash -x -c '/bin/echo $FOO'
+ /bin/bash -x -c '/bin/echo $FOO'
+ /bin/echo 123
123
Publishing API documentation to GitLab Pages #
A useful feature of AWS API Gateway is GetExport, which will produce an API definition in Swagger or OpenAPI format. This is especially useful if you’ve defined all the endpoints and methods in API Gateway (rather than defining a proxy path that handles everyting).
I came up with a simple way of using this along with Swagger UI to publish up-to-date documentation for an API I’m working on to GitLab Pages. It’s a simple CI/CD pipeline that exports the API definition from API Gateway, downloads the stand-alone version of Swagger UI, and publishes both to GitLab Pages with a tiny change to the Javascript to point at the desired API specification:
---
variables:
SWAGGER_UI_VERSION: "5.31.0"
API_GATEWAY_ID: "xxxxxxxxxx"
default:
image: debian:trixie-slim
fetch-openapi-spec:
stage: build
before_script:
- apt-get -qq update && apt-get -qq install awscli
script:
- aws apigateway get-export --rest-api-id "${API_GATEWAY_ID}" --stage-name v1 --export-type oas30 openapi.json
artifacts:
paths:
- openapi.json
create-pages:
stage: build
needs:
- fetch-openapi-spec
dependencies:
- fetch-openapi-spec
before_script:
- apt-get -qq update && apt-get -qq install curl
script:
- curl -L https://github.com/swagger-api/swagger-ui/archive/refs/tags/v${SWAGGER_UI_VERSION}.tar.gz -o swagger-ui-${SWAGGER_UI_VERSION}.tar.gz
- tar xf swagger-ui-${SWAGGER_UI_VERSION}.tar.gz
- mv swagger-ui-${SWAGGER_UI_VERSION}/dist public
- mv openapi.json public
- sed -i -e 's|https://petstore\.swagger\.io/v2/swagger\.json|./openapi.json|' public/swagger-initializer.js
pages: true
The fetch-openapi-spec job needs to run with AWS credentials with sufficient
permissions to make the GetExport call. My preferred way to do this is to use
GitLab’s OpenID Connect to get
temporary credentials.
Now we can update the terraform pipeline that deploys the API to trigger this as a downstream job, and our API documentation will always be up-to-date!
Leaking roofs and the state of search #
Earlier this week we had strong winds and heavy rain, and I noticed that I had a leak. Water was dripping onto the kitchen floor from somewhere I didn’t think there was any pipework, so I suspected it was coming in from outside. Sure enough, when I went upstairs and looked at the ceiling of the room above, there was a big water stain. I grabbed a step ladder to look in the loft: there were clear signs of water entering in several places where the roof of the extension meets the wall of the main house. I suspected a problem with the flashing.
So I pulled up a search engine and started looking for local roofing contractors. I know there are several as I’ve seen their vans around town, but it seems none of them have web pages that show up in the search results.
The top hits were from some scammy company that appears to automatically generate a website for a “local” company, complete with phone number with local dialling code. If you repeat the search for a town in a different part of the country, you get the same website with a different company name and dialling code.
I have mostly stopped using Google for search but, to their credit, Google Maps does show some of the local businesses and gives phone numbers (but no web sites) for them.
I also found a couple of suggestions in a local Facebook group and got a word-of-mouth recommendation from my sister. The ones I managed to get through to were inundated (the earliest they could get here was at the weekend) so I ended up going with a company from Checkatrade simply because they could get here the same day to diagnose the problem and come back the following day to fix it. I’m sure I paid way over the odds but with more rain in the forecast I wanted it fixed quickly.
Listening #
- Eyes of the Void by Adrian Tchaikovsky (Audio book)
- Better Offline: The Enshittifinancial Crisis (Podcast)
- Cautionary Tales: The WOW Machine Stops (Podcast)
- Linux Matters: Points of You (Podcast)
- Hacker Public Radio: How I do todo (Podcast)
- Linux Dev Time: Episode 142 (Podcast)
- Smashing Security 451: I hacked the government, and your headphones are next (Podcast)
- Late Night Linux: Episode 370 (Podcast)
- 2.5 Admins 284: Bootooth (Podcast)
- Clojure in Product: Would you do it again? Episode 12 (Podcast)