Skip to content

Conversation

@marle3003
Copy link
Owner

Potential fix for https://github.com/marle3003/mokapi/security/code-scanning/53

To fix the identified issue, we must ensure that when handling the Avro "int" type and converting from float64/other sources to Go int, the value fits within both the Avro 32-bit signed integer range (math.MinInt32 to math.MaxInt32) and the Go int range (though targeting the Avro spec is more important). This is best achieved by adding an explicit range check before the conversion and returning an error if the value is out of bounds. The check should be applied to all code paths where a value is converted to int as part of parsing Avro "int" types.

Required adjustments:

  • Only edit within the shown file schema/avro/schema/parser_json.go, specifically inside the parseType function for "int" type when handling float64.
  • Add a bound check before converting val to int, using math.MinInt32 and math.MaxInt32.
  • Return an appropriate error if the value is not within bounds.
  • No extra imports are needed, as math is already imported.
  • The fix should not affect other parsing logic or types.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…tween integer types

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@codecov
Copy link

codecov bot commented Dec 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.84%. Comparing base (6c1a191) to head (5bee462).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #781      +/-   ##
==========================================
- Coverage   70.84%   70.84%   -0.01%     
==========================================
  Files         457      457              
  Lines       41293    41296       +3     
==========================================
+ Hits        29255    29257       +2     
  Misses       9873     9873              
- Partials     2165     2166       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@marle3003 marle3003 marked this pull request as ready for review December 14, 2025 14:41
@marle3003 marle3003 merged commit 0bd50c0 into main Dec 14, 2025
11 checks passed
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.

2 participants