Skip to content

Commit 3d25e3c

Browse files
committed
Merge branch 'release/v1.2.0' into main
2 parents fa2da23 + e47c8b4 commit 3d25e3c

33 files changed

+956
-428
lines changed

.github/workflows/go.yml

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
# This workflow will build a golang project
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
3-
41
name: Go
52

63
on:
74
push:
85
branches: [ "main", "dev" ]
6+
paths-ignore:
7+
- 'README.md'
98
pull_request:
109
branches: [ "main", "dev" ]
10+
types: [opened, synchronize, reopened, ready_for_review]
1111

1212
jobs:
1313

1414
build:
15+
if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && !github.event.pull_request.draft)
1516
runs-on: ubuntu-latest
1617
strategy:
1718
matrix:
@@ -31,3 +32,61 @@ jobs:
3132
GOOS: ${{ matrix.os }}
3233
GOARCH: ${{ matrix.arch }}
3334
run: go build -v ./...
35+
36+
tests:
37+
if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && !github.event.pull_request.draft)
38+
needs: build
39+
runs-on: ubuntu-latest
40+
name: Update coverage badge
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v2
44+
with:
45+
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
46+
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
47+
48+
- name: Setup go
49+
uses: actions/setup-go@v2
50+
with:
51+
go-version: '1.19'
52+
53+
- uses: actions/cache@v2
54+
with:
55+
path: ~/go/pkg/mod
56+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
57+
restore-keys: |
58+
${{ runner.os }}-go-
59+
60+
- name: Run Test
61+
run: |
62+
go test -v ./... -covermode=set -coverprofile=coverage.out
63+
go tool cover -func=coverage.out -o=coverage.out
64+
env:
65+
HTB_TOKEN: ${{ secrets.HTB_TOKEN }}
66+
TEST: "true"
67+
68+
- name: Go Coverage Badge
69+
uses: tj-actions/coverage-badge-go@v2
70+
with:
71+
filename: coverage.out
72+
73+
- name: Verify Changed files
74+
uses: tj-actions/verify-changed-files@v12
75+
id: verify-changed-files
76+
with:
77+
files: README.md
78+
79+
- name: Commit changes
80+
if: steps.verify-changed-files.outputs.files_changed == 'true'
81+
run: |
82+
git config --local user.email "[email protected]"
83+
git config --local user.name "GitHub Action"
84+
git add README.md
85+
git commit -m "chore: Updated coverage badge."
86+
87+
- name: Push changes
88+
if: steps.verify-changed-files.outputs.files_changed == 'true'
89+
uses: ad-m/github-push-action@master
90+
with:
91+
github_token: ${{ secrets.TOKEN_PUSH }}
92+
branch: dev

.github/workflows/release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
13+
release:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v4
22+
with:
23+
go-version: '1.20'
24+
25+
- name: Release
26+
uses: goreleaser/goreleaser-action@v4
27+
with:
28+
distribution: goreleaser
29+
version: latest
30+
args: release --clean
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*.dll
88
*.so
99
*.dylib
10+
.idea
1011

1112
# Test binary, built with `go test -c`
1213
*.test
@@ -19,3 +20,5 @@
1920

2021
# Go workspace file
2122
go.work
23+
coverage.out
24+
htb-cli

Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BINARY_NAME=htb-cli
2+
3+
PLATFORMS=darwin linux windows
4+
5+
ARCHITECTURES=amd64 arm64
6+
7+
OUTPUT_DIR=build
8+
9+
all: test coverage $(PLATFORMS)
10+
11+
$(PLATFORMS):
12+
for arch in $(ARCHITECTURES); do \
13+
GOOS=$@ GOARCH=$$arch go build -o $(OUTPUT_DIR)/$(BINARY_NAME)-$@-$$arch; \
14+
done
15+
16+
build:
17+
go build -o $(OUTPUT_DIR)/$(BINARY_NAME)
18+
19+
test:
20+
go test -v ./...
21+
22+
coverage:
23+
go test -coverprofile=coverage.out ./...
24+
go tool cover -html=coverage.out -o coverage.html
25+
26+
clean:
27+
rm -rf $(OUTPUT_DIR) coverage.out coverage.html
28+
29+
.PHONY: all test coverage clean $(PLATFORMS)

README.md

Lines changed: 16 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# htb-cli
2+
![Coverage](https://img.shields.io/badge/Coverage-17.4%25-red)
23

34
![Workflows (main)](https://github.com/GoToolSharing/htb-cli/actions/workflows/go.yml/badge.svg?branch=main)
45
![Workflows (dev)](https://github.com/GoToolSharing/htb-cli/actions/workflows/go.yml/badge.svg?branch=dev)
6+
![GitHub go.mod Go version (main)](https://img.shields.io/github/go-mod/go-version/GoToolSharing/htb-cli/main)
7+
![GitHub go.mod Go version (dev)](https://img.shields.io/github/go-mod/go-version/GoToolSharing/htb-cli/dev)
8+
![GitHub release](https://img.shields.io/github/v/release/GoToolSharing/htb-cli)
9+
![GitHub Repo stars](https://img.shields.io/github/stars/GoToolSharing/htb-cli)
510

611
<div>
712
<img alt="current version" src="https://img.shields.io/badge/linux-supported-success">
@@ -27,92 +32,36 @@ export HTB_TOKEN=eyJ...
2732

2833
## Helper
2934

30-
```
31-
This software, engineered using the Go programming language, serves to streamline and automate various tasks for the HackTheBox platform, enhancing user efficiency and productivity.
32-
33-
Usage:
34-
htb-cli [command]
35-
36-
Available Commands:
37-
active Catalogue of active machines
38-
help Help about any command
39-
info Showcase detailed machine information
40-
reset Reset a machine
41-
start Start a machine
42-
status Displays the status of HackTheBox servers
43-
stop Stop the current machine
44-
submit Submit credentials (User and Root Flags)
45-
46-
Flags:
47-
-h, --help help for htb-cli
48-
-p, --proxy string Configure a URL for an HTTP proxy
49-
-v, --verbose Verbose mode
50-
51-
Use "htb-cli [command] --help" for more information about a command.
52-
```
35+
![Helper](/assets/helper.png)
5336

5437
## Start
5538

56-
```
57-
❯ htb-cli start -m Blue
58-
? The following machine was found : Blue Yes
59-
Machine deployed to lab.
60-
```
39+
![Start machine](/assets/start.png)
6140

6241
## Stop
6342

64-
```
65-
❯ htb-cli stop
66-
Machine terminated.
67-
```
43+
![Stop machine](/assets/stop.png)
6844

6945
## Reset
7046

71-
```
72-
❯ htb-cli reset
73-
CozyHosting will be reset in 1 minute.
74-
```
47+
![Reset machine](/assets/reset.png)
7548

7649
## Submit
7750

78-
This command allows to submit the user flag and the root flag of active and retired machines. The first argument is the flag and the second the difficulty /10.
79-
8051
### Submit machine flag
81-
```
82-
❯ htb-cli submit -m SteamCloud -f flag4testing -d 3
83-
? The following machine was found : SteamCloud Yes
84-
SteamCloud user is now owned.
85-
```
52+
53+
![Submit machine flag](/assets/submit_machine.png)
8654

8755
### Submit challenge flag
88-
```
89-
❯ htb-cli submit -c Phonebook -f flag4testing -d 3
90-
? The following challenge was found : Phonebook Yes
91-
Incorrect flag
92-
```
56+
57+
![Submit challenge flag](/assets/submit_challenge.png)
9358

9459
## Info
9560

96-
```
97-
❯ htb-cli info
98-
? Do you want to check for active machine ? Yes
99-
Name |OS |Active |Difficulty |Stars |IP |Status |Release
100-
Blue |Windows |0 |Easy |4.5 |10.10.10.40 |✅ User - ✅ Root |2017-07-28
101-
```
61+
![Info active machine](/assets/info_active.png)
10262

103-
```
104-
❯ htb-cli info -m Zip -m pilgrimage
105-
? Do you want to check for active machine ? No
106-
? The following machine was found : Zipping Yes
107-
Name |OS |Active |Difficulty |Stars |FirstUserBlood |FirstRootBlood |Status |Release
108-
Zipping |Linux |✅ |Medium |4.1 |0H 15M 9S |1H 12M 28S |❌ User - ❌ Root |2023-08-26
109-
? The following machine was found : Pilgrimage Yes
110-
Pilgrimage |Linux |✅ |Easy |4.5 |0H 17M 0S |0H 20M 33S |✅ User - ✅ Root |2023-06-24
111-
```
63+
![Info machines](/assets/info_machines.png)
11264

11365
## Status
11466

115-
```
116-
❯ htb-cli status
117-
All Systems Operational
118-
```
67+
![Status](/assets/status.png)

SECURITY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Security Policy
2+
3+
## Reporting a Vulnerability
4+
5+
Please report (suspected) security vulnerabilities to [email protected]. You will receive a response from us within 48 hours. If the issue is confirmed, we will release a patch as soon as possible depending on complexity.
6+

assets/helper.png

299 KB
Loading

assets/info_active.png

123 KB
Loading

assets/info_machines.png

202 KB
Loading

assets/reset.png

66.9 KB
Loading

0 commit comments

Comments
 (0)