Skip to content

Fix bugs, improve error handling, and expand test coverage - #29

Merged
mostafa merged 3 commits into
mainfrom
improvements
Feb 21, 2026
Merged

mostafa merged 3 commits into
mainfrom
improvements

Conversation

@mostafa

@mostafa mostafa commented Feb 21, 2026 •

Copy link
Copy Markdown
Member

Ticket(s)

Description

This PR fixes several bugs, improves error handling, and expands test coverage for the SQL IDS/IPS plugin.

Bug fixes

  • Fix prepareResponse using hardcoded constants: ErrorNumber and ErrorDetail were package-level constants instead of p.ErrorNumber / p.ErrorDetail, so user-configured values from the config were silently ignored.
  • Fix release workflow name: Copy-paste error from gatewayd-plugin-cache corrected.
  • Fix test function name typos: Test_OnTrafficFromClinet → Test_OnTrafficFromClient.

Improvements

  • Add HTTP timeout for prediction API calls: Propagate context with a configurable timeout (default 10s) instead of context.Background(), preventing the plugin from blocking indefinitely if DeepSQLi is slow or unresponsive.
  • Handle encode errors in prepareResponse: Errors from EmptyQueryResponse.Encode() and ReadyForQuery.Encode() are now logged instead of silently discarded.
  • Update CI action versions: actions/checkout v3→v4, actions/setup-go v3→v5, softprops/action-gh-release v1→v2.

New tests

  • Test_emptyResponse — exercises the ResponseType == "empty" branch
  • Test_GetPluginConfig — covers config retrieval
  • Test_OnTrafficFromClientBelowThreshold — verifies no-detection path for legitimate queries
  • Test_OnTrafficFromClientEmptyQuery — verifies empty request handling

Related PRs

Development Checklist

  • I have added a descriptive title to this PR.
  • I have performed a self-review of my own code.
  • I have added tests for my changes.

Legal Checklist

  • I have read and agreed to the LICENSE (required).

- Use p.ErrorNumber and p.ErrorDetail instead of hardcoded package
  constants in prepareResponse, so user-configured values take effect
- Propagate context with a configurable timeout (default 10s) to the
  prediction API HTTP call instead of using context.Background()
- Handle encode errors from EmptyQueryResponse and ReadyForQuery
  instead of silently discarding them
- Fix "Clinet" -> "Client" typos in test function names
- Add Test_emptyResponse for the "empty" response type branch
- Add Test_GetPluginConfig for the config retrieval method
- Add Test_OnTrafficFromClientBelowThreshold for the no-detection path
- Add Test_OnTrafficFromClientEmptyQuery for empty request handling
- Remove duplicate Test_OnTrafficFromClientFailedPrediction
- Fix copy-paste error: "gatewayd-plugin-cache" -> "gatewayd-plugin-sql-ids-ips"
- Update actions/checkout from v3 to v4
- Update actions/setup-go from v3 to v5
- Update softprops/action-gh-release from v1 to v2
@mostafa mostafa self-assigned this Feb 21, 2026
@mostafa mostafa changed the title Improvements Fix bugs, improve error handling, and expand test coverage Feb 21, 2026
@mostafa
mostafa merged commit 7d68c5f into main Feb 21, 2026
1 check passed
@mostafa
mostafa deleted the improvements branch February 21, 2026 23:02
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.

1 participant