Skip to content

Commit

Permalink
chore: prepare demo
Browse files Browse the repository at this point in the history
  • Loading branch information
mxab committed May 17, 2024
1 parent 74c39e4 commit d5ed1fa
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"request": "launch",
"mode": "auto",
"program": "cmd/nacp/nacp.go",
"args": ["-config=otel.conf.hcl"],
"cwd": "${workspaceFolder}/example/otel",
"args": ["-config=nacp.conf.hcl"],
"cwd": "${workspaceFolder}/misc/hashitalk_secure2024",
}
]
}
4 changes: 4 additions & 0 deletions example/notation/delete_test_certs.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#!/bin/sh
# https://notaryproject.dev/docs/user-guides/installation/uninstall/#remove-the-test-key-and-self-signed-certificate
echo "Deleting test certs on macOS"
# default name or take first argument
NAME="wabbit-networks.io"
if [ -n "$1" ]; then
NAME=$1
fi


notation key delete $NAME
Expand Down
7 changes: 7 additions & 0 deletions misc/hashitalk_secure2024/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM alpine:3.19

ENTRYPOINT [ "sh", "-c", \
"echo 'Hello HashiTalk Secure Friends!' && sleep 3600" \
]

# localhost:5000/my-app:v1
18 changes: 18 additions & 0 deletions misc/hashitalk_secure2024/delete_test_certs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
# https://notaryproject.dev/docs/user-guides/installation/uninstall/#remove-the-test-key-and-self-signed-certificate
echo "Deleting test certs on macOS"
# default name or take first argument
NAME="nacp-demo"
if [ -n "$1" ]; then
NAME=$1
fi


notation key delete $NAME
notation cert delete -y --type ca --store ${NAME} ${NAME}.crt

#echo "rm \"${NOTATION_DIR}/localkeys/${NAME}.key\""


rm "${HOME}/Library/Application Support/notation/localkeys/${NAME}.key"
rm "${HOME}/Library/Application Support/notation/localkeys/${NAME}.crt"
11 changes: 11 additions & 0 deletions misc/hashitalk_secure2024/demo.nomad
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
job "demo" {
datacenters = ["dc1"]
group "demo" {
task "demo" {
driver = "docker"
config {
image = "localhost:5000/my-app:v1"
}
}
}
}
29 changes: 29 additions & 0 deletions misc/hashitalk_secure2024/nacp.conf.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
validator "opa" "enforce_digest" {

opa_rule {
query = <<EOH
errors = data.digest.errors
EOH

filename = "digest/digest.rego"
}
}
/*
validator "opa" "verify_image" {
opa_rule {
query = <<EOH
errors = data.image_verification.errors
EOH
filename = "notation/notation.rego"
}
notation {
repo_plain_http = true
trust_store_dir = "/Users/max/Library/Application Support/notation"
trust_policy_file = "/Users/max/Library/Application Support/notation/trustpolicy.json"
}
}
*/
14 changes: 14 additions & 0 deletions misc/hashitalk_secure2024/notation/notation.rego
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package image_verification

import rego.v1

errors contains msg if {
some g, t
input.TaskGroups[g].Tasks[t].Driver == "docker"
image := input.TaskGroups[g].Tasks[t].Config.image

# check if image is verified
not notation_verify_image(image)

msg := sprintf("TaskGroup %d Task %d image cannot be verified (image %s)", [g, t, image])
}
7 changes: 7 additions & 0 deletions misc/hashitalk_secure2024/purge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

nomad stop -purge registry

docker rmi -f localhost:5000/my-app:v1

./delete_test_data.sh
27 changes: 27 additions & 0 deletions misc/hashitalk_secure2024/registry.nomad
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
job "registry" {

type = "service"

group "registry" {

network {
port "registry" {
static = 5000
to = 5000
}
}

task "registry" {

driver = "docker"

config {
image = "registry:2"
ports = ["registry"]
}
env {
REGISTRY_STORAGE_DELETE_ENABLED = "true"
}
}
}
}

0 comments on commit d5ed1fa

Please sign in to comment.