Documentation ¶
Index ¶
- Constants
- Variables
- func GetMachineID() string
- func GetOSVendor() string
- func GetToolVersionCallback(toolName, version string) func() (string, error)
- func GetUpdateToolCallback(toolName, version string) func()
- func GetUpdateToolFromRepoCallback(toolName, version, repoName string) func()
- func GetVersionCheckCallback(toolName string) func() (string, error)deprecated
- func GetVersionDescription(current string, latest string) string
- func GetpdtmParams(version string) string
- func IsDevReleaseOutdated(current string, latest string) bool
- func IsOutdated(current, latest string) bool
- func UnpackAssetWithCallback(format AssetFormat, data *bytes.Reader, callback AssetFileCallback) error
- type AssetFileCallback
- type AssetFormat
- type GHReleaseDownloader
- func (d *GHReleaseDownloader) DownloadAssetWithName(assetname string, showProgressBar bool) (*bytes.Buffer, error)
- func (d *GHReleaseDownloader) DownloadSourceWithCallback(showProgressBar bool, callback AssetFileCallback) error
- func (d *GHReleaseDownloader) DownloadTool() (*bytes.Buffer, error)
- func (d *GHReleaseDownloader) GetExecutableFromAsset() ([]byte, error)
- func (d *GHReleaseDownloader) GetReleaseChecksums() (map[string]string, error)
- func (d *GHReleaseDownloader) SetToolName(toolName string)
- type Tool
Constants ¶
const ( Organization = "projectdiscovery" UpdateCheckEndpoint = "https://api.pdtm.sh/api/v1/tools/%v" )
Variables ¶
var ( ErrNoAssetFound = errorutil.NewWithFmt("update: could not find release asset for your platform (%s/%s)") SkipCheckSumValidation = false // by default checksum of gh assets is verified with checksums file present in release )
var ( // By default when tool is updated release notes of latest version are printed HideReleaseNotes = false NoColorReleaseNotes = false HideProgressBar = false VersionCheckTimeout = time.Duration(5) * time.Second DownloadUpdateTimeout = time.Duration(30) * time.Second // Note: DefaultHttpClient is only used in GetToolVersionCallback DefaultHttpClient *http.Client )
Aurora instance
Functions ¶
func GetMachineID ¶ added in v0.0.81
func GetMachineID() string
GetMachineID return a unique identifier that is unique to the machine it is a sha256 hashed value with pdtm as salt
func GetOSVendor ¶ added in v0.0.87
func GetOSVendor() string
Get OS Vendor returns the linux distribution vendor if not linux then returns runtime.GOOS
func GetToolVersionCallback ¶ added in v0.0.22
GetToolVersionCallback returns a callback function that checks for updates of tool by sending a request to update check endpoint and returns latest version if repoName is empty then tool name is considered as repoName
func GetUpdateToolCallback ¶
func GetUpdateToolCallback(toolName, version string) func()
GetUpdateToolCallback returns a callback function that updates given tool if given version is older than latest gh release and exits
func GetUpdateToolFromRepoCallback ¶ added in v0.0.22
func GetUpdateToolFromRepoCallback(toolName, version, repoName string) func()
GetUpdateToolWithRepoCallback returns a callback function that is similar to GetUpdateToolCallback but it takes repoName as an argument (repoName can be either just repoName ex: `nuclei` or full repo Addr ex: `projectdiscovery/nuclei`)
func GetVersionCheckCallback
deprecated
func GetVersionDescription ¶
GetVersionDescription returns tags like (latest) or (outdated) or (dev)
func GetpdtmParams ¶ added in v0.0.56
GetpdtmParams returns encoded query parameters sent to update check endpoint
func IsDevReleaseOutdated ¶ added in v0.0.22
IsDevReleaseOutdated returns true if installed tool (dev version) is outdated ex: if installed tools is v2.9.1-dev and latest release is v2.9.1 then it is outdated since v2.9.1-dev is released and merged into main/master branch
func IsOutdated ¶ added in v0.0.22
IsOutdated returns true if current version is outdated
func UnpackAssetWithCallback ¶ added in v0.0.22
func UnpackAssetWithCallback(format AssetFormat, data *bytes.Reader, callback AssetFileCallback) error
UnpackAssetWithCallback unpacks asset and executes callback function on every file in data
Types ¶
type AssetFileCallback ¶ added in v0.0.22
AssetFileCallback function is executed on every file in unpacked asset . if returned error is not nil furthur processing of asset file is stopped
type AssetFormat ¶
type AssetFormat uint
const ( Zip AssetFormat = iota Tar Unknown )
func IdentifyAssetFormat ¶ added in v0.0.22
func IdentifyAssetFormat(assetName string) AssetFormat
func (AssetFormat) FileExtension ¶ added in v0.0.22
func (a AssetFormat) FileExtension() string
FileExtension of this asset format
type GHReleaseDownloader ¶
type GHReleaseDownloader struct { Format AssetFormat AssetID int Latest *github.RepositoryRelease // contains filtered or unexported fields }
GHReleaseDownloader fetches and reads release of a gh repo
func NewghReleaseDownloader ¶
func NewghReleaseDownloader(RepoName string) (*GHReleaseDownloader, error)
NewghReleaseDownloader returns GHRD instance
func (*GHReleaseDownloader) DownloadAssetWithName ¶ added in v0.0.22
func (d *GHReleaseDownloader) DownloadAssetWithName(assetname string, showProgressBar bool) (*bytes.Buffer, error)
DownloadAssetWithName downloads asset with given name
func (*GHReleaseDownloader) DownloadSourceWithCallback ¶ added in v0.0.22
func (d *GHReleaseDownloader) DownloadSourceWithCallback(showProgressBar bool, callback AssetFileCallback) error
DownloadSourceWithCallback downloads source code of latest release and calls callback for each file in archive
func (*GHReleaseDownloader) DownloadTool ¶ added in v0.0.22
func (d *GHReleaseDownloader) DownloadTool() (*bytes.Buffer, error)
DownloadTool downloads tool and returns bin data
func (*GHReleaseDownloader) GetExecutableFromAsset ¶
func (d *GHReleaseDownloader) GetExecutableFromAsset() ([]byte, error)
GetExecutableFromAsset downloads , validates checksum and only returns tool Binary
func (*GHReleaseDownloader) GetReleaseChecksums ¶ added in v0.0.22
func (d *GHReleaseDownloader) GetReleaseChecksums() (map[string]string, error)
GetReleaseChecksums tries to download tool checksum if release contains any in map[asset_name]checksum_data format
func (*GHReleaseDownloader) SetToolName ¶ added in v0.0.22
func (d *GHReleaseDownloader) SetToolName(toolName string)
SetAssetName: By default RepoName is assumed as ToolName which maynot be the case always setToolName corrects that