Skip to content

Commit

Permalink
use default perms
Browse files Browse the repository at this point in the history
  • Loading branch information
dogancanbakir committed Aug 10, 2023
1 parent 52e9253 commit 3a1d0e9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
/.vs

examples/basic/basic
examples/basic/basic.exe
examples/basic/basic.exe

.devcontainer
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/miekg/dns v1.1.55 // indirect
github.com/projectdiscovery/blackrock v0.0.1 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/tools v0.6.0 // indirect
)

Expand All @@ -23,9 +23,9 @@ require (
github.com/aymerick/douceur v0.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/microcosm-cc/bluemonday v1.0.24 // indirect
github.com/microcosm-cc/bluemonday v1.0.25 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/projectdiscovery/utils v0.0.40-0.20230627061640-8ec2b35f851c
github.com/projectdiscovery/utils v0.0.48
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect
golang.org/x/net v0.11.0 // indirect
golang.org/x/net v0.14.0 // indirect
)
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
github.com/microcosm-cc/bluemonday v1.0.24 h1:NGQoPtwGVcbGkKfvyYk1yRqknzBuoMiUrO6R7uFTPlw=
github.com/microcosm-cc/bluemonday v1.0.24/go.mod h1:ArQySAMps0790cHSkdPEJ7bGkF2VePWH773hsJNSHf8=
github.com/microcosm-cc/bluemonday v1.0.25 h1:4NEwSfiJ+Wva0VxN5B8OwMicaJvD8r9tlJWm9rtloEg=
github.com/microcosm-cc/bluemonday v1.0.25/go.mod h1:ZIOjCQp1OrzBBPIJmfX4qDYFuhU02nx4bn030ixfHLE=
github.com/miekg/dns v1.1.55 h1:GoQ4hpsj0nFLYe+bWiCToyrBEJXkQfOOIvFGFy0lEgo=
github.com/miekg/dns v1.1.55/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand All @@ -20,6 +22,8 @@ github.com/projectdiscovery/blackrock v0.0.1 h1:lHQqhaaEFjgf5WkuItbpeCZv2DUIE45k
github.com/projectdiscovery/blackrock v0.0.1/go.mod h1:ANUtjDfaVrqB453bzToU+YB4cUbvBRpLvEwoWIwlTss=
github.com/projectdiscovery/utils v0.0.40-0.20230627061640-8ec2b35f851c h1:mNV/VSMi9wVpq3gcz4km2oUml9M+La20GaFoJPe3Ils=
github.com/projectdiscovery/utils v0.0.40-0.20230627061640-8ec2b35f851c/go.mod h1:rrd8dTBuKEScNMLgs1Xiu8rPCVeR0QTzmRcQ5iM3ymo=
github.com/projectdiscovery/utils v0.0.48 h1:eXJfOYQ3whDIo4uBX68UiPCLCmGE7Isv9348YukaCbY=
github.com/projectdiscovery/utils v0.0.48/go.mod h1:WhzbWSyGkTDn4Jvw+7jM2yP675/RARegNjoA6S7zYcc=
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca h1:NugYot0LIVPxTvN8n+Kvkn6TrbMyxQiuvKdEwFdR9vI=
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
Expand All @@ -30,9 +34,13 @@ golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU=
golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
Expand Down
5 changes: 3 additions & 2 deletions goflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

"github.com/cnf/structhash"
fileutil "github.com/projectdiscovery/utils/file"
permissionutil "github.com/projectdiscovery/utils/permission"
"golang.org/x/exp/maps"
"gopkg.in/yaml.v3"
)
Expand Down Expand Up @@ -110,10 +111,10 @@ func (flagSet *FlagSet) Parse() error {
if err != nil {
return err
}
_ = os.MkdirAll(filepath.Dir(configFilePath), os.ModePerm)
_ = os.MkdirAll(filepath.Dir(configFilePath), permissionutil.ConfigFolderPermission)
if !fileutil.FileExists(configFilePath) {
configData := flagSet.generateDefaultConfig()
return os.WriteFile(configFilePath, configData, os.ModePerm)
return os.WriteFile(configFilePath, configData, permissionutil.ConfigFilePermission)
}
_ = flagSet.MergeConfigFile(configFilePath) // try to read default config after parsing flags
return nil
Expand Down
7 changes: 4 additions & 3 deletions goflags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"testing"
"time"

permissionutil "github.com/projectdiscovery/utils/permission"
"github.com/stretchr/testify/assert"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -63,7 +64,7 @@ severity:
int-value: 543
bool-value: true
duration-value: 1h`
err := os.WriteFile("test.yaml", []byte(configFileData), os.ModePerm)
err := os.WriteFile("test.yaml", []byte(configFileData), permissionutil.ConfigFilePermission)
require.Nil(t, err, "could not write temporary config")
defer os.Remove("test.yaml")

Expand Down Expand Up @@ -303,7 +304,7 @@ func TestParseFileCommaSeparatedStringSlice(t *testing.T) {
testFileData := `value1
Value2 "
value3`
err := os.WriteFile(testFile, []byte(testFileData), os.ModePerm)
err := os.WriteFile(testFile, []byte(testFileData), permissionutil.ConfigFilePermission)
require.Nil(t, err, "could not write temporary values file")
defer os.Remove(testFile)

Expand Down Expand Up @@ -332,7 +333,7 @@ config-only:
- test
- test2
`
err := os.WriteFile("test.yaml", []byte(configFileData), os.ModePerm)
err := os.WriteFile("test.yaml", []byte(configFileData), permissionutil.ConfigFilePermission)
require.Nil(t, err, "could not write temporary config")
defer os.Remove("test.yaml")

Expand Down

0 comments on commit 3a1d0e9

Please sign in to comment.