Skip to content

Commit

Permalink
chore: No longer run weaver as root, or give full filesystem access
Browse files Browse the repository at this point in the history
  • Loading branch information
jsuereth committed Aug 20, 2024
1 parent 40db676 commit ad14d55
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
43 changes: 29 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,33 +113,44 @@ yamllint:
# Generate markdown tables from YAML definitions
.PHONY: table-generation
table-generation:
docker run --rm -v $(PWD)/model:/source -v $(PWD)/docs:/spec -v $(PWD)/templates:/weaver/templates \
docker run --rm \
-u $(id -u ${USER}):$(id -g ${USER}) \
--mount 'type=bind,source=$(PWD)/templates,target=/home/weaver/templates,readonly' \
--mount 'type=bind,source=$(PWD)/model,target=/home/weaver/source,readonly' \
--mount 'type=bind,source=$(PWD)/docs,target=/home/weaver/target' \
$(WEAVER_CONTAINER) registry update-markdown \
--registry=/source \
--registry=/home/weaver/source \
--attribute-registry-base-url=/docs/attributes-registry \
--templates=/weaver/templates \
--templates=/home/weaver/templates \
--target=markdown \
/spec
/home/weaver/target

# Generate attribute registry markdown.
.PHONY: attribute-registry-generation
attribute-registry-generation:
docker run --rm -v $(PWD)/model:/source -v $(PWD)/docs:/spec -v $(PWD)/templates:/weaver/templates \
docker run --rm \
-u $(id -u ${USER}):$(id -g ${USER}) \
--mount 'type=bind,source=$(PWD)/templates,target=/home/weaver/templates,readonly' \
--mount 'type=bind,source=$(PWD)/model,target=/home/weaver/source,readonly' \
--mount 'type=bind,source=$(PWD)/docs,target=/home/weaver/target' \
$(WEAVER_CONTAINER) registry generate \
--registry=/source \
--templates=/weaver/templates \
--registry=/home/weaver/source \
--templates=/home/weaver//templates \
markdown \
/spec/attributes-registry/
/home/weaver/target/attributes-registry/
npm run fix:format

# Check if current markdown tables differ from the ones that would be generated from YAML definitions (weaver).
.PHONY: table-check
table-check:
docker run --rm -v $(PWD)/model:/source -v $(PWD)/docs:/spec -v $(PWD)/templates:/weaver/templates \
docker run --rm \
--mount 'type=bind,source=$(PWD)/templates,target=/home/weaver/templates,readonly' \
--mount 'type=bind,source=$(PWD)/model,target=/home/weaver/source,readonly' \
--mount 'type=bind,source=$(PWD)/docs,target=/home/weaver/target,readonly' \
$(WEAVER_CONTAINER) registry update-markdown \
--registry=/source \
--registry=/home/weaver/target \
--attribute-registry-base-url=/docs/attributes-registry \
--templates=/weaver/templates \
--templates=/home/weaver/templates \
--target=markdown \
--dry-run \
/spec
Expand Down Expand Up @@ -215,11 +226,15 @@ generate-gh-issue-templates:
LATEST_RELEASED_SEMCONV_VERSION := $(shell git ls-remote --tags https://github.com/open-telemetry/semantic-conventions.git | cut -f 2 | sort --reverse | head -n 1 | tr '/' ' ' | cut -d ' ' -f 3 | $(SED) 's/v//g')
.PHONY: check-policies
check-policies:
docker run --rm -v $(PWD)/model:/source -v $(PWD)/docs:/spec -v $(PWD)/policies:/policies \
docker run --rm \
-u $(id -u ${USER}):$(id -g ${USER}) \
--mount 'type=bind,source=$(PWD)/policies,target=/home/weaver/policies,readonly' \
--mount 'type=bind,source=$(PWD)/model,target=/home/weaver/source,readonly' \
-v $(PWD)/policies:/policies \
${WEAVER_CONTAINER} registry check \
--registry=/source \
--registry=/home/weaver/source \
--baseline-registry=https://github.com/open-telemetry/semantic-conventions/archive/refs/tags/v$(LATEST_RELEASED_SEMCONV_VERSION).zip[model] \
--policy=/policies
--policy=/home/weaver/policies

# Test rego policies
.PHONY: test-policies
Expand Down
2 changes: 1 addition & 1 deletion dependencies.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Dependabot can keep this file up to date with latest containers.

# Weaver is used to generate markdown docs, and enforce policies on the model.
FROM otel/weaver:0.8.0 AS weaver
FROM otel/weaver:v0.9.0 AS weaver

# OPA is used to test policies enforced by weaver.
FROM openpolicyagent/opa:0.67.1 AS opa
Expand Down

0 comments on commit ad14d55

Please sign in to comment.