-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore(bigquery-jdbc): dockerized proxy environment to run integration tests #13546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
logachev
wants to merge
2
commits into
main
Choose a base branch
from
kirl/it_with_proxy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+91
−5
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
java-bigquery-jdbc/tools/environments/proxy/start-proxy.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| #!/bin/bash | ||
| # start-proxy.sh | ||
|
|
||
| set -e | ||
|
|
||
| echo "Starting Squid proxy..." | ||
| # Run squid in background. | ||
| # On Debian, /usr/sbin/squid is the binary. | ||
| # -s sends errors to syslog. -Y during rebuild. -C do not catch fatal signals. | ||
| /usr/sbin/squid -sYC | ||
|
|
||
| # Wait for squid to be ready and listen on 3128 | ||
| echo "Waiting for Squid to listen on port 3128..." | ||
| timeout=30 | ||
| while ! curl -s -I -x http://127.0.0.1:3128 https://www.google.com >/dev/null; do | ||
| sleep 1 | ||
| timeout=$((timeout - 1)) | ||
| if [ $timeout -le 0 ]; then | ||
| echo "Squid failed to start or cannot access the internet." | ||
| exit 1 | ||
| fi | ||
| done | ||
| echo "Squid is ready and working." | ||
|
|
||
| # Configure iptables to restrict network access | ||
| echo "Configuring iptables rules..." | ||
|
|
||
| # 1. Allow loopback traffic | ||
| iptables -A OUTPUT -o lo -j ACCEPT | ||
|
|
||
| # 2. Allow squid user (proxy) to access the network | ||
| iptables -A OUTPUT -m owner --uid-owner proxy -j ACCEPT | ||
|
|
||
| # 3. Allow DNS (port 53) for everyone | ||
| iptables -A OUTPUT -p udp --dport 53 -j ACCEPT | ||
| iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT | ||
|
|
||
| # 4. Allow outgoing traffic to port 3128 (proxies) for testing external proxies | ||
| iptables -A OUTPUT -p tcp --dport 3128 -j ACCEPT | ||
|
|
||
| # 4.5 Allow raw access to Maven Central (repo.maven.apache.org) for dynamic dependency downloads | ||
| echo "Resolving repo.maven.apache.org and allowing raw access..." | ||
| for ip in $(getent ahosts repo.maven.apache.org | awk '{print $1}' | sort -u); do | ||
| if [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| echo "Allowing outbound to $ip" | ||
| iptables -A OUTPUT -d "$ip" -p tcp --dport 443 -j ACCEPT | ||
| iptables -A OUTPUT -d "$ip" -p tcp --dport 80 -j ACCEPT | ||
| fi | ||
| done | ||
|
|
||
| # 5. Reject all other outgoing TCP/UDP traffic | ||
| iptables -A OUTPUT -p tcp -j REJECT --reject-with tcp-reset | ||
| iptables -A OUTPUT -p udp -j REJECT | ||
|
|
||
| echo "Raw network access is now disabled. All traffic must go through the proxy." | ||
|
|
||
| # Execute the main command | ||
| exec "$@" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.