From 6db3299f15a1a835eb321971f3012b3b63443ae5 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sun, 4 Oct 2026 03:10:06 +1100 Subject: [PATCH] feat(workflows): firewall workflow package; pack.sh builds files-only packages --- README.md | 8 +++--- scripts/pack.sh | 22 ++++++++++----- workflows/firewall/package.yaml | 13 +++++++++ .../firewall/workflows/firewall-contain.yaml | 27 +++++++++++++++++++ .../workflows/firewall-investigate.yaml | 25 +++++++++++++++++ 5 files changed, 86 insertions(+), 9 deletions(-) create mode 100644 workflows/firewall/package.yaml create mode 100644 workflows/firewall/workflows/firewall-contain.yaml create mode 100644 workflows/firewall/workflows/firewall-investigate.yaml diff --git a/README.md b/README.md index 4a66d65..9d9008b 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ directory holds one subdirectory per extension. ``` secret-engines// package.yaml + Go source, served over secretengine.v1 +workflows// package.yaml + workflow YAML, projected into workflow-definitions sdk/ generated surface stubs and the Serve helper scripts/pack.sh build one package and push it to a registry ``` @@ -20,8 +21,9 @@ the Go SDK is a convenience. scripts/pack.sh secret-engines/bws localhost:5001/bws:1.0.0 # prints the digest ``` -Install the printed digest through archie-core's package store, accept the -authority the package declares, then enable it in `extension-settings`. An -extension runs only while all three hold. +Install the printed digest from the Extensions page, accept the authority the +package declares, then enable it. An extension runs only while all three hold. +A data package (no `main.go`) needs only the install: its files are projected +into the matching resource and withdrawn when the package is removed. Platform: linux/amd64. diff --git a/scripts/pack.sh b/scripts/pack.sh index 8682316..47f0780 100755 --- a/scripts/pack.sh +++ b/scripts/pack.sh @@ -1,7 +1,10 @@ #!/usr/bin/env bash # Build one package and push it to a registry as an archie-core store package. # scripts/pack.sh secret-engines/bws localhost:5001/bws:1.0.0 -# Prints the manifest digest, the pin archie-core installs by. +# scripts/pack.sh workflows/firewall localhost:5001/firewall:1.0.0 +# A directory with a main.go is an extension: it is built to bin/. Every +# other file beside package.yaml is carried as written, at the path package.yaml +# declares. Prints the manifest digest, the pin archie-core installs by. set -euo pipefail dir=${1:?package directory, e.g. secret-engines/bws} @@ -10,12 +13,19 @@ root=$(cd "$(dirname "$0")/.." && pwd) work=$(mktemp -d) trap 'rm -rf "$work"' EXIT -mkdir -p "$work/stage/bin" "$work/oci/blobs/sha256" -(cd "$root" && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags='-s -w' \ - -o "$work/stage/bin/$(basename "$dir")" "./$dir") -chmod 0755 "$work/stage/bin/$(basename "$dir")" +mkdir -p "$work/stage" "$work/oci/blobs/sha256" +if [ -f "$root/$dir/main.go" ]; then + mkdir -p "$work/stage/bin" + (cd "$root" && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags='-s -w' \ + -o "$work/stage/bin/$(basename "$dir")" "./$dir") + chmod 0755 "$work/stage/bin/$(basename "$dir")" +fi +(cd "$root/$dir" && find . -type f ! -name package.yaml ! -name '*.go' ! -name go.mod ! -name go.sum -print0 \ + | while IFS= read -r -d '' f; do install -D -m 0644 "$f" "$work/stage/${f#./}"; done) -tar --owner=0 --group=0 --numeric-owner --sort=name -C "$work/stage" -czf "$work/layer.tgz" "bin/$(basename "$dir")" +# Regular files only: the store refuses directory entries in a layer. +(cd "$work/stage" && find . -type f -printf '%P\n' | LC_ALL=C sort >"$work/files.txt" \ + && tar --owner=0 --group=0 --numeric-owner --no-recursion -czf "$work/layer.tgz" -T "$work/files.txt") blob() { local d; d=$(sha256sum "$1" | cut -d' ' -f1); cp "$1" "$work/oci/blobs/sha256/$d"; echo "sha256:$d"; } printf '{}' >"$work/config.json" diff --git a/workflows/firewall/package.yaml b/workflows/firewall/package.yaml new file mode 100644 index 0000000..0de8cbf --- /dev/null +++ b/workflows/firewall/package.yaml @@ -0,0 +1,13 @@ +apiVersion: dev.archie.package.v1 +displayName: Firewall investigate and contain +description: Investigate a source address from firewall logs, then decide and record containment. Needs a network-investigator agent profile. +version: 1.0.0 +contributes: + workflows: + - workflows/firewall-investigate.yaml + - workflows/firewall-contain.yaml +files: + - path: workflows/firewall-investigate.yaml + mode: 420 + - path: workflows/firewall-contain.yaml + mode: 420 diff --git a/workflows/firewall/workflows/firewall-contain.yaml b/workflows/firewall/workflows/firewall-contain.yaml new file mode 100644 index 0000000..7a8fd8c --- /dev/null +++ b/workflows/firewall/workflows/firewall-contain.yaml @@ -0,0 +1,27 @@ +# The containment workflow a firewall-investigate run calls: +# firewall-investigate (workflow.call, wait: true) hands its findings upward +# from its declared summary, and this workflow's own agent stage decides and +# records the containment as its own declared outputs. Paste it into the +# dashboard's workflow definitions alongside firewall-investigate. +id: firewall-contain +repository: none +profile: network-investigator +inputs: + src_ip: { type: string, required: true } +outputs: + contained: { type: bool, required: true } + summary: { type: string } +steps: + - type: workflow.call + settings: + workflow: firewall-investigate + wait: true + inputs: { src_ip: "inputs.src_ip" } + outputs: { summary: "outputs.summary" } + - type: agent.run + settings: + mission: >- + Using the investigation summary the called workflow returned, decide + whether the source address in the inputs should be contained. Write + your decision with the contained tool, and a one-line rationale with + the summary tool. \ No newline at end of file diff --git a/workflows/firewall/workflows/firewall-investigate.yaml b/workflows/firewall/workflows/firewall-investigate.yaml new file mode 100644 index 0000000..dbe799a --- /dev/null +++ b/workflows/firewall/workflows/firewall-investigate.yaml @@ -0,0 +1,25 @@ +# A workflow with no repository: a binding on a firewall event type assigns +# src_ip from a mapped parameter and runs one agent mission in a scratch +# workspace under the network-investigator profile. Paste it into the +# dashboard's workflow definitions. +# +# Its declared output (summary) is offered to the agent stages as a capture +# tool named after it; a wait:true caller publishes it as one of its own +# outputs. +id: firewall-investigate +repository: none +profile: network-investigator +inputs: + src_ip: { type: string, required: true } + severity: { type: string } +outputs: + summary: { type: string } +steps: + - type: agent.run + settings: + mission: >- + Investigate the source address in the inputs: who owns it, what it + resolves to, and whether it is reachable. Report what you found and + how serious it looks given the severity, and write your one-line + conclusion with the summary tool. + read_only: true