Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.
Rust chatgptclaudeclidesktopdesktop-appelectron-alternativegeminilinuxmacosnativefierno-electronrusttauriweb-to-desktopwebsite-to-appwebviewwindowsyoutube
fix: harden GitHub Action input handling
Anupam Mediratta4aeff868fd9b
diff --git a/action.yml b/action.ymlindex dffcf778..0e1272e0 100644--- a/action.yml+++ b/action.yml@@ -41,6 +41,7 @@ inputs:outputs:package-path:description: "Path to the generated package"+ value: ${{ steps.build.outputs.package-path }}runs:using: "composite"@@ -58,36 +59,55 @@ runs:# Install Rust/Cargo if neededif ! command -v cargo &> /dev/null; then- curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y+ rustup_init="$(mktemp)"+ trap 'rm -f "$rustup_init"' EXIT+ curl --proto '=https' --tlsv1.2 -sSf -o "$rustup_init" https://sh.rustup.rs+ sh "$rustup_init" -ysource ~/.cargo/env- echo "$HOME/.cargo/bin" >> $GITHUB_PATH+ echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"fi- name: Build Pake App+ id: buildshell: bash+ env:+ INPUT_URL: ${{ inputs.url }}+ INPUT_NAME: ${{ inputs.name }}+ INPUT_ICON: ${{ inputs.icon }}+ INPUT_WIDTH: ${{ inputs.width }}+ INPUT_HEIGHT: ${{ inputs.height }}+ INPUT_DEBUG: ${{ inputs.debug }}+ INPUT_OUTPUT_DIR: ${{ inputs.output-dir }}run: |+ if [[ "$INPUT_OUTPUT_DIR" == *$'\n'* || "$INPUT_OUTPUT_DIR" == *$'\r'* ]]; then+ echo "❌ Output directory must not contain line breaks" >&2+ exit 1+ fi+# Build arguments- ARGS=("${{ inputs.url }}")+ ARGS=("$INPUT_URL")- ARGS+=("--name" "${{ inputs.name }}")+ ARGS+=("--name" "$INPUT_NAME")- if [ -n "${{ inputs.icon }}" ]; then- ARGS+=("--icon" "${{ inputs.icon }}")+ if [ -n "$INPUT_ICON" ]; then+ ARGS+=("--icon" "$INPUT_ICON")fi- ARGS+=("--width" "${{ inputs.width }}")- ARGS+=("--height" "${{ inputs.height }}")+ ARGS+=("--width" "$INPUT_WIDTH")+ ARGS+=("--height" "$INPUT_HEIGHT")- if [ "${{ inputs.debug }}" == "true" ]; then+ if [ "$INPUT_DEBUG" == "true" ]; thenARGS+=("--debug")fi# Create output directory- mkdir -p "${{ inputs.output-dir }}"+ mkdir -p -- "$INPUT_OUTPUT_DIR"export PAKE_CREATE_APP=1# Run Pake CLI- echo "🔧 Running: node dist/cli.js ${ARGS[*]}"+ printf '🔧 Running:'+ printf ' %q' node dist/cli.js "${ARGS[@]}"+ printf '\n'node dist/cli.js "${ARGS[@]}"# Find generated package and set output@@ -100,9 +120,14 @@ runs:if [ -n "$PACKAGE" ]; then# Move to output directoryBASENAME=$(basename "$PACKAGE")- mv "$PACKAGE" "${{ inputs.output-dir }}/$BASENAME" 2>/dev/null || cp -r "$PACKAGE" "${{ inputs.output-dir }}/$BASENAME"- echo "package-path=${{ inputs.output-dir }}/$BASENAME" >> $GITHUB_OUTPUT- echo "✅ Package created: ${{ inputs.output-dir }}/$BASENAME"+ PACKAGE_PATH="$INPUT_OUTPUT_DIR/$BASENAME"+ if [[ "$PACKAGE_PATH" == *$'\n'* || "$PACKAGE_PATH" == *$'\r'* ]]; then+ echo "❌ Package path must not contain line breaks" >&2+ exit 1+ fi+ mv -- "$PACKAGE" "$PACKAGE_PATH" 2>/dev/null || cp -r -- "$PACKAGE" "$PACKAGE_PATH"+ printf 'package-path=%s\n' "$PACKAGE_PATH" >> "$GITHUB_OUTPUT"+ printf '✅ Package created: %s\n' "$PACKAGE_PATH"elseecho "❌ No package found"exit 1diff --git a/tests/unit/action-input-security.test.ts b/tests/unit/action-input-security.test.tsnew file mode 100644index 00000000..0dbf8abb--- /dev/null+++ b/tests/unit/action-input-security.test.ts@@ -0,0 +1,58 @@+import fs from 'node:fs';+import path from 'node:path';+import { describe, expect, it } from 'vitest';++const actionSource = fs.readFileSync(+ path.resolve(__dirname, '../../action.yml'),+ 'utf8',+);++const buildStep = actionSource.slice(+ actionSource.indexOf(' - name: Build Pake App'),+);+const buildRunScript = buildStep.slice(buildStep.indexOf(' run: |'));++describe('Pake composite action input handling', () => {+ it('keeps action expressions out of the generated Bash script', () => {+ expect(buildRunScript).not.toMatch(/\$\{\{\s*inputs\./);++ const mappings = [+ 'INPUT_URL: ${{ inputs.url }}',+ 'INPUT_NAME: ${{ inputs.name }}',+ 'INPUT_ICON: ${{ inputs.icon }}',+ 'INPUT_WIDTH: ${{ inputs.width }}',+ 'INPUT_HEIGHT: ${{ inputs.height }}',+ 'INPUT_DEBUG: ${{ inputs.debug }}',+ 'INPUT_OUTPUT_DIR: ${{ inputs.output-dir }}',+ ];++ for (const mapping of mappings) {+ expect(buildStep).toContain(mapping);+ }+ });++ it('maps the package path from the build step', () => {+ expect(actionSource).toContain(+ 'value: ${{ steps.build.outputs.package-path }}',+ );+ expect(buildStep).toContain('id: build');+ expect(buildStep).toContain(+ `printf 'package-path=%s\\n' "$PACKAGE_PATH" >> "$GITHUB_OUTPUT"`,+ );+ });++ it('rejects line breaks before writing the output command', () => {+ expect(buildStep).toContain(+ String.raw`if [[ "$INPUT_OUTPUT_DIR" == *$'\n'* || "$INPUT_OUTPUT_DIR" == *$'\r'* ]]; then`,+ );+ expect(buildStep).toContain(+ String.raw`if [[ "$PACKAGE_PATH" == *$'\n'* || "$PACKAGE_PATH" == *$'\r'* ]]; then`,+ );+ });++ it('uses a unique temporary file for the Rust installer', () => {+ expect(actionSource).toContain('rustup_init="$(mktemp)"');+ expect(actionSource).toContain(`trap 'rm -f "$rustup_init"' EXIT`);+ expect(actionSource).not.toContain('/tmp/rustup-init.sh');+ });+});