Skip to content

Implement CIS 1.3.7 - Third-party storage services restriction - #312

Open
UmerA3653 wants to merge 2 commits into
mainfrom
feature/1-3-7-third-party-storage
Open

Implement CIS 1.3.7 - Third-party storage services restriction#312
UmerA3653 wants to merge 2 commits into
mainfrom
feature/1-3-7-third-party-storage

Conversation

@UmerA3653

Copy link
Copy Markdown

Implements CIS control 1.3.7 (restrict third-party storage services in Microsoft 365 on the web).

While working on this, I found that metadata.json had 1.3.7 pointing to the wrong collector — it was set to the same collector used by control 6.5.3, but 1.3.7 actually needs to check something different (a service principal setting in Entra ID, not an Exchange setting). Confirmed this against the official CIS benchmark documentation.

What this PR adds:

  • A new collector for the Entra ID service principal check
  • A Rego policy for the control, plus unit tests
  • Registered the new collector
  • Updated metadata.json with the correct collector, permissions, and status

Tested and confirmed working:

  • Unit tests pass
  • Ran the full structural test suite, all passing
  • Ran a live scan against the test tenant and confirmed the control evaluates correctly

Summary

Implements control 1.3.7, including fixing an incorrect collector mapping found in metadata.json.

Type of Change

  • New feature
  • Bug fix

- metadata.json incorrectly mapped 1.3.7 to the OWA mailbox policy
  collector (which actually powers 6.5.3). Confirmed via CIS benchmark
  audit text that 1.3.7 checks the 'Third Party Storage Services'
  service principal in Entra ID instead.
- Add new Graph-based collector
  (entra.applications.third_party_storage_services)
- Add Rego policy + unit tests (4 cases, all passing)
- Update metadata.json: automation_status=ready, correct collector,
  policy_file, and requires_permissions
- Verified end-to-end via structural pytest suite (438 passed) and a
  live scan against the sandbox tenant
@UmerA3653
UmerA3653 requested a review from a team as a code owner August 2, 2026 16:20
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Preview Environment

A preview environment can be spun up on demand for this PR.

Action Label Includes
Spin up preview deploy-preview Frontend, backend, database, Redis, OPA, worker
Spin up preview with M365 deploy-preview-m365 Everything above + PowerShell service for Exchange/Teams scan testing
Tear down preview teardown-preview Stops the environment early

The environment will also be torn down automatically when the PR is closed or merged.
Preview URLs will appear in a follow-up comment once the deploy completes (~5–8 min).
M365 scans require real tenant credentials added through the frontend UI.

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

CI: Engine

Job Result
Security analysis (CodeQL) success
Lint failure
Tests success

One or more checks failed. View logs

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

Copy link
Copy Markdown

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: 664b49c06f

ℹ️ 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 +48 to +49
except Exception as exc:
collector_error = str(exc)

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 Preserve Graph errors instead of reporting a missing SP

When the /servicePrincipals request raises (for example because Application.Read.All was not consented, Graph throttles, or the network times out), this handler only records collector_error and leaves service_principal as None; the return below therefore sends service_principal_exists: false, and the new policy reports the control as a normal non-compliant tenant rather than letting evaluate_control retry or mark an error (engine/worker/tasks.py:299-310). That produces false compliance failures and misleading evidence for collection failures, so propagate the exception or model an explicit unknown/error state.

Useful? React with 👍 / 👎.

…arty-storage

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
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.

1 participant