Skip to content

feat(scanning): Add list all image tags method #191

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

Merged
merged 1 commit into from
May 7, 2021
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
13 changes: 13 additions & 0 deletions sdcclient/_scanning.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,19 @@ def list_images(self):

return [True, res.json()]

def list_image_tags(self):
"""
Lists the current set of image tags in the scanner.

Returns: A JSON object containing all the image tags.
"""
url = self.url + "/api/scanning/v1/anchore/summaries/imagetags"
res = self.http.get(url, headers=self.hdrs, verify=self.ssl_verify)
if not self._checkResponse(res):
return [False, self.lasterr]

return [True, res.json()]

def list_whitelisted_cves(self):
'''**Description**
List the whitelisted global CVEs.
Expand Down
20 changes: 20 additions & 0 deletions specs/secure/scanning/list_image_tags_spec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import os

from expects import expect, contain, have_keys
from mamba import before, description, it

from sdcclient import SdScanningClient
from specs import be_successful_api_call

with description("Scanning list_image_tags") as self:
with before.all:
self.client = SdScanningClient(sdc_url=os.getenv("SDC_SECURE_URL", "https://secure.sysdig.com"),
token=os.getenv("SDC_SECURE_TOKEN"))

with it("is able to retrieve all the image tags"):
ok, res = self.client.list_image_tags()

expect((ok, res)).to(be_successful_api_call)
expect(res).to(
contain(have_keys("analyzed_at", "created_at", "fulltag", "imageDigest", "imageId", "parentDigest",
"tag_detected_at", "analysis_status")))
19 changes: 19 additions & 0 deletions specs/secure/scanning/list_images_spec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os

from expects import expect, contain, have_keys
from mamba import before, description, it

from sdcclient import SdScanningClient
from specs import be_successful_api_call

with description("Scanning list_images") as self:
with before.all:
self.client = SdScanningClient(sdc_url=os.getenv("SDC_SECURE_URL", "https://secure.sysdig.com"),
token=os.getenv("SDC_SECURE_TOKEN"))
with it("is able to list all the scanned images"):
ok, res = self.client.list_images()

expect((ok, res)).to(be_successful_api_call)
expect(res).to(contain(
have_keys("annotations", "imageDigest", "last_updated", "analysis_status", "image_content", "image_detail",
"image_status", "parentDigest", "userId", "created_at")))