Skip to content

Reduce redundant Microsoft Graph requests during Conditional Access collection - #195

Merged
silverhack merged 1 commit into
silverhack:developfrom
0xDarknightHacks:perf/conditional-access-graph-requests
Sep 28, 2026
Merged

silverhack merged 1 commit into
silverhack:developfrom
0xDarknightHacks:perf/conditional-access-graph-requests

Conversation

@0xDarknightHacks

Copy link
Copy Markdown

Context

While profiling Monkey365 during Microsoft 365 security assessments, I noticed redundant Microsoft Graph requests being made during Conditional Access collection.

This PR focuses only on reducing those unnecessary requests. The goal is to avoid retrieving data that has already been collected or is already available during the same assessment, while preserving the existing Conditional Access collection behavior and output.

This change originally came from performance work I was doing in my own fork of Monkey365. I am submitting it separately so the optimization can be reviewed independently rather than proposing the broader set of performance changes at once.

Description

This PR removes redundant Microsoft Graph requests from the Conditional Access collection path and reuses the data already available to the collector where applicable.

The scope is intentionally narrow:

  • Reduce unnecessary Graph calls during Conditional Access collection.
  • Preserve the existing collected data and assessment behavior.
  • Avoid changes to unrelated collectors or workloads.
  • Keep the change aligned with the current Monkey365 v1.0.0 codebase.

This is a performance optimization rather than a fix for an existing reported issue, so there is no associated issue number.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions

Copy link
Copy Markdown
Contributor

Pull request targets main

This pull request cannot be merged because only the repository's
develop branch may be merged into main.

For a feature or bug fix, change the pull request's base branch to
develop. The maintainer will promote tested changes from develop
to main as part of the release process.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@0xDarknightHacks
0xDarknightHacks changed the base branch from main to develop September 26, 2026 20:56
@0xDarknightHacks
0xDarknightHacks force-pushed the perf/conditional-access-graph-requests branch from 027fa51 to bcfbdab Compare September 26, 2026 21:03
@silverhack

Copy link
Copy Markdown
Owner

Hi @0xDarknightHacks, thanks for submitting the pull request.

The collector that makes use of this helper function never calls it with -Detailed anyway, but I agree with the change. That flag would just end up adding redundant queries. Thanks for taking the time to review it! I’ll get this merged ASAP.

@silverhack
silverhack merged commit 1c23f5a into silverhack:develop Sep 28, 2026
1 check passed
@0xDarknightHacks

Copy link
Copy Markdown
Author

Thanks for pointing that out, and thanks for reviewing and merging this!

I completely missed that the collector never actually calls the helper with -Detailed. I had identified the redundant queries while tracing the helper and incorrectly assumed that path was exercised during the normal collection flow.

That's a useful catch on my side as well, I'll make sure to trace the actual collector call paths more carefully before proposing any of the other optimizations I've been experimenting with.

Really appreciate the feedback and the quick review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants