Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

www.github.com/cli/browser.git

Package Overview
Dependencies
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

www.github.com/cli/browser.git - npm Package Compare versions

Comparing version
v1.0.0
to
v1.1.0
+76
zbrowser_windows.go
// Code generated by 'go generate'; DO NOT EDIT.
package browser
import (
"syscall"
"unsafe"
"golang.org/x/sys/windows"
)
var _ unsafe.Pointer
// Do the interface allocations only once for common
// Errno values.
const (
errnoERROR_IO_PENDING = 997
)
var (
errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
errERROR_EINVAL error = syscall.EINVAL
)
// errnoErr returns common boxed Errno values, to prevent
// allocations at runtime.
func errnoErr(e syscall.Errno) error {
switch e {
case 0:
return errERROR_EINVAL
case errnoERROR_IO_PENDING:
return errERROR_IO_PENDING
}
// TODO: add more here, after collecting data on the common
// error values see on Windows. (perhaps when running
// all.bat?)
return e
}
var (
modshell32 = windows.NewLazySystemDLL("shell32.dll")
procShellExecuteW = modshell32.NewProc("ShellExecuteW")
)
func shellExecute(hwnd int, verb string, file string, args string, cwd string, showCmd int) (err error) {
var _p0 *uint16
_p0, err = syscall.UTF16PtrFromString(verb)
if err != nil {
return
}
var _p1 *uint16
_p1, err = syscall.UTF16PtrFromString(file)
if err != nil {
return
}
var _p2 *uint16
_p2, err = syscall.UTF16PtrFromString(args)
if err != nil {
return
}
var _p3 *uint16
_p3, err = syscall.UTF16PtrFromString(cwd)
if err != nil {
return
}
return _shellExecute(hwnd, _p0, _p1, _p2, _p3, showCmd)
}
func _shellExecute(hwnd int, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int) (err error) {
r1, _, e1 := syscall.Syscall6(procShellExecuteW.Addr(), 6, uintptr(hwnd), uintptr(unsafe.Pointer(verb)), uintptr(unsafe.Pointer(file)), uintptr(unsafe.Pointer(args)), uintptr(unsafe.Pointer(cwd)), uintptr(showCmd))
if r1 == 0 {
err = errnoErr(e1)
}
return
}
+10
-13
package browser
import (
"errors"
"os/exec"
"strings"
)
func openBrowser(url string) error {
browserPath, err := lookPath("xdg-open", "wslview")
if err != nil {
return err
}
return runCmd(browserPath, url)
}
providers := []string{"xdg-open", "x-www-browser", "www-browser", "wslview"}
func lookPath(cmdName, fallbackName string) (string, error) {
cmdPath, err := exec.LookPath(cmdName)
if errors.Is(err, exec.ErrNotFound) {
if wslPath, err := exec.LookPath(fallbackName); err == nil {
return wslPath, nil
// There are multiple possible providers to open a browser on linux
// One of them is xdg-open, another is x-www-browser, then there's www-browser, etc.
// Look for one that exists and run it
for _, provider := range providers {
if _, err := exec.LookPath(provider); err == nil {
return runCmd(provider, url)
}
}
return cmdPath, err
return &exec.Error{Name: strings.Join(providers, ","), Err: exec.ErrNotFound}
}
func setFlags(cmd *exec.Cmd) {}

@@ -0,22 +1,14 @@

//go:generate mkwinsyscall -output zbrowser_windows.go browser_windows.go
//sys shellExecute(hwnd int, verb string, file string, args string, cwd string, showCmd int) (err error) = shell32.ShellExecuteW
package browser
import (
"os/exec"
"strings"
"syscall"
import "os/exec"
"github.com/cli/safeexec"
)
const sW_SHOWNORMAL = 1
func openBrowser(url string) error {
cmdPath, err := safeexec.LookPath("cmd")
if err != nil {
return err
}
r := strings.NewReplacer("&", "^&")
return runCmd(cmdPath, "/c", "start", r.Replace(url))
return shellExecute(0, "", url, "", "", sW_SHOWNORMAL)
}
func setFlags(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
}
+1
-1

@@ -5,2 +5,2 @@ module github.com/cli/browser

require github.com/cli/safeexec v1.0.0
require golang.org/x/sys v0.0.0-20210319071255-635bc2c9138d
+2
-2

@@ -1,2 +0,2 @@

github.com/cli/safeexec v1.0.0 h1:0VngyaIyqACHdcMNWfo6+KdUYnqEr2Sg+bSP1pdF+dI=
github.com/cli/safeexec v1.0.0/go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5zx3Q=
golang.org/x/sys v0.0.0-20210319071255-635bc2c9138d h1:jbzgAvDZn8aEnytae+4ou0J0GwFZoHR0hOrTg4qH8GA=
golang.org/x/sys v0.0.0-20210319071255-635bc2c9138d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

@@ -8,4 +8,2 @@

- [safety](https://github.com/cli/safeexec#readme) when running inside of an untrusted directory on Windows;
- WSL compatibility;
- `OpenReader` error wrapping;

@@ -12,0 +10,0 @@ - `ErrNotFound` error wrapping on BSD;