Skip to content

Conversation

@andoniaf
Copy link
Member

@andoniaf andoniaf commented Jan 20, 2026

Context

Adds a new security check defender_safelinks_policy_enabled for the m365 provider.

Description

This PR adds a new security check for m365:

  • Check: defender_safelinks_policy_enabled
  • Implementation: New check that detects security misconfigurations
  • Tests: Unit tests covering pass, fail, and no-resources scenarios

Steps to review

  1. Review the check implementation at prowler/providers/m365/services/defender/defender_safelinks_policy_enabled/
  2. Review the metadata file for correct severity, remediation, and compliance mappings
  3. Run the check tests: poetry run pytest tests/providers/m365/services/defender/defender_safelinks_policy_enabled/ -v
  4. Optionally run the check against a test environment

Checklist

Community Checklist
  • This feature/issue is listed in here or roadmap.prowler.com
  • Is it assigned to me, if not, request it via the issue/feature in here or Prowler Community Slack

SDK/CLI

  • Are there new checks included in this PR? Yes
    • If so, do we need to update permissions for the provider? Please review this carefully.

License

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

Add new security check defender_safelinks_policy_enabled for m365 provider.
Includes check implementation, metadata, and unit tests.

Related: https://prowlerpro.atlassian.net/browse/PROWLER-707
@andoniaf andoniaf requested review from a team as code owners January 20, 2026 07:42
@github-actions github-actions bot added provider/m365 Issues/PRs related with the M365 provider metadata-review labels Jan 20, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 20, 2026

Conflict Markers Resolved

All conflict markers have been successfully resolved in this pull request.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 20, 2026

✅ All necessary CHANGELOG.md files have been updated.

@codecov
Copy link

codecov bot commented Jan 20, 2026

Codecov Report

❌ Patch coverage is 87.50000% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.56%. Comparing base (6c6a6c5) to head (2b37a20).

❗ There is a different number of reports uploaded between BASE (6c6a6c5) and HEAD (2b37a20). Click for more details.

HEAD has 4 uploads less than BASE
Flag BASE (6c6a6c5) HEAD (2b37a20)
prowler-py3.10-azure 1 0
prowler-py3.11-azure 1 0
prowler-py3.12-azure 1 0
prowler-py3.9-azure 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #9832       +/-   ##
===========================================
- Coverage   86.60%   76.56%   -10.04%     
===========================================
  Files         222      177       -45     
  Lines        5645     9632     +3987     
===========================================
+ Hits         4889     7375     +2486     
- Misses        756     2257     +1501     
Flag Coverage Δ
prowler-py3.10-azure ?
prowler-py3.10-lib 76.50% <87.50%> (?)
prowler-py3.10-m365 88.62% <88.96%> (?)
prowler-py3.11-azure ?
prowler-py3.11-lib 76.50% <87.50%> (?)
prowler-py3.11-m365 88.62% <88.96%> (?)
prowler-py3.12-azure ?
prowler-py3.12-lib 76.50% <87.50%> (?)
prowler-py3.12-m365 88.62% <88.96%> (?)
prowler-py3.9-azure ?
prowler-py3.9-lib 76.56% <87.50%> (?)
prowler-py3.9-m365 88.78% <88.96%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
prowler 76.56% <87.50%> (-10.04%) ⬇️
api ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 20, 2026

🔒 Container Security Scan

Image: prowler:3b238cf
Last scan: 2026-01-23 14:12:38 UTC

📊 Vulnerability Summary

Severity Count
🔴 Critical 3
Total 3

3 package(s) affected

⚠️ Action Required

Critical severity vulnerabilities detected. These should be addressed before merging:

  • Review the detailed scan results
  • Update affected packages to patched versions
  • Consider using a different base image if updates are unavailable

📋 Resources:

@andoniaf andoniaf changed the title feat(m365): add defender_safelinks_policy_enabled security check Draft: feat(m365): add defender_safelinks_policy_enabled security check Jan 20, 2026
@andoniaf andoniaf changed the title Draft: feat(m365): add defender_safelinks_policy_enabled security check feat(m365): add defender_safelinks_policy_enabled security check Jan 20, 2026
@andoniaf andoniaf marked this pull request as draft January 20, 2026 08:25
@andoniaf andoniaf marked this pull request as ready for review January 20, 2026 10:46
@andoniaf andoniaf marked this pull request as draft January 20, 2026 11:59
@andoniaf andoniaf marked this pull request as ready for review January 20, 2026 15:29
Copy link
Member

@HugoPBrito HugoPBrito left a comment

Choose a reason for hiding this comment

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

Please also map the check with the corresponding compliances.

f"or insufficient permissions. Related checks will be skipped."
)
else:
logger.error(f"PowerShell error output: {error_result}")
Copy link
Member

Choose a reason for hiding this comment

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

Since this is an error for a Microsoft specific module, I would add this logic to m365_powershell.py and I would leave this file untouched. We could even add it to all calls having a method that does that.

It returns the original PowerShell error (as it is intended to). Specific integration messages should be in the inteegration file m365_powershell.py.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

andoniaf added a commit that referenced this pull request Jan 23, 2026
Address PR #9832 review feedback:
- Update CHANGELOG entry to 5.18.0 section
- Revert powershell.py to simple error logging
- Override read_output() in M365PowerShell with M365-specific cmdlet
  error handling for missing licensing scenarios
@andoniaf andoniaf requested a review from HugoPBrito January 23, 2026 13:24
result = default

if error_result:
self._process_m365_error(error_result)
Copy link
Member

Choose a reason for hiding this comment

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

Please, recreate this method (_process_m365_error) in the original powerhsell.py file, keeping the original handling.

Then, create an @override to that function here. That way we enhance original integration scalability and avoid repeating a lot of code, ensuring best practices.

…override pattern

- Create _process_error() method in base PowerShellSession class with generic
  error messaging for missing cmdlets
- Add @OverRide _process_error() in M365PowerShell class with M365-specific
  messaging about Microsoft Defender for Office 365 licensing
- Update changelog with defender_safelinks_policy_enabled entry in v5.18.0
@andoniaf andoniaf force-pushed the feat/PROWLER-707-test branch from 0b978d0 to 2b37a20 Compare January 23, 2026 14:03
@andoniaf andoniaf requested a review from HugoPBrito January 23, 2026 14:06
@@ -0,0 +1,40 @@
{
"Provider": "m365",
"CheckID": "defender_safelinks_policy_enabled",
Copy link
Member

Choose a reason for hiding this comment

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

Please map the check with its compliance requirements.


findings.append(report)

# Multiple Safe Links Policies
Copy link
Member

Choose a reason for hiding this comment

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

Same thing as #9833 (comment). We should handle with distinction between default, non default, its coverage and priority.

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

Labels

metadata-review provider/m365 Issues/PRs related with the M365 provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants