Registry credentials
To scan a private image, Image Scan needs a registry login. It only pulls the image: it never pushes, changes or deletes anything. So the credential should allow only that.
| Rule | Why |
|---|---|
| Read-only (pull). No push, delete or admin | If the credential leaks, nobody can publish a tampered image to your registry |
| Only the repositories that will be scanned, when the registry allows it | Limits exposure to what Leavory actually needs |
A credential dedicated to Leavory, with a name like leavory-image-scan |
You can revoke it without affecting anything else, and tell where each access came from in the registry logs |
| Never your personal password, the registry admin user or the token your pipeline uses to push | Those credentials allow much more than pulling images |
| With an expiration date, when the registry allows it | A forgotten credential stops working on its own |
| Revoke it when you remove the registry from Image Scan | An unused credential is only risk |
What Leavory does with the credential
Section titled “What Leavory does with the credential”- Tests the login before saving. If the registry refuses it, nothing is stored.
- Stores the password or token encrypted. The screen never shows the value again.
- Uses the credential only to pull the images you added, in the first scan, the daily scan and Rescan.
Minimum scope per registry
Section titled “Minimum scope per registry”| Registry | Credential | Minimum scope | Can it be limited to repositories? |
|---|---|---|---|
| Docker Hub | Personal access token | Read-only | Not with a personal token; yes with an organization access token (Team and Business plans) |
GitHub (ghcr.io) |
Personal access token (classic) | only read:packages |
No: it reads every package the user can see. Use a machine user |
| Quay | Robot account | Read | Yes, per repository |
| GitLab | Deploy token | only read_registry |
Yes: create it on the project, not the group |
| Azure Container Registry | Token | content/read + metadata/read |
Yes, with a custom scope map |
| Google Artifact Registry / GCR | Service account JSON key | Artifact Registry Reader role | Yes: grant the role on the repository, not the project |
Step by step
Section titled “Step by step”Docker Hub
Section titled “Docker Hub”- Account settings → Personal access tokens → Generate new token.
- Access permissions: Read-only. Don’t use Read & Write or Read, Write, Delete.
- Set an expiration date and generate the token.
- In Image Scan: Username = your Docker Hub user; Access token = the token.
If your company has Docker Team or Business, prefer an organization access token with read access only to the repositories that will be scanned.
GitHub Container Registry (ghcr.io)
Section titled “GitHub Container Registry (ghcr.io)”- Settings → Developer settings → Personal access tokens → Tokens (classic) → Generate new token (classic).
- Check only
read:packages. Don’t checkwrite:packages,delete:packagesorrepo. - Set an expiration and generate the token.
- In Image Scan: Username = the GitHub user; Access token = the token.
- In the organization: Robot Accounts → Create Robot Account, named
leavory_image_scan. - Grant Read permission only on the repositories that will be scanned.
- In Image Scan: Username = the robot’s full name (
<organization>+leavory_image_scan); Access token = the robot token.
GitLab
Section titled “GitLab”- In the project that holds the images: Settings → Repository → Deploy tokens → Add token.
- Check only
read_registryand set an expiration date. - In Image Scan: Username = the deploy token’s generated user; Access token = the token.
Prefer the project deploy token. A group deploy token reads the registry of every project in the group.
Azure Container Registry
Section titled “Azure Container Registry”Don’t use the ACR Admin user: it has full access to the registry.
- In the ACR: Repository permissions → Scope maps → Add.
- Choose only the repositories that will be scanned and check
content/readandmetadata/readon each. - Repository permissions → Tokens → Add, named
leavory-image-scan, with the scope map you created. - Generate a token password with an expiration date.
- In Image Scan: Username = the token name; Access token = the generated password.
The built-in _repositories_pull scope map is also read-only, but it covers every repository in the registry.
Use it only if all of them should be scanned.
Google Artifact Registry and GCR
Section titled “Google Artifact Registry and GCR”- Create a dedicated service account, such as
leavory-image-scan. - On the Artifact Registry repository (not the whole project), grant it the Artifact Registry Reader role
(
roles/artifactregistry.reader). - On the service account: Keys → Add key → JSON.
- In Image Scan: Username =
_json_key; Password = the entire content of the JSON file.
The JSON key doesn’t expire on its own. Note the date and rotate the key periodically.
Rotate or revoke a credential
Section titled “Rotate or revoke a credential”- Create the new credential in the registry.
- In Image Scan, save the login again for the same registry: the new one replaces the old only after it passes the test.
- Revoke the old credential in the registry.
To stop scanning images from a registry, remove the login in Image Scan and revoke the credential in the registry.