Skip to content

Commit

Permalink
better keeping affil and unaffil user props in sync
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Brauer <[email protected]>
  • Loading branch information
danbrauer committed Nov 12, 2024
1 parent 9874a4a commit 94e32df
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions cartography/models/github/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@


@dataclass(frozen=True)
class GitHubOrganizationUserNodeProperties(CartographyNodeProperties):
class BaseGitHubUserNodeProperties(CartographyNodeProperties):
# core properties in all GitHubUser nodes
id: PropertyRef = PropertyRef('url')
lastupdated: PropertyRef = PropertyRef('lastupdated', set_in_kwargs=True)
fullname: PropertyRef = PropertyRef('name')
Expand All @@ -51,22 +52,20 @@ class GitHubOrganizationUserNodeProperties(CartographyNodeProperties):
is_enterprise_owner: PropertyRef = PropertyRef('isEnterpriseOwner')
email: PropertyRef = PropertyRef('email')
company: PropertyRef = PropertyRef('company')


@dataclass(frozen=True)
class GitHubOrganizationUserNodeProperties(BaseGitHubUserNodeProperties):
# specified for affiliated users only. The GitHub api does not return this property for unaffiliated users.
has_2fa_enabled: PropertyRef = PropertyRef('hasTwoFactorEnabled')
# specified for affiliated uers only. Unaffiliated users do not have a 'role' in the target organization.
role: PropertyRef = PropertyRef('role')


@dataclass(frozen=True)
class GitHubUnaffiliatedUserNodeProperties(CartographyNodeProperties):
id: PropertyRef = PropertyRef('url')
lastupdated: PropertyRef = PropertyRef('lastupdated', set_in_kwargs=True)
fullname: PropertyRef = PropertyRef('name')
username: PropertyRef = PropertyRef('login', extra_index=True)
is_site_admin: PropertyRef = PropertyRef('isSiteAdmin')
is_enterprise_owner: PropertyRef = PropertyRef('isEnterpriseOwner')
email: PropertyRef = PropertyRef('email')
company: PropertyRef = PropertyRef('company')
# 'has_2fa_enabled' not specified for unaffiliated; GitHub api does not return this property for them
# 'role' not specified for unaffiliated; they do not have a role in the target organization
class GitHubUnaffiliatedUserNodeProperties(BaseGitHubUserNodeProperties):
# No additional properties needed
pass


@dataclass(frozen=True)
Expand Down

0 comments on commit 94e32df

Please sign in to comment.