feat(index): update index with latest GUFI support #295
feat(index): update index with latest GUFI support #295sundereshwar wants to merge 4 commits intomainfrom
Conversation
d4cac5c to
5d0f568
Compare
| return "", fmt.Errorf("invalid day expression %q: %w", expr, err) | ||
| } | ||
|
|
||
| ts := time.Now().AddDate(0, 0, -int(n)).Unix() |
Check failure
Code scanning / CodeQL
Incorrect conversion between integer types High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 22 days ago
In general, to fix this kind of problem you must avoid converting a wider integer type to a narrower one without ensuring the value lies within the target type’s range. For parsed input, that means either: (1) parsing with a bit size that matches the eventual type (so no narrowing occurs), or (2) checking upper and lower bounds before casting.
Here, the problematic code is in parseDayClause at line 347: time.Now().AddDate(0, 0, -int(n)). The API time.Time.AddDate(years, months, days int) requires int parameters, so we cannot avoid an int value. The safest, most localized fix is to validate that n is within the int range before casting. Because Go’s int width is platform‑dependent and we must not assume 32‑ vs 64‑bit, we can derive the bounds using strconv.IntSize from the already‑imported strconv package, avoiding adding new imports. We:
- Compute
maxInt := int64(1<<(strconv.IntSize-1) - 1)andminInt := -maxInt - 1. - Check that
nis within[minInt, maxInt]; if it is not, return an error indicating the day expression is out of range. - Only then perform
int(n).
This preserves existing behavior for all previously valid inputs, but rejects extreme values that would overflow on the current platform, removing the incorrect narrowing conversion.
| @@ -344,7 +344,14 @@ | ||
| return "", fmt.Errorf("invalid day expression %q: %w", expr, err) | ||
| } | ||
|
|
||
| ts := time.Now().AddDate(0, 0, -int(n)).Unix() | ||
| maxInt := int64(1<<(strconv.IntSize-1) - 1) | ||
| minInt := -maxInt - 1 | ||
| if n < minInt || n > maxInt { | ||
| return "", fmt.Errorf("invalid day expression %q: value out of range", expr) | ||
| } | ||
|
|
||
| dayOffset := int(n) | ||
| ts := time.Now().AddDate(0, 0, -dayOffset).Unix() | ||
| return fmt.Sprintf("%s %s %d", col, op, ts), nil | ||
| } | ||
|
|
- added Migrate Command. - treesummary is not optional for `create` and `rescan`. - added treesummary for `info` - removed references for GUFI Config. - commands would always check for Index Root. - refactored code to suit the trailing slash changes
| log.Warn("skipping unparseable inode", zap.String("inode", inodeStr), zap.Error(err)) | ||
| continue | ||
| } | ||
| signed := int64(unsigned) // exact two's complement, matches C plugin behavior |
Check failure
Code scanning / CodeQL
Incorrect conversion between integer types High
Copilot Autofix
AI 10 days ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
What does this PR do / why do we need it?
Required for all PRs.
Related Issue(s)
Required when applicable.
Where should the reviewer(s) start reviewing this?
Only required for larger PRs when this may not be immediately obvious.
Are there any specific topics we should discuss before merging?
Not required.
What are the next steps after this PR?
Not required.
Checklist before merging:
Required for all PRs.
When creating a PR these are items to keep in mind that cannot be checked by GitHub actions:
For more details refer to the Go coding standards and the pull request process.