Skip to content

fix(ci): hardening security of GH actions #6305

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
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
# Make this a reusable workflow, no value needed
# https://docs.github.com/en/actions/using-workflows/reusing-workflows

permissions:
contents: read

jobs:
build_core:
name: Core
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/create-production-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:
create-stencil-release-pull-request:
name: Generate Stencil Release PR
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
# Log the input from GitHub Actions for easy traceability
- name: Log GitHub Input
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/lint-and-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
# Make this a reusable workflow, no value needed
# https://docs.github.com/en/actions/using-workflows/reusing-workflows

permissions:
contents: read

jobs:
format:
name: Check
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
build_core:
name: Build
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
description: The version that was just published to npm.
value: ${{ jobs.get-dev-version.outputs.dev-version }}

permissions:
contents: read

jobs:
build_core:
name: Build
Expand Down Expand Up @@ -57,6 +60,7 @@ jobs:
needs: [get-dev-version, build_core]
runs-on: ubuntu-22.04
permissions:
contents: read
id-token: write
steps:
- name: Checkout Code
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
workflow_dispatch:
# Allow this workflow to be run on-demand

permissions:
contents: read

jobs:
build_core:
name: Build
Expand Down Expand Up @@ -59,6 +62,7 @@ jobs:
needs: [get-nightly-version, build_core]
runs-on: ubuntu-22.04
permissions:
contents: read
id-token: write
steps:
- name: Checkout Code
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
# Make this a reusable workflow, no value needed
# https://docs.github.com/en/actions/using-workflows/reusing-workflows

permissions:
contents: read

jobs:
analysis_test:
name: (${{ matrix.os }}.${{ matrix.node }})
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-bundlers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
# Make this a reusable workflow, no value needed
# https://docs.github.com/en/actions/using-workflows/reusing-workflows

permissions:
contents: read

jobs:
bundler_tests:
name: Verify Bundlers
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-component-starter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
# Make this a reusable workflow, no value needed
# https://docs.github.com/en/actions/using-workflows/reusing-workflows

permissions:
contents: read

jobs:
analysis_test:
name: (${{ matrix.os }}.node-${{ matrix.node }}.jest-${{ matrix.jest }})
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test-copytask.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ on:
# Make this a reusable workflow, no value needed
# https://docs.github.com/en/actions/using-workflows/reusing-workflows

permissions:
contents: read

jobs:
bundler_tests:
name: Verify Copy Task
runs-on: 'ubuntu-22.04'
steps:
- name: Checkout Code
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Get Core Dependencies
uses: ./.github/workflows/actions/get-core-dependencies
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test-docs-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ on:
# Make this a reusable workflow, no value needed
# https://docs.github.com/en/actions/using-workflows/reusing-workflows

permissions:
contents: read

jobs:
docs_build_test:
name: (${{ matrix.os }}.${{ matrix.node }})
strategy:
fail-fast: false
matrix:
node: ['16', '18', '20', '22']
node: ['18', '20', '22']
os: ['ubuntu-latest', 'windows-latest']
runs-on: ${{ matrix.os }}
steps:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
# Make this a reusable workflow, no value needed
# https://docs.github.com/en/actions/using-workflows/reusing-workflows

permissions:
contents: read

jobs:
e2e_test:
name: (${{ matrix.os }}.${{ matrix.node }})
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/test-types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ on:
# Make this a reusable workflow, no value needed
# https://docs.github.com/en/actions/using-workflows/reusing-workflows

permissions:
contents: read

jobs:
unit_test:
name: Type Tests
strategy:
fail-fast: false
matrix:
node: ['18', '20', '22']
runs-on: ubuntu-latest
steps:
- name: Checkout Code
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ on:
# Make this a reusable workflow, no value needed
# https://docs.github.com/en/actions/using-workflows/reusing-workflows

permissions:
contents: read

jobs:
unit_test:
name: (${{ matrix.os }}.${{ matrix.node }})
strategy:
fail-fast: false
matrix:
node: ['16', '18', '20', '22']
node: ['18', '20', '22']
os: ['ubuntu-latest', 'windows-latest']
runs-on: ${{ matrix.os }}
steps:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-wdio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
# Make this a reusable workflow, no value needed
# https://docs.github.com/en/actions/using-workflows/reusing-workflows

permissions:
contents: read

jobs:
wdio_test:
name: Run WebdriverIO Component Tests (${{ matrix.browser }})
Expand Down
172 changes: 0 additions & 172 deletions renovate.json5

This file was deleted.

5 changes: 5 additions & 0 deletions src/dev-server/request-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export function createRequestHandler(devServerConfig: d.DevServerConfig, serverC
try {
const req = normalizeHttpRequest(devServerConfig, incomingReq);

// check for directory traversal
if (!normalizePath(req.filePath).startsWith(normalizePath(devServerConfig.root))) {
return serverCtx.serve404(req, res, `invalid path`, `404 File Not Found`);
}

if (!req.url) {
return serverCtx.serve302(req, res);
}
Expand Down
Loading