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

fix: nil pointer dereference in checkBadReferrer method #61

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

This commit fixes a bug in the checkBadReferrer method where a nil pointer dereference occurred. The code was checking if an error occurred and returning it without handling the case when the error is nil. This caused a panic at runtime when trying to access a nil pointer. The fix removes the error logging statement and returns early when the error is nil, preventing the panic from happening.

Proposed of changes

This PR fixes/implements the following bugs/features:

How has this been tested?

Proof:

Closing issues

Fixes #60

Checklist:

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage has no change and project coverage change: +0.07 :tada:

Comparison is base (3bc6527) 71.70% compared to head (60b537b) 71.78%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #61 +/- ## ========================================== + Coverage 71.70% 71.78% +0.07% ========================================== Files 5 5 Lines 965 964 -1 ========================================== Hits 692 692 + Misses 228 227 -1 Partials 45 45 ``` | [Impacted Files](https://app.codecov.io/gh/kitabisa/teler-waf/pull/61?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/61?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kitabisa#diff-YW5hbHl6ZS5nbw==) | `70.53% <ø> (+0.20%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.