Skip to content

Bulk asynchronous downloader for multiple file hosts

ci/cd: improve security of workflows (#1737)

NTFSvolumecc7eb9b81542
diff --git a/.github/workflows/create_release.yaml b/.github/workflows/GH_release.yaml
similarity index 73%
rename from .github/workflows/create_release.yaml
rename to .github/workflows/GH_release.yaml
index 269c20f59..9f8357181 100644
--- a/.github/workflows/create_release.yaml
+++ b/.github/workflows/GH_release.yaml
@@ -3,15 +3,20 @@ name: Create GH Release
on:
workflow_dispatch:
+permissions: {}
+
jobs:
create_release:
+ name: Create GitHub Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
- uses: actions/checkout@v5
+ uses: actions/[email protected]
+ with:
+ persist-credentials: false
- name: Check for version tag
id: check_tag
@@ -26,7 +31,7 @@ jobs:
- name: Extract version number
id: extract_version
run: |
- TAG_NAME=${{ env.TAG_NAME }}
+ TAG_NAME=${TAG_NAME}
VERSION_NUMBER=$(echo "$TAG_NAME" | grep -oE '^[0-9]+' | head -n 1)
if [ -z "$VERSION_NUMBER" ]; then
echo "Error: No numeric version found in tag name."
@@ -37,7 +42,7 @@ jobs:
- name: Extract changelog content
id: extract_changelog
run: |
- TAG_NAME=${{ env.TAG_NAME }}
+ TAG_NAME=${TAG_NAME}
CHANGELOG_CONTENT=$(awk -v version="$TAG_NAME" '
/^#+ \[/ { if (p) { exit }; if ($2 == "["version"]") { p=1; next} } p && NF
' "CHANGELOG.md")
@@ -51,15 +56,16 @@ jobs:
- name: Create start scripts zip
run: |
- mkdir -p zip/Cyberdrop-DL.v${{ env.VERSION_NUMBER }}
- cp -r scripts/release/* zip/Cyberdrop-DL.v${{ env.VERSION_NUMBER }}
+ mkdir -p zip/Cyberdrop-DL.v${VERSION_NUMBER}
+ cp -r scripts/release/* zip/Cyberdrop-DL.v${VERSION_NUMBER}
cd zip
- zip -r ../Cyberdrop-DL.v${{ env.TAG_NAME }}.zip *
+ zip -r ../Cyberdrop-DL.v${TAG_NAME}.zip *
- name: Create GH release
id: create_release
- uses: softprops/action-gh-release@v2
- with:
- name: ${{ env.TAG_NAME }}
- body: ${{ env.CHANGELOG_CONTENT }}
- files: Cyberdrop-DL.v${{ env.TAG_NAME }}.zip
+ run: |
+ gh release create "$TAG_NAME" \
+ --title "$TAG_NAME" \
+ --notes "$CHANGELOG_CONTENT" \
+ --draft \
+ "Cyberdrop-DL.v${TAG_NAME}.zip"
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 46a717fe4..bbed81fbe 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -5,22 +5,27 @@ on:
branches:
- main
paths:
- - 'cyberdrop_dl/**/*.py'
- - 'tests/**/*.py'
- - '.github/workflows/ci.yaml'
+ - "cyberdrop_dl/**/*.py"
+ - "tests/**/*.py"
+ - ".github/workflows/ci.yaml"
pull_request:
branches:
- main
paths:
- - 'cyberdrop_dl/**/*.py'
- - 'cyberdrop_dl/pyproject.toml'
- - 'tests/**/*.py'
- - '.github/workflows/ci.yaml'
+ - "cyberdrop_dl/**/*.py"
+ - "cyberdrop_dl/pyproject.toml"
+ - "tests/**/*.py"
+ - ".github/workflows/ci.yaml"
workflow_dispatch:
-jobs:
+permissions: {}
+jobs:
test:
+ name: Run pytest
+ permissions:
+ contents: read
+
runs-on: ${{ matrix.os }}
strategy:
@@ -34,19 +39,17 @@ jobs:
python-version: "pypy-3.11"
fail-fast: true
- defaults:
- run:
- shell: bash
-
steps:
- name: Checkout code
- uses: actions/checkout@v5
+ uses: actions/[email protected]
+ with:
+ persist-credentials: false
- name: Install uv
- uses: astral-sh/setup-uv@v6
+ uses: astral-sh/[email protected]
with:
- version: "0.10.11"
python-version: ${{ matrix.python-version }}
+ enable-cache: false
- name: Install dependencies
run: |
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index d407edd5c..482cf81aa 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -9,7 +9,7 @@ permissions: {}
jobs:
publish_to_pypi:
- name: publish_to_pypi
+ name: Publish to Pypi
runs-on: ubuntu-latest
environment:
name: pypi
@@ -18,12 +18,12 @@ jobs:
contents: read
steps:
- name: Checkout
- uses: actions/checkout@v6
+ uses: actions/[email protected]
with:
ref: ${{ github.ref_name }}
persist-credentials: false
- name: Install uv
- uses: astral-sh/setup-uv@v7
+ uses: astral-sh/[email protected]
with:
enable-cache: false
- name: Ensure tag matches package version
diff --git a/.github/workflows/ruff.yaml b/.github/workflows/ruff.yaml
index b7dfbc8b1..2781cc0f3 100644
--- a/.github/workflows/ruff.yaml
+++ b/.github/workflows/ruff.yaml
@@ -1,20 +1,24 @@
name: Ruff
-on: [ push, pull_request ]
+
+permissions: {}
+
+on:
+ push:
+ pull_request:
+
jobs:
ruff:
+ name: Lint and format
runs-on: ubuntu-latest
+ permissions:
+ contents: read
+
steps:
- name: checkout code
- uses: actions/checkout@v5
-
- - name: ruff lint
- uses: astral-sh/ruff-action@v3
+ uses: actions/[email protected]
with:
- version: "0.15.6"
+ persist-credentials: false
- - name: ruff format check
- uses: astral-sh/ruff-action@v3
- with:
- version: "0.15.6"
- args:
- "format --check --diff"
+ - uses: astral-sh/[email protected]
+ - run: ruff format --check --diff
+ if: ${{ !cancelled() }}
diff --git a/cyberdrop_dl/crawlers/gofile.py b/cyberdrop_dl/crawlers/gofile.py
index dbb025a1a..37913ec68 100644
--- a/cyberdrop_dl/crawlers/gofile.py
+++ b/cyberdrop_dl/crawlers/gofile.py
@@ -193,7 +193,7 @@ class GoFileCrawler(Crawler):
)
if password:
- sha256_password = sha256(password.encode()).hexdigest()
+ sha256_password = sha256(password.encode(), usedforsecurity=False).hexdigest()
api_url = api_url.update_query(password=sha256_password)
for page in itertools.count(1):