Skip to content

Update notion api rule to take new key version #4318

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Tapiocaba
Copy link

Description:

This commit adds the updated (ntn_ prefix) Notion API regex key detection and updates the test keys. secret prefix keys have been depreciated in the public api.

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

@Tapiocaba Tapiocaba requested a review from a team as a code owner July 15, 2025 23:09
Copy link
Contributor

@shahzadhaider1 shahzadhaider1 left a comment

Choose a reason for hiding this comment

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

Hey @Tapiocaba, thanks for opening this PR to update the regex pattern for the Notion detector based on the recent token format changes, really appreciate your contribution!

That said, we won't be able to merge this as-is since the old secret format is still valid and in use. Instead of modifying the existing detector, it would be better to create a v2 of the Notion detector. This way, we can support detection of both the old and new token formats without losing compatibility.

If you'd like to help with creating the new version, feel free to check out our guide on building a v2 detector. I am happy to assist if you have any questions.

Thanks again for bringing this to our attention!

@@ -22,13 +22,13 @@ var (
client = common.SaneHttpClient()

// Make sure that your group is surrounded in boundary characters such as below to reduce false positives.
keyPat = regexp.MustCompile(`\b(secret_[A-Za-z0-9]{43})\b`)
keyPat = regexp.MustCompile(`\b((?:secret_[A-Za-z0-9]{43})|ntn_[0-9]{11}[A-Za-z0-9]{32}[A-Za-z0-9]{3})\b`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Great 😃 Could you move the new pattern to a separate V2 detector instead of merging it into the existing one? Since the API for verification is the same, we can extract the verification logic into a shared method and use it in both versions.

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.

3 participants