Skip to content

Replace API_ID and API_HASH with hardcoded values - #70

Open
harshsinghrajawat369-cell wants to merge 1 commit into
AsmSafone:masterfrom
harshsinghrajawat369-cell:patch-4
Open

harshsinghrajawat369-cell wants to merge 1 commit into
AsmSafone:masterfrom
harshsinghrajawat369-cell:patch-4

Conversation

@harshsinghrajawat369-cell

@harshsinghrajawat369-cell harshsinghrajawat369-cell commented Sep 2, 2026

Copy link
Copy Markdown

Updated API credentials in the Config class.

Summary by Sourcery

Embed the application’s API and bot credentials directly in the configuration.

Enhancements:

  • Update the Config class to use embedded API credentials, session data, and bot token instead of reading those values from environment variables.

Chores:

  • Remove environment-based configuration for the API credentials, session, and bot token.

Updated API credentials in the Config class.
@sourcery-ai

sourcery-ai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The 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

Change Details Files
Replaces environment-variable lookups with hardcoded credential strings passed as lookup keys, changing how API and session credentials are sourced.
  • Substitutes the API ID and API hash environment-variable names with literal values.
  • Substitutes the session and bot-token environment-variable names with literal credential values.
  • Leaves the fallback value as None, so these assignments do not directly assign the literals unless identically named environment variables exist.
config.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread config.py
Comment on lines +28 to +31
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread config.py
Comment on lines +28 to +31
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚨 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.

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.

1 participant