ci: restrict workflow token permissions and add property-based tests - #1405
ci: restrict workflow token permissions and add property-based tests#1405mgarbs wants to merge 1 commit into
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Improve the repository's OpenSSF Scorecard results without changing any job behaviour: * Token-Permissions: declare a read-only top-level token (contents: read) in flow-pr-title-check.yaml and grant statuses: write only to the title-check job that needs it. This was the only top-level write scope that the Token-Permissions check penalises; the top-level id-token: write in publish-npm-package.yaml is not scored and is left untouched. * Fuzzing: add fast-check as a devDependency and a property-based test suite for RetryUtils.retryTask (test/unit/utils/RetryUtils.property.spec.ts) that runs as part of the existing mocha unit tests. Signed-off-by: Michael Garber <michael.garber@hashgraph.com>
1593803 to
f183a7b
Compare
|
Some context on the intent behind this PR: it's part of a coordinated effort to raise the OpenSSF Scorecard scores across the hiero-ledger org. Scorecard is an automated 0–10 rating of a repository's supply-chain security practices — workflow token permissions, dependency pinning, SAST coverage, committed binaries, fuzzing, and similar checks — and it's what the org's security dashboard tracks. The checks this PR moves (measured with |
Description:
Raise the repository's OpenSSF Scorecard results without changing what any workflow or job does.
GITHUB_TOKENinflow-pr-title-check.yamland grantstatuses: writeonly to thetitle-checkjobfast-checkas a devDependency and a property-based test suite forRetryUtils.retryTaskRelated issue(s):
None (no tracking issue exists for this work).
Notes for reviewer:
Changes grouped by Scorecard check:
Token-Permissions
.github/workflows/flow-pr-title-check.yaml: the workflow hadstatuses: writeat the top level, which Scorecard flags as an excessive default token. The top-level block is nowcontents: readandstatuses: writemoves tojobs.title-check.permissions, which is the only job (and the only scope)step-security/conventional-pr-title-actionneeds to post the commit status. Every other workflow already declarescontents: readat the top level. This was the only top-level write scope the check penalises; the one other top-level write scope in the repository,id-token: writeinpublish-npm-package.yaml, is not scored (see below).Fuzzing
package.json/package-lock.json: addfast-check(devDependency only, installed with npm 10 so the lockfile diff is limited tofast-checkand its single dependencypure-rand).test/unit/utils/RetryUtils.property.spec.ts: three property-based tests forRetryUtils.retryTaskcovering, for arbitrarymaxRetriesand failure counts: the task result is returned once it succeeds before the budget is exhausted; the task is invoked exactlymaxRetriestimes and the error is rethrown when it never succeeds; retries stop as soon asshouldRetryrejects an error. They are picked up by the existingnpm run testglob and run withbackOff: 0, so they add well under a second to the suite.Intentionally not changed:
publish-npm-package.yamlline 99,npm install -g npm@11.7.0: Scorecard reports everynpm installas unpinned, but this is a global tool upgrade (npm >= 11.5 is what enables trusted publishing) rather than a project dependency install, so there is no lockfile to switch it tonpm ci. Left as is; it is the only remaining Pinned-Dependencies finding.Analyze (actions)andAnalyze (javascript-typescript)check runs on every commit), so no advancedcodeql.ymlworkflow is added here. An advanced configuration cannot run alongside default setup, and Scorecard already credits the existing check runs.flow-semantic-release.ymlalready scopes its write permissions at the job level and is untouched.publish-npm-package.yamlkeepsid-token: writeat the top level. Scorecard does not penalise that scope, and the release workflow cannot be exercised from a pull request, so it is left as is.Verification:
actionlint .github/workflows/*reports the same pre-existing notes as onmain(self-hosted runner labels, existing shellcheck hints) and nothing newscorecard --local . --checks Token-Permissions,Pinned-Dependencies,Binary-Artifacts,Dangerous-Workflow,SAST,Fuzzingbefore/after as in the table abovenpm ci && npm run teston Node 20: 113 passing (110 existing + 3 new)Checklist