Browse Source

check for length 64 signature, don't throw usage error on cluster unreachable

Alexander Belanger 4 năm trước cách đây
mục cha
commit
a4dc70cc8e
2 tập tin đã thay đổi với 5 bổ sung8 xóa
  1. 1 5
      ee/billing/ironplans.go
  2. 4 3
      internal/usage/usage.go

+ 1 - 5
ee/billing/ironplans.go

@@ -212,12 +212,8 @@ func (c *Client) GetIDToken(projectID uint, user *cemodels.User) (token string,
 // VerifySignature verifies a webhook signature based on hmac protocal
 // https://docs.ironplans.com/webhook-events/webhook-events
 func (c *Client) VerifySignature(signature string, body []byte) bool {
-	if len(signature) != 71 || !strings.HasPrefix(signature, "sha256=") {
-		return false
-	}
-
 	actual := make([]byte, 32)
-	_, err := hex.Decode(actual, []byte(signature[7:]))
+	_, err := hex.Decode(actual, []byte(signature))
 
 	if err != nil {
 		return false

+ 4 - 3
internal/usage/usage.go

@@ -2,7 +2,6 @@ package usage
 
 import (
 	"errors"
-	"fmt"
 	"time"
 
 	"github.com/porter-dev/porter/api/types"
@@ -112,13 +111,15 @@ func getResourceUsage(opts *GetUsageOpts, clusters []*models.Cluster) (uint, uin
 		agent, err := kubernetes.GetAgentOutOfClusterConfig(ooc)
 
 		if err != nil {
-			return 0, 0, fmt.Errorf("failed to get agent: %s", err.Error())
+			continue
+			// return 0, 0, fmt.Errorf("failed to get agent: %s", err.Error())
 		}
 
 		totAlloc, err := nodes.GetAllocatableResources(agent.Clientset)
 
 		if err != nil {
-			return 0, 0, fmt.Errorf("failed to get alloc: %s", err.Error())
+			continue
+			// return 0, 0, fmt.Errorf("failed to get alloc: %s", err.Error())
 		}
 
 		totCPU += totAlloc.CPU