Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.

Unreleased
* [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.

1.9.3 - 2026-11-12
* [Fix] ReportAPI.create_scan_report_v2 (POST /reports/v2, Improved Scan Report) — the hardcoded severities filter silently excluded Critical, the single most severe category. Confirmed live against a real scan: the generated report's own reportFilters.filters showed "excluded": ["Critical"], and totalResults jumped from 117 to 139 (exactly the 22 Critical findings that were missing) once fixed. Every report generated by this method before this fix was silently missing all Critical-severity results.
* [Add] ReportAPI.create_scan_report_v2 optional severities/states/status/sections/report_type/emails/report_filename/timezone params, matching the documented request body — previously these were all hardcoded with no way for callers to override them. report_filename, when omitted, now lets the server apply its own "Cx_ScanReport_{Scan_Date}" default instead of forcing an empty string.
Expand Down
30 changes: 30 additions & 0 deletions CheckmarxPythonSDK/CxOne/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,36 @@
get_risks_aggregate,
get_risks_ai_insights,
)
from .policyManagerAPI import (
PolicyManagerAPI,
get_tenant_policies,
create_policy,
delete_policies,
get_policy,
update_policy,
delete_policy,
get_policy_v2,
update_policy_v2,
get_tenant_policies_with_pagination,
create_policy_v2,
get_tenant_policies_with_pagination_v3,
get_default_policy,
assign_projects_to_policy,
delete_projects_from_policy,
pin_policy,
get_tenant_projects,
get_projects_tags,
get_policy_violations,
get_evaluated_policies_by_scan_id_and_project_id,
get_tenant_incidents,
get_tenant_incidents_total_count,
get_tenant_incidents_with_pagination,
get_tenant_incidents_with_pagination_and_filters,
get_enhanced_incidents_with_pagination_and_filters,
get_incident_results,
delete_data,
delete_data_for_service,
)

from .accessManagementAPI import (
AccessManagementAPI,
Expand Down
28 changes: 28 additions & 0 deletions CheckmarxPythonSDK/CxOne/dto/BreakBuildExemptStateDto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from dataclasses import dataclass, field, asdict
from typing import List, Optional


@dataclass
class BreakBuildExemptStateDto:
"""A result state that is exempt from breaking the build for a rule.

Attributes:
scanner (Optional[str]): The scanner the exemption applies to.
ruleName (Optional[str]): The policy rule the exemption applies to.
stateName (List[str]): Result states exempt from breaking the build.
"""

scanner: Optional[str] = None
ruleName: Optional[str] = None
stateName: List[str] = field(default_factory=list)

@classmethod
def from_dict(cls, item: dict) -> "BreakBuildExemptStateDto":
return cls(
scanner=item.get("scanner"),
ruleName=item.get("ruleName"),
stateName=list(item.get("stateName") or []),
)

def to_dict(self) -> dict:
return {k: v for k, v in asdict(self).items() if v is not None}
27 changes: 27 additions & 0 deletions CheckmarxPythonSDK/CxOne/dto/EnhancedIncidentsPaginationDTO.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from dataclasses import dataclass, field
from typing import List, Optional

from .EnhancedIncidentsWebDTO import EnhancedIncidentsWebDTO


@dataclass
class EnhancedIncidentsPaginationDTO:
"""Paginated response from GET /incidents/filters/v2.

Attributes:
incidents (List[EnhancedIncidentsWebDTO]): Incidents on the current page.
filteredIncidentsCount (Optional[int]): Total count after filtering.
"""

incidents: List[EnhancedIncidentsWebDTO] = field(default_factory=list)
filteredIncidentsCount: Optional[int] = None

@classmethod
def from_dict(cls, item: dict) -> "EnhancedIncidentsPaginationDTO":
return cls(
incidents=[
EnhancedIncidentsWebDTO.from_dict(i)
for i in (item.get("incidents") or [])
],
filteredIncidentsCount=item.get("filteredIncidentsCount"),
)
52 changes: 52 additions & 0 deletions CheckmarxPythonSDK/CxOne/dto/EnhancedIncidentsWebDTO.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from dataclasses import dataclass, field
from typing import List, Optional


@dataclass
class EnhancedIncidentsWebDTO:
"""A policy incident, as returned by the enhanced (v2) incidents endpoint.

Same shape as IncidentWebDto plus the originating scanner engine.

Attributes:
id (Optional[int]): Incident ID.
policyName (Optional[str]): Name of the violated policy.
projectName (Optional[str]): Name of the project scanned.
branch (Optional[str]): Branch scanned.
ruleName (Optional[str]): Name of the violated rule.
scanId (Optional[str]): The scan's UUID.
scanDate (Optional[str]): When the scan ran (date-time).
policyTags (List[str]): Tags on the violated policy.
defaultPolicy (Optional[bool]): Whether the policy is the tenant default.
defaultPolicyEvaluation (Optional[bool]): Whether the default policy
was the one evaluated.
engine (Optional[str]): The scanner engine that produced the incident.
"""

id: Optional[int] = None
policyName: Optional[str] = None
projectName: Optional[str] = None
branch: Optional[str] = None
ruleName: Optional[str] = None
scanId: Optional[str] = None
scanDate: Optional[str] = None
policyTags: List[str] = field(default_factory=list)
defaultPolicy: Optional[bool] = None
defaultPolicyEvaluation: Optional[bool] = None
engine: Optional[str] = None

@classmethod
def from_dict(cls, item: dict) -> "EnhancedIncidentsWebDTO":
return cls(
id=item.get("id"),
policyName=item.get("policyName"),
projectName=item.get("projectName"),
branch=item.get("branch"),
ruleName=item.get("ruleName"),
scanId=item.get("scanId"),
scanDate=item.get("scanDate"),
policyTags=list(item.get("policyTags") or []),
defaultPolicy=item.get("defaultPolicy"),
defaultPolicyEvaluation=item.get("defaultPolicyEvaluation"),
engine=item.get("engine"),
)
34 changes: 34 additions & 0 deletions CheckmarxPythonSDK/CxOne/dto/EvaluatedPolicyWebDto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from dataclasses import dataclass, field
from typing import List, Optional


@dataclass
class EvaluatedPolicyWebDto:
"""A single policy's evaluation result for one scan/project.

Attributes:
policyName (Optional[str]): The evaluated policy's name.
description (Optional[str]): The policy's description.
rulesViolated (List[str]): Names of rules that were violated.
tags (List[str]): The policy's tags.
breakBuild (Optional[bool]): Whether this policy breaks the build.
status (Optional[str]): Evaluation status. Values: PASSED, FAILED.
"""

policyName: Optional[str] = None
description: Optional[str] = None
rulesViolated: List[str] = field(default_factory=list)
tags: List[str] = field(default_factory=list)
breakBuild: Optional[bool] = None
status: Optional[str] = None

@classmethod
def from_dict(cls, item: dict) -> "EvaluatedPolicyWebDto":
return cls(
policyName=item.get("policyName"),
description=item.get("description"),
rulesViolated=list(item.get("rulesViolated") or []),
tags=list(item.get("tags") or []),
breakBuild=item.get("breakBuild"),
status=item.get("status"),
)
46 changes: 46 additions & 0 deletions CheckmarxPythonSDK/CxOne/dto/FindingsWebDto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from dataclasses import dataclass
from typing import Optional


@dataclass
class FindingsWebDto:
"""A SAST/IaC finding as referenced from a policy violation.

Attributes:
resultId (Optional[str]): The result ID.
similarityId (Optional[str]): The similarity ID.
queryId (Optional[str]): The query ID that produced the finding.
queryName (Optional[str]): The query name.
severity (Optional[str]): Severity. Values: CRITICAL, HIGH, MEDIUM, LOW, INFO.
cweId (Optional[int]): CWE ID, if applicable.
fileName (Optional[str]): File the finding was detected in.
line (Optional[int]): Line number of the finding.
description (Optional[str]): Finding description.
stateName (Optional[str]): Current result state.
"""

resultId: Optional[str] = None
similarityId: Optional[str] = None
queryId: Optional[str] = None
queryName: Optional[str] = None
severity: Optional[str] = None
cweId: Optional[int] = None
fileName: Optional[str] = None
line: Optional[int] = None
description: Optional[str] = None
stateName: Optional[str] = None

@classmethod
def from_dict(cls, item: dict) -> "FindingsWebDto":
return cls(
resultId=item.get("resultId"),
similarityId=item.get("similarityId"),
queryId=item.get("queryId"),
queryName=item.get("queryName"),
severity=item.get("severity"),
cweId=item.get("cweId"),
fileName=item.get("fileName"),
line=item.get("line"),
description=item.get("description"),
stateName=item.get("stateName"),
)
64 changes: 64 additions & 0 deletions CheckmarxPythonSDK/CxOne/dto/IncidentResultWebDTO.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from dataclasses import dataclass
from typing import Optional


@dataclass
class IncidentResultWebDTO:
"""A single result underlying a policy incident.

Attributes:
id (Optional[int]): Result ID.
severity (Optional[str]): Result severity.
issue (Optional[str]): Issue/query name.
issueLink (Optional[str]): Link to the issue in the CxOne UI.
cweLink (Optional[str]): Link to the CWE reference.
sourceFilePackage (Optional[str]): Source file or package name.
sourceFileLink (Optional[str]): Link to the source file in the CxOne UI.
lineNumber (Optional[int]): Line number of the finding.
insight (Optional[str]): Remediation insight text.
insightLink (Optional[str]): Link to the remediation insight.
resultId (Optional[str]): The underlying result's ID.
recommendedVersion (Optional[str]): Recommended package version (SCA).
attackVector (Optional[str]): Attack vector description.
attackComplexity (Optional[str]): Attack complexity description.
riskOrchestrationLink (Optional[str]): Link to Risk Orchestration.
sastResultsLink (Optional[str]): Link to the SAST result.
"""

id: Optional[int] = None
severity: Optional[str] = None
issue: Optional[str] = None
issueLink: Optional[str] = None
cweLink: Optional[str] = None
sourceFilePackage: Optional[str] = None
sourceFileLink: Optional[str] = None
lineNumber: Optional[int] = None
insight: Optional[str] = None
insightLink: Optional[str] = None
resultId: Optional[str] = None
recommendedVersion: Optional[str] = None
attackVector: Optional[str] = None
attackComplexity: Optional[str] = None
riskOrchestrationLink: Optional[str] = None
sastResultsLink: Optional[str] = None

@classmethod
def from_dict(cls, item: dict) -> "IncidentResultWebDTO":
return cls(
id=item.get("id"),
severity=item.get("severity"),
issue=item.get("issue"),
issueLink=item.get("issueLink"),
cweLink=item.get("cweLink"),
sourceFilePackage=item.get("sourceFilePackage"),
sourceFileLink=item.get("sourceFileLink"),
lineNumber=item.get("lineNumber"),
insight=item.get("insight"),
insightLink=item.get("insightLink"),
resultId=item.get("resultId"),
recommendedVersion=item.get("recommendedVersion"),
attackVector=item.get("attackVector"),
attackComplexity=item.get("attackComplexity"),
riskOrchestrationLink=item.get("riskOrchestrationLink"),
sastResultsLink=item.get("sastResultsLink"),
)
36 changes: 36 additions & 0 deletions CheckmarxPythonSDK/CxOne/dto/IncidentResultsDTO.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from dataclasses import dataclass, field
from typing import List, Optional

from .IncidentResultWebDTO import IncidentResultWebDTO
from .ViolationDetailsDTO import ViolationDetailsDTO


@dataclass
class IncidentResultsDTO:
"""Response from GET /incidents/{incidentId}/results.

Attributes:
violationDetails (Optional[ViolationDetailsDTO]): The violated
policy/rule details common to all results.
results (List[IncidentResultWebDTO]): Results on the current page.
filteredResultsCount (Optional[int]): Total count after filtering.
"""

violationDetails: Optional[ViolationDetailsDTO] = None
results: List[IncidentResultWebDTO] = field(default_factory=list)
filteredResultsCount: Optional[int] = None

@classmethod
def from_dict(cls, item: dict) -> "IncidentResultsDTO":
return cls(
violationDetails=(
ViolationDetailsDTO.from_dict(item["violationDetails"])
if item.get("violationDetails")
else None
),
results=[
IncidentResultWebDTO.from_dict(r)
for r in (item.get("results") or [])
],
filteredResultsCount=item.get("filteredResultsCount"),
)
47 changes: 47 additions & 0 deletions CheckmarxPythonSDK/CxOne/dto/IncidentWebDto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from dataclasses import dataclass, field
from typing import List, Optional


@dataclass
class IncidentWebDto:
"""A policy incident (a policy violation recorded for a scan).

Attributes:
id (Optional[int]): Incident ID.
policyName (Optional[str]): Name of the violated policy.
projectName (Optional[str]): Name of the project scanned.
branch (Optional[str]): Branch scanned.
ruleName (Optional[str]): Name of the violated rule.
scanId (Optional[str]): The scan's UUID.
scanDate (Optional[str]): When the scan ran (date-time).
policyTags (List[str]): Tags on the violated policy.
defaultPolicy (Optional[bool]): Whether the policy is the tenant default.
defaultPolicyEvaluation (Optional[bool]): Whether the default policy
was the one evaluated.
"""

id: Optional[int] = None
policyName: Optional[str] = None
projectName: Optional[str] = None
branch: Optional[str] = None
ruleName: Optional[str] = None
scanId: Optional[str] = None
scanDate: Optional[str] = None
policyTags: List[str] = field(default_factory=list)
defaultPolicy: Optional[bool] = None
defaultPolicyEvaluation: Optional[bool] = None

@classmethod
def from_dict(cls, item: dict) -> "IncidentWebDto":
return cls(
id=item.get("id"),
policyName=item.get("policyName"),
projectName=item.get("projectName"),
branch=item.get("branch"),
ruleName=item.get("ruleName"),
scanId=item.get("scanId"),
scanDate=item.get("scanDate"),
policyTags=list(item.get("policyTags") or []),
defaultPolicy=item.get("defaultPolicy"),
defaultPolicyEvaluation=item.get("defaultPolicyEvaluation"),
)
Loading