Repository navigation
ci: address the OpenSSF Scorecard findings - #8
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.mdat the repository root.contact:field inmanifest.yaml(AlexMultiAgent@users.noreply.github.com), soSECURITY.mdquotes it as a fallback and says plainly that it is a GitHub noreply address and that the advisory form is the preferred route.2. Token-Permissions in
codeql.yml(9/10 -> fixed)security-events: writewas granted at the workflow level, so every job in the file could write to code scanning. It now lives on theanalyzejob only:The CodeQL action only needs
security-events: writeon the job that runsgithub/codeql-action/analyze(the SARIF upload), so nothing else is affected.3. Pinned-Dependencies (3/10 -> fixed)
Every
uses:in.github/workflows/ci.ymland.github/workflows/codeql.ymlis now pinned to a full 40-character commit SHA with a trailing# vX.Y.Zcomment:11d5960a326750d5838078e36cf38b85af677262a26af69be951a213d495a4c3e4e4022e16d87065d0cc045d04ccac9d8b7881df0226f9e82c39688eea165f8d65b6e75b540449e92b4886f43607fa02d3f86a106a0bac45b974a628896c90dbdf5c80931bd86f2fdb4b86187fa4059f16f31a3202acc9ea1bd86f2fdb4b86187fa4059f16f31a3202acc9eaEvery SHA was resolved with
and the peeled commit (
^{}) was used.github/codeql-actionpublishes annotated tags, so the unpeeled SHA is the tag object rather than the commit —v4.39.4peels to1bd86f2f…, while the tag object ise0462179…. The same peeled SHA is already used forgithub/codeql-action/upload-sarifinscorecard.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 keepscontents: writeThe job at
.github/workflows/ci.yml:67is thereleasejob, and it genuinely needs write access:It runs
gh release create/gh release editandgh release uploadto publish the tagged.difypkgas a GitHub Release asset. Creating a release and uploading release assets is a repository-contents write, so downgrading it toreadwould break the release pipeline. It was left aswrite, and a comment above the block now records why.The
qualityjob needs no write permissions — it runs the gates and uploads a workflow artifact — so it keeps inheriting the read-onlycontents: readfrom 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.mdout of the.difypkgdify plugin packagehonours.difyignoreand nothing else, so a rootSECURITY.mdwould have shipped inside the plugin package.SECURITY.mdis now listed in.difyignore, andscripts/verify_package.pylists 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.mdis not among them, andscripts/verify_package.pypasses.Deliberately left alone
releasejob'scontents: writeinci.yml— it publishes the GitHub Release, see above.ci.ymlandcodeql.yml. The pins keep the majors the workflows already used (checkoutv4,setup-pythonv5,setup-uvv6,upload-artifactv4,download-artifactv4,codeql-actionv4) and move them to the newest patch of that major, so pinning does not change runtime behaviour.scorecard.ymlwas already pinned and was not touched.requirements.txt,pyproject.toml,uv.lock,manifest.yaml— untouched.requirements.txtships inside the.difypkgand is installed by the plugin daemon from its own lagging package mirror, so the dependency set must not be touched here.Known remaining findings (out of scope for this PR)
Packaging, Code-Review, Signed-Releases, CII-Best-Practices, Fuzzing, Contributors, SAST.
Verification
yaml.safe_loadpasses forci.yml,codeql.ymlandscorecard.yml.uv run pytest -q→ 256 passed.uv run ruff check .anduv run ruff format --check .→ clean.scripts/verify_package.py→ 19 runtime entries,SECURITY.mdexcluded.