Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-768: Plugin to detect Telegram bot tokens #808

Merged
merged 1 commit into from
Apr 30, 2024

Conversation

Chandra158
Copy link
Contributor

@Chandra158 Chandra158 commented Apr 29, 2024

Please check if the PR fulfills these requirements

  • Tests for the changes have been added
  • Docs have been added / updated
  • All CI checks are green

What kind of change does this PR introduce?

Tests

  • New test added for plugin
  • Tested manually in local with newly created token
{
        "type": "Telegram Bot Token",
        "filename": "test_data/test-bot.yaml",
        "hashed_secret": "c429079ee6a839ece2e7b0a6770198d8fe5ed438",
        "is_verified": true,
        "line_number": 11
},

re.compile(r'\d{8,10}:[0-9A-Za-z_-]{35}'),
]

def verify(self, secret: str) -> VerifiedResult: # pragma: no cover
Copy link
Member

@lorenzodb1 lorenzodb1 Apr 29, 2024

Choose a reason for hiding this comment

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

Looking at other RegexBasedDetector, it doesn't look like you need a verify method like you would in a BasePlugin (see github_token.py for reference).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

plugins.md#verified-secrets

provides the ability to decrease false positives by making an API call to a server to check whether a PotentialSecret is indeed real. This can be extremely useful for specific secrets (e.g. RegexBasedDetector subclasses) since we are able to determine which server to contact.

verify method is optional but really good in decreasing False-positives. Others RegexBasedDetector plugins also has this method implemented where there is a way to verify whether the token is still active. (stripe.py, slack.py)

In my test in local:

  • without verify: will report if any string matches the plugin regex ("is_verified": false)
  • with verify: will only report if the token is still active ("is_verified": true)

Copy link
Member

@lorenzodb1 lorenzodb1 left a comment

Choose a reason for hiding this comment

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

Is this the same as #769?

@Chandra158
Copy link
Contributor Author

Is this the same as #769?

Yes, looks same as 769. Didn't see it earlier.
Not sure if it is abandoned or they are still working on it. Anyway, let me know if I should close my PR.

@lorenzodb1
Copy link
Member

@Chandra158 I don't see any update on that PR, so I'd go with this one.

Copy link
Member

@jpdakran jpdakran left a comment

Choose a reason for hiding this comment

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

LGTM

@lorenzodb1 lorenzodb1 merged commit 28a6658 into Yelp:master Apr 30, 2024
12 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.

None yet

4 participants