From 3328a284d289ada99eccad2e1b426d73c01c187b Mon Sep 17 00:00:00 2001 From: Joona Hoikkala Date: Wed, 7 Dec 2022 18:26:06 +0200 Subject: [PATCH] Fix linter workflow and autocalibration for lines & words match (#614) * Fix autocalibration for lines & words match * Fix golangci-lint workflow --- .github/workflows/golangci-lint.yml | 7 +++++-- CHANGELOG.md | 1 + pkg/ffuf/autocalibration.go | 13 +++++++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index ab35228..dbf5ffe 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -11,9 +11,12 @@ jobs: name: lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/setup-go@v3 + with: + go-version: 1.17 + - uses: actions/checkout@v3 - name: golangci-lint - uses: golangci/golangci-lint-action@v2 + uses: golangci/golangci-lint-action@v3 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. version: v1.29 diff --git a/CHANGELOG.md b/CHANGELOG.md index 89d9a41..8f9f4ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - master - New - Changed + - Fixed issue with autocalibration of line & words filter - v1.5.0 - New diff --git a/pkg/ffuf/autocalibration.go b/pkg/ffuf/autocalibration.go index d6d02e5..3154151 100644 --- a/pkg/ffuf/autocalibration.go +++ b/pkg/ffuf/autocalibration.go @@ -54,7 +54,7 @@ func (j *Job) calibrationRequest(inputs map[string][]byte) (Response, error) { return resp, fmt.Errorf("Response wouldn't be matched") } -//CalibrateForHost runs autocalibration for a specific host +// CalibrateForHost runs autocalibration for a specific host func (j *Job) CalibrateForHost(host string, baseinput map[string][]byte) error { if j.Config.MatcherManager.CalibratedForDomain(host) { return nil @@ -86,7 +86,7 @@ func (j *Job) CalibrateForHost(host string, baseinput map[string][]byte) error { return nil } -//CalibrateResponses returns slice of Responses for randomly generated filter autocalibration requests +// CalibrateResponses returns slice of Responses for randomly generated filter autocalibration requests func (j *Job) Calibrate(input map[string][]byte) error { if j.Config.MatcherManager.Calibrated() { return nil @@ -112,8 +112,9 @@ func (j *Job) Calibrate(input map[string][]byte) error { return nil } -//CalibrateIfNeeded runs a self-calibration task for filtering options (if needed) by requesting random resources and -// configuring the filters accordingly +// CalibrateIfNeeded runs a self-calibration task for filtering options (if needed) by requesting random resources and +// +// configuring the filters accordingly func (j *Job) CalibrateIfNeeded(host string, input map[string][]byte) error { j.calibMutex.Lock() defer j.calibMutex.Unlock() @@ -192,7 +193,7 @@ func (j *Job) calibrateFilters(responses []Response, perHost bool) error { return nil } } - _ = j.Config.MatcherManager.AddFilter("word", strconv.FormatInt(baselineSize, 10), false) + _ = j.Config.MatcherManager.AddFilter("word", strconv.FormatInt(baselineWords, 10), false) return nil } } @@ -226,7 +227,7 @@ func (j *Job) calibrateFilters(responses []Response, perHost bool) error { return nil } } - _ = j.Config.MatcherManager.AddFilter("line", strconv.FormatInt(baselineSize, 10), false) + _ = j.Config.MatcherManager.AddFilter("line", strconv.FormatInt(baselineLines, 10), false) return nil } }