Skip to content

26T1-BAC-TR-005 - Collector creation for SharePoint#136

Open
tinar10 wants to merge 4 commits into
mainfrom
feature/26T1-BAC-TR-005_Collector_creation_for_SharePoint
Open

26T1-BAC-TR-005 - Collector creation for SharePoint#136
tinar10 wants to merge 4 commits into
mainfrom
feature/26T1-BAC-TR-005_Collector_creation_for_SharePoint

Conversation

@tinar10
Copy link
Copy Markdown
Collaborator

@tinar10 tinar10 commented Mar 29, 2026

Summary of the Changes
The pull request introduces new SharePoint-specific collectors required for compliance scanning of Section 7 in Microsoft 365. Additionally, the connection method uses Microsoft Graph, with the necessary SharePoint API permissions enabled in Entra ID (Azure AD).

Components

  • /engine (collectors / policies)

Testing Done

  • Tested run locally

Rollback

  • Revert the commit changes

Screenshots

image

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: bd5fa11738

ℹ️ 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 +39 to +41
is_restricted(sharing_capability, normalized) if {
sharing_capability != null
not contains(normalized, "anyone")
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 Enforce organization-only sharing for control 7.2.4

This rule currently treats any value that does not contain "anyone" as compliant, so settings like externalUserSharingOnly or existingExternalUserSharingOnly will pass even though the control text in this file says the recommended state is Only people in your organization. In practice, tenants that still allow external sharing can be reported as compliant, which produces false positives for this benchmark check.

Useful? React with 👍 / 👎.

Comment on lines +45 to +47
"sharepoint_sharing_capability": tenant_settings.get(
"CoreSharingCapability",
tenant_settings.get("SharingCapability"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Read Graph sharePointSettings using camelCase fields

get_tenant_settings() returns the raw Microsoft Graph payload, but this collector only reads PascalCase keys (for example CoreSharingCapability/SharingCapability). With normal Graph responses (sharingCapability, oneDriveSharingCapability, etc.), these fields resolve to null, so site_sharing_settings loses the sharing configuration data and downstream evaluations from this collector cannot make accurate decisions.

Useful? React with 👍 / 👎.

@du-dhartley
Copy link
Copy Markdown
Collaborator

@tinar10 Did you need to assign any new permissions for this collector to work?

@du-dhartley
Copy link
Copy Markdown
Collaborator

It's worth reviewing the feedback that codex has added re casing

@du-dhartley du-dhartley self-assigned this Apr 7, 2026
@tinar10
Copy link
Copy Markdown
Collaborator Author

tinar10 commented Apr 17, 2026

@tinar10 Did you need to assign any new permissions for this collector to work?

Hi @du-dhartley , yes, needed to enable an additional Microsoft Graph API permission for this collector. Specifically, SharePointTenantSettings.Read.All was required to retrieve SharePoint tenant settings. Without it, some fields were returning null.

@tinar10
Copy link
Copy Markdown
Collaborator Author

tinar10 commented Apr 17, 2026

It's worth reviewing the feedback that codex has added re casing

sure, let me review and address the feedback from Codex.

@tinar10
Copy link
Copy Markdown
Collaborator Author

tinar10 commented Apr 20, 2026

@codex

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: 43206fa6d9

ℹ️ 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".


is_restricted(sharing_capability, normalized) if {
sharing_capability != null
not contains(normalized, "anyone")
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 Mark externalUserAndGuestSharing as non-compliant

is_restricted currently marks the control compliant for any non-null value that does not literally contain "anyone", but Microsoft Graph returns the Anyone-links state as externalUserAndGuestSharing; that string bypasses this check and causes false passes for tenants that still allow anonymous sharing. This affects control 7.2.3 accuracy and should be fixed by explicitly evaluating known enum values (or explicitly failing externalUserAndGuestSharing).

Useful? React with 👍 / 👎.

@tinar10
Copy link
Copy Markdown
Collaborator Author

tinar10 commented Apr 27, 2026

@codex

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: 3981f07318

ℹ️ 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 +50 to +53
is_restricted(sharing_capability, normalized) if {
sharing_capability != null
restricted_sharing_values[normalized]
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Make is_restricted return false for non-matching values

is_restricted is currently a partial rule, so when sharing_capability is null or a non-restricted value (for example the non-compliant externalUserAndGuestSharing case), compliant := is_restricted(...) becomes undefined and the result rule does not evaluate. In those paths the policy falls back to the default {"compliant": false, "message": "Evaluation failed"} and loses the intended control-specific message and affected resource details, which degrades scan accuracy and troubleshooting output.

Useful? React with 👍 / 👎.

@tinar10
Copy link
Copy Markdown
Collaborator Author

tinar10 commented Apr 27, 2026

@codex

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: 97d1d1d812

ℹ️ 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 +116 to +119
"onedrive_sharing_capability": self._first_present(
tenant_settings,
"OneDriveSharingCapability",
"oneDriveSharingCapability",
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 Populate OneDrive sharing capability from Graph response

SpoTenantDataCollector.collect now reads onedrive_sharing_capability only from OneDriveSharingCapability/oneDriveSharingCapability, but this collector is fed by SharePointClient.get_tenant_settings() (GET /admin/sharepoint/settings), whose Graph payload does not expose those keys. That means this field is always null, and 7.2.4_onedrive_content_sharing_restricted.rego will consistently evaluate as non-compliant/unknown after 7.2.4 was marked ready, creating false failures for all tenants.

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.

@tinar10 I haven't checked this particular case mentioned here but it seems like one to double check

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.

@tinar10 Can you please check the validity of this? Does the endpoint actually return this key?

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.

@du-dhartley , let me double check.

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.

@du-dhartley , validated this Graph response from GET /admin/sharepoint/settings. The response includes sharingCapability, but it does not include oneDriveSharingCapability or OneDriveSharingCapability.

This confirms that the current collector mapping will resolve onedrive_sharing_capability to NULL only when using this endpoint, so the control for 7.2.4 may produce false failures unless we identify another data source for the OneDrive-specific sharing setting.
image

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