DEV Community

Cover image for How to Save and Archive GitHub PRs and Issues Offline Before They Disappear
Dev Dhanadiya
Dev Dhanadiya

Posted on Edited on

How to Save and Archive GitHub PRs and Issues Offline Before They Disappear

Open-source maintainers deal with spam and occasional supply chain attempts on GitHub. When a suspicious or compromised account is reported, GitHub's Trust and Safety team may suspend or ban the account.

Once that happens, the story is often over for anyone trying to review what happened. A banned account's PRs, issues, and comments are commonly hidden or return 404 Not Found.

For a maintainer or security reviewer trying to understand how the attempt worked, write up an advisory, or warn other projects that the same account targeted, there is very little left to inspect.

How Some Attacks Hide in GitHub's UI

In several recent open-source incidents, attackers did not just open a single obvious PR. They used normal GitHub features in ways that make review harder:

  • Blending in: Opening ordinary issues and small PRs in other repositories to look like an active contributor.
  • Force-pushing over warnings: When a review bot or maintainer leaves a warning on a line of code, force-pushing the branch marks the thread as "Outdated" and collapses it in the UI.
  • Off-screen padding: Padding a single line with hundreds or thousands of tabs and spaces so the actual payload sits far off to the right, outside the normal diff view.

If the account is banned before anyone saves the thread, those force-pushes, collapsed bot comments, and padded diffs can become unreachable.

What ghsp Tries to Solve

ghsp (GitHub Security Peek) is a small command-line tool built around a simple idea: if you spot something suspicious, save the PR or issue locally before reporting it, and read it offline later in a format similar to gh.

It does not try to replace full security scanners, and it does not require a server or database. If you already use the GitHub CLI (gh), ghsp uses your existing login.

How ghsp Works

ghsp splits the job into two parts: saving what is currently visible on GitHub, and viewing that saved copy offline.

1. Save Before It Disappears (ghsp archive)

You can point ghsp at a PR number, an issue number, a GitHub URL, or PRs and issues opened by a specific author in a repo or organization.

When archiving an item, ghsp fetches and stores what the GitHub API exposes at that moment:

  • Metadata: Title, description, state, author details, labels, and CI check status summaries.
  • Chronological timeline: Human comments, bot comments, review summaries, and inline code review threads. Unlike the web UI, ghsp keeps collapsed and outdated comments visible.
  • Force-pushes and commits: Before-and-after commit hashes from force-push events, individual commit patches, and comparison diffs (for any commits GitHub has not already garbage-collected).
  • Embedded images: HTTPS images and attachments referenced in descriptions or comments are saved locally when accessible without a browser session; if an asset cannot be downloaded, ghsp records the error and keeps the original URL.

To avoid executing untrusted code on your machine, ghsp never clones the repository or checks out PR branches. Everything is stored as plain text diffs, patches, and JSON.

2. Three Simple Red-Flag Checks

During ghsp archive, it runs three straightforward checks on saved diffs (including archived force-push patches) and the timeline:

  1. Off-screen lines: Flags added lines longer than 300 characters or containing more than 40 consecutive spaces or tabs.
  2. Hidden Unicode: Flags zero-width characters and bidirectional override characters.
  3. Force-push + collapsed bot comment: Flags PRs that have both a force-push event and an outdated or collapsed bot comment.

These are simple pattern checks rather than full static analysis. If any match, ghsp shows a warning banner when you view the PR.

3. Read Everything Offline (view, diff, list, status)

Once saved, your local copy does not depend on GitHub keeping the account or PR online:

  • Overview: ghsp status shows your archive folder path, counts, and a table of saved PRs and issues. ghsp pr list and ghsp issue list filter by repo or author.
  • Full threads: ghsp pr view <number> --comments and ghsp issue view <number> --comments print the description, labels, check summaries, and timeline in chronological order, keeping [BOT], [OUTDATED], [MINIMIZED], and [FORCE PUSH] markers visible.
  • Diffs: ghsp pr diff <number> shows the PR diff, --force-push shows archived before/after force-push diffs, and --commit <sha> or --commits shows individual saved commit patches.
  • Cleanup: ghsp delete (or ghsp rm) removes a single PR, an issue, a repo, or everything with --all.

4. Storage Location

By default, ghsp stores archives in your local data directory (~/.local/share/ghsp on Linux/macOS or %LocalAppData%\ghsp on Windows), grouped by <owner>/<repo>/pull/<number> and <owner>/<repo>/issue/<number>.

If a team wants to keep a shared record inside a Git repository, you can pass --dir . (or set GHSP_DIR) to save archives directly into that folder and commit them manually.

Try It Out

macOS and Linux:

curl -fsSL https://raw.githubusercontent.com/devxdh/ghsp/main/scripts/install.sh | sh
Enter fullscreen mode Exit fullscreen mode

Windows (PowerShell):

irm https://raw.githubusercontent.com/devxdh/ghsp/main/scripts/install.ps1 | iex
Enter fullscreen mode Exit fullscreen mode

Or via Go:

go install github.com/devxdh/ghsp@latest
Enter fullscreen mode Exit fullscreen mode

The install scripts also try to place <TAB> completion files in standard shell directories for Bash, Zsh, Fish, and PowerShell, with ghsp completion <shell> available if your shell setup needs manual sourcing.

Example workflow:

# 1. Save a PR and an issue locally
ghsp archive -R owner/repo --pr 123 --issue 456

# 2. Check what is stored locally
ghsp status

# 3. Read the timeline and force-push diffs offline
ghsp pr view 123 -R owner/repo --comments
ghsp pr diff 123 -R owner/repo --force-push
Enter fullscreen mode Exit fullscreen mode

ghsp cannot recover PRs that GitHub has already deleted before you run it, and it is not meant to replace dedicated security scanners. It is simply a small utility to help maintainers preserve context before it disappears. You can find the source and releases at devxdh/ghsp.

Top comments (1)

Collapse
 
devxdh profile image
Dev Dhanadiya •

Please do share your feedback on the project.