mirror of
https://github.com/ffuf/ffuf
synced 2024-12-03 00:29:15 +00:00
Add linter workflow as GitHub action (#325)
* Add linter workflow as GitHub action * Fix linter issues * More fixes
This commit is contained in:
parent
2abc72018d
commit
99100e0608
9 changed files with 66 additions and 19 deletions
28
.github/workflows/golangci-lint.yml
vendored
Normal file
28
.github/workflows/golangci-lint.yml
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
name: golangci-lint
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v*
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
jobs:
|
||||
golangci:
|
||||
name: lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
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
|
||||
|
||||
# Optional: working directory, useful for monorepos
|
||||
# working-directory: somedir
|
||||
|
||||
# Optional: golangci-lint command line arguments.
|
||||
# args: --issues-exit-code=0
|
||||
|
||||
# Optional: show only new issues if it's a pull request. The default value is `false`.
|
||||
# only-new-issues: true
|
|
@ -35,7 +35,7 @@ type InternalInputProvider interface {
|
|||
|
||||
//OutputProvider is responsible of providing output from the RunnerProvider
|
||||
type OutputProvider interface {
|
||||
Banner() error
|
||||
Banner()
|
||||
Finalize() error
|
||||
Progress(status Progress)
|
||||
Info(infostring string)
|
||||
|
|
|
@ -119,7 +119,10 @@ func (j *Job) Start() {
|
|||
j.startExecution()
|
||||
}
|
||||
|
||||
j.Output.Finalize()
|
||||
err := j.Output.Finalize()
|
||||
if err != nil {
|
||||
j.Output.Error(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func (j *Job) jobsInQueue() bool {
|
||||
|
|
|
@ -12,7 +12,7 @@ type ValueRange struct {
|
|||
|
||||
func ValueRangeFromString(instr string) (ValueRange, error) {
|
||||
// is the value a range
|
||||
minmax := regexp.MustCompile("^(\\d+)\\-(\\d+)$").FindAllStringSubmatch(instr, -1)
|
||||
minmax := regexp.MustCompile(`^(\d+)-(\d+)$`).FindAllStringSubmatch(instr, -1)
|
||||
if minmax != nil {
|
||||
// yes
|
||||
minval, err := strconv.ParseInt(minmax[0][1], 10, 0)
|
||||
|
|
|
@ -58,6 +58,7 @@ func AddMatcher(conf *ffuf.Config, name string, option string) error {
|
|||
|
||||
//CalibrateIfNeeded runs a self-calibration task for filtering options (if needed) by requesting random resources and acting accordingly
|
||||
func CalibrateIfNeeded(j *ffuf.Job) error {
|
||||
var err error
|
||||
if !j.Config.AutoCalibration {
|
||||
return nil
|
||||
}
|
||||
|
@ -67,12 +68,12 @@ func CalibrateIfNeeded(j *ffuf.Job) error {
|
|||
return err
|
||||
}
|
||||
if len(responses) > 0 {
|
||||
calibrateFilters(j, responses)
|
||||
err = calibrateFilters(j, responses)
|
||||
}
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
func calibrateFilters(j *ffuf.Job, responses []ffuf.Response) {
|
||||
func calibrateFilters(j *ffuf.Job, responses []ffuf.Response) error {
|
||||
sizeCalib := make([]string, 0)
|
||||
wordCalib := make([]string, 0)
|
||||
lineCalib := make([]string, 0)
|
||||
|
@ -97,14 +98,24 @@ func calibrateFilters(j *ffuf.Job, responses []ffuf.Response) {
|
|||
lineCalib = ffuf.UniqStringSlice(lineCalib)
|
||||
|
||||
if len(sizeCalib) > 0 {
|
||||
AddFilter(j.Config, "size", strings.Join(sizeCalib, ","))
|
||||
err := AddFilter(j.Config, "size", strings.Join(sizeCalib, ","))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if len(wordCalib) > 0 {
|
||||
AddFilter(j.Config, "word", strings.Join(wordCalib, ","))
|
||||
err := AddFilter(j.Config, "word", strings.Join(wordCalib, ","))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if len(lineCalib) > 0 {
|
||||
AddFilter(j.Config, "line", strings.Join(lineCalib, ","))
|
||||
err := AddFilter(j.Config, "line", strings.Join(lineCalib, ","))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetupFilters(parseOpts *ffuf.ConfigOptions, conf *ffuf.Config) error {
|
||||
|
|
|
@ -19,7 +19,7 @@ func NewStatusFilter(value string) (ffuf.FilterProvider, error) {
|
|||
var intranges []ffuf.ValueRange
|
||||
for _, sv := range strings.Split(value, ",") {
|
||||
if sv == "all" {
|
||||
intranges = append(intranges, ffuf.ValueRange{AllStatuses, AllStatuses})
|
||||
intranges = append(intranges, ffuf.ValueRange{Min: AllStatuses, Max: AllStatuses})
|
||||
} else {
|
||||
vr, err := ffuf.ValueRangeFromString(sv)
|
||||
if err != nil {
|
||||
|
|
|
@ -188,7 +188,10 @@ func writeHTML(config *ffuf.Config, results []Result) error {
|
|||
|
||||
templateName := "output.html"
|
||||
t := template.New(templateName).Delims("{{", "}}")
|
||||
t.Parse(htmlTemplate)
|
||||
t.Execute(f, outHTML)
|
||||
return nil
|
||||
_, err = t.Parse(htmlTemplate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = t.Execute(f, outHTML)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -44,7 +44,10 @@ func writeMarkdown(config *ffuf.Config, res []Result) error {
|
|||
|
||||
templateName := "output.md"
|
||||
t := template.New(templateName).Delims("{{", "}}")
|
||||
t.Parse(markdownTemplate)
|
||||
t.Execute(f, outMD)
|
||||
return nil
|
||||
_, err = t.Parse(markdownTemplate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = t.Execute(f, outMD)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -50,8 +50,8 @@ func NewStdoutput(conf *ffuf.Config) *Stdoutput {
|
|||
return &outp
|
||||
}
|
||||
|
||||
func (s *Stdoutput) Banner() error {
|
||||
fmt.Fprintf(os.Stderr ,"%s\n v%s\n%s\n\n", BANNER_HEADER, ffuf.VERSION, BANNER_SEP)
|
||||
func (s *Stdoutput) Banner() {
|
||||
fmt.Fprintf(os.Stderr, "%s\n v%s\n%s\n\n", BANNER_HEADER, ffuf.VERSION, BANNER_SEP)
|
||||
printOption([]byte("Method"), []byte(s.config.Method))
|
||||
printOption([]byte("URL"), []byte(s.config.Url))
|
||||
|
||||
|
@ -141,7 +141,6 @@ func (s *Stdoutput) Banner() error {
|
|||
printOption([]byte("Filter"), []byte(f.Repr()))
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "%s\n\n", BANNER_SEP)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Stdoutput) Progress(status ffuf.Progress) {
|
||||
|
|
Loading…
Reference in a new issue