Skip to content

Commit 3e7b28c

Browse files
authored
fix: setup-gap log levels (#1000)
* fix: envoy proxy health check * chore: add changeset * fix: logging, reorganize logic * fix: restrict debug logging * chore: add changeset
1 parent fa6726f commit 3e7b28c

4 files changed

Lines changed: 185 additions & 79 deletions

File tree

.changeset/mean-pumpkins-rhyme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"setup-gap": minor
3+
---
4+
5+
feat: restrict debug logging in public repositories

actions/setup-gap/action.yml

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -269,16 +269,52 @@ runs:
269269
# Verify the installation by checking version
270270
gomplate --version
271271
272+
- name: Check Debug Mode
273+
id: enable-debug
274+
shell: bash
275+
env:
276+
ENABLE_PROXY_DEBUG: ${{ inputs.enable-proxy-debug }}
277+
PROXY_LOG_LEVEL: ${{ inputs.proxy-log-level }}
278+
GH_TOKEN: ${{ github.token }}
279+
run: |
280+
if [[ "$ENABLE_PROXY_DEBUG" == "false" && "$PROXY_LOG_LEVEL" == "info" ]]; then
281+
# default inputs
282+
echo "Setting debug-mode to false because of default inputs"
283+
echo "debug-mode=false" | tee -a $GITHUB_OUTPUT
284+
exit 0
285+
fi
286+
287+
# Get repository visibility using GitHub CLI
288+
# either public, private, or internal
289+
REPO_VISIBILITY=$(gh api repos/${GITHUB_REPOSITORY} --jq '.visibility')
290+
291+
if [[ "$REPO_VISIBILITY" == "public" ]]; then
292+
echo "Repository is public, debug logging is restricted."
293+
echo "debug-mode=false" >> $GITHUB_OUTPUT
294+
exit 0
295+
fi
296+
297+
if [[ "$REPO_VISIBILITY" == "private" || "$REPO_VISIBILITY" == "internal" ]]; then
298+
if [ "$ENABLE_PROXY_DEBUG" = "true" ] || [ "$PROXY_LOG_LEVEL" = "debug" ]; then
299+
echo "Repo is private and enable-proxy-debug is true or proxy-log-level is debug."
300+
echo "debug-mode=true" >> $GITHUB_OUTPUT
301+
else
302+
echo "debug-mode=false" >> $GITHUB_OUTPUT
303+
fi
304+
exit 0
305+
fi
306+
307+
echo "::warning::Unknown repository visibility: $REPO_VISIBILITY. Setting debug-mode to false."
308+
echo "debug-mode=false" >> $GITHUB_OUTPUT
309+
272310
- name: Setup and run services
273311
id: setup-services
274312
shell: bash
275313
env:
276314
GAP_NAME: "gap-${{ inputs.gap-name }}"
277315
DYNAMIC_PROXY_PORT: ${{ inputs.dynamic-proxy-port }}
278-
ENABLE_PROXY_DEBUG: ${{ inputs.enable-proxy-debug }}
279316
GITHUB_OIDC_TOKEN_HEADER_NAME:
280317
${{ inputs.github-oidc-token-header-name }}
281-
PROXY_LOG_LEVEL: ${{ inputs.proxy-log-level }}
282318
ENVOY_PROXY_IMAGE: ${{ inputs.envoy-proxy-image }}
283319
K8S_API_ENDPOINT_PORT: ${{ inputs.k8s-api-endpoint-port }}
284320
MAIN_DNS_ZONE: ${{ inputs.main-dns-zone }}
@@ -288,27 +324,27 @@ runs:
288324
AUTH_SERVICE_NAME: ${{ inputs.gap-name }}-authz
289325
AUTH_SERVICE_PORT: ${{ inputs.auth-service-port }}
290326
PATH_CERTS_DIR: ${{ env.PATH_CERTS_DIR }}
327+
DEBUG_MODE: ${{ steps.enable-debug.outputs.debug-mode }}
291328
REQUIRED_ENV_VARS: >-
292329
WEBSOCKETS_PROXY_PORT DYNAMIC_PROXY_PORT PROXY_PORT
293-
K8S_API_ENDPOINT_PORT MAIN_DNS_ZONE ENVOY_PROXY_IMAGE
294-
ENABLE_PROXY_DEBUG PROXY_LOG_LEVEL AUTH_SERVICE_NAME AUTH_SERVICE_PORT
330+
K8S_API_ENDPOINT_PORT MAIN_DNS_ZONE ENVOY_PROXY_IMAGE PROXY_LOG_LEVEL
331+
AUTH_LOG_LEVEL AUTH_SERVICE_NAME AUTH_SERVICE_PORT
295332
ACTIONS_ID_TOKEN_REQUEST_TOKEN ACTIONS_ID_TOKEN_REQUEST_URL
296333
GITHUB_REPOSITORY GITHUB_OIDC_TOKEN_HEADER_NAME GITHUB_OIDC_HOSTNAME
297334
run: |
298335
# Get the Github OIDC hostname
299336
export GITHUB_OIDC_HOSTNAME=$(echo $ACTIONS_ID_TOKEN_REQUEST_URL | awk -F[/:] '{print $4}')
300337
301-
# Set additional debug flags if debug logging is enabled
302-
if [ "$ENABLE_PROXY_DEBUG" = "true" ] || [ "$PROXY_LOG_LEVEL" = "debug" ]; then
338+
export PROXY_LOG_LEVEL="info"
339+
export AUTH_LOG_LEVEL="info"
340+
export ENVOY_EXTRA_ARGS=""
341+
if [[ "$DEBUG_MODE" == "true" ]]; then
342+
echo "Debug logging enabled with component logging"
303343
export PROXY_LOG_LEVEL="debug"
344+
export AUTH_LOG_LEVEL="debug"
304345
export ENVOY_EXTRA_ARGS="--component-log-level upstream:debug,connection:debug,router:debug,http:debug,filter:debug,client:debug"
305-
echo "Debug logging enabled with component logging"
306-
else
307-
export ENVOY_EXTRA_ARGS=""
308346
fi
309347
310-
echo "Using log level: ${PROXY_LOG_LEVEL}"
311-
312348
# Loop through each variable and check if it's empty
313349
for var in $REQUIRED_ENV_VARS; do
314350
eval value=\$$var
@@ -327,18 +363,16 @@ runs:
327363
328364
echo "Validating Envoy config..."
329365
if ! docker run --rm \
330-
--dns 8.8.8.8
331-
--dns 8.8.4.4
332366
--volume "${PATH_CERTS_DIR}":/tls \
333367
--volume "${GITHUB_ACTION_PATH}/envoy.yaml":/etc/envoy/envoy.yaml \
334368
"${ENVOY_PROXY_IMAGE}" \
335369
/usr/local/bin/envoy --mode validate -c /etc/envoy/envoy.yaml \
336-
--log-level "${PROXY_LOG_LEVEL}" "${ENVOY_EXTRA_ARGS}"; then
370+
--log-level "${PROXY_LOG_LEVEL}" ${ENVOY_EXTRA_ARGS}; then
337371
echo "::error::Envoy configuration validation failed."
338372
exit 1
339373
fi
340374
341-
if [ "$ENABLE_PROXY_DEBUG" = "true" ] || [ "$PROXY_LOG_LEVEL" = "debug" ]; then
375+
if [[ "$DEBUG_MODE" == "true" ]]; then
342376
echo "Docker compose configuration:"
343377
docker compose -f "${GITHUB_ACTION_PATH}/docker-compose.yml" config
344378
fi

0 commit comments

Comments
 (0)