Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support Image Summary API in python sdk #173

Merged
merged 2 commits into from
Mar 22, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
LW_API_SECRET: ${{ secrets.LW_API_SECRET }}
LW_BASE_DOMAIN: ${{ secrets.LW_BASE_DOMAIN }}
- name: Report Status
if: contains(github.ref, "main")
if: github.ref_name == 'main'
uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ job.status }}
Expand Down
7 changes: 7 additions & 0 deletions laceworksdk/api/v2/vulnerabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(self, session):
self.containers = self.ContainerVulnerabilitiesAPI(session, self._base_path)
self.hosts = self.HostVulnerabilitiesAPI(session, self._base_path)
self.packages = self.SoftwarePackagesAPI(session, self._base_path)
self.imageSummary = self.ImageSummaryVulnerabilitiesAPI(session, self._base_path)

class ContainerVulnerabilitiesAPI(SearchEndpoint):
"""A class used to represent the Container Vulnerabilities API endpoint."""
Expand Down Expand Up @@ -90,6 +91,12 @@ def status(self, request_id):
)

return response.json()

class ImageSummaryVulnerabilitiesAPI(SearchEndpoint):
"""A class used to represent the ImageSummary Vulnerabilities API endpoint."""

RESOURCE = "ImageSummary"


class HostVulnerabilitiesAPI(SearchEndpoint):
"""A class used to represent the Host Vulnerabilities API endpoint."""
Expand Down
16 changes: 15 additions & 1 deletion tests/api/v2/test_vulnerabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class TestVulnerabilitesEndpoint(SearchEndpoint):
OBJECT_TYPE = VulnerabilitiesAPI
OBJECT_MAP = {
"containers": VulnerabilitiesAPI.ContainerVulnerabilitiesAPI,
"hosts": VulnerabilitiesAPI.HostVulnerabilitiesAPI
"hosts": VulnerabilitiesAPI.HostVulnerabilitiesAPI,
"imageSummary": VulnerabilitiesAPI.ImageSummaryVulnerabilitiesAPI
}

def test_vulnerabilities_containers_api_scan(self, api_object, request):
Expand Down Expand Up @@ -67,3 +68,16 @@ def test_vulnerabilities_packages_api_scan(api, api_object):
"pkgVer": "1.1.1-1ubuntu2.1~20.04"
}])
assert "data" in response.keys()

def test_vulnerabilities_image_summary_search(api, api_object):
json = {
"timeFilter": {
"startTime": "2024-03-18T00:00:00Z",
"endTime": "2024-03-19T08:00:00Z"
},
"filters" : [
{"field": "ndvContainers", "expression": "gt", "value": 0}
]
}
response = api_object.imageSummary.search(json)
assert "data" in next(response, None)
Loading