Replacing goos with osutils (#3571)

* Replacing goos with osutils

* pleasing his majesty the linter
This commit is contained in:
Mzack9999 2023-04-19 19:30:15 +02:00 committed by GitHub
parent bf08913cd0
commit 978d0bcc23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 6 deletions

View File

@ -25,6 +25,7 @@ import (
"github.com/projectdiscovery/nuclei/v2/pkg/utils/monitor" "github.com/projectdiscovery/nuclei/v2/pkg/utils/monitor"
errorutil "github.com/projectdiscovery/utils/errors" errorutil "github.com/projectdiscovery/utils/errors"
fileutil "github.com/projectdiscovery/utils/file" fileutil "github.com/projectdiscovery/utils/file"
osutils "github.com/projectdiscovery/utils/os"
) )
var ( var (
@ -357,9 +358,9 @@ on extensive configurability, massive extensibility and ease of use.`)
return flagSet return flagSet
} }
// isColorNotAvailable returns true if ascii collored output is not available. // isColorNotAvailable returns true if ascii colored output is not available.
func isColorNotAvailable() bool { func isColorNotAvailable() bool {
return runtime.GOOS == "windows" return osutils.IsWindows()
} }
// cleanupOldResumeFiles cleans up resume files older than 10 days. // cleanupOldResumeFiles cleans up resume files older than 10 days.

View File

@ -3,10 +3,10 @@ package generators
import ( import (
"os" "os"
"path/filepath" "path/filepath"
"runtime"
"testing" "testing"
"github.com/projectdiscovery/nuclei/v2/pkg/catalog/disk" "github.com/projectdiscovery/nuclei/v2/pkg/catalog/disk"
osutils "github.com/projectdiscovery/utils/os"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -37,7 +37,7 @@ func TestLoadPayloads(t *testing.T) {
require.Equal(t, map[string][]string{"new": {"test", "another"}}, values, "could not get values") require.Equal(t, map[string][]string{"new": {"test", "another"}}, values, "could not get values")
}) })
t.Run("no-sandbox-unix", func(t *testing.T) { t.Run("no-sandbox-unix", func(t *testing.T) {
if runtime.GOOS == "windows" { if osutils.IsWindows() {
return return
} }
_, err := generator.loadPayloads(map[string]interface{}{ _, err := generator.loadPayloads(map[string]interface{}{

View File

@ -4,7 +4,6 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"os" "os"
"runtime"
"strings" "strings"
"github.com/go-rod/rod" "github.com/go-rod/rod"
@ -14,6 +13,7 @@ import (
"github.com/projectdiscovery/nuclei/v2/pkg/types" "github.com/projectdiscovery/nuclei/v2/pkg/types"
fileutil "github.com/projectdiscovery/utils/file" fileutil "github.com/projectdiscovery/utils/file"
osutils "github.com/projectdiscovery/utils/os"
reflectutil "github.com/projectdiscovery/utils/reflect" reflectutil "github.com/projectdiscovery/utils/reflect"
stringsutil "github.com/projectdiscovery/utils/strings" stringsutil "github.com/projectdiscovery/utils/strings"
) )
@ -123,7 +123,7 @@ func New(options *types.Options) (*Browser, error) {
func MustDisableSandbox() bool { func MustDisableSandbox() bool {
// linux with root user needs "--no-sandbox" option // linux with root user needs "--no-sandbox" option
// https://github.com/chromium/chromium/blob/c4d3c31083a2e1481253ff2d24298a1dfe19c754/chrome/test/chromedriver/client/chromedriver.py#L209 // https://github.com/chromium/chromium/blob/c4d3c31083a2e1481253ff2d24298a1dfe19c754/chrome/test/chromedriver/client/chromedriver.py#L209
return runtime.GOOS == "linux" && os.Geteuid() == 0 return osutils.IsWindows() && os.Geteuid() == 0
} }
// SetUserAgent sets custom user agent to the browser // SetUserAgent sets custom user agent to the browser