Replace API_ID and API_HASH with hardcoded values - #70
harshsinghrajawat369-cell wants to merge 1 commit into
Conversation
Updated API credentials in the Config class.
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe Config class changes credential configuration from named environment variables to embedded sensitive values used as os.environ lookup keys; this both exposes credentials in source control and likely causes the fields to become None unless matching environment variables are defined. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="config.py" line_range="28-31" />
<code_context>
- self.API_HASH: str = os.environ.get("API_HASH", None)
- self.SESSION: str = os.environ.get("SESSION", None)
- self.BOT_TOKEN: str = os.environ.get("BOT_TOKEN", None)
+ self.API_ID: str = os.environ.get("38074255", None)
+ self.API_HASH: str = os.environ.get("b24d8bf27bba4316a37c4bf2a7e9b9cf", None)
+ self.SESSION: str = os.environ.get("BQJE948AxjlJfRIp_e9772JU6rn0Dbg5hSr1eqFuZvgG7RG1iHKeZjt1-8k72XDALn_5r4Jx0QXfZROL0ZxwFbi39DNlTQvU0t0dJIvs-SwJTyQmBEixyN2aGDlprrrRpRjdO4IFqPKgf30wj4tgMdWwlfg-6rmhKtQ5dojRcAhdqWXioibbYkB2ox43CfVNwXuK77b02H_LE22GDj5IV6xDVqbNsxcSR6OBXsrhJY11HdJrV5AkAxgbelkB5sWG_6GuiWaK0XD3WAIBoOop8f3vcn3opvO2QqytOTbHWnyuAkDwW3gbTLYfQEXXMZuRIEYyjmw-I0dCjppxB2vB3cjq9361xAAAAAHwf61bAA", None)
+ self.BOT_TOKEN: str = os.environ.get("8712882922:AAEpzHdNSgsP60idD50_WcvCcrwzaQzBD2g", None)
self.SUDOERS: list = [
int(id) for id in os.environ.get("SUDOERS", " ").split() if id.isnumeric()
</code_context>
<issue_to_address>
**issue (bug_risk):** `os.environ.get` treats each hardcoded credential as an environment-variable name, so `API_ID`, `API_HASH`, `SESSION`, and `BOT_TOKEN` all resolve to `None` unless variables with those credential strings as names exist. `Config.__init__` then exits at the required-credentials check, preventing the application from starting.
**Suggested fix:** Assign the intended literals directly (converting `API_ID` to an integer if required by the client), or keep `os.environ.get` keyed by `API_ID`, `API_HASH`, `SESSION`, and `BOT_TOKEN`.
</issue_to_address>
### Comment 2
<location path="config.py" line_range="28-31" />
<code_context>
- self.API_HASH: str = os.environ.get("API_HASH", None)
- self.SESSION: str = os.environ.get("SESSION", None)
- self.BOT_TOKEN: str = os.environ.get("BOT_TOKEN", None)
+ self.API_ID: str = os.environ.get("38074255", None)
+ self.API_HASH: str = os.environ.get("b24d8bf27bba4316a37c4bf2a7e9b9cf", None)
+ self.SESSION: str = os.environ.get("BQJE948AxjlJfRIp_e9772JU6rn0Dbg5hSr1eqFuZvgG7RG1iHKeZjt1-8k72XDALn_5r4Jx0QXfZROL0ZxwFbi39DNlTQvU0t0dJIvs-SwJTyQmBEixyN2aGDlprrrRpRjdO4IFqPKgf30wj4tgMdWwlfg-6rmhKtQ5dojRcAhdqWXioibbYkB2ox43CfVNwXuK77b02H_LE22GDj5IV6xDVqbNsxcSR6OBXsrhJY11HdJrV5AkAxgbelkB5sWG_6GuiWaK0XD3WAIBoOop8f3vcn3opvO2QqytOTbHWnyuAkDwW3gbTLYfQEXXMZuRIEYyjmw-I0dCjppxB2vB3cjq9361xAAAAAHwf61bAA", None)
+ self.BOT_TOKEN: str = os.environ.get("8712882922:AAEpzHdNSgsP60idD50_WcvCcrwzaQzBD2g", None)
self.SUDOERS: list = [
int(id) for id in os.environ.get("SUDOERS", " ").split() if id.isnumeric()
</code_context>
<issue_to_address>
**🚨 issue (security):** The diff embeds a Telegram API hash, session string, and bot token directly in the repository, exposing credentials to anyone with access to the source and allowing unauthorized use of the bot/session.
**Suggested fix:** Revoke and rotate all exposed credentials, remove them from the source and repository history, and load them from a secure environment variable or secret manager.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 2 findings to address first, and the diff exposes a bot token, session credential, and API credentials in source control, allowing unauthorized access until those credentials are revoked or rotated; reverting does not remove copies already obtained. It also likely makes the application read missing environment variables and fail at runtime, which would be fixed by reverting.
Blocking findings: config.py:31, config.py:31
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| self.API_ID: str = os.environ.get("38074255", None) | ||
| self.API_HASH: str = os.environ.get("b24d8bf27bba4316a37c4bf2a7e9b9cf", None) | ||
| self.SESSION: str = os.environ.get("BQJE948AxjlJfRIp_e9772JU6rn0Dbg5hSr1eqFuZvgG7RG1iHKeZjt1-8k72XDALn_5r4Jx0QXfZROL0ZxwFbi39DNlTQvU0t0dJIvs-SwJTyQmBEixyN2aGDlprrrRpRjdO4IFqPKgf30wj4tgMdWwlfg-6rmhKtQ5dojRcAhdqWXioibbYkB2ox43CfVNwXuK77b02H_LE22GDj5IV6xDVqbNsxcSR6OBXsrhJY11HdJrV5AkAxgbelkB5sWG_6GuiWaK0XD3WAIBoOop8f3vcn3opvO2QqytOTbHWnyuAkDwW3gbTLYfQEXXMZuRIEYyjmw-I0dCjppxB2vB3cjq9361xAAAAAHwf61bAA", None) | ||
| self.BOT_TOKEN: str = os.environ.get("8712882922:AAEpzHdNSgsP60idD50_WcvCcrwzaQzBD2g", None) |
There was a problem hiding this comment.
issue (bug_risk): os.environ.get treats each hardcoded credential as an environment-variable name, so API_ID, API_HASH, SESSION, and BOT_TOKEN all resolve to None unless variables with those credential strings as names exist. Config.__init__ then exits at the required-credentials check, preventing the application from starting.
Suggested fix: Assign the intended literals directly (converting API_ID to an integer if required by the client), or keep os.environ.get keyed by API_ID, API_HASH, SESSION, and BOT_TOKEN.
| self.API_ID: str = os.environ.get("38074255", None) | ||
| self.API_HASH: str = os.environ.get("b24d8bf27bba4316a37c4bf2a7e9b9cf", None) | ||
| self.SESSION: str = os.environ.get("BQJE948AxjlJfRIp_e9772JU6rn0Dbg5hSr1eqFuZvgG7RG1iHKeZjt1-8k72XDALn_5r4Jx0QXfZROL0ZxwFbi39DNlTQvU0t0dJIvs-SwJTyQmBEixyN2aGDlprrrRpRjdO4IFqPKgf30wj4tgMdWwlfg-6rmhKtQ5dojRcAhdqWXioibbYkB2ox43CfVNwXuK77b02H_LE22GDj5IV6xDVqbNsxcSR6OBXsrhJY11HdJrV5AkAxgbelkB5sWG_6GuiWaK0XD3WAIBoOop8f3vcn3opvO2QqytOTbHWnyuAkDwW3gbTLYfQEXXMZuRIEYyjmw-I0dCjppxB2vB3cjq9361xAAAAAHwf61bAA", None) | ||
| self.BOT_TOKEN: str = os.environ.get("8712882922:AAEpzHdNSgsP60idD50_WcvCcrwzaQzBD2g", None) |
There was a problem hiding this comment.
🚨 issue (security): The diff embeds a Telegram API hash, session string, and bot token directly in the repository, exposing credentials to anyone with access to the source and allowing unauthorized use of the bot/session.
Suggested fix: Revoke and rotate all exposed credentials, remove them from the source and repository history, and load them from a secure environment variable or secret manager.
Updated API credentials in the Config class.
Summary by Sourcery
Embed the application’s API and bot credentials directly in the configuration.
Enhancements:
Chores: