Skip to content

feat: add shared gh, topology and Slack block helpers for workflow scripts - #338

Open
cryptodev-2s wants to merge 18 commits into
mainfrom
feat/shared-workflow-helpers
Open

cryptodev-2s wants to merge 18 commits into
mainfrom
feat/shared-workflow-helpers

Conversation

@cryptodev-2s

@cryptodev-2s cryptodev-2s commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Explanation

Adds small shared helpers for workflow scripts, so each script doesn't write its own: a gh api wrapper that retries rate limits, server errors and network errors when the caller opts in (a write isn't safe to repeat), a typed topology.json fetch with the Slack handle lookup, and the Slack text helpers (escape, escape and cut to a length, section).

Nothing uses them yet. The Dependabot reminder in #305 is the first user. The team label action, the RC commits script and the changelog cleaner can move onto them in their own PRs.


Note

Low Risk
Additive shared utilities and tests only; no workflow or runtime behavior changes until later PRs adopt them.

Overview
Introduces reusable shared modules under .github/scripts/shared/ for upcoming workflow refactors (e.g. Dependabot reminder in #305). Nothing in production workflows imports them yet.

github-cli.mts wraps gh api with configurable tokens, retries only transient failures (rate limits, 5xx, network) via existing retry.mts, and adds ghGraphql / ghGraphqlPages helpers with pagination support.

topology.mts fetches and parses MetaMask-planning's topology.json in one raw API call, plus slug normalization and lookups for teams, Slack user-group handles (with validation to block markup like <!channel>), and membership by GitHub user.

slack-blocks.mts centralizes Slack mrkdwn escaping, truncation, section chunking under size limits, and block capping with an overflow notice.

Vitest coverage thresholds are bumped slightly to reflect the new tested code.

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

…ripts

Adds ghApi and GraphQL wrappers that only retry transient failures, a typed
topology.json fetch with lookups, and Slack block helpers (escape, truncate,
chunk, cap). Nothing uses them yet, other scripts can adopt them later.
topology.json holds handles like @Core-platform-Team in slackHandle.team,
not Slack user group IDs. Slack turns a handle in message text into a
mention, so no lookup is needed.
@cryptodev-2s
cryptodev-2s force-pushed the feat/shared-workflow-helpers branch from 08cb86e to 746f14b Compare December 2, 2026 13:03
Comment thread .github/scripts/shared/github-cli.mts Resolved
Octokit avoids spawning gh. It does not retry, so reads and queries go through
a small retry helper that looks at the HTTP status.
Comment thread .github/scripts/shared/octokit.mts Outdated
return new Octokit({ auth: token });
}

// Octokit doesn't retry. Only retry what can succeed later: rate limits and

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can use the plugin, but it introduces another dependency. I’m wondering if we should just use Octokit directly instead. Any recommendations?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's already a dependency of octokit.js. I think your assumption that Octokit doesn't retry is wrong?

@cryptodev-2s cryptodev-2s Dec 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am using @octokit/rest thats why I asked if you prefer we switch to Octokit directly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, sorry, I misunderstood. Yes, I think using Octokit directly is fine.

@cryptodev-2s
cryptodev-2s marked this pull request as draft December 3, 2026 15:11
@socket-security

socket-security Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedoctokit@​5.0.59910010082100

View full report

@socket-security

socket-security Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Warning

MetaMask internal reviewing guidelines:

  • Do not ignore-all
  • Each alert has instructions on how to review if you don't know what it means. If lost, ask your Security Liaison or the supply-chain group
  • Copy-paste ignore lines for specific packages or a group of one kind with a note on what research you did to deem it safe.
    @SocketSecurity ignore npm/PACKAGE@VERSION
Priority Alert  (click "▶" to expand/collapse) Action
Low priority
Potential code anomaly (AI signal): npm @octokit/auth-oauth-user is 75.0% likely to have a medium risk anomaly

Notes: The module functions as a conventional OAuth helper for Octokit, supporting web-based code exchange, device flow, and direct token usage. No overt malicious activity detected. Primary risk centers on handling of clientSecret in the device-flow branch and the potential leakage through logs, UIs, or misconfigured callbacks. Recommend enforcing strict handling of sensitive fields (do not log clientSecret, sanitize outputs) and reviewing onTokenCreated implementations for secure usage.

Confidence: 0.75

Severity: 0.60

From: package.json → npm/octokit@5.0.5 → npm/@octokit/auth-oauth-user@6.0.4

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@octokit/auth-oauth-user@6.0.4. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn
Low priority
Potential code anomaly (AI signal): npm @octokit/oauth-app is 62.0% likely to have a medium risk anomaly

Notes: This module primarily performs legitimate OAuth token creation, but it has a significant confidentiality risk: it emits highly sensitive authentication material (access token, refresh token, and application clientSecret) and a constructed authenticated Octokit instance through emitEvent without any visible redaction. If emitEvent routes events to logs/telemetry/external systems or if event handlers are not strictly internal-only, this could lead to credential leakage. No clear malware/backdoor indicators are present in the snippet itself.

Confidence: 0.62

Severity: 0.64

From: package.json → npm/octokit@5.0.5 → npm/@octokit/oauth-app@8.0.4

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@octokit/oauth-app@8.0.4. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn
Low priority
Potential code anomaly (AI signal): npm @octokit/oauth-app is 64.0% likely to have a medium risk anomaly

Notes: This module performs legitimate OAuth-user authentication with Octokit, then emits a “token created” event containing the OAuth access token, scopes, the full authentication object, and the authenticated Octokit instance. There is no direct malicious activity visible in the snippet, but it creates a significant credential-exposure risk if the event system logs, persists, or transmits payloads or if untrusted listeners can observe the event.

Confidence: 0.64

Severity: 0.52

From: package.json → npm/octokit@5.0.5 → npm/@octokit/oauth-app@8.0.4

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@octokit/oauth-app@8.0.4. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn

View full report

@cryptodev-2s
cryptodev-2s marked this pull request as ready for review December 3, 2026 16:39

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants