Fix linter workflow and autocalibration for lines & words match (#614)

* Fix autocalibration for lines & words match

* Fix golangci-lint workflow
This commit is contained in:
Joona Hoikkala 2022-12-07 18:26:06 +02:00 committed by GitHub
parent 5c489aea78
commit 3328a284d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 8 deletions

View file

@ -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

View file

@ -2,6 +2,7 @@
- master
- New
- Changed
- Fixed issue with autocalibration of line & words filter
- v1.5.0
- New

View file

@ -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
}
}