Skip to content

Commit

Permalink
Merge pull request #17 from wallarm/release/0.5.2
Browse files Browse the repository at this point in the history
Release 0.5.2
  • Loading branch information
infkfwlrm authored Aug 21, 2024
2 parents 50b691b + e192d3a commit 6a31b8d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions action.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ type (
CredStuffMode string `json:"cred_stuff_mode,omitempty"`
CaseSensitive *bool `json:"case_sensitive,omitempty"`
LoginPoint TwoDimensionalSlice `json:"login_point,omitempty"`
Delay int `json:"delay,omitempty"`
Burst int `json:"burst,omitempty"`
Rate int `json:"rate,omitempty"`
RspStatus int `json:"rsp_status,omitempty"`
TimeUnit string `json:"time_unit,omitempty"`
}

// ActionFilter is the specific filter for getting the rules.
Expand Down
13 changes: 10 additions & 3 deletions wallarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"log"
"math"
"net/http"
"os"
"strings"
"sync"
"time"
Expand All @@ -36,7 +37,12 @@ func New(opts ...Option) (API, error) {
}

func newClient(opts ...Option) (API, error) {
silentLogger := log.New(ioutil.Discard, "", log.LstdFlags)
logger := log.New(ioutil.Discard, "", log.LstdFlags)
_, useTfOutput := os.LookupEnv("TF_LOG_PROVIDER")
if useTfOutput {
logger = log.New(os.Stdout, "", log.LstdFlags)
}

defaultUserAgent := "Wallarm-go/" + Version

api := &api{
Expand All @@ -47,7 +53,7 @@ func newClient(opts ...Option) (API, error) {
MinRetryDelay: time.Duration(1) * time.Second,
MaxRetryDelay: time.Duration(30) * time.Second,
},
logger: silentLogger,
logger: logger,
Mutex: &sync.Mutex{},
}

Expand Down Expand Up @@ -117,6 +123,7 @@ func (api *api) makeRequestContext(ctx context.Context, method, uri, reqType str

}

api.logger.Printf("REQUEST: Method: %s, Uri: %s, Body: %s", method, uri, string(jsonBody))
if query, ok := params.(string); ok {
q := strings.NewReader(query)
resp, err = api.request(ctx, method, uri, reqType, reqBody, q)
Expand Down Expand Up @@ -156,7 +163,7 @@ func (api *api) makeRequestContext(ctx context.Context, method, uri, reqType str
}

specificResourceProcessing := []string{"scanner", "user"}

api.logger.Printf("HTTP Status: %d, Body: %s", resp.StatusCode, respBody)
switch {
case resp.StatusCode >= http.StatusOK && resp.StatusCode < http.StatusMultipleChoices:
case resp.StatusCode == http.StatusUnauthorized:
Expand Down

0 comments on commit 6a31b8d

Please sign in to comment.