Repository navigation
Feature/policy manager api - #239
Open
cx-happy-yang wants to merge 3 commits into
Open
cx-happy-yang wants to merge 3 commits into
cx-happy-yang wants to merge 3 commits into
Conversation
cx-happy-yang
commented
Nov 6, 2026
Contributor
- [Add] PolicyManagerAPI for the Cx Policy Manager REST API (/api/policy_management_service_uri) — tenant policies (create/get/update/delete, V2/V3 pagination, pin, project assignment), policy violations, per-scan policy evaluation, incidents (including the enhanced V2 view), incident results, and internal data-retention cleanup. 27 endpoints, 22 new DTOs.
|
Great job! No new security vulnerabilities introduced in this pull request |
cx-nathan-leach
previously approved these changes
Nov 11, 2026
Implements all 27 endpoints of POLICY_MANAGER.yaml
(/api/policy_management_service_uri), previously entirely unwrapped:
- Policies: create/get/update/delete (plus V2/V3 pagination variants),
pin/unpin, assign/remove projects, bulk delete, default policy.
- Projects: tenant projects and project tags as seen by Policy Manager.
- Policy violations and per-scan policy evaluation.
- Incidents: list/paginate/filter (including the enhanced V2 view with
engine info), total count, and per-incident results.
- Internal data-retention cleanup endpoints (implemented, but
deliberately not exercised in tests -- they delete data across
services tenant-wide).
22 new DTOs under CxOne/dto/, registered in dto/__init__.py and
CxOne/__init__.py following the existing dataclass+from_dict/to_dict
convention (see riskOrchestrationAPI.py / scaManagementOfRiskAPI.py).
Verified against the live spec server and a real tenant, which turned
up two spec-vs-reality mismatches fixed before landing:
- DELETE /policies/{id}, /policies (bulk), /policies/projects/{id}
actually respond 204 No Content, not the 200 the spec documents.
- POST /policies/v2 actually returns a bare int (the new policy ID),
not the PolicyShortWebDto object the spec documents.
tests/CxOne/test_policy_manager_api.py exercises the full
create/get/update/pin/assign/delete lifecycle live (always cleaning up
what it creates), following this suite's existing convention of
skipping gracefully on 400/401/403/404 (used here for incidents/scan
endpoints this tenant doesn't have data or a feature flag for). 15
passed, 3 skipped for exactly that reason.
Also adds docs/swagger_yaml/CxOne/POLICY_MANAGER.yaml as the spec this
implementation was built from.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
docs/CxOne_REST_API_List.md was stale on this branch -- its generator script only existed on the separate docs/refresh-cxone-api-reference branch, which none of the feature branches were based on. Brought the generator over (verbatim from that branch) and regenerated the list so it reflects what's actually on this branch: master's existing endpoints plus the new PolicyManagerAPI (27 endpoints).
cx-happy-yang
force-pushed
the
feature/policy-manager-api
branch
from
November 18, 2026 02:19
99177f4 to
05c106f
Compare
test_get_incident_results and test_get_policy_violations previously swallowed real conditions behind pytest.skip: - test_get_incident_results skipped silently when the tenant had no incidents, instead of surfacing that there was nothing to assert. - test_get_policy_violations caught ANY exception via _skip_on_client_error and skipped on 400/401/403/404, masking a real finding. Removed both skips and ran live to see the real state: - test_get_incident_results now fails with IndexError -- this tenant genuinely has zero policy incidents right now. Not an SDK bug. - test_get_policy_violations now fails with a real 404 'The provided project ID ... and scan ID ... do not match'. Confirmed via direct comparison that this is NOT an actual ID mismatch: get_evaluated_policies_by_scan_id_and_project_id succeeds with the exact same project_id/scan_id pair, returning PoliciesResultWebDto(status='NONE', policies=[]) -- i.e. this scan was simply never evaluated by any policy. The live Policy Manager service's /policy_violations endpoint returns a misleading 404 instead of an empty result for that case. SDK request (URL/params) is correct; this is a server-side quirk, not an SDK bug. Left both failing as an accurate reflection of current tenant state rather than restoring the skips -- CI (ci.yml) only runs build + pylint, not these live pytest suites, so this doesn't block merging.
Contributor
Author
|
Hi @cx-james-bostock , please help me approve. I just resolved a merge conflict. |
cx-james-bostock
approved these changes
Nov 18, 2026
cx-james-bostock
left a comment
Contributor
There was a problem hiding this comment.
Hi @cx-happy-yang,
Looks good to me.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
