Skip to content

Use null-safe string comparison to prevent NullPointerException in Sq… - #2302

Merged
zubcevic merged 3 commits into
WebGoat:mainfrom
Kaustub593S:fix-null-safe-comparison
May 29, 2026
Merged

zubcevic merged 3 commits into
WebGoat:mainfrom
Kaustub593S:fix-null-safe-comparison

Conversation

@Kaustub593S

Copy link
Copy Markdown
Contributor

SqlInjectionLesson2

Replaced direct string comparison with a null-safe comparison.

Changed:
results.getString("department").equals("Marketing")

to:
"Marketing".equals(results.getString("department"))

This prevents a potential NullPointerException and follows common Java best practices of

"constant".equals(variable)

@Kaustub593S
Kaustub593S marked this pull request as draft May 15, 2026 09:32
@Kaustub593S
Kaustub593S marked this pull request as ready for review May 15, 2026 09:32
@Kaustub593S
Kaustub593S marked this pull request as draft May 15, 2026 09:32
@Kaustub593S
Kaustub593S marked this pull request as ready for review May 15, 2026 09:32
@zubcevic

Copy link
Copy Markdown
Collaborator

Thanks for your contribution to make WebGoat better

@zubcevic
zubcevic merged commit c624868 into WebGoat:main May 29, 2026
4 checks passed
@Kaustub593S
Kaustub593S deleted the fix-null-safe-comparison branch May 31, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants