Skip to content

Commit c554f9f

Browse files
authored
feat(scanning): Add list all image tags method (#191)
1 parent 1a933a8 commit c554f9f

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

sdcclient/_scanning.py

+13
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,19 @@ def list_images(self):
105105

106106
return [True, res.json()]
107107

108+
def list_image_tags(self):
109+
"""
110+
Lists the current set of image tags in the scanner.
111+
112+
Returns: A JSON object containing all the image tags.
113+
"""
114+
url = self.url + "/api/scanning/v1/anchore/summaries/imagetags"
115+
res = self.http.get(url, headers=self.hdrs, verify=self.ssl_verify)
116+
if not self._checkResponse(res):
117+
return [False, self.lasterr]
118+
119+
return [True, res.json()]
120+
108121
def list_whitelisted_cves(self):
109122
'''**Description**
110123
List the whitelisted global CVEs.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import os
2+
3+
from expects import expect, contain, have_keys
4+
from mamba import before, description, it
5+
6+
from sdcclient import SdScanningClient
7+
from specs import be_successful_api_call
8+
9+
with description("Scanning list_image_tags") as self:
10+
with before.all:
11+
self.client = SdScanningClient(sdc_url=os.getenv("SDC_SECURE_URL", "https://secure.sysdig.com"),
12+
token=os.getenv("SDC_SECURE_TOKEN"))
13+
14+
with it("is able to retrieve all the image tags"):
15+
ok, res = self.client.list_image_tags()
16+
17+
expect((ok, res)).to(be_successful_api_call)
18+
expect(res).to(
19+
contain(have_keys("analyzed_at", "created_at", "fulltag", "imageDigest", "imageId", "parentDigest",
20+
"tag_detected_at", "analysis_status")))
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import os
2+
3+
from expects import expect, contain, have_keys
4+
from mamba import before, description, it
5+
6+
from sdcclient import SdScanningClient
7+
from specs import be_successful_api_call
8+
9+
with description("Scanning list_images") as self:
10+
with before.all:
11+
self.client = SdScanningClient(sdc_url=os.getenv("SDC_SECURE_URL", "https://secure.sysdig.com"),
12+
token=os.getenv("SDC_SECURE_TOKEN"))
13+
with it("is able to list all the scanned images"):
14+
ok, res = self.client.list_images()
15+
16+
expect((ok, res)).to(be_successful_api_call)
17+
expect(res).to(contain(
18+
have_keys("annotations", "imageDigest", "last_updated", "analysis_status", "image_content", "image_detail",
19+
"image_status", "parentDigest", "userId", "created_at")))

0 commit comments

Comments
 (0)