Files
AiSOC/plugins
Beenu Arora a42feeb57b feat(connectors): the M365 audit DLP.All stream is a real per-instance switch (WS4.2) (#2004)
## What

WS4.2 of the gap-closure program. The `m365_audit` module docstring
promised *"DLP can be re-enabled per-instance later via
`connector_config` once the analyst opt-in path lands"* while
`_DEFAULT_CONTENT_TYPES` was hard-coded and the constructor accepted no
such setting — the aspirational-comment family. A tenant who wanted
Purview DLP events through the audit trail had no switch to flip.

## The change

- `schema()` declares **`include_dlp`** (boolean, default **off**) with
help text naming the volume cost and the stricter `ActivityFeed.ReadDlp`
permission that sensitive-data details require.
- The constructor accepts it; coercion follows the house `_truthy` rule
(the `wiz` connector's): a boolean from the wizard and a string from a
hand-written instance row mean the same thing, and **an unparseable
value means off** — a collector that defaults to on when it cannot read
its own switch is a poll the tenant did not ask for.
- `content_types()` replaces direct `_DEFAULT_CONTENT_TYPES` iteration
in both the subscription-start and content-listing loops; a transport
seam lets tests drive the real fetch path.
- Docs page corrected: it claimed *"the connector subscribes to all five
content types"*, which was false before this change and would have been
misleading after; it now states the four-by-default / opt-in-fifth truth
and what `ActivityFeed.ReadDlp` does and does not gate.
- Docstring rewritten to state what is true (the 'later' promise is
gone, and a test pins that).

## Testing (failing test first)

- `test_m365_audit_dlp_toggle.py` — **15 cases, all red on the
pre-change tree** (schema field absent, constructor rejects the kwarg,
fetch path unobservable): schema declares the field defaulting off; the
docstring no longer says 'later'; default polls exactly the four
`Audit.*` types; five truthy spellings enable `DLP.All`; six
garbage/falsy values mean off; and the fetch path is observed **at the
wire** — the mock Management API records the real HTTP requests and the
content-type selection is read off them, not off a constant.
- **Negative control**: forcing the coercion to always-`False` fails the
four enable cases (`4 failed, 11 passed`); restored, `15 passed`.
- Full connectors suite: **2040 passed, 3 skipped**. `ruff` clean,
`check_mypy_baseline` OK, `check_claim_gate_matrix` 408 rows / 399
GATED, `readme_gates` OK.

## Artifacts regenerated (not hand-edited)

`scripts/connector_conformance.py`,
`scripts/generate_connector_catalog_fallback.py`,
`scripts/generate_connector_docs.py`, `pnpm marketplace:sync` (the
`coverage.md` timestamp diff is the normal regeneration artifact).
`plugins/m365-audit/plugin.yaml` mirrors the schema field.

## Claim matrix

One new GATED row (the switch reaches the wire), tallies recomputed by
the script: 408 rows — 399 GATED / 9 PARTIAL / 0 NO GATE.
2026-11-22 14:29:19 -08:00
..