projectdiscovery / pdtm

ProjectDiscovery's Open Source Tool Manager
https://projectdiscovery.io
MIT License
677 stars 49 forks source link

install if not there. #232

Closed gedw99 closed 7 months ago

gedw99 commented 7 months ago

SO when a user calls for naabu, we check if its installed and if not, install it, and then let the original call to naabu through.

The below Makefile works btw, but I was thinking we should codify it into pdtm as golang code.


OS_GO_BIN_NAME=go
ifeq ($(shell uname),Windows)
    OS_GO_BIN_NAME=go.exe
endif

OS_GO_OS=$(shell $(OS_GO_BIN_NAME) env GOOS)
BIN_PDTM_NAME=pdtm
ifeq ($(OS_GO_OS),windows)
    BIN_PDTM_NAME=pdtm.exe
endif
BIN_PDTM_WHICH=$(shell which $(BIN_PDTM_NAME))

BIN_NAAABU_NAME=naabu
ifeq ($(OS_GO_OS),windows)
    BIN_NAAABU_NAME=naabu.exe
endif
BIN_NAAABU_WHICH=$(shell which $(BIN_NAAABU_NAME))

naabu-init:
    @echo "checking ..."
ifeq ($(BIN_NAAABU_WHICH),)
    $(BIN_PDTM_NAME) -install naabu
endif
naabu: naabu-init
    $(BIN_NAAABU_NAME)
dogancanbakir commented 7 months ago

@gedw99,

SO when a user calls for naabu, we check if its installed and is not, instal it, and then let the original call to naabu through.

We're installing the given tool programmatically if it's already not installed. Is this what you were aiming? See https://github.com/projectdiscovery/pdtm/blob/main/internal/runner/runner.go#L98

gedw99 commented 7 months ago

Thanks but on a Mac if does not work in that if the naabu is not installed then the call to naabu fails.

I will try this again though. Could be mistaken

gedw99 commented 7 months ago

Also the code uses go install to do the install I think ? so we could also make it install off the GitHub binaries eventually. A env toggle could then determine what me hanism it uses.

This would however require the binaries to be signed. For Mac that quite easy but needs an Apple developer account.

The reason of course being that not all users have golang installed.

dogancanbakir commented 7 months ago

No, it depends on the tool's installation type, if it is binary, it tries binary install, then go install if the binary install is not successful.

go install: https://github.com/projectdiscovery/pdtm/blob/main/internal/runner/runner.go#L106 binary install: https://github.com/projectdiscovery/pdtm/blob/main/internal/runner/runner.go#L113

gedw99 commented 7 months ago

Thanks. I think we can close this and I can reopen if I need to later