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

elevenlabs analyzer #3850

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

kashifkhan0771
Copy link
Contributor

@kashifkhan0771 kashifkhan0771 commented Jan 23, 2025

Description:

This Pull requests add a new analyzer for ElevenLabs

Test Cases:

Screenshot from 2025-01-28 11-38-10
Screenshot from 2025-01-28 12-36-36

Checklist:

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

@kashifkhan0771 kashifkhan0771 marked this pull request as ready for review January 27, 2025 14:33
@kashifkhan0771 kashifkhan0771 requested a review from a team as a code owner January 27, 2025 14:33
@kashifkhan0771 kashifkhan0771 changed the title elevenlabs analyzer [WIP] elevenlabs analyzer Jan 27, 2025
@kashifkhan0771 kashifkhan0771 requested a review from a team as a code owner January 28, 2025 07:43
If write permission API calls was not as expected than only we make read permission API calls
This we only do for those API calls which does not add any resources to secretInfo
*/
func getResources(client *http.Client, key string, secretInfo *SecretInfo) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Points to Consider for Implementation while getting resource:

  1. Aggregate Errors:
    Instead of failing on the first error, collect all errors encountered during the process and return them as a single aggregated error at the end. This ensures that users get a complete picture of what went wrong, rather than having to address issues one at a time.

  2. Graceful Error Handling in CLI:
    For the CLI, log errors when checking a specific scope or fetching resource fails, but continue processing other tasks. Improving the user experience and allowing for partial success.

  3. Concurrent API Calls:
    Use Go routines to call APIs concurrently. This will significantly improve performance by reducing the total time spent waiting for API responses.

Let me know your thoughts on these points.

Copy link
Contributor

Choose a reason for hiding this comment

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

My vote will be for concurrent API calls with error handling for each permission.

var secretInfo = &SecretInfo{}

// validate the key and get user information
if err := validateKey(client, key, secretInfo); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

The func name validateKey is confusing as this function is fetching the ElevenLabs User. Moreover, this function is also setting up User, Resource and Permissions in SecretInfo. I would recommend to break it multiple func.

Comment on lines 250 to 325
if err := getHistory(client, key, secretInfo); err != nil {
return err
}

if err := deleteHistory(client, key, secretInfo); err != nil {
return err
}

// dubbings
if err := deleteDubbing(client, key, secretInfo); err != nil {
return err
}

// if dubbing write permission was not added
if !permissionExist(secretInfo.Permissions, DubbingWrite) {
if err := getDebugging(client, key, secretInfo); err != nil {
return err
}
}

// voices
if err := getVoices(client, key, secretInfo); err != nil {
return err
}

if err := deleteVoice(client, key, secretInfo); err != nil {
return err
}

// projects
if err := getProjects(client, key, secretInfo); err != nil {
return err
}

if err := deleteProject(client, key, secretInfo); err != nil {
return err
}

// pronunciation dictionaries
if err := getPronunciationDictionaries(client, key, secretInfo); err != nil {
return err
}

if err := removePronunciationDictionariesRule(client, key, secretInfo); err != nil {
return err
}

// models
if err := getModels(client, key, secretInfo); err != nil {
return err
}

// audio native
if err := updateAudioNativeProject(client, key, secretInfo); err != nil {
return err
}

// workspace
if err := deleteInviteFromWorkspace(client, key, secretInfo); err != nil {
return err
}

// text to speech
if err := textToSpeech(client, key, secretInfo); err != nil {
return err
}

// voice changer
if err := speechToSpeech(client, key, secretInfo); err != nil {
return err
}

// audio isolation
if err := audioIsolation(client, key, secretInfo); err != nil {
return err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

These are too many calls. is it possible to optimize them ? may be using go routines

} else if errorResp.Detail.Status == MissingPermissions {
// key is missing user read permissions but is valid
secretInfo.Valid = true
color.Yellow("\n[!] API Key missing user read permissions")
Copy link
Contributor

Choose a reason for hiding this comment

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

AnalyzePermission should only be gathering information from the service. As it is the common code calling from CLI and detectors.

If write permission API calls was not as expected than only we make read permission API calls
This we only do for those API calls which does not add any resources to secretInfo
*/
func getResources(client *http.Client, key string, secretInfo *SecretInfo) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

My vote will be for concurrent API calls with error handling for each permission.

@kashifkhan0771 kashifkhan0771 force-pushed the feat/oss-97-elevenlabs-analyzer branch from 3ba85a9 to 4975781 Compare January 29, 2025 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants