Skip to content

Commit 6c82039

Browse files
committed
v1,1.0
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
1 parent ec14b8c commit 6c82039

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"flag"
55
"fmt"
6+
"os"
67

78
"github.com/fatih/color"
89
"github.com/joanbono/akt/modules/rotate"
@@ -45,12 +46,17 @@ func main() {
4546
fmt.Printf("%v Try with %v\n\n", cyan.Sprintf("[i]"), bold.Sprintf("akt -h"))
4647
return
4748
} else {
49+
//Check that .aws/credentials file is accessible before rotating the keys
50+
//This will prevent rotated keys not being written anywhere
51+
if _, err := os.Stat(writer.Reader()); err != nil {
52+
fmt.Printf("%v .aws/credentials file not found\n", red.Sprintf("[-]"))
53+
os.Exit(2)
54+
}
4855
accessKey, secretKey, username = rotate.Rotate(profileFlag, userFlag)
4956
if saveFlag {
5057
writer.Profiler(profileFlag, accessKey, secretKey)
5158
} else {
5259
writer.Printer(profileFlag, accessKey, secretKey)
5360
}
5461
}
55-
5662
}

0 commit comments

Comments
 (0)