Skip to content

Commit

Permalink
feat(scanning): Add list all image tags method (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
tembleking committed May 7, 2021
1 parent 1a933a8 commit c554f9f
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
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")))

0 comments on commit c554f9f

Please sign in to comment.