mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 22:44:13 +08:00
Remove unnecessary network restrictions test and update readme + action.yml with no default domains and respective instructions in the readme
This commit is contained in:
35
README.md
35
README.md
@@ -500,22 +500,41 @@ For enhanced security, you can restrict Claude's network access to specific doma
|
|||||||
- Preventing access to external services
|
- Preventing access to external services
|
||||||
- Limiting Claude to only your internal APIs and services
|
- Limiting Claude to only your internal APIs and services
|
||||||
|
|
||||||
When `allowed_domains` is set, Claude can only access:
|
When `allowed_domains` is set, Claude can only access the domains you explicitly list. You'll need to include the appropriate provider domains based on your authentication method.
|
||||||
|
|
||||||
1. The domains you explicitly list
|
#### Provider-Specific Examples
|
||||||
2. Auto-detected provider domains (based on your authentication method)
|
|
||||||
|
|
||||||
#### Basic Example
|
##### If using Anthropic API or subscription
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: anthropics/claude-code-action@beta
|
- uses: anthropics/claude-code-action@beta
|
||||||
with:
|
with:
|
||||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||||
|
# Or: claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
||||||
allowed_domains: |
|
allowed_domains: |
|
||||||
.github.com
|
.anthropic.com
|
||||||
.githubusercontent.com
|
```
|
||||||
ghcr.io
|
|
||||||
.blob.core.windows.net
|
##### If using AWS Bedrock
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: anthropics/claude-code-action@beta
|
||||||
|
with:
|
||||||
|
use_bedrock: "true"
|
||||||
|
allowed_domains: |
|
||||||
|
bedrock.*.amazonaws.com
|
||||||
|
bedrock-runtime.*.amazonaws.com
|
||||||
|
```
|
||||||
|
|
||||||
|
##### If using Google Vertex AI
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: anthropics/claude-code-action@beta
|
||||||
|
with:
|
||||||
|
use_vertex: "true"
|
||||||
|
allowed_domains: |
|
||||||
|
*.googleapis.com
|
||||||
|
vertexai.googleapis.com
|
||||||
```
|
```
|
||||||
|
|
||||||
#### GitHub Enterprise Example
|
#### GitHub Enterprise Example
|
||||||
|
|||||||
18
action.yml
18
action.yml
@@ -153,26 +153,12 @@ runs:
|
|||||||
# Install and configure Squid proxy
|
# Install and configure Squid proxy
|
||||||
sudo apt-get update && sudo apt-get install -y squid
|
sudo apt-get update && sudo apt-get install -y squid
|
||||||
|
|
||||||
echo "${{ inputs.allowed_domains }}" > /tmp/whitelist.txt
|
echo "${{ inputs.allowed_domains }}" > $RUNNER_TEMP/whitelist.txt
|
||||||
|
|
||||||
if [[ -n "${{ inputs.anthropic_api_key }}" ]]; then
|
|
||||||
echo ".anthropic.com" >> /tmp/whitelist.txt
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${{ inputs.use_bedrock }}" == "true" ]]; then
|
|
||||||
echo "bedrock.*.amazonaws.com" >> /tmp/whitelist.txt
|
|
||||||
echo "bedrock-runtime.*.amazonaws.com" >> /tmp/whitelist.txt
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${{ inputs.use_vertex }}" == "true" ]]; then
|
|
||||||
echo "*.googleapis.com" >> /tmp/whitelist.txt
|
|
||||||
echo "vertexai.googleapis.com" >> /tmp/whitelist.txt
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Configure Squid
|
# Configure Squid
|
||||||
sudo tee /etc/squid/squid.conf << 'EOF'
|
sudo tee /etc/squid/squid.conf << 'EOF'
|
||||||
http_port 127.0.0.1:3128
|
http_port 127.0.0.1:3128
|
||||||
acl whitelist dstdomain "/tmp/whitelist.txt"
|
acl whitelist dstdomain "$RUNNER_TEMP/whitelist.txt"
|
||||||
acl localhost src 127.0.0.1/32
|
acl localhost src 127.0.0.1/32
|
||||||
http_access allow localhost whitelist
|
http_access allow localhost whitelist
|
||||||
http_access deny all
|
http_access deny all
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
import { describe, test, expect } from "bun:test";
|
|
||||||
|
|
||||||
describe("Network Restrictions", () => {
|
|
||||||
test("should block access to unauthorized domains", async () => {
|
|
||||||
const url = "https://example.com/api/data";
|
|
||||||
|
|
||||||
try {
|
|
||||||
const controller = new AbortController();
|
|
||||||
const timeoutId = setTimeout(() => controller.abort(), 5000);
|
|
||||||
|
|
||||||
const response = await fetch(url, {
|
|
||||||
signal: controller.signal,
|
|
||||||
});
|
|
||||||
|
|
||||||
clearTimeout(timeoutId);
|
|
||||||
expect(response.ok).toBe(false);
|
|
||||||
throw new Error(`Unauthorized domain ${url} was not blocked by proxy`);
|
|
||||||
} catch (error) {
|
|
||||||
expect(error).toBeDefined();
|
|
||||||
console.log(`Successfully blocked: ${url}`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should allow access to whitelisted domains", async () => {
|
|
||||||
const url = "https://api.github.com/zen";
|
|
||||||
|
|
||||||
try {
|
|
||||||
const controller = new AbortController();
|
|
||||||
const timeoutId = setTimeout(() => controller.abort(), 5000);
|
|
||||||
|
|
||||||
const response = await fetch(url, {
|
|
||||||
signal: controller.signal,
|
|
||||||
});
|
|
||||||
|
|
||||||
clearTimeout(timeoutId);
|
|
||||||
expect(response.ok).toBe(true);
|
|
||||||
console.log(`Successfully allowed: ${url}`);
|
|
||||||
} catch (error: any) {
|
|
||||||
throw new Error(
|
|
||||||
`Whitelisted domain ${url} was blocked: ${error.message}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user