Skip to content
This repository was archived by the owner on May 7, 2026. It is now read-only.

SSPROD-2210: Added import_image and anchore_account to SDC CLI#100

Merged
yathi-sysdig merged 1 commit into
masterfrom
SSPROD-2210
Oct 9, 2019
Merged

SSPROD-2210: Added import_image and anchore_account to SDC CLI#100
yathi-sysdig merged 1 commit into
masterfrom
SSPROD-2210

Conversation

@yathi-sysdig
Copy link
Copy Markdown
Contributor

@yathi-sysdig yathi-sysdig commented Sep 5, 2019

Usage

Anchore User Account

from sdcclient._scanning import SdScanningClient
client = SdScanningClient('<token>', 'http://localhost:9040')
print(client.get_anchore_users_account())
[True, {'created_at': '2019-08-12T23:41:58Z', 'email': None, 'last_updated': '2019-08-12T23:41:58Z', 'name': 'tenant_1PLVMqZvrKDcMVRDTDtUL4dOki4', 'state': 'enabled', 'type': 'user'}]

This PR implements import_image and accounts API needed to do inline-scanning. Currently it is in a bash script here https://github.com/sysdiglabs/secure-inline-scan/blob/inline-scan/inline_scan.sh#L463

Import Image

from sdcclient._scanning import SdScanningClient
client = SdScanningClient('<token>', 'http://localhost:9040')
print(client.get_anchore_users_account())
[True, {'created_at': '2019-08-12T23:41:58Z', 'email': None, 'last_updated': '2019-08-12T23:41:58Z', 'name': 'tenant_1PLVMqZvrKDcMVRDTDtUL4dOki4', 'state': 'enabled', 'type': 'user'}]

Comment thread sdcclient/_scanning.py
except Exception as err:
print(err)

def get_anchore_users_account(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can this function be useful? Asking only because I have not much context about it (it may be useful to add more color in the description for other users as well).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API is needed to fetch the username for running inline-scan. The script uses this API here https://github.com/sysdiglabs/secure-inline-scan/blob/inline-scan/inline_scan.sh#L434

Comment thread sdcclient/_scanning.py

return [True, res.content]

def import_image(self, infile):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any example (maybe not just using this function) to show how this functionality can be used? I think it can expose very interesting use cases.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davideschiera this function is part of the inline-scan solution which is currently in a bash script. This function essentially implements the import image API being used in the script here https://github.com/sysdiglabs/secure-inline-scan/blob/inline-scan/inline_scan.sh#L463

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can an example (similar to examples/get_anchore_users_account.py) show how to import an image and then do something with it (eg. scan it)?

I was imagine something like that, but I'm not sure if it can be meaningful or useful.

Copy link
Copy Markdown
Contributor

@davideschiera davideschiera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of notes about more examples and info, and a minor renaming.

Nothing that seems blocker for the PR. I'll leave if/when address the comments up to you ;-)

Thanks!

Comment thread sdcclient/_scanning.py
except Exception as err:
print(err)

def get_anchore_users_account(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: get_anchore_user_account or get_anchore_user_account_details may be more appropriate.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@yathi-sysdig yathi-sysdig merged commit cfe47d0 into master Oct 9, 2019
@tembleking tembleking deleted the SSPROD-2210 branch August 10, 2020 13:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants