Skip to content

Conversation

@ArneTR
Copy link
Member

@ArneTR ArneTR commented Nov 20, 2025

Greptile Overview

Greptile Summary

Moved CarbonDB and PowerHOG features from enterprise (ee/) to open source, making them publicly available through new API routes and frontend interfaces.

Major changes:

  • Added 8 new public API routes for CarbonDB and PowerHOG data collection and retrieval
  • Created database schema with 10 new tables for storing energy/carbon metrics and process measurements
  • Implemented geo-IP lookup and carbon intensity calculation via ElectricityMaps API
  • Added frontend dashboards for visualizing carbon and energy data
  • Updated test configuration to enable features by default instead of requiring enterprise flag

Critical issues found:

  • SQL injection vulnerability in api/carbondb.py:187 where table column names are interpolated directly into queries
  • Missing input validation across multiple filter parameters in /v2/carbondb endpoint - comma-separated values aren't validated as integers before database casting
  • Error handling issue in carbondb_add() where negative carbon intensity values (-1 error codes) propagate into calculations, resulting in negative carbon measurements

Other concerns:

  • Hardcoded Berlin coordinates for private IPs may produce misleading production data
  • Frontend uses proper XSS escaping with escapeString() function

* main:
  (feat): Added internal self tests for test data validity
  Removing confusing info that message was transported via email
  Update cron schedule and randomize URL input in GitHub Action for testing webNRG
@ArneTR
Copy link
Member Author

ArneTR commented Nov 20, 2025

@greptileai

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

28 files reviewed, 12 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +1014 to +1018
carbon_intensity_g_per_kWh = get_carbon_intensity(latitude, longitude) # cached

energy_J = float(data['energy_uj']) / 1e6
energy_kWh = energy_J / (3_600*1_000)
carbon_kg = (energy_kWh * carbon_intensity_g_per_kWh)/1_000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: get_carbon_intensity() returns -1 on error but this negative value is used directly in carbon calculation without validation, resulting in negative carbon_kg

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