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

Add support for GitHub teams and team-repos #1167

Merged
merged 4 commits into from May 12, 2023
Merged

Add support for GitHub teams and team-repos #1167

merged 4 commits into from May 12, 2023

Conversation

achantavy
Copy link
Contributor

Testing performed

  • Integration tests
  • Manually ran CLI

Copy link
Collaborator

@jychp jychp left a comment

Choose a reason for hiding this comment

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

Needed feature, thx for the job.
Some non blocking comments.

May be it can be confusing to have a module with both old way & new model queries ...

auth_data['token'],
auth_data['url'],
auth_data['name'],
config.update_tag,
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should modify users & repos sync to add "config.update_tag" parameter to keep all sync function a similar definition.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can take away this parameter instead, since the update tag is within common_job_parameters.

lastupdated: PropertyRef = PropertyRef('lastupdated', set_in_kwargs=True)


@dataclass(frozen=True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

May be you could add an extra label "GITHUB_PERMISSION" or similar to allow generic graph queries like "does team X has access to repository Y" with a simple query:
| MATCH (a:GitHubTeam)-[r:GITHUB_PERMISSION]-(b:GitHubRepository)
This will allow much cleaner queries, and if any new kind of role appears you will not break your existing queries.

Copy link
Contributor

Choose a reason for hiding this comment

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

There are 5 possible roles, but I'm not against the idea. I usually would just do something like match (a:MyNode)--(b:OtherNode). If we do this, I think a good name is ACCESS.
https://docs.github.com/en/organizations/managing-user-access-to-your-organizations-repositories/repository-roles-for-an-organization

lastupdated: PropertyRef = PropertyRef('lastupdated', set_in_kwargs=True)


@dataclass(frozen=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

There are 5 possible roles, but I'm not against the idea. I usually would just do something like match (a:MyNode)--(b:OtherNode). If we do this, I think a good name is ACCESS.
https://docs.github.com/en/organizations/managing-user-access-to-your-organizations-repositories/repository-roles-for-an-organization


@dataclass(frozen=True)
class GitHubTeamNodeProperties(CartographyNodeProperties):
id: PropertyRef = PropertyRef('url')
Copy link
Contributor

Choose a reason for hiding this comment

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

nonblocker: I feel like id should maybe be {org}/{name}, but i see that url was also used for the id of Repos

@patch.object(cartography.intel.github.teams, 'get_teams', return_value=GH_TEAM_DATA)
def test_sync_github_teams(mock_teams, mock_team_repos, neo4j_session):
# Arrange
_ensure_local_neo4j_has_test_data(neo4j_session)
Copy link
Contributor

Choose a reason for hiding this comment

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

Non blocker: add one more test org to make sure teams aren't accidentally added to that other org.

auth_data['token'],
auth_data['url'],
auth_data['name'],
config.update_tag,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can take away this parameter instead, since the update tag is within common_job_parameters.

@achantavy achantavy merged commit 7d1b5c6 into master May 12, 2023
5 checks passed
@achantavy achantavy deleted the githubteam branch May 12, 2023 18:07
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