Skip to content

Commit

Permalink
Merge pull request #87 from projectdiscovery/dev
Browse files Browse the repository at this point in the history
pdtm v0.0.4
  • Loading branch information
ehsandeep authored Mar 3, 2023
2 parents 1492c33 + 8d9730e commit 51f46cd
Show file tree
Hide file tree
Showing 24 changed files with 556 additions and 560 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-latest-16-cores, windows-latest-8-cores, macOS-latest]
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Check out code
uses: actions/checkout@v3
Expand All @@ -27,7 +27,13 @@ jobs:
- name: Test
run: go test ./...
working-directory: .
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Race Condition Tests
run: go build -race .
working-directory: cmd/pdtm/

- name: Test Example Code
run: go run .
working-directory: examples/
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
runs-on: ubuntu-latest-16-cores
permissions:
actions: read
contents: read
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/dockerhub-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ on:

jobs:
docker:
runs-on: ubuntu-latest
runs-on: ubuntu-latest-16-cores
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get Github tag
id: meta
run: |
echo "::set-output name=tag::$(curl --silent "https://api.github.com/repos/projectdiscovery/pdtm/releases/latest" | jq -r .tag_name)"
curl --silent "https://api.github.com/repos/projectdiscovery/pdtm/releases/latest" | jq -r .tag_name | xargs -I {} echo TAG={} >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand All @@ -32,9 +32,9 @@ jobs:
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm
push: true
tags: projectdiscovery/pdtm:latest,projectdiscovery/pdtm:${{ steps.meta.outputs.tag }}
tags: projectdiscovery/pdtm:latest,projectdiscovery/pdtm:${{ steps.meta.outputs.TAG }}
4 changes: 2 additions & 2 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
- name: Checkout code
uses: actions/checkout@v3
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3.3.1
uses: golangci/golangci-lint-action@v3.4.0
with:
version: latest
args: --timeout 5m
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
release:
runs-on: ubuntu-latest
runs-on: ubuntu-latest-16-cores
steps:
- name: "Check out code"
uses: actions/checkout@v3
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/setup-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: 🔨 Setup Test

on:
pull_request:
workflow_dispatch:

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build:
name: Test Setups
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest-16-cores, windows-latest-8-cores, macOS-latest]
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Check out code
uses: actions/checkout@v3

- name: Dry Run - No Tool Installed
run: go run .
working-directory: cmd/pdtm/
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Install Run - Setup All The Tools
run: go run . -ia
working-directory: cmd/pdtm/
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Add binaries folder to ENV PATH (Unix-Like)
if: runner.os != 'Windows'
run: go run . -show-path -nsp >> $GITHUB_PATH
working-directory: cmd/pdtm/

- name: Add binaries folder to ENV PATH (Windows)
if: runner.os == 'Windows'
run: |
go run . -show-path -nsp | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
working-directory: cmd/pdtm/

- name: Checking tools existence
run: |
go run . | grep -vz "not installed"
working-directory: cmd/pdtm/

- name: Update Run - Update All The Tools
run: go run . -ua
working-directory: cmd/pdtm/
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Remove Run - Remove All The Tools
run: go run . -ra
working-directory: cmd/pdtm/
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM golang:1.19.4-alpine AS builder
FROM golang:1.20.1-alpine AS builder
RUN apk add --no-cache git
RUN go install -v github.com/projectdiscovery/pdtm/cmd/pdtm@latest

FROM alpine:3.17.0
FROM alpine:3.17.2
RUN apk -U upgrade --no-cache \
&& apk add --no-cache bind-tools ca-certificates
COPY --from=builder /go/bin/pdtm /usr/local/bin/
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Flags:
CONFIG:
-config string cli flag configuration file (default "$HOME/.config/pdtm/config.yaml")
-bp, -binary-path string custom location to download project binary (default "$HOME/.pdtm/go/bin")
-nsp, -no-set-path disable adding path to environment variables

INSTALL:
-i, -install string[] install single or multiple project by name (comma separated)
Expand All @@ -77,9 +78,10 @@ REMOVE:
-ra, -remove-all remove all the projects

DEBUG:
-nc, -no-color disable output content coloring (ANSI escape codes)
-version show version of the project
-v show verbose output
-sp, -show-path show the current binary path then exit
-version show version of the project
-v, -verbose show verbose output
-nc, -no-color disable output content coloring (ANSI escape codes)
```

## Running pdtm
Expand Down
32 changes: 32 additions & 0 deletions examples/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package main

import (
"fmt"

"github.com/projectdiscovery/goflags"
"github.com/projectdiscovery/pdtm/pkg/utils"
)

type options struct {
DisableUpdateCheck bool
}

func main() {
options := &options{}
flagSet := goflags.NewFlagSet()
toolName := "nuclei"

flagSet.CreateGroup("update", "Update",
flagSet.CallbackVarP(utils.GetUpdaterCallback(toolName), "update", "up", fmt.Sprintf("update %v to the latest released version", toolName)),
flagSet.BoolVarP(&options.DisableUpdateCheck, "disable-update-check", "duc", false, "disable automatic update check"),
)

if err := flagSet.Parse(); err != nil {
panic(err)
}

if !options.DisableUpdateCheck {
msg := utils.GetVersionCheckCallback(toolName)()
fmt.Println(msg)
}
}
34 changes: 20 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,46 +1,52 @@
module github.com/projectdiscovery/pdtm

go 1.18
go 1.19

require (
github.com/google/go-github v17.0.0+incompatible
github.com/projectdiscovery/goflags v0.1.6
github.com/projectdiscovery/gologger v1.1.7
github.com/projectdiscovery/utils v0.0.4-0.20221214110533-9f95ee986a54
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a
github.com/projectdiscovery/goflags v0.1.8-0.20230227110143-6fd5a0dc706b
github.com/projectdiscovery/gologger v1.1.8
github.com/projectdiscovery/utils v0.0.13
github.com/stretchr/testify v1.8.2
golang.org/x/oauth2 v0.5.0
golang.org/x/sys v0.5.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
)

require (
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/cnf/structhash v0.0.0-20201127153200-e1b16c1ebc08 // indirect
github.com/dsnet/compress v0.0.1 // indirect
github.com/golang/protobuf v1.4.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
github.com/logrusorgru/aurora/v4 v4.0.0
github.com/mholt/archiver v3.1.1+incompatible // indirect
github.com/microcosm-cc/bluemonday v1.0.21 // indirect
github.com/miekg/dns v1.1.50 // indirect
github.com/microcosm-cc/bluemonday v1.0.22 // indirect
github.com/miekg/dns v1.1.51 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/nwaples/rardecode v1.1.0 // indirect
github.com/pierrec/lz4 v2.6.0+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect
github.com/ulikunitz/xz v0.5.8 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
golang.org/x/exp v0.0.0-20221019170559-20944726eadf // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/tools v0.1.12 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/protobuf v1.25.0 // indirect
golang.org/x/tools v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/djherbis/times.v1 v1.3.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
)
Loading

0 comments on commit 51f46cd

Please sign in to comment.