3563 Commits

Author SHA1 Message Date
Nathan Wallace
0d6cb1afad Fix #4713: Add nil check in initialiseSchemaAndTableSuggestions (#4879)
* Add test for #4713: initialiseSchemaAndTableSuggestions should handle nil client

* Fix #4713: Add nil check in initialiseSchemaAndTableSuggestions
2025-11-15 11:17:46 -05:00
Nathan Wallace
79ab1c9b69 Fix #4707: Add nil check in hideRootFlags (#4880)
* Add test for #4707: hideRootFlags should handle non-existent flags

* Fix #4707: Add nil check in hideRootFlags
2025-11-15 11:16:53 -05:00
Nathan Wallace
0b0b330a27 Fix #4717: Add nil check to Target.Export() (#4881)
* Add test for #4717: Target.Export() should handle nil exporter gracefully

* Fix #4717: Add nil check to Target.Export()
2025-11-15 11:16:16 -05:00
Nathan Wallace
8568ff50e1 Race condition on disableTiming field closes #4808 (rebased) (#4885)
* Add test for #4808: Race condition on disableTiming field

Add test that verifies disableTiming field uses atomic.Bool instead of
plain bool to prevent race conditions.

The test checks that:
- disableTiming is declared as atomic.Bool
- shouldFetchTiming() uses atomic Load()
- getQueryTiming() uses atomic Store() operations
- Direct assignments that cause races are not present

This test will fail until the implementation is fixed.

* Fix #4808: Use atomic.Bool for disableTiming to prevent race condition
2025-11-15 11:12:33 -05:00
Nathan Wallace
b1e9500c1b Fix #4812: Add size limits to autocomplete suggestions maps (rebased) (#4888)
* Add test for #4812: Autocomplete suggestions should have size limits

This test verifies that autocomplete suggestion maps enforce size limits
to prevent unbounded memory growth. The test calls setTablesForSchema()
and setQueriesForMod() methods that should enforce:
- Maximum 100 schemas in tablesBySchema
- Maximum 500 tables per schema
- Maximum 100 mods in queriesByMod
- Maximum 500 queries per mod

This test will fail until the size limiting implementation is added.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix #4812: Add size limits to autocomplete suggestions maps

Implements bounded size for autocomplete suggestion maps to prevent
unbounded memory growth with large schemas:

- Added constants for max schemas (100) and max tables per schema (500)
- Created setTablesForSchema() and setQueriesForMod() methods that enforce
  limits using LRU-style eviction when limits are exceeded
- Updated interactive_client_autocomplete.go to use the new bounded setter

This prevents excessive memory consumption when dealing with databases
that have hundreds of connections with many tables each.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-15 11:10:22 -05:00
Nathan Wallace
f799be5447 Handle single word and empty string in lastWord() closes #4787 (#4891)
* Add test for #4787: lastWord() panics on single word or empty string

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix #4787: Handle single word and empty string in lastWord()

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-15 11:10:06 -05:00
Nathan Wallace
11ce53cfc4 Race condition on disableTiming field closes #4808 (rebased) (#4890)
* Add test for #4808: Race condition on disableTiming field

Add test that verifies disableTiming field uses atomic.Bool instead of
plain bool to prevent race conditions.

The test checks that:
- disableTiming is declared as atomic.Bool
- shouldFetchTiming() uses atomic Load()
- getQueryTiming() uses atomic Store() operations
- Direct assignments that cause races are not present

This test will fail until the implementation is fixed.

* Fix #4808: Use atomic.Bool for disableTiming to prevent race condition
2025-11-15 11:05:25 -05:00
Nathan Wallace
1a1b380918 Concurrent read and close synchronization closes #4805 (#4874)
* Unskip test demonstrating bug #4805: Concurrent read and close may race

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix #4805: Add synchronization for concurrent StreamRow and Close

The sync.Once in Close() only prevents multiple Close() calls, but
doesn't coordinate with StreamRow() operations. Added a mutex and
closed flag to prevent race conditions when one goroutine streams
rows while another closes the result.

The fix:
- Added mutex (mu) and closed flag to Result struct
- StreamRow checks closed flag before streaming (with RLock)
- Close sets closed flag (with Lock) before closing channel

This prevents "send on closed channel" panics and data races.

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-15 10:51:37 -05:00
Nathan Wallace
6016a71053 Nil pointer dereference in logReceiveError closes #4798 (#4842)
* Unskip test demonstrating bug #4798: Nil pointer dereference in logReceiveError

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix #4798: Add nil check to logReceiveError

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-15 10:50:17 -05:00
Nathan Wallace
e278975448 RunBatchSession nil Client handling closes #4796 (#4839)
* Unskip test demonstrating bug #4796: RunBatchSession panics with nil Client

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix #4796: Add nil check for Client in RunBatchSession

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-15 10:49:31 -05:00
Nathan Wallace
22bfc9991f initialisationComplete flag synchronized closes #4803 (rebased) (#4886)
* Add test for #4803: Race condition in initialisationComplete flag

Add TestInitialisationComplete_RaceCondition to demonstrate the data race
that occurs when the initialisationComplete boolean flag is accessed
concurrently by multiple goroutines without synchronization.

The test simulates:
- Init goroutine writing to the flag
- Query executor reading via isInitialised()
- Notification handler reading the flag directly

This test will fail when run with the -race flag, exposing the bug.

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix #4803: Use atomic.Bool for initialisationComplete flag

Replace the plain boolean initialisationComplete field with atomic.Bool
to prevent data races when accessed concurrently by multiple goroutines.

Changes:
- Change field type from bool to atomic.Bool
- Use .Store(true) for writes
- Use .Load() for reads in isInitialised() and handleConnectionUpdateNotification()
- Update test to use atomic operations

The test now passes with -race flag, confirming the race condition is fixed.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-15 10:48:46 -05:00
Nathan Wallace
7a1533bd4f Race condition in rate limiter map access closes #4799 (#4843)
* Add test for #4799: Race condition in rate limiter map access

This test demonstrates the race condition in getUserDefinedLimitersForPlugin
where the userLimiters map is read without mutex protection while being
concurrently written by other goroutines.

Run with: go test -race -v -run TestPluginManager_ConcurrentRateLimiterMapAccess ./pkg/pluginmanager_service

* Fix #4799: Add mutex protection for rate limiter map access

Protected all accesses to m.userLimiters map with RWMutex:
- getUserDefinedLimitersForPlugin: Added RLock for map read
- getPluginsWithChangedLimiters: Added RLock for map iteration
- handleUserLimiterChanges: Added Lock for map write
- refreshRateLimiterTable: Added RLock for map iteration
- setRateLimiters: Added RLock for map read

This prevents data races when the map is concurrently read and written
by multiple goroutines.
2025-11-15 10:48:09 -05:00
Nathan Wallace
a4d90c3ac9 Fix logic error in IdentifyMissingComments closes #4814 (#4872)
* Add test for #4814: Logic error in IdentifyMissingComments

Demonstrates the bug where the function uses OR (||) instead of AND (&&)
on line 426, causing connections being deleted to be incorrectly added
to MissingComments.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix #4814: Change OR to AND in IdentifyMissingComments logic

Corrects the logic error on line 426 where OR (||) was incorrectly used
instead of AND (&&). The condition should be "if NOT updating AND NOT
deleting" to properly exclude connections being updated or deleted from
the MissingComments list.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-15 08:10:53 -05:00
Nathan Wallace
cb1fa48173 Fix flaky TestQueryContextLeakage test (#4887)
Changes:
1. Renamed TestQueryContextLeakage -> TestContextCancellationTiming
   - The test was checking cancellation timing, not memory leaks
   - Updated comments to reflect actual purpose

2. Increased timeout from 1ms to 100ms
   - 1ms is too aggressive for CI runners under load
   - 100ms still catches real deadlocks while avoiding flakiness
   - Added detailed comments explaining the timeout choice

3. Added TestNoGoroutineLeaks using goleak
   - Properly tests for actual resource leaks (goroutines)
   - More reliable than memory-based leak detection
   - Uses industry-standard goleak library

The original 1ms timeout caused intermittent CI failures on slower
runners, as context cancellation involves goroutine scheduling that
has no guaranteed sub-millisecond timing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-15 08:05:00 -05:00
Nathan Wallace
2e5f3fda97 Add comprehensive passing tests from bug hunting initiative (#4864) 2025-11-13 09:26:46 +08:00
Nathan Wallace
aaef09b670 Fix #4866: Increase snapshot row streaming timeout from 5s to 30s (#4867) 2025-11-13 09:14:46 +08:00
dependabot[bot]
4e84c29348 [dep][actions](deps): Bump golangci/golangci-lint-action (#4766) 2025-11-11 19:26:16 +08:00
Nathan Wallace
5c11d66574 Fix #4699: Add bounds check to isValidDatabaseName (#4733) 2025-11-11 19:25:44 +08:00
Nathan Wallace
5e1d316759 Fix #4710: Return empty slice instead of nil in getTableAndConnectionSuggestions (#4734) 2025-11-11 19:25:03 +08:00
Nathan Wallace
8baad08f41 Fix #4718: Use atomic write to prevent partial files (#4740) 2025-11-11 19:06:13 +08:00
Nathan Wallace
688e711419 Add AI development documentation and guidelines (#4777) 2025-11-11 19:03:27 +08:00
Nathan Wallace
a7cb5caa02 Fix #4715: Add mutex protection to export.Manager (#4738) 2025-11-11 18:54:52 +08:00
Nathan Wallace
7996d3c878 Fix #4712: Make Result.Close() idempotent (#4741) 2025-11-11 18:53:18 +08:00
Nathan Wallace
99fd81ccf6 Fix memory leak in DatabaseSession management (issue #3737) (#4742) 2025-11-11 18:35:16 +08:00
Nathan Wallace
6ebc0e5040 Fix #4744: Race condition on spinner.Suffix field (#4772) 2025-11-11 18:01:56 +08:00
Nathan Wallace
da0c9ddc0e Fix #4750: Nil pointer panic in RegisterExporters (#4769) 2025-11-11 17:58:06 +08:00
Nathan Wallace
28fb1d5237 Fix #4767: GetDbClient error handling (#4770) 2025-11-11 17:54:56 +08:00
Nathan Wallace
1472e96e74 Fix #4748: SQL injection vulnerability in GetSetConnectionStateSql (#4773) 2025-11-11 17:39:46 +08:00
Nathan Wallace
ca32de335c Fix #4757: Race condition in exemplarSchemaMap (#4774) 2025-11-11 17:31:58 +08:00
Nathan Wallace
aa696c9da3 Fix #4756: Race condition in Viper global state (#4775) 2025-11-11 17:29:59 +08:00
Nathan Wallace
13a24f840f Fix #4768: Goroutine leak in snapshot (#4776) 2025-11-11 17:26:33 +08:00
Nathan Wallace
4281ad3f10 Add comprehensive tests for pkg/{task,snapshot,cmdconfig,statushooks,introspection,initialisation,ociinstaller} (#4765) 2025-11-11 17:02:49 +08:00
Puskar Basu
d943ddd23a Merge branch 'v2.3.x' into develop (#4694) 2025-11-03 14:51:09 +05:30
Puskar Basu
d2642a6203 Release Steampipe v2.3.2 (#4695) 2025-11-03 14:50:16 +05:30
Puskar Basu
b41fbe31d9 v2.3.2 v2.3.2 2025-11-03 14:21:51 +05:30
Puskar Basu
603ae82e6e Fix glibc errors in linux builds (#4692) 2025-11-03 13:49:19 +05:30
Puskar Basu
248a1f4936 Merge branch 'v2.3.x' into develop 2025-10-31 17:19:23 +05:30
Puskar Basu
1b45380de9 Merge pull request #4690 from turbot/v2.3.x 2025-10-31 17:18:42 +05:30
Puskar Basu
119d7dd315 v2.3.1 v2.3.1 2025-10-31 16:36:45 +05:30
Puskar Basu
6367945009 Fix issue where macOS binaries failed to run due to absolute openssl paths and too-new min OS (#4687) 2025-10-31 16:20:33 +05:30
Puskar Basu
c69748b6be Merge branch 'v2.3.x' into develop 2025-10-30 15:43:20 +05:30
Puskar Basu
9c8b4438f3 Merge pull request #4678 from turbot/v2.3.x
Release Steampipe v2.3.0
2025-10-30 15:42:07 +05:30
Puskar Basu
bc1003bebf v2.3.0 v2.3.0 2025-10-30 15:01:16 +05:30
Puskar Basu
9aac94322c Improve table truncation message for datasets exceeding 10k rows, show the same message in batch queries as well (#4675) 2025-10-30 13:47:07 +05:30
dependabot[bot]
d7289b85fd [dep][go](deps): Bump github.com/jackc/pgx/v5 from 5.7.3 to 5.7.6 (#4660) 2025-10-30 11:55:15 +05:30
dependabot[bot]
4fad14407b [dep][go](deps): Bump github.com/hashicorp/go-plugin from 1.6.3 to 1.7.0 (#4662) 2025-10-30 11:54:53 +05:30
dependabot[bot]
df135bf1f9 [dep][go](deps): Bump github.com/spf13/cobra from 1.9.1 to 1.10.1 (#4659) 2025-10-30 11:42:43 +05:30
dependabot[bot]
4b51cd8efc [dep][actions](deps): Bump actions/setup-go from 5.5.0 to 6.0.0 (#4663) 2025-10-30 11:41:43 +05:30
dependabot[bot]
b04eaa8e43 [dep][actions](deps): Bump actions/cache from 4.2.4 to 4.3.0 (#4664) 2025-10-30 11:41:22 +05:30
dependabot[bot]
f397a47a24 [dep][actions](deps): Bump actions/checkout from 4.2.2 to 5.0.0 (#4666) 2025-10-30 11:41:02 +05:30