-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #217 from 0x41424142/patching
add pm.get_patch_catalog, CLI get_patch_catalog, sql.upload_pm_patch_catalog
- Loading branch information
Showing
13 changed files
with
447 additions
and
29 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
from dataclasses import dataclass | ||
from datetime import datetime | ||
from typing import Union | ||
|
||
from ...base.base_class import BaseClass | ||
from ...base.base_list import BaseList | ||
|
||
DT_FIELDS = [ | ||
"syncDateTime", | ||
"modifiedDate", | ||
"publishedDate", | ||
] | ||
|
||
BL_STR_FIELDS = [ | ||
"appFamily", | ||
"product", | ||
"qid", | ||
"supersedes", | ||
"cve", | ||
"architecture", | ||
"supersededBy", | ||
"supportedOs", | ||
] | ||
|
||
|
||
@dataclass | ||
class PackageDetail(BaseClass): | ||
""" | ||
Linux package details. | ||
""" | ||
|
||
packageName: str = None | ||
architecture: str = None | ||
|
||
def __str__(self): | ||
return f"{self.packageName} ({self.architecture})" | ||
|
||
|
||
@dataclass | ||
class CatalogPatch(BaseClass): | ||
""" | ||
A data class representing a patch in the Qualys Patch Management catalog. | ||
""" | ||
|
||
patchId: str = None | ||
id: str = None | ||
title: str = None | ||
type: str = None | ||
appFamily: BaseList[str] = None | ||
vendor: str = None | ||
product: BaseList[str] = None | ||
platform: str = None | ||
kb: str = None | ||
isSuperseded: bool = None | ||
isSecurity: bool = None | ||
isRollback: bool = None | ||
servicePack: bool = None | ||
advisory: str = None | ||
vendorlink: str = None | ||
osIdentifier: str = None | ||
advisoryLink: str = None | ||
deleted: bool = None | ||
rebootRequired: bool = None | ||
vendorSeverity: str = None | ||
description: str = None | ||
qid: BaseList[int] = None | ||
enabled: bool = None | ||
downloadMethod: str = None | ||
supportedOs: str = None | ||
supersedes: BaseList[str] = None | ||
notification: str = None | ||
cve: BaseList[str] = None | ||
architecture: BaseList[str] = None | ||
packageDetails: BaseList[PackageDetail] = None | ||
patchFeedProviderId: int = None | ||
syncDateTime: Union[int, datetime] = None | ||
vendorPatchId: Union[str, int] = None | ||
modifiedDate: Union[int, datetime] = None | ||
publishedDate: Union[int, datetime] = None | ||
category: str = None | ||
isEsuPatch: bool = None | ||
supersededBy: BaseList[str] = None | ||
bulletin: str = None | ||
|
||
def __post_init__(self): | ||
for field in DT_FIELDS: | ||
if getattr(self, field): | ||
try: | ||
setattr( | ||
self, | ||
field, | ||
datetime.fromtimestamp(getattr(self, field) / 1000), | ||
) | ||
except (TypeError, OSError): | ||
setattr(self, field, None) | ||
|
||
for field in BL_STR_FIELDS: | ||
if getattr(self, field): | ||
setattr(self, field, BaseList(getattr(self, field))) | ||
|
||
if self.notification: | ||
print( | ||
"CatalogPatch's notification attribute is currently not parsed and is set to a string. Please submit a PR adding the functionality to parse this attribute." | ||
) | ||
setattr(self, "notification", str(self.notification)) | ||
|
||
if self.packageDetails: | ||
bl = BaseList() | ||
for pd in self.packageDetails: | ||
bl.append(PackageDetail(**pd)) | ||
setattr(self, "packageDetails", bl) |
This file contains 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
Oops, something went wrong.