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

New plugin for OpenAI tokens #823

Merged
merged 3 commits into from
May 3, 2024
Merged

Conversation

Chandra158
Copy link
Contributor

@Chandra158 Chandra158 commented May 3, 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?

Feature: New plugin to detect OpenAI api keys

Token Format

  • User API keys (legacy): sk-[20_alpha_numberic] T3BlbkFJ [20_alpha_numberic] (T3BlbkFJ = base64 for "OpenAI")
    • there's no official documentation but found this community forum which mentions legacy token format
  • Project API keys: sk-<project_name>-[20_alpha_numberic] T3BlbkFJ [20_alpha_numberic]
  • Generated tokens for both from OpenAI portal and verified manually

Token verification

Checking whether token is active might not be possible; so haven't implemented verify() method for the plugin:

  • No official API to check validity of tokens (refs: openai api-reference)
  • Calling random apis (like: v1/models) may or may not work because of the restrictions placed on tokens during creation
    • another downside could be credit usage for valid tokens

Tests

  • New tests added for plugin
  • Tested manually in local with sample token in file
      {
        "type": "OpenAI Token",
        "filename": "test_data/files/file_with_secrets.py",
        "hashed_secret": "007111295d396c8234d268fa24014ef5235136b0",
        "is_verified": false,
        "line_number": 5
      }

@lorenzodb1 lorenzodb1 merged commit d2ef48e into Yelp:master May 3, 2024
15 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

3 participants