Skip to content

ci: address the OpenSSF Scorecard findings - #8

Merged
AlexMultiAgent merged 1 commit into
mainfrom
ci/scorecard-hardening
Nov 23, 2026
Merged

AlexMultiAgent merged 1 commit into
mainfrom
ci/scorecard-hardening

Conversation

@AlexMultiAgent

Copy link
Copy Markdown
Owner

What this changes

The Scorecard workflow now publishes its results, so the findings it reports are real. This PR fixes the ones that are cheap to fix and leaves the rest for later.

1. Security-Policy (0/10 -> fixed)

Added SECURITY.md at the repository root.

  • Reporting route: the GitHub private vulnerability reporting form for this repository — https://github.com/AlexMultiAgent/dify-plugin-myweather/security/advisories/new
  • No email address was invented. The only address this repository declares in its package metadata is the contact: field in manifest.yaml (AlexMultiAgent@users.noreply.github.com), so SECURITY.md quotes it as a fallback and says plainly that it is a GitHub noreply address and that the advisory form is the preferred route.
  • Prose on what counts as a vulnerability in this plugin (in scope / out of scope) and what a reporter can expect.
  • Disclosure timeline with concrete numbers: acknowledgement within 7 days, a fix or an advisory within 90 days.
  • "Supported versions": 0.1.4 is the current published release and the supported one; 0.1.5 is listed as in development. No version was bumped — the published baseline stays 0.1.4 and the next version stays 0.1.5.

2. Token-Permissions in codeql.yml (9/10 -> fixed)

security-events: write was granted at the workflow level, so every job in the file could write to code scanning. It now lives on the analyze job only:

permissions:            # workflow level -- read-only
  contents: read
  actions: read
  packages: read

jobs:
  analyze:
    permissions:        # job level
      actions: read
      contents: read
      packages: read
      security-events: write

The CodeQL action only needs security-events: write on the job that runs github/codeql-action/analyze (the SARIF upload), so nothing else is affected.

3. Pinned-Dependencies (3/10 -> fixed)

Every uses: in .github/workflows/ci.yml and .github/workflows/codeql.yml is now pinned to a full 40-character commit SHA with a trailing # vX.Y.Z comment:

Action Tag Commit SHA Version comment
actions/checkout v4.4.0 11d5960a326750d5838078e36cf38b85af677262 v4.4.0
actions/setup-python v5.6.0 a26af69be951a213d495a4c3e4e4022e16d87065 v5.6.0
astral-sh/setup-uv v6.8.0 d0cc045d04ccac9d8b7881df0226f9e82c39688e v6.8.0
actions/upload-artifact v4.6.2 ea165f8d65b6e75b540449e92b4886f43607fa02 v4.6.2
actions/download-artifact v4.3.0 d3f86a106a0bac45b974a628896c90dbdf5c8093 v4.3.0
github/codeql-action/init v4.39.4 1bd86f2fdb4b86187fa4059f16f31a3202acc9ea v4.39.4
github/codeql-action/analyze v4.39.4 1bd86f2fdb4b86187fa4059f16f31a3202acc9ea v4.39.4

Every SHA was resolved with

git ls-remote https://github.com/<owner>/<repo> refs/tags/<tag> 'refs/tags/<tag>^{}'

and the peeled commit (^{}) was used. github/codeql-action publishes annotated tags, so the unpeeled SHA is the tag object rather than the commit — v4.39.4 peels to 1bd86f2f…, while the tag object is e0462179…. The same peeled SHA is already used for github/codeql-action/upload-sarif in scorecard.yml, so this is consistent with the existing pin.

After editing, all 13 pins across the three workflow files (including the four already pinned in scorecard.yml) were re-resolved and compared against the file contents — every one matched.

No SHA was left unverified, and nothing was left unpinned.

4. Token-Permissions in ci.yml — the release job keeps contents: write

The job at .github/workflows/ci.yml:67 is the release job, and it genuinely needs write access:

release:
  if: startsWith(github.ref, 'refs/tags/v')
  permissions:
    contents: write

It runs gh release create / gh release edit and gh release upload to publish the tagged .difypkg as a GitHub Release asset. Creating a release and uploading release assets is a repository-contents write, so downgrading it to read would break the release pipeline. It was left as write, and a comment above the block now records why.

The quality job needs no write permissions — it runs the gates and uploads a workflow artifact — so it keeps inheriting the read-only contents: read from the workflow level.

5. Badge

The OpenSSF Scorecard badge was added directly under the H1 in README.md (the README has no other badge row).

Packaging: keeping SECURITY.md out of the .difypkg

dify plugin package honours .difyignore and nothing else, so a root SECURITY.md would have shipped inside the plugin package. SECURITY.md is now listed in .difyignore, and scripts/verify_package.py lists it as a forbidden file so CI fails if it ever leaks into an archive again.

Verified by rebuilding the package from the parent directory with the Dify CLI: the archive still contains exactly the 19 runtime files, SECURITY.md is not among them, and scripts/verify_package.py passes.

Deliberately left alone

  • The release job's contents: write in ci.yml — it publishes the GitHub Release, see above.
  • The action major versions in ci.yml and codeql.yml. The pins keep the majors the workflows already used (checkout v4, setup-python v5, setup-uv v6, upload-artifact v4, download-artifact v4, codeql-action v4) and move them to the newest patch of that major, so pinning does not change runtime behaviour. scorecard.yml was already pinned and was not touched.
  • requirements.txt, pyproject.toml, uv.lock, manifest.yaml — untouched. requirements.txt ships inside the .difypkg and is installed by the plugin daemon from its own lagging package mirror, so the dependency set must not be touched here.
  • No repository settings were changed — no branch protection, no security settings, no merge.

Known remaining findings (out of scope for this PR)

Packaging, Code-Review, Signed-Releases, CII-Best-Practices, Fuzzing, Contributors, SAST.

Verification

  • yaml.safe_load passes for ci.yml, codeql.yml and scorecard.yml.
  • uv run pytest -q → 256 passed.
  • uv run ruff check . and uv run ruff format --check . → clean.
  • Package rebuilt with the Dify CLI and checked with scripts/verify_package.py → 19 runtime entries, SECURITY.md excluded.

The Scorecard workflow now publishes its results, so the findings it
reports are worth fixing.

Add SECURITY.md: the repository had no security policy, so the
Security-Policy check scored 0. It points at the GitHub private
advisory form as the reporting route, says what counts as a
vulnerability, and states the disclosure timeline -- 7 days to
acknowledge, 90 days to publish a fix or an advisory. SECURITY.md is
repository metadata rather than runtime, so it is added to .difyignore
and to the package verifier's forbidden list; a rebuilt .difypkg still
holds exactly the 19 runtime files.

Move security-events: write from the CodeQL workflow level down to the
analyze job. The workflow-level block is read-only now, and only the
job that uploads SARIF to code scanning can write. The release job in
ci.yml keeps contents: write -- it creates the GitHub Release and
uploads the .difypkg as a release asset, so it genuinely writes.

Pin every action in ci.yml and codeql.yml to a full commit SHA, with
the version in a trailing comment. Each SHA is the peeled commit of
its tag, resolved with git ls-remote; annotated tags carry a separate
tag-object SHA, which would be the wrong pin. Dependabot's
github-actions ecosystem updates the pins in place.

Add the OpenSSF Scorecard badge to the README, under the H1.
@AlexMultiAgent
AlexMultiAgent merged commit 6b27846 into main Nov 23, 2026
6 checks passed
@AlexMultiAgent
AlexMultiAgent deleted the ci/scorecard-hardening branch November 23, 2026 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant