全部搜尋項
bullseye  ] [  bookworm  ] [  trixie  ] [  sid  ]
[ 原始碼: golang-github-cli-safeexec  ]

套件:golang-github-cli-safeexec-dev(1.0.0-2)

golang-github-cli-safeexec-dev 的相關連結

Screenshot

Debian 的資源:

下載原始碼套件 golang-github-cli-safeexec

維護小組:

外部的資源:

相似套件:

safer version of exec.LookPath on Windows

safeexec is a Go module that provides a safer alternative to exec.LookPath() on Windows.

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

  import "os/exec"

  func gitStatus() error {
      // On Windows, this will result in .\git.exe or .\git.bat being executed
      // if either were found in the current working directory.
      cmd := exec.Command("git", "status") 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: https://github.com/golang/go/issues/38736

Since Go does not provide a version of exec.LookPath() that only searches PATH and does not search the current working directory, this module provides a LookPath function that works consistently across platforms.

Example use:

  import (
      "os/exec" "github.com/cli/safeexec"
  )

  func gitStatus() error {
      gitBin, err := safeexec.LookPath("git")
      if err != nil {
          return err
      }
      cmd := exec.Command(gitBin, "status")
      return cmd.Run()
  }

下載 golang-github-cli-safeexec-dev

下載可用於所有硬體架構的
硬體架構 套件大小 安裝後大小 檔案
all 5。1 kB31。0 kB [檔案列表]