Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
z3r0yu committed Jan 25, 2024
1 parent 749b90a commit 7158f59
Show file tree
Hide file tree
Showing 20 changed files with 1,188 additions and 2 deletions.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Bug report
about: Create a report to help us improve
title: "[Issue] "
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**ghtracker version**
Include the version of ghtracker you are using, `ghtracker -version`

**Complete command you used to reproduce this**


**Screenshots**
Add screenshots of the error for a better context.
34 changes: 34 additions & 0 deletions .github/ISSUE_TEMPLATE/issue-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Issue report
about: Create a report to help us to improve the project
labels: 'Type: Bug'

---

<!--
1. Please search to see if an isclearsue already exists for the bug you encountered.
-->

<!-- ISSUES MISSING IMPORTANT INFORMATION MAY BE CLOSED WITHOUT INVESTIGATION. -->

### ghtracker version:
<!-- You can find current version of ghtracker with "ghtracker -version" -->
<!-- We only accept issues that are reproducible on the latest version of ghtracker. -->
<!-- You can find the latest version of project at https://github.com/zer0yu/ghtracker/releases/ -->

### Current Behavior:
<!-- A concise description of what you're experiencing. -->

### Expected Behavior:
<!-- A concise description of what you expected to happen. -->

### Steps To Reproduce:
<!--
Example: steps to reproduce the behavior:
1. Run 'ghtracker ..'
2. See error...
-->


### Anything else:
<!-- Links? References? Screnshots? Anything that will give us more context about the issue that you are encountering! -->
33 changes: 33 additions & 0 deletions .github/workflows/release-binary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: 🎉 Release Binary

on:
push:
tags:
- v*
workflow_dispatch:

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: "Check out code"
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: "Set up Go"
uses: actions/setup-go@v4
with:
go-version: 1.21.x

- name: "Create release on GitHub"
uses: goreleaser/goreleaser-action@v4
with:
args: "release --rm-dist"
version: latest
workdir: .
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
162 changes: 160 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,160 @@
# ghtracker
CLI tool for tracking dependents repositories and sorting result by Stars ⭐
<h1 align="center">
<img src="static/ghtracker-logo.png" alt="subfinder" width="200px">
<br>
</h1>

<h4 align="center">CLI tool for tracking dependents repositories and sorting result by Stars ⭐</h4>

<p align="center">
<a href="https://goreportcard.com/report/github.com/zer0yu/ghtracker"><img src="https://goreportcard.com/badge/github.com/zer0yu/ghtracker"></a>
<a href="https://github.com/zer0yu/ghtracker/issues"><img src="https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat"></a>
<a href="https://github.com/zer0yu/ghtracker/releases"><img src="https://img.shields.io/github/release/zer0yu/ghtracker"></a>
</p>

<p align="center">
<a href="#features">Features</a> •
<a href="#installation">Install</a> •
<a href="#usage">Usage</a> •
<a href="#why-ghtracker">Why ghtracker</a> •
<a href="#references">References</a> •
</p>

---

`ghtracker` is a tool for tracking dependents repositories and sorting result by Stars ⭐. It has a simple architecture and is optimized for speed.

## Features

- Analysis of 'used by' or 'Dependency graph' in Github repositories and sorting result by Stars
- In-depth Search of Key Code in Used Objects
- Support for Output in JSON Format
- Provision of Aesthetically Pleasing and Easy-to-Read Terminal Table Outputs
- Comprehensive Cross-Platform Compatibility
- Efficient HTTP Request Anti-Ban Mechanism

## Installation

### From Source

`ghtracker` requires **go1.20** to install successfully. Run the following command to install the latest version:

```sh
go install github.com/zer0yu/ghtracker@latest
```

### From Release

Download from [releases](http://github.com/zer0yu/ghtracker/releases/)

## Usage

### Help

```sh
ghtracker -h
```

This will display help for the tool. Here are all the switches it supports.

```sh
CLI tool for tracking dependents repositories and sorting result by Stars

Usage:
ghtracker [flags]

Flags:
-d, --description Show description of packages or repositories (performs additional request per repository)
-h, --help help for ghtracker
-m, --minstar int Minimum number of stars (default=5) (default 5)
-f, --output string File to write output to (optional)
-r, --repositories Sort repositories or packages (default packages)
-o, --rows int Number of showing repositories (default=10) (default 10)
-s, --search string search code at dependents (repositories or packages)
-t, --table View mode
-k, --token string GitHub token
-u, --url string URL to process
```

### Basic Usage

#### 1. Retrieves Packages in 'Used by' or 'Dependency graph' by default, and saves the addresses of projects with more than 5 output stars.

```sh
ghtracker --url https://github.com/AFLplusplus/LibAFL -t
/
+---------------------------------------+-------+-------------+
| URL | STARS | DESCRIPTION |
+---------------------------------------+-------+-------------+
| https://github.com/AFLplusplus/LibAFL | 1.7K | |
| https://github.com/epi052/feroxfuzz | 183 | |
| https://github.com/fkie-cad/butterfly | 40 | |
| https://github.com/z2-2z/peacock | 0 | |
+---------------------------------------+-------+-------------+
found 8 packages others packages are private
Complete!
```

#### 2. Get the Repositories in the 'Used by' or 'Dependency graph', by default it saves the addresses of projects with the first 10.

```sh
ghtracker --url https://github.com/AFLplusplus/LibAFL -t -r
/
+--------------------------------------------------------+-------+-------------+
| URL | STARS | DESCRIPTION |
+--------------------------------------------------------+-------+-------------+
| https://github.com/AFLplusplus/LibAFL | 1.7K | |
| https://github.com/hardik05/Damn_Vulnerable_C_Program | 604 | |
| https://github.com/fuzzland/ityfuzz | 524 | |
| https://github.com/epi052/feroxfuzz | 183 | |
| https://github.com/epi052/fuzzing-101-solutions | 119 | |
| https://github.com/tlspuffin/tlspuffin | 117 | |
| https://github.com/Agnoctopus/Tartiflette | 90 | |
| https://github.com/fkie-cad/butterfly | 40 | |
| https://github.com/IntelLabs/PreSiFuzz | 38 | |
| https://github.com/RickdeJager/TrackmaniaFuzzer | 32 | |
| https://github.com/AFLplusplus/libafl_paper_artifacts | 17 | |
| https://github.com/novafacing/libc-fuzzer | 12 | |
| https://github.com/vusec/triereme | 11 | |
| https://github.com/bitterbit/fuzzer-qemu | 7 | |
| https://github.com/atredis-jordan/libafl-workshop-blog | 7 | |
| https://github.com/rezer0dai/LibAFL | 6 | |
| https://github.com/jjjutla/Fuzz | 5 | |
+--------------------------------------------------------+-------+-------------+
found 190 repositories others repositories are private
Complete!
```

#### 3. Save the result in a file in Json format

```sh
ghtracker --url https://github.com/AFLplusplus/LibAFL -t -r --output ./test.json
```

#### 4. Search Code Pattern in 'Dependency graph' (Need Github Token)

```sh
ghtracker --url https://github.com/AFLplusplus/LibAFL --token your_token_value -t --search AFL --output ./test.json
\
[INF] https://github.com/AFLplusplus/LibAFL/blob/e117b7199ca902d462edc1de1bc0b3cb71c27aff/scripts/afl-persistent-config with 1747 stars
[INF] https://github.com/AFLplusplus/LibAFL/blob/e117b7199ca902d462edc1de1bc0b3cb71c27aff/libafl_cc/src/afl-coverage-pass.cc with 1747 stars
[INF] https://github.com/AFLplusplus/LibAFL/blob/e117b7199ca902d462edc1de1bc0b3cb71c27aff/libafl_targets/src/cmps/observers/aflpp.rs with 1747 stars
[INF] https://github.com/AFLplusplus/LibAFL/blob/e117b7199ca902d462edc1de1bc0b3cb71c27aff/fuzzers/forkserver_libafl_cc/src/bin/libafl_cc.rs with 1747 stars
[INF] https://github.com/AFLplusplus/LibAFL/blob/e117b7199ca902d462edc1de1bc0b3cb71c27aff/fuzzers/libfuzzer_libpng_aflpp_ui/README.md with 1747 stars
...
...
```

#### 5. Get all repositories in the 'Dependency graph'

```sh
ghtracker --url https://github.com/AFLplusplus/LibAFL -t -r -m 0 --output ./test.json
```

# Why ghtracker

1. Gtihub does not support sorting the 'Dependency graph' by the number of Stars from 2019 until now, so ghtracker
was born. Detials in issue in [1537](https://github.com/isaacs/github/issues/1537)
2. GHTOPDEP does not continue to update support, and there are some issues in the community, e.g., [issue](https://github.com/github-tooling/ghtopdep). ghtracker has optimized and improved on this, and has addressed issues in the community.

# References
- [GHTOPDEP](https://github.com/github-tooling/ghtopdep)
54 changes: 54 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package cmd

import (
"github.com/projectdiscovery/gologger"
"github.com/zer0yu/ghtracker/pkg/runner"
"os"

"github.com/spf13/cobra"
"github.com/zer0yu/ghtracker/pkg/options"
)

var ghoptions = options.GHTopDepOptions{}

var rootCmd = &cobra.Command{
Use: "ghtracker",
Short: "CLI tool for tracking dependents repositories and sorting result by Stars",
Long: ``,
Run: GHTracker,
}

func Execute() {
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}

func init() {
rootCmd.PersistentFlags().BoolVarP(&ghoptions.Version, "version", "v", false, "Show version of ghtracker")
rootCmd.PersistentFlags().StringVarP(&ghoptions.URL, "url", "u", "", "URL to process")
rootCmd.PersistentFlags().BoolVarP(&ghoptions.Repositories, "repositories", "r", false,
"Sort repositories or packages (default repositories)")
rootCmd.PersistentFlags().BoolVarP(&ghoptions.Table, "table", "t", false, "View mode")
rootCmd.PersistentFlags().BoolVarP(&ghoptions.Description, "description", "d", false,
"Show description of packages or repositories (performs additional request per repository)")
rootCmd.PersistentFlags().IntVarP(&ghoptions.Rows, "rows", "o", 10, "Number of showing repositories (default=10)")
rootCmd.PersistentFlags().IntVarP(&ghoptions.MinStar, "minstar", "m", 5, "Minimum number of stars (default=5)")
rootCmd.PersistentFlags().StringVarP(&ghoptions.Search, "search", "s", "",
"search code at dependents (repositories or packages)")
rootCmd.PersistentFlags().StringVarP(&ghoptions.Token, "token", "k", os.Getenv("GHTOPDEP_TOKEN"), "GitHub token")
rootCmd.PersistentFlags().StringVarP(&ghoptions.OutputFile, "output", "f", "", "File to write output to (optional)")
}

func GHTracker(_ *cobra.Command, _ []string) {
newRunner, err := runner.NewRunner(&ghoptions)
if err != nil {
gologger.Fatal().Msgf("Could not create runner: %s\n", err)
}

err = newRunner.RunGHCrawler()
if err != nil {
gologger.Fatal().Msgf("Could not run fuzz engine: %s\n", err)
}
}
59 changes: 59 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
module github.com/zer0yu/ghtracker

go 1.21.3

require (
github.com/PuerkitoBio/goquery v1.8.1
github.com/briandowns/spinner v1.23.0
github.com/gofri/go-github-ratelimit v1.1.0
github.com/google/go-github/v58 v58.0.0
github.com/imroc/req/v3 v3.42.3
github.com/olekukonko/tablewriter v0.0.5
github.com/projectdiscovery/gologger v1.1.12
github.com/spf13/cobra v1.8.0
)

require (
github.com/andybalholm/brotli v1.0.6 // indirect
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
github.com/fatih/color v1.7.0 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/pprof v0.0.0-20231229205709-960ae82b1e42 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mattn/go-isatty v0.0.8 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mholt/archiver/v3 v3.5.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/nwaples/rardecode v1.1.3 // indirect
github.com/onsi/ginkgo/v2 v2.13.2 // indirect
github.com/pierrec/lz4/v4 v4.1.2 // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/qtls-go1-20 v0.4.1 // indirect
github.com/quic-go/quic-go v0.40.1 // indirect
github.com/refraction-networking/utls v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
go.uber.org/mock v0.4.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.16.1 // indirect
gopkg.in/djherbis/times.v1 v1.3.0 // indirect
)
Loading

0 comments on commit 7158f59

Please sign in to comment.