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

feat: added support for scanning any account #168

Merged
merged 4 commits into from
Jan 21, 2024

Conversation

elad-pticha
Copy link
Contributor

No description provided.

@elad-pticha
Copy link
Contributor Author

Changed org subcommand to account.
This feature allows us to determine if each account is a user or organization and to scan its GitHub Actions.

Now we iterate over each account:

for account in Config.account_name:
        generator = get_account_generator(account)

        for repo in generator:
            download_workflows_and_actions(repo)

and determine its type:

account_info = get_account_info(account_name=account_name)
    account_type = account_info.get("type")

    if account_type == "User":
        log.info(f"[+] Scanning user: {account_name}")
        return get_user_repository_generator(account_name)

    elif account_type == "Organization":
        log.info(f"[+] Scanning organization: {account_name}")
        return get_organization_repository_generator(account_name)

    else:
        log.error(f"[-] Failed to get account type for {account_name}")
        return None

From there, we continue the same.
This structure eliminates duplicate code and allows the user to scan in a single raven command for both organizations (like we had before) and user repositories.

Usage:

raven download account --account-name ravendemo --account-name $PERSONAL_ACCOUNT --token $GITHUB_TOKEN

Copy link
Contributor

@oreenlivnicode oreenlivnicode left a comment

Choose a reason for hiding this comment

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

I love that you can add multiple accounts to the same scan, but I am unsure about the obfuscation of the account type. It feels odd to me that the user doesn't have to explicitly specify whether the account is a user or an organization.
What led to the decision not to ask for the account type explicitly?

src/downloader/download.py Outdated Show resolved Hide resolved
src/downloader/download.py Show resolved Hide resolved
@elad-pticha
Copy link
Contributor Author

This solution allows users to scan different types of accounts without specifying if it is an organization or a user account.
Requiring users to select the account type is unnecessary and will block us from scanning different versions in a single command.

I think this is the best solution as we don't care if we scan an organization or a user account as we want RAVEN to scan its repositories.

Command like this:
raven download account --token $GITHUB_TOKEN --account-name userAccount --account-name microsoft

This makes it as easy as possible to run RAVEN as you don't even have to check if a specific account is org type or user type, RAVEN just does this in the backend.

@oreenlivnicode WDYT?

@elad-pticha elad-pticha force-pushed the feat/support-any-account branch from ed6230c to 9490158 Compare January 2, 2024 03:38
@oreenlivnicode
Copy link
Contributor

I got it @elad-pticha. I saw that github themselves use the terminology account. So I am ok with it.

README.md Outdated Show resolved Hide resolved
@elad-pticha elad-pticha force-pushed the feat/support-any-account branch 3 times, most recently from 016ddd3 to bfdae36 Compare January 21, 2024 08:44
@elad-pticha elad-pticha force-pushed the feat/support-any-account branch from bfdae36 to 05a9316 Compare January 21, 2024 08:48
@elad-pticha elad-pticha merged commit f65625b into main Jan 21, 2024
7 checks passed
@elad-pticha elad-pticha deleted the feat/support-any-account branch January 21, 2024 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to scan a user account
2 participants