Skip to content

Add policy to restrict Approved-LowRisk label#26728

Merged
daxian-dbw merged 3 commits into
masterfrom
copilot/add-github-policy-file
Jan 28, 2026
Merged

Add policy to restrict Approved-LowRisk label#26728
daxian-dbw merged 3 commits into
masterfrom
copilot/add-github-policy-file

Conversation

Copilot AI commented Jan 27, 2026

Copy link
Copy Markdown
Contributor

Adds automation to restrict the Approved-LowRisk label to authorized maintainers. Unauthorized additions are automatically removed with a reply message.

Changes

  • Add .github/policies/labelAdded.approvedLowRisk.yml with event responder that:
    • Triggers on Approved-LowRisk label added to open PRs
    • Removes label if added by user without Admin permissions and not in allowlist
    • Posts reply explaining the restriction

Authorization

Allowed users:

  • Repository members with Admin permissions
  • Explicit allowlist: iSazonov, daxian-dbw
  • Commented allowlist entries for future enablement: TravisEz13, adityapatwardhan, jshigetomi

Policy Structure

eventResponderTasks:
  - if:
      - labelAdded:
          label: Approved-LowRisk
      - not:
          or:
            - activitySenderHasPermission:
                permission: Admin
            - isActivitySender:
                user: iSazonov
    then:
      - removeLabel:
          label: Approved-LowRisk
      - addReply
Original prompt

Create a pull request in PowerShell/PowerShell (base: master) that adds the new GitHub policy file below.

File to add

Path: .github/policies/labelAdded.approvedLowRisk.yml

Contents:

id: labelAdded.approvedLowRisk
name: GitOps.PullRequestIssueManagement
description: Remove Approved-LowRisk if applied by an unauthorized user
owner:
resource: repository
disabled: false
where:
configuration:
  resourceManagementConfiguration:
    eventResponderTasks:
      - description: Remove Approved-LowRisk if label was added by someone not authorized
        if:
          - payloadType: Pull_Request
          - isOpen
          - labelAdded:
              label: Approved-LowRisk
          # Unauthorized = NOT admin/write AND NOT in explicit allowlist
          - not:
              or:
                - activitySenderHasPermission:
                    permission: Admin
                - activitySenderHasPermission:
                    permission: Write

                # Allowlist (enabled)
                - isActivitySender:
                    user: iSazonov
                    issueAuthor: False
                - isActivitySender:
                    user: daxian-dbw
                    issueAuthor: False

                # Allowlist (commented out for now)
                # - isActivitySender:
                #     user: TravisEz13
                #     issueAuthor: False
                # - isActivitySender:
                #     user: adityapatwardhan
                #     issueAuthor: False
                # - isActivitySender:
                #     user: jshigetomi
                #     issueAuthor: False
        then:
          - removeLabel:
              label: Approved-LowRisk
          - addReply:
              reply: >-
                The `Approved-LowRisk` label is restricted to authorized maintainers and was removed.
onFailure:
onSuccess:

Acceptance criteria

  • Add the file exactly as specified.
  • Ensure YAML formatting/indentation is valid.
  • Open a PR titled "Add policy to restrict Approved-LowRisk label".

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>
Copilot AI changed the title [WIP] Add new GitHub policy file for label management Add policy to restrict Approved-LowRisk label Jan 27, 2026
Copilot AI requested a review from TravisEz13 January 27, 2026 21:07
Comment thread .github/policies/labelAdded.approvedLowRisk.yml Outdated
Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>

@daxian-dbw daxian-dbw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thank you!

@daxian-dbw daxian-dbw added the CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log label Jan 27, 2026
@daxian-dbw daxian-dbw marked this pull request as ready for review January 28, 2026 01:02
@daxian-dbw daxian-dbw requested review from a team and jshigetomi as code owners January 28, 2026 01:02
Copilot AI review requested due to automatic review settings January 28, 2026 01:02
@daxian-dbw daxian-dbw merged commit b3a3864 into master Jan 28, 2026
39 of 42 checks passed
@daxian-dbw daxian-dbw deleted the copilot/add-github-policy-file branch January 28, 2026 01:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds a GitHub policy automation file to restrict the Approved-LowRisk label to authorized maintainers only. When an unauthorized user adds this label to a PR, the policy automatically removes it and posts an explanatory message.

Changes:

  • Adds .github/policies/labelAdded.approvedLowRisk.yml with event responder configuration that monitors for Approved-LowRisk label additions, validates authorization, and takes removal actions if unauthorized

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +17 to +21
# Unauthorized = NOT admin AND NOT in explicit allowlist
- not:
or:
- activitySenderHasPermission:
permission: Admin

Copilot AI Jan 28, 2026

Copy link

Choose a reason for hiding this comment

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

The PR description states that allowed users include "Repository members with Admin permissions" and users in the allowlist. However, the original prompt in the PR description includes both Admin and Write permissions in the authorization check, while the current implementation only checks for Admin permission.

The original prompt specified:

- activitySenderHasPermission:
    permission: Admin
- activitySenderHasPermission:
    permission: Write

But the current implementation only has:

- activitySenderHasPermission:
    permission: Admin

This means users with Write permission (who are not in the explicit allowlist) will have the label removed, even though the original specification intended to allow them. Please clarify whether Write permission holders should be authorized to use this label, and if so, add the missing permission check.

Copilot uses AI. Check for mistakes.
JustinGrote pushed a commit to JustinGrote/PowerShell that referenced this pull request Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants