Skip to content

feat(index): update index with latest GUFI support #295

Draft
sundereshwar wants to merge 4 commits intomainfrom
sunder/feature/index-gufi-sync
Draft

feat(index): update index with latest GUFI support #295
sundereshwar wants to merge 4 commits intomainfrom
sunder/feature/index-gufi-sync

Conversation

@sundereshwar
Copy link
Copy Markdown
Contributor

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:

  • Documentation:
    • Does developer documentation (code comments, readme, etc.) need to be added or updated?
    • Does the user documentation need to be expanded or updated for this change?
  • Testing:
    • Does this functionality require changing or adding new unit tests?
    • Does this functionality require changing or adding new integration tests?
  • Git Hygiene:

For more details refer to the Go coding standards and the pull request process.

@sundereshwar sundereshwar self-assigned this Feb 10, 2026
@iamjoemccormick iamjoemccormick linked an issue Feb 10, 2026 that may be closed by this pull request
@sundereshwar sundereshwar force-pushed the sunder/feature/index-gufi-sync branch from d4cac5c to 5d0f568 Compare March 26, 2026 12:41
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

Incorrect conversion of a signed 64-bit integer from
strconv.ParseInt
to a lower bit size type int without an upper bound check.

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:

  1. Compute maxInt := int64(1<<(strconv.IntSize-1) - 1) and minInt := -maxInt - 1.
  2. Check that n is within [minInt, maxInt]; if it is not, return an error indicating the day expression is out of range.
  3. 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.

Suggested changeset 1
ctl/pkg/ctl/index/predicates.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/ctl/pkg/ctl/index/predicates.go b/ctl/pkg/ctl/index/predicates.go
--- a/ctl/pkg/ctl/index/predicates.go
+++ b/ctl/pkg/ctl/index/predicates.go
@@ -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
 }
 
EOF
@@ -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
}

Copilot is powered by AI and may make mistakes. Always verify output.
- 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

Incorrect conversion of an unsigned 64-bit integer from
strconv.ParseUint
to a lower bit size type int64 without an upper bound check.

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.

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.

Integrate Hive index CLI with latest GUFI and plugin support

2 participants