looker

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2022 License: GPL-3.0 Imports: 1 Imported by: 0

README

Looker

🔍 find app path and print it.

A alternative package to exec.LookPath().

The problem

The following code, relatively common approach to running external commands has a vulnerability on Windows:

import "os/exec"

func gitAdd() error {
    cmd := exec.Command("git", "add", "Formula")
    return cmd.Run()
}

Searching the current directory (surprising behavior) before searching folders listed in the PATH environment variable (expected behavior) seems to be intended in Go and unlikely to be changed go#38736

Example:

import (
    "os/exec"

    "github.com/abdfnx/looker"
)

func gitAdd() error {
    gitPath, err := looker.LookPath("git")

    if err != nil {
        return err
    }

    cmd := exec.Command(gitPath, "add", "Formula")
    return cmd.Run()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LookPath

func LookPath(file string) (string, error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL