@@ -35,14 +35,21 @@ runs:
3535 steps :
3636 - name : Run in sandbox
3737 shell : bash -e -o pipefail {0}
38+ env :
39+ INPUTS_ALLOW_CHECKOUT_CREDENTIALS : ${{ inputs.allow-checkout-credentials }}
40+ INPUTS_DISABLE_NETWORK : ${{ inputs.disable-network }}
41+ INPUTS_ENV : ${{ inputs.env }}
42+ INPUTS_PERSIST_WORKSPACE_CHANGES : ${{ inputs.persist-workspace-changes }}
43+ INPUTS_ROOTFS_IMAGE : ${{ inputs.rootfs-image }}
44+ INPUTS_RUN : ${{ inputs.run }}
3845 run : |
3946 # Set up and run the gVisor sandbox
4047
4148 # Check for persisted tokens from checkout action (unless explicitly allowed)
42- if [ -f "${{ github.workspace }} /.git/config" ]; then
49+ if [ -f "$GITHUB_WORKSPACE /.git/config" ]; then
4350 # Check if git config contains authorization tokens
44- if grep -q "AUTHORIZATION:" "${{ github.workspace }} /.git/config" 2>/dev/null; then
45- if [ "${{ inputs.allow-checkout-credentials }} " != "true" ]; then
51+ if grep -q "AUTHORIZATION:" "$GITHUB_WORKSPACE /.git/config" 2>/dev/null; then
52+ if [ "$INPUTS_ALLOW_CHECKOUT_CREDENTIALS " != "true" ]; then
4653 echo "::error::Security Error: Detected persisted authentication token from checkout action"
4754 echo "::error::The checkout action has persisted credentials in .git/config which would be accessible inside the sandbox."
4855 echo "::error::To fix this, use 'persist-credentials: false' in your checkout step:"
@@ -61,14 +68,14 @@ runs:
6168 SANDBOX_DIR=$(mktemp -d /tmp/gvisor-sandbox-XXXXXX)
6269
6370 # Download and extract Docker image as rootfs
64- echo "Downloading rootfs image: ${{ inputs.rootfs-image }} ..."
71+ echo "Downloading rootfs image: $INPUTS_ROOTFS_IMAGE ..."
6572 mkdir -p "$SANDBOX_DIR/rootfs"
6673
6774 # Pull the Docker image
68- docker pull --platform linux/amd64 "${{ inputs.rootfs-image }} "
75+ docker pull --platform linux/amd64 "$INPUTS_ROOTFS_IMAGE "
6976
7077 # Create a container from the image (don't start it)
71- CONTAINER_ID=$(docker create --platform linux/amd64 "${{ inputs.rootfs-image }} " /bin/true)
78+ CONTAINER_ID=$(docker create --platform linux/amd64 "$INPUTS_ROOTFS_IMAGE " /bin/true)
7279
7380 # Export the container's filesystem
7481 echo "Extracting rootfs from Docker image..."
8592 sudo cp /etc/resolv.conf "$SANDBOX_DIR/rootfs/etc/resolv.conf"
8693
8794 # Create parent directories for workspace mount point
88- WORKSPACE_DIR="${{ github.workspace }} "
95+ WORKSPACE_DIR="$GITHUB_WORKSPACE "
8996 WORKSPACE_PARENT=$(dirname "$WORKSPACE_DIR")
9097 sudo mkdir -p "$SANDBOX_DIR/rootfs$WORKSPACE_PARENT"
9198
@@ -95,25 +102,25 @@ runs:
95102 fi
96103
97104 # Create the user script inside the rootfs
98- sudo tee "$SANDBOX_DIR/rootfs/entrypoint.sh" > /dev/null << ' SANDBOXED_SCRIPT_EOF'
105+ sudo tee "$SANDBOX_DIR/rootfs/entrypoint.sh" > /dev/null << SANDBOXED_SCRIPT_EOF
99106 #!/bin/bash
100107 set -euo pipefail # Exit on any error, undefined variable, or pipe failure
101- cd "${{ github.workspace }} "
102- ${{ inputs.run }}
108+ cd "\$GITHUB_WORKSPACE "
109+ $INPUTS_RUN
103110 SANDBOXED_SCRIPT_EOF
104111
105112 sudo chmod +x "$SANDBOX_DIR/rootfs/entrypoint.sh"
106113
107114 # Generate OCI config using the pre-built binary
108115 # Write the env input to a temporary file to safely handle quotes and newlines
109- cat > "$SANDBOX_DIR/additional_env.txt" << ' SANDBOXED_ENV_EOF'
110- ${{ inputs.env }}
116+ cat > "$SANDBOX_DIR/additional_env.txt" << SANDBOXED_ENV_EOF
117+ $INPUTS_ENV
111118 SANDBOXED_ENV_EOF
112119 # Only pass the file if it's not empty
113120 if [ -s "$SANDBOX_DIR/additional_env.txt" ]; then
114- "${{ github.action_path }} /generate-config" "$SANDBOX_DIR/additional_env.txt" > "$SANDBOX_DIR/config.json"
121+ "$GITHUB_ACTION_PATH /generate-config" "$SANDBOX_DIR/additional_env.txt" > "$SANDBOX_DIR/config.json"
115122 else
116- "${{ github.action_path }} /generate-config" > "$SANDBOX_DIR/config.json"
123+ "$GITHUB_ACTION_PATH /generate-config" > "$SANDBOX_DIR/config.json"
117124 fi
118125
119126 # Run the container with runsc
@@ -123,7 +130,7 @@ runs:
123130 cd "$SANDBOX_DIR"
124131 # Configure overlay based on persist-workspace-changes setting
125132 # Note: Running runsc with sudo but container processes still run as runner user (not root)
126- if [ "${{ inputs.persist-workspace-changes }} " = "true" ]; then
133+ if [ "$INPUTS_PERSIST_WORKSPACE_CHANGES " = "true" ]; then
127134 echo "::warning::Workspace changes will persist on the host filesystem"
128135 # Use overlay only for root filesystem, not for bind mounts (workspace)
129136 OVERLAY_FLAGS="--overlay2=root:self"
@@ -132,7 +139,7 @@ runs:
132139 OVERLAY_FLAGS="--overlay2=all:self"
133140 fi
134141 # Configure network based on disable-network setting
135- if [ "${{ inputs.disable-network }} " = "true" ]; then
142+ if [ "$INPUTS_DISABLE_NETWORK " = "true" ]; then
136143 echo "::notice::Network access disabled in sandbox"
137144 NETWORK_FLAGS="--network=none"
138145 else
@@ -145,7 +152,7 @@ runs:
145152 fi
146153 # Run the sandbox and capture exit code
147154 EXIT_CODE=0
148- sudo "${{ github.action_path }} /runsc" $RUNSC_FLAGS run "$CONTAINER_ID" || EXIT_CODE=$?
155+ sudo "$GITHUB_ACTION_PATH /runsc" $RUNSC_FLAGS run "$CONTAINER_ID" || EXIT_CODE=$?
149156
150157 # Clean up (always run, even if sandbox failed)
151158 cd /
0 commit comments