Skip to content

Commit

Permalink
repos collaborators docs updates
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Brauer <[email protected]>
  • Loading branch information
danbrauer committed Nov 21, 2024
1 parent a9020bd commit f94f00f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
14 changes: 12 additions & 2 deletions cartography/intel/github/repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,15 @@ def _get_repo_collaborators(
token: str, api_url: str, organization: str, repo: str, affiliation: str,
) -> PaginatedGraphqlData:
"""
TODO docs
Retrieve a list of collaborators for a given repository, as described in
https://docs.github.com/en/graphql/reference/objects#repositorycollaboratorconnection.
:param token: The Github API token as string.
:param api_url: The Github v4 API endpoint as string.
:param organization: The name of the target Github organization as string.
:pram repo: The name of the target Github repository as string.
:param affiliation: The type of affiliation to retrieve collaborators for. Either 'DIRECT' or 'OUTSIDE'.
See https://docs.github.com/en/graphql/reference/enums#collaboratoraffiliation
:return: A list of dicts representing repos. See tests.data.github.repos for data shape.
"""
collaborators, _ = fetch_all(
token,
Expand Down Expand Up @@ -360,7 +368,9 @@ def _transform_collaborators(
"""
Performs data adjustments for collaborators in a GitHub repo.
Output data shape = [{permission, repo_url, url (the user's URL), login, name}, ...]
:param collaborators: See cartography.tests.data.github.repos for data shape. TODO update test data probably
:param collaborators: For data shape, see
cartography.tests.data.github.repos.DIRECT_COLLABORATORS
cartography.tests.data.github.repos.OUTSIDE_COLLABORATORS
:param repo_url: The URL of the GitHub repo.
:param transformed_collaborators: Output dict. Data shape =
{'ADMIN': [{ user }, ...], 'MAINTAIN': [{ user }, ...], 'READ': [ ... ], 'TRIAGE': [ ... ], 'WRITE': [ ... ]}
Expand Down
18 changes: 16 additions & 2 deletions docs/root/modules/github/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,20 @@ Representation of a single GitHubRepository (repo) [repository object](https://d
(GitHubOrganization)-[OWNER]->(GitHubRepository)
```
- GitHubRepositories in an organization can have outside collaborators with different permissions, including ADMIN,
- GitHubRepositories in an organization can have [outside collaborators](https://docs.github.com/en/graphql/reference/enums#collaboratoraffiliation) who may be granted different levels of access, including ADMIN,
WRITE, MAINTAIN, TRIAGE, and READ ([Reference](https://docs.github.com/en/graphql/reference/enums#repositorypermission)).
```
(GitHubUser)-[:OUTSIDE_COLLAB_{ACTION}]->(GitHubRepository)
```
- GitHubRepositories in an organization also mark all [direct collaborators](https://docs.github.com/en/graphql/reference/enums#collaboratoraffiliation), folks who are not necessarily 'outside' but who are granted access directly to the repository (as opposed to via membership in a team). They may be granted different levels of access, including ADMIN,
WRITE, MAINTAIN, TRIAGE, and READ ([Reference](https://docs.github.com/en/graphql/reference/enums#repositorypermission)).
```
(GitHubUser)-[:DIRECT_COLLAB_{ACTION}]->(GitHubRepository)
```
- GitHubRepositories use ProgrammingLanguages
```
(GitHubRepository)-[:LANGUAGE]->(ProgrammingLanguage)
Expand Down Expand Up @@ -151,13 +158,20 @@ Representation of a single GitHubUser [user object](https://developer.github.com
(GitHubUser)-[OWNER]->(GitHubRepository)
```
- GitHubRepositories in an organization can have outside collaborators with different permissions, including ADMIN,
- GitHubRepositories in an organization can have [outside collaborators](https://docs.github.com/en/graphql/reference/enums#collaboratoraffiliation) who may be granted different levels of access, including ADMIN,
WRITE, MAINTAIN, TRIAGE, and READ ([Reference](https://docs.github.com/en/graphql/reference/enums#repositorypermission)).
```
(GitHubUser)-[:OUTSIDE_COLLAB_{ACTION}]->(GitHubRepository)
```
- GitHubRepositories in an organization also mark all [direct collaborators](https://docs.github.com/en/graphql/reference/enums#collaboratoraffiliation), folks who are not necessarily 'outside' but who are granted access directly to the repository (as opposed to via membership in a team). They may be granted different levels of access, including ADMIN,
WRITE, MAINTAIN, TRIAGE, and READ ([Reference](https://docs.github.com/en/graphql/reference/enums#repositorypermission)).
```
(GitHubUser)-[:DIRECT_COLLAB_{ACTION}]->(GitHubRepository)
```
- GitHubUsers are members of an organization. In some cases there may be a user who is "unaffiliated" with an org, for example if the user is an enterprise owner, but not member of, the org. [Enterprise owners](https://docs.github.com/en/enterprise-cloud@latest/admin/managing-accounts-and-repositories/managing-users-in-your-enterprise/roles-in-an-enterprise#enterprise-owners) have complete control over the enterprise (i.e. they can manage all enterprise settings, members, and policies) yet may not show up on member lists of the GitHub org.
```
Expand Down

0 comments on commit f94f00f

Please sign in to comment.