Quick overview
This workflow monitors GitHub pull requests for new npm dependencies, checks each added package using OpenAI plus npm, OSV, and GitHub metadata, and reports results back to the PR and to Slack when a dependency is blocked.
How it works
- Triggers when a GitHub pull request is opened, updated, or reopened.
- Fetches the pull request’s changed files from the GitHub API and keeps only package.json diffs.
- Extracts newly added dependency entries from the diff, deduplicates them, and skips packages in the trusted allowlist.
- Uses an OpenAI agent to review each remaining dependency by querying the npm registry, npm download stats, OSV vulnerability data, and (when available) the package’s GitHub source repository.
- Aggregates all package verdicts into a single Markdown table comment and posts it to the pull request, then sets a dependency-check commit status on the PR head SHA.
- If any package is marked as blocked, applies a label to the pull request and posts an alert with details to a Slack #security channel.
- If the workflow execution fails, sends a Slack message to the security channel with the error and execution link.
Setup
- Create a GitHub API credential (access token) with permission to read PR files and create PR comments, statuses, and labels, then set the trigger’s owner and repository values.
- Add an OpenAI credential for the chat model used by the agent.
- Add a Slack credential and set the target channel (for example, #security) for both alert messages.
- Review and adjust the trusted package list, minimum weekly downloads, minimum age in days, and block label name in the Review Settings values.
- Optional: configure GitHub branch protection rules to require the dependency-check status before merging.