Add Copilot Studio support to Maester#1441
Add Copilot Studio support to Maester#1441lnfernux wants to merge 13 commits intomaester365:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Copilot Studio (Dataverse-backed) “AI Agent Security” coverage to Maester by introducing new MT.1113–MT.1122 tests, plus connection/docs updates to support authenticating and querying agent configuration from Dataverse.
Changes:
- Introduces
Get-MtAIAgentInfo(Dataverse OData retrieval + caching) and 10 newTest-MtAIAgent*security tests (MT.1113–MT.1122). - Extends
Connect-Maester/Disconnect-Maesterwith a newDataverseservice option and Az-context reuse behavior. - Adds Maester config + documentation updates for Dataverse setup and the new test pages/result details.
Reviewed changes
Copilot reviewed 42 out of 42 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| website/docs/tests/maester/MT.1113.md | New website test page for MT.1113 (broad sharing). |
| website/docs/tests/maester/MT.1114.md | New website test page for MT.1114 (missing/weak auth). |
| website/docs/tests/maester/MT.1115.md | New website test page for MT.1115 (risky HTTP config). |
| website/docs/tests/maester/MT.1116.md | New website test page for MT.1116 (email exfiltration). |
| website/docs/tests/maester/MT.1117.md | New website test page for MT.1117 (dormant agents). |
| website/docs/tests/maester/MT.1118.md | New website test page for MT.1118 (maker auth). |
| website/docs/tests/maester/MT.1119.md | New website test page for MT.1119 (hard-coded creds). |
| website/docs/tests/maester/MT.1120.md | New website test page for MT.1120 (MCP tools). |
| website/docs/tests/maester/MT.1121.md | New website test page for MT.1121 (missing instructions). |
| website/docs/tests/maester/MT.1122.md | New website test page for MT.1122 (orphaned ownership). |
| website/docs/sections/create-entra-app.md | Adds optional Dataverse permission/setup section for app registration. |
| website/docs/connect-maester/readme.md | Adds Dataverse connection guidance to Connect-Maester docs. |
| website/docs/connect-maester/connect-maester-advanced.md | Adds advanced Dataverse (SPN-style) guidance. |
| tests/maester-config.json | Adds DataverseEnvironmentUrl global setting + registers MT.1113–MT.1122 metadata. |
| tests/Maester/AIAgent/Test-AIAgentSecurity.Tests.ps1 | New Pester wrapper to run MT.1113–MT.1122. |
| powershell/public/maester/aiagent/Test-MtAIAgentBroadSharing.ps1 | New MT.1113 implementation. |
| powershell/public/maester/aiagent/Test-MtAIAgentBroadSharing.md | Result detail markdown for MT.1113. |
| powershell/public/maester/aiagent/Test-MtAIAgentNoAuthentication.ps1 | New MT.1114 implementation. |
| powershell/public/maester/aiagent/Test-MtAIAgentNoAuthentication.md | Result detail markdown for MT.1114. |
| powershell/public/maester/aiagent/Test-MtAIAgentRiskyHttpConfig.ps1 | New MT.1115 implementation. |
| powershell/public/maester/aiagent/Test-MtAIAgentRiskyHttpConfig.md | Result detail markdown for MT.1115. |
| powershell/public/maester/aiagent/Test-MtAIAgentEmailExfiltration.ps1 | New MT.1116 implementation. |
| powershell/public/maester/aiagent/Test-MtAIAgentEmailExfiltration.md | Result detail markdown for MT.1116. |
| powershell/public/maester/aiagent/Test-MtAIAgentDormant.ps1 | New MT.1117 implementation. |
| powershell/public/maester/aiagent/Test-MtAIAgentDormant.md | Result detail markdown for MT.1117. |
| powershell/public/maester/aiagent/Test-MtAIAgentAuthorAuthentication.ps1 | New MT.1118 implementation. |
| powershell/public/maester/aiagent/Test-MtAIAgentAuthorAuthentication.md | Result detail markdown for MT.1118. |
| powershell/public/maester/aiagent/Test-MtAIAgentHardCodedCredentials.ps1 | New MT.1119 implementation. |
| powershell/public/maester/aiagent/Test-MtAIAgentHardCodedCredentials.md | Result detail markdown for MT.1119. |
| powershell/public/maester/aiagent/Test-MtAIAgentMcpTools.ps1 | New MT.1120 implementation. |
| powershell/public/maester/aiagent/Test-MtAIAgentMcpTools.md | Result detail markdown for MT.1120. |
| powershell/public/maester/aiagent/Test-MtAIAgentMissingInstructions.ps1 | New MT.1121 implementation. |
| powershell/public/maester/aiagent/Test-MtAIAgentMissingInstructions.md | Result detail markdown for MT.1121. |
| powershell/public/maester/aiagent/Test-MtAIAgentOrphaned.ps1 | New MT.1122 implementation. |
| powershell/public/maester/aiagent/Test-MtAIAgentOrphaned.md | Result detail markdown for MT.1122. |
| powershell/public/Connect-Maester.ps1 | Adds Dataverse service option + Az-context reuse + token preflight attempt. |
| powershell/public/Disconnect-Maester.ps1 | Disconnects Az when Dataverse was used; adds error handling. |
| powershell/internal/Get-MtAIAgentInfo.ps1 | New Dataverse OData retrieval + mapping + caching for agent data. |
| powershell/internal/Clear-ModuleVariable.ps1 | Clears cached AIAgentInfo on reset. |
| powershell/Maester.psm1 | Adds AIAgentInfo to the session object. |
| powershell/Maester.psd1 | Exports the 10 new Test-MtAIAgent* functions. |
| build/aitools/test-metadata/maester-config.json | Adds Dataverse environment URL to test metadata sample config. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Clarified the threshold description for dormant agents.
Updated the description for clarity and corrected a grammatical error.
|
Thanks for the contribution, @lnfernux! I'm not able to test at this point but did do a quick review of the overall structure and it looks like you covered a lot! Something to consider with regards to the verbiage and labeling of this set of tests: The "Dataverse" refers to the enterprise data platform for Microsoft 365 as a whole. The description of/in these tests seems to equate "dataverse" with "Copilot Studio" and related components. What do you think about creating a little more clarity between the general dataverse tests and those that specifically pertain to Copilot Studio or AI-related features? |
Yeah, I agree to a certain degree. The tests are only for Copilot Studio as of now, but this PR also uses the dataverse API (https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/overview) so that's why it refers to that. I can make some adjustments to the test naming and labeling to reflect that the tests are for Copilot Studio, and the connection is via dataverse api. |
|
@SamErde I've done a basic rework, where I've moved all Dataverse references into the latter part. Basically now everything will be referred to as "Copilot Studio" tests, and refer to the dataverse api as the connection method, like "Copilot Studio (via dataverse API)". If you are not connected, error messages should still mention that the dataverse api url isn't configured (because that's still the API we are using). Hopefully that looks and reads a bit better. Quick edit: If you need an SPN with read access to my test environment and I can fix that for you if you want to test. |
Nice, those updates look good. |
Description
Adds 10 new Copilot Studio agent security tests (MT.1113-MT.1122) based on the Copilot Studio Agent Security Top 10 Risks. These tests query agent configuration from the Dataverse OData API and check for common security misconfigurations in Copilot Studio agents.
Also adds
Dataverseas a new service option inConnect-Maesterto support authentication to the Dataverse API, and preserves existing Az contexts (federated credentials, managed identity) so the interactive login prompt is skipped when a session already exists.What's been tested
I've tested this locally using both interactive and SPN (clientId + secret). Interactive with
Connect-Maester -Graph,Dataverse, SPN requires you to sign in withConnect-AzAccountandConnect-MgGraphbefore runningConnect-Maester -Dataversesince Graph will be implicit (explicit??). Didn't test in CI/CD.I set up 11 different agents in Copilot Studio plus the default one (this one is excluded from tests):
If you want to test it, here's the guidance on setting up the different agents:
I also had Claude whip up a test plan TEST-VALIDATION-PLAN.md that I went through locally.
Disclaimers
I'm not a good writer, so Claude helped build the skeletons for the .md files, the comments for the scripts and the tests. I've gone over the markdown files to make sure all the links works and has relevant/correct information. The regex for test MT.1119 detects everything I've tested, but man am I bad at regex.
Some things are open for debate and can freely be changed:
Test-MtAIAgent*- can also beTest-MtCopilotStudioor something.Why no Defender XDR table?
This requires Copilot Studio licenses to publish the agents, so I didn't have the option to do this. Might be viable, would love to see someone with access to that test this.
Why no Graph?
I tried using these two endpoints:
GET graph.microsoft.com/copilot/admin/catalog/packages– Retrieves a complete inventory of all agents and apps (Microsoft, External, Shared, and Custom).GET graph.microsoft.com/copilot/admin/catalog/packages/{id}– Fetches detailed metadata for a specific agent or app, including properties and manifest details.Endpoints didn't exist (tried BETA also) and according to https://mc.merill.net/message/MC1173195 it's being added later, so either I'm dumb (I am, but still) or we can try this later.
What's included
New tests (10)
Test-MtAIAgentBroadSharingTest-MtAIAgentNoAuthenticationTest-MtAIAgentRiskyHttpConfigTest-MtAIAgentEmailExfiltrationTest-MtAIAgentDormantTest-MtAIAgentAuthorAuthenticationTest-MtAIAgentHardCodedCredentialsTest-MtAIAgentMcpToolsTest-MtAIAgentMissingInstructionsTest-MtAIAgentOrphanedNew internal function
Get-MtAIAgentInfo- Queries the Dataverse OData API for Copilot Studio agent data, maps option set values, resolves owner UPNs, classifies topics vs tools, and caches results for reuse across tests.Connect-Maester changes
Dataverseto the-ServiceparameterValidateSetGet-AzContextcheck to reuse existing Az sessions from federated credentials, managed identity, or priorConnect-AzAccountcallsDisconnect-Maesterto handle Dataverse serviceDocumentation
website/docs/tests/maester/MT.1113.md-MT.1122.md)website/docs/connect-maester/readme.mdand the advanced connection docs with Dataverse sectionpowershell/public/maester/aiagent/Test-MtAIAgent*.md)Configuration
DataverseEnvironmentUrltotests/maester-config.jsonGlobalSettings (empty default)DormantAgentDaysconfig option (default: 180) for MT.1117New files
Modified files
How to test
Prerequisites
Az.Accountsmodule installedDataverseEnvironmentUrlset intests/Custom/maester-config.json:{ "GlobalSettings": { "DataverseEnvironmentUrl": "https://orgXXXXX.crmNN.dynamics.com" } }bot,botcomponent,systemuser, andconnectionreferencetables.Create an Application User in Power Platform
Maester Security Reader) with Organization-level Read on: Agent (bot), Agent component (botcomponent), User (systemuser), and Connection Reference (connectionreference)*Creating a custom role requires:
Configure Maester
Add the environment URL to
maester-config.json:{ "GlobalSettings": { "DataverseEnvironmentUrl": "https://org12345.crm.dynamics.com" } }Interactive testing
What to verify
Connect-Maester -Service Dataverseconnects and validates tokenDataverseEnvironmentUrlis not configuredReferences
Contribution Checklist
Before submitting this PR, please confirm you have completed the following:
/powershell/tests/pester.ps1on your local system.