Skip to content

Add Rego policy for CIS 1.3.3 (external calendar sharing)#196

Open
williamywccc wants to merge 2 commits into
mainfrom
feature/add-cis-1.3.3-policy
Open

Add Rego policy for CIS 1.3.3 (external calendar sharing)#196
williamywccc wants to merge 2 commits into
mainfrom
feature/add-cis-1.3.3-policy

Conversation

@williamywccc
Copy link
Copy Markdown
Collaborator

Summary

  • Implements the Rego policy for CIS Microsoft 365 Foundations v6.0.0 control 1.3.3
  • Rewrites the sharing_policy collector to produce structured, per-entry violation data instead of a flat boolean
  • Adds a sample JSON file for manual OPA eval testing

How it works

Get-SharingPolicy returns a Domains field as a list of domain:Capability pairs. The collector parses each entry and flags those where the domain component is Anonymous or * (wildcard) paired with a CalendarSharing* capability on an enabled policy. Named external SMTP domains are not classified as violations.

The Rego policy checks calendar_sharing_violations from the collector output and surfaces each offending entry as an affected resource.

Notes

There is an existing branch Arvinder/CIS-M365-1-3-3-and-1-3-6 that covers the same control. Please coordinate with Arvinder before merging to avoid conflicts.

Test plan

  • Run opa eval with engine/samples/exchange_organization_sharing_policy_sample.json to verify non-compliant path
  • Run opa eval with an input where calendar_sharing_violations is empty to verify compliant path
  • Verify against a live tenant once Exchange PowerShell permissions are available

Made with Cursor

Rewrites the sharing_policy collector to produce structured violation data:
each SharingPolicy Domains entry is parsed as a domain:Capability pair,
and entries using Anonymous or wildcard (*) domains with CalendarSharing
capabilities are flagged as non-compliant. Named SMTP partner domains are
not evaluated.

The Rego policy (1.3.3_external_calendar_sharing.rego) checks
calendar_sharing_violations from the collector output and reports
each violating domain entry as an affected resource.

Includes a sample JSON file for manual OPA eval testing.

Made-with: Cursor
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3fd9fea956

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +63 to +67
if low == "anonymous":
return "anonymous_calendar_sharing"
if low == "*":
return "wildcard_calendar_sharing"
return None
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Treat all external calendar domains as violations

Control 1.3.3 requires external calendar sharing to be unavailable, but this logic only flags Anonymous and * domains and returns None for named domains. A policy like partner.com:CalendarSharingFreeBusySimple still enables sharing with users outside the organization, yet this collector will report no violation and the new Rego policy will mark the control compliant. That creates a false-negative compliance result for tenants that allow calendar sharing to specific external domains.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is valid and should be addressed.

Copy link
Copy Markdown
Collaborator

@du-dhartley du-dhartley left a comment

Choose a reason for hiding this comment

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

@williamywccc If there was a known conflict with another branch, why was this PR created?
Aside from that, there are a couple of issues that need to be resolved, however the known and expected conflict should be resolved before either branch have updates applied.

We should also demonstrate expected and matched pass/fail results by settings values to invalid and then valid settings, shown by scans.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Was this file produced by a tool or by a real API?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This data was produced by running the data collector against the real live test tenant API. I am double checking to ensure the absolute latest real output is committed



class SharingPolicyDataCollector(BasePowerShellCollector):
"""Collects sharing policy settings for CIS compliance evaluation.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Docstrings have been removed, please add these back to the class

class SharingPolicyDataCollector(BasePowerShellCollector):

async def collect(self, client: PowerShellClient) -> dict[str, Any]:
"""Collect sharing policy data.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please restore the docstrings - updates are ok but these should be present.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

My apologies! I accidentally deleted the docstrings while cleaning up the code earlier. I am putting them back right now.

Restore class and collect method docstrings that were accidentally removed.
Replace placeholder sample JSON with real output from live sandbox tenant.

Co-authored-by: Cursor <cursoragent@cursor.com>
@williamywccc
Copy link
Copy Markdown
Collaborator Author

PR196_Fail_Result PR196_Pass_Result

The above are pass/fail results

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