1
1
Fork 0
mirror of https://github.com/OJ/gobuster.git synced 2024-05-28 04:56:03 +02:00

Compare commits

...

2 Commits

Author SHA1 Message Date
firefart 0a77af9d71 no progressbar when no terminal 2024-02-01 20:18:23 +00:00
firefart 33c222ce5e fix #482 2024-02-01 14:05:34 +01:00
7 changed files with 112 additions and 71 deletions

View File

@ -1,28 +1,30 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the // For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/go // README at: https://github.com/devcontainers/templates/tree/main/src/go
{ {
"name": "Go", "name": "Go",
"image": "mcr.microsoft.com/devcontainers/go", "image": "mcr.microsoft.com/devcontainers/go",
"features": { "features": {
"ghcr.io/guiyomh/features/golangci-lint:0": {} "ghcr.io/guiyomh/features/golangci-lint:0": {},
}, "ghcr.io/devcontainers-contrib/features/go-task:1": {}
"postCreateCommand": "go mod download", },
// Features to add to the dev container. More info: https://containers.dev/features. "postCreateCommand": "go mod download",
// "features": {}, // Features to add to the dev container. More info: https://containers.dev/features.
// Use 'forwardPorts' to make a list of ports inside the container available locally. // "features": {},
// "forwardPorts": [], // Use 'forwardPorts' to make a list of ports inside the container available locally.
// Use 'postCreateCommand' to run commands after the container is created. // "forwardPorts": [],
// "postCreateCommand": "go version", // Use 'postCreateCommand' to run commands after the container is created.
// Configure tool-specific properties. // "postCreateCommand": "go version",
"customizations": { // Configure tool-specific properties.
"vscode": { "customizations": {
"extensions": [ "vscode": {
"golang.go", "extensions": [
"shardulm94.trailing-spaces", "golang.go",
"IBM.output-colorizer", "shardulm94.trailing-spaces",
"ms-vscode.makefile-tools", "IBM.output-colorizer",
"ms-azuretools.vscode-docker" "task.vscode-task",
] "github.vscode-github-actions",
} "redhat.vscode-yaml"
} ]
} }
}
}

View File

@ -13,6 +13,9 @@ jobs:
with: with:
go-version: ${{ matrix.go }} go-version: ${{ matrix.go }}
- name: Install Task
uses: arduino/setup-task@v1
- name: Check out code - name: Check out code
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -29,10 +32,10 @@ jobs:
go get -v -t -d ./... go get -v -t -d ./...
- name: Build linux - name: Build linux
run: make linux run: task linux
- name: Build windows - name: Build windows
run: make windows run: task windows
- name: Test - name: Test
run: make test run: task test

View File

@ -1,41 +0,0 @@
.DEFAULT_GOAL := linux
.PHONY: linux
linux:
go build -o ./gobuster
.PHONY: windows
windows:
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o ./gobuster.exe
.PHONY: fmt
fmt:
go fmt ./...
.PHONY: update
update:
go get -u
go mod tidy -v
.PHONY: all
all: fmt update linux windows test lint
.PHONY: test
test:
go test -v -race ./...
.PHONY: lint
lint:
"$$(go env GOPATH)/bin/golangci-lint" run ./...
go mod tidy
.PHONY: lint-update
lint-update:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin
$$(go env GOPATH)/bin/golangci-lint --version
.PHONY: tag
tag:
@[ "${TAG}" ] && echo "Tagging a new version ${TAG}" || ( echo "TAG is not set"; exit 1 )
git tag -a "${TAG}" -m "${TAG}"
git push origin "${TAG}"

View File

@ -40,6 +40,8 @@ All funds that are donated to this project will be donated to charity. A full lo
- added automaxprocs for use in docker with cpu limits - added automaxprocs for use in docker with cpu limits
- log http requests with debug enabled - log http requests with debug enabled
- allow fuzzing of Host header in fuzz mode - allow fuzzing of Host header in fuzz mode
- automatically disable progress output when output is redirected
- fix extra special characters when run with `--no-progress`
## 3.6 ## 3.6

62
Taskfile.yml Normal file
View File

@ -0,0 +1,62 @@
version: "3"
vars:
PROGRAM: gobuster
tasks:
update:
cmds:
- go get -u
- go mod tidy -v
build:
aliases: [default, linux]
cmds:
- go fmt ./...
- go vet ./...
- go build -o {{.PROGRAM}}
env:
CGO_ENABLED: 0
linux:
cmds:
- task: build
env:
CGO_ENABLED: 0
GOOS: linux
GOARCH: amd64
windows:
cmds:
- task: build
env:
CGO_ENABLED: 0
GOOS: windows
GOARCH: amd64
test:
env:
CGO_ENABLED: 1 # required by -race
cmds:
- go test -race -cover ./...
lint:
cmds:
- golangci-lint run ./... --timeout=30m
- go mod tidy
lint-update:
cmds:
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b {{ .GOPATH }}/bin
- golangci-lint --version
vars:
GOPATH:
sh: go env GOPATH
tag:
cmds:
- git tag -a "${TAG}" -m "${TAG}"
- git push origin "${TAG}"
preconditions:
- sh: '[[ -n "${TAG}" ]]'
msg: "Please set the TAG environment variable"

View File

@ -36,7 +36,12 @@ func resultWorker(g *libgobuster.Gobuster, filename string, wg *sync.WaitGroup)
} }
if s != "" { if s != "" {
s = strings.TrimSpace(s) s = strings.TrimSpace(s)
_, _ = fmt.Printf("%s%s\n", TERMINAL_CLEAR_LINE, s) if g.Opts.NoProgress {
_, _ = fmt.Printf("%s\n", s)
} else {
// only print the clear line when progress output is enabled
_, _ = fmt.Printf("%s%s\n", TERMINAL_CLEAR_LINE, s)
}
if f != nil { if f != nil {
err = writeToFile(f, s) err = writeToFile(f, s)
if err != nil { if err != nil {
@ -163,6 +168,15 @@ func Gobuster(ctx context.Context, opts *libgobuster.Options, plugin libgobuster
log.Println(ruler) log.Println(ruler)
} }
fi, err := os.Stdout.Stat()
if err != nil {
return err
}
// check if we are not in a terminal. If so, disable output
if (fi.Mode() & os.ModeCharDevice) != os.ModeCharDevice {
opts.NoProgress = true
}
// our waitgroup for all goroutines // our waitgroup for all goroutines
// this ensures all goroutines are finished // this ensures all goroutines are finished
// when we call wg.Wait() // when we call wg.Wait()

View File

@ -11,7 +11,6 @@ type Options struct {
PatternFile string PatternFile string
Patterns []string Patterns []string
OutputFilename string OutputFilename string
NoStatus bool
NoProgress bool NoProgress bool
NoError bool NoError bool
Quiet bool Quiet bool