Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Dont filter content from Copilot#1464

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JoannaaKL merged 6 commits intomainfromallow-copilot-in-lockdown
Nov 26, 2025
Merged

Conversation

@JoannaaKL
Copy link
Contributor

Lockdown mode improvement: if the author is trusted bot, don't filter out content. For now the list of trusted bots is hardcoded but it can easily be configurable if needed.

@JoannaaKLJoannaaKL requested a review froma team as acode ownerNovember 21, 2025 10:56
CopilotAI review requested due to automatic review settingsNovember 21, 2025 10:56
Copilot finished reviewing on behalf ofJoannaaKLNovember 21, 2025 11:00
Copy link
Contributor

CopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request enhances lockdown mode to allow content from trusted bots (dependabot, github-actions, github-copilot) to bypass content filtering. The changes add aViewerType field to track whether the GitHub API viewer is a Bot, and implement aisTrustedBot() check with a hardcoded list of trusted bot logins.

Key changes:

  • AddedViewerType field to track the__typename from GitHub's GraphQL API
  • AddedtrustedBotLogins map with hardcoded trusted bot identifiers
  • ModifiedIsSafeContent() to check for trusted bots before filtering content

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

FileDescription
pkg/lockdown/lockdown.goAdded ViewerType field, trustedBotLogins map, isTrustedBot() method, and modified IsSafeContent() to check trusted bots; updated GraphQL query to fetch __typename
pkg/lockdown/lockdown_test.goUpdated test mocks and assertions to include ViewerType field with value "User"

@JoannaaKLJoannaaKLforce-pushed theallow-copilot-in-lockdown branch from7f851b4 to869c024CompareNovember 21, 2025 11:04
@JoannaaKLJoannaaKLforce-pushed theallow-copilot-in-lockdown branch from869c024 to8400964CompareNovember 21, 2025 11:06
@JoannaaKLJoannaaKL changed the titleDont filter content from trusted botsDont filter content from CopilotNov 21, 2025
},nil
}

c.logDebug("repo access cache miss","owner",owner,"repo",repo,"user",username)
Copy link
Contributor

Choose a reason for hiding this comment

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

why you decided to remove attributes?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I didn't want to be too verbose but this is good point, I re-added them. It will make debugging easier
CleanShot 2025-11-24 at 11 16 06@2x

SamMorrowDrums
SamMorrowDrums previously approved these changesNov 24, 2025
Copy link
Collaborator

@SamMorrowDrumsSamMorrowDrums left a comment

Choose a reason for hiding this comment

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

That seems ok. I think there's no easy way to do this other than string matching.

Could always allow a trusted user/bot arg so you can allow exceptions with intention. Like comma separated list of names or something.

logger*slog.Logger
client*githubv4.Client
mu sync.Mutex
cache*cache2go.CacheTable
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's possible if it's expensive enough we might want to use redis or memcached on remote server, do you have a solution in mind for that?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Yes, I was thinking of that, or even creating an adapter for the local server. Generally using Redis in the remote server would be the next logical step.
Two main aspects that will guide enhancing this mode are

  1. lockdown mode becomes popular and
  2. if the memory burden on maintaining this cache with TTL is too high (but I need to analyse usage patterns to be 100% sure, my gut feeling is that typical user won't be scanning thousands of repos)

SamMorrowDrums reacted with thumbs up emoji
}
ifrepoInfo.IsPrivate||repoInfo.ViewerLogin==username {

c.logInfo(ctx,fmt.Sprintf("evaluated repo access fur user %s to %s/%s for content filtering, result: hasPushAccess=%t, isPrivate=%t",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this logger hook into MCP logging because log output shows up like an error with MCP servers using stdio, and I think you can instead send server log messages explicitly.

Also you can log to stderr (at least the docs from MCP debugging in VS Code say that's better.

It looks like this is logging to stdio unless I missed something.

JoannaaKL reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

It's also sending logs to stderr, I am basically passing down the logger that is created in main:
CleanShot 2025-11-24 at 10 31 52@2x
Or is that not what you meant?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That should be sufficient.

JoannaaKL reacted with thumbs up emoji
Copy link
Contributor

CopilotAI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment on lines 122 to 134
func (c*RepoAccessCache)IsSafeContent(ctx context.Context,username,owner,repostring) (bool,error) {
repoInfo,err:=c.getRepoAccessInfo(ctx,username,owner,repo)
iferr!=nil {
c.logDebug("error checking repo access info for content filtering","owner",owner,"repo",repo,"user",username,"error",err)
returnfalse,err
}
ifrepoInfo.IsPrivate||repoInfo.ViewerLogin==username {

c.logDebug(ctx,fmt.Sprintf("evaluated repo access for user %s to %s/%s for content filtering, result: hasPushAccess=%t, isPrivate=%t",
username,owner,repo,repoInfo.HasPushAccess,repoInfo.IsPrivate))

ifc.isTrustedBot(username)||repoInfo.IsPrivate||repoInfo.ViewerLogin==strings.ToLower(username) {
returntrue,nil
}
returnrepoInfo.HasPushAccess,nil

Choose a reason for hiding this comment

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

The trusted bot check should be performed before callinggetRepoAccessInfo to avoid an unnecessary API query for trusted bots. Currently, the function fetches repo access information first (which may involve a GraphQL API call), then checks if the user is a trusted bot. This wastes API quota and adds latency for bot accounts.

Consider moving the trusted bot check to the beginning:

func (c*RepoAccessCache)IsSafeContent(ctx context.Context,username,owner,repostring) (bool,error) {ifc.isTrustedBot(username) {returntrue,nil}repoInfo,err:=c.getRepoAccessInfo(ctx,username,owner,repo)iferr!=nil {returnfalse,err}// ... rest of the logic}

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

This sounds reasonable

Comment on lines +119 to +121
// - the author currently has push access to the repository;
// - the repository is private;
// - the content was created by the viewer.

Choose a reason for hiding this comment

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

The documentation lists the conditions in a different order than they are checked in the code. The comment states:

  1. trusted bot
  2. push access
  3. private repo
  4. viewer matches username

But the code checks:

  1. trusted bot
  2. private repo
  3. viewer matches username
  4. push access

For clarity and maintainability, the documentation should match the code order. Consider updating the comment to:

// IsSafeContent determines if the specified user can safely access the requested repository content.// Safe access applies when any of the following is true:// - the content was created by a trusted bot;// - the repository is private;// - the content was created by the viewer;// - the author currently has push access to the repository.
Suggested change
// - theauthor currently has push access to the repository;
// - therepository is private;
// - thecontent was created bytheviewer.
// - therepository is private;
// - thecontent was created by the viewer;
// - theauthor currently has push access totherepository.

Copilot uses AI. Check for mistakes.
Comment on lines +267 to +270
func (c*RepoAccessCache)isTrustedBot(usernamestring)bool {
_,ok:=c.trustedBotLogins[strings.ToLower(username)]
returnok
}

Choose a reason for hiding this comment

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

The new trusted bot functionality lacks test coverage. Since other functions in this package have tests (e.g.,TestRepoAccessCacheEvictsAfterTTL), the new behavior should also be tested.

Consider adding test cases for:

  1. Verifying that "copilot" (case-insensitive) is recognized as a trusted bot
  2. EnsuringIsSafeContent returnstrue for trusted bots without querying the API
  3. Testing that non-trusted usernames still trigger the normal access checks

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@LuluBeatsonLuluBeatson left a comment

Choose a reason for hiding this comment

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

Looks good!

Only minor things are: checkingisTrustedBot beforegetRepoAccessInfo, test coverage

@JoannaaKL
Copy link
ContributorAuthor

Looks good!

Only minor things are: checkingisTrustedBot beforegetRepoAccessInfo, test coverage

Thanks - I will address your feedback in a follow up pr ❤️

@JoannaaKLJoannaaKL merged commit7cfb354 intomainNov 26, 2025
23 checks passed
@JoannaaKLJoannaaKL deleted the allow-copilot-in-lockdown branchNovember 26, 2025 10:24
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

Copilot code reviewCopilotCopilot left review comments

@tonytrgtonytrgtonytrg approved these changes

@LuluBeatsonLuluBeatsonLuluBeatson approved these changes

@almaleksiaalmaleksiaAwaiting requested review from almaleksia

@SamMorrowDrumsSamMorrowDrumsAwaiting requested review from SamMorrowDrums

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@JoannaaKL@almaleksia@SamMorrowDrums@tonytrg@LuluBeatson

[8]ページ先頭

©2009-2025 Movatter.jp