7 Commits

Author SHA1 Message Date
oittaa
0cc9e01a9d Refine G407 to improve detection and coverage of hardcoded nonces (#1460)
* Refine G407 to improve detection and coverage of hardcoded nonces

* chore: consolidate common analyzer patterns into util.go and improve G602 coverage

* Optimize G602 and G115 with state caching and regex pre-compilation

* Improve G115 overflow detection and fix false positives and false negatives

* golangci-lint workaround
2026-01-12 09:56:55 +01:00
oittaa
52f5dbf4d4 feat(slice): enhance slice bounds analysis with dynamic bounds handling (#1457)
* feat(slice): enhance slice bounds analysis with dynamic bounds handling

* feat(slice): enhance extractLenBound to support additional offset patterns and improve slice bounds analysis

* golangci-lint run

* Improve G602 slice bounds detection: support 3-index slices and correct capacity tracking

* Support out-of-bounds detection for range loops with offsets
2026-01-09 13:52:05 +01:00
Cosmin Cojocar
c073629009 Improve slice bound check (#1442)
Improve slice bound check to habdle bounded values and properly parse
the address index only from references

Signed-off-by: Cosmin Cojocar <cosmin@cojocar.ch>
2025-12-28 19:39:40 +02:00
kondratev
01029f0a74 check nil slices, partially check bounds (#1396)
* check nil slices, partially check bounds

* add tests, cleanup, add fixed array

* cleanup

* lint

* looks like go bug, add second check

* ohh

* check instruction position

---------

Co-authored-by: Kondratev Pavel <kondratev_pa@magnit.ru>
2025-10-03 10:41:33 +02:00
William Bergeron-Drouin
ea5b2766bb fix: G602 support for nested conditionals with bounds check (#1201)
* Recursive fix

* Add some more test cases

* Fix formatting

* Add depth check
2024-09-04 11:07:42 +02:00
Cosmin Cojocar
2aad3f02a5 Fix lint warnings by properly formatting the files
Signed-off-by: Cosmin Cojocar <gcojocar@adobe.com>
2023-12-08 14:46:36 +01:00
Adam Kaplan
0e2a61899a chore: Refactor Sample Code to Separate Files
Split the code in `source.go` to individual sample files, one per rule.
This will help contributors submit samples for new rules, or
improvements to existing rules. The cgo sample was all that was left
after refactoring, which resulted in its own sample file.

Sample code was also formatted to have some level of consistency.
Each sample go "file" attempts to keep the formatting of `gofmt`, and
each code sample is in its own section in the sample file.

Signed-off-by: Adam Kaplan <adam@adambkaplan.com>
2023-12-08 14:46:36 +01:00