Skip to content

Commit

Permalink
chore: fill out api_mapping in progress, remove coverage from precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
patrcoff committed May 22, 2024
1 parent 5d7cd20 commit 6124a51
Show file tree
Hide file tree
Showing 4 changed files with 279 additions and 14 deletions.
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ repos:
name: Run pylint
entry: ./run_pylint.sh
stage: [commit]
- id: coverage
name: coverage
stages: [commit]
language: system
entry: coverage report --fail-under=50 --omit __init__.py
types: [python]
pass_filenames: false
# - id: coverage
# name: coverage
# stages: [commit]
# language: system
# entry: coverage report --fail-under=50 --omit __init__.py
# types: [python]
# pass_filenames: false
4 changes: 2 additions & 2 deletions research scripts/api_url_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

for link in links:
href = link.get("href")
if href not in ["http://www.ivanti.com/en-US/company/legal", "#", None]:
if href not in ["https://www.ivanti.com/en-US/company/legal", "#", None]:
# print("|"+href+"|")
endpoints.append(href)
output = []
Expand All @@ -35,7 +35,7 @@
else:
output.append(endpoint_base_url.strip())
except AttributeError:
print("attempted item endpoint_url")
print(f"attempted item {endpoint_url}")

with open("base_urls.txt", "w+") as f:
for url in sorted(output, key=lambda x: x.split("v1.0/")[-1]):
Expand Down
164 changes: 159 additions & 5 deletions src/isecapipy/api_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,27 +342,181 @@ def placeholder():
"distributionservers": {
"base_url": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/distributionservers"
}
},
"get": {
"all": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/distributionservers",
"params": None,
"request_body": None,
"response": (list, ResponseModels.DistributionServers),
},
"one": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/distributionservers/"
"{id}",
"params": None,
"request_body": None,
"response": ResponseModels.DistributionServers,
},
},
},
"ipranges": {
"base_url": {"href": "https://<consoleFQDN:port>/st/console/api/v1.0/ipranges"}
"base_url": {"href": "https://<consoleFQDN:port>/st/console/api/v1.0/ipranges"},
"get": {
"all": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/ipranges",
"params": None,
"request_body": None,
"response": (list, ResponseModels.IPRange),
},
"one": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/ipranges/{id}",
"params": None,
"request_body": None,
"response": ResponseModels.IPRange,
},
},
},
"deploymentconfigurations": {
"base_url": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/linux/patch/"
"deploymentconfigurations"
}
},
"get": {
"all": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/linux/patch/"
"deploymentconfigurations",
"params": [
{"createdByMe": {"type": bool, "default": None}},
{"name": {"type": str, "default": None}},
],
"request_body": None,
"response": (list, ResponseModels.LinuxPatchDeploymentConfiguration),
},
"one": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/linux/patch/"
"deploymentconfigurations/{id}",
"params": None,
"request_body": None,
"response": ResponseModels.LinuxPatchDeploymentConfiguration,
},
"usedBy": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/linux/patch/"
"deploymentconfigurations/{id}/usedby",
"params": None,
"request_body": None,
"response": ResponseModels.NotImplementedModel,
},
},
"post": {
"one": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/linux/patch/"
"deploymentconfigurations",
"params": None,
"request_body": RequestModels.LinuxDeployConfig,
"response": ResponseModels.LinuxPatchDeploymentConfiguration,
},
},
"delete": {
"one": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/linux/patch/"
"deploymentconfigurations/{id}",
"params": None,
"request_body": None,
"response": ResponseModels.SuccessCode,
},
},
"put": {
"one": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/linux/patch/"
"deploymentconfigurations/{id}",
"params": None,
"request_body": RequestModels.LinuxDeployConfig,
"response": ResponseModels.SuccessCode,
},
},
},
"scanconfigurations": {
"base_url": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/linux/patch/' \
'scanconfigurations"
}
},
"get": {
"all": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/linux/patch/' \
'scanconfigurations",
"params": [
{"createdByMe": {"type": bool, "default": None}},
{"name": {"type": str, "default": None}},
],
"request_body": None,
"response": (list, ResponseModels.LinuxPatchScanConfiguration),
},
"one": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/linux/patch/' \
'scanconfigurations/{id}",
"params": None,
"request_body": None,
"response": ResponseModels.LinuxPatchScanConfiguration,
},
"usedBy": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/linux/patch/' \
'scanconfigurations/{id}/usedby",
"params": None,
"request_body": None,
"response": ResponseModels.LinuxPatchScanConfigUsedBy,
},
},
"post": {
"one": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/linux/patch/' \
'scanconfigurations",
"params": None,
"request_body": RequestModels.LinuxPatchScanConfig,
"response": ResponseModels.LinuxPatchScanConfiguration,
},
},
"delete": {
"one": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/linux/patch/' \
'scanconfigurations/{id}",
"params": None,
"request_body": None,
"response": ResponseModels.SuccessCode,
},
},
"put": {
"one": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/linux/patch/' \
'scanconfigurations/{id}",
"params": None,
"request_body": RequestModels.LinuxPatchScanConfig,
"response": ResponseModels.SuccessCode,
},
},
},
"machinegroups": {
"base_url": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/machinegroups"
}
},
"get": {
"all": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/machinegroups",
"params": {
"count": {"type": int, "default": 10},
"name": {"type": str, "default": None},
"start": {"type": int, "default": None},
"path": {"type": str, "default": None},
},
"request_body": None,
"response": (list, ResponseModels.MachineGroup),
},
"one": {
"href": "https://<consoleFQDN:port>/st/console/api/v1.0/machinegroups/{id}",
"params": None,
"request_body": None,
"response": ResponseModels.MachineGroup,
},
},
},
"machines": {
"base_url": {"href": "https://<consoleFQDN:port>/st/console/api/v1.0/machines"}
Expand Down
111 changes: 111 additions & 0 deletions src/isecapipy/response_models/response_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,117 @@ class LinuxPatchMetadata(BaseModel):
# Linux Patch Scan Configuration ------------------------------------


class LinuxPathScanFilter(BaseModel):
"""The REST API data model for Linux patch scan filter"""

patchGroupIds: List[int]
patchTypeSeverities: str # Enum - None(0)
# Enum - SecurityUnassigned(1)
# Enum - SecurityCritical(2)
# Enum - SecurityImportant(4)
# Enum - SecurityModerate(8)
# Enum - SecurityLow(16)
# Enum - BugFix(32)
# Enum - Enhancement(64)


class LinuxPatchScanConfiguration(BaseModel):
"""The REST API data model for Linux patch scan configuration"""

createdBy: str
description: str
filter: LinuxPathScanFilter
id: str
isSystem: bool
links: Dict[str, Dict[str, str]]
name: str
path: str


class LinuxPatchScanConfigUsedBy(BaseModel):
"""The REST API data model for Linux patch scan - used by"""

name: str
usageType: str # Enum


# Machine Groups ----------------------------------------------------


class DiscoveryFilterType(BaseModel):
"""The REST API data model for discovery filter types"""

machineName: int
domain: int
IpAddress: int
IpRange: int
machineFile: int
domainFile: int
IpRangeFile: int
IpAddressFile: int
organizationalUnit: int
nestedGroup: int
virtualServerWildcard: int


class DiscoveryFilters(BaseModel):
"""The REST API data model for discovery filters"""

adminCredentialId: str
category: DiscoveryFilterType
containerCredentialId: str
id: int
IncludeChildOU: bool
isExcluded: bool
links: Dict[str, Dict[str, str]]
name: str
nestedGroupId: int
notes: str


class VirtDiscoveryFilterType(DiscoveryFilterType):
virtualServerCenterHostedOfflineSystem: int
offlineDirectory: Optional[int]
offlineImage: Optional[int]


class VirtualMachineDiscoveryFilter(BaseModel):
"""The REST API data model for virtual machine discovery filters"""

adminCredentialId: str
category: VirtDiscoveryFilterType
id: int
InventoryPath: str
links: Dict[str, Dict[str, str]]
note: str
serverName: str


class ServerFilterTypes(BaseModel):
workstation: int
server: int
sqlServer: int
domainController: int
printServer: int
iisServer: int


class MachineGroup(BaseModel):
connectionMethod: str # Enum
creator: str
credentialId: str
description: str
discoveryFilters: List[DiscoveryFilters]
id: str
isBuiltIn: bool
isReadOnly: bool
links: Dict[str, Dict[str, str]]
name: str
path: str
serverFilterTypes: List[ServerFilterTypes]
virtualMachineDiscoveryFilters: List[VirtualMachineDiscoveryFilter]


# NOT IMPLIMENTED OR NEEDS TESTING (ISEC DOCS INCOMPLETE)


Expand Down

0 comments on commit 6124a51

Please sign in to comment.