Skip to content

Instantly share code, notes, and snippets.

@jdolitsky
jdolitsky / tf-lockfile-h1-hashes.sh
Created April 13, 2024 06:25
Update the "h1:..." hashes in .terraform.lock.hcl
#!/usr/bin/env bash
# This script obtains the "h1:..." hashes for all platforms
# See https://github.com/hashicorp/terraform/issues/27264
set -o errexit; set -o nounset; set -o pipefail
export GOBIN="${PWD}/bin" PATH="${PWD}/bin:${PATH}"; TMPDIR="$(mktemp -d)"
# Note: All modules in the lockfile MUST have zips for these platforms
PLATFORMS=("darwin/amd64" "darwin/arm64" "linux/amd64" "linux/arm64")
@jdolitsky
jdolitsky / top_10_files.sh
Created July 27, 2023 03:30
Top 10 largest files in a container image
top_10_files() { crane export $1 --platform linux/amd64 | tar -tvf - | awk -v size="$size" '$5 >= size {print $5" "$9}' | sort -nrk1.2 | head -n10 | numfmt --to=iec-i --suffix=B --format="%9.2f"; }
@jdolitsky
jdolitsky / README.md
Created August 29, 2022 19:22
One-liner to get the checksum for an apk package (Alpine etc.) using apk-tools

On apk-based distro (Alpine etc.):

( APK_NAME="hello" APK_RELDIR="repository/testdata" && apk index -o TMP.tar.gz \
    ${APK_RELDIR}/*.apk &>/dev/null && tar xf TMP.tar.gz -O APKINDEX | \
    grep  -e ^C: -e ^P: | grep -B1 P:${APK_NAME} | head -1 | \
    cut -d: -f2 && rm -f TMP.tar.gz )

Using Docker (via distroless.dev/alpine-base):

@jdolitsky
jdolitsky / README.md
Last active September 8, 2022 18:18
Getting the checksum for an apk package (Alpine etc.) in Go
@jdolitsky
jdolitsky / melange.yaml
Created July 28, 2022 21:15
Melange config file for bom
package:
name: bom
version: "{{ .Version }}"
description: A utility to generate SPDX-compliant Bill of Materials manifests
target-architecture:
- all
copyright:
- license: Apache-2.0
paths:
- "*"
@jdolitsky
jdolitsky / policy-spdxjson.yaml
Last active July 27, 2022 21:33
ClustertImagePolicy requiring an SBOM in SPDX format stored as a keyless attestation against public Fulcio using cosign
apiVersion: policy.sigstore.dev/v1alpha1
kind: ClusterImagePolicy
metadata:
name: keyless-attestation-spdxjson
spec:
images:
- glob: **
authorities:
- name: keyless
keyless:
@jdolitsky
jdolitsky / hello-melange-apko-15.txt
Created July 21, 2022 05:07
Secure Your Software Factory with melange and apko
Hello World!
@jdolitsky
jdolitsky / hello-melange-apko-14.txt
Last active July 21, 2022 15:30
Secure Your Software Factory with melange and apko
$ curl -s http://localhost:8080
Hello World!
@jdolitsky
jdolitsky / hello-melange-apko-13.txt
Last active July 21, 2022 05:06
Secure Your Software Factory with melange and apko
docker run --rm -it --rm -p 8080:8080 factory-demo
@jdolitsky
jdolitsky / hello-melange-apko-12.txt
Created July 21, 2022 05:04
Secure Your Software Factory with melange and apko
docker load < output.tar