Skip to content

Commit

Permalink
don't remove members if doesn't have permission to get their last act…
Browse files Browse the repository at this point in the history
…ive, just ignore them (#276)
  • Loading branch information
noamd-legit authored Dec 11, 2023
1 parent 9ef7c2f commit 0d52c90
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 8 additions & 4 deletions internal/collectors/github/members_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,18 @@ func (c *memberCollector) enrichMembers(org *ghcollected.ExtendedOrg, members []
localMember := member
gw.Do(func() {
memberLastActive, err := c.collectMemberLastActiveTime(org.Name(), *localMember.Login)
lastActive := -1

if err == nil && !memberLastActive.IsZero() {
lastActive = int(memberLastActive.UnixNano())
}

if err != nil {
perm := c.memberMissingPermission(org, localMember)
c.IssueMissingPermissions(perm)
return
}
if !memberLastActive.IsZero() {
resChannel <- ghcollected.NewOrganizationMember(localMember, int(memberLastActive.UnixNano()), memberType)
}

resChannel <- ghcollected.NewOrganizationMember(localMember, lastActive, memberType)
})
}

Expand Down
2 changes: 2 additions & 0 deletions policies/github/member.rego
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ stale_member_found[mem] := true {
some member
mem := input.members[member]
mem.is_admin == false
mem.last_active != -1
isStale(mem.last_active, 6)
}

Expand All @@ -55,6 +56,7 @@ stale_admin_found[mem] := true {
some member
mem := input.members[member]
mem.is_admin == true
mem.last_active != -1
isStale(mem.last_active, 6)
}

Expand Down

0 comments on commit 0d52c90

Please sign in to comment.