Skip to content

Commit

Permalink
v1,1.0
Browse files Browse the repository at this point in the history
Added a check in main.go where it checks if the .aws/credentials file
exists before rotating the keys, to ensure the key is rotated and then
written to the file
  • Loading branch information
joanbono committed Mar 11, 2021
1 parent ec14b8c commit 6c82039
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"os"

"github.com/fatih/color"
"github.com/joanbono/akt/modules/rotate"
Expand Down Expand Up @@ -45,12 +46,17 @@ func main() {
fmt.Printf("%v Try with %v\n\n", cyan.Sprintf("[i]"), bold.Sprintf("akt -h"))
return
} else {
//Check that .aws/credentials file is accessible before rotating the keys
//This will prevent rotated keys not being written anywhere
if _, err := os.Stat(writer.Reader()); err != nil {
fmt.Printf("%v .aws/credentials file not found\n", red.Sprintf("[-]"))
os.Exit(2)
}
accessKey, secretKey, username = rotate.Rotate(profileFlag, userFlag)
if saveFlag {
writer.Profiler(profileFlag, accessKey, secretKey)
} else {
writer.Printer(profileFlag, accessKey, secretKey)
}
}

}

0 comments on commit 6c82039

Please sign in to comment.