Skip to content

feat(cis): automate control 5.1.4.2 device limit - #328

Open
karansoni15-create wants to merge 1 commit into
mainfrom
karan/5.1.4.2-device-limit
Open

feat(cis): automate control 5.1.4.2 device limit#328
karansoni15-create wants to merge 1 commit into
mainfrom
karan/5.1.4.2-device-limit

Conversation

@karansoni15-create

@karansoni15-create karansoni15-create commented Aug 16, 2026

Copy link
Copy Markdown

Summary

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor / code cleanup
  • Documentation
  • CI/CD / infrastructure
  • Security

Affected Components

  • /backend-api
  • /frontend
  • /engine (collectors / policies)
  • /security
  • /infrastructure
  • /.github/workflows
  • /docs

Motivation

Testing Done

  • Unit tests pass locally
  • Tested manually — describe how:
  • No tests required — explain why:

Security Considerations

Breaking Changes

  • No breaking changes
  • Yes — describe below:

Rollback Plan

  • Revert commit is sufficient
  • Requires additional steps — describe below:

Checklist

  • Code follows project conventions
  • No secrets, credentials, or tokens committed
  • Relevant documentation updated (if applicable)
  • CI/CD workflows pass on this branch
  • PR is focused on one thing

Screenshots

Copilot AI lite review requested due to automatic review settings August 16, 2026 03:38
@karansoni15-create
karansoni15-create requested a review from a team as a code owner August 16, 2026 03:38
@github-actions

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

Copy link
Copy Markdown
Contributor

CI: Engine

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

All checks passed.

Copilot AI 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.

Pull request overview

Automates CIS Microsoft 365 Foundations v6.0.0 control 5.1.4.2 by wiring it to the Entra device registration policy collector and adding a Rego policy (plus tests) to evaluate whether the per-user device registration quota stays within the CIS-recommended limit.

Changes:

  • Mark control 5.1.4.2 as automated/ready in benchmark metadata and point it at entra.devices.device_registration_policy.
  • Add a new Rego policy implementing compliance logic for the max-devices-per-user quota.
  • Add Rego tests covering compliant/non-compliant and missing/null quota scenarios.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
engine/tests/test_cis_5_1_4_2_max_devices_per_user.rego Adds OPA/Rego test cases for the new control logic.
engine/policies/cis/microsoft-365-foundations/v6.0.0/metadata.json Wires control 5.1.4.2 to the correct collector, policy file, and permission scope.
engine/policies/cis/microsoft-365-foundations/v6.0.0/5.1.4.2_max_devices_per_user.rego Implements the automated compliance evaluation and result payload for control 5.1.4.2.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +14 to +15
# requires_permissions:
# - Policy.Read.All
Comment on lines +43 to +48
test_non_compliant_missing_quota if {
result := data.cis.microsoft_365_foundations.v6_0_0.control_5_1_4_2.result with input as {}

result.compliant == false
result.message == "Unable to determine maximum devices per user"
}
Comment on lines +22 to +46

compliant if {
input.user_device_quota != null
is_number(input.user_device_quota)
input.user_device_quota <= 20
}

result := {
"compliant": compliant,
"message": message,
"details": {
"user_device_quota": object.get(input, "user_device_quota", null),
"recommended_maximum": 20,
},
}

message := "Maximum devices per user is within the CIS recommended limit" if {
compliant
}

message := "Maximum devices per user exceeds the CIS recommended limit" if {
input.user_device_quota != null
is_number(input.user_device_quota)
input.user_device_quota > 20
}

@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: ba9d11bfb7

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

# severity: medium
# service: EntraID
# requires_permissions:
# - Policy.Read.All

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 Declare the device-configuration permission in the policy

When policy annotations are inspected or copied—a supported workflow in engine/policies/README.md—this advertises Policy.Read.All, but the selected collector calls /beta/policies/deviceRegistrationPolicy, and both its module documentation and this control's metadata.json require Policy.Read.DeviceConfiguration. A tool provisioning scopes from the embedded annotation can therefore grant the wrong permission and make this newly ready control fail during collection; keep the annotation synchronized with the collector and benchmark metadata.

Useful? React with 👍 / 👎.

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