Skip to content

ci: fix DevSkim SARIF upload on main (codeql-action v4, security-events permission) - #893

Open
vadim-korolik wants to merge 1 commit into
mainfrom
termag-vkorolik/cmwl8thxv0hs37bf97g5455aw
Open

vadim-korolik wants to merge 1 commit into
mainfrom
termag-vkorolik/cmwl8thxv0hs37bf97g5455aw

Conversation

@vadim-korolik

@vadim-korolik vadim-korolik commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Demo

Before/fix/after transcript: https://app.termag.ldinfra.net/termag/files/vkorolik-observability-sdk/artifacts/ci-devskim-dotnet/devskim-demo.md

DevSkim, dispatched on this branch (run 44187513739): passed, and the SARIF upload produced a devskim code-scanning analysis for the branch (376 results).

Why main fails

DevSkim has failed on every push and schedule run on main since 2026-03-26. The last green run was 2026-03-24. The failing step is "Upload DevSkim scan results to GitHub Security tab" (.github/workflows/devskim.yml:32-35):

  • Resource not accessible by integration: the repo's default GITHUB_TOKEN is read-only (default_workflow_permissions: read), and the workflow declared no permissions:, so it couldn't write security-events. PR runs pass this step, so the failure only appeared on main.
  • CodeQL Action major versions v1 and v2 have been deprecated: upload-sarif@v2 (line 33) is now a hard failure.

Change

  • github/codeql-action/upload-sarif@v2 → @v4, the same major version as the repo's CodeQL default setup.
  • The workflow gets contents: read. The job gets contents: read, security-events: write and actions: read.

Related

The other half of this ask, the .NET SDK workflow, is in #894.

Asked by vkorolik through termag ask; follow up with termag ask … --thread cmwl8thxv0hs37bf97g5455aw.

🤖 Generated with Claude Code

Opened from termag


Note

Overview
Restores successful DevSkim runs on main by fixing the “Upload DevSkim scan results to GitHub Security tab” step in devskim.yml.

The workflow now declares contents: read at the workflow level, and the DevSkim job grants security-events: write and actions: read so the default read-only GITHUB_TOKEN can publish SARIF to the Security tab (the previous failure on push/schedule was “Resource not accessible by integration”).

The upload action is bumped from github/codeql-action/upload-sarif@v2 to @v4, aligning with the repo’s CodeQL setup and avoiding deprecation hard-fails on v2.

Reviewed by Cursor Bugbot for commit 75ec5b0. Bugbot is set up for automated code reviews on this repo. Configure here.

…nts permission)

The upload-sarif step has failed on every push/schedule run since
2026-03-26 with 'Resource not accessible by integration': the repo's
default GITHUB_TOKEN is read-only, so uploading to code scanning needs an
explicit security-events: write. It also used github/codeql-action v2,
which is deprecated and now fails the step. Move to v4 (what the repo's
CodeQL default setup uses) and grant contents/actions read +
security-events write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Generated-by: termag
@vadim-korolik

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 75ec5b0. Configure here.

@vadim-korolik
vadim-korolik marked this pull request as ready for review November 17, 2026 22:36
@vadim-korolik
vadim-korolik requested a review from a team as a code owner November 17, 2026 22:36
vadim-korolik added a commit that referenced this pull request Nov 18, 2026
…n the version is new (#894)

<!-- TERMAG_PR_BODY_BEGIN -->
## Demo
Before/fix/after transcript:
https://app.termag.ldinfra.net/termag/files/vkorolik-observability-sdk/artifacts/ci-devskim-dotnet/dotnet-demo.md

## Why main fails
Both jobs of `.NET SDK` have failed at "Push generated package to NuGet
registry" on every push to `main` since 2026-04-16. The last green run
was 2026-04-15, and no .NET code changed between the two.

- `.github/workflows/dotnet.yml:35-39` (ASP.NET Core) and `:67-70`
(ASP.NET4) push on **every** main push. The versions they push are
Highlight.ASPCore 0.2.16 (published 2025-03-25) and Highlight.ASP4
0.2.10, both already on nuget.org. So each push was a duplicate, and
`--skip-duplicate` / `-SkipDuplicate` turned nuget.org's 409 into a
pass.
- The `NUGET_API_KEY` repo secret was last updated
**2025-04-16T19:49Z**. The first failure was 2026-04-16T21:02Z, which
matches nuget.org's 365-day maximum key lifetime. nuget.org rejects an
expired key before it checks for duplicates, so the push exits 1.

## Change
- **Only push new versions.** A new step, "Check whether the package
version is already on NuGet" (`.github/scripts/nuget-needs-publish.sh`),
looks up each built `.nupkg`'s id and version (symbols skipped) in
nuget.org's flat-container index. It writes `publish=true` only when a
version isn't published yet. Pushes to `main` that don't bump a version
no longer touch NuGet.
- **Trusted publishing instead of `NUGET_API_KEY`**, as in [NuGet's
docs](https://learn.microsoft.com/en-us/nuget/nuget-org/trusted-publishing):
  - Both jobs get `permissions: contents: read, id-token: write`.
- A new step, `NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 #
v1.2.0` with `user: ${{ secrets.NUGET_USER }}`, runs only when a push
will happen. This is the docs' `NuGet/login@v1`, pinned by SHA like the
repo's other third-party actions (SEC-7924). It trades the job's GitHub
OIDC token for a nuget.org API key that lasts one hour.
- The push steps take that key from `steps.login.outputs.NUGET_API_KEY`
through an env var. ASP.NET Core uses `dotnet nuget push --api-key
"$NUGET_API_KEY"`. ASP.NET4 keeps its `nuget push bin\**\*.nupkg`
command (now `-ApiKey $env:NUGET_API_KEY`). I dropped `-SymbolApiKey`
because the project builds no symbol packages.
- `dotnet.yml` no longer references `secrets.NUGET_API_KEY`. I didn't
delete the secret.
- No other workflow in the repo publishes to NuGet, so there was nothing
to stay consistent with. `observability-dotnet` has no NuGet release
workflow here.
- No package versions or release-please files changed.

## Verification
- PR run
[44205999788](https://github.com/launchdarkly/observability-sdk/actions/runs/44205999788)
passed on both jobs (Linux and Windows). Notices show `highlight.aspcore
0.2.16` and `highlight.asp4 0.2.10` are already on nuget.org. Both the
"NuGet login" and "Push" steps were skipped, and nothing was published.
- `actionlint` 1.7.12 reports only the custom runner label, which `main`
also has.
- After switching to `secrets.NUGET_USER` (3c4e6f9): PR run
[44207123511](https://github.com/launchdarkly/observability-sdk/actions/runs/44207123511)
passed on both jobs, with login and push skipped. actionlint is
unchanged.
- **Not exercised yet:** the OIDC login and push only run on `main` when
a version is new, so they can't be tested until the next version bump of
Highlight.ASPCore or Highlight.ASP4. Before that bump, do the setup
below. Otherwise the first push fails at "NuGet login".

## Setup needed on nuget.org
These must match `.github/workflows/dotnet.yml` exactly, or
`NuGet/login` fails (fields are case-insensitive).

- [ ] Sign in to nuget.org as a member of the **`Highlight`**
organization, which owns both **Highlight.ASPCore** and
**Highlight.ASP4**. Then choose your username → **Trusted Publishing** →
add a GitHub Actions policy:
- **Policy owner:** `Highlight`. The policy covers every package that
owner has, which includes Highlight.ASPCore and Highlight.ASP4.
  - **Repository Owner:** `launchdarkly`
  - **Repository:** `observability-sdk`
- **Workflow File:** `dotnet.yml` (file name only, no
`.github/workflows/` path)
  - **Environment:** *leave empty*. Neither job sets `environment:`.
- [x] Repository secret **`NUGET_USER`** (Settings → Secrets and
variables → Actions → Secrets), set 2026-11-18. It holds the nuget.org
**username (profile name, not email)** of the account that created the
policy. The workflow passes it as `user: ${{ secrets.NUGET_USER }}` to
`NuGet/login`, as NuGet's docs recommend.
- [ ] Don't rename `dotnet.yml`. Renaming it breaks the policy.
- [ ] After the first successful trusted-publishing push, delete the
expired `NUGET_API_KEY` repo secret. Nothing in the repo uses it any
more, and this PR leaves it in place.

## Related
The DevSkim half of this ask: #893.

Asked by `vkorolik` through `termag ask`; follow up with `termag ask …
--thread cmwl8thxv0hs37bf97g5455aw`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- TERMAG_PR_BODY_END -->

<!-- termag: box=i-061783cb7582c0ce0 project=repo
ask=cmwl8thxv0hs37bf97g5455aw -->
<sub>Opened from termag</sub>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@vadim-korolik vadim-korolik added the merge-ready Approved, CI green, Bugbot clean, no open threads label Nov 18, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-ready Approved, CI green, Bugbot clean, no open threads

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants