From 83fb6bf0cc5c085a4891725b52b04aa3e64643bd Mon Sep 17 00:00:00 2001 From: jasonpatrickellykrause Date: Mon, 16 Nov 2026 13:30:27 -0700 Subject: [PATCH 1/2] Add CI build, tests, and security scanning - Build workflow restores, builds, and runs tests on pull requests and pushes to main. NuGetAudit already fails restore on high or critical advisories; a final step lists lower-severity ones. - CodeQL scans the C# code (security-extended) and the workflows. - Dependency review fails pull requests that add a dependency with a high or critical advisory. - Dependabot also updates pinned GitHub Actions and groups test package updates. - Tests that call Deezer are tagged Live and skipped in CI. Co-Authored-By: Claude Opus 5.5 --- .github/codeql/codeql-config.yml | 12 ++++++ .github/dependabot.yml | 14 +++++++ .github/workflows/build.yml | 50 ++++++++++++++++++++++ .github/workflows/codeql.yml | 56 +++++++++++++++++++++++++ .github/workflows/dependency-review.yml | 22 ++++++++++ DeezNET.Tests/DeezerURLTests.cs | 4 ++ 6 files changed, 158 insertions(+) create mode 100644 .github/codeql/codeql-config.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/dependency-review.yml diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml new file mode 100644 index 0000000..413ca55 --- /dev/null +++ b/.github/codeql/codeql-config.yml @@ -0,0 +1,12 @@ +name: DeezNET CodeQL config + +# security-extended adds lower-precision security queries on top of the defaults +queries: + - uses: security-extended + +# the library and CLI ship; tests don't +paths: + - DeezNET + - DeezCLI +paths-ignore: + - DeezNET.Tests diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b34f80c..1ee3df9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,3 +5,17 @@ updates: schedule: interval: weekly open-pull-requests-limit: 5 + groups: + # one PR for the test stack instead of one per package + test-dependencies: + patterns: + - "Microsoft.NET.Test.Sdk" + - "xunit*" + - "coverlet*" + - "Shouldly" + + # also keeps the SHA-pinned actions current + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..670b67c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,50 @@ +name: Build +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +# read-only; nothing in this workflow publishes +permissions: + contents: read + +# a newer push to the same branch or PR makes the running build pointless +concurrency: + group: build-${{ github.ref }} + cancel-in-progress: true + +env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + DOTNET_NOLOGO: true + # same SDK as Lidarr.Plugin.Deezer, which builds this library from source + DOTNET_VERSION: 8.0.405 + +jobs: + build: + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Setup .NET + uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + - name: Pin the SDK + # the runner image has newer SDKs that would otherwise take precedence + run: echo '{"sdk":{"version": "${{ env.DOTNET_VERSION }}"}}' > ./global.json + - name: Restore + # NuGetAudit in DeezNET.csproj fails the restore on high or critical advisories, including transitive packages + run: dotnet restore DeezNET.sln + - name: Build + run: dotnet build DeezNET.sln -c Release --no-restore + - name: Test + # tests tagged Live call Deezer and compare against data that changes, so they aren't run here + run: dotnet test DeezNET.Tests -c Release --no-build --filter "Category!=Live" --logger "console;verbosity=normal" + - name: List vulnerable packages + # restore already fails on high and critical; this shows moderate and low ones in the log too + run: dotnet list DeezNET.sln package --vulnerable --include-transitive diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..0b5bd61 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,56 @@ +name: CodeQL +on: + push: + branches: + - main + pull_request: + schedule: + # weekly, so new queries run against unchanged code too + - cron: '23 6 * * 1' + workflow_dispatch: + +permissions: + contents: read + +jobs: + analyze: + runs-on: ubuntu-24.04 + permissions: + contents: read + security-events: write + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Initialize CodeQL + uses: github/codeql-action/init@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2 + with: + languages: csharp + build-mode: none + config-file: ./.github/codeql/codeql-config.yml + - name: Analyze + uses: github/codeql-action/analyze@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2 + with: + category: /language:csharp + + actions: + # scans the workflows themselves, for problems such as script injection from PR titles or overly broad tokens + runs-on: ubuntu-24.04 + permissions: + contents: read + security-events: write + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Initialize CodeQL + uses: github/codeql-action/init@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2 + with: + languages: actions + build-mode: none + - name: Analyze + uses: github/codeql-action/analyze@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2 + with: + category: /language:actions diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 0000000..1586f35 --- /dev/null +++ b/.github/workflows/dependency-review.yml @@ -0,0 +1,22 @@ +name: Dependency Review +on: + pull_request: + +permissions: + contents: read + pull-requests: write + +jobs: + dependency-review: + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Review dependency changes + uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0 + with: + # fail PRs that add a dependency with a known high or critical vulnerability + fail-on-severity: high + comment-summary-in-pr: on-failure diff --git a/DeezNET.Tests/DeezerURLTests.cs b/DeezNET.Tests/DeezerURLTests.cs index 48a34bb..00d585a 100644 --- a/DeezNET.Tests/DeezerURLTests.cs +++ b/DeezNET.Tests/DeezerURLTests.cs @@ -46,6 +46,8 @@ public void TryParseFullUrlTest(string url, bool parsable, long id = 0, EntityTy // i don't know if these short urls expire + // calls Deezer, so CI skips it with --filter "Category!=Live" + [Trait("Category", "Live")] [Theory] [InlineData("https://deezer.page.link/PjpK8Ywdavbpn9FA8", "https://www.deezer.com/track/29373181?host=3103984544&utm_campaign=clipboard-generic&utm_source=user_sharing&utm_content=track-29373181&deferredFl=1")] [InlineData("https://deezer.page.link/27ms3uwmnFK63wsQ6", "https://www.deezer.com/album/548556802?host=3103984544&utm_campaign=clipboard-generic&utm_source=user_sharing&utm_content=album-548556802&deferredFl=1")] @@ -57,6 +59,8 @@ public void UnshortenURLTest(string shortened, string expected) } // it's very possible for the Artist and ArtistTop values to change later + // calls Deezer, so CI skips it with --filter "Category!=Live" + [Trait("Category", "Live")] [Theory] [InlineData("https://www.deezer.com/en/track/13787884", new long[] { 13787884 })] [InlineData("https://www.deezer.com/en/album/509603971", new long[] { 2531592621, 2531592631, 2531592641, 2531592651, 2531592661 })] From bf41a25b1e3f1376a6bfbf39d9dd08b3640ffebd Mon Sep 17 00:00:00 2001 From: jasonpatrickellykrause Date: Mon, 16 Nov 2026 13:40:13 -0700 Subject: [PATCH 2/2] Fix invalid YAML in the build workflow The SDK pin step's plain scalar contained ": ", which YAML parses as a mapping, so GitHub rejected the whole workflow. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 670b67c..17a278b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,9 @@ jobs: dotnet-version: ${{ env.DOTNET_VERSION }} - name: Pin the SDK # the runner image has newer SDKs that would otherwise take precedence - run: echo '{"sdk":{"version": "${{ env.DOTNET_VERSION }}"}}' > ./global.json + # a block scalar, because the ": " inside the JSON would end a plain YAML value + run: | + echo '{"sdk":{"version": "${{ env.DOTNET_VERSION }}"}}' > ./global.json - name: Restore # NuGetAudit in DeezNET.csproj fails the restore on high or critical advisories, including transitive packages run: dotnet restore DeezNET.sln