teler-sh / teler-waf

teler-waf is a Go HTTP middleware that protects local web services from OWASP Top 10 threats, known vulnerabilities, malicious actors, botnets, unwanted crawlers, and brute force attacks.
https://test.teler.sh
Apache License 2.0
344 stars 32 forks source link

refactor: `checkDirectoryBruteforce` implementation #78

Closed dwisiswant0 closed 1 year ago

dwisiswant0 commented 1 year ago

IMPORTANT: Please do not create a PR without creating an issue first!

(Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of the pull request).

Summary

In this commit, the checkDirectoryBruteforce function has been refactored for improved efficiency and clarity. The previous logic involving file extension extraction and replacement has been streamlined. The regex pattern is created using the modified path directly. The regexp.MatchString call has been adjusted to directly match the pattern against the directory bruteforce data stored in the threat data structure. This modification improves functionality, ensures maintainability, and accommodates dataset alterations as indicated in the following source:

Proposed of changes

This PR fixes/implements the following bugs/features:

How has this been tested?

Proof:

Closing issues

Fixes #

Checklist:

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.16% :tada:

Comparison is base (8b45daf) 80.83% compared to head (3887b49) 81.00%. Report is 2 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #78 +/- ## ========================================== + Coverage 80.83% 81.00% +0.16% ========================================== Files 5 5 Lines 1002 995 -7 ========================================== - Hits 810 806 -4 + Misses 144 142 -2 + Partials 48 47 -1 ``` | [Files Changed](https://app.codecov.io/gh/kitabisa/teler-waf/pull/78?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kitabisa) | Coverage Δ | | |---|---|---| | [analyze.go](https://app.codecov.io/gh/kitabisa/teler-waf/pull/78?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kitabisa#diff-YW5hbHl6ZS5nbw==) | `77.20% <100.00%> (+0.41%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.