An open API service indexing awesome lists of open source software.

https://github.com/hofiorg/dependabot-alerts

A script to fetch Dependabot alerts for all repositories of a GitHub user
https://github.com/hofiorg/dependabot-alerts

bash bash-script dependabot dependabot-alerts script shell-script

Last synced: 9 months ago
JSON representation

A script to fetch Dependabot alerts for all repositories of a GitHub user

Awesome Lists containing this project

README

          

# dependabot-alerts

[![Shell Script](https://img.shields.io/badge/Bash-Script-blue?logo=gnubash)](https://github.com/hofiorg/dependabot-alerts/blob/main/dependabot-alerts)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/hofiorg/dependabot-alerts/blob/main/LICENSE)
[![ShellCheck](https://github.com/hofiorg/dependabot-alerts/actions/workflows/lint-bash.yml/badge.svg)](https://github.com/hofiorg/dependabot-alerts/actions/workflows/lint-bash.yml)

A script to fetch [Dependabot](https://github.com/dependabot) alerts for all repositories of a GitHub user.

## ๐Ÿ› ๏ธ Prerequisites

This script requires the following tools to be installed on your system:

- [`curl`](https://curl.se/) โ€” for making HTTP requests to the GitHub API
- [`jq`](https://stedolan.github.io/jq/) โ€” for parsing JSON responses in Bash

### โ˜‘๏ธ Check if they are installed

Run the following commands to verify:

```sh
which curl
which jq
```

If either command returns no path, you need to install the missing tools.

## ๐Ÿ“ฅ Installation

### On Ubuntu (including WSL)

```sh
sudo apt update
sudo apt install -y curl jq
```

### ๐Ÿ” Set up the GitHub Personal Access Token

Create a fine-grained or classic token at ๐Ÿ‘‰ with the following permissions:

- `repo` (for private repositories, if applicable)
- `security_events` (for Dependabot alerts)

### ๐ŸŒ Set the token as Environment Variable

```sh
export GH_TOKEN=your_github_token_here
```

To make this persistent, add the above line to your `~/.bashrc` or `~/.zshrc`.

### ๐Ÿš€ Usage

Run the script as follows:

```sh
./dependabot-alerts [github_username]
```

If no username is provided, it defaults to `hofiorg`.

#### ๐Ÿงช Examples

```sh
./dependabot-alerts
./dependabot-alerts octocat
```

#### ๐Ÿ“Š Output Example

When you run the script, you'll see a table like this:

```txt
๐Ÿ“ฆ Fetching repository list for user 'hofiorg'...
Repository Status
------------------------------ ------
angular-boilerplate โœ…
graphql_react_example โŒ 2
java_websockets โœ…
react-input-calendar -
utils โœ…
```

**Legend:**

- โœ… โ€“ No open Dependabot alerts
- โŒ *n* โ€“ *n* open, undismissed alerts found
- `-` โ€“ Alerts not accessible (e.g., archived or insufficient permissions)