Thanks to visit codestin.com
Credit goes to github.com

Skip to content

New plugin for OpenAI tokens#823

Merged
lorenzodb1 merged 3 commits into
Yelp:masterfrom
Chandra158:gh-plugin-openai
May 3, 2024
Merged

New plugin for OpenAI tokens#823
lorenzodb1 merged 3 commits into
Yelp:masterfrom
Chandra158:gh-plugin-openai

Conversation

@Chandra158
Copy link
Copy Markdown
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
      }

@Chandra158 Chandra158 requested review from josh-ho and lorenzodb1 May 3, 2024 13:09
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