Skip to content

Commit

Permalink
refactor: correct some linter items
Browse files Browse the repository at this point in the history
  • Loading branch information
Integralist committed Nov 13, 2023
1 parent 45a5e55 commit 6ef7348
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pkg/app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/fastly/cli/pkg/text"
)

// Run kick starts the CLI application.
func Run(args []string, stdin io.Reader) error {
opts, err := Init(args, stdin)
if err != nil {
Expand Down Expand Up @@ -382,8 +383,9 @@ func processToken(commands []cmd.Command, commandName string, m *manifest.Data,
if g.Verbose() {
displayToken(tokenSource, m.File.Profile, *g, out)
}

checkConfigPermissions(g.Flags.Quiet, commandName, tokenSource, out)
if !g.Flags.Quiet {
checkConfigPermissions(commandName, tokenSource, out)
}

return token, nil
}
Expand Down Expand Up @@ -612,16 +614,14 @@ func displayToken(tokenSource lookup.Source, profileName string, g global.Data,
// If we are using the token from config file, check the file's permissions
// to assert if they are not too open or have been altered outside of the
// application and warn if so.
func checkConfigPermissions(quietMode bool, commandName string, tokenSource lookup.Source, out io.Writer) {
func checkConfigPermissions(commandName string, tokenSource lookup.Source, out io.Writer) {
segs := strings.Split(commandName, " ")
if tokenSource == lookup.SourceFile && (len(segs) > 0 && segs[0] != "profile") {
if fi, err := os.Stat(config.FilePath); err == nil {
if mode := fi.Mode().Perm(); mode > config.FilePermissions {
if !quietMode {
text.Warning(out, "Unprotected configuration file.\n\n")
text.Output(out, "Permissions for '%s' are too open\n\n", config.FilePath)
text.Output(out, "It is recommended that your configuration file is NOT accessible by others.\n\n")
}
text.Warning(out, "Unprotected configuration file.\n\n")
text.Output(out, "Permissions for '%s' are too open\n\n", config.FilePath)
text.Output(out, "It is recommended that your configuration file is NOT accessible by others.\n\n")
}
}
}
Expand Down

0 comments on commit 6ef7348

Please sign in to comment.