Skip to content

Commit 832b44b

Browse files
authored
Merge pull request #57 from r33drichards/add-opa-docker-compose
Add Docker Compose for OPA and example fetch policy
2 parents 4059987 + 73c76ab commit 832b44b

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

docker-compose.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
services:
2+
opa:
3+
image: openpolicyagent/opa:latest
4+
command: ["run", "--server", "--addr", "0.0.0.0:8181", "/policies"]
5+
ports:
6+
- "8181:8181"
7+
volumes:
8+
- ./policies:/policies:ro

policies/fetch.rego

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package mcp.fetch
2+
3+
default allow = false
4+
5+
# Read-only: GET and HEAD only
6+
allow if {
7+
input.method == "GET"
8+
domain_allowed
9+
}
10+
11+
allow if {
12+
input.method == "HEAD"
13+
domain_allowed
14+
}
15+
16+
# Exact domain matches
17+
exact_domains := {
18+
"github.com",
19+
"api.github.com",
20+
"bedrock-runtime.us-west-2.amazonaws.com",
21+
"bedrock.us-west-2.amazonaws.com",
22+
"sts.amazonaws.com",
23+
"sts.us-west-2.amazonaws.com",
24+
"otel.cua.ai",
25+
"cache.nixos.org",
26+
"channels.nixos.org",
27+
"nixos.org",
28+
"proxy.golang.org",
29+
"sum.golang.org",
30+
"gopkg.in",
31+
"golang.org",
32+
"google.golang.org",
33+
"files.pythonhosted.org",
34+
"pypi.org",
35+
"registry.npmjs.org",
36+
}
37+
38+
# Wildcard suffix matches (*.example.com)
39+
wildcard_suffixes := {
40+
".github.qkg1.top",
41+
".githubusercontent.com",
42+
".cachix.org",
43+
}
44+
45+
domain_allowed if {
46+
exact_domains[input.url_parsed.host]
47+
}
48+
49+
domain_allowed if {
50+
some suffix in wildcard_suffixes
51+
endswith(input.url_parsed.host, suffix)
52+
}

0 commit comments

Comments
 (0)