Skip to content

Feature/auscope#463

Merged
pnemere merged 151 commits intodevelopmentfrom
feature/auscope
Mar 30, 2026
Merged

Feature/auscope#463
pnemere merged 151 commits intodevelopmentfrom
feature/auscope

Conversation

@pnemere
Copy link
Copy Markdown
Contributor

@pnemere pnemere commented Mar 30, 2026

No description provided.

Antimatter543 and others added 30 commits October 28, 2025 16:20
…nts to run as part of test. Also ignore some local files
…terising some expected ids that were hard coded into the tests. Also added some docs and seed data for running test
…IFF files and also the Z-stack OME tiff file format. CLI commands tiffinfo are helpful to walk through the tiff file structures
…ge (jpeg) tiff, z-stacked tiffs with pyramids etc. Works :)
  Implemented tile-based image serving for pyramidal TIFFs to enable
  efficient pan/zoom of large scientific images in the frontend.

  Changes:
  - Add PyramidTileSimple endpoint for local development/testing
    - GET /pyramid-tiles/{scan}/{filename}/{page}/{level}/{x}/{y} - serves individual tiles
    - GET /pyramid-info/{scan}/{filename} - returns ImagePyramid metadata proto
  - Register routes in main.go with public permissions
…om a given tiff image, and stores it in a local location
@pnemere pnemere merged commit 617283b into development Mar 30, 2026
9 checks passed
}

locSave := &protos.ScanEntry{
Id: int32(pmc),

Check failure

Code scanning / CodeQL

Incorrect conversion between integer types High

Incorrect conversion of an integer with architecture-dependent bit size from
strconv.Atoi
to a lower bit size type int32 without an upper bound check.

Copilot Autofix

AI 3 days ago

In general, you fix this class of issue by either:

  • parsing directly into the target bit size using strconv.ParseInt/ParseUint with the correct bitSize, or
  • keeping Atoi but adding explicit upper and lower bound checks before converting to a narrower integer type.

Here, the safest fix without changing behavior is to parse loc.Id as an int64 with a bit size of 32 and then convert to int32. That guarantees the parsed value is within int32 range or yields an error. Concretely, in core/scan/read-entries.go:

  • Replace pmc, err := strconv.Atoi(loc.Id) with pmc64, err := strconv.ParseInt(loc.Id, 10, 32).
  • On success, convert with int32(pmc64) when populating ScanEntry.Id.

The existing error handling already turns any parse error into a returned error, so behavior remains consistent: invalid or out-of-range values will now also produce an error (instead of silent truncation). No new imports are needed because strconv is already imported. The only code changes are renaming the local variable and switching to ParseInt with an appropriate bit size, plus adjusting the type of locSave.Id.

Suggested changeset 1
core/scan/read-entries.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/core/scan/read-entries.go b/core/scan/read-entries.go
--- a/core/scan/read-entries.go
+++ b/core/scan/read-entries.go
@@ -26,7 +26,7 @@
 	for _, c := range indexes {
 		loc := exprPB.Locations[c]
 
-		pmc, err := strconv.Atoi(loc.Id)
+		pmc64, err := strconv.ParseInt(loc.Id, 10, 32)
 		if err != nil {
 			return nil, fmt.Errorf("Failed to convert PMC %v to int while reading scan location %v", loc.Id, c)
 		}
@@ -40,7 +40,7 @@
 		}
 
 		locSave := &protos.ScanEntry{
-			Id:        int32(pmc),
+			Id:        int32(pmc64),
 			Timestamp: timestamp,
 		}
 
EOF
@@ -26,7 +26,7 @@
for _, c := range indexes {
loc := exprPB.Locations[c]

pmc, err := strconv.Atoi(loc.Id)
pmc64, err := strconv.ParseInt(loc.Id, 10, 32)
if err != nil {
return nil, fmt.Errorf("Failed to convert PMC %v to int while reading scan location %v", loc.Id, c)
}
@@ -40,7 +40,7 @@
}

locSave := &protos.ScanEntry{
Id: int32(pmc),
Id: int32(pmc64),
Timestamp: timestamp,
}

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

3 participants