Skip to content

Commit 5e4e678

Browse files
committed
refactor: removed logs and comments
Signed-off-by: Jad Chahed <[email protected]>
1 parent caac9f8 commit 5e4e678

File tree

3 files changed

+0
-19
lines changed

3 files changed

+0
-19
lines changed

go/admin/api.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ func (a *Admin) handleExecutionsAdd(c *gin.Context) {
193193
}
194194

195195
serverAPIURL := "http://localhost:8080/api/executions/add"
196-
// make a body with "admin-user": {encryptedToken}, "source": {source}, "sha": {sha}, "workloads": workloads, "numberOfExecutions": {numberOfExecutions}}
197196

198197
req, err := http.NewRequest("POST", serverAPIURL, bytes.NewBuffer(jsonData))
199198

@@ -205,7 +204,6 @@ func (a *Admin) handleExecutionsAdd(c *gin.Context) {
205204

206205
req.Header.Set("Content-Type", "application/json")
207206

208-
// Execute the request
209207
client := &http.Client{}
210208
resp, err := client.Do(req)
211209
if err != nil {
@@ -215,7 +213,6 @@ func (a *Admin) handleExecutionsAdd(c *gin.Context) {
215213
}
216214
defer resp.Body.Close()
217215

218-
// Handle the response from the server API
219216
if resp.StatusCode != http.StatusOK {
220217
slog.Error("Server API returned an error: ", resp.Status)
221218
c.JSON(resp.StatusCode, gin.H{"error": "Failed to process request on server API"})

go/server/api.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,6 @@ type ExecutionRequest struct {
548548
}
549549

550550
func (s *Server) addExecutions(c *gin.Context) {
551-
slog.Info("Adding execution")
552-
553551
var req ExecutionRequest
554552

555553
if err := c.ShouldBindJSON(&req); err != nil {
@@ -561,8 +559,6 @@ func (s *Server) addExecutions(c *gin.Context) {
561559

562560
slog.Info(decryptedToken)
563561

564-
slog.Infof("source: %s, sha: %s, workloads: %v, numberOfExecutions: %s, token: %s", req.Source, req.SHA, req.Workloads, req.NumberOfExecutions, decryptedToken)
565-
566562
if req.Source == "" || req.SHA == "" || len(req.Workloads) == 0 || req.NumberOfExecutions == "" {
567563
c.JSON(http.StatusBadRequest, &ErrorAPI{Error: "missing argument"})
568564
return

go/tools/server/utils.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,24 @@ const (
3434

3535
func Encrypt(stringToEncrypt string, keyString string) (encryptedString string) {
3636
slog.Info(stringToEncrypt, keyString)
37-
//Since the key is in string, we need to convert decode it to bytes
3837
key, _ := hex.DecodeString(keyString)
3938
plaintext := []byte(stringToEncrypt)
4039

41-
//Create a new Cipher Block from the key
4240
block, err := aes.NewCipher(key)
4341
if err != nil {
4442
panic(err.Error())
4543
}
4644

47-
//Create a new GCM - https://en.wikipedia.org/wiki/Galois/Counter_Mode
48-
//https://golang.org/pkg/crypto/cipher/#NewGCM
4945
aesGCM, err := cipher.NewGCM(block)
5046
if err != nil {
5147
panic(err.Error())
5248
}
5349

54-
//Create a nonce. Nonce should be from GCM
5550
nonce := make([]byte, aesGCM.NonceSize())
5651
if _, err = io.ReadFull(rand.Reader, nonce); err != nil {
5752
panic(err.Error())
5853
}
5954

60-
//Encrypt the data using aesGCM.Seal
61-
//Since we don't want to save the nonce somewhere else in this case, we add it as a prefix to the encrypted data. The first nonce argument in Seal is the prefix.
6255
ciphertext := aesGCM.Seal(nonce, nonce, plaintext, nil)
6356
return fmt.Sprintf("%x", ciphertext)
6457
}
@@ -68,25 +61,20 @@ func Decrypt(encryptedString string, keyString string) (decryptedString string)
6861
key, _ := hex.DecodeString(keyString)
6962
enc, _ := hex.DecodeString(encryptedString)
7063

71-
//Create a new Cipher Block from the key
7264
block, err := aes.NewCipher(key)
7365
if err != nil {
7466
panic(err.Error())
7567
}
7668

77-
//Create a new GCM
7869
aesGCM, err := cipher.NewGCM(block)
7970
if err != nil {
8071
panic(err.Error())
8172
}
8273

83-
//Get the nonce size
8474
nonceSize := aesGCM.NonceSize()
8575

86-
//Extract the nonce from the encrypted data
8776
nonce, ciphertext := enc[:nonceSize], enc[nonceSize:]
8877

89-
//Decrypt the data
9078
plaintext, err := aesGCM.Open(nil, nonce, ciphertext, nil)
9179
if err != nil {
9280
panic(err.Error())

0 commit comments

Comments
 (0)