Skip to content

Commit 227f73e

Browse files
committed
skip API call for bots and add github-action[bot] to trusted logins
1 parent 836c41e commit 227f73e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pkg/lockdown/lockdown.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ func newRepoAccessCache(client *githubv4.Client, restClient *github.Client, opts
101101
cache: cache2go.Cache(defaultRepoAccessCacheKey),
102102
ttl: defaultRepoAccessTTL,
103103
trustedBotLogins: map[string]struct{}{
104-
"copilot": {},
104+
"copilot": {},
105+
"github-actions[bot]": {},
105106
},
106107
}
107108
for _, opt := range opts {
@@ -133,6 +134,10 @@ type CacheStats struct {
133134
// - the repository is private;
134135
// - the content was created by the viewer.
135136
func (c *RepoAccessCache) IsSafeContent(ctx context.Context, username, owner, repo string) (bool, error) {
137+
if c.isTrustedBot(username) {
138+
return true, nil
139+
}
140+
136141
repoInfo, err := c.getRepoAccessInfo(ctx, username, owner, repo)
137142
if err != nil {
138143
return false, err
@@ -141,7 +146,7 @@ func (c *RepoAccessCache) IsSafeContent(ctx context.Context, username, owner, re
141146
c.logDebug(ctx, fmt.Sprintf("evaluated repo access for user %s to %s/%s for content filtering, result: hasPushAccess=%t, isPrivate=%t",
142147
username, owner, repo, repoInfo.HasPushAccess, repoInfo.IsPrivate))
143148

144-
if c.isTrustedBot(username) || repoInfo.IsPrivate || repoInfo.ViewerLogin == strings.ToLower(username) {
149+
if repoInfo.IsPrivate || repoInfo.ViewerLogin == strings.ToLower(username) {
145150
return true, nil
146151
}
147152
return repoInfo.HasPushAccess, nil

0 commit comments

Comments
 (0)