Skip to content

feat(scanner): add enterprise security operations rules - #274

Open
TFT444 wants to merge 3 commits into
devfrom
feat/262-security-operations-rules
Open

feat(scanner): add enterprise security operations rules#274
TFT444 wants to merge 3 commits into
devfrom
feat/262-security-operations-rules

Conversation

@TFT444

@TFT444 TFT444 commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements issue #262 as a policy-driven Azure security-operations rule pack covering subscription logging, critical-resource diagnostics, retention, Defender for Cloud operational coverage, and Microsoft Sentinel detection and response readiness.

What changed

  • Added AZ-SECOPS-001 through AZ-SECOPS-010 with explicit fail-closed collection behavior.
  • Added read-only collectors for Azure Monitor, Defender for Cloud, Log Analytics, and Microsoft Sentinel.
  • Added organisation-owned policy configuration with no automatic production defaults.
  • Added one CLI remediation playbook per rule.
  • Added CIS Azure, NIST CSF, ISO 27001, and SOC 2 mappings without inventing unsupported CIS control IDs.
  • Added documentation covering scope, permissions, outcomes, limitations, and evidence behavior.
  • Added regression coverage ensuring incomplete Sentinel evidence returns UNKNOWN rather than a false FAIL.

Validation

  • Security-operations tests: 84 passed.
  • Ruff: passed.
  • Ruff formatting check: 261 files formatted.
  • Full local suite: 639 passed, 3 skipped, 1 unrelated local failure caused by a pre-existing Chroma package mismatch in the shared virtual environment.
  • Preliminary live, read-only Azure validation completed against an Azure student subscription:
    • Defender plans: 18 collected.
    • Defender assessments: 17 collected.
    • Log Analytics workspaces: 1 collected.
    • Sentinel onboarding: 1 workspace confirmed.
    • Sentinel analytics rules: 1 collected.
    • Sentinel data connectors and automation rules: successfully queried.
    • All ten rules executed with zero execution errors and zero Azure write operations.

Validation limits

The student subscription contained no in-scope Key Vault, SQL, or Storage resources, so controls 003-005 still require representative enterprise-resource validation. Control 007 also requires a high-severity unhealthy Defender assessment with usable age evidence to validate the complete SLA path. This preliminary test is integration evidence, not final enterprise acceptance certification.

Closes #262

TFT444 added 3 commits August 13, 2026 14:21
Signed-off-by: Tanvir Farhad <tamimtarafder12@gmail.com>
…262)

Implements the ten AZ-SECOPS controls on top of the issue #262 collection
foundation (fe172ce): activity-log export and category coverage, critical
resource diagnostics, log retention and destination-ownership checks,
Defender for Cloud plan coverage and recommendation SLA, and Microsoft
Sentinel connector health, analytics coverage, and incident-response
notification destinations.

- Extends scanner/security_operations.py with Defender pricing/assessments
  collectors and Sentinel auto-discovery: every Log Analytics workspace is
  enumerated subscription-wide, then checked individually for Sentinel
  onboarding, so scope is discovered rather than configured. Adds a PARTIAL
  CollectionStatus for this per-workspace fan-out so a permission failure on
  one workspace doesn't discard evidence from every other workspace.
- Adds ten rule modules (AZ-SECOPS-001..010) under scanner/rules/, each
  reading its policy from OPENSHIELD_SECURITY_OPERATIONS_POLICY and
  representing PASS/NOT_APPLICABLE/UNKNOWN as an empty findings list with a
  log line (matching the existing az_dl_00x/az_kv_003 convention) so
  engine.py's findings-list contract needs no changes. FAIL findings carry
  scope, destination, retention, ownership, evidence timestamp, permissions,
  and an explicit unknown_reason field in metadata.
- Adds a CLI remediation playbook per rule under playbooks/cli/.
- Adds real, researched CIS Azure Foundations Benchmark v2.0, NIST CSF v1.1,
  ISO 27001:2013, and SOC 2 mappings for all ten rules in
  compliance/frameworks/*.json. Three controls (log-destination ownership,
  Sentinel connector health, Sentinel analytics coverage) have no dedicated
  CIS benchmark control and use the existing N/A-<RULE_ID> convention rather
  than a fabricated match.
- Adds unit tests covering complete/incomplete diagnostics, category
  matching, retention boundaries, destination ownership, Defender pricing
  tiers and SLA age (including the no-timestamp case), Sentinel connector
  and analytics states, action-group/automation-rule alternatives, empty
  inventories, approved exclusions, and permission/API failures.
- Updates docs/security-operations-rules.md with per-rule documentation and
  documents the findings-list outcome model as a known limitation.

Signed-off-by: Tanvir Farhad <tamimtarafder12@gmail.com>
Signed-off-by: Tanvir Farhad <tamimtarafder12@gmail.com>
@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails
pip/azure-mgmt-loganalytics 14.0.0 UnknownUnknown
pip/azure-mgmt-security 7.0.0 🟢 6.9
Details
CheckScoreReason
Code-Review🟢 9Found 21/22 approved changesets -- score normalized to 9
Maintained🟢 1030 commit(s) and 5 issue activity found in the last 90 days -- score normalized to 10
CII-Best-Practices🟢 5badge detected: Passing
Security-Policy🟢 10security policy file detected
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Packaging⚠️ -1packaging workflow not detected
License🟢 10license file detected
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
Signed-Releases⚠️ -1no releases found
Branch-Protection🟢 5branch protection is not maximal on development and all release branches
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0
Binary-Artifacts🟢 8binaries present in source code
Pinned-Dependencies🟢 4dependency not pinned by hash detected -- score normalized to 4
Fuzzing🟢 10project is fuzzed
pip/azure-mgmt-securityinsight 1.0.0 🟢 6.9
Details
CheckScoreReason
Code-Review🟢 9Found 21/22 approved changesets -- score normalized to 9
Maintained🟢 1030 commit(s) and 5 issue activity found in the last 90 days -- score normalized to 10
CII-Best-Practices🟢 5badge detected: Passing
Security-Policy🟢 10security policy file detected
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Packaging⚠️ -1packaging workflow not detected
License🟢 10license file detected
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
Signed-Releases⚠️ -1no releases found
Branch-Protection🟢 5branch protection is not maximal on development and all release branches
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0
Binary-Artifacts🟢 8binaries present in source code
Pinned-Dependencies🟢 4dependency not pinned by hash detected -- score normalized to 4
Fuzzing🟢 10project is fuzzed

Scanned Files

  • requirements.txt

@TFT444
TFT444 requested review from m-khan-97 and removed request for SHAURYAKSHARMA24 and parthrohit22 August 13, 2026 23:27
@TFT444

TFT444 commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator Author

10 security operations rules in one PR, including Sentinel, three Azure SDK integrations, Defender for Cloud and live read-only Azure testing.

real environment test passed

openshield azure proof

@m-khan-97 m-khan-97 left a comment

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.

Large PR, reviewed thoroughly — fetched the branch, installed the missing azure-mgmt-monitor dependency, and ran all 84 tests (pass). This is genuinely strong engineering, worth calling out specifically:

  • Fail-safe policy loading is correctly threaded end-to-end. load_policy_from_env never raises — unset env var, missing file, or failed strict validation all collapse to None, and every rule treats None as UNKNOWN (empty list, no finding) rather than silently claiming compliance. Traced this through AZ-SECOPS-001 to confirm the contract actually holds in a real rule, not just in the docstring.
  • CollectionResult's PARTIAL status is a genuinely useful addition for the Sentinel per-workspace collectors — distinguishing "workspace confirmed not onboarded" from "workspace onboarding state unknown" is exactly the right nuance for a security tool, and failed_scopes is threaded through so callers can't accidentally conflate the two.
  • Compliance JSON completeness is correct this time — verified all 10 AZ-SECOPS rules present in all 4 framework JSONs with matching keys, learning from the gap in the earlier resilience-rules round.
  • load_security_operations_policy's strict validation (exact field-set match, positive-integer checks, non-empty-string list validation) means a malformed policy file fails loudly at load time rather than silently producing wrong results downstream.
  • Good honesty in the module docstring about the engine's real limitation (no side-channel for PASS/UNKNOWN/NOT_APPLICABLE) rather than hacking around it — and reusing the existing az_dl_00x/az_kv_003 convention instead of inventing a fourth pattern.

One minor, non-blocking gap: OPENSHIELD_SECURITY_OPERATIONS_POLICY is documented in docs/security-operations-rules.md but not mentioned in .env.example. Since all 10 rules are silently inert (always UNKNOWN) until this is set, someone skimming .env.example for what to configure could miss that this whole rule pack needs activating. Worth a one-line addition in a follow-up.

Approving.

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.

Implement enterprise logging, detection, and security operations rules

2 participants