Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Add a script to detect all of local Images and then scan them #2

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ $ docker-index sbom --image <IMAGE>
* `--oci-dir <DIR>` can point to a local image in OCI directory format
* `--output <OUTPUT FILE>` allows to store the generated SBOM in a local file
* `--include-cves` will include all detected CVEs in generated output
### `scanner.sh`

To scan all of local images , use the following command:
```shell
./checker.sh
```

### `docker-index cve`

Expand Down
Binary file added docker-index
Binary file not shown.
31 changes: 31 additions & 0 deletions scanner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
#written by rezshar
#The easiest way to scan all local images
./docker-index 2>&1 > /dev/null
Val1=$(echo $?)
if [ "$?" -ne 0 ]
then
echo "Installing docker-index"
echo "please wait ..."
./install.sh
# else
# echo "OK!"
fi

if [ ! -d /var/lib/docker/image/overlay2/imagedb/content/sha256/ ]; then

Choose a reason for hiding this comment

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

it seems that the docker-index would also work well with the short hash of docker images -aq
so you could just iterate over like this:

for i in $(docker images -qa); do docker-index cve --image "$i" DSA-2022-0001; done

assuming you have docker-index in your PATH.

DOCKERPATH=$(docker info | grep "Docker Root Dir" | sed 's/^.*: //')
ls $DOCKERPATH/image/overlay2/imagedb/content/sha256/ -1 > temp
else
ls /var/lib/docker/image/overlay2/imagedb/content/sha256/ -1 > temp
fi

file="temp"
while read -r line
do
printf 'Line: %s\n' "$line"
current=$line
echo "Scanning $current"
./docker-index cve --image "$current" DSA-2022-0001
echo "Lets go for another Images :)"
done < $file
echo "Enjoy"